Skip to content

Commit

Permalink
Remove 'template arguments' parameter (#436)
Browse files Browse the repository at this point in the history
It was introduced for compatibility and can be removed in SRF 3.0
  • Loading branch information
s7eph4n authored and kghbln committed Oct 11, 2018
1 parent dd6e74a commit 158651e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 23 deletions.
3 changes: 2 additions & 1 deletion RELEASE-NOTES.md
Expand Up @@ -7,9 +7,10 @@ This is not a release yet.
* Raised minimum required version of PHP to 5.6
* Raised minimum required version of MediaWiki to 1.27
* Improved filtered format: More options, better test coverage, re-enabled by default (by Stephan Gambke)
* #248 Fixed localization of numbers in the math result formats (by James Hong Kong)
* [#248](https://github.com/SemanticMediaWiki/SemanticResultFormats/pull/248) Fixed localization of numbers in the math result formats (by James Hong Kong)
* [#365](https://github.com/SemanticMediaWiki/SemanticResultFormats/pull/365) Added support for the latest versions of the GraphViz extension
* [#375](https://github.com/SemanticMediaWiki/SemanticResultFormats/pull/375) Fixed exposing of file dimensions in captions for the "gallery" format
* Tree format: Removed `template arguments` parameter
* Added support for installation together with the latest versions of the Maps extension (by Jeroen De Dauw)
* Updated translations (by translatewiki.net community)

Expand Down
6 changes: 2 additions & 4 deletions formats/tree/TreeNodeVisitor.php
Expand Up @@ -152,11 +152,9 @@ protected function getParamNameForCell( $cell, $columnNumber ) {

$label = $cell->getPrintRequest()->getLabel();

if ( $this->configuration['template arguments'] === 'numbered' || ( $label === '' ) ) {
if ( $this->configuration[ 'named args' ] === true || ( $label === '' ) ) {
$paramName = $columnNumber + 1;
} elseif ( $this->configuration['template arguments'] === 'legacy' ) {
$paramName = '?' . $label;
} else { // $this->configuration[ 'template arguments' ] === 'named'
} else {
$paramName = $label;
}

Expand Down
23 changes: 5 additions & 18 deletions formats/tree/TreeResultPrinter.php
Expand Up @@ -73,20 +73,6 @@ protected function postProcessParameters() {
// Don't support pagination in trees
$this->mSearchlabel = null;

if ( array_key_exists( 'template arguments', $this->params )
&& $this->params['template arguments'] !== 'numbered' ) {

if ( filter_var( $this->params['named args'], FILTER_VALIDATE_BOOLEAN ) === true ) {
$this->params['template arguments'] = 'legacy';
} elseif (
$this->params['template arguments'] !== 'named' &&
$this->params['template arguments'] !== 'legacy'
) {
// default
$this->params['template arguments'] = 'numbered';
}
}

// Allow "_" for encoding spaces, as documented
$this->params['sep'] = str_replace( '_', ' ', $this->params['sep'] );

Expand Down Expand Up @@ -177,6 +163,7 @@ public function getTemplateCall( $templateName, $params = [] ) {
* @param $definitions array of IParamDefinition
*
* @return array of IParamDefinition|array
* @throws Exception
*/
public function getParamDefinitions( array $definitions ) {
$params = parent::getParamDefinitions( $definitions );
Expand Down Expand Up @@ -290,11 +277,10 @@ public function getLinkerForColumn( $column ) {
private function initalizeStandardTemplateParameters() {

$query = $this->getQueryResult()->getQuery();
$userparam = trim( $this->params[ 'userparam' ] );

$this->standardTemplateParameters =
( trim( $this->params['userparam'] ) !== '' ? ( '|userparam=' . trim(
$this->params['userparam']
) ) : '' ) .
( $userparam !== '' ? ( '|userparam=' . $userparam ) : '' ) .
'|smw-resultquerycondition=' . $query->getQueryString() .
'|smw-resultquerylimit=' . $query->getLimit() .
'|smw-resultqueryoffset=' . $query->getOffset();
Expand All @@ -306,6 +292,7 @@ private function initalizeStandardTemplateParameters() {
* @param TreeNode[] $nodes
*
* @return TreeNode
* @throws \Exception
*/
protected function buildTreeFromNodeList( $rootHash, $nodes ) {

Expand Down Expand Up @@ -362,7 +349,7 @@ protected function buildLinesFromTree( $tree ) {
'format' => trim( $this->params['format'] ),
'template' => trim( $this->params['template'] ),
'headers' => $this->params['headers'],
'template arguments' => $this->params['template arguments'],
'named args' => $this->params['named args'],
'sep' => $this->params['sep'],
];

Expand Down

0 comments on commit 158651e

Please sign in to comment.