function edit() {
    ctools_include('form');
    $form_state = array(
      'display' => &$this->display,
      'renderer' => &$this,
      'content_types' => $this->cache->content_types,
      're_render' => FALSE,
      'no_redirect' => TRUE,
      'display_title' => !empty($this->cache->display_title),
      'cache key' => $this->display->cache_key,
    );

    $output = ctools_build_form('panels_edit_display_form', $form_state);
    if ($output) {
      return $output;
    }

    // no output == submit
    if (!$output) {
      if (!empty($form_state['clicked_button']['#save-display'])) {
        drupal_set_message(t('Panel content has been updated.'));
        panels_save_display($this->display);
      }
      else {
        drupal_set_message(t('Your changes have been discarded.'));
      }

      panels_cache_clear('display', $this->display->did);
      return $this->display;
    }
  }
 /**
  * AJAX entry point to create the controller form for an IPE.
  */
 function ajax_save_form($break = NULL)
 {
     ctools_include('form');
     if (!empty($this->cache->locked)) {
         if ($break != 'break') {
             $account = user_load($this->cache->locked->uid);
             $name = theme('username', $account);
             $lock_age = format_interval(time() - $this->cache->locked->updated);
             $message = t("This panel is being edited by user !user, and is therefore locked from editing by others. This lock is !age old.\n\nClick OK to break this lock and discard any changes made by !user.", array('!user' => $name, '!age' => $lock_age));
             $this->commands[] = array('command' => 'unlockIPE', 'message' => $message, 'break_path' => url($this->get_url('save-form', 'break')));
             return;
         }
         // Break the lock.
         panels_edit_cache_break_lock($this->cache);
     }
     $form_state = array('display' => &$this->display, 'content_types' => $this->cache->content_types, 'rerender' => FALSE, 'no_redirect' => TRUE, 'layout' => $this->plugins['layout']);
     $output = ctools_build_form('panels_ipe_edit_control_form', $form_state);
     if ($output) {
         // At this point, we want to save the cache to ensure that we have a lock.
         panels_edit_cache_set($this->cache);
         $this->commands[] = array('command' => 'initIPE', 'key' => $this->clean_key, 'data' => $output);
         return;
     }
     // no output == submit
     if (!empty($form_state['clicked_button']['#save-display'])) {
         // Saved. Save the cache.
         panels_edit_cache_save($this->cache);
     } else {
         // Cancelled. Clear the cache.
         panels_edit_cache_clear($this->cache);
     }
     $this->commands[] = array('command' => 'endIPE', 'key' => $this->clean_key, 'data' => $output);
 }
 /**
  * Page callback to delete an exportable item.
  */
 function delete_page($js, $input, $item)
 {
     $form_state = array('plugin' => $this->plugin, 'object' => &$this, 'ajax' => $js, 'item' => $item, 'op' => $item->export_type & EXPORT_IN_CODE ? 'revert' : 'delete', 'rerender' => TRUE, 'no_redirect' => TRUE);
     ctools_include('form');
     $output = ctools_build_form('ctools_export_ui_delete_confirm_form', $form_state);
     if (!empty($form_state['executed'])) {
         ctools_export_crud_delete($this->plugin['schema'], $item);
         $export_key = $this->plugin['export']['key'];
         $message = str_replace('%title', check_plain($item->{$export_key}), $this->plugin['strings']['confirmation'][$form_state['op']]['success']);
         drupal_set_message($message);
         drupal_goto(ctools_export_ui_plugin_base_path($this->plugin));
     }
     return $output;
 }