本文整理汇总了PHP中rex_select::addDBSqlOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP rex_select::addDBSqlOptions方法的具体用法?PHP rex_select::addDBSqlOptions怎么用?PHP rex_select::addDBSqlOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rex_select
的用法示例。
在下文中一共展示了rex_select::addDBSqlOptions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rex_a62_metaFields
//.........这里部分代码省略.........
}
$selected = '';
if (in_array($key, $dbvalues_esc)) {
$selected = ' checked="checked"';
}
if ($oneValue) {
$tag_attr = ' class="' . $class . '"';
$field .= '<input type="' . $typeLabel . '" name="' . $name . '" value="' . $key . '" id="' . $id . '" ' . $attr . $selected . ' />' . "\n";
} else {
$field .= '<p class="' . $class . '">' . "\n";
$field .= '<label for="' . $id . '"><span>' . htmlspecialchars($value) . '</span></label>';
$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);
// 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();
示例2: rex_a62_metaFields
//.........这里部分代码省略.........
if (!$oneValue) {
$field .= '</div>';
}
break;
case 'select':
$tag_attr = ' class="rex-form-select"';
$select = new rex_select();
$select->setStyle('class="rex-form-select"');
$select->setName($name);
$select->setId($id);
$multiple = false;
foreach ($attrArray as $attr_name => $attr_value) {
if (empty($attr_name)) {
continue;
}
$select->setAttribute($attr_name, $attr_value);
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]);
示例3: renderMetaFields
//.........这里部分代码省略.........
$e['field'] = $field;
$fragment = new rex_fragment();
$fragment->setVar('elements', [$e], false);
$field = $fragment->parse('core/form/form.php');
}
break;
case 'select':
$tag_attr = ' class="form-control"';
$select = new rex_select();
$select->setStyle('class="form-control"');
$select->setName($name);
$select->setId($id);
$multiple = false;
foreach ($attrArray as $attr_name => $attr_value) {
if (empty($attr_name)) {
continue;
}
$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();
示例4: rex_a62_metaFields
//.........这里部分代码省略.........
$key = 'true';
}
$selected = '';
if (in_array($key, $dbvalues)) {
$selected = ' checked="checked"';
}
if ($oneValue) {
$tag_attr = ' class="' . $class . '"';
$field .= '<input type="' . $typeLabel . '" name="' . $name . '" value="' . $key . '" id="' . $id . '" ' . $attr . $selected . ' />' . "\n";
} else {
$field .= '<p class="' . $class . '">' . "\n";
$field .= '<label for="' . $id . '"><span>' . htmlspecialchars($value) . '</span></label>';
$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]');