本文整理汇总了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.
//.........这里部分代码省略.........