function ajax_build in Ajax 6
Builds the output object
Parameters
$data Assoc:
Return value
Assoc
2 calls to ajax_build()
- ajax_submitter in ./
ajax.module - Submission handler callback
- ajax_validator in ./
ajax.module - Validation handler callback
File
- ./
ajax.module, line 498
Code
function ajax_build($data) {
$out = array(
'status' => true,
'updaters' => array(),
'debug' => array(),
'messages_error' => array(),
'messages_status' => array(),
'messages_warning' => array(),
'redirect' => NULL,
'preview' => NULL,
'form_id' => NULL,
'options' => array(),
);
// MESSAGE:ERROR
if (array_key_exists('messages_error', $data) && $data['messages_error'] !== NULL) {
$out['status'] = FALSE;
foreach ($data['messages_error'] as $k => $v) {
$out['messages_error'][] = array(
'id' => ajax_clean_id("edit-" . $k),
'value' => $v,
);
}
}
// MESSAGE:STATUS
if (array_key_exists('messages_status', $data) && $data['messages_status'] !== NULL) {
foreach ($data['messages_status'] as $k => $v) {
$out['messages_status'][] = array(
'id' => (int) $k,
'value' => $v,
);
}
}
// MESSAGE:WARNING
if (array_key_exists('messages_warning', $data) && $data['messages_warning'] !== null) {
foreach ($data['messages_warning'] as $k => $v) {
$out['messages_warning'][] = array(
'id' => (int) $k,
'value' => $v,
);
}
}
// Redirect: Destination Parameter
if (array_key_exists('destination', $_GET)) {
$out['redirect'] = ajax_get_redirect($_GET['destination']);
}
elseif (array_key_exists('redirect', $data) && $data['redirect'] !== NULL) {
$out['redirect'] = ajax_get_redirect($data['redirect']);
}
// Preview
if (array_key_exists('preview', $data) && $data['preview'] !== NULL) {
$out['preview'] = rawurlencode($data['preview']);
}
// Debug
if (array_key_exists('debug', $data) && $data['debug'] !== NULL) {
$out['debug'] = $data['debug'];
}
// Form ID
if (array_key_exists('form_id', $data) && $data['form_id'] !== NULL) {
$out['form_id'] = $data['form_id'];
}
// Misc Admin Options to Send to Client
if (array_key_exists('options', $data) && $data['options'] !== NULL) {
$out['options'] = $data['options'];
}
return $out;
}