本文整理汇总了PHP中phpbb\request\request::overwrite方法的典型用法代码示例。如果您正苦于以下问题:PHP request::overwrite方法的具体用法?PHP request::overwrite怎么用?PHP request::overwrite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpbb\request\request
的用法示例。
在下文中一共展示了request::overwrite方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_config_for_polls
/**
* Checks the selected poll options
*
* @param array $poll The array of poll data, modified here
* @return array Array with processed language strings with errors, if any
*/
public function check_config_for_polls(&$poll)
{
// Check for poll scoring options to be consistent
if ($this->config['wolfsblvt.advancedpolls.activate_poll_scoring']) {
$poll_max_value = $this->request->variable('wolfsblvt_poll_max_value', 1);
$poll_total_value = $this->request->variable('wolfsblvt_poll_total_value', 1);
if ($poll_max_value > $poll_total_value) {
return array($this->user->lang['AP_POLL_TOTAL_LOWER_MAX_VOTES']);
}
if ($poll_max_value === 1 && (int) $poll['poll_max_options'] > 1) {
$poll_total_value = (int) $poll['poll_max_options'];
$this->request->overwrite('wolfsblvt_poll_total_value', (int) $poll['poll_max_options']);
}
if ((int) $poll['poll_max_options'] > $poll_total_value) {
return array($this->user->lang['AP_POLL_TOTAL_LOWER_MAX_OPTS']);
}
}
// Check for poll end specs
if ($this->config['wolfsblvt.advancedpolls.activate_poll_end']) {
// Poll data from the form
$current_time = time();
$poll_length_scale = $this->request->variable('wolfsblvt_poll_length_scale', 24);
$poll_start = $poll['poll_start'] ?: $current_time;
$poll_length = $poll['poll_length'] ? $poll['poll_length'] * $poll_length_scale * 3600 : 0;
$poll_end = $poll_start + $poll_length;
$poll_end_ary = getdate($poll_end ?: $current_time);
// Gather the options we should set, default to selected poll_end
$opts = array('year', 'mon', 'mday', 'hours', 'minutes');
$new_poll_end_ary = array();
foreach ($opts as $opt) {
$new_poll_end_ary[$opt] = $this->request->variable('wolfsblvt_poll_end_' . $opt, -1);
$new_poll_end_ary[$opt] = $new_poll_end_ary[$opt] > 0 || $new_poll_end_ary[$opt] == 0 && in_array($opt, array('hours', 'minutes')) ? $new_poll_end_ary[$opt] : $poll_end_ary[$opt];
}
// Check that the input date is valid
if (!checkdate($new_poll_end_ary['mon'], $new_poll_end_ary['mday'], $new_poll_end_ary['year']) || $new_poll_end_ary['hours'] > 23 || $new_poll_end_ary['minutes'] > 59) {
return array($this->user->lang['AP_POLL_END_INVALID']);
}
// Calculate poll_start and poll_length based on poll_end, if specified in the form
$new_poll_end = mktime($new_poll_end_ary['hours'], $new_poll_end_ary['minutes'], 0, $new_poll_end_ary['mon'], $new_poll_end_ary['mday'], $new_poll_end_ary['year']);
$new_poll_length = 0;
if (abs($new_poll_end - $poll_end) > 60) {
if ($new_poll_end > $current_time) {
$new_poll_length = ceil(($new_poll_end - $current_time) / 86400);
} else {
if ($poll_end > $current_time) {
$new_poll_length = ceil(($new_poll_end - min($poll_start, $new_poll_end - 60)) / 86400);
}
}
}
if ($new_poll_length > 0) {
$poll['poll_length'] = $new_poll_length;
$poll['poll_start'] = $new_poll_end - $new_poll_length * 86400;
}
}
return array();
}
示例2: get_excluded_options
/**
* {@inheritDoc}
*/
public function get_excluded_options($key, $action, $current_value, &$field_data, $step)
{
if ($step == 2 && $key == 'field_default_value') {
$always_now = $this->request->variable('always_now', -1);
if ($always_now == 1 || $always_now === -1 && $current_value == 'now') {
$now = getdate();
$field_data['field_default_value_day'] = $now['mday'];
$field_data['field_default_value_month'] = $now['mon'];
$field_data['field_default_value_year'] = $now['year'];
$current_value = 'now';
$this->request->overwrite('field_default_value', $current_value, \phpbb\request\request_interface::POST);
} else {
if ($this->request->is_set('field_default_value_day')) {
$field_data['field_default_value_day'] = $this->request->variable('field_default_value_day', 0);
$field_data['field_default_value_month'] = $this->request->variable('field_default_value_month', 0);
$field_data['field_default_value_year'] = $this->request->variable('field_default_value_year', 0);
$current_value = sprintf('%2d-%2d-%4d', $field_data['field_default_value_day'], $field_data['field_default_value_month'], $field_data['field_default_value_year']);
$this->request->overwrite('field_default_value', $current_value, \phpbb\request\request_interface::POST);
} else {
list($field_data['field_default_value_day'], $field_data['field_default_value_month'], $field_data['field_default_value_year']) = explode('-', $current_value);
}
}
return $current_value;
}
return parent::get_excluded_options($key, $action, $current_value, $field_data, $step);
}