You are here

class panelizer_defaults_ui in Panelizer 7.2

Same name and namespace in other branches
  1. 7.3 plugins/export_ui/panelizer_defaults_ui.class.php \panelizer_defaults_ui

@file Contains the administrative UI for selectable panelizer defaults.

Hierarchy

Expanded class hierarchy of panelizer_defaults_ui

1 string reference to 'panelizer_defaults_ui'
panelizer_defaults.inc in plugins/export_ui/panelizer_defaults.inc

File

plugins/export_ui/panelizer_defaults_ui.class.php, line 7
Contains the administrative UI for selectable panelizer defaults.

View source
class panelizer_defaults_ui extends ctools_export_ui {
  function init($plugin) {
    ctools_include('export');
    $this->plugin = $plugin;

    // Get rid of the list parent:
    unset($this->plugin['menu']['items']['list callback']);
  }
  function hook_menu(&$items) {

    // Change the item to a tab.
    $this->plugin['menu']['items']['list']['type'] = MENU_LOCAL_TASK;
    $this->plugin['menu']['items']['list']['weight'] = -6;
    $this->plugin['menu']['items']['list']['title'] = 'List defaults';

    // menu local actions are weird.
    $this->plugin['menu']['items']['add']['path'] = 'list/add';
    $this->plugin['menu']['items']['import']['path'] = 'list/import';

    // Edit is being handled elsewhere:
    unset($this->plugin['menu']['items']['edit']);
    unset($this->plugin['menu']['items']['edit callback']);
    unset($this->plugin['menu']['items']['context']);
    unset($this->plugin['menu']['items']['content']);
    unset($this->plugin['menu']['items']['layout']);
    unset($this->plugin['menu']['items']['access']);

    // Change the callbacks for everything:
    foreach ($this->plugin['menu']['items'] as $key => $item) {
      $this->plugin['menu']['items'][$key]['access callback'] = 'panelizer_has_choice_callback';
      $this->plugin['menu']['items'][$key]['access arguments'] = array(
        4,
        5,
        '',
      );
      $this->plugin['menu']['items'][$key]['page callback'] = 'panelizer_export_ui_switcher_page';
      array_unshift($this->plugin['menu']['items'][$key]['page arguments'], 5);
      array_unshift($this->plugin['menu']['items'][$key]['page arguments'], 4);
    }
    parent::hook_menu($items);
  }
  function list_page($js, $input) {
    drupal_set_title($this->entity_handler
      ->get_bundle_title($this->entity_bundle));
    return parent::list_page($js, $input);
  }
  function list_filter($form_state, $item) {

    // Reminder: This returns TRUE to exclude the item.
    if ($this->entity_handler->entity_type != $item->panelizer_type) {
      return TRUE;
    }
    if ($this->entity_bundle != $item->panelizer_key) {
      return TRUE;
    }
    if (!$this->entity_handler
      ->access_default_panelizer_object($item)) {
      return TRUE;
    }
    if (empty($item->title) && $item->name == implode(':', array(
      $this->entity_handler->entity_type,
      $this->entity_bundle,
      'default',
    ))) {
      $item->title = t('Default');
    }
    return parent::list_filter($form_state, $item);
  }
  function edit_execute_form_standard(&$form_state) {
    if ($form_state['form type'] == 'clone') {
      list($x, $y, $name) = explode(':', $form_state['original name']);
      $form_state['item']->title = t('Clone of') . ' ' . $form_state['item']->title;
      $form_state['item']->name = 'clone_of_' . $name;
    }
    else {
      if ($form_state['op'] == 'add') {
        $form_state['item']->panelizer_type = $this->entity_handler->entity_type;
        $form_state['item']->panelizer_key = $this->entity_bundle;
        $form_state['item']->display = $this->entity_handler
          ->get_default_display();
      }
    }
    return parent::edit_execute_form_standard($form_state);
  }
  function edit_form_validate(&$form, &$form_state) {
    $export_key = $this->plugin['export']['key'];

    // When adding a machine name, the entity/bundle are left off so the user
    // does not have to deal with it. We put it back here behind the scenes.
    $name = $form_state['values'][$export_key];
    form_set_value($form['info'][$export_key], implode(':', array(
      $this->entity_handler->entity_type,
      $this->entity_bundle,
      $name,
    )), $form_state);
  }

  // Simplest way to override the drupal_goto from parent.
  // Why isn't delete using the redirect system everything else is?
  function delete_page($js, $input, $item) {
    $clone = clone $item;

    // Change the name into the title so the form shows the right
    // value. @todo file a bug against CTools to use admin title if
    // available.
    $clone->name = $clone->title;
    $form_state = array(
      'plugin' => $this->plugin,
      'object' => &$this,
      'ajax' => $js,
      'item' => $clone,
      'op' => $item->export_type & EXPORT_IN_CODE ? 'revert' : 'delete',
      'rerender' => TRUE,
      'no_redirect' => TRUE,
    );
    $output = drupal_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->title), $this->plugin['strings']['confirmation'][$form_state['op']]['success']);
      drupal_set_message($message);
      drupal_goto(ctools_export_ui_plugin_base_path($this->plugin) . '/list');
    }
    return $output;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ctools_export_ui::$name property
