You are here

function finder_ui_element_page in Finder 7.2

Finder UI element page.

Parameters

$finder: The finder object.

$feid: The finder element id or 'new'.

$js: The $js parameter required by ctools.

1 string reference to 'finder_ui_element_page'
finder_ui_menu in modules/finder_ui/finder_ui.module
Implements hook_menu().

File

modules/finder_ui/includes/element.inc, line 21

Code

function finder_ui_element_page($finder, $feid, $js) {
  ctools_include('modal');
  ctools_include('ajax');
  ctools_include('object-cache');
  $finder = ctools_object_cache_get('finder', $finder->name);
  $form_state = array(
    'finder' => $finder,
    'feid' => $feid,
    'ajax' => $js,
  );
  $output = ctools_modal_form_wrapper('finder_ui_element_form', $form_state);
  if ($form_state['executed'] && $js) {
    if ($form_state['triggering_element']['#parents'][0] == 'submit' && finder_ui_check_lock($finder)) {
      $finder = ctools_object_cache_get('finder', $finder->name);
      if ($feid == 'new') {
        $element =& $finder
          ->create_element($form_state['values']['id']);
      }
      else {
        $element =& $finder->elements[$feid];
      }
      foreach ($form_state['values'] as $key => $value) {
        if ($key != 'settings') {
          $element->{$key} = $value;
        }
      }
      foreach ($form_state['values']['settings'] as $key => $value) {
        $element->settings[$key] = $value;
      }

      //$finder->save_element($element);
      $finder
        ->build_elements();
      $finder
        ->load_element_handlers();
      ctools_object_cache_set('finder', $finder->name, $finder);
      $output = drupal_render(finder_ui_element_list($finder));
      $output .= '<div class="finder-ui-needs-reload"></div>';
      $commands[] = ajax_command_html('#finder-ui-elements-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;
}