Пример #1
0
 /**
  * Just calls SMW's own #subobject for each instance of this
  * recurring event.
  */
 public static function doSetInternalRecurringEvent(&$parser)
 {
     // This is a hack, as is doSetInternal() - see comments
     // in that method.
     $params = func_get_args();
     array_shift($params);
     // We already know the $parser ...
     // First param should be a standalone property name.
     $objToPagePropName = array_shift($params);
     $results = SMWSetRecurringEvent::getDatesForRecurringEvent($params);
     if ($results == null) {
         return null;
     }
     list($property, $all_date_strings, $unused_params) = $results;
     // Mimic a call to #subobject for each date.
     foreach ($all_date_strings as $date_string) {
         $first_params = array(&$parser, '', $objToPagePropName . '=' . $parser->getTitle()->getText(), "{$property}={$date_string}");
         $cur_params = array_merge($first_params, $unused_params);
         call_user_func_array(array('SMWSubobject', 'render'), $cur_params);
     }
 }
Пример #2
0
 /**
  * @return an array of the values to be used in the target field of the target form
  */
 function getValues(&$data)
 {
     $start = SPSUtils::fromArray($data, 'start');
     $end = SPSUtils::fromArray($data, 'end', $start);
     $period = SPSUtils::fromArray($data, 'period', 1);
     $unit = SPSUtils::fromArray($data, 'unit', 'day');
     if ($start === null || $start === '') {
         throw new SPSException(SPSUtils::buildMessage('spserror-date-startdatemissing'));
     }
     //prepare params for getDatesForRecurringEvent
     $params = array('property=SomeDummyProperty', 'start=' . $start, 'end=' . $end, 'period=' . $period, 'unit=' . $unit);
     $values = SMWSetRecurringEvent::getDatesForRecurringEvent($params);
     if ($values === null) {
         throw new SPSException(SPSUtils::buildMessage('spserror-date-internalerror'));
     }
     // if the first date did not contain a time, remove the time from all
     // generated dates
     if (preg_match('/.:../', $values[1][0]) === 0) {
         foreach ($values[1] as $key => $value) {
             $values[1][$key] = trim(preg_replace('/..:..:../', '', $value));
         }
     }
     return $values[1];
 }
 /**
  * Handle the #set_internal_recurring_event parser function.
  */
 public static function doSetInternalRecurringEvent(&$parser)
 {
     $params = func_get_args();
     array_shift($params);
     // We already know the $parser ...
     // First param should be a standalone property name.
     $objToPagePropName = array_shift($params);
     // The location of this function changed in SMW 1.5.3
     if (class_exists('SMWSetRecurringEvent')) {
         $results = SMWSetRecurringEvent::getDatesForRecurringEvent($params);
     } else {
         $results = SMWParserExtensions::getDatesForRecurringEvent($params);
     }
     if ($results == null) {
         return null;
     }
     list($property, $all_date_strings, $unused_params) = $results;
     // Mimic a call to #set_internal for each date.
     foreach ($all_date_strings as $date_string) {
         $first_params = array(&$parser, $objToPagePropName, "{$property}={$date_string}");
         $cur_params = array_merge($first_params, $unused_params);
         call_user_func_array('SIOHandler::doSetInternal', $cur_params);
     }
 }