当前位置: 首页>>代码示例>>PHP>>正文


PHP Settings::set方法代码示例

本文整理汇总了PHP中SMW\Settings::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::set方法的具体用法?PHP Settings::set怎么用?PHP Settings::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SMW\Settings的用法示例。


在下文中一共展示了Settings::set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parse

 /**
  * Parse parameters and set internal properties
  *
  * @since 1.9
  *
  * @param $params
  */
 protected function parse($parameters)
 {
     // Initialize variables.
     $all_date_strings = array();
     $unused_params = array();
     $property_name = $start_date = $end_date = $unit = $period = $week_num = null;
     $included_dates = array();
     $excluded_dates = array();
     $excluded_dates_jd = array();
     // Parse parameters and assign values
     foreach ($parameters as $name => $values) {
         foreach ($values as $value) {
             switch ($name) {
                 case 'property':
                     $this->property = $value;
                     break;
                 case 'start':
                     $start_date = DataValueFactory::getInstance()->newTypeIDValue('_dat', $value);
                     break;
                 case 'end':
                     $end_date = DataValueFactory::getInstance()->newTypeIDValue('_dat', $value);
                     break;
                 case 'limit':
                     // Override default limit with query specific limit
                     $this->settings->set('smwgDefaultNumRecurringEvents', (int) $value);
                     break;
                 case 'unit':
                     $unit = $value;
                     break;
                 case 'period':
                     $period = (int) $value;
                     break;
                 case 'week number':
                     $week_num = (int) $value;
                     break;
                 case 'include':
                     // This is for compatibility only otherwise we break
                     // to much at once. Instead of writing include=...;...
                     // it should be include=...;...|+sep=; because the
                     // ParameterParser class is conditioned to split those
                     // parameter accordingly
                     if (strpos($value, ';')) {
                         $included_dates = explode(';', $value);
                     } else {
                         $included_dates[] = $value;
                     }
                     break;
                 case 'exclude':
                     // Some as above
                     if (strpos($value, ';')) {
                         $excluded_dates = explode(';', $value);
                     } else {
                         $excluded_dates[] = $value;
                     }
                     break;
                 default:
                     $this->parameters[$name][] = $value;
             }
         }
     }
     if ($start_date === null) {
         $this->errors[] = new Message('smw-events-start-date-missing');
         return;
     } else {
         if (!$start_date->getDataItem() instanceof SMWDITime) {
             $this->setError($start_date->getErrors());
             return;
         }
     }
     // Check property
     if (is_null($this->property)) {
         $this->errors[] = new Message('smw-events-property-missing');
         return;
     }
     // Exclude dates
     foreach ($excluded_dates as $date_str) {
         $excluded_dates_jd[] = $this->getJulianDay(DataValueFactory::getInstance()->newTypeIDValue('_dat', $date_str));
     }
     // If the period is null, or outside of normal bounds, set it to 1.
     if (is_null($period) || $period < 1 || $period > 500) {
         $period = 1;
     }
     // Handle 'week number', but only if it's of unit 'month'.
     if ($unit == 'month' && !is_null($week_num)) {
         $unit = 'dayofweekinmonth';
         if ($week_num < -4 || $week_num > 5 || $week_num == 0) {
             $week_num = null;
         }
     }
     if ($unit == 'dayofweekinmonth' && is_null($week_num)) {
         $week_num = ceil($start_date->getDay() / 7);
     }
     // Get the Julian day value for both the start and end date.
//.........这里部分代码省略.........
开发者ID:whysasse,项目名称:kmwiki,代码行数:101,代码来源:RecurringEvents.php


注:本文中的SMW\Settings::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。