You are here

function finder_ui_element_delete_page in Finder 7.2

Finder UI element delete page.

Parameters

$finder: The finder object.

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

$js: The $js parameter required by ctools.

Return value

The page output.

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

File

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

Code

function finder_ui_element_delete_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_delete_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);
      $element =& $finder->elements[$feid];

      // Delete the element and remove it from the finder.
      $finder
        ->delete_element($element);
      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;
}