本文整理汇总了PHP中config::_UI_get_conf_element方法的典型用法代码示例。如果您正苦于以下问题:PHP config::_UI_get_conf_element方法的具体用法?PHP config::_UI_get_conf_element怎么用?PHP config::_UI_get_conf_element使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config
的用法示例。
在下文中一共展示了config::_UI_get_conf_element方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _UI_get_conf_element
function _UI_get_conf_element($group, $name, $display_name, $type, $val, $selectionArray = null, $deletable = false, $allow_reset = false)
{
global $_CONF, $LANG_CONFIG;
$t = new Template($GLOBALS['_CONF']['path_layout'] . 'admin/config');
$t->set_file('element', 'config_element.thtml');
$blocks = array('delete-button', 'text-element', 'passwd-element', 'placeholder-element', 'select-element', 'list-element', 'unset-param', 'keyed-add-button', 'unkeyed-add-button', 'text-area');
if (is_array($blocks)) {
foreach ($blocks as $block) {
$t->set_block('element', $block);
}
}
$t->set_var('lang_restore', $LANG_CONFIG['restore']);
$t->set_var('lang_enable', $LANG_CONFIG['enable']);
$t->set_var('lang_add_element', $LANG_CONFIG['add_element']);
$t->set_var('name', $name);
$t->set_var('display_name', $display_name);
if (!is_array($val)) {
if (is_float($val)) {
/**
* @todo FIXME: for Locales where the comma is the decimal
* separator, patch output to a decimal point
* to prevent it being cut off by COM_applyFilter
*/
$t->set_var('value', str_replace(',', '.', $val));
} else {
$t->set_var('value', htmlspecialchars($val));
}
}
if ($deletable) {
$t->set_var('delete', $t->parse('output', 'delete-button'));
} else {
if ($allow_reset) {
$t->set_var('unset_link', "(<a href='#' onclick='unset(\"{$name}\");return false;' title='" . $LANG_CONFIG['disable'] . "'>X</a>)");
}
if (($a = strrchr($name, '[')) !== FALSE) {
$o = str_replace(array('[', ']'), array('_', ''), $name);
} else {
$o = $name;
}
$helpUrl = $this->_get_ConfigHelp($group, $o);
if (!empty($helpUrl)) {
$t->set_var('doc_link', $helpUrl);
} else {
$t->set_var('doc_link', '');
}
$docUrl = $this->_getConfigHelpDocument($group, $o);
if ($docUrl != '') {
$t->set_var('cfg_item', $o);
} else {
$t->unset_var('cfg_item');
}
}
if ($type == "unset") {
return $t->finish($t->parse('output', 'unset-param'));
} elseif ($type == "text") {
return $t->finish($t->parse('output', 'text-element'));
} elseif ($type == "textarea") {
return $t->finish($t->parse('output', 'text-area'));
} elseif ($type == "passwd") {
return $t->finish($t->parse('output', 'passwd-element'));
} elseif ($type == "placeholder") {
return $t->finish($t->parse('output', 'placeholder-element'));
} elseif ($type == 'select') {
// if $name is like "blah[0]", separate name and index
$n = explode('[', $name);
$name = $n[0];
$index = null;
if (count($n) == 2) {
$i = explode(']', $n[1]);
$index = $i[0];
}
$type_name = $type . '_' . $name;
if ($group == 'Core') {
$fn = 'configmanager_' . $type_name . '_helper';
} else {
$fn = 'plugin_configmanager_' . $type_name . '_' . $group;
}
if (function_exists($fn)) {
if ($index === null) {
$selectionArray = $fn();
} else {
$selectionArray = $fn($index);
}
} else {
if (is_array($selectionArray)) {
// leave sorting to the function otherwise
uksort($selectionArray, 'strcasecmp');
}
}
if (!is_array($selectionArray)) {
return $t->finish($t->parse('output', 'text-element'));
}
$t->set_block('select-element', 'select-options', 'myoptions');
if (is_array($selectionArray)) {
foreach ($selectionArray as $sName => $sVal) {
if (is_bool($sVal)) {
$t->set_var('opt_value', $sVal ? 'b:1' : 'b:0');
} else {
$t->set_var('opt_value', $sVal);
}
//.........这里部分代码省略.........
示例2: _UI_get_conf_element
/**
* Get a parsed config element based on group $group, name $name,
* type $type, value to be shown $val and label $display_name to be shown
* on the left based on language.
*
* @param string $group Configuration group.
* @param string $name Configuration name on table.
* @param string $display_name Configuration display name based on language.
* @param string $type Configuration type such as select, text, textarea, @select, etc.
* @param string $val Value of configuration
* @param mixed $selectionArray Array of option of select element
* @param bool $deleteable If configuration is deleteable
* @param bool $allow_reset Allow set and unset of configuration
* @return
*/
function _UI_get_conf_element($group, $name, $display_name, $type, $val, $selectionArray = null, $deletable = false, $allow_reset = false)
{
global $_CONF, $LANG_CONFIG;
$t = COM_newTemplate($GLOBALS['_CONF']['path_layout'] . 'admin/config');
$t->set_file('element', 'config_element.thtml');
$blocks = array('delete-button', 'text-element', 'placeholder-element', 'select-element', 'list-element', 'unset-param', 'keyed-add-button', 'unkeyed-add-button', 'text-area', 'validation_error_block');
foreach ($blocks as $block) {
$t->set_block('element', $block);
}
$t->set_var('lang_restore', $LANG_CONFIG['restore']);
$t->set_var('lang_enable', $LANG_CONFIG['enable']);
$t->set_var('lang_add_element', $LANG_CONFIG['add_element']);
$t->set_var('name', $name);
$t->set_var('id_name', str_replace(array('[', ']'), array('_', ''), $name));
$t->set_var('display_name', $display_name);
// check tmp values
if (isset($this->tmpValues[$group][$name])) {
$val = $this->tmpValues[$group][$name];
}
if (!is_array($val)) {
if (is_float($val)) {
/**
* @todo FIXME: for Locales where the comma is the decimal
* separator, patch output to a decimal point
* to prevent it being cut off by COM_applyFilter
*/
$t->set_var('value', str_replace(',', '.', $val));
} else {
$t->set_var('value', htmlspecialchars($val));
}
}
// if there is a error message to shown
if (isset($this->validationErrors[$group][$name])) {
$t->set_var('validation_error_message', $this->validationErrors[$group][$name]);
$t->set_var('error_block', $t->parse('output', 'validation_error_block'));
$t->set_var('error_class', ' input_error');
$t->set_var('value', $this->validationErrorValues[$group][$name]);
} else {
$t->set_var('error_class', '');
$t->set_var('error_block', '');
}
if ($deletable) {
$t->set_var('delete', $t->parse('output', 'delete-button'));
} else {
if ($allow_reset) {
$t->set_var('unset_link', "(<a href=\"#{$name}\" class=\"unset_param\" title='" . $LANG_CONFIG['disable'] . "'>X</a>)");
}
if (($a = strrchr($name, '[')) !== FALSE) {
$on = substr($a, 1, -1);
$o = str_replace(array('[', ']'), array('_', ''), $name);
} else {
$o = $name;
$on = $name;
}
if (!is_numeric($on)) {
$this->_set_ConfigHelp($t, $group, $o);
}
}
if ($type == "unset") {
return $t->finish($t->parse('output', 'unset-param'));
} elseif ($type == "text") {
return $t->finish($t->parse('output', 'text-element'));
} elseif ($type == "textarea") {
return $t->finish($t->parse('output', 'text-area'));
} elseif ($type == "placeholder") {
return $t->finish($t->parse('output', 'placeholder-element'));
} elseif ($type == 'select') {
// if $name is like "blah[0]", separate name and index
$n = explode('[', $name);
$name = $n[0];
$index = null;
if (count($n) == 2) {
$i = explode(']', $n[1]);
$index = $i[0];
}
$type_name = $type . '_' . $name;
if ($group == 'Core') {
$fn = 'configmanager_' . $type_name . '_helper';
} else {
$fn = 'plugin_configmanager_' . $type_name . '_' . $group;
}
if (function_exists($fn)) {
if ($index === null) {
$selectionArray = $fn();
} else {
//.........这里部分代码省略.........
示例3: _UI_get_conf_element
function _UI_get_conf_element($group, $name, $display_name, $type, $val, $selectionArray = null, $deletable = false, $allow_reset = false)
{
global $_CONF, $LANG_CONFIG;
$t = new Template($GLOBALS['_CONF']['path_layout'] . 'admin/config');
$t->set_file('element', 'config_element.thtml');
$blocks = array('delete-button', 'text-element', 'placeholder-element', 'select-element', 'list-element', 'unset-param', 'keyed-add-button', 'unkeyed-add-button');
foreach ($blocks as $block) {
$t->set_block('element', $block);
}
$t->set_var('site_url', $_CONF['site_url']);
$t->set_var('site_admin_url', $_CONF['site_admin_url']);
$t->set_var('layout_url', $_CONF['layout_url']);
$t->set_var('xhtml', XHTML);
$t->set_var('lang_restore', $LANG_CONFIG['restore']);
$t->set_var('lang_enable', $LANG_CONFIG['enable']);
$t->set_var('lang_add_element', $LANG_CONFIG['add_element']);
$t->set_var('name', $name);
$t->set_var('display_name', $display_name);
if (!is_array($val)) {
$t->set_var('value', htmlspecialchars($val));
}
if ($deletable) {
$t->set_var('delete', $t->parse('output', 'delete-button'));
} else {
if ($allow_reset) {
$t->set_var('unset_link', "(<a href='#' onClick='unset(\"{$name}\");' title='" . $LANG_CONFIG['disable'] . "'>X</a>)");
}
if (($a = strrchr($name, '[')) !== FALSE) {
$on = substr($a, 1, -1);
$o = str_replace(array('[', ']'), array('_', ''), $name);
} else {
$o = $name;
$on = $name;
}
if (!is_numeric($on)) {
$descUrl = $this->_get_ConfigHelp($group, $o);
if (!empty($descUrl)) {
$t->set_var('doc_url', $descUrl);
$t->set_var('doc_link', '(<a href="' . $descUrl . '" target="help">?</a>)');
}
}
}
if ($type == "unset") {
return $t->finish($t->parse('output', 'unset-param'));
} elseif ($type == "text") {
return $t->finish($t->parse('output', 'text-element'));
} elseif ($type == "placeholder") {
return $t->finish($t->parse('output', 'placeholder-element'));
} elseif ($type == 'select') {
$type_name = $type . '_' . $name;
if ($group == 'Core') {
$fn = 'configmanager_' . $type_name . '_helper';
} else {
$fn = 'plugin_configmanager_' . $type_name . '_' . $group;
}
if (function_exists($fn)) {
$selectionArray = $fn();
} else {
if (is_array($selectionArray)) {
// leave sorting to the function otherwise
uksort($selectionArray, 'strcasecmp');
}
}
if (!is_array($selectionArray)) {
return $t->finish($t->parse('output', 'text-element'));
}
$t->set_block('select-element', 'select-options', 'myoptions');
foreach ($selectionArray as $sName => $sVal) {
if (is_bool($sVal)) {
$t->set_var('opt_value', $sVal ? 'b:1' : 'b:0');
} else {
$t->set_var('opt_value', $sVal);
}
$t->set_var('opt_name', $sName);
$t->set_var('selected', $val == $sVal ? 'selected="selected"' : '');
$t->parse('myoptions', 'select-options', true);
}
return $t->parse('output', 'select-element');
} elseif (strpos($type, '@') === 0) {
$result = '';
foreach ($val as $valkey => $valval) {
$result .= config::_UI_get_conf_element($group, $name . '[' . $valkey . ']', $display_name . '[' . $valkey . ']', substr($type, 1), $valval, $selectionArray, false);
}
return $result;
} elseif (strpos($type, "*") === 0 || strpos($type, "%") === 0) {
$t->set_var('arr_name', $name);
$t->set_var('array_type', $type);
$button = $t->parse('output', strpos($type, "*") === 0 ? 'keyed-add-button' : 'unkeyed-add-button');
$t->set_var('my_add_element_button', $button);
$result = "";
foreach ($val as $valkey => $valval) {
$result .= config::_UI_get_conf_element($group, $name . '[' . $valkey . ']', $valkey, substr($type, 1), $valval, $selectionArray, true);
}
$t->set_var('my_elements', $result);
return $t->parse('output', 'list-element');
}
}