Skip to content

Commit

Permalink
[Filtered] added "list view userparam" (#631)
Browse files Browse the repository at this point in the history
closes #629 
* added "list view userparam" to Filtered format
* added additional tests for list view specific parameter
  • Loading branch information
gesinn-it-gea committed Jan 26, 2021
1 parent 670487b commit de70e7a
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 2 deletions.
13 changes: 11 additions & 2 deletions formats/filtered/src/View/ListView.php
Expand Up @@ -40,6 +40,7 @@ protected function handleParameters() {
$this->mIntroTemplate = $params['list view introtemplate'];
$this->mOutroTemplate = $params['list view outrotemplate'];
$this->mNamedArgs = $params['list view named args'];
$this->mUserParam = $params['list view userparam'];

$this->mShowHeaders = $params['headers'];
}
Expand Down Expand Up @@ -124,8 +125,8 @@ protected function printRow( $row, &$rownum, $rowstart, $rowend, &$result, $list
if ( $this->mTemplate !== '' ) { // build template code
$this->getQueryPrinter()->hasTemplates( true );

// $wikitext = ( $this->mUserParam ) ? "|userparam=$this->mUserParam" : '';
$wikitext = '';
$wikitext = ( $this->mUserParam ) ? "|#userparam=$this->mUserParam" : '';
//$wikitext = '';

foreach ( $row as $fieldNumber => $field ) {

Expand Down Expand Up @@ -257,6 +258,14 @@ public static function getParameters() {
// 'islist' => false,
];

$params[] = [
//'type' => 'string',
'name' => 'list view userparam',
'message' => 'srf-paramdesc-filtered-list-userparam',
'default' => '',
// 'islist' => false,
];

return $params;
}

Expand Down
1 change: 1 addition & 0 deletions i18n/en.json
Expand Up @@ -242,6 +242,7 @@
"srf-paramdesc-filtered-filter-position": "The position of the filters in relation to the views. Allowed values: \"top\", \"bottom\". Default: \"top\".",
"srf-paramdesc-filtered-list-type": "The type of the list. Allowed values: \"list\", \"ul\", \"ol\". Default: \"list\".",
"srf-paramdesc-filtered-list-template": "The template that is to be used to format the list entries.",
"srf-paramdesc-filtered-list-userparam": "The userparam that is passed to the template.",
"srf-paramdesc-filtered-list-named-args": "Name the arguments passed to the template.",
"srf-paramdesc-filtered-list-introtemplate": "The name of a template to display before the query results, if there are any.",
"srf-paramdesc-filtered-list-outrotemplate": "The name of a template to display after the query results, if there are any.",
Expand Down
1 change: 1 addition & 0 deletions i18n/qqq.json
Expand Up @@ -258,6 +258,7 @@
"srf-paramdesc-filtered-filter-position": "{{doc-paramdesc|filter position}}\n{{doc-important|Do not translate the parameter values \"top\" and \"bottom\".}}",
"srf-paramdesc-filtered-list-type": "{{doc-paramdesc|list view type}}\n{{doc-important|Do not translate the parameter values \"list\", \"ul\" and \"ol\"}}",
"srf-paramdesc-filtered-list-template": "{{doc-paramdesc|list view template}}",
"srf-paramdesc-filtered-list-userparam": "{{doc-paramdesc|list view userparam}}",
"srf-paramdesc-filtered-list-named-args": "{{doc-paramdesc|list view named args}}\n\nSee this page for [https://www.semantic-mediawiki.org/wiki/Help:Template_format#Usage_for_named_args detailed information on named argruments].",
"srf-paramdesc-filtered-list-introtemplate": "{{doc-paramdesc|list view introtemplate}}\n\nSimilar to {{msg-mw|srf-paramdesc-filtered-list-outrotemplate}}.",
"srf-paramdesc-filtered-list-outrotemplate": "{{doc-paramdesc|list view outrotemplate}}\n\nSimilar to {{msg-mw|srf-paramdesc-filtered-list-introtemplate}}.",
Expand Down
104 changes: 104 additions & 0 deletions tests/phpunit/Integration/JSONScript/TestCases/filtered-03.json
@@ -0,0 +1,104 @@
{
"description": "Filtered format: List view tests",
"setup": [
{
"namespace": "SMW_NS_PROPERTY",
"page": "Filtered test/City name",
"contents": "[[Has type::Text]]"
},

{
"namespace": "NS_TEMPLATE",
"page": "City",
"contents": "[[Category:Filtered test]][[Category:City]][[Filtered test/City name::{{{Name|}}}]]"
},

{
"namespace": "NS_TEMPLATE",
"page": "RT City",
"contents": "Name: {{{1|}}}"
},
{
"namespace": "NS_TEMPLATE",
"page": "RT City Intro",
"contents": "INTRO"
},
{
"namespace": "NS_TEMPLATE",
"page": "RT City Outro",
"contents": "OUTRO"
},
{
"namespace": "NS_TEMPLATE",
"page": "RT City Userparam",
"contents": "{{{#userparam}}}"
},

{
"page": "Filtered test/Berlin",
"contents": "{{City|Name=Berlin}}"
},
{
"page": "Example/Filtered 03-01",
"contents": "{{#ask:[[Category:Filtered test]] |?Filtered test/City name |format=filtered |views=list |list view template=RT City |link=none}}"
},
{
"page": "Example/Filtered 03-02",
"contents": "{{#ask:[[Category:Filtered test]] |?Filtered test/City name |format=filtered |views=list |list view userparam=USERPARAM |list view template=RT City Userparam |link=none}}"
},
{
"page": "Example/Filtered 03-03",
"contents": "{{#ask:[[Category:Filtered test]] |?Filtered test/City name |format=filtered |views=list |list view template=RT City |list view introtemplate=RT City Intro |list view outrotemplate=RT City Outro |link=none}}"
}
],
"tests": [
{
"type": "parser",
"about": "Filtered 03-01 (List view: template)",
"subject": "Example/Filtered 03-01",
"assert-output": {
"to-be-valid-html": 1,
"to-contain": [
"Name: Filtered test/Berlin"
]
}
},

{
"type": "parser",
"about": "Filtered 03-02 (List view: template with userparam)",
"subject": "Example/Filtered 03-02",
"assert-output": {
"to-be-valid-html": 1,
"to-contain": [
"USERPARAM"
]
}
},

{
"type": "parser",
"about": "Filtered 03-03 (List view: template with intro/outro template)",
"subject": "Example/Filtered 03-03",
"assert-output": {
"to-be-valid-html": 1,
"to-contain": [
"INTRO", "Name: Filtered test/Berlin", "OUTRO"
]
}
}
],
"settings": {
"wgContLang": "en",
"wgLang": "en",
"smwgNamespacesWithSemanticLinks": {
"NS_MAIN": true,
"SMW_NS_PROPERTY": true
}
},
"meta": {
"version": "2",
"is-incomplete": false,
"debug": false
}
}

0 comments on commit de70e7a

Please sign in to comment.