http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90932

Revision: 90932
Author:   yaron
Date:     2011-06-28 02:59:48 +0000 (Tue, 28 Jun 2011)
Log Message:
-----------
Fixed for SMW 1.6

Modified Paths:
--------------
    
trunk/extensions/SemanticMediaWiki/includes/parserhooks/SMW_SetRecurringEvent.php

Modified: 
trunk/extensions/SemanticMediaWiki/includes/parserhooks/SMW_SetRecurringEvent.php
===================================================================
--- 
trunk/extensions/SemanticMediaWiki/includes/parserhooks/SMW_SetRecurringEvent.php
   2011-06-28 02:56:45 UTC (rev 90931)
+++ 
trunk/extensions/SemanticMediaWiki/includes/parserhooks/SMW_SetRecurringEvent.php
   2011-06-28 02:59:48 UTC (rev 90932)
@@ -50,9 +50,20 @@
                        SMWOutputs::commitToParser( $parser );
                }       
        }
+
+       /**
+        * Helper function - creates an object of type SMWTimeValue based
+        * on a "Julian day" integer
+        */
+       static protected function jdToTimeValue( $jd ) {
+               $timeDataItem = SMWDITime::newFromJD( $jd, 
SMWDITime::CM_GREGORIAN, SMWDITime::PREC_YMDT );
+               $timeValue = new SMWTimeValue( '_dat' );
+               $timeValue->setDataItem( $timeDataItem );
+               return $timeValue;
+       }
        
        /**
-        * Helper function used by doSetRecurringEvent(), as well as the
+        * Helper function used in this class, as well as by the
         * Semantic Internal Objects extension
         *
         * @param Parser &$parser The current parser
@@ -104,7 +115,7 @@
 
                                        foreach ( $excluded_dates as $date_str 
) {
                                                $date = 
SMWDataValueFactory::newTypeIDValue( '_dat', $date_str );
-                                               $excluded_dates_jd[] = 
$date->getDataItem()->getSerialization();
+                                               $excluded_dates_jd[] = 
$date->getDataItem()->getJD();
                                        }
                                        break;
                                default:
@@ -137,11 +148,11 @@
 
                // Get the Julian day value for both the start and end date.
                if ( !is_null( $end_date ) ) {
-                       $end_date_jd = 
$end_date->getDataItem()->getSerialization();
+                       $end_date_jd = $end_date->getDataItem()->getJD();
                }
 
                $cur_date = $start_date;
-               $cur_date_jd = $start_date->getDataItem()->getSerialization();
+               $cur_date_jd = $start_date->getDataItem()->getJD();
                $i = 0;
                $reached_end_date = false;
 
@@ -190,7 +201,7 @@
                                // keep incrementing by a week, until we get 
there.
                                do {
                                        $cur_date_jd += 7;
-                                       $cur_date = 
SMWDataValueFactory::newTypeIDValue( '_dat', $cur_date_jd );
+                                       $cur_date = self::jdToTimeValue( 
$cur_date_jd );
                                        $right_month = ( $cur_date->getMonth() 
== $new_month );
 
                                        if ( $week_num < 0 ) {
@@ -198,19 +209,19 @@
 
                                                do {
                                                        $next_week_jd += 7;
-                                                       $next_week_date = 
SMWDataValueFactory::newTypeIDValue( '_dat', $next_week_jd );
+                                                       $next_week_date = 
self::jdToTimeValue( $next_week_jd );
                                                        $right_week = ( 
$next_week_date->getMonth() != $new_month ) || ( $next_week_date->getYear() != 
$new_year );
                                                } while ( !$right_week );
 
                                                $cur_date_jd = $next_week_jd + 
( 7 * $week_num );
-                                               $cur_date = 
SMWDataValueFactory::newTypeIDValue( '_dat', $cur_date_jd );
+                                               $cur_date = 
self::jdToTimeValue( $cur_date_jd );
                                        } else {
                                                $cur_week_num = ceil( 
$cur_date->getDay() / 7 );
                                                $right_week = ( $cur_week_num 
== $week_num );
 
                                                if ( $week_num == 5 && ( 
$cur_date->getMonth() % 12 == ( $new_month + 1 ) % 12 ) ) {
                                                        $cur_date_jd -= 7;
-                                                       $cur_date = 
SMWDataValueFactory::newTypeIDValue( '_dat', $cur_date_jd );
+                                                       $cur_date = 
self::jdToTimeValue( $cur_date_jd );
                                                        $right_month = 
$right_week = true;
                                                }
                                        }
@@ -218,7 +229,7 @@
                        } else { // $unit == 'day' or 'week'
                                // Assume 'day' if it's none of the above.
                                $cur_date_jd += ( $unit === 'week' ) ? 7 * 
$period : $period;
-                               $cur_date = 
SMWDataValueFactory::newTypeIDValue( '_dat', $cur_date_jd );
+                               $cur_date = self::jdToTimeValue( $cur_date_jd );
                        }
 
                        // should we stop?
@@ -237,4 +248,4 @@
                return array( $property_name, $all_date_strings, $unused_params 
);
        }       
        
-}
\ No newline at end of file
+}


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to