r82300 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82299‎ | r82300 | r82301 >
Date:21:47, 16 February 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
spacing tweaks :)
Modified paths:
  • /trunk/extensions/SemanticInternalObjects/SemanticInternalObjects_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticInternalObjects/SemanticInternalObjects_body.php
@@ -1,13 +1,10 @@
22 <?php
3 -/**
4 - * @author Yaron Koren
5 - */
63
7 -if ( !defined( 'MEDIAWIKI' ) ) die();
8 -
94 /**
105 * Class that holds information on a single internal object, including all
116 * its properties.
 7+ *
 8+ * @author Yaron Koren
129 */
1310 class SIOInternalObject {
1411 protected $mMainTitle;
@@ -75,6 +72,7 @@
7673 function __construct($name, $namespace) {
7774 $this->mSIOTitle = new SIOTitle( $name, $namespace );
7875 }
 76+
7977 function getExportData() {
8078 global $smwgNamespace;
8179 return new SMWExpData( new SMWExpResource( SIOExporter::getResolverURL() . $this->mSIOTitle->getPrefixedURL() ) );
@@ -106,6 +104,7 @@
107105 * protected, and thus can't be accessed externally.
108106 */
109107 class SIOSQLStore extends SMWSQLStore2 {
 108+
110109 static function deleteDataForPage( $subject ) {
111110 $pageName = $subject->getDBKey();
112111 $namespace = $subject->getNamespace();
@@ -120,6 +119,7 @@
121120 'smw_title LIKE ' . $db->addQuotes( $pageName . '#%' ) . ' AND ' . 'smw_namespace=' . $db->addQuotes( $namespace ) . ' AND smw_iw=' . $db->addQuotes( $iw ),
122121 'SIO::getSMWPageObjectIDs'
123122 );
 123+
124124 while ( $row = $db->fetchObject( $res ) ) {
125125 $idsForDeletion[] = $row->smw_id;
126126 }
@@ -154,6 +154,7 @@
155155 // set all the properties pointing from this internal object
156156 foreach ( $internalObject->getPropertyValuePairs() as $propertyValuePair ) {
157157 list( $property, $value ) = $propertyValuePair;
 158+
158159 // handling changed in SMW 1.5
159160 if ( method_exists( 'SMWSQLStore2', 'findPropertyTableID' ) ) {
160161 $tableid = SMWSQLStore2::findPropertyTableID( $property );
@@ -169,6 +170,7 @@
170171 $isText = ( $mode == SMW_SQL2_TEXT2 );
171172 $isCoords = false;
172173 }
 174+
173175 if ( $isRelation ) {
174176 $upRels2[] = array(
175177 's_id' => $ioID,
@@ -182,6 +184,7 @@
183185 } else {
184186 $valueNum = $value->getNumericValue();
185187 }
 188+
186189 $upAtts2[] = array(
187190 's_id' => $ioID,
188191 'p_id' => $this->makeSMWPropertyID( $property ),
@@ -206,6 +209,7 @@
207210 );
208211 }
209212 }
 213+
210214 return array( $upRels2, $upAtts2, $upText2, $upCoords );
211215 }
212216
@@ -228,6 +232,7 @@
229233 'smw_title LIKE ' . $db->addQuotes( $pageName . '#%' ) . ' AND ' . 'smw_namespace=' . $db->addQuotes( $namespace ) . ' AND smw_iw=' . $db->addQuotes( $iw ),
230234 'SIO::getSMWPageObjectIDs'
231235 );
 236+
232237 while ( $row = $db->fetchObject( $res ) ) {
233238 $value = new SIOInternalObjectValue( $row->smw_title, $row->smw_namespace );
234239 $semdata = new SMWSemanticData( $value, false );
@@ -238,8 +243,10 @@
239244 $semdata->addPropertyStubValue( reset( $d ), end( $d ) );
240245 }
241246 }
 247+
242248 $rdfDataArray[] = SMWExporter::makeExportData( $semdata, null );
243249 }
 250+
244251 return true;
245252 }
246253 }
@@ -269,8 +276,10 @@
270277 if ( ! empty( self::$mCurPageFullName ) ) {
271278 self::$mHandledPages[] = self::$mCurPageFullName;
272279 }
 280+
273281 self::$mCurPageFullName = '';
274282 self::$mInternalObjectIndex = 1;
 283+
275284 return true;
276285 }
277286
@@ -296,14 +305,17 @@
297306 self::$mCurPageFullName = $mainPageFullName;
298307 self::$mInternalObjectIndex = 1;
299308 }
 309+