ctools_export_ui::$options property
ctools_export_ui::$plugin property
ctools_export_ui::access public function Menu callback to determine if an operation is accessible. 1
ctools_export_ui::add_page public function
ctools_export_ui::build_operations public function Builds the operation links for a specific exportable item.
ctools_export_ui::clone_page public function Main entry point to clone an item.
ctools_export_ui::delete_form_submit public function Deletes exportable items from the database.
ctools_export_ui::disable_page public function Callback to disable a page.
ctools_export_ui::edit_cache_clear public function Clear the object cache for the currently edited item.
ctools_export_ui::edit_cache_get public function Retrieve the item currently being edited from the object cache.
ctools_export_ui::edit_cache_get_key public function Figure out what the cache key is for this object.
ctools_export_ui::edit_cache_set public function Cache the item currently currently being edited.
ctools_export_ui::edit_cache_set_key public function
ctools_export_ui::edit_execute_form public function Execute the form.
ctools_export_ui::edit_execute_form_wizard public function Execute the wizard for editing.
ctools_export_ui::edit_finish_validate public function Perform a final validation check before allowing the form to be finished.
ctools_export_ui::edit_form public function Provide the actual editing form. 1
ctools_export_ui::edit_form_import public function Import form. Provides simple helptext instructions and textarea for pasting a export definition.
ctools_export_ui::edit_form_import_submit public function Submit callback for import form.
ctools_export_ui::edit_form_import_validate public function Import form validate handler.
ctools_export_ui::edit_form_submit public function Handle the submission of the edit form. 2
ctools_export_ui::edit_page public function Main entry point to edit an item.
ctools_export_ui::edit_save_form public function Called to save the final product from the edit form.
ctools_export_ui::edit_wizard_back public function Wizard 'back' callback when using a wizard to edit an item.
ctools_export_ui::edit_wizard_cancel public function Wizard 'cancel' callback when using a wizard to edit an item.
ctools_export_ui::edit_wizard_finish public function Wizard 'cancel' callback when using a wizard to edit an item. 1
ctools_export_ui::edit_wizard_next public function Wizard 'next' callback when using a wizard to edit an item. 1
ctools_export_ui::enable_page public function Callback to enable a page.
ctools_export_ui::export_page public function Page callback to display export information for an exportable item.
ctools_export_ui::get_page_title public function Get a page title for the current page from our plugin strings.
ctools_export_ui::get_wizard_info public function Get the form info for the wizard. 1
ctools_export_ui::import_page public function Page callback to import information for an exportable item.
ctools_export_ui::list_build_row public function Build a row based on the item. 2
ctools_export_ui::list_css public function Add listing CSS to the page.
ctools_export_ui::list_footer public function Render a footer to go after thie list.
ctools_export_ui::list_form public function Create the filter/sort form at the top of a list of exports. 2
ctools_export_ui::list_form_submit public function Submit the filter/sort form.
ctools_export_ui::list_form_validate public function Validate the filter/sort form.
ctools_export_ui::list_header public function Render a header to go before the list.
ctools_export_ui::list_render public function Render all of the rows together.
ctools_export_ui::list_search_fields public function Provide a list of fields to test against for the default "search" widget. 1
ctools_export_ui::list_sort_options public function Provide a list of sort options. 2
ctools_export_ui::list_table_header public function Provide the table header. 2
ctools_export_ui::load_item public function Called by ctools_export_ui_load to load the item.
ctools_export_ui::redirect public function Perform a drupal_goto() to the location provided by the plugin for the operation.
ctools_export_ui::set_item_state public function Set an item's state to enabled or disabled and output to user.
panelizer_defaults_ui::delete_page function Page callback to delete an exportable item. Overrides ctools_export_ui::delete_page
panelizer_defaults_ui::edit_execute_form_standard function Execute the standard form for editing. Overrides ctools_export_ui::edit_execute_form_standard
panelizer_defaults_ui::edit_form_validate function Validate callback for the edit form. Overrides ctools_export_ui::edit_form_validate
panelizer_defaults_ui::hook_menu function hook_menu() entry point. Overrides ctools_export_ui::hook_menu
panelizer_defaults_ui::init function Fake constructor -- this is easier to deal with than the real constructor because we are retaining PHP4 compatibility, which would require all child classes to implement their own constructor. Overrides ctools_export_ui::init
panelizer_defaults_ui::list_filter function Determine if a row should be filtered out. Overrides ctools_export_ui::list_filter
panelizer_defaults_ui::list_page function Master entry point for handling a list. Overrides ctools_export_ui::list_page