function finder_ui_field_page in Finder 7.2
Finder UI field page.
Parameters
$finder: The finder object.
$feid: The element machine name or 'new'.
$field_key: The field key.
$js: The $js param required by ctools.
Return value
The output.
1 string reference to 'finder_ui_field_page'
- finder_ui_menu in modules/
finder_ui/ finder_ui.module - Implements hook_menu().
File
- modules/
finder_ui/ includes/ field.inc, line 25
Code
function finder_ui_field_page($finder, $feid, $field_key, $js) {
ctools_include('modal');
ctools_include('ajax');
ctools_include('object-cache');
finder_inc('element', 'finder_ui');
$finder = ctools_object_cache_get('finder', $finder->name);
$form_state = array(
'ajax' => $js,
'finder' => $finder,
'feid' => $feid,
'field_key' => $field_key,
);
$output = ctools_modal_form_wrapper('finder_ui_field_form', $form_state);
if ($form_state['executed'] && $js) {
if ($form_state['triggering_element']['#parents'][0] == 'submit') {
$finder = ctools_object_cache_get('finder', $finder->name);
$element =& $finder->elements[$feid];
$field_key = $form_state['values']['field'];
$relationship = $form_state['values']['relationship'];
$format = $form_state['values']['format'];
list($table, $field) = explode('.', $field_key);
$element->settings['fields'][$field_key] = (object) array(
'table' => $table,
'field' => $field,
'relationship' => $relationship,
'format' => $format,
);
ctools_object_cache_set('finder', $finder->name, $finder);
$output = drupal_render(finder_ui_field_list($finder, $element->id));
$commands[] = ajax_command_html('#finder-ui-element-' . $element->id . '-fields-list', $output);
$commands[] = ajax_command_css('#edit-changed', array(
'display' => 'block',
));
}
elseif ($form_state['triggering_element']['#parents'][0] == 'delete') {
$finder = ctools_object_cache_get('finder', $finder->name);
$element =& $finder->elements[$feid];
$field_key = $form_state['values']['field'];
unset($element->settings['fields'][$field_key]);
ctools_object_cache_set('finder', $finder->name, $finder);
$output = drupal_render(finder_ui_field_list($finder, $element->id));
$commands[] = ajax_command_html('#finder-ui-element-' . $element->id . '-fields-list', $output);
$commands[] = ajax_command_css('#edit-changed', array(
'display' => 'block',
));
}
$commands[] = ctools_modal_command_dismiss();
print ajax_render($commands);
exit;
}
if ($js) {
print ajax_render($output);
exit;
}
// Otherwise, just return the output.
return $output;
}