r74097 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74096‎ | r74097 | r74098 >
Date:19:49, 1 October 2010
Author:ashley
Status:deferred
Tags:
Comment:
Semantic MediaWiki: cleanup to some of the stuff in includes directory; coding style changes, braces, trimmed trailing spaces, shortened some long lines etc.
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Factbox.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Infolink.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Outputs.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_ParseData.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_ParserExtensions.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryParser.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryPrinter.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Record_Descriptions.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_RefreshTab.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_SemanticData.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_ParseData.php
@@ -1,9 +1,9 @@
22 <?php
33 /**
44 * The class in this file manages semantic data collected during parsing of an article.
5 - *
 5+ *
66 * @author Markus Krötzsch
7 - *
 7+ *
88 * @file
99 * @ingroup SMW
1010 */
@@ -32,55 +32,59 @@
3333 static public function stripMagicWords( &$text, $parser ) {
3434 $words = array();
3535 $mw = MagicWord::get( 'SMW_NOFACTBOX' );
36 -
 36+
3737 if ( $mw->matchAndRemove( $text ) ) {
3838 $words[] = 'SMW_NOFACTBOX';
3939 }
40 -
 40+
4141 $mw = MagicWord::get( 'SMW_SHOWFACTBOX' );
42 -
 42+
4343 if ( $mw->matchAndRemove( $text ) ) {
4444 $words[] = 'SMW_SHOWFACTBOX';
4545 }
46 -
 46+
4747 $output = SMWParseData::getOutput( $parser );
4848 $output->mSMWMagicWords = $words;
49 -
 49+
5050 return $words;
5151 }
5252
5353 /**
5454 * This function retrieves the SMW data from a given parser, and creates
5555 * a new empty container if it is not initiated yet.
56 - *
 56+ *
5757 * @retun SMWSemanticData
5858 */
5959 static public function getSMWdata( $parser ) {
6060 $output = self::getOutput( $parser );
6161 $title = $parser->getTitle();
62 -
 62+
6363 // No parsing, create error.
64 - if ( !isset( $output ) || !isset( $title ) ) return null;
65 -
 64+ if ( !isset( $output ) || !isset( $title ) ) {
 65+ return null;
 66+ }
 67+
6668 // No data container yet.
67 - if ( !isset( $output->mSMWData ) ) {
 69+ if ( !isset( $output->mSMWData ) ) {
6870 $output->mSMWData = new SMWSemanticData( SMWWikiPageValue::makePageFromTitle( $title ) );
6971 }
70 -
 72+
7173 return $output->mSMWData;
7274 }
7375
7476 /**
7577 * Clear all stored data for a given parser.
76 - *
 78+ *
7779 * @param Parser $parser
7880 */
7981 static public function clearStorage( Parser $parser ) {
8082 $output = self::getOutput( $parser );
8183 $title = $parser->getTitle();
82 -
83 - if ( !isset( $output ) || !isset( $title ) ) return;
84 -
 84+
 85+ if ( !isset( $output ) || !isset( $title ) ) {
 86+ return;
 87+ }
 88+
8589 $output->mSMWData = new SMWSemanticData( SMWWikiPageValue::makePageFromTitle( $title ) );
8690 }
8791
@@ -89,42 +93,41 @@
9094 * intended to be used on user input, and property and value are sepcified by
9195 * strings as they might be found in a wiki. The function returns a datavalue
9296 * object that contains the result of the operation.
93 - *
 97+ *
9498 * @param string $propertyName
9599 * @param string $value
96100 * @param mixed $caption string or false
97 - * @param Parser $parser
 101+ * @param Parser $parser
98102 * @param boolean $storeAnnotation
99 - *
 103+ *
100104 * @return SMWDataValue
101105 */
102106 static public function addProperty( $propertyName, $value, $caption, Parser $parser, $storeAnnotation = true ) {
103 - wfProfileIn( "SMWParseData::addProperty (SMW)" );
104 -
 107+ wfProfileIn( 'SMWParseData::addProperty (SMW)' );
 108+
105109 global $smwgContLang;
106 -
 110+
107111 // See if this property is a special one, such as e.g. "has type".
108112 $property = SMWPropertyValue::makeUserProperty( $propertyName );
109113 $result = SMWDataValueFactory::newPropertyObjectValue( $property, $value, $caption );
110 -
 114+
111115 if ( $property->isInverse() ) {
112116 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
113117 $result->addError( wfMsgForContent( 'smw_noinvannot' ) );
114118 } elseif ( $storeAnnotation && ( self::getSMWData( $parser ) !== null ) ) {
115119 self::getSMWData( $parser )->addPropertyObjectValue( $property, $result );
116 -
 120+
117121 // Take note of the error for storage (do this here and not in storage, thus avoiding duplicates).
118 - if ( !$result->isValid() ) {
 122+ if ( !$result->isValid() ) {
119123 self::getSMWData( $parser )->addPropertyObjectValue( SMWPropertyValue::makeProperty( '_ERRP' ), $property->getWikiPageValue() );
120124 }
121125 }
122 -
123 - wfProfileOut( "SMWParseData::addProperty (SMW)" );
124 -
 126+
 127+ wfProfileOut( 'SMWParseData::addProperty (SMW)' );
 128+
125129 return $result;
126130 }
127131
128 -
129132 /**
130133 * This function takes care of storing the collected semantic data and takes
131134 * care of clearing out any outdated entries for the processed page. It assume that
@@ -137,28 +140,28 @@
138141 * conversion factors have changed. If so, it triggers SMWUpdateJobs for the relevant articles,
139142 * which then asynchronously update the semantic data in the database.
140143 *
141 - * @param $parseroutput ParserOutput object that contains the results of parsing which will
142 - * be stored.
143 - * @param $title Title object specifying the page that should be saved.
144 - * @param $makejobs Bool stating whether jobs should be created to trigger further updates if
145 - * this appears to be necessary after this update.
 144+ * @param $parseroutput ParserOutput object that contains the results of parsing which will
 145+ * be stored.
 146+ * @param $title Title object specifying the page that should be saved.
 147+ * @param $makejobs Bool stating whether jobs should be created to trigger further updates if
 148+ * this appears to be necessary after this update.
146149 *
147 - * FIXME Some job generations here might create too many jobs at once on a large wiki. Use incremental jobs instead.
 150+ * @todo FIXME: Some job generations here might create too many jobs at once on a large wiki. Use incremental jobs instead.
148151 */
149152 static public function storeData( $parseroutput, Title $title, $makejobs = true ) {
150153 global $smwgEnableUpdateJobs, $wgContLang, $smwgMW_1_14, $smwgDeclarationProperties;
151 -
 154+
152155 $semdata = $parseroutput->mSMWData;
153156 $namespace = $title->getNamespace();
154157 $processSemantics = smwfIsSemanticsProcessed( $namespace );
155 -
 158+
156159 if ( !isset( $semdata ) ) { // no data at all?
157160 $semdata = new SMWSemanticData( SMWWikiPageValue::makePageFromTitle( $title ) );
158161 }
159 -
 162+
160163 if ( $processSemantics ) {
161164 $pmdat = SMWPropertyValue::makeProperty( '_MDAT' );
162 -
 165+
163166 if ( count( $semdata->getPropertyValues( $pmdat ) ) == 0 ) { // no article data present yet, add it here
164167 $timestamp = $smwgMW_1_14 ? Revision::getTimeStampFromID( $title, $title->getLatestRevID() ) : Revision::getTimeStampFromID( $title->getLatestRevID() );
165168 $dv = SMWDataValueFactory::newPropertyObjectValue( $pmdat, $wgContLang->sprintfDate( 'd M Y G:i:s', $timestamp ) );
@@ -174,7 +177,7 @@
175178 // even finding uses of a property fails after its type was changed.
176179 $updatejobflag = false;
177180 $jobs = array();
178 -
 181+
179182 if ( $makejobs && $smwgEnableUpdateJobs && ( $namespace == SMW_NS_PROPERTY ) ) {
180183 // If it is a property, then we need to check if the type or the allowed values have been changed.
181184 $ptype = SMWPropertyValue::makeProperty( '_TYPE' );
@@ -195,14 +198,14 @@
196199 if ( $updatejobflag ) {
197200 $prop = SMWPropertyValue::makeProperty( $title->getDBkey() );
198201 $subjects = smwfGetStore()->getAllPropertySubjects( $prop );
199 -
 202+
200203 foreach ( $subjects as $subject ) {
201204 $jobs[] = new SMWUpdateJob( $subject->getTitle() );
202205 }
203206 wfRunHooks( 'smwUpdatePropertySubjects', array( &$jobs ) );
204 -
 207+
205208 $subjects = smwfGetStore()->getPropertySubjects( SMWPropertyValue::makeProperty( '_ERRP' ), $prop->getWikiPageValue() );
206 -
 209+
207210 foreach ( $subjects as $subject ) {
208211 $jobs[] = new SMWUpdateJob( $subject->getTitle() );
209212 }
@@ -211,36 +214,39 @@
212215 // if it is a type we need to check if the conversion factors have been changed
213216 $pconv = SMWPropertyValue::makeProperty( '_CONV' );
214217 $ptype = SMWPropertyValue::makeProperty( '_TYPE' );
215 -
 218+
216219 $oldfactors = smwfGetStore()->getPropertyValues( $semdata->getSubject(), $pconv );
217220 $newfactors = $semdata->getPropertyValues( $pconv );
218221 $updatejobflag = !self::equalDatavalues( $oldfactors, $newfactors );
219 -
 222+
220223 if ( $updatejobflag ) {
221224 $store = smwfGetStore();
222 -
 225+
223226 /// FIXME: this will kill large wikis! Use incremental updates!
224227 $dv = SMWDataValueFactory::newTypeIdValue( '__typ', $title->getDBkey() );
225228 $proppages = $store->getPropertySubjects( $ptype, $dv );
226 -
 229+
227230 foreach ( $proppages as $proppage ) {
228231 $jobs[] = new SMWUpdateJob( $proppage->getTitle() );
229232 $prop = SMWPropertyValue::makeProperty( $proppage->getDBkey() );
230233 $subjects = $store->getAllPropertySubjects( $prop );
231 -
 234+
232235 foreach ( $subjects as $subject ) {
233236 $jobs[] = new SMWUpdateJob( $subject->getTitle() );
234237 }
235 -
236 - $subjects = smwfGetStore()->getPropertySubjects( SMWPropertyValue::makeProperty( '_ERRP' ), $prop->getWikiPageValue() );
237 -
 238+
 239+ $subjects = smwfGetStore()->getPropertySubjects(
 240+ SMWPropertyValue::makeProperty( '_ERRP' ),
 241+ $prop->getWikiPageValue()
 242+ );
 243+
238244 foreach ( $subjects as $subject ) {
239245 $jobs[] = new SMWUpdateJob( $subject->getTitle() );
240246 }
241247 }
242248 }
243249 }
244 -
 250+
245251 // Actually store semantic data, or at least clear it if needed
246252 if ( $processSemantics ) {
247253 smwfGetStore()->updateData( $semdata );
@@ -252,7 +258,7 @@
253259 if ( $updatejobflag ) {
254260 Job::batchInsert( $jobs ); ///NOTE: this only happens if $smwgEnableUpdateJobs was true above
255261 }
256 -
 262+
257263 return true;
258264 }
259265
@@ -266,16 +272,20 @@
267273 // and finally concatenated, thus creating one long hash out of each
268274 // of the data value arrays. These are compared.
269275 $values = array();
270 - foreach ( $dv1 as $v ) $values[] = $v->getHash();
271 -
 276+ foreach ( $dv1 as $v ) {
 277+ $values[] = $v->getHash();
 278+ }
 279+
272280 sort( $values );
273 - $dv1hash = implode( "___", $values );
274 -
 281+ $dv1hash = implode( '___', $values );
 282+
275283 $values = array();
276 - foreach ( $dv2 as $v ) $values[] = $v->getHash();
277 -
 284+ foreach ( $dv2 as $v ) {
 285+ $values[] = $v->getHash();
 286+ }
 287+
278288 sort( $values );
279 - $dv2hash = implode( "___", $values );
 289+ $dv2hash = implode( '___', $values );
280290
281291 return ( $dv1hash == $dv2hash );
282292 }
@@ -283,7 +293,7 @@
284294 /**
285295 * Get the parser output from a parser object. The result is also stored
286296 * in SMWParseData::$mPrevOutput for further reference.
287 - *
 297+ *
288298 * @param Parser $parser
289299 */
290300 static protected function getOutput( Parser $parser ) {
@@ -292,7 +302,7 @@
293303 } else {
294304 self::$mPrevOutput = $parser->mOutput;
295305 }
296 -
 306+
297307 return self::$mPrevOutput;
298308 }
299309
@@ -302,11 +312,13 @@
303313 */
304314 static public function onParserAfterTidy( &$parser, &$text ) {
305315 global $smwgUseCategoryHierarchy, $smwgCategoriesAsInstances;
306 -
307 - if ( self::getSMWData( $parser ) === null ) return true;
308 -
 316+
 317+ if ( self::getSMWData( $parser ) === null ) {
 318+ return true;
 319+ }
 320+
309321 $categories = $parser->mOutput->getCategoryLinks();
310 -
 322+
311323 foreach ( $categories as $name ) {
312324 if ( $smwgCategoriesAsInstances && ( self::getSMWData( $parser )->getSubject()->getNamespace() != NS_CATEGORY ) ) {
313325 $pinst = SMWPropertyValue::makeProperty( '_INST' );
@@ -314,7 +326,7 @@
315327 $dv->setValues( $name, NS_CATEGORY );
316328 self::getSMWData( $parser )->addPropertyObjectValue( $pinst, $dv );
317329 }
318 -
 330+
319331 if ( $smwgUseCategoryHierarchy && ( self::getSMWData( $parser )->getSubject()->getNamespace() == NS_CATEGORY ) ) {
320332 $psubc = SMWPropertyValue::makeProperty( '_SUBC' );
321333 $dv = SMWDataValueFactory::newPropertyObjectValue( $psubc );
@@ -322,10 +334,10 @@
323335 self::getSMWData( $parser )->addPropertyObjectValue( $psubc, $dv );
324336 }
325337 }
326 -
 338+
327339 $sortkey = ( $parser->mDefaultSort ? $parser->mDefaultSort : self::getSMWData( $parser )->getSubject()->getText() );
328340 self::getSMWData( $parser )->getSubject()->setSortkey( $sortkey );
329 -
 341+
330342 return true;
331343 }
332344
@@ -342,33 +354,37 @@
343355 */
344356 static public function onNewRevisionFromEditComplete( $article, $rev, $baseID ) {
345357 global $wgContLang, $smwgContLang;
346 -
 358+
347359 if ( ( $article->mPreparedEdit ) && ( $article->mPreparedEdit->output instanceof ParserOutput ) ) {
348360 $output = $article->mPreparedEdit->output;
349361 $title = $article->getTitle();
350 -
351 - if ( !isset( $title ) ) return true; // nothing we can do
 362+
 363+ if ( !isset( $title ) ) {
 364+ return true; // nothing we can do
 365+ }
352366 if ( !isset( $output->mSMWData ) ) { // no data container yet, make one
353367 $output->mSMWData = new SMWSemanticData( SMWWikiPageValue::makePageFromTitle( $title ) );
354368 }
355 -
 369+
356370 $semdata = $output->mSMWData;
357371 } else { // give up, just keep the old data
358372 return true;
359373 }
360 -
 374+
361375 $pmdat = SMWPropertyValue::makeProperty( '_MDAT' );
362 -
 376+
363377 // create a date string that is certainly parsable in the current language:
364378 $timestamp = $article->getTimestamp();
365 -
366 - $date = $wgContLang->sprintfDate( 'd ', $timestamp ) . $smwgContLang->getMonthLabel( ( $wgContLang->sprintfDate( 'm', $timestamp ) + 0 ) ) . $wgContLang->sprintfDate( ' Y G:i:s', $timestamp );
 379+
 380+ $date = $wgContLang->sprintfDate( 'd ', $timestamp ) .
 381+ $smwgContLang->getMonthLabel( ( $wgContLang->sprintfDate( 'm', $timestamp ) + 0 ) ) .
 382+ $wgContLang->sprintfDate( ' Y G:i:s', $timestamp );
367383 $dv = SMWDataValueFactory::newPropertyObjectValue( $pmdat, $date );
368 -
 384+
369385 // The below method is not safe, since "M" as used in MW may not be the month label as used in SMW if SMW falls back to some other language:
370 - // $dv = SMWDataValueFactory::newPropertyObjectValue($pmdat, $wgContLang->sprintfDate('d M Y G:i:s',$article->getTimestamp()));
 386+ // $dv = SMWDataValueFactory::newPropertyObjectValue( $pmdat, $wgContLang->sprintfDate( 'd M Y G:i:s', $article->getTimestamp() ) );
371387 $semdata->addPropertyObjectValue( $pmdat, $dv );
372 -
 388+
373389 return true;
374390 }
375391
@@ -380,21 +396,21 @@
381397 $output = $links_update->mParserOutput;
382398 } else { // MediaWiki <= 1.13 compatibility
383399 $output = self::$mPrevOutput;
384 -
 400+
385401 if ( !isset( $output ) ) {
386402 smwfGetStore()->clearData( $links_update->mTitle, SMWFactbox::isNewArticle() );
387403 return true;
388404 }
389405 }
390 -
 406+
391407 self::storeData( $output, $links_update->mTitle, true );
392 -
 408+
393409 return true;
394410 }
395411
396412 /**
397 - * This method will be called whenever an article is deleted so that
398 - * semantic properties are cleared appropriately.
 413+ * This method will be called whenever an article is deleted so that
 414+ * semantic properties are cleared appropriately.
399415 */
400416 static public function onArticleDelete( &$article, &$user, &$reason ) {
401417 smwfGetStore()->deleteSubject( $article->getTitle() );
@@ -402,8 +418,8 @@
403419 }
404420
405421 /**
406 - * This method will be called whenever an article is moved so that
407 - * semantic properties are moved accordingly.
 422+ * This method will be called whenever an article is moved so that
 423+ * semantic properties are moved accordingly.
408424 */
409425 static public function onTitleMoveComplete( &$old_title, &$new_title, &$user, $pageid, $redirid ) {
410426 smwfGetStore()->changeTitle( $old_title, $new_title, $pageid, $redirid );
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Record_Descriptions.php
@@ -19,13 +19,17 @@
2020 class SMWRecordDescription extends SMWConjunction {
2121
2222 public function getQueryString( $asvalue = false ) {
23 - if ( !$asvalue ) return ''; // give up; SMWRecordDescriptions must always be values
 23+ if ( !$asvalue ) {
 24+ return ''; // give up; SMWRecordDescriptions must always be values
 25+ }
2426 $fields = array();
2527 $maxpos = - 1;
2628 foreach ( $this->m_descriptions as $desc ) {
2729 if ( $desc instanceof SMWRecordFieldDescription ) { // everything else would be a bug; ignore
2830 $fields[$desc->getPosition()] = $desc->getDescription()->getQueryString( true );
29 - if ( $maxpos < $desc->getPosition() ) $maxpos = $desc->getPosition();
 31+ if ( $maxpos < $desc->getPosition() ) {
 32+ $maxpos = $desc->getPosition();
 33+ }
3034 }
3135 }
3236 if ( $maxpos < 0 ) {
@@ -82,7 +86,9 @@
8387 }
8488
8589 public function getQueryString( $asvalue = false ) {
86 - if ( !$asvalue ) return ''; // give up; SMWRecordFieldDescriptions must always be values
 90+ if ( !$asvalue ) {
 91+ return ''; // give up; SMWRecordFieldDescriptions must always be values
 92+ }
8793 $prefix = '';
8894 for ( $i = 0; $i < $this->m_position; $i++ ) {
8995 $prefix .= '?; ';
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php
@@ -31,7 +31,7 @@
3232 * The format string is used to specify the output format if already
3333 * known. Otherwise it will be determined from the parameters when
3434 * needed. This parameter is just for optimisation in a common case.
35 - *
 35+ *
3636 * @return SMWQuery
3737 */
3838 static public function createQuery( $querystring, array $params, $context = SMWQueryProcessor::INLINE_QUERY, $format = '', $extraprintouts = array() ) {
@@ -45,7 +45,7 @@
4646 $qp = new SMWQueryParser( $queryfeatures );
4747 $qp->setDefaultNamespaces( $smwgQDefaultNamespaces );
4848 $desc = $qp->getQueryDescription( $querystring );
49 -
 49+
5050 if ( $format == 'count' ) {
5151 $querymode = SMWQuery::MODE_COUNT;
5252 } elseif ( $format == 'debug' ) {
@@ -58,7 +58,7 @@
5959 $mainlabel = array_key_exists( 'mainlabel', $params ) ? $params['mainlabel'] : '';
6060 if ( ( $querymode == SMWQuery::MODE_NONE ) ||
6161 ( ( !$desc->isSingleton() || ( count( $desc->getPrintRequests() ) + count( $extraprintouts ) == 0 ) )
62 - && ( trim($mainlabel) != '-' ) ) ) {
 62+ && ( trim( $mainlabel ) != '-' ) ) ) {
6363 $desc->prependPrintRequest( new SMWPrintRequest( SMWPrintRequest::PRINT_THIS, $mainlabel ) );
6464 }
6565
@@ -72,7 +72,7 @@
7373 if ( ( array_key_exists( 'offset', $params ) ) && ( is_int( $params['offset'] + 0 ) ) ) {
7474 $query->setOffset( max( 0, trim( $params['offset'] ) + 0 ) );
7575 }
76 -
 76+
7777 if ( $query->querymode == SMWQuery::MODE_COUNT ) { // largest possible limit for "count", even inline
7878 global $smwgQMaxLimit;
7979 $query->setOffset( 0 );
@@ -88,11 +88,11 @@
8989 $query->setLimit( $smwgQDefaultLimit );
9090 }
9191 }
92 -
 92+
9393 // determine sortkeys and ascendings:
9494 if ( array_key_exists( 'order', $params ) ) {
9595 $orders = explode( ',', $params['order'] );
96 -
 96+
9797 foreach ( $orders as $key => $order ) { // normalise
9898 $order = strtolower( trim( $order ) );
9999 if ( ( $order == 'descending' ) || ( $order == 'reverse' ) || ( $order == 'desc' ) ) {
@@ -106,35 +106,35 @@
107107 } else {
108108 $orders = array();
109109 }
110 -
 110+
111111 reset( $orders );
112112
113113 if ( array_key_exists( 'sort', $params ) ) {
114114 $query->sort = true;
115115 $query->sortkeys = array();
116 -
 116+
117117 foreach ( explode( ',', trim( $params['sort'] ) ) as $sort ) {
118118 $sort = smwfNormalTitleDBKey( trim( $sort ) ); // slight normalisation
119119 $order = current( $orders );
120120 if ( $order === false ) { // default
121121 $order = 'ASC';
122122 }
123 -
 123+
124124 if ( array_key_exists( $sort, $query->sortkeys ) ) {
125125 // maybe throw an error here?
126126 } else {
127127 $query->sortkeys[$sort] = $order;
128128 }
129 -
 129+
130130 next( $orders );
131131 }
132 -
 132+
133133 if ( current( $orders ) !== false ) { // sort key remaining, apply to page name
134134 $query->sortkeys[''] = current( $orders );
135135 }
136136 } elseif ( $format == 'rss' ) { // unsorted RSS: use *descending* default order
137 - ///TODO: the default sort field should be "modification date" (now it is the title, but
138 - ///likely to be overwritten by printouts with label "date").
 137+ // TODO: the default sort field should be "modification date" (now it is the title, but
 138+ // likely to be overwritten by printouts with label "date").
139139 $query->sortkeys[''] = ( current( $orders ) != false ) ? current( $orders ) : 'DESC';
140140 } else { // sort by page title (main column) by default
141141 $query->sortkeys[''] = ( current( $orders ) != false ) ? current( $orders ) : 'ASC';
@@ -152,31 +152,31 @@
153153 */
154154 static public function processFunctionParams( array $rawparams, &$querystring, &$params, &$printouts, $showmode = false ) {
155155 global $wgContLang;
156 -
 156+
157157 $querystring = '';
158158 $printouts = array();
159159 $lastprintout = null;
160160 $params = array();
161 -
 161+
162162 foreach ( $rawparams as $name => $param ) {
163163 // special handling for arrays - this can happen if the
164164 // param came from a checkboxes input in Special:Ask
165165 if ( is_array( $param ) ) {
166166 $param = implode( ',', array_keys( $param ) );
167167 }
168 -
 168+
169169 if ( is_string( $name ) && ( $name != '' ) ) { // accept 'name' => 'value' just as '' => 'name=value'
170170 $param = $name . '=' . $param;
171171 }
172 -
 172+
173173 if ( $param == '' ) {
174174 } elseif ( $param { 0 } == '?' ) { // print statement
175175 $param = substr( $param, 1 );
176176 $parts = explode( '=', $param, 2 );
177177 $propparts = explode( '#', $parts[0], 2 );
178 -
 178+
179179 $data = null;
180 -
 180+
181181 if ( trim( $propparts[0] ) == '' ) { // print "this"
182182 $printmode = SMWPrintRequest::PRINT_THIS;
183183 $label = ''; // default
@@ -190,7 +190,7 @@
191191 if ( $title === null ) { // too bad, this is no legal property/category name, ignore
192192 continue;
193193 }
194 -
 194+
195195 if ( $title->getNamespace() == NS_CATEGORY ) {
196196 $printmode = SMWPrintRequest::PRINT_CCAT;
197197 $data = $title;
@@ -202,28 +202,30 @@
203203 $label = $showmode ? '' : $property->getWikiValue(); // default
204204 }
205205 }
206 -
 206+
207207 if ( count( $propparts ) == 1 ) { // no outputformat found, leave empty
208208 $propparts[] = false;
209209 } elseif ( trim( $propparts[1] ) == '' ) { // "plain printout", avoid empty string to avoid confusions with "false"
210210 $propparts[1] = '-';
211211 }
212 -
 212+
213213 if ( count( $parts ) > 1 ) { // label found, use this instead of default
214214 $label = trim( $parts[1] );
215215 }
216 -
 216+
217217 $lastprintout = new SMWPrintRequest( $printmode, $label, $data, trim( $propparts[1] ) );
218218 $printouts[] = $lastprintout;
219219 } elseif ( $param[0] == '+' ) { // print request parameter
220220 if ( $lastprintout !== null ) {
221221 $param = substr( $param, 1 );
222222 $parts = explode( '=', $param, 2 );
223 - if ( count( $parts ) == 2 ) $lastprintout->setParameter( trim( $parts[0] ), $parts[1] );
 223+ if ( count( $parts ) == 2 ) {
 224+ $lastprintout->setParameter( trim( $parts[0] ), $parts[1] );
 225+ }
224226 }
225227 } else { // parameter or query
226228 $parts = explode( '=', $param, 2 );
227 -
 229+
228230 if ( count( $parts ) >= 2 ) {
229231 $params[strtolower( trim( $parts[0] ) )] = $parts[1]; // don't trim here, some params care for " "
230232 } else {
@@ -231,9 +233,11 @@
232234 }
233235 }
234236 }
235 -
 237+
236238 $querystring = str_replace( array( '&lt;', '&gt;' ), array( '<', '>' ), $querystring );
237 - if ( $showmode ) $querystring = "[[:$querystring]]";
 239+ if ( $showmode ) {
 240+ $querystring = "[[:$querystring]]";
 241+ }
238242 }
239243
240244 /**
@@ -261,93 +265,99 @@
262266 */
263267 static public function getResultFromQueryString( $querystring, array $params, $extraprintouts, $outputmode, $context = SMWQueryProcessor::INLINE_QUERY ) {
264268 wfProfileIn( 'SMWQueryProcessor::getResultFromQueryString (SMW)' );
265 -
 269+
266270 $format = SMWQueryProcessor::getResultFormat( $params );
267271 $query = SMWQueryProcessor::createQuery( $querystring, $params, $context, $format, $extraprintouts );
268272 $result = SMWQueryProcessor::getResultFromQuery( $query, $params, $extraprintouts, $outputmode, $context, $format );
269 -
 273+
270274 wfProfileOut( 'SMWQueryProcessor::getResultFromQueryString (SMW)' );
271 -
 275+
272276 return $result;
273277 }
274278
275279 static public function getResultFromQuery( SMWQuery $query, array $params, $extraprintouts, $outputmode, $context = SMWQueryProcessor::INLINE_QUERY, $format = '' ) {
276280 wfProfileIn( 'SMWQueryProcessor::getResultFromQuery (SMW)' );
277 -
 281+
278282 // Query routing allows extensions to provide alternative stores as data sources
279283 // The while feature is experimental and is not properly integrated with most of SMW's architecture. For instance, some query printers just fetch their own store.
280 - ///TODO: case-insensitive
 284+ // @todo FIXME: case-insensitive
281285 global $smwgQuerySources;
282 -
 286+
283287 if ( array_key_exists( 'source', $params ) && array_key_exists( $params['source'], $smwgQuerySources ) ) {
284288 $store = new $smwgQuerySources[$params['source']]();
285289 $query->params = $params; // this is a hack
286290 } else {
287291 $store = smwfGetStore(); // default store
288292 }
289 -
 293+
290294 $res = $store->getQueryResult( $query );
291295
292296 if ( ( $query->querymode == SMWQuery::MODE_INSTANCES ) || ( $query->querymode == SMWQuery::MODE_NONE ) ) {
293297 wfProfileIn( 'SMWQueryProcessor::getResultFromQuery-printout (SMW)' );
294 -
 298+
295299 if ( $format == '' ) {
296300 $format = SMWQueryProcessor::getResultFormat( $params );
297301 }
298 -
 302+
299303 $printer = SMWQueryProcessor::getResultPrinter( $format, $context, $res );
300304 $result = $printer->getResult( $res, $params, $outputmode );
301 -
 305+
302306 wfProfileOut( 'SMWQueryProcessor::getResultFromQuery-printout (SMW)' );
303307 wfProfileOut( 'SMWQueryProcessor::getResultFromQuery (SMW)' );
304 -
 308+
305309 return $result;
306310 } else { // result for counting or debugging is just a string
307 - if ( array_key_exists( 'intro', $params ) ) $res = str_replace( '_', ' ', $params['intro'] ) . $res;
308 - if ( array_key_exists( 'outro', $params ) ) $res .= str_replace( '_', ' ', $params['outro'] );
309 -
 311+ if ( array_key_exists( 'intro', $params ) ) {
 312+ $res = str_replace( '_', ' ', $params['intro'] ) . $res;
 313+ }
 314+ if ( array_key_exists( 'outro', $params ) ) {
 315+ $res .= str_replace( '_', ' ', $params['outro'] );
 316+ }
 317+
310318 wfProfileOut( 'SMWQueryProcessor::getResultFromQuery (SMW)' );
311 -
 319+
312320 return $res . smwfEncodeMessages( $query->getErrors() );
313321 }
314322 }
315323
316324 /**
317325 * Determines the format from an array of parameters, and returns it.
318 - *
 326+ *
319327 * @param array $params
320 - *
 328+ *
321329 * @return string
322330 */
323331 static protected function getResultFormat( array $params ) {
324332 $format = 'auto';
325 -
 333+
326334 if ( array_key_exists( 'format', $params ) ) {
327335 global $smwgResultFormats;
328 -
 336+
329337 $format = strtolower( trim( $params['format'] ) );
330 -
 338+
331339 if ( !array_key_exists( $format, $smwgResultFormats ) ) {
332340 $isAlias = self::resolveFormatAliases( $format );
333 - if ( !$isAlias ) $format = 'auto'; // If it is an unknown format, defaults to list/table again
 341+ if ( !$isAlias ) {
 342+ $format = 'auto'; // If it is an unknown format, defaults to list/table again
 343+ }
334344 }
335345 }
336 -
 346+
337347 return $format;
338348 }
339 -
 349+
340350 /**
341351 * Turns format aliases into main formats.
342 - *
 352+ *
343353 * @param string $format
344 - *
 354+ *
345355 * @return boolean Indicates if the passed format was an alias, and thus was changed.
346356 */
347357 static protected function resolveFormatAliases( &$format ) {
348358 global $smwgResultAliases;
349359
350360 $isAlias = false;
351 -
 361+
352362 foreach ( $smwgResultAliases as $mainFormat => $aliases ) {
353363 if ( in_array( $format, $aliases ) ) {
354364 $format = $mainFormat;
@@ -363,20 +373,20 @@
364374 * Find suitable SMWResultPrinter for the given format. The context in which the query is to be
365375 * used determines some basic settings of the returned printer object. Possible contexts are
366376 * SMWQueryProcessor::SPECIAL_PAGE, SMWQueryProcessor::INLINE_QUERY, SMWQueryProcessor::CONCEPT_DESC.
367 - *
 377+ *
368378 * @param string $format
369379 * @param $context
370 - *
 380+ *
371381 * @return SMWResultPrinter
372382 */
373383 static public function getResultPrinter( $format, $context = SMWQueryProcessor::SPECIAL_PAGE ) {
374384 global $smwgResultFormats;
375 -
 385+
376386 self::resolveFormatAliases( $format );
377 -
 387+
378388 // TODO: this seems to contain the same logic as found in getResultFormat - a single function for this might be better.
379389 $formatClass = array_key_exists( $format, $smwgResultFormats ) ? $smwgResultFormats[$format] : 'SMWAutoResultPrinter';
380 -
 390+
381391 return new $formatClass( $format, ( $context != SMWQueryProcessor::SPECIAL_PAGE ) );
382392 }
383393
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php
@@ -248,12 +248,18 @@
249249 * particular datatype in mind.
250250 */
251251 public function addServiceLinks() {
252 - if ( $this->mHasServiceLinks ) return;
253 - if ( ( $this->m_property === null ) || ( $this->m_property->getWikiPageValue() === null ) ) return; // no property known
 252+ if ( $this->mHasServiceLinks ) {
 253+ return;
 254+ }
 255+ if ( ( $this->m_property === null ) || ( $this->m_property->getWikiPageValue() === null ) ) {
 256+ return; // no property known
 257+ }
254258
255259 $args = $this->getServiceLinkParams();
256260
257 - if ( $args === false ) return; // no services supported
 261+ if ( $args === false ) {
 262+ return; // no services supported
 263+ }
258264
259265 array_unshift( $args, '' ); // add a 0 element as placeholder
260266 $servicelinks = smwfGetStore()->getPropertyValues( $this->m_property->getWikiPageValue(), SMWPropertyValue::makeProperty( '_SERV' ) );
@@ -401,11 +407,21 @@
402408 $value = $list[2];
403409
404410 switch ( $list[1] ) {
405 - case '<': $comparator = SMW_CMP_LEQ; break;
406 - case '>': $comparator = SMW_CMP_GEQ; break;
407 - case '!': $comparator = SMW_CMP_NEQ; break;
408 - case '~': $comparator = SMW_CMP_LIKE; break;
409 - case '!~': $comparator = SMW_CMP_NLKE; break;
 411+ case '<':
 412+ $comparator = SMW_CMP_LEQ;
 413+ break;
 414+ case '>':
 415+ $comparator = SMW_CMP_GEQ;
 416+ break;
 417+ case '!':
 418+ $comparator = SMW_CMP_NEQ;
 419+ break;
 420+ case '~':
 421+ $comparator = SMW_CMP_LIKE;
 422+ break;
 423+ case '!~':
 424+ $comparator = SMW_CMP_NLKE;
 425+ break;
410426 // default: not possible
411427 }
412428 }
@@ -550,8 +566,12 @@
551567 */
552568 public function getShortText( $outputformat, $linker = null ) {
553569 switch ( $outputformat ) {
554 - case SMW_OUTPUT_WIKI: return $this->getShortWikiText( $linker );
555 - case SMW_OUTPUT_HTML: case SMW_OUTPUT_FILE: default: return $this->getShortHTMLText( $linker );
 570+ case SMW_OUTPUT_WIKI:
 571+ return $this->getShortWikiText( $linker );
 572+ case SMW_OUTPUT_HTML:
 573+ case SMW_OUTPUT_FILE:
 574+ default:
 575+ return $this->getShortHTMLText( $linker );
556576 }
557577 }
558578
@@ -565,8 +585,12 @@
566586 */
567587 public function getLongText( $outputformat, $linker = null ) {
568588 switch ( $outputformat ) {
569 - case SMW_OUTPUT_WIKI: return $this->getLongWikiText( $linker );
570 - case SMW_OUTPUT_HTML: case SMW_OUTPUT_FILE: default: return $this->getLongHTMLText( $linker );
 589+ case SMW_OUTPUT_WIKI:
 590+ return $this->getLongWikiText( $linker );
 591+ case SMW_OUTPUT_HTML:
 592+ case SMW_OUTPUT_FILE:
 593+ default:
 594+ return $this->getLongHTMLText( $linker );
571595 }
572596 }
573597
@@ -750,11 +774,18 @@
751775 * Creates an error if the value is illegal.
752776 */
753777 protected function checkAllowedValues() {
754 - if ( ( $this->m_property === null ) || ( $this->m_property->getWikiPageValue() === null ) ) return; // no property known
 778+ if ( ( $this->m_property === null ) || ( $this->m_property->getWikiPageValue() === null ) ) {
 779+ return; // no property known
 780+ }
755781
756 - $allowedvalues = smwfGetStore()->getPropertyValues( $this->m_property->getWikiPageValue(), SMWPropertyValue::makeProperty( '_PVAL' ) );
 782+ $allowedvalues = smwfGetStore()->getPropertyValues(
 783+ $this->m_property->getWikiPageValue(),
 784+ SMWPropertyValue::makeProperty( '_PVAL' )
 785+ );
757786
758 - if ( count( $allowedvalues ) == 0 ) return;
 787+ if ( count( $allowedvalues ) == 0 ) {
 788+ return;
 789+ }
759790
760791 $hash = $this->getHash();
761792 $value = SMWDataValueFactory::newTypeIDValue( $this->getTypeID() );
@@ -778,7 +809,9 @@
779810
780811 if ( !$accept ) {
781812 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
782 - $this->addError( wfMsgForContent( 'smw_notinenum', $this->getWikiValue(), $valuestring ) );
 813+ $this->addError(
 814+ wfMsgForContent( 'smw_notinenum', $this->getWikiValue(), $valuestring )
 815+ );
783816 }
784817 }
785818
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Infolink.php
@@ -112,7 +112,13 @@
113113 */
114114 public static function newPropertySearchLink( $caption, $propertyName, $propertyValue, $style = 'smwsearch' ) {
115115 global $wgContLang;
116 - return new SMWInfolink( true, $caption, $wgContLang->getNsText( NS_SPECIAL ) . ':SearchByProperty', $style, array( $propertyName, $propertyValue ) );
 116+ return new SMWInfolink(
 117+ true,
 118+ $caption,
 119+ $wgContLang->getNsText( NS_SPECIAL ) . ':SearchByProperty',
 120+ $style,
 121+ array( $propertyName, $propertyValue )
 122+ );
117123 }
118124
119125 /**
@@ -121,13 +127,18 @@
122128 * @param string $caption The label for the link.
123129 * @param string $subject
124130 * @param string $propertyName
125 - * @param mixed $style CSS class of a span to embedd the link into, or false if no extra style is required.
 131+ * @param mixed $style CSS class of a span to embed the link into, or false if no extra style is required.
126132 *
127133 * @return SMWInfolink
128134 */
129135 public static function newInversePropertySearchLink( $caption, $subject, $propertyname, $style = false ) {
130136 global $wgContLang;
131 - return new SMWInfolink( true, $caption, $wgContLang->getNsText( NS_SPECIAL ) . ':PageProperty/' . $subject . '::' . $propertyname, $style );
 137+ return new SMWInfolink(
 138+ true,
 139+ $caption,
 140+ $wgContLang->getNsText( NS_SPECIAL ) . ':PageProperty/' . $subject . '::' . $propertyname,
 141+ $style
 142+ );
132143 }
133144
134145 /**
@@ -141,7 +152,13 @@
142153 */
143154 public static function newBrowsingLink( $caption, $titleText, $style = 'smwbrowse' ) {
144155 global $wgContLang;
145 - return new SMWInfolink( true, $caption, $wgContLang->getNsText( NS_SPECIAL ) . ':Browse', $style, array( $titleText ) );
 156+ return new SMWInfolink(
 157+ true,
 158+ $caption,
 159+ $wgContLang->getNsText( NS_SPECIAL ) . ':Browse',
 160+ $style,
 161+ array( $titleText )
 162+ );
146163 }
147164
148165 /**
@@ -225,9 +242,13 @@
226243
227244 if ( $title !== null ) {
228245 if ( $outputformat == SMW_OUTPUT_WIKI ) {
229 - $link = "[" . $title->getFullURL( SMWInfolink::encodeParameters( $this->mParams, false ) ) . " $this->mCaption]";
 246+ $link = '[' . $title->getFullURL( SMWInfolink::encodeParameters( $this->mParams, false ) ) . " $this->mCaption]";
230247 } else { // SMW_OUTPUT_HTML, SMW_OUTPUT_FILE
231 - $link = $this->getLinker( $linker )->makeKnownLinkObj( $title, $this->mCaption, SMWInfolink::encodeParameters( $this->mParams, false ) );
 248+ $link = $this->getLinker( $linker )->makeKnownLinkObj(
 249+ $title,
 250+ $this->mCaption,
 251+ SMWInfolink::encodeParameters( $this->mParams, false )
 252+ );
232253 }
233254 } else {
234255 return ''; // the title was bad, normally this would indicate a software bug
@@ -239,7 +260,7 @@
240261 if ( $outputformat == SMW_OUTPUT_WIKI ) {
241262 $link = "[$target $this->mCaption]";
242263 } else { // SMW_OUTPUT_HTML, SMW_OUTPUT_FILE
243 - $link = "<a href=\"" . htmlspecialchars( $target ) . "\">$this->mCaption</a>";
 264+ $link = '<a href="' . htmlspecialchars( $target ) . "\">$this->mCaption</a>";
244265 }
245266 }
246267
@@ -304,7 +325,9 @@
305326 * @return Linker
306327 */
307328 protected function getLinker( &$linker = null ) {
308 - if ( $linker === null ) $linker = new Linker();
 329+ if ( $linker === null ) {
 330+ $linker = new Linker();
 331+ }
309332 return $linker;
310333 }
311334
@@ -330,7 +353,9 @@
331354
332355 if ( $forTitle ) {
333356 foreach ( $params as $name => $value ) {
334 - if ( is_string( $name ) && ( $name != '' ) ) $value = $name . '=' . $value;
 357+ if ( is_string( $name ) && ( $name != '' ) ) {
 358+ $value = $name . '=' . $value;
 359+ }
335360 // Escape certain problematic values. Use SMW-escape
336361 // (like URLencode but - instead of % to prevent double encoding by later MW actions)
337362 //
@@ -355,7 +380,9 @@
356381 $value
357382 );
358383
359 - if ( $result != '' ) $result .= '/';
 384+ if ( $result != '' ) {
 385+ $result .= '/';
 386+ }
360387
361388 $result .= $value;
362389 }
@@ -366,7 +393,9 @@
367394 if ( is_string( $name ) && ( $name != '' ) ) {
368395 $value = $name . '=' . rawurlencode( $value );
369396
370 - if ( $result != '' ) $result .= '&';
 397+ if ( $result != '' ) {
 398+ $result .= '&';
 399+ }
371400
372401 $result .= $value;
373402 } else {
@@ -374,7 +403,9 @@
375404 }
376405 }
377406 if ( count( $q ) > 0 ) { // prepend encoding for unlabelled parameters
378 - if ( $result != '' ) $result = '&' . $result;
 407+ if ( $result != '' ) {
 408+ $result = '&' . $result;
 409+ }
379410 $result = 'x=' . rawurlencode( SMWInfolink::encodeParameters( $q, true ) ) . $result;
380411 }
381412 }
@@ -414,7 +445,9 @@
415446 $result = $wgRequest->getValues();
416447
417448 if ( array_key_exists( 'x', $result ) ) { // Considered to be part of the title param.
418 - if ( $titleParam != '' ) $titleParam .= '/';
 449+ if ( $titleParam != '' ) {
 450+ $titleParam .= '/';
 451+ }
419452 $titleParam .= $result['x'];
420453 unset( $result['x'] );
421454 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryPrinter.php
@@ -22,24 +22,30 @@
2323
2424 protected $m_params;
2525
26 - /** Text to print *before* the output in case it is *not* empty; assumed to be wikitext.
27 - * Normally this is handled in SMWResultPrinter and can be ignored by subclasses. */
 26+ /**
 27+ * Text to print *before* the output in case it is *not* empty; assumed to be wikitext.
 28+ * Normally this is handled in SMWResultPrinter and can be ignored by subclasses.
 29+ */
2830 protected $mIntro = '';
2931
30 - /** Text to print *after* the output in case it is *not* empty; assumed to be wikitext.
31 - * Normally this is handled in SMWResultPrinter and can be ignored by subclasses. */
 32+ /**
 33+ * Text to print *after* the output in case it is *not* empty; assumed to be wikitext.
 34+ * Normally this is handled in SMWResultPrinter and can be ignored by subclasses.
 35+ */
3236 protected $mOutro = '';
3337
34 - /** Text to use for link to further results, or empty if link should not be shown.
35 - * Unescaped! Use SMWResultPrinter::getSearchLabel() and SMWResultPrinter::linkFurtherResults()
36 - * instead of accessing this directly. */
 38+ /**
 39+ * Text to use for link to further results, or empty if link should not be shown.
 40+ * Unescaped! Use SMWResultPrinter::getSearchLabel() and SMWResultPrinter::linkFurtherResults()
 41+ * instead of accessing this directly.
 42+ */
3743 protected $mSearchlabel = null;
3844
3945 /** Default return value for empty queries. Unescaped. Normally not used in sub-classes! */
4046 protected $mDefault = '';
4147
4248 // parameters relevant for printers in general:
43 - protected $mFormat; // a string identifier describing a valid format
 49+ protected $mFormat; // a string identifier describing a valid format
4450 protected $mLinkFirst; // should article names of the first column be linked?
4551 protected $mLinkOthers; // should article names of other columns (besides the first) be linked?
4652 protected $mShowHeaders = SMW_HEADERS_SHOW; // should the headers (property names) be printed?
@@ -74,8 +80,8 @@
7581 * Return serialised results in specified format.
7682 * Implemented by subclasses.
7783 */
78 - abstract protected function getResultText( /* SMWQueryResult */ $res, $outputmode );
79 -
 84+ abstract protected function getResultText( /* SMWQueryResult */ $res, $outputmode );
 85+
8086 /**
8187 * Constructor. The parameter $format is a format string
8288 * that may influence the processing details.
@@ -113,66 +119,66 @@
114120 * effectively can get down to level 3. The basic maximal depth of 2 can be changed by setting the
115121 * variable SMWResultPrinter::$maxRecursionDepth (in LocalSettings.php, after enableSemantics()).
116122 * Do this at your own risk.
117 - *
 123+ *
118124 * @param SMWQueryResult $results
119125 * @param array $params
120126 * @param $outputmode
121 - *
 127+ *
122128 * @return string
123129 */
124130 public function getResult( $results, $params, $outputmode ) {
125131 global $wgParser;
126 -
 132+
127133 $this->isHTML = false;
128134 $this->hasTemplates = false;
129135 $this->readParameters( $params, $outputmode );
130136
131137 // Default output for normal printers:
132138 if ( ( $outputmode != SMW_OUTPUT_FILE ) && // not in FILE context,
133 - ( $results->getCount() == 0 ) && // no results,
134 - ( $this->getMimeType( $results ) === false ) ) { // normal printer -> take over processing
 139+ ( $results->getCount() == 0 ) && // no results,
 140+ ( $this->getMimeType( $results ) === false ) ) { // normal printer -> take over processing
135141 if ( !$results->hasFurtherResults() ) {
136142 return $this->escapeText( $this->mDefault, $outputmode ) . $this->getErrorString( $results );
137143 } elseif ( $this->mInline ) {
138144 $label = $this->mSearchlabel;
139 -
 145+
140146 if ( $label === null ) { // apply defaults
141147 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
142148 $label = wfMsgForContent( 'smw_iq_moreresults' );
143149 }
144 -
 150+
145151 if ( $label != '' ) {
146152 $link = $results->getQueryLink( $this->escapeText( $label, $outputmode ) );
147153 $result = $link->getText( $outputmode, $this->mLinker );
148154 } else {
149155 $result = '';
150156 }
151 -
 157+
152158 $result .= $this->getErrorString( $results );
153 -
 159+
154160 return $result;
155161 }
156162 }
157163
158164 // Get output from printer:
159165 $result = $this->getResultText( $results, $outputmode );
160 -
 166+
161167 if ( $outputmode == SMW_OUTPUT_FILE ) { // just return result in file mode
162168 return $result;
163169 }
164 -
 170+
165171 $result .= $this->getErrorString( $results ); // append errors
166 -
 172+
167173 if ( ( !$this->isHTML ) && ( $this->hasTemplates ) ) { // preprocess embedded templates if needed
168174 if ( ( $wgParser->getTitle() instanceof Title ) && ( $wgParser->getOptions() instanceof ParserOptions ) ) {
169175 SMWResultPrinter::$mRecursionDepth++;
170 -
 176+
171177 if ( SMWResultPrinter::$mRecursionDepth <= SMWResultPrinter::$maxRecursionDepth ) { // restrict recursion
172178 $result = '[[SMW::off]]' . $wgParser->replaceVariables( $result ) . '[[SMW::on]]';
173179 } else {
174180 $result = ''; /// TODO: explain problem (too much recursive parses)
175181 }
176 -
 182+
177183 SMWResultPrinter::$mRecursionDepth--;
178184 } else { // not during parsing, no preprocessing needed, still protect the result
179185 $result = '[[SMW::off]]' . $result . '[[SMW::on]]';
@@ -183,18 +189,18 @@
184190 $result = array( $result, 'isHTML' => true );
185191 } elseif ( ( !$this->isHTML ) && ( $outputmode == SMW_OUTPUT_HTML ) ) {
186192 SMWResultPrinter::$mRecursionDepth++;
187 -
 193+
188194 // check whether we are in an existing parse, or if we should start a new parse for $wgTitle
189195 if ( SMWResultPrinter::$mRecursionDepth <= SMWResultPrinter::$maxRecursionDepth ) { // retrict recursion
190196 if ( ( $wgParser->getTitle() instanceof Title ) && ( $wgParser->getOptions() instanceof ParserOptions ) ) {
191197 $result = $wgParser->recursiveTagParse( $result );
192198 } else {
193199 global $wgTitle;
194 -
 200+
195201 $popt = new ParserOptions();
196202 $popt->setEditSection( false );
197203 $pout = $wgParser->parse( $result . '__NOTOC__', $wgTitle, $popt );
198 -
 204+
199205 /// NOTE: as of MW 1.14SVN, there is apparently no better way to hide the TOC
200206 SMWOutputs::requireFromParserOutput( $pout );
201207 $result = $pout->getText();
@@ -202,7 +208,7 @@
203209 } else {
204210 $result = ''; /// TODO: explain problem (too much recursive parses)
205211 }
206 -
 212+
207213 SMWResultPrinter::$mRecursionDepth--;
208214 }
209215
@@ -231,46 +237,46 @@
232238 * Read an array of parameter values given as key-value-pairs and
233239 * initialise internal member fields accordingly. Possibly overwritten
234240 * (extended) by subclasses.
235 - *
 241+ *
236242 * @param array $params
237243 * @param $outputmode
238244 */
239245 protected function readParameters( /* array */ $params, $outputmode ) {
240246 $this->m_params = $params;
241 -
 247+
242248 if ( array_key_exists( 'intro', $params ) ) {
243249 $this->mIntro = str_replace( '_', ' ', $params['intro'] );
244250 }
245 -
 251+
246252 if ( array_key_exists( 'outro', $params ) ) {
247253 $this->mOutro = str_replace( '_', ' ', $params['outro'] );
248254 }
249 -
 255+
250256 if ( array_key_exists( 'searchlabel', $params ) ) {
251257 $this->mSearchlabel = $params['searchlabel'];
252258 }
253 -
 259+
254260 if ( array_key_exists( 'link', $params ) ) {
255261 switch ( strtolower( trim( $params['link'] ) ) ) {
256262 case 'head': case 'subject':
257263 $this->mLinkFirst = true;
258 - $this->mLinkOthers = false;
 264+ $this->mLinkOthers = false;
259265 break;
260266 case 'all':
261267 $this->mLinkFirst = true;
262 - $this->mLinkOthers = true;
 268+ $this->mLinkOthers = true;
263269 break;
264270 case 'none':
265271 $this->mLinkFirst = false;
266 - $this->mLinkOthers = false;
 272+ $this->mLinkOthers = false;
267273 break;
268274 }
269275 }
270 -
 276+
271277 if ( array_key_exists( 'default', $params ) ) {
272278 $this->mDefault = str_replace( '_', ' ', $params['default'] );
273279 }
274 -
 280+
275281 if ( array_key_exists( 'headers', $params ) ) {
276282 if ( strtolower( trim( $params['headers'] ) ) == 'hide' ) {
277283 $this->mShowHeaders = SMW_HEADERS_HIDE;
@@ -346,7 +352,7 @@
347353 * refer to messages here. The format name is normally not used in
348354 * wiki text but only in forms etc. hence the user language should be
349355 * used when retrieving messages.
350 - *
 356+ *
351357 * @return string
352358 */
353359 public function getName() {
@@ -357,7 +363,7 @@
358364 * Provides a simple formatted string of all the error messages that occurred.
359365 * Can be used if not specific error formatting is desired. Compatible with HTML
360366 * and Wiki.
361 - *
 367+ *
362368 * @return string
363369 */
364370 public function getErrorString( $res ) {
@@ -366,7 +372,7 @@
367373
368374 /**
369375 * Set whether errors should be shown. By default they are.
370 - *
 376+ *
371377 * @param boolean $show
372378 */
373379 public function setShowErrors( $show ) {
@@ -376,7 +382,7 @@
377383 /**
378384 * If $outputmode is SMW_OUTPUT_HTML, escape special characters occuring in the
379385 * given text. Otherwise return text as is.
380 - *
 386+ *
381387 * @return string
382388 */
383389 protected function escapeText( $text, $outputmode ) {
@@ -386,7 +392,7 @@
387393 /**
388394 * Get the string the user specified as a text for the "further results" link,
389395 * properly escaped for the current output mode.
390 - *
 396+ *
391397 * @return string
392398 */
393399 protected function getSearchLabel( $outputmode ) {
@@ -397,7 +403,7 @@
398404 * Check whether a "further results" link would normally be generated for this
399405 * result set with the given parameters. Individual result printers may decide to
400406 * create or hide such a link independent of that, but this is the default.
401 - *
 407+ *
402408 * @return boolean
403409 */
404410 protected function linkFurtherResults( $results ) {
@@ -408,9 +414,9 @@
409415 * Return an array describing the parameters of specifically text-based
410416 * formats, like 'list' and 'table', for use in their getParameters()
411417 * functions
412 - *
 418+ *
413419 * @since 1.5.0
414 - *
 420+ *
415421 * @return array
416422 */
417423 protected function textDisplayParameters() {
@@ -424,9 +430,9 @@
425431 /**
426432 * Return an array describing the parameters of the export formats
427433 * like 'rss' and 'csv', for use in their getParameters() functions
428 - *
 434+ *
429435 * @since 1.5.0
430 - *
 436+ *
431437 * @return array
432438 */
433439 protected function exportFormatParameters() {
@@ -442,9 +448,9 @@
443449 * A function to describe the allowed parameters of a query using
444450 * any specific format - most query printers should override this
445451 * function
446 - *
 452+ *
447453 * @since 1.5.0
448 - *
 454+ *
449455 * @return array
450456 */
451457 public function getParameters() {
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_ParserExtensions.php
@@ -21,19 +21,19 @@
2222 protected static $mTempStoreAnnotations;
2323
2424 /**
25 - * This method will be called before an article is displayed or previewed.
26 - * For display and preview we strip out the semantic properties and append them
27 - * at the end of the article.
28 - *
29 - * @param Parser $parser
30 - * @param string $text
 25+ * This method will be called before an article is displayed or previewed.
 26+ * For display and preview we strip out the semantic properties and append them
 27+ * at the end of the article.
 28+ *
 29+ * @param Parser $parser
 30+ * @param string $text
3131 */
3232 static public function onInternalParseBeforeLinks( &$parser, &$text ) {
3333 global $smwgStoreAnnotations, $smwgLinksInValues;
34 -
 34+
3535 SMWParseData::stripMagicWords( $text, $parser );
36 -
37 - // Store the results if enabled (we have to parse them in any case,
 36+
 37+ // Store the results if enabled (we have to parse them in any case,
3838 // in order to clean the wiki source for further processing).
3939 $smwgStoreAnnotations = smwfIsSemanticsProcessed( $parser->getTitle()->getNamespace() );
4040 SMWParserExtensions::$mTempStoreAnnotations = true; // used for [[SMW::on]] and [[SMW:off]]
@@ -43,7 +43,7 @@
4444 if ( $rt !== null ) {
4545 $p = SMWPropertyValue::makeProperty( '_REDI' );
4646 $dv = SMWDataValueFactory::newPropertyObjectValue( $p, $rt->getPrefixedText() );
47 -
 47+
4848 if ( $smwgStoreAnnotations ) {
4949 SMWParseData::getSMWData( $parser )->addPropertyObjectValue( $p, $dv );
5050 }
@@ -51,7 +51,7 @@
5252
5353 // only used in subsequent callbacks, forgotten afterwards
5454 SMWParserExtensions::$mTempParser = $parser;
55 -
 55+
5656 // In the regexp matches below, leading ':' escapes the markup, as known for Categories.
5757 // Parse links to extract semantic properties.
5858 if ( $smwgLinksInValues ) { // More complex regexp -- lib PCRE may cause segfaults if text is long :-(
@@ -99,7 +99,7 @@
100100 static public function simpleParsePropertiesCallback( $semanticLink ) {
101101 $value = '';
102102 $caption = false;
103 -
 103+
104104 if ( array_key_exists( 2, $semanticLink ) ) {
105105 $parts = explode( '|', $semanticLink[2] );
106106 if ( array_key_exists( 0, $parts ) ) {
@@ -109,7 +109,7 @@
110110 $caption = $parts[1];
111111 }
112112 }
113 -
 113+
114114 if ( $caption !== false ) {
115115 return SMWParserExtensions::parsePropertiesCallback( array( $semanticLink[0], $semanticLink[1], $value, $caption ) );
116116 } else {
@@ -123,21 +123,21 @@
124124 */
125125 static public function parsePropertiesCallback( $semanticLink ) {
126126 global $smwgInlineErrors, $smwgStoreAnnotations;
127 -
 127+
128128 wfProfileIn( 'smwfParsePropertiesCallback (SMW)' );
129 -
 129+
130130 if ( array_key_exists( 1, $semanticLink ) ) {
131131 $property = $semanticLink[1];
132132 } else {
133133 $property = '';
134134 }
135 -
 135+
136136 if ( array_key_exists( 2, $semanticLink ) ) {
137137 $value = $semanticLink[2];
138138 } else {
139139 $value = '';
140140 }
141 -
 141+
142142 if ( $value == '' ) { // silently ignore empty values
143143 wfProfileOut( 'smwfParsePropertiesCallback (SMW)' );
144144 return '';
@@ -164,19 +164,19 @@
165165
166166 // Extract annotations and create tooltip.
167167 $properties = preg_split( '/:[=:]/u', $property );
168 -
 168+
169169 foreach ( $properties as $singleprop ) {
170170 $dv = SMWParseData::addProperty( $singleprop, $value, $valueCaption, SMWParserExtensions::$mTempParser, $smwgStoreAnnotations && SMWParserExtensions::$mTempStoreAnnotations );
171171 }
172 -
 172+
173173 $result = $dv->getShortWikitext( true );
174 -
 174+
175175 if ( ( $smwgInlineErrors && $smwgStoreAnnotations && SMWParserExtensions::$mTempStoreAnnotations ) && ( !$dv->isValid() ) ) {
176176 $result .= $dv->getErrorText();
177177 }
178 -
 178+
179179 wfProfileOut( 'smwfParsePropertiesCallback (SMW)' );
180 -
 180+
181181 return $result;
182182 }
183183
@@ -192,11 +192,11 @@
193193 $parser->setFunctionHook( 'concept', array( 'SMWParserExtensions', 'doConcept' ) );
194194 $parser->setFunctionHook( 'set', array( 'SMWParserExtensions', 'doSet' ) );
195195 $parser->setFunctionHook( 'set_recurring_event', array( 'SMWParserExtensions', 'doSetRecurringEvent' ) );
196 -
 196+
197197 if ( defined( 'SFH_OBJECT_ARGS' ) ) { // only available since MediaWiki 1.13
198198 $parser->setFunctionHook( 'declare', array( 'SMWParserExtensions', 'doDeclare' ), SFH_OBJECT_ARGS );
199199 }
200 -
 200+
201201 return true; // Always return true, in order not to stop MW's hook processing!
202202 }
203203
@@ -206,21 +206,21 @@
207207 */
208208 static public function doAsk( &$parser ) {
209209 global $smwgQEnabled, $smwgIQRunningNumber;
210 -
 210+
211211 if ( $smwgQEnabled ) {
212212 $smwgIQRunningNumber++;
213 -
 213+
214214 $params = func_get_args();
215215 array_shift( $params ); // We already know the $parser ...
216 -
 216+
217217 $result = SMWQueryProcessor::getResultFromFunctionParams( $params, SMW_OUTPUT_WIKI );
218218 } else {
219219 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
220220 $result = smwfEncodeMessages( array( wfMsgForContent( 'smw_iq_disabled' ) ) );
221221 }
222 -
 222+
223223 SMWOutputs::commitToParser( $parser );
224 -
 224+
225225 return $result;
226226 }
227227
@@ -230,19 +230,19 @@
231231 */
232232 static public function doShow( &$parser ) {
233233 global $smwgQEnabled, $smwgIQRunningNumber;
234 -
 234+
235235 if ( $smwgQEnabled ) {
236236 $smwgIQRunningNumber++;
237 -
 237+
238238 $params = func_get_args();
239239 array_shift( $params ); // We already know the $parser ...
240 -
 240+
241241 $result = SMWQueryProcessor::getResultFromFunctionParams( $params, SMW_OUTPUT_WIKI, SMWQueryProcessor::INLINE_QUERY, true );
242242 } else {
243243 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
244244 $result = smwfEncodeMessages( array( wfMsgForContent( 'smw_iq_disabled' ) ) );
245245 }
246 -
 246+
247247 SMWOutputs::commitToParser( $parser );
248248 return $result;
249249 }
@@ -253,12 +253,12 @@
254254 */
255255 static public function doConcept( &$parser ) {
256256 global $smwgQDefaultNamespaces, $smwgQMaxSize, $smwgQMaxDepth, $wgContLang;
257 -
 257+
258258 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
259 -
 259+
260260 $title = $parser->getTitle();
261261 $pconc = SMWPropertyValue::makeProperty( '_CONC' );
262 -
 262+
263263 if ( $title->getNamespace() != SMW_NS_CONCEPT ) {
264264 $result = smwfEncodeMessages( array( wfMsgForContent( 'smw_no_concept_namespace' ) ) );
265265 SMWOutputs::commitToParser( $parser );
@@ -272,20 +272,20 @@
273273 // process input:
274274 $params = func_get_args();
275275 array_shift( $params ); // We already know the $parser ...
276 -
 276+
277277 // Use first parameter as concept (query) string.
278278 $concept_input = str_replace( array( '&gt;', '&lt;' ), array( '>', '<' ), array_shift( $params ) );
279 -
 279+
280280 // second parameter, if any, might be a description
281281 $concept_docu = array_shift( $params );
282 -
 282+
283283 // NOTE: the str_replace above is required in MediaWiki 1.11, but not in MediaWiki 1.14
284284 $query = SMWQueryProcessor::createQuery( $concept_input, array( 'limit' => 20, 'format' => 'list' ), SMWQueryProcessor::CONCEPT_DESC );
285285 $concept_text = $query->getDescription()->getQueryString();
286286
287287 $dv = SMWDataValueFactory::newPropertyObjectValue( $pconc );
288288 $dv->setValues( $concept_text, $concept_docu, $query->getDescription()->getQueryFeatures(), $query->getDescription()->getSize(), $query->getDescription()->getDepth() );
289 -
 289+
290290 if ( SMWParseData::getSMWData( $parser ) !== null ) {
291291 SMWParseData::getSMWData( $parser )->addPropertyObjectValue( $pconc, $dv );
292292 }
@@ -300,7 +300,7 @@
301301 '</span>' . '<span class="smwrdflink">' . $rdflink->getWikiText() . '</span>' . '<br />' .
302302 ( $concept_docu ? "<p>$concept_docu</p>" : '' ) .
303303 '<pre>' . str_replace( '[', '&#x005B;', $concept_text ) . "</pre>\n</div>";
304 -
 304+
305305 SMWOutputs::commitToParser( $parser );
306306 return $result;
307307 }
@@ -313,10 +313,10 @@
314314 static public function doInfo( &$parser ) {
315315 $params = func_get_args();
316316 array_shift( $params ); // We already know the $parser ...
317 -
 317+
318318 $content = array_shift( $params ); // Use only first parameter, ignore the rest (may get meaning later).
319319 $result = smwfEncodeMessages( array( $content ), 'info' );
320 -
 320+
321321 SMWOutputs::commitToParser( $parser );
322322 return $result;
323323 }
@@ -331,27 +331,27 @@
332332 * | area = 396 km²
333333 * | sea = Adria
334334 * }}
335 - *
 335+ *
336336 * This creates annotations with the properties as stated on the left side, and the
337337 * values on the right side.
338338 *
339339 * @param Parser &$parser The current parser
340 - *
 340+ *
341341 * @return empty string
342342 */
343343 static public function doSet( &$parser ) {
344344 $params = func_get_args();
345345 array_shift( $params ); // We already know the $parser ...
346 -
 346+
347347 foreach ( $params as $param ) {
348348 $parts = explode( '=', trim( $param ), 2 );
349 -
 349+
350350 // Only add the property when there is both a name and a value.
351351 if ( count( $parts ) == 2 ) {
352352 SMWParseData::addProperty( $parts[0], $parts[1], false, $parser, true );
353353 }
354354 }
355 -
 355+
356356 SMWOutputs::commitToParser( $parser ); // not obviously required, but let us be sure
357357 return '';
358358 }
@@ -375,84 +375,91 @@
376376 // Set values from the parameters.
377377 foreach ( $params as $param ) {
378378 $parts = explode( '=', trim( $param ) );
379 -
380 - if ( count( $parts ) != 2 ) continue;
381 -
 379+
 380+ if ( count( $parts ) != 2 ) {
 381+ continue;
 382+ }
 383+
382384 list( $name, $value ) = $parts;
383 -
 385+
384386 switch( $name ) {
385 - case 'property' :
 387+ case 'property':
386388 $property_name = $value;
387389 break;
388 - case 'start' :
 390+ case 'start':
389391 $start_date = SMWDataValueFactory::newTypeIDValue( '_dat', $value );
390392 break;
391 - case 'end' :
 393+ case 'end':
392394 $end_date = SMWDataValueFactory::newTypeIDValue( '_dat', $value );
393395 break;
394 - case 'unit' :
 396+ case 'unit':
395397 $unit = $value;
396398 break;
397 - case 'period' :
 399+ case 'period':
398400 $period = (int)$value;
399401 break;
400 - case 'week number' :
 402+ case 'week number':
401403 $week_num = (int)$value;
402404 break;
403 - case 'include' :
 405+ case 'include':
404406 $included_dates = explode( ';', $value );
405 - break;
406 - case 'exclude' :
 407+ break;
 408+ case 'exclude':
407409 $excluded_dates = explode( ';', $value );
408 -
 410+
409411 foreach ( $excluded_dates as $date_str ) {
410412 $date = SMWDataValueFactory::newTypeIDValue( '_dat', $date_str );
411413 $excluded_dates_jd[] = $date->getValueKey();
412 - }
413 - break;
 414+ }
 415+ break;
414416 default:
415417 $unused_params[] = $param;
416418 }
417419 }
418 -
 420+
419421 // We need at least a property and start date - if either one is null, exit here.
420 - if ( is_null( $property_name ) || is_null( $start_date ) ) return;
421 -
 422+ if ( is_null( $property_name ) || is_null( $start_date ) ) {
 423+ return;
 424+ }
 425+
422426 // If the period is null, or outside of normal bounds, set it to 1.
423 - if ( is_null( $period ) || $period < 1 || $period > 500 ) $period = 1;
 427+ if ( is_null( $period ) || $period < 1 || $period > 500 ) {
 428+ $period = 1;
 429+ }
424430
425431 // Handle 'week number', but only if it's of unit 'month'.
426432 if ( $unit == 'month' && ! is_null( $week_num ) ) {
427433 $unit = 'dayofweekinmonth';
428 -
 434+
429435 if ( $week_num < -4 || $week_num > 5 || $week_num == 0 ) {
430436 $week_num = null;
431437 }
432438 }
433 -
434 - if ( $unit == 'dayofweekinmonth' && is_null( $week_num ) )
435 - $week_num = ceil($start_date->getDay() / 7);
436439
 440+ if ( $unit == 'dayofweekinmonth' && is_null( $week_num ) ) {
 441+ $week_num = ceil( $start_date->getDay() / 7 );
 442+ }
 443+
437444 // Get the Julian day value for both the start and end date.
438445 $start_date_jd = $start_date->getValueKey();
439 -
 446+
440447 if ( !is_null( $end_date ) ) {
441448 $end_date_jd = $end_date->getValueKey();
442449 }
443 -
 450+
444451 $cur_date = $start_date;
445452 $cur_date_jd = $start_date->getValueKey();
446453 $i = 0;
447454 $reached_end_date = false;
448 -
 455+
449456 do {
450457 $i++;
451458 $exclude_date = ( in_array( $cur_date_jd, $excluded_dates_jd ) );
452 -
 459+
453460 if ( !$exclude_date ) {
454461 $all_date_strings[] = $cur_date->getLongWikiText();
455462 }
456 -
 463+
457464 // Now get the next date.
458465 // Handling is different depending on whether it's
459466 // month/year or week/day since the latter is a set
@@ -462,7 +469,7 @@
463470 $cur_month = $cur_date->getMonth();
464471 $cur_day = $cur_date->getDay();
465472 $cur_time = $cur_date->getTimeString();
466 -
 473+
467474 if ( $unit == 'year' ) {
468475 $cur_year += $period;
469476 $display_month = $cur_month;
@@ -472,7 +479,7 @@
473480 $cur_month %= 12;
474481 $display_month = ( $cur_month == 0 ) ? 12 : $cur_month;
475482 }
476 -
 483+
477484 $date_str = "$cur_year-$display_month-$cur_day $cur_time";
478485 $cur_date = SMWDataValueFactory::newTypeIDValue( '_dat', $date_str );
479486 $cur_date_jd = $cur_date->getValueKey();
@@ -480,35 +487,35 @@
481488 // e.g., "3rd Monday of every month"
482489 $prev_month = $cur_date->getMonth();
483490 $prev_year = $cur_date->getYear();
484 -
 491+
485492 $new_month = ( $prev_month + $period ) % 12;
486493 if ( $new_month == 0 ) $new_month = 12;
487 -
 494+
488495 $new_year = $prev_year + floor( ( $prev_month + $period - 1 ) / 12 );
489496 $cur_date_jd += ( 28 * $period ) - 7;
490 -
 497+
491498 // We're sometime before the actual date now -
492499 // keep incrementing by a week, until we get there.
493500 do {
494501 $cur_date_jd += 7;
495502 $cur_date = SMWDataValueFactory::newTypeIDValue( '_dat', $cur_date_jd );
496503 $right_month = ( $cur_date->getMonth() == $new_month );
497 -
 504+
498505 if ( $week_num < 0 ) {
499506 $next_week_jd = $cur_date_jd;
500 -
 507+
501508 do {
502509 $next_week_jd += 7;
503510 $next_week_date = SMWDataValueFactory::newTypeIDValue( '_dat', $next_week_jd );
504511 $right_week = ( $next_week_date->getMonth() != $new_month ) || ( $next_week_date->getYear() != $new_year );
505512 } while ( !$right_week );
506 -
 513+
507514 $cur_date_jd = $next_week_jd + ( 7 * $week_num );
508515 $cur_date = SMWDataValueFactory::newTypeIDValue( '_dat', $cur_date_jd );
509516 } else {
510517 $cur_week_num = ceil( $cur_date->getDay() / 7 );
511518 $right_week = ( $cur_week_num == $week_num );
512 -
 519+
513520 if ( $week_num == 5 && ( $cur_date->getMonth() % 12 == ( $new_month + 1 ) % 12 ) ) {
514521 $cur_date_jd -= 7;
515522 $cur_date = SMWDataValueFactory::newTypeIDValue( '_dat', $cur_date_jd );
@@ -600,7 +607,7 @@
601608 if ( trim( $arg ) != '' ) {
602609 $expanded = trim( $frame->expand( $arg ) );
603610 $parts = explode( '=', $expanded, 2 );
604 -
 611+
605612 if ( count( $parts ) == 1 ) {
606613 $propertystring = $expanded;
607614 $argumentname = $expanded;
@@ -608,19 +615,19 @@
609616 $propertystring = $parts[0];
610617 $argumentname = $parts[1];
611618 }
612 -
 619+
613620 $property = SMWPropertyValue::makeUserProperty( $propertystring );
614621 $argument = $frame->getArgument( $argumentname );
615622 $valuestring = $frame->expand( $argument );
616 -
 623+
617624 if ( $property->isValid() ) {
618625 $type = $property->getPropertyTypeID();
619 -
 626+
620627 if ( $type == '_wpg' ) {
621628 $matches = array();
622629 preg_match_all( '/\[\[([^\[\]]*)\]\]/', $valuestring, $matches );
623630 $objects = $matches[1];
624 -
 631+
625632 if ( count( $objects ) == 0 ) {
626633 if ( trim( $valuestring ) != '' ) {
627634 SMWParseData::addProperty( $propertystring, $valuestring, false, $parser, true );
@@ -635,7 +642,7 @@
636643 SMWParseData::addProperty( $propertystring, $valuestring, false, $parser, true );
637644 }
638645 }
639 -
 646+
640647 $value = SMWDataValueFactory::newPropertyObjectValue( $property, $valuestring );
641648 // if (!$value->isValid()) continue;
642649 }
@@ -643,7 +650,7 @@
644651 } else {
645652 // @todo Save as metadata
646653 }
647 -
 654+
648655 SMWOutputs::commitToParser( $parser ); // Not obviously required, but let us be sure.
649656 return '';
650657 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryParser.php
@@ -48,36 +48,36 @@
4949 * Compute an SMWDescription from a query string. Returns whatever descriptions could be
5050 * wrestled from the given string (the most general result being SMWThingDescription if
5151 * no meaningful condition was extracted).
52 - *
 52+ *
5353 * @param string $querystring
54 - *
 54+ *
5555 * @return SMWDescription
5656 */
5757 public function getQueryDescription( $querystring ) {
5858 wfProfileIn( 'SMWQueryParser::getQueryDescription (SMW)' );
59 -
 59+
6060 $this->m_errors = array();
6161 $this->m_curstring = $querystring;
6262 $this->m_sepstack = array();
6363 $setNS = false;
6464 $result = $this->getSubqueryDescription( $setNS );
65 -
 65+
6666 if ( !$setNS ) { // add default namespaces if applicable
6767 $result = $this->addDescription( $this->m_defaultns, $result );
6868 }
69 -
 69+
7070 if ( $result === null ) { // parsing went wrong, no default namespaces
7171 $result = new SMWThingDescription();
7272 }
73 -
 73+
7474 wfProfileOut( 'SMWQueryParser::getQueryDescription (SMW)' );
75 -
 75+
7676 return $result;
7777 }
7878
7979 /**
8080 * Return array of error messages (possibly empty).
81 - *
 81+ *
8282 * @return array
8383 */
8484 public function getErrors() {
@@ -86,7 +86,7 @@
8787
8888 /**
8989 * Return error message or empty string if no error occurred.
90 - *
 90+ *
9191 * @return string
9292 */
9393 public function getErrorString() {
@@ -113,22 +113,22 @@
114114 * Note that $setNS is no means to switch on or off default namespaces in general,
115115 * but just controls query generation. For general effect, the default namespaces
116116 * should be set to NULL.
117 - *
 117+ *
118118 * @return SMWDescription or null
119119 */
120120 protected function getSubqueryDescription( &$setNS ) {
121121 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
122 -
 122+
123123 $conjunction = null; // used for the current inner conjunction
124124 $disjuncts = array(); // (disjunctive) array of subquery conjunctions
125125 $hasNamespaces = false; // does the current $conjnuction have its own namespace restrictions?
126 - $mustSetNS = $setNS; // must ns restrictions be set? (may become true even if $setNS is false)
 126+ $mustSetNS = $setNS; // must NS restrictions be set? (may become true even if $setNS is false)
127127
128128 $continue = ( $chunk = $this->readChunk() ) != ''; // skip empty subquery completely, thorwing an error
129 -
 129+
130130 while ( $continue ) {
131131 $setsubNS = false;
132 -
 132+
133133 switch ( $chunk ) {
134134 case '[[': // start new link block
135135 $ld = $this->getLinkDescription( $setsubNS );
@@ -140,29 +140,32 @@
141141 $this->pushDelimiter( '</q>' );
142142 $conjunction = $this->addDescription( $conjunction, $this->getSubqueryDescription( $setsubNS ) );
143143 break;
144 - case 'OR': case '||': case '': case '</q>': // finish disjunction and maybe subquery
 144+ case 'OR':
 145+ case '||':
 146+ case '':
 147+ case '</q>': // finish disjunction and maybe subquery
145148 if ( $this->m_defaultns !== null ) { // possibly add namespace restrictions
146149 if ( $hasNamespaces && !$mustSetNS ) {
147 - // add ns restrictions to all earlier conjunctions (all of which did not have them yet)
 150+ // add NS restrictions to all earlier conjunctions (all of which did not have them yet)
148151 $mustSetNS = true; // enforce NS restrictions from now on
149152 $newdisjuncts = array();
150 -
 153+
151154 foreach ( $disjuncts as $conj ) {
152155 $newdisjuncts[] = $this->addDescription( $conj, $this->m_defaultns );
153156 }
154 -
 157+
155158 $disjuncts = $newdisjuncts;
156159 } elseif ( !$hasNamespaces && $mustSetNS ) {
157160 // add ns restriction to current result
158161 $conjunction = $this->addDescription( $conjunction, $this->m_defaultns );
159162 }
160163 }
161 -
 164+
162165 $disjuncts[] = $conjunction;
163166 // start anew
164167 $conjunction = null;
165168 $hasNamespaces = false;
166 -
 169+
167170 // finish subquery?
168171 if ( $chunk == '</q>' ) {
169172 if ( $this->popDelimiter( '</q>' ) ) {
@@ -181,11 +184,11 @@
182185 $this->m_errors[] = wfMsgForContent( 'smw_unexpectedpart', $chunk );
183186 // return null; // Try to go on, it can only get better ...
184187 }
185 -
 188+
186189 if ( $setsubNS ) { // namespace restrictions encountered in current conjunct
187190 $hasNamespaces = true;
188191 }
189 -
 192+
190193 if ( $continue ) { // read on only if $continue remained true
191194 $chunk = $this->readChunk();
192195 }
@@ -193,7 +196,7 @@
194197
195198 if ( count( $disjuncts ) > 0 ) { // make disjunctive result
196199 $result = null;
197 -
 200+
198201 foreach ( $disjuncts as $d ) {
199202 if ( $d === null ) {
200203 $this->m_errors[] = wfMsgForContent( 'smw_emptysubquery' );
@@ -208,7 +211,7 @@
209212 $setNS = false;
210213 return null;
211214 }
212 -
 215+
213216 $setNS = $mustSetNS; // NOTE: also false if namespaces were given but no default NS descs are available
214217
215218 return $result;
@@ -224,15 +227,15 @@
225228 // This method is called when we encountered an opening '[['. The following
226229 // block could be a Category-statement, fixed object, or property statement.
227230 $chunk = $this->readChunk( '', true, false ); // NOTE: untrimmed, initial " " escapes prop. chains
228 -
 231+
229232 if ( ( smwfNormalTitleText( $chunk ) == $this->m_categoryprefix ) || // category statement or
230233 ( smwfNormalTitleText( $chunk ) == $this->m_conceptprefix ) ) { // concept statement
231234 return $this->getClassDescription( $setNS, ( smwfNormalTitleText( $chunk ) == $this->m_categoryprefix ) );
232235 } else { // fixed subject, namespace restriction, property query, or subquery
233236 $sep = $this->readChunk( '', false ); // do not consume hit, "look ahead"
234 -
 237+
235238 if ( ( $sep == '::' ) || ( $sep == ':=' ) ) {
236 - if ( $chunk { 0 } != ':' ) { // property statement
 239+ if ( $chunk{0} != ':' ) { // property statement
237240 return $this->getPropertyDescription( $chunk, $setNS );
238241 } else { // escaped article description, read part after :: to get full contents
239242 $chunk .= $this->readChunk( '\[\[|\]\]|\|\||\|' );
@@ -253,21 +256,21 @@
254257 // note: no subqueries allowed here, inline disjunction allowed, wildcards allowed
255258 $result = null;
256259 $continue = true;
257 -
 260+
258261 while ( $continue ) {
259262 $chunk = $this->readChunk();
260 -
 263+
261264 if ( $chunk == '+' ) {
262265 // wildcard, ignore for categories (semantically meaningless, everything is in some class)
263266 } else { // assume category/concept title
264267 /// NOTE: use m_c...prefix to prevent problems with, e.g., [[Category:Template:Test]]
265 - $class = Title::newFromText( ( $category ? $this->m_categoryprefix:$this->m_conceptprefix ) . $chunk );
 268+ $class = Title::newFromText( ( $category ? $this->m_categoryprefix : $this->m_conceptprefix ) . $chunk );
266269 if ( $class !== null ) {
267 - $desc = $category ? new SMWClassDescription( $class ):new SMWConceptDescription( $class );
 270+ $desc = $category ? new SMWClassDescription( $class ) : new SMWConceptDescription( $class );
268271 $result = $this->addDescription( $result, $desc, false );
269272 }
270273 }
271 -
 274+
272275 $chunk = $this->readChunk();
273276 $continue = ( $chunk == '||' ) && $category; // disjunctions only for cateories
274277 }
@@ -284,26 +287,26 @@
285288 protected function getPropertyDescription( $propertyname, &$setNS ) {
286289 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
287290 $this->readChunk(); // consume separator ":=" or "::"
288 -
 291+
289292 // first process property chain syntax (e.g. "property1.property2::value"), escaped by initial " ":
290 - $propertynames = ( $propertyname { 0 } == ' ' ) ? array( $propertyname ):explode( '.', $propertyname );
 293+ $propertynames = ( $propertyname{0} == ' ' ) ? array( $propertyname ):explode( '.', $propertyname );
291294 $properties = array();
292295 $typeid = '_wpg';
293296 $inverse = false;
294 -
 297+
295298 foreach ( $propertynames as $name ) {
296299 if ( $typeid != '_wpg' ) { // non-final property in chain was no wikipage: not allowed
297300 $this->m_errors[] = wfMsgForContent( 'smw_valuesubquery', $prevname );
298301 return null; ///TODO: read some more chunks and try to finish [[ ]]
299302 }
300 -
 303+
301304 $property = SMWPropertyValue::makeUserProperty( $name );
302 -
 305+
303306 if ( !$property->isValid() ) { // illegal property identifier
304307 $this->m_errors = array_merge( $this->m_errors, $property->getErrors() );
305308 return null; ///TODO: read some more chunks and try to finish [[ ]]
306309 }
307 -
 310+
308311 $typeid = $property->getPropertyTypeID();
309312 $inverse = $property->isInverse();
310313 $prevname = $name;
@@ -312,10 +315,10 @@
313316
314317 $innerdesc = null;
315318 $continue = true;
316 -
 319+
317320 while ( $continue ) {
318321 $chunk = $this->readChunk();
319 -
 322+
320323 switch ( $chunk ) {
321324 case '+': // wildcard, add namespaces for page-type properties
322325 if ( ( $this->m_defaultns !== null ) && ( ( $typeid == '_wpg' ) || $inverse ) ) {
@@ -351,7 +354,8 @@
352355 case ']]': // close [[ ]]
353356 $open--;
354357 break;
355 - case '|': case '||': // terminates only outermost [[ ]]
 358+ case '|':
 359+ case '||': // terminates only outermost [[ ]]
356360 if ( $open == 1 ) {
357361 $open = 0;
358362 }
@@ -375,19 +379,19 @@
376380
377381 if ( $innerdesc === null ) { // make a wildcard search
378382 $innerdesc = ( ( $this->m_defaultns !== null ) && ( $typeid == '_wpg' ) ) ?
379 - $this->addDescription( $innerdesc, $this->m_defaultns, false ):
380 - $this->addDescription( $innerdesc, new SMWThingDescription(), false );
 383+ $this->addDescription( $innerdesc, $this->m_defaultns, false ) :
 384+ $this->addDescription( $innerdesc, new SMWThingDescription(), false );
381385 $this->m_errors[] = wfMsgForContent( 'smw_propvalueproblem', $property->getWikiValue() );
382386 }
383 -
 387+
384388 $properties = array_reverse( $properties );
385 -
 389+
386390 foreach ( $properties as $property ) {
387391 $innerdesc = new SMWSomeProperty( $property, $innerdesc );
388392 }
389 -
 393+
390394 $result = $innerdesc;
391 -
 395+
392396 return $this->finishLinkDescription( $chunk, false, $result, $setNS );
393397 }
394398
@@ -400,40 +404,40 @@
401405 */
402406 protected function getArticleDescription( $firstchunk, &$setNS ) {
403407 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
404 -
 408+
405409 $chunk = $firstchunk;
406410 $result = null;
407411 $continue = true;
408412 // $innerdesc = null;
409 -
 413+
410414 while ( $continue ) {
411415 if ( $chunk == '<q>' ) { // no subqueries of the form [[<q>...</q>]] (not needed)
412416 $this->m_errors[] = wfMsgForContent( 'smw_misplacedsubquery' );
413417 return null;
414418 }
415 -
 419+
416420 $list = preg_split( '/:/', $chunk, 3 ); // ":Category:Foo" "User:bar" ":baz" ":+"
417 -
 421+
418422 if ( ( $list[0] == '' ) && ( count( $list ) == 3 ) ) {
419423 $list = array_slice( $list, 1 );
420424 }
421425 if ( ( count( $list ) == 2 ) && ( $list[1] == '+' ) ) { // try namespace restriction
422426 global $wgContLang;
423427 $idx = $wgContLang->getNsIndex( $list[0] );
424 -
 428+
425429 if ( $idx !== false ) {
426430 $result = $this->addDescription( $result, new SMWNamespaceDescription( $idx ), false );
427431 }
428432 } else {
429433 $value = SMWDataValueFactory::newTypeIDValue( '_wpg', $chunk );
430 -
 434+
431435 if ( $value->isValid() ) {
432436 $result = $this->addDescription( $result, new SMWValueDescription( $value ), false );
433437 }
434438 }
435439
436440 $chunk = $this->readChunk( '\[\[|\]\]|\|\||\|' );
437 -
 441+
438442 if ( $chunk == '||' ) {
439443 $chunk = $this->readChunk( '\[\[|\]\]|\|\||\|' );
440444 $continue = true;
@@ -447,14 +451,14 @@
448452
449453 protected function finishLinkDescription( $chunk, $hasNamespaces, $result, &$setNS ) {
450454 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
451 -
 455+
452456 if ( $result === null ) { // no useful information or concrete error found
453457 $this->m_errors[] = wfMsgForContent( 'smw_badqueryatom' );
454458 } elseif ( !$hasNamespaces && $setNS && ( $this->m_defaultns !== null ) ) {
455459 $result = $this->addDescription( $result, $this->m_defaultns );
456460 $hasNamespaces = true;
457461 }
458 -
 462+
459463 $setNS = $hasNamespaces;
460464
461465 if ( $chunk == '|' ) { // skip content after single |, but report a warning
@@ -467,17 +471,17 @@
468472 }
469473 $this->m_errors[] = wfMsgForContent( 'smw_unexpectedpart', htmlspecialchars( $labelpart ) );
470474 }
471 -
 475+
472476 if ( $chunk != ']]' ) {
473477 // What happended? We found some chunk that could not be processed as
474 - // link content (as in [[Category:Test<q>]]), or the closing ]] are
 478+ // link content (as in [[Category:Test<q>]]), or the closing ]] are
475479 // just missing entirely.
476480 if ( $chunk != '' ) {
477481 $this->m_errors[] = wfMsgForContent( 'smw_misplacedsymbol', htmlspecialchars( $chunk ) );
478 -
 482+
479483 // try to find a later closing ]] to finish this misshaped subpart
480484 $chunk = $this->readChunk( '\]\]' );
481 -
 485+
482486 if ( $chunk != ']]' ) {
483487 $chunk = $this->readChunk( '\]\]' );
484488 }
@@ -486,7 +490,7 @@
487491 $this->m_errors[] = wfMsgForContent( 'smw_noclosingbrackets' );
488492 }
489493 }
490 -
 494+
491495 return $result;
492496 }
493497
@@ -517,23 +521,25 @@
518522 if ( $consume ) {
519523 $this->m_curstring = '';
520524 }
521 -
522 - return $trim ? trim( $chunks[0] ):$chunks[0];
 525+
 526+ return $trim ? trim( $chunks[0] ) : $chunks[0];
523527 } elseif ( count( $chunks ) == 3 ) { // this should generally happen if count is not 1
524528 if ( $chunks[0] == '' ) { // string started with delimiter
525529 if ( $consume ) {
526530 $this->m_curstring = $chunks[2];
527531 }
528 -
529 - return $trim ? trim( $chunks[1] ):$chunks[1];
 532+
 533+ return $trim ? trim( $chunks[1] ) : $chunks[1];
530534 } else {
531535 if ( $consume ) {
532536 $this->m_curstring = $chunks[1] . $chunks[2];
533537 }
534 -
535 - return $trim ? trim( $chunks[0] ):$chunks[0];
 538+
 539+ return $trim ? trim( $chunks[0] ) : $chunks[0];
536540 }
537 - } else { return false; } // should never happen
 541+ } else {
 542+ return false;
 543+ } // should never happen
538544 }
539545
540546 /**
@@ -584,18 +590,18 @@
585591 } else {
586592 $allowed = true;
587593 }
588 -
 594+
589595 if ( !$allowed ) {
590596 $this->m_errors[] = wfMsgForContent( $notallowedmessage, str_replace( '[', '&#x005B;', $newdesc->getQueryString() ) );
591597 return $curdesc;
592598 }
593 -
 599+
594600 if ( $newdesc === null ) {
595601 return $curdesc;
596602 } elseif ( $curdesc === null ) {
597603 return $newdesc;
598604 } else { // we already found descriptions
599 - if ( ( ( $conjunction ) && ( $curdesc instanceof SMWConjunction ) ) ||
 605+ if ( ( ( $conjunction ) && ( $curdesc instanceof SMWConjunction ) ) ||
600606 ( ( !$conjunction ) && ( $curdesc instanceof SMWDisjunction ) ) ) { // use existing container
601607 $curdesc->addDescription( $newdesc );
602608 return $curdesc;
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Outputs.php
@@ -22,7 +22,7 @@
2323 *
2424 * @file SMW_Ouputs.php
2525 * @ingroup SMW
26 - *
 26+ *
2727 * @author Markus Krötzsch
2828 */
2929 class SMWOutputs {
@@ -49,7 +49,7 @@
5050 * @param $id string or predefined constant for identifying a head item
5151 * @param $item string containing a complete HTML-compatibly text snippet that
5252 * should go into the HTML header; only required if $id is no built-in constant.
53 - *
 53+ *
5454 * FIXME: switch on precence of the resource loader (introduced in MW 1.17).
5555 * SMW_sorttable.js uses addOnloadHook and breaks as it is now on 1.17.
5656 */
@@ -60,11 +60,11 @@
6161 switch ( $id ) {
6262 case SMW_HEADER_TOOLTIP:
6363 self::requireHeadItem( SMW_HEADER_STYLE );
64 - self::$mHeadItems['smw_tt'] = '<script type="text/javascript" src="' . $smwgScriptPath . '/skins/SMW_tooltip.js"></script>';
 64+ self::$mHeadItems['smw_tt'] = '<script type="text/javascript" src="' . $smwgScriptPath . '/skins/SMW_tooltip.js"></script>';
6565 break;
6666 case SMW_HEADER_SORTTABLE:
6767 self::requireHeadItem( SMW_HEADER_STYLE );
68 - self::$mHeadItems['smw_st'] = '<script type="text/javascript" src="' . $smwgScriptPath . '/skins/SMW_sorttable.js"></script>';
 68+ self::$mHeadItems['smw_st'] = '<script type="text/javascript" src="' . $smwgScriptPath . '/skins/SMW_sorttable.js"></script>';
6969 break;
7070 case SMW_HEADER_STYLE:
7171 global $wgContLang;
@@ -118,7 +118,9 @@
119119 $po = $parser->mOutput;
120120 }
121121
122 - if ( isset( $po ) ) self::commitToParserOutput( $po );
 122+ if ( isset( $po ) ) {
 123+ self::commitToParserOutput( $po );
 124+ }
123125 }
124126
125127 /**
@@ -151,5 +153,5 @@
152154
153155 self::$mHeadItems = array();
154156 }
155 -
 157+
156158 }
\ No newline at end of file
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_RefreshTab.php
@@ -4,16 +4,18 @@
55 * @ingroup SMW
66 */
77
8 -/*
 8+/**
99 * Protect against register_globals vulnerabilities.
1010 * This line must be present before any global variable is referenced.
1111 */
12 -if ( !defined( 'MEDIAWIKI' ) ) die();
 12+if ( !defined( 'MEDIAWIKI' ) ) {
 13+ die();
 14+}
1315
1416 global $wgHooks;
1517
16 -$wgHooks[ 'SkinTemplateTabs' ][] = 'smwfAddRefreshTab'; // basic tab addition
17 -$wgHooks[ 'SkinTemplateNavigation' ][] = 'smwfAddStructuredRefreshTab'; // structured version for "Vector"-type skins
 18+$wgHooks['SkinTemplateTabs'][] = 'smwfAddRefreshTab'; // basic tab addition
 19+$wgHooks['SkinTemplateNavigation'][] = 'smwfAddStructuredRefreshTab'; // structured version for "Vector"-type skins
1820
1921 /**
2022 * Extends the provided array of content actions with an action that refreshes the article,
@@ -21,7 +23,7 @@
2224 */
2325 function smwfAddRefreshTab( $skin, &$content_actions ) {
2426 global $wgUser;
25 - if ( $wgUser->isAllowed( 'purge' ) ) {
 27+ if ( $wgUser->isAllowed( 'purge' ) ) {
2628 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
2729 $content_actions['purge'] = array(
2830 'class' => false,
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Factbox.php
@@ -19,20 +19,20 @@
2020 */
2121 static public function getFactboxText( SMWSemanticData $semdata, $showfactbox = SMW_FACTBOX_NONEMPTY ) {
2222 global $wgContLang;
23 - wfProfileIn( "SMWFactbox::printFactbox (SMW)" );
 23+ wfProfileIn( 'SMWFactbox::printFactbox (SMW)' );
2424 switch ( $showfactbox ) {
25 - case SMW_FACTBOX_HIDDEN: // show never
26 - wfProfileOut( "SMWFactbox::printFactbox (SMW)" );
 25+ case SMW_FACTBOX_HIDDEN: // never show
 26+ wfProfileOut( 'SMWFactbox::printFactbox (SMW)' );
2727 return '';
2828 case SMW_FACTBOX_SPECIAL: // show only if there are special properties
2929 if ( !$semdata->hasVisibleSpecialProperties() ) {
30 - wfProfileOut( "SMWFactbox::printFactbox (SMW)" );
 30+ wfProfileOut( 'SMWFactbox::printFactbox (SMW)' );
3131 return '';
3232 }
3333 break;
3434 case SMW_FACTBOX_NONEMPTY: // show only if non-empty
3535 if ( !$semdata->hasVisibleProperties() ) {
36 - wfProfileOut( "SMWFactbox::printFactbox (SMW)" );
 36+ wfProfileOut( 'SMWFactbox::printFactbox (SMW)' );
3737 return '';
3838 }
3939 break;
@@ -44,9 +44,18 @@
4545 if ( wfRunHooks( 'smwShowFactbox', array( &$text, $semdata ) ) ) {
4646 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
4747 SMWOutputs::requireHeadItem( SMW_HEADER_STYLE );
48 - $rdflink = SMWInfolink::newInternalLink( wfMsgForContent( 'smw_viewasrdf' ), $wgContLang->getNsText( NS_SPECIAL ) . ':ExportRDF/' . $semdata->getSubject()->getWikiValue(), 'rdflink' );
 48+ $rdflink = SMWInfolink::newInternalLink(
 49+ wfMsgForContent( 'smw_viewasrdf' ),
 50+ $wgContLang->getNsText( NS_SPECIAL ) . ':ExportRDF/' .
 51+ $semdata->getSubject()->getWikiValue(),
 52+ 'rdflink'
 53+ );
4954
50 - $browselink = SMWInfolink::newBrowsingLink( $semdata->getSubject()->getText(), $semdata->getSubject()->getWikiValue(), 'swmfactboxheadbrowse' );
 55+ $browselink = SMWInfolink::newBrowsingLink(
 56+ $semdata->getSubject()->getText(),
 57+ $semdata->getSubject()->getWikiValue(),
 58+ 'swmfactboxheadbrowse'
 59+ );
5160 $text .= '<div class="smwfact">' .
5261 '<span class="smwfactboxhead">' . wfMsgForContent( 'smw_factbox_head', $browselink->getWikiText() ) . '</span>' .
5362 '<span class="smwrdflink">' . $rdflink->getWikiText() . '</span>' .
@@ -82,7 +91,7 @@
8392 }
8493 $text .= '</table></div>';
8594 }
86 - wfProfileOut( "SMWFactbox::printFactbox (SMW)" );
 95+ wfProfileOut( 'SMWFactbox::printFactbox (SMW)' );
8796 return $text;
8897 }
8998
@@ -94,7 +103,7 @@
95104 */
96105 static public function getFactboxTextFromOutput( $parseroutput, $title ) {
97106 global $wgRequest, $smwgShowFactboxEdit, $smwgShowFactbox;
98 - $mws = ( isset( $parseroutput->mSMWMagicWords ) ) ? $parseroutput->mSMWMagicWords:array();
 107+ $mws = ( isset( $parseroutput->mSMWMagicWords ) ) ? $parseroutput->mSMWMagicWords : array();
99108 if ( in_array( 'SMW_SHOWFACTBOX', $mws ) ) {
100109 $showfactbox = SMW_FACTBOX_NONEMPTY;
101110 } elseif ( in_array( 'SMW_NOFACTBOX', $mws ) ) {
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php
@@ -72,31 +72,30 @@
7373 /**
7474 * Return true if semantic data should be processed and displayed for a page
7575 * in the given namespace.
76 - * @return bool
 76+ * @return boolean
7777 */
7878 function smwfIsSemanticsProcessed( $namespace ) {
7979 global $smwgNamespacesWithSemanticLinks;
8080 return !empty( $smwgNamespacesWithSemanticLinks[$namespace] );
8181 }
8282
83 -
8483 /**
8584 * Takes a title text and turns it safely into its DBKey. This function
8685 * reimplements most of the title normalization as done in Title.php in order
8786 * to achieve conversion with less overhead. The official code could be called
8887 * here if more advanced normalization is needed.
89 - *
 88+ *
9089 * @param string $text
9190 */
9291 function smwfNormalTitleDBKey( $text ) {
9392 global $wgCapitalLinks;
94 -
 93+
9594 $text = trim( $text );
96 -
 95+
9796 if ( $wgCapitalLinks ) {
9897 $text = ucfirst( $text );
9998 }
100 -
 99+
101100 return str_replace( ' ', '_', $text );
102101 }
103102
@@ -105,25 +104,25 @@
106105 * reimplements the title normalization as done in Title.php in order to
107106 * achieve conversion with less overhead. The official code could be called
108107 * here if more advanced normalization is needed.
109 - *
 108+ *
110109 * @param string $text
111110 */
112111 function smwfNormalTitleText( $text ) {
113112 global $wgCapitalLinks;
114 -
 113+
115114 $text = trim( $text );
116 -
 115+
117116 if ( $wgCapitalLinks ) {
118117 $text = ucfirst( $text );
119118 }
120 -
 119+
121120 return str_replace( '_', ' ', $text );
122121 }
123122
124123 /**
125124 * Escapes text in a way that allows it to be used as XML content (e.g. as a
126125 * string value for some property).
127 - *
 126+ *
128127 * @param string $text
129128 */
130129 function smwfXMLContentEncode( $text ) {
@@ -133,7 +132,7 @@
134133 /**
135134 * Decodes character references and inserts Unicode characters instead, using
136135 * the MediaWiki Sanitizer.
137 - *
 136+ *
138137 * @param string $text
139138 */
140139 function smwfHTMLtoUTF8( $text ) {
@@ -144,14 +143,14 @@
145144 * This method formats a float number value according to the given language and
146145 * precision settings, with some intelligence to produce readable output. Used
147146 * to format a number that was not hand-formatted by a user.
148 -*
 147+*
149148 * @param mixed $value input number
150149 * @param integer $decplaces optional positive integer, controls how many digits after
151150 * the decimal point are shown
152151 */
153152 function smwfNumberFormat( $value, $decplaces = 3 ) {
154153 global $smwgMaxNonExpNumber;
155 -
 154+
156155 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
157156 $decseparator = wfMsgForContent( 'smw_decseparator' );
158157
@@ -161,7 +160,7 @@
162161 // using number_format. This may lead to 1.200, so then use trim to
163162 // remove trailing zeroes.
164163 $doScientific = false;
165 -
 164+
166165 // @todo: Don't do all this magic for integers, since the formatting does not fit there
167166 // correctly. E.g. one would have integers formatted as 1234e6, not as 1.234e9, right?
168167 // The "$value!=0" is relevant: we want to scientify numbers that are close to 0, but never 0!
@@ -182,7 +181,7 @@
183182 }
184183 }
185184 }
186 -
 185+
187186 if ( $doScientific ) {
188187 // Should we use decimal places here?
189188 $value = sprintf( "%1.6e", $value );
@@ -203,7 +202,7 @@
204203 // Assumes substr is faster than a regular expression replacement.
205204 $end = $decseparator . str_repeat( '0', $decplaces );
206205 $lenEnd = strlen( $end );
207 -
 206+
208207 if ( substr( $value, - $lenEnd ) === $end ) {
209208 $value = substr( $value, 0, - $lenEnd );
210209 } else {
@@ -212,7 +211,7 @@
213212 $value = preg_replace( "/(\\$decseparator\\d+?)0*$/u", '$1', $value, 1 );
214213 }
215214 }
216 -
 215+
217216 return $value;
218217 }
219218
@@ -229,7 +228,9 @@
230229 function smwfEncodeMessages( array $messages, $icon = 'warning', $seperator = ' <!--br-->' ) {
231230 if ( count( $messages ) > 0 ) {
232231 SMWOutputs::requireHeadItem( SMW_HEADER_TOOLTIP );
233 - foreach( $messages as &$message ) $message = htmlspecialchars( $message );
 232+ foreach( $messages as &$message ) {
 233+ $message = htmlspecialchars( $message );
 234+ }
234235 $messageString = implode( $seperator, $messages );
235236 return '<span class="smwttpersist"><span class="smwtticon">' . $icon . '.png</span><span class="smwttcontent">' . $messageString . '</span> </span>';
236237 } else {
@@ -242,10 +243,10 @@
243244 * wfLoadExtensionMessages function will no longer be needed (or supported).
244245 * This function is used for maintaining compatibility with MediaWiki 1.15 or
245246 * below.
246 - *
 247+ *
247248 * @param string $extensionName The extension name for finding the the message
248249 * file; same as in wfLoadExtensionMessages()
249 - *
 250+ *
250251 * @since 1.5.1
251252 */
252253 function smwfLoadExtensionMessages( $extensionName ) {
@@ -260,21 +261,21 @@
261262 * infrastructure allows to set up load balancing and task-dependent use of
262263 * stores (e.g. using other stores for fast querying than for storing new
263264 * facts), somewhat similar to MediaWiki's DB implementation.
264 - *
 265+ *
265266 * @return SMWStore
266267 */
267268 function &smwfGetStore() {
268269 global $smwgMasterStore, $smwgDefaultStore, $smwgIP;
269 -
 270+
270271 // No autoloading for RAP store, since autoloaded classes are in rare cases loaded by MW even if not used in code.
271272 // This is not possible for RAPstore, which depends on RAP being installed.
272 - if ( $smwgDefaultStore == 'SMWRAPStore2' ) {
 273+ if ( $smwgDefaultStore == 'SMWRAPStore2' ) {
273274 include_once( $smwgIP . 'includes/storage/SMW_RAPStore2.php' );
274275 }
275 -
 276+
276277 if ( $smwgMasterStore === null ) {
277278 $smwgMasterStore = new $smwgDefaultStore();
278279 }
279 -
 280+
280281 return $smwgMasterStore;
281282 }
\ No newline at end of file
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_SemanticData.php
@@ -3,10 +3,10 @@
44 * The class in this file manages (special) mProperties that are
55 * associated with a certain subject (article). It is used as a
66 * container for chunks of subject-centred data.
7 - *
 7+ *
88 * @file
99 * @ingroup SMW
10 - *
 10+ *
1111 * @author Markus Krötzsch
1212 * @author Jeroen De Dauw
1313 */
@@ -15,82 +15,82 @@
1616 * Class for representing chunks of semantic data for one given
1717 * article (subject), similar what is typically displayed in the factbox.
1818 * This is a light-weight data container.
19 - *
 19+ *
2020 * @ingroup SMW
2121 */
2222 class SMWSemanticData {
23 -
 23+
2424 /**
2525 * States whether this is a stub object. Stubbing might happen on serialisation to save DB space.
26 - *
 26+ *
2727 * @var boolean
2828 */
29 - public $stubObject = true;
30 -
 29+ public $stubObject = true;
 30+
3131 /**
3232 * Cache for the local version of "Property:"
33 - *
 33+ *
3434 * @var mixed
3535 */
36 - static protected $mPropertyPrefix = false;
37 -
 36+ static protected $mPropertyPrefix = false;
 37+
3838 /**
3939 * Text keys and arrays of datavalue objects.
40 - *
 40+ *
4141 * @var array
42 - */
 42+ */
4343 protected $mPropVals = array();
44 -
 44+
4545 /**
4646 * Text keys and title objects.
47 - *
 47+ *
4848 * @var array
4949 */
5050 protected $mProperties = array();
51 -
 51+
5252 /**
5353 * Stub property data that is not part of $propvals and $mProperties yet. Entries use
5454 * property DB keys as keys. The value is an array of DBkey-arrays that define individual
5555 * datavalues. The stubs will be set up when first accessed.
56 - *
 56+ *
5757 * @var array
5858 */
5959 protected $mStubPropVals = array();
60 -
 60+
6161 /**
6262 * States whether the container holds any normal properties.
63 - *
 63+ *
6464 * @var boolean
6565 */
6666 protected $mHasVisibleProps = false;
67 -
 67+
6868 /**
6969 * States whether the container holds any displayable special mProperties (some are internal only without a display name).
70 - *
 70+ *
7171 * @var boolean
7272 */
7373 protected $mHasVisibleSpecs = false;
74 -
 74+
7575 /**
76 - * States whether repeated values should be avoided. Not needing duplicte elimination
77 - * (e.g. when loading from store) can save much time, since objects can remain stubs until someone
78 - * really acesses their value.
79 - *
80 - * @var boolean
 76+ * States whether repeated values should be avoided. Not needing duplicte elimination
 77+ * (e.g. when loading from store) can save much time, since objects can remain stubs until someone
 78+ * really acesses their value.
 79+ *
 80+ * @var boolean
8181 */
8282 protected $mNoDuplicates;
8383
8484 /**
8585 * SMWWikiPageValue object that is the subject of this container.
8686 * Subjects that are NULL are used to represent "internal objects" only.
87 - *
 87+ *
8888 * @var SMWWikiPageValue
8989 */
9090 protected $mSubject;
9191
9292 /**
9393 * Constructor.
94 - *
 94+ *
9595 * @param SMWWikiPageValue $subject
9696 * @param boolean $noDuplicates
9797 */
@@ -106,9 +106,9 @@
107107 * subject is serialised, yielding a minimal stub data container after unserialisation. This is a little safer than serialising
108108 * nothing: if, for any reason, SMW should ever access an unserialised parser output, then the Semdata container will at least
109109 * look as if properly initialised (though empty).
110 - *
 110+ *
111111 * @note It might be even better to have other members with stub object data that is used for serializing, thus using much less data.
112 - *
 112+ *
113113 * @return array
114114 */
115115 public function __sleep() {
@@ -117,7 +117,7 @@
118118
119119 /**
120120 * Return subject to which the stored semantic annotation refer to.
121 - *
 121+ *
122122 * @return SMWWikiPageValue subject
123123 */
124124 public function getSubject() {
@@ -130,36 +130,36 @@
131131 public function getProperties() {
132132 $this->unstubProperties();
133133 ksort( $this->mProperties, SORT_STRING );
134 -
 134+
135135 return $this->mProperties;
136136 }
137137
138138 /**
139139 * Get the array of all stored values for some property.
140 - *
 140+ *
141141 * @param SMWPropertyValue $property
142 - *
 142+ *
143143 * @return array
144144 */
145145 public function getPropertyValues( SMWPropertyValue $property ) {
146146 if ( array_key_exists( $property->getDBkey(), $this->mStubPropVals ) ) {
147147 // Unstub those entries completely.
148148 $this->unstubProperty( $property->getDBkey(), $property );
149 -
 149+
150150 foreach ( $this->mStubPropVals[$property->getDBkey()] as $dbkeys ) {
151151 $dv = SMWDataValueFactory::newPropertyObjectValue( $property );
152152 $dv->setDBkeys( $dbkeys );
153 -
 153+
154154 if ( $this->mNoDuplicates ) {
155155 $this->mPropVals[$property->getDBkey()][$dv->getHash()] = $dv;
156156 } else {
157157 $this->mPropVals[$property->getDBkey()][] = $dv;
158158 }
159159 }
160 -
 160+
161161 unset( $this->mStubPropVals[$property->getDBkey()] );
162162 }
163 -
 163+
164164 if ( array_key_exists( $property->getDBkey(), $this->mPropVals ) ) {
165165 return $this->mPropVals[$property->getDBkey()];
166166 } else {
@@ -171,33 +171,33 @@
172172 * Generate a hash value to simplify the comparison of this data container with other
173173 * containers. The hash uses PHP's md5 implementation, which is among the fastest hash
174174 * algorithms that PHP offers.
175 - *
 175+ *
176176 * @return string
177177 */
178178 public function getHash() {
179179 $ctx = hash_init( 'md5' );
180 -
 180+
181181 if ( $this->mSubject !== null ) { // here and below, use "_#_" to separate values; really not much care needed here
182182 hash_update( $ctx, '_#_' . $this->mSubject->getHash() );
183183 }
184 -
 184+
185185 foreach ( $this->getProperties() as $property ) {
186186 hash_update( $ctx, '_#_' . $property->getHash() . '##' );
187 -
 187+
188188 foreach ( $this->getPropertyValues( $property ) as $dv ) {
189189 hash_update( $ctx, '_#_' . $dv->getHash() );
190190 }
191191 }
192 -
 192+
193193 return hash_final( $ctx );
194194 }
195195
196196 /**
197197 * Return true if there are any visible properties.
198 - *
 198+ *
199199 * @note While called "visible" this check actually refers to the function
200200 * SMWPropertyValue::isShown(). The name is kept for compatibility.
201 - *
 201+ *
202202 * @return boolean
203203 */
204204 public function hasVisibleProperties() {
@@ -208,10 +208,10 @@
209209 /**
210210 * Return true if there are any special properties that can
211211 * be displayed.
212 - *
 212+ *
213213 * @note While called "visible" this check actually refers to the function
214214 * SMWPropertyValue::isShown(). The name is kept for compatibility.
215 - *
 215+ *
216216 * @return boolean
217217 */
218218 public function hasVisibleSpecialProperties() {
@@ -222,32 +222,34 @@
223223 /**
224224 * Store a value for a property identified by its title object. Duplicate
225225 * value entries are usually ignored.
226 - *
 226+ *
227227 * @note Attention: there is no check whether the type of the given datavalue agrees
228228 * with what SMWDataValueFactory is producing (based on predefined property records and
229229 * the current DB content). Always use SMWDataValueFactory to produce fitting values!
230 - *
 230+ *
231231 * @param SMWPropertyValue $property
232232 * @param SMWDataValue $value
233233 */
234234 public function addPropertyObjectValue( SMWPropertyValue $property, SMWDataValue $value ) {
235 - if ( !$property->isValid() ) return; // nothing we can do
236 -
 235+ if ( !$property->isValid() ) {
 236+ return; // nothing we can do
 237+ }
 238+
237239 if ( !array_key_exists( $property->getDBkey(), $this->mPropVals ) ) {
238240 $this->mPropVals[$property->getDBkey()] = array();
239241 $this->mProperties[$property->getDBkey()] = $property;
240242 }
241 -
 243+
242244 if ( $this->mNoDuplicates ) {
243245 $this->mPropVals[$property->getDBkey()][$value->getHash()] = $value;
244246 } else {
245247 $this->mPropVals[$property->getDBkey()][] = $value;
246248 }
247 -
 249+
248250 if ( !$property->isUserDefined() ) {
249251 if ( $property->isShown() ) {
250 - $this->mHasVisibleSpecs = true;
251 - $this->mHasVisibleProps = true;
 252+ $this->mHasVisibleSpecs = true;
 253+ $this->mHasVisibleProps = true;
252254 }
253255 } else {
254256 $this->mHasVisibleProps = true;
@@ -257,13 +259,13 @@
258260 /**
259261 * Store a value for a given property identified by its text label (without
260262 * namespace prefix). Duplicate value entries are usually ignored.
261 - *
 263+ *
262264 * @param string $propertyName
263265 * @param SMWDataValue $value
264266 */
265267 public function addPropertyValue( $propertyName, SMWDataValue $value ) {
266268 $propertykey = smwfNormalTitleDBKey( $propertyName );
267 -
 269+
268270 if ( array_key_exists( $propertykey, $this->mProperties ) ) {
269271 $property = $this->mProperties[$propertykey];
270272 } else {
@@ -271,14 +273,14 @@
272274 global $wgContLang;
273275 self::$mPropertyPrefix = $wgContLang->getNsText( SMW_NS_PROPERTY ) . ':';
274276 } // explicitly use prefix to cope with things like [[Property:User:Stupid::somevalue]]
275 -
 277+
276278 $property = SMWPropertyValue::makeUserProperty( self::$mPropertyPrefix . $propertyName );
277 -
 279+
278280 if ( !$property->isValid() ) { // error, maybe illegal title text
279281 return;
280282 }
281283 }
282 -
 284+
283285 $this->addPropertyObjectValue( $property, $value );
284286 }
285287
@@ -294,7 +296,7 @@
295297 $propertyKey = $property->getDBkey();
296298 $this->unstubProperty( $propertyKey, $property );
297299 }
298 -
 300+
299301 $this->mStubPropVals[$propertyKey][] = $valueKeys;
300302 }
301303
@@ -322,7 +324,7 @@
323325 * Unstub a single property from the stub data array. If available, an existing object
324326 * for that property might be provided, so we do not need to make a new one. It is not
325327 * checked if the object matches the property name.
326 - *
 328+ *
327329 * @param string $propertyName
328330 * @param $propertyObject
329331 */
@@ -331,13 +333,13 @@
332334 if ( $propertyObject === null ) {
333335 $propertyObject = SMWPropertyValue::makeProperty( $propertyName );
334336 }
335 -
 337+
336338 $this->mProperties[$propertyName] = $propertyObject;
337 -
 339+
338340 if ( !$propertyObject->isUserDefined() ) {
339341 if ( $propertyObject->isShown() ) {
340 - $this->mHasVisibleSpecs = true;
341 - $this->mHasVisibleProps = true;
 342+ $this->mHasVisibleSpecs = true;
 343+ $this->mHasVisibleProps = true;
342344 }
343345 } else {
344346 $this->mHasVisibleProps = true;
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php
@@ -1,10 +1,10 @@
22 <?php
33 /**
44 * This file contains the SMWDataValueFactory class.
5 - *
 5+ *
66 * @author Markus Krötzsch
77 * @author Jeroen De Dauw
8 - *
 8+ *
99 * @file
1010 * @ingroup SMWDataValues
1111 */
@@ -28,21 +28,21 @@
2929
3030 /**
3131 * Array of type labels indexed by type ids. Used for datatype resolution.
32 - *
 32+ *
3333 * @var array
3434 */
3535 static private $mTypeLabels;
36 -
 36+
3737 /**
3838 * Array of ids indexed by type aliases. Used for datatype resolution.
39 - *
 39+ *
4040 * @var array
4141 */
4242 static private $mTypeAliases;
43 -
 43+
4444 /**
4545 * Array of class names for creating new SMWDataValue, indexed by type id.
46 - *
 46+ *
4747 * @var array of SMWDataValue
4848 */
4949 static private $mTypeClasses;
@@ -51,7 +51,7 @@
5252 * Create an SMWDataValue object that can hold values for the type that the
5353 * given SMWTypesValue object specifies. If no $value is given, an empty
5454 * container is created, the value of which can be set later on.
55 - *
 55+ *
5656 * @param SMWTypesValue $typevalue Represents the type of the object
5757 * @param mixed $value user value string, or false if unknown
5858 * @param mixed $caption user-defined caption or false if none given
@@ -61,39 +61,43 @@
6262 if ( !$typeValue->isValid() ) { // just return the error, pass it through
6363 $result = self::newTypeIDValue( '__err' );
6464 $result->addError( $typeValue->getErrors() );
65 -
 65+
6666 return $result;
6767 }
68 -
 68+
6969 return self::newTypeIDValue( $typeValue->getDBkey(), $value, $caption, $property );
7070 }
7171
7272 /**
7373 * Create a value from a type id. If no $value is given, an empty container
7474 * is created, the value of which can be set later on.
75 - *
 75+ *
7676 * @param $typeid id string for the given type
7777 * @param mixed $value user value string, or false if unknown
7878 * @param mixed $caption user-defined caption or false if none given
7979 * @param SMWPropertyValue $property Property object for which this value was made, or NULL
80 - *
 80+ *
8181 * @return SMWDataValue
8282 */
8383 static public function newTypeIDValue( $typeid, $value = false, $caption = false, $property = null ) {
8484 self::initDatatypes();
85 -
 85+
8686 if ( array_key_exists( $typeid, self::$mTypeClasses ) ) { // direct response for basic types
8787 $result = new self::$mTypeClasses[$typeid]( $typeid );
88 - } elseif ( ( $typeid != '' ) && ( $typeid { 0 } != '_' ) ) { // custom type with linear conversion
 88+ } elseif ( ( $typeid != '' ) && ( $typeid{0} != '_' ) ) { // custom type with linear conversion
8989 $result = new self::$mTypeClasses['__lin']( $typeid );
9090 } else { // type really unknown
9191 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
9292 return new SMWErrorValue( wfMsgForContent( 'smw_unknowntype', $typeid ), $value, $caption );
9393 }
94 -
95 - if ( $property !== null ) $result->setProperty( $property );
96 - if ( $value !== false ) $result->setUserValue( $value, $caption );
97 -
 94+
 95+ if ( $property !== null ) {
 96+ $result->setProperty( $property );
 97+ }
 98+ if ( $value !== false ) {
 99+ $result->setUserValue( $value, $caption );
 100+ }
 101+
98102 return $result;
99103 }
100104
@@ -101,11 +105,11 @@
102106 * Create a value for the given property, provided as an SMWPropertyValue
103107 * object. If no value is given, an empty container is created, the value
104108 * of which can be set later on.
105 - *
 109+ *
106110 * @param SMWPropertyValue $property
107111 * @param mixed $value
108112 * @param mixed $caption
109 - *
 113+ *
110114 * @return SMWDataValue
111115 */
112116 static public function newPropertyObjectValue( SMWPropertyValue $property, $value = false, $caption = false ) {
@@ -122,14 +126,14 @@
123127 */
124128 static protected function initDatatypes() {
125129 global $smwgContLang;
126 -
 130+
127131 if ( is_array( self::$mTypeLabels ) ) {
128132 return; // init happened before
129133 }
130 -
 134+
131135 self::$mTypeLabels = $smwgContLang->getDatatypeLabels();
132136 self::$mTypeAliases = $smwgContLang->getDatatypeAliases();
133 -
 137+
134138 // Setup built-in datatypes.
135139 // NOTE: all ids must start with underscores, where two underscores indicate
136140 // truly internal (non user-acessible types). All others should also get a
@@ -167,21 +171,21 @@
168172 '__imp' => 'SMWImportValue', // Special import vocabulary type
169173 '__pro' => 'SMWPropertyValue', // Property type (possibly predefined, no always based on a page)
170174 );
171 -
 175+
172176 wfRunHooks( 'smwInitDatatypes' );
173177 }
174178
175179 /**
176180 * A function for registering/overwriting datatypes for SMW. Should be
177181 * called from within the hook 'smwInitDatatypes'.
178 - *
 182+ *
179183 * @param string $id
180184 * @param string $className
181185 * @param mixed $label
182186 */
183187 static public function registerDatatype( $id, $className, $label = false ) {
184188 self::$mTypeClasses[$id] = $className;
185 -
 189+
186190 if ( $label != false ) {
187191 self::$mTypeLabels[$id] = $label;
188192 }
@@ -192,7 +196,7 @@
193197 * should have a primary label, either provided by SMW or registered with
194198 * registerDatatype(). This function should be called from within the hook
195199 * 'smwInitDatatypes'.
196 - *
 200+ *
197201 * @param string $id
198202 * @param string $label
199203 */
@@ -209,14 +213,14 @@
210214 *
211215 * This method may or may not take aliases into account. For unknown
212216 * labels, the normalised (DB-version) label is used as an ID.
213 - *
 217+ *
214218 * @param string $label
215219 * @param boolean $useAlias
216220 */
217221 static public function findTypeID( $label, $useAlias = true ) {
218222 self::initDatatypes();
219223 $id = array_search( $label, self::$mTypeLabels );
220 -
 224+
221225 if ( $id !== false ) {
222226 return $id;
223227 } elseif ( ( $useAlias ) && ( array_key_exists( $label, self::$mTypeAliases ) ) ) {
@@ -230,13 +234,13 @@
231235 * Get the translated user label for a given internal ID. If the ID does
232236 * not have a label associated with it in the current language, the ID
233237 * itself is transformed into a label (appropriate for user defined types).
234 - *
 238+ *
235239 * @param string $id
236240 */
237241 static public function findTypeLabel( $id ) {
238242 self::initDatatypes();
239 -
240 - if ( $id { 0 } === '_' ) {
 243+
 244+ if ( $id{0} === '_' ) {
241245 if ( array_key_exists( $id, self::$mTypeLabels ) ) {
242246 return self::$mTypeLabels[$id];
243247 } else { // internal type without translation to user space;
@@ -254,7 +258,7 @@
255259 * a property, and that are internal (i.e. not user defined). No labels are
256260 * returned for internal types without user labels (e.g. the special types
257261 * for some special properties), and for user defined types.
258 - *
 262+ *
259263 * @return array
260264 */
261265 static public function getKnownTypeLabels() {
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php
@@ -19,16 +19,16 @@
2020 *
2121 * This function also sets up all autoloading, such that all SMW classes are
2222 * available as early on. Moreover, jobs and special pages are registered.
23 - *
 23+ *
2424 * @param mixed $namespace
2525 * @param boolean $complete
26 - *
 26+ *
2727 * @return true
2828 */
2929 function enableSemantics( $namespace = null, $complete = false ) {
3030 global $wgVersion, $wgExtensionFunctions, $wgAutoloadClasses, $wgSpecialPages, $wgSpecialPageGroups, $wgHooks, $wgExtensionMessagesFiles;
3131 global $smwgIP, $smwgNamespace, $wgJobClasses, $wgExtensionAliasesFiles, $wgServer;
32 -
 32+
3333 // The dot tells that the domain is not complete. It will be completed
3434 // in the Export since we do not want to create a title object here when
3535 // it is not needed in many cases.
@@ -49,16 +49,15 @@
5050
5151 $wgHooks['ParserTestTables'][] = 'smwfOnParserTestTables';
5252 $wgHooks['AdminLinks'][] = 'smwfAddToAdminLinks';
53 -
 53+
5454 if ( version_compare( $wgVersion, '1.17alpha', '>=' ) ) {
5555 // For MediaWiki 1.17 alpha and later.
5656 $wgHooks['ExtensionTypes'][] = 'smwfAddSemanticExtensionType';
57 - }
58 - else {
 57+ } else {
5958 // For pre-MediaWiki 1.17 alpha.
60 - $wgHooks['SpecialVersionExtensionTypes'][] = 'smwfOldAddSemanticExtensionType';
 59+ $wgHooks['SpecialVersionExtensionTypes'][] = 'smwfOldAddSemanticExtensionType';
6160 }
62 -
 61+
6362 // Register special pages aliases file
6463 $wgExtensionAliasesFiles['SemanticMediaWiki'] = $smwgIP . 'languages/SMW_Aliases.php';
6564
@@ -72,14 +71,14 @@
7372 $wgAutoloadClasses['SMWResultPrinter'] = $smwgIP . 'includes/SMW_QueryPrinter.php';
7473 $wgAutoloadClasses['SMWDataValueFactory'] = $smwgIP . 'includes/SMW_DataValueFactory.php';
7574 $wgAutoloadClasses['SMWDataValue'] = $smwgIP . 'includes/SMW_DataValue.php';
76 -
 75+
7776 // Article pages
7877 $apDir = $smwgIP . 'includes/articlepages/';
7978 $wgAutoloadClasses['SMWOrderedListPage'] = $apDir . 'SMW_OrderedListPage.php';
8079 $wgAutoloadClasses['SMWTypePage'] = $apDir . 'SMW_TypePage.php';
8180 $wgAutoloadClasses['SMWPropertyPage'] = $apDir . 'SMW_PropertyPage.php';
82 - $wgAutoloadClasses['SMWConceptPage'] = $apDir . 'SMW_ConceptPage.php';
83 -
 81+ $wgAutoloadClasses['SMWConceptPage'] = $apDir . 'SMW_ConceptPage.php';
 82+
8483 // Printers
8584 $qpDir = $smwgIP . 'includes/queryprinters/';
8685 $wgAutoloadClasses['SMWAutoResultPrinter'] = $qpDir . 'SMW_QP_Auto.php';
@@ -90,7 +89,7 @@
9190 $wgAutoloadClasses['SMWRSSResultPrinter'] = $qpDir . 'SMW_QP_RSSlink.php';
9291 $wgAutoloadClasses['SMWCsvResultPrinter'] = $qpDir . 'SMW_QP_CSV.php';
9392 $wgAutoloadClasses['SMWJSONResultPrinter'] = $qpDir . 'SMW_QP_JSONlink.php';
94 -
 93+
9594 // Datavalues
9695 $dvDir = $smwgIP . 'includes/datavalues/';
9796 $wgAutoloadClasses['SMWContainerValue'] = $dvDir . 'SMW_DV_Container.php';
@@ -111,7 +110,7 @@
112111 $wgAutoloadClasses['SMWBoolValue'] = $dvDir . 'SMW_DV_Bool.php';
113112 $wgAutoloadClasses['SMWConceptValue'] = $dvDir . 'SMW_DV_Concept.php';
114113 $wgAutoloadClasses['SMWImportValue'] = $dvDir . 'SMW_DV_Import.php';
115 -
 114+
116115 // Export
117116 $expDir = $smwgIP . 'includes/export/';
118117 $wgAutoloadClasses['SMWExporter'] = $expDir . 'SMW_Exporter.php';
@@ -119,13 +118,13 @@
120119 $wgAutoloadClasses['SMWExpElement'] = $expDir . 'SMW_Exp_Element.php';
121120 $wgAutoloadClasses['SMWExpLiteral'] = $expDir . 'SMW_Exp_Element.php';
122121 $wgAutoloadClasses['SMWExpResource'] = $expDir . 'SMW_Exp_Element.php';
123 -
 122+
124123 // Stores & queries
125124 $wgAutoloadClasses['SMWQueryProcessor'] = $smwgIP . 'includes/SMW_QueryProcessor.php';
126125 $wgAutoloadClasses['SMWQueryParser'] = $smwgIP . 'includes/SMW_QueryParser.php';
127126 $wgAutoloadClasses['SMWRecordDescription'] = $smwgIP . 'includes/SMW_Record_Descriptions.php';
128127 $wgAutoloadClasses['SMWRecordFieldDescription'] = $smwgIP . 'includes/SMW_Record_Descriptions.php';
129 -
 128+
130129 $stoDir = $smwgIP . 'includes/storage/';
131130 $wgAutoloadClasses['SMWQuery'] = $stoDir . 'SMW_Query.php';
132131 $wgAutoloadClasses['SMWQueryResult'] = $stoDir . 'SMW_QueryResult.php';
@@ -144,7 +143,7 @@
145144 $wgAutoloadClasses['SMWSQLStore2'] = $stoDir . 'SMW_SQLStore2.php';
146145 $wgAutoloadClasses['SMWSQLStore2Table'] = $stoDir . 'SMW_SQLStore2Table.php';
147146 $wgAutoloadClasses['SMWSQLHelpers'] = $stoDir . 'SMW_SQLHelpers.php';
148 -
 147+
149148 // Do not autoload RAPStore, since some special pages load all autoloaded classes, which causes
150149 // troubles with RAP store if RAP is not installed (require_once fails).
151150 // $wgAutoloadClasses['SMWRAPStore'] = $smwgIP . 'includes/storage/SMW_RAPStore.php';
@@ -244,7 +243,7 @@
245244 $wgHooks['MonoBookTemplateToolboxEnd'][] = 'smwfShowBrowseLink';
246245 }
247246 }
248 -
 247+
249248 if ( version_compare( $wgVersion, '1.14alpha', '>=' ) ) {
250249 $wgHooks['SkinAfterContent'][] = 'SMWFactbox::onSkinAfterContent'; // draw Factbox below categories
251250 $smwgMW_1_14 = true; // assume latest 1.14 API
@@ -269,11 +268,11 @@
270269
271270 /**
272271 * Adds the 'semantic' extension type to the type list.
273 - *
 272+ *
274273 * @since 1.5.2
275 - *
 274+ *
276275 * @param $aExtensionTypes Array
277 - *
 276+ *
278277 * @return true
279278 */
280279 function smwfAddSemanticExtensionType( array &$aExtensionTypes ) {
@@ -284,12 +283,12 @@
285284
286285 /**
287286 * @see smwfAddSemanticExtensionType
288 - *
 287+ *
289288 * @since 1.5.2
290 - *
 289+ *
291290 * @param $oSpecialVersion SpecialVersion
292291 * @param $aExtensionTypes Array
293 - *
 292+ *
294293 * @return true
295294 */
296295 function smwfOldAddSemanticExtensionType( SpecialVersion &$oSpecialVersion, array &$aExtensionTypes ) {
@@ -298,38 +297,38 @@
299298
300299 /**
301300 * Adds links to Admin Links page.
302 - **/
 301+ */
303302 function smwfAddToAdminLinks( &$admin_links_tree ) {
304303 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
305 -
 304+
306305 $data_structure_section = new ALSection( wfMsg( 'smw_adminlinks_datastructure' ) );
307 -
 306+
308307 $smw_row = new ALRow( 'smw' );
309308 $smw_row->addItem( ALItem::newFromSpecialPage( 'Categories' ) );
310309 $smw_row->addItem( ALItem::newFromSpecialPage( 'Properties' ) );
311310 $smw_row->addItem( ALItem::newFromSpecialPage( 'UnusedProperties' ) );
312311 $smw_row->addItem( ALItem::newFromSpecialPage( 'SemanticStatistics' ) );
313 -
 312+
314313 $data_structure_section->addRow( $smw_row );
315314 $smw_admin_row = new ALRow( 'smw_admin' );
316315 $smw_admin_row->addItem( ALItem::newFromSpecialPage( 'SMWAdmin' ) );
317 -
 316+
318317 $data_structure_section->addRow( $smw_admin_row );
319318 $smw_docu_row = new ALRow( 'smw_docu' );
320319 $smw_name = wfMsg( 'specialpages-group-smw_group' );
321320 $smw_docu_label = wfMsg( 'adminlinks_documentation', $smw_name );
322 - $smw_docu_row->addItem( AlItem::newFromExternalLink( "http://semantic-mediawiki.org/wiki/Help:User_manual", $smw_docu_label ) );
323 -
 321+ $smw_docu_row->addItem( AlItem::newFromExternalLink( 'http://semantic-mediawiki.org/wiki/Help:User_manual', $smw_docu_label ) );
 322+
324323 $data_structure_section->addRow( $smw_docu_row );
325324 $admin_links_tree->addSection( $data_structure_section, wfMsg( 'adminlinks_browsesearch' ) );
326325 $smw_row = new ALRow( 'smw' );
327326 $displaying_data_section = new ALSection( wfMsg( 'smw_adminlinks_displayingdata' ) );
328 - $smw_row->addItem( AlItem::newFromExternalLink( "http://semantic-mediawiki.org/wiki/Help:Inline_queries", wfMsg( 'smw_adminlinks_inlinequerieshelp' ) ) );
 327+ $smw_row->addItem( AlItem::newFromExternalLink( 'http://semantic-mediawiki.org/wiki/Help:Inline_queries', wfMsg( 'smw_adminlinks_inlinequerieshelp' ) ) );
329328
330329 $displaying_data_section->addRow( $smw_row );
331330 $admin_links_tree->addSection( $displaying_data_section, wfMsg( 'adminlinks_browsesearch' ) );
332331 $browse_search_section = $admin_links_tree->getSection( wfMsg( 'adminlinks_browsesearch' ) );
333 -
 332+
334333 $smw_row = new ALRow( 'smw' );
335334 $smw_row->addItem( ALItem::newFromSpecialPage( 'Browse' ) );
336335 $smw_row->addItem( ALItem::newFromSpecialPage( 'Ask' ) );
@@ -343,15 +342,15 @@
344343 /**
345344 * Register special classes for displaying semantic content on Property/Type
346345 * pages.
347 - *
 346+ *
348347 * @param $title: Title
349348 * @param $article: Article or null
350 - *
 349+ *
351350 * @return true
352351 */
353352 function smwfOnArticleFromTitle( Title &$title, /* Article */ &$article ) {
354353 global $smwgIP;
355 -
 354+
356355 if ( $title->getNamespace() == SMW_NS_TYPE ) {
357356 $article = new SMWTypePage( $title );
358357 } elseif ( $title->getNamespace() == SMW_NS_PROPERTY ) {
@@ -359,7 +358,7 @@
360359 } elseif ( $title->getNamespace() == SMW_NS_CONCEPT ) {
361360 $article = new SMWConceptPage( $title );
362361 }
363 -
 362+
364363 return true;
365364 }
366365
@@ -391,10 +390,10 @@
392391 if ( $skintemplate->data['isarticle'] ) {
393392 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
394393 $browselink = SMWInfolink::newBrowsingLink( wfMsg( 'smw_browselink' ),
395 - $skintemplate->data['titleprefixeddbkey'], false );
396 - echo "<li id=\"t-smwbrowselink\">" . $browselink->getHTML() . "</li>";
397 - }
398 - return true;
 394+ $skintemplate->data['titleprefixeddbkey'], false );
 395+ echo '<li id="t-smwbrowselink">' . $browselink->getHTML() . '</li>';
 396+ }
 397+ return true;
399398 }
400399
401400 /**********************************************/
@@ -424,7 +423,9 @@
425424 smwfInitContentLanguage( $wgLanguageCode );
426425
427426 // Register namespace identifiers
428 - if ( !is_array( $wgExtraNamespaces ) ) { $wgExtraNamespaces = array(); }
 427+ if ( !is_array( $wgExtraNamespaces ) ) {
 428+ $wgExtraNamespaces = array();
 429+ }
429430 $wgExtraNamespaces = $wgExtraNamespaces + $smwgContLang->getNamespaces();
430431 $wgNamespaceAliases = $wgNamespaceAliases + $smwgContLang->getNamespaceAliases();
431432
@@ -470,13 +471,15 @@
471472 */
472473 function smwfInitContentLanguage( $langcode ) {
473474 global $smwgIP, $smwgContLang;
474 -
475 - if ( !empty( $smwgContLang ) ) { return; }
 475+
 476+ if ( !empty( $smwgContLang ) ) {
 477+ return;
 478+ }
476479 wfProfileIn( 'smwfInitContentLanguage (SMW)' );
477480
478481 $smwContLangFile = 'SMW_Language' . str_replace( '-', '_', ucfirst( $langcode ) );
479482 $smwContLangClass = 'SMWLanguage' . str_replace( '-', '_', ucfirst( $langcode ) );
480 -
 483+
481484 if ( file_exists( $smwgIP . 'languages/' . $smwContLangFile . '.php' ) ) {
482485 include_once( $smwgIP . 'languages/' . $smwContLangFile . '.php' );
483486 }
@@ -486,7 +489,7 @@
487490 include_once( $smwgIP . 'languages/SMW_LanguageEn.php' );
488491 $smwContLangClass = 'SMWLanguageEn';
489492 }
490 -
 493+
491494 $smwgContLang = new $smwContLangClass();
492495
493496 wfProfileOut( 'smwfInitContentLanguage (SMW)' );

Status & tagging log