300310 $curObjectNum = self::$mInternalObjectIndex;
301311 $params = func_get_args();
302312 array_shift( $params ); // we already know the $parser...
303313 $internalObject = new SIOInternalObject( $title, $curObjectNum );
304314 $objToPagePropName = array_shift( $params );
305315 $internalObject->addPropertyAndValue( $objToPagePropName, self::$mCurPageFullName );
 316+
306317 foreach ( $params as $param ) {
307 - $parts = explode( "=", trim( $param ), 2 );
 318+ $parts = explode( '=', trim( $param ), 2 );
 319+
308320 if ( count( $parts ) == 2 ) {
309321 $key = $parts[0];
310322 $value = $parts[1];
@@ -312,6 +324,7 @@
313325 if ( substr( $key, - 5 ) == '#list' ) {
314326 $key = substr( $key, 0, strlen( $key ) - 5 );
315327 $listValues = explode( ',', $value );
 328+
316329 foreach ( $listValues as $listValue ) {
317330 $internalObject->addPropertyAndValue( $key, trim( $listValue ) );
318331 }
@@ -320,6 +333,7 @@
321334 }
322335 }
323336 }
 337+
324338 self::$mInternalObjects[] = $internalObject;
325339 }
326340
@@ -339,6 +353,7 @@
340354 } else {
341355 $results = SMWParserExtensions::getDatesForRecurringEvent( $params );
342356 }
 357+
343358 if ( $results == null ) {
344359 return null;
345360 }
@@ -352,6 +367,7 @@
353368 $objToPagePropName,
354369 "$property=$date_string"
355370 );
 371+
356372 $cur_params = array_merge( $first_params, $unused_params );
357373 call_user_func_array( 'SIOHandler::doSetInternal', $cur_params );
358374 }
@@ -384,6 +400,7 @@
385401 $allAtts2Inserts = array();
386402 $allText2Inserts = array();
387403 $allCoordsInserts = array();
 404+
388405 foreach ( self::$mInternalObjects as $internalObject ) {
389406 list( $upRels2, $upAtts2, $upText2, $upCoords ) = $sioSQLStore->getStorageSQL( $internalObject );
390407 $allRels2Inserts = array_merge( $allRels2Inserts, $upRels2 );
@@ -408,9 +425,11 @@
409426 if ( count( $allCoordsInserts ) > 0 ) {
410427 $db->insert( 'sm_coords', $allCoordsInserts, 'SIO::updateCoordsData' );
411428 }
 429+
412430 // end transaction
413431 $db->commit( 'SIO::updatePageData' );
414432 self::$mInternalObjects = array();
 433+
415434 return true;
416435 }
417436
@@ -437,9 +456,11 @@
438457 'smw_title LIKE ' . $db->addQuotes( $oldPageName . '#%' ) . ' AND ' . 'smw_namespace=' . $db->addQuotes( $oldNamespace ) . ' AND smw_iw=' . $db->addQuotes( $iw ),
439458 'SIO::getTitlesForPageMove'
440459 );
 460+
441461 while ( $row = $db->fetchObject( $res ) ) {
442462 $sioNames[] = $row->smw_title;
443463 }
 464+
444465 foreach ( $sioNames as $sioName ) {
445466 // update the name, and possibly the namespace as well
446467 $newSIOName = str_replace( $oldPageName, $newPageName, $sioName );
@@ -450,6 +471,7 @@
451472 'SIO::updateTitlesForPageMove'
452473 );
453474 }
 475+
454476 return true;
455477 }
456478
@@ -461,15 +483,19 @@
462484 */
463485 static function handleUpdatingOfInternalObjects( &$jobs ) {
464486 $uniqueTitles = array();
 487+
465488 foreach ( $jobs as $i => $job ) {
466489 $title = Title::makeTitleSafe( $job->title->getNamespace(), $job->title->getText() );
467490 $id = $title->getArticleID();
468491 $uniqueTitles[$id] = $title;
469492 }
 493+
470494 $jobs = array();
 495+
471496 foreach ( $uniqueTitles as $id => $title ) {
472497 $jobs[] = new SMWUpdateJob( $title );
473498 }
 499+
474500 return true;
475501 }
476502
@@ -483,10 +509,14 @@
484510 static function handleRefreshingOfInternalObjects( &$jobs ) {
485511 $allJobs = $jobs;
486512 $jobs = array();
 513+
487514 foreach ( $allJobs as $job ) {
488 - if ( strpos( $job->title->getText(), '#' ) === false )
 515+ if ( strpos( $job->title->getText(), '#' ) === false ) {
489516 $jobs[] = $job;
 517+ }
490518 }
 519+
491520 return true;
492521 }
 522+
493523 }

Status & tagging log