r90353 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90352‎ | r90353 | r90354 >
Date:18:14, 18 June 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
use wgLang->listToText and fixed display of invalid datavlues
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Factbox.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Factbox.php
@@ -61,6 +61,7 @@
6262 '<span class="smwfactboxhead">' . wfMsgForContent( 'smw_factbox_head', $browselink->getWikiText() ) . '</span>' .
6363 '<span class="smwrdflink">' . $rdflink->getWikiText() . '</span>' .
6464 '<table class="smwfacttable">' . "\n";
 65+
6566 foreach ( $semdata->getProperties() as $propertyDi ) {
6667 $propertyDv = SMWDataValueFactory::newDataItemValue( $propertyDi, null );
6768 if ( !$propertyDi->isShown() ) { // showing this is not desired, hide
@@ -76,22 +77,22 @@
7778 }
7879
7980 $propvalues = $semdata->getPropertyValues( $propertyDi );
80 - $l = count( $propvalues );
81 - $i = 0;
82 - foreach ( $propvalues as $di ) {
83 - if ( $i != 0 ) {
84 - if ( $i > $l - 2 ) {
85 - $text .= wfMsgForContent( 'smw_finallistconjunct' ) . ' ';
86 - } else {
87 - $text .= ', ';
88 - }
 81+
 82+ $valuesHtml = array();
 83+
 84+ foreach ( $propvalues as $dataItem ) {
 85+ $dataValue = SMWDataValueFactory::newDataItemValue( $dataItem, $propertyDi );
 86+
 87+ if ( $dataValue->isValid() ) {
 88+ $valuesHtml[] = $dataValue->getLongWikiText( true ) . $dataValue->getInfolinkText( SMW_OUTPUT_WIKI );
8989 }
90 - $i += 1;
91 - $dv = SMWDataValueFactory::newDataItemValue( $di, $propertyDi );
92 - $text .= $dv->getLongWikiText( true ) . $dv->getInfolinkText( SMW_OUTPUT_WIKI );
9390 }
 91+
 92+ $text .= $GLOBALS['wgLang']->listToText( $valuesHtml );
 93+
9494 $text .= '</td></tr>';
9595 }
 96+
9697 $text .= '</table></div>';
9798 }
9899 wfProfileOut( 'SMWFactbox::printFactbox (SMW)' );
@@ -125,6 +126,7 @@
126127 } else {
127128 $semdata = $parseroutput->mSMWData;
128129 }
 130+
129131 return SMWFactbox::getFactboxText( $semdata, $showfactbox );
130132 }
131133
@@ -136,6 +138,7 @@
137139 static public function onOutputPageParserOutput( $outputpage, $parseroutput ) {
138140 global $wgTitle, $wgParser;
139141 $factbox = SMWFactbox::getFactboxTextFromOutput( $parseroutput, $wgTitle );
 142+
140143 if ( $factbox != '' ) {
141144 $popts = new ParserOptions();
142145 $po = $wgParser->parse( $factbox, $wgTitle, $popts );
@@ -144,6 +147,7 @@
145148 SMWOutputs::requireFromParserOutput( $po );
146149 SMWOutputs::commitToOutputPage( $outputpage );
147150 } // else: nothing shown, don't even set any text
 151+
148152 return true;
149153 }
150154