本文整理汇总了PHP中admin_find_write_settings函数的典型用法代码示例。如果您正苦于以下问题:PHP admin_find_write_settings函数的具体用法?PHP admin_find_write_settings怎么用?PHP admin_find_write_settings使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了admin_find_write_settings函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: admin_find_write_settings
/**
* Internal recursive function - finds all settings from submitted form
*
* @param object $node Instance of admin_category, or admin_settingpage
* @param array $data
* @return array
*/
function admin_find_write_settings($node, $data)
{
$return = array();
if (empty($data)) {
return $return;
}
if ($node instanceof admin_category) {
$entries = array_keys($node->children);
foreach ($entries as $entry) {
$return = array_merge($return, admin_find_write_settings($node->children[$entry], $data));
}
} else {
if ($node instanceof admin_settingpage) {
foreach ($node->settings as $setting) {
$fullname = $setting->get_full_name();
if (array_key_exists($fullname, $data)) {
$return[$fullname] = $setting;
}
}
}
}
return $return;
}
示例2: save_config_data
protected function save_config_data(admin_root $adminroot, array $data)
{
$adminroot->errors = array();
$settings = admin_find_write_settings($adminroot, $data);
$count = 0;
foreach ($settings as $fullname => $setting) {
/** @var $setting admin_setting */
$original = $setting->get_setting();
$error = $setting->write_setting($data[$fullname]);
if ($error !== '') {
$adminroot->errors[$fullname] = new stdClass();
$adminroot->errors[$fullname]->data = $data[$fullname];
$adminroot->errors[$fullname]->id = $setting->get_id();
$adminroot->errors[$fullname]->error = $error;
}
$count++;
}
return $count;
}