本文整理汇总了PHP中AdminHelper::getElementDefaults方法的典型用法代码示例。如果您正苦于以下问题:PHP AdminHelper::getElementDefaults方法的具体用法?PHP AdminHelper::getElementDefaults怎么用?PHP AdminHelper::getElementDefaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdminHelper
的用法示例。
在下文中一共展示了AdminHelper::getElementDefaults方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getElementValues
public static function getElementValues($storedElement)
{
$return_array = array();
$app_json = AdminHelper::getElementAppJSON($storedElement['type']);
if ($app_json) {
// start by getting defaults. this will populate scalars, etc.
$return_array = AdminHelper::getElementDefaults($app_json['options']);
foreach ($app_json['options'] as $section_name => $details) {
foreach ($details['data'] as $data => $value) {
if (isset($value['values'])) {
$formatting_data = $value['values'];
}
if ($value['type'] == 'options') {
if (is_array($value['values'])) {
foreach ($value['values'] as $subname => $subvalue) {
if (isset($storedElement['options'][$data][$subname])) {
$return_array['options_' . $value['name'] . '-' . $subname] = AdminHelper::formatElementValue($storedElement['options'][$data][$subname], $subvalue['type'], $formatting_data);
}
}
}
} else {
if ($value['type'] == 'scalar') {
$scalarcount = 0;
if (isset($storedElement['options'][$data])) {
if (is_array($storedElement['options'][$data])) {
$scalarcount = count($storedElement['options'][$data]);
}
}
for ($i = 0; $i < $scalarcount; $i++) {
foreach ($value['values'] as $subname => $subvalue) {
if (isset($subvalue['values'])) {
$formatting_data = $subvalue['values'];
}
if ($subvalue['type'] == 'options') {
if (is_array($subvalue['values'])) {
foreach ($subvalue['values'] as $sub2name => $sub2value) {
if (isset($sub2value['values'])) {
$formatting_data = $sub2value['values'];
}
if (isset($storedElement['options'][$data][$i][$subname][$sub2name])) {
$return_array['options_' . $subname . '-' . $sub2name . '-clone-' . $data . '-' . $i] = AdminHelper::formatElementValue($storedElement['options'][$data][$i][$subname][$sub2name], $sub2value['type'], $formatting_data);
}
}
}
} else {
if (isset($storedElement['options'][$data][$i][$subname])) {
$return_array['options_' . $subname . '-clone-' . $data . '-' . $i] = AdminHelper::formatElementValue($storedElement['options'][$data][$i][$subname], $subvalue['type'], $formatting_data);
}
}
}
}
} else {
if (isset($storedElement['options'][$data])) {
$return_array['options_' . $data] = AdminHelper::formatElementValue($storedElement['options'][$data], $value['type'], $formatting_data);
}
}
}
}
}
}
return $return_array;
}
示例2: foreach
AdminHelper::handleElementFormPOST($_POST, $cash_admin);
// Detects state of element add and routes to /elements/edit if successful
if ($cash_admin->getCurrentElementState() == 'add' && !$cash_admin->getErrorState()) {
$current_element = $cash_admin->getCurrentElement();
AdminHelper::controllerRedirect('/elements/edit/' . $current_element['id']);
}
// Not a completed add, so let's show the form
// first check for requirements
$requirements_response = $cash_admin->requestAndStore(array('cash_request_type' => 'element', 'cash_action' => 'checkuserrequirements', 'user_id' => $cash_admin->effective_user_id, 'element_type' => $element_addtype));
$app_json = AdminHelper::getElementAppJSON($element_addtype);
if ($requirements_response['payload'] === true) {
if ($app_json) {
// set page title/tip
$cash_admin->page_data['ui_title'] = 'Add ' . $app_json['details']['en']['name'] . ' Element';
$cash_admin->page_data['ui_page_tip'] = $app_json['details']['en']['instructions'];
$element_defaults = AdminHelper::getElementDefaults($app_json['options']);
$cash_admin->page_data = array_merge($cash_admin->page_data, $element_defaults);
if (isset($app_json['copy'])) {
if (is_array($app_json['copy']['en'])) {
foreach ($app_json['copy']['en'] as $key => $val) {
$cash_admin->page_data['copy_' . $key] = $val;
}
}
}
if (is_array($app_json['details']['en'])) {
foreach ($app_json['details']['en'] as $key => $val) {
$cash_admin->page_data['details_' . $key] = $val;
}
}
$cash_admin->page_data['all_requirements'] = true;
$cash_admin->page_data['element_button_text'] = 'Save changes';