本文整理汇总了PHP中AdminHelper::setBasicElementFormData方法的典型用法代码示例。如果您正苦于以下问题:PHP AdminHelper::setBasicElementFormData方法的具体用法?PHP AdminHelper::setBasicElementFormData怎么用?PHP AdminHelper::setBasicElementFormData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdminHelper
的用法示例。
在下文中一共展示了AdminHelper::setBasicElementFormData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleElementFormPOST
public static function handleElementFormPOST($post_data, &$cash_admin, $options_array)
{
if (isset($post_data['doelementadd'])) {
// Adding a new element:
$cash_admin->setCurrentElementState('add');
$element_add_request = new CASHRequest(array('cash_request_type' => 'element', 'cash_action' => 'addelement', 'name' => $post_data['element_name'], 'type' => $post_data['element_type'], 'options_data' => $options_array, 'user_id' => AdminHelper::getPersistentData('cash_effective_user')));
if ($element_add_request->response['status_uid'] != 'element_addelement_200') {
$cash_admin->setErrorState('element_add_failure');
} else {
$cash_admin->setCurrentElement($element_add_request->response['payload']);
}
} elseif (isset($post_data['doelementedit'])) {
// Editing an existing element:
$cash_admin->setCurrentElementState('edit');
$element_edit_request = new CASHRequest(array('cash_request_type' => 'element', 'cash_action' => 'editelement', 'id' => $post_data['element_id'], 'name' => $post_data['element_name'], 'options_data' => $options_array));
if ($element_edit_request->response['status_uid'] == 'element_editelement_200') {
$cash_admin->setCurrentElement($post_data['element_id']);
} else {
$cash_admin->setErrorState('element_edit_failure');
}
}
AdminHelper::setBasicElementFormData($cash_admin);
}
示例2: arsort
arsort($tmp_locations_array);
// sort temp array most to least
$tmp_locations_array = array_slice($tmp_locations_array, 0, 5);
// trim temp array to no more than 5
$locations_array = array();
// let's rebuild the locations array
foreach ($tmp_locations_array as $location => $total) {
$locations_array[] = array('access_location' => $location, 'total' => $total);
}
$cash_admin->page_data['location_analytics'] = new ArrayIterator($locations_array);
$cash_admin->page_data['method_analytics'] = new ArrayIterator($methods_array);
}
// Detects if element add has happened and deals with POST data if it has
AdminHelper::handleElementFormPOST($_POST, $cash_admin);
// Set basic id/name stuff for the element
AdminHelper::setBasicElementFormData($cash_admin);
// pull stored element data
$cash_admin->page_data = array_merge($cash_admin->page_data, AdminHelper::getElementValues($current_element));
$cash_admin->page_data['ui_title'] = '' . $current_element['name'] . '';
$cash_admin->page_data['element_button_text'] = 'Save changes';
$cash_admin->page_data['element_rendered_content'] = $cash_admin->mustache_groomer->render(AdminHelper::getElementTemplate($current_element), $cash_admin->page_data);
$campaign_response = $cash_admin->requestAndStore(array('cash_request_type' => 'element', 'cash_action' => 'getcampaignforelement', 'id' => $current_element['id']));
if ($campaign_response['payload']) {
$cash_admin->page_data['campaign_id'] = $campaign_response['payload']['id'];
$cash_admin->page_data['campaign_title'] = $campaign_response['payload']['title'];
}
} else {
AdminHelper::controllerRedirect('/elements/');
}
} else {
AdminHelper::controllerRedirect('/elements/');
示例3: handleElementFormPOST
public static function handleElementFormPOST($post_data, &$cash_admin)
{
global $admin_primary_cash_request;
if (AdminHelper::elementFormSubmitted($post_data)) {
// first create the options array
$options_array = array();
// now populate it from the POST data, fixing booleans
$app_json = AdminHelper::getElementAppJSON($post_data['element_type']);
if ($app_json) {
foreach ($app_json['options'] as $section_name => $details) {
foreach ($details['data'] as $data => $values) {
if ($values['type'] == 'boolean') {
if (isset($post_data[$data])) {
$options_array[$data] = 1;
} else {
$options_array[$data] = 0;
}
} elseif ($values['type'] == 'options') {
if (is_array($values['values'])) {
foreach ($values['values'] as $subname => $subvalues) {
$options_array[$data][$subname] = $post_data[$data . '-' . $subname];
}
}
} else {
if ($values['type'] != 'scalar') {
$options_array[$data] = $post_data[$data];
}
}
}
}
$scalars = AdminHelper::processScalarData($post_data, $app_json);
$options_array = array_merge($options_array, $scalars);
}
if (isset($post_data['doelementadd'])) {
// Adding a new element:
$cash_admin->setCurrentElementState('add');
$admin_primary_cash_request->processRequest(array('cash_request_type' => 'element', 'cash_action' => 'addelement', 'name' => $post_data['element_name'], 'type' => $post_data['element_type'], 'options_data' => $options_array, 'user_id' => AdminHelper::getPersistentData('cash_effective_user')));
if ($admin_primary_cash_request->response['status_uid'] == 'element_addelement_200') {
$current_campaign = false;
if ($post_data['in_campaign']) {
$current_campaign = $post_data['in_campaign'];
} else {
$current_campaign = AdminHelper::getPersistentData('current_campaign');
}
if ($current_campaign) {
$cash_admin->requestAndStore(array('cash_request_type' => 'element', 'cash_action' => 'addelementtocampaign', 'campaign_id' => $current_campaign, 'element_id' => $admin_primary_cash_request->response['payload']));
// handle differently for AJAX and non-AJAX
if ($cash_admin->page_data['data_only']) {
AdminHelper::formSuccess('Success. New element added.', '/');
} else {
$cash_admin->setCurrentElement($admin_primary_cash_request->response['payload']);
}
} else {
// handle differently for AJAX and non-AJAX
if ($cash_admin->page_data['data_only']) {
AdminHelper::formSuccess('Success. New element added.', '/elements/edit/' . $admin_primary_cash_request->response['payload']);
} else {
$cash_admin->setCurrentElement($admin_primary_cash_request->response['payload']);
}
}
} else {
// handle differently for AJAX and non-AJAX
if ($cash_admin->page_data['data_only']) {
AdminHelper::formFailure('Error. Something just didn\'t work right.', '/elements/add/' . $post_data['element_type']);
} else {
$cash_admin->setErrorState('element_add_failure');
}
}
} elseif (isset($post_data['doelementedit'])) {
// Editing an existing element:
$cash_admin->setCurrentElementState('edit');
$admin_primary_cash_request->processRequest(array('cash_request_type' => 'element', 'cash_action' => 'editelement', 'id' => $post_data['element_id'], 'name' => $post_data['element_name'], 'options_data' => $options_array));
if ($admin_primary_cash_request->response['status_uid'] == 'element_editelement_200') {
// handle differently for AJAX and non-AJAX
if ($cash_admin->page_data['data_only']) {
// AJAX
AdminHelper::formSuccess('Success. Edited.', '/elements/edit/' . $post_data['element_id']);
} else {
// non-AJAX
$cash_admin->setCurrentElement($post_data['element_id']);
}
} else {
// handle differently for AJAX and non-AJAX
if ($cash_admin->page_data['data_only']) {
// AJAX
AdminHelper::formFailure('Error. Something just didn\'t work right.', '/elements/edit/' . $post_data['element_id']);
} else {
// non-AJAX
$cash_admin->setErrorState('element_edit_failure');
}
}
}
AdminHelper::setBasicElementFormData($cash_admin);
}
}