本文整理汇总了PHP中rex_select::addOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP rex_select::addOptions方法的具体用法?PHP rex_select::addOptions怎么用?PHP rex_select::addOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rex_select
的用法示例。
在下文中一共展示了rex_select::addOptions方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rex_a62_metaFields
//.........这里部分代码省略.........
}
break;
case 'select':
$select = new rex_select();
$select->setName($name);
$select->setId($id);
// hier mit den "raw"-values arbeiten, da die rex_select klasse selbst escaped
$select->setSelected($dbvalues);
foreach (rex_split_string($attr) as $attr_name => $attr_value) {
if (empty($attr_name)) {
continue;
}
$select->setAttribute($attr_name, $attr_value);
if ($attr_name == 'multiple') {
$select->setName($name . '[]');
}
}
if (rex_sql::getQueryType($params) == 'SELECT') {
// Werte via SQL Laden
$select->addDBSqlOptions($params);
} else {
// Optionen mit | separiert
// eine einzelne Option kann mit key:value separiert werden
$values = array();
$value_groups = explode('|', $params);
foreach ($value_groups as $value_group) {
if (strpos($value_group, ':') !== false) {
$temp = explode(':', $value_group);
$values[$temp[0]] = $temp[1];
} else {
$values[$value_group] = $value_group;
}
}
$select->addOptions($values);
}
$field .= $select->get();
break;
case 'datetime':
case 'date':
if ($dbvalues_esc[0] == '') {
$dbvalues_esc[0] = time();
}
$style = 'class="rex-fdate"';
$yearStyle = 'class="rex-fdatey"';
$yearSelect = new rex_select();
$yearSelect->addOptions(range(2005, date('Y') + 10), true);
$yearSelect->setName($name . '[year]');
$yearSelect->setSize(1);
$yearSelect->setId($id);
$yearSelect->setStyle($yearStyle);
$yearSelect->setSelected(date('Y', $dbvalues_esc[0]));
$monthSelect = new rex_select();
$monthSelect->addOptions(range(1, 12), true);
$monthSelect->setName($name . '[month]');
$monthSelect->setSize(1);
$monthSelect->setStyle($style);
$monthSelect->setSelected(date('m', $dbvalues_esc[0]));
$daySelect = new rex_select();
$daySelect->addOptions(range(1, 31), true);
$daySelect->setName($name . '[day]');
$daySelect->setSize(1);
$daySelect->setStyle($style);
$daySelect->setSelected(date('j', $dbvalues_esc[0]));
if ($typeLabel == 'datetime') {
$hourSelect = new rex_select();
$hourSelect->addOptions(range(1, 23), true);
示例2: rex_a62_metaFields
//.........这里部分代码省略.........
if ($attr_name == 'multiple') {
$multiple = true;
$select->setName($name . '[]');
}
}
// Beachte auch default values in multiple fields bei ADD.
// Im EDIT wurde dies bereits vorher gehandelt
if ($multiple && !$activeItem) {
$dbvalues = explode('|', $defaultValue);
}
// hier mit den "raw"-values arbeiten, da die rex_select klasse selbst escaped
$select->setSelected($dbvalues);
if (!$multiple) {
$select->setSize(1);
}
if (rex_sql::getQueryType($params) == 'SELECT') {
// Werte via SQL Laden
$select->addDBSqlOptions($params);
} else {
// Optionen mit | separiert
// eine einzelne Option kann mit key:value separiert werden
$values = array();
$value_groups = explode('|', $params);
foreach ($value_groups as $value_group) {
// check ob key:value paar
// und der wert beginnt nicht mit "translate:"
if (strpos($value_group, ':') !== false && strpos($value_group, 'translate:') !== 0) {
$temp = explode(':', $value_group, 2);
$values[$temp[0]] = rex_translate($temp[1]);
} else {
$values[$value_group] = rex_translate($value_group);
}
}
$select->addOptions($values);
}
$field .= $select->get();
break;
case 'date':
case 'time':
case 'datetime':
$tag_attr = ' class="rex-form-select-date"';
$active = $dbvalues[0] != 0;
if ($dbvalues[0] == '') {
$dbvalues[0] = time();
}
$inputValue = array();
$inputValue['year'] = date('Y', $dbvalues[0]);
$inputValue['month'] = date('m', $dbvalues[0]);
$inputValue['day'] = date('j', $dbvalues[0]);
$inputValue['hour'] = date('G', $dbvalues[0]);
$inputValue['minute'] = date('i', $dbvalues[0]);
$rexInput = rex_input::factory($typeLabel);
$rexInput->addAttributes($attrArray);
$rexInput->setAttribute('id', $id);
$rexInput->setAttribute('name', $name);
$rexInput->setValue($inputValue);
$field = $rexInput->getHtml();
$checked = $active ? ' checked="checked"' : '';
$field .= '<input class="rex-form-select-checkbox rex-metainfo-checkbox" type="checkbox" name="' . $name . '[active]" value="1"' . $checked . ' />';
break;
case 'textarea':
$tag_attr = ' class="rex-form-textarea"';
$rexInput = rex_input::factory($typeLabel);
$rexInput->addAttributes($attrArray);
$rexInput->setAttribute('id', $id);
$rexInput->setAttribute('name', $name);
示例3: renderMetaFields
//.........这里部分代码省略.........
}
$select->setAttribute($attr_name, $attr_value);
if ($attr_name == 'multiple') {
$multiple = true;
$select->setName($name . '[]');
$select->setMultiple();
}
}
// Beachte auch default values in multiple fields bei ADD.
// Im EDIT wurde dies bereits vorher gehandelt
if ($multiple && !$activeItem) {
$dbvalues = explode('|', $defaultValue);
}
// hier mit den "raw"-values arbeiten, da die rex_select klasse selbst escaped
$select->setSelected($dbvalues);
if (rex_sql::getQueryType($params) == 'SELECT') {
// Werte via SQL Laden
$select->addDBSqlOptions($params);
} else {
// Optionen mit | separiert
// eine einzelne Option kann mit key:value separiert werden
$values = [];
$value_groups = explode('|', $params);
foreach ($value_groups as $value_group) {
// check ob key:value paar
// und der wert beginnt nicht mit "translate:"
if (strpos($value_group, ':') !== false && strpos($value_group, 'translate:') !== 0) {
$temp = explode(':', $value_group, 2);
$values[$temp[0]] = rex_i18n::translate($temp[1]);
} else {
$values[$value_group] = rex_i18n::translate($value_group);
}
}
$select->addOptions($values);
}
$field .= $select->get();
$e = [];
$e['label'] = $label;
$e['field'] = $field;
$fragment = new rex_fragment();
$fragment->setVar('elements', [$e], false);
$field = $fragment->parse('core/form/form.php');
break;
case 'date':
case 'time':
case 'datetime':
$tag_attr = ' class="form-control-date"';
$active = $dbvalues[0] != 0;
if ($dbvalues[0] == '') {
$dbvalues[0] = time();
}
$inputValue = [];
$inputValue['year'] = date('Y', $dbvalues[0]);
$inputValue['month'] = date('n', $dbvalues[0]);
$inputValue['day'] = date('j', $dbvalues[0]);
$inputValue['hour'] = date('G', $dbvalues[0]);
$inputValue['minute'] = date('i', $dbvalues[0]);
$rexInput = rex_input::factory($typeLabel);
$rexInput->addAttributes($attrArray);
$rexInput->setAttribute('id', $id);
$rexInput->setAttribute('name', $name);
$rexInput->setValue($inputValue);
$field = $rexInput->getHtml();
$checked = $active ? ' checked="checked"' : '';
$field .= '<input class="rex-metainfo-checkbox" type="checkbox" name="' . $name . '[active]" value="1"' . $checked . ' />';
$e = [];
示例4:
$content = '';
$submit_message = rex_i18n::msg('setup_410');
if (count($error_array) > 0) {
$submit_message = rex_i18n::msg('setup_414');
}
$content .= '
<fieldset>
<input type="hidden" name="page" value="setup" />
<input type="hidden" name="step" value="5" />
<input type="hidden" name="lang" value="' . $lang . '" />';
$timezone_sel = new rex_select();
$timezone_sel->setId('rex-form-timezone');
$timezone_sel->setStyle('class="form-control"');
$timezone_sel->setName('timezone');
$timezone_sel->setSize(1);
$timezone_sel->addOptions(DateTimeZone::listIdentifiers(), true);
$timezone_sel->setSelected($config['timezone']);
$db_create_checked = rex_post('redaxo_db_create', 'boolean') ? ' checked="checked"' : '';
$content .= '<legend>' . rex_i18n::msg('setup_402') . '</legend>';
$formElements = [];
$n = [];
$n['label'] = '<label for="rex-form-serveraddress">' . rex_i18n::msg('server') . '</label>';
$n['field'] = '<input class="form-control" type="text" id="rex-form-serveraddress" name="serveraddress" value="' . $config['server'] . '" autofocus />';
$formElements[] = $n;
$n = [];
$n['label'] = '<label for="rex-form-servername">' . rex_i18n::msg('servername') . '</label>';
$n['field'] = '<input class="form-control" type="text" id="rex-form-servername" name="servername" value="' . $config['servername'] . '" />';
$formElements[] = $n;
$n = [];
$n['label'] = '<label for="rex-form-error-email">' . rex_i18n::msg('error_email') . '</label>';
$n['field'] = '<input class="form-control" type="text" id="rex-form-error-email" name="error_email" value="' . $config['error_email'] . '" />';
示例5:
// ----- welche startseite
$sel_startpage = new rex_select();
$sel_startpage->setSize(1);
$sel_startpage->setName('userperm_startpage');
$sel_startpage->setId('rex-user-perm-startpage');
$sel_startpage->setAttribute('class', 'form-control');
$sel_startpage->addOption('default', '');
$startpages = [];
foreach (rex_be_controller::getPages() as $page => $pageObj) {
/* @var $pageObj rex_be_page */
if ($pageObj->hasNavigation() && !$pageObj->isHidden()) {
$startpages[$page] = $pageObj->getTitle();
}
}
asort($startpages);
$sel_startpage->addOptions($startpages);
$userperm_startpage = rex_request('userperm_startpage', 'string');
// --------------------------------- Title
// --------------------------------- FUNCTIONS
$FUNC_UPDATE = '';
$FUNC_APPLY = '';
$FUNC_DELETE = '';
if ($user_id != 0 && (rex::getUser()->isAdmin() || !$sql->getValue('admin'))) {
$FUNC_UPDATE = rex_request('FUNC_UPDATE', 'string');
$FUNC_APPLY = rex_request('FUNC_APPLY', 'string');
$FUNC_DELETE = rex_request('FUNC_DELETE', 'string');
} else {
$user_id = 0;
}
$FUNC_ADD = rex_request('FUNC_ADD', 'string');
$save = rex_request('save', 'int');
示例6: rex_a62_metaFields
//.........这里部分代码省略.........
$field .= '<input type="' . $typeLabel . '" name="' . $name . '" value="' . $key . '" id="' . $id . '" ' . $attr . $selected . ' />' . "\n";
$field .= '</p>' . "\n";
}
}
break;
case 'select':
$select = new rex_select();
$select->setName($name);
$select->setId($id);
$select->setSelected($dbvalues);
foreach (explode(' ', $attr) as $pair) {
if (strpos($pair, '=') === false) {
continue;
}
$temp = explode('=', $pair);
$select->setAttribute($temp[0], str_replace(array('"', "'"), '', $temp[1]));
if ($temp[0] == 'multiple') {
$select->setName($name . '[]');
}
}
if (rex_sql::getQueryType($params) == 'SELECT') {
$select->addDBSqlOptions($params);
} else {
$values = array();
$value_groups = explode('|', $params);
foreach ($value_groups as $value_group) {
if (strpos($value_group, ':') !== false) {
$temp = explode(':', $value_group);
$values[$temp[0]] = $temp[1];
} else {
$values[$value_group] = $value_group;
}
}
$select->addOptions($values);
}
$field .= $select->get();
break;
case 'datetime':
case 'date':
if ($dbvalues[0] == '') {
$dbvalues[0] = time();
}
$style = 'class="rex-fdate"';
$yearStyle = 'class="rex-fdatey"';
$yearSelect = new rex_select();
$yearSelect->addOptions(range(2005, date('Y') + 2), true);
$yearSelect->setName($name . '[year]');
$yearSelect->setSize(1);
$yearSelect->setId($id);
$yearSelect->setStyle($yearStyle);
$yearSelect->setSelected(date('Y', $dbvalues[0]));
$monthSelect = new rex_select();
$monthSelect->addOptions(range(1, 12), true);
$monthSelect->setName($name . '[month]');
$monthSelect->setSize(1);
$monthSelect->setStyle($style);
$monthSelect->setSelected(date('m', $dbvalues[0]));
$daySelect = new rex_select();
$daySelect->addOptions(range(1, 31), true);
$daySelect->setName($name . '[day]');
$daySelect->setSize(1);
$daySelect->setStyle($style);
$daySelect->setSelected(date('j', $dbvalues[0]));
if ($typeLabel == 'datetime') {
$hourSelect = new rex_select();
$hourSelect->addOptions(range(1, 23), true);
示例7:
$bildposition->addOptions(array('oben' => 'über dem Text', 'unten' => 'unter dem Text', 'nachueberschrift' => 'unter der Überschrift', 'nachteaser' => 'unter dem Teasertext'));
$bildanpassen = new rex_select();
$bildanpassen->setName('REX_INPUT_VALUE[' . $i . '][bildanpassen]');
$bildanpassen->setSelected(isset($values[$i]['bildanpassen']) ? $values[$i]['bildanpassen'] : '');
$bildanpassen->setSize(1);
$bildanpassen->addOptions(array('ja' => 'ja', 'nein' => 'nein'));
$ueberschriftlink = new rex_select();
$ueberschriftlink->setName('REX_INPUT_VALUE[' . $i . '][ueberschriftlink]');
$ueberschriftlink->setSelected(isset($values[$i]['ueberschriftlink']) ? $values[$i]['ueberschriftlink'] : '');
$ueberschriftlink->setSize(1);
$ueberschriftlink->addOptions(array('nein' => 'nein', 'ja' => 'ja'));
$bildlink = new rex_select();
$bildlink->setName('REX_INPUT_VALUE[' . $i . '][bildlink]');
$bildlink->setSelected(isset($values[$i]['bildlink']) ? $values[$i]['bildlink'] : '');
$bildlink->setSize(1);
$bildlink->addOptions(array('nein' => 'nein', 'ja' => 'ja'));
echo '
<div id="bereich' . $i . '" class="tab-pane fade in">
<div class="form-horizontal">' . PHP_EOL;
//
// Überschriften
//
if ($anzeige_ueberschriften) {
echo '
<h3>Überschrift</h3>
<div class="form-group">
<label class="col-sm-3 control-label">Überschrift</label>
<div class="col-sm-9">
<input class="form-control" name="REX_INPUT_VALUE[' . $i . '][ueberschrift]" value="' . (isset($values[$i]['ueberschrift']) ? $values[$i]['ueberschrift'] : '') . '" type="text" />
</div>
示例8: htmlspecialchars
} else {
if ($this->relation['relation_type'] == 2) {
$e['field'] = '<input class="form-control" type="text" name="yform_MANAGER_DATANAME[' . $this->getId() . ']" value="' . htmlspecialchars($valueName) . '" id="yform_MANAGER_DATANAME_' . $this->getId() . '" readonly="readonly" /><input type="hidden" name="' . $this->getFieldName() . '" id="yform_MANAGER_DATA_' . $this->getId() . '" value="' . implode(',', $this->getValue()) . '" />';
$e['functionButtons'] = '
<a href="javascript:void(0);" class="btn btn-popup" onclick="yform_manager_openDatalist(' . $this->getId() . ', \'' . $this->relation['source_table'] . '.' . $this->getName() . '\', \'' . $link . '\',\'0\');return false;" title="' . rex_i18n::msg('yform_relation_choose_entry') . '"><i class="rex-icon rex-icon-add"></i></a>
<a href="javascript:void(0);" class="btn btn-popup" onclick="yform_manager_deleteDatalist(' . $this->getId() . ',\'0\');return false;" title="' . rex_i18n::msg('yform_relation_delete_entry') . '"><i class="rex-icon rex-icon-remove"></i></a>';
$fragment = new rex_fragment();
$fragment->setVar('elements', [$e], false);
echo $fragment->parse('core/form/widget.php');
} else {
$select = new rex_select();
$select->setStyle('class="form-control"');
$select->setId('yform_MANAGER_DATALIST_SELECT_' . $this->getId() . '');
$select->setName('yform_MANAGER_DATALIST_SELECT' . $this->getId() . '');
$select->setSize($this->relation['size']);
$select->addOptions($options);
$e['field'] = $select->get() . '<input type="hidden" name="' . $this->getFieldName() . '" id="yform_MANAGER_DATALIST_' . $this->getId() . '" value="' . implode(',', $this->getValue()) . '" />';
$e['moveButtons'] = '
<a href="javascript:void(0);" class="btn btn-popup" onclick="yform_manager_moveDatalist(' . $this->getId() . ',\'top\');return false;" title="' . rex_i18n::msg('yform_relation_move_first_data') . '"><i class="rex-icon rex-icon-top"></i></a>
<a href="javascript:void(0);" class="btn btn-popup" onclick="yform_manager_moveDatalist(' . $this->getId() . ',\'up\');return false;" title="' . rex_i18n::msg('yform_relation_move_up_data') . '>"><i class="rex-icon rex-icon-up"></i></a>
<a href="javascript:void(0);" class="btn btn-popup" onclick="yform_manager_moveDatalist(' . $this->getId() . ',\'down\');return false;" title="' . rex_i18n::msg('yform_relation_down_first_data') . '"><i class="rex-icon rex-icon-down"></i></a>
<a href="javascript:void(0);" class="btn btn-popup" onclick="yform_manager_moveDatalist(' . $this->getId() . ',\'bottom\');return false;" title="' . rex_i18n::msg('yform_relation_move_last_data') . '"><i class="rex-icon rex-icon-bottom"></i></a>';
$e['functionButtons'] = '
<a href="javascript:void(0);" class="btn btn-popup" onclick="yform_manager_openDatalist(' . $this->getId() . ', \'' . $this->relation['source_table'] . ' . ' . $this->getName() . '\', \'' . $link . '\',\'1\');return false;" title="' . rex_i18n::msg('yform_relation_choose_entry') . '"><i class="rex-icon rex-icon-add"></i></a>
<a href="javascript:void(0);" class="btn btn-popup" onclick="yform_manager_deleteDatalist(' . $this->getId() . ',\'1\');return false;" title="' . rex_i18n::msg('yform_relation_delete_entry') . '"><i class="rex-icon rex-icon-remove"></i></a>
';
$fragment = new rex_fragment();
$fragment->setVar('elements', [$e], false);
echo $fragment->parse('core/form/widget_list.php');
}
}