Skip to content

Commit

Permalink
Merge pull request #217 from SemanticMediaWiki/queryprinter-listprinter
Browse files Browse the repository at this point in the history
ListResultPrinter add extra information to the template output
  • Loading branch information
JeroenDeDauw committed Mar 10, 2014
2 parents 2832ef7 + a3d6e51 commit cbf79f5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions includes/queryprinters/ListResultPrinter.php
Expand Up @@ -160,15 +160,15 @@ protected function getResultText( SMWQueryResult $queryResult, $outputmode ) {
$result .= $this->header;

if ( $this->mIntroTemplate !== '' ) {
$result .= "{{" . $this->mIntroTemplate . "}}";
$result .= "{{" . $this->mIntroTemplate . $this->addCommonTemplateParameters( $queryResult ) . "}}";
}

while ( $row = $queryResult->getNext() ) {
$result .= $this->getRowText( $row, $queryResult );
}

if ( $this->mOutroTemplate !== '' ) {
$result .= "{{" . $this->mOutroTemplate . "}}";
$result .= "{{" . $this->mOutroTemplate . $this->addCommonTemplateParameters( $queryResult ) . "}}";
}

// Make label for finding further results
Expand Down Expand Up @@ -271,7 +271,7 @@ protected function getRowText( array $row, SMWQueryResult $res ) {

if ( $this->mTemplate !== '' ) { // Build template code
$this->hasTemplates = true;
$content = $this->mTemplate . $this->getTemplateContent( $row );
$content = $this->mTemplate . $this->getTemplateContent( $row ) . $this->addCommonTemplateParameters( $res );
$result .= $this->getRowStart( $res ) . '{{' . $content . '}}';
} else { // Build simple list
$content = $this->getRowListContent( $row );
Expand Down Expand Up @@ -387,7 +387,7 @@ protected function getRowListContent( array $row ) {
* @return string
*/
protected function getTemplateContent( $row ){
$wikitext = $this->mUserParam ? "|userparam=$this->mUserParam" : '';
$wikitext = '';

foreach ( $row as $i => $field ) {
$wikitext .= '|' . ( $this->mNamedArgs ? '?' . $field->getPrintRequest()->getLabel() : $i + 1 ) . '=';
Expand All @@ -407,6 +407,11 @@ protected function getTemplateContent( $row ){
return $wikitext;
}

protected function addCommonTemplateParameters( $queryResult ) {
return ( $this->mUserParam ? "|userparam=$this->mUserParam" : '' ) .
"|swm-resultquerycondition=" . $queryResult->getQuery()->getQueryString();
}

/**
* Get text for further results link. Used only during getResultText().
*
Expand Down

0 comments on commit cbf79f5

Please sign in to comment.