當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。