r71607 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71606‎ | r71607 | r71608 >
Date:00:41, 25 August 2010
Author:yaron
Status:deferred
Tags:
Comment:
Added handling for new parser function, #set_internal_recurring_event
Modified paths:
  • /trunk/extensions/SemanticInternalObjects/SemanticInternalObjects.php (modified) (history)
  • /trunk/extensions/SemanticInternalObjects/SemanticInternalObjects_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticInternalObjects/SemanticInternalObjects.php
@@ -1,6 +1,6 @@
22 <?php
33 /**
4 - * Initialization file for SemanticInternalObjects.
 4+ * Initialization file for Semantic Internal Objects.
55 *
66 * @file
77 * @ingroup SemanticInternalObjects
@@ -35,6 +35,7 @@
3636
3737 function siofRegisterParserFunctions( &$parser ) {
3838 $parser->setFunctionHook( 'set_internal', array( 'SIOHandler', 'doSetInternal' ) );
 39+ $parser->setFunctionHook( 'set_internal_recurring_event', array( 'SIOHandler', 'doSetInternalRecurringEvent' ) );
3940 return true; // always return true, in order not to stop MW's hook processing!
4041 }
4142
@@ -42,6 +43,7 @@
4344 switch ( $langCode ) {
4445 default:
4546 $magicWords['set_internal'] = array ( 0, 'set_internal' );
 47+ $magicWords['set_internal_recurring_event'] = array ( 0, 'set_internal_recurring_event' );
4648 }
4749 return true;
48 -}
\ No newline at end of file
 50+}
Index: trunk/extensions/SemanticInternalObjects/SemanticInternalObjects_body.php
@@ -284,6 +284,32 @@
285285 self::$mInternalObjects[] = $internalObject;
286286 }
287287
 288+ public static function doSetInternalRecurringEvent( &$parser ) {
 289+ $params = func_get_args();
 290+ array_shift( $params ); // We already know the $parser ...
 291+
 292+ // first param should be a standalone property name
 293+ $objToPagePropName = array_shift( $params );
 294+
 295+ $results = SMWParserExtensions::getDatesForRecurringEvent( $params );
 296+ if ( $results == null ) {
 297+ return null;
 298+ }
 299+
 300+ list( $property, $all_date_strings, $unused_params ) = $results;
 301+
 302+ // Mimic a call to #set_internal for each date.
 303+ foreach ( $all_date_strings as $date_string ) {
 304+ $first_params = array(
 305+ $parser,
 306+ $objToPagePropName,
 307+ "$property=$date_string"
 308+ );
 309+ $cur_params = array_merge( $first_params, $unused_params );
 310+ call_user_func_array( 'SIOHandler::doSetInternal', $cur_params );
 311+ }
 312+ }
 313+
288314 public static function updateData( $subject ) {
289315 $sioSQLStore = new SIOSQLStore();
290316 // Find all "pages" in the SMW IDs table that are internal

Status & tagging log