r36032 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36031‎ | r36032 | r36033 >
Date:16:59, 8 June 2008
Author:mkroetzsch
Status:old
Tags:
Comment:
Extra parameter in templated result formatters, Bug 14440
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_List.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Template.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_List.php
@@ -18,6 +18,7 @@
1919
2020 protected $mSep = '';
2121 protected $mTemplate = '';
 22+ protected $mUserParam = '';
2223
2324 protected function readParameters($params,$outputmode) {
2425 SMWResultPrinter::readParameters($params,$outputmode);
@@ -31,6 +32,9 @@
3233 if (array_key_exists('template', $params)) {
3334 $this->mTemplate = trim($params['template']);
3435 }
 36+ if (array_key_exists('userparam', $params)) {
 37+ $this->mUserParam = trim($params['userparam']);
 38+ }
3539 }
3640
3741 protected function getResultText($res,$outputmode) {
@@ -84,7 +88,7 @@
8589
8690 $first_col = true;
8791 if ($usetemplate) { // build template code
88 - $wikitext = '';
 92+ $wikitext = ($this->mUserParam)?"|userparam=$this->mUserParam":'';
8993 $i = 1; // explicitly number parameters for more robust parsing (values may contain "=")
9094 foreach ($row as $field) {
9195 $wikitext .= '|' . $i++ . '=';
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QP_Template.php
@@ -13,6 +13,7 @@
1414 class SMWTemplateResultPrinter extends SMWResultPrinter {
1515
1616 protected $m_template;
 17+ protected $m_userparam;
1718
1819 protected function readParameters($params,$outputmode) {
1920 SMWResultPrinter::readParameters($params,$outputmode);
@@ -22,6 +23,12 @@
2324 } else {
2425 $this->m_template = false;
2526 }
 27+
 28+ if (array_key_exists('userparam', $params)) {
 29+ $this->m_userparam = trim($params['userparam']);
 30+ } else {
 31+ $this->m_userparam = false;
 32+ }
2633 }
2734
2835 protected function getResultText($res, $outputmode) {
@@ -41,14 +48,14 @@
4249 $parserinput = $this->mIntro;
4350 while ( $row = $res->getNext() ) {
4451 $i = 1; // explicitly number parameters for more robust parsing (values may contain "=")
45 - $wikitext = '';
 52+ $wikitext = ($this->m_userparam)?"|userparam=$this->m_userparam":'';
4653 $firstcol = true;
4754 foreach ($row as $field) {
4855 $wikitext .= '|' . $i++ . '=';
4956 $first = true;
5057 while ( ($text = $field->getNextText(SMW_OUTPUT_WIKI, $this->getLinker($firstcol))) !== false ) {
5158 if ($first) {
52 - $first = false;
 59+ $first = false;
5360 } else {
5461 $wikitext .= ', ';
5562 }

Status & tagging log