You are here

function panelizer_export_ui_switcher_page in Panelizer 7.3

Same name and namespace in other branches
  1. 7.2 panelizer.module \panelizer_export_ui_switcher_page()

Specialized version of ctools_export_ui_switcher_page().

This one is designed to set our entity handler and bundle on the object so we can refer to it later without having to override all of the entry points.

1 call to panelizer_export_ui_switcher_page()
panelizer_default_list_or_settings_page in ./panelizer.module
Page callback to delegate to either the settings page or list page.
1 string reference to 'panelizer_export_ui_switcher_page'
panelizer_defaults_ui::hook_menu in plugins/export_ui/panelizer_defaults_ui.class.php
hook_menu() entry point.

File

./panelizer.module, line 866
The Panelizer module attaches panels to entities, providing default panels and allowing each panel to be configured independently by privileged users.

Code

function panelizer_export_ui_switcher_page($entity_handler, $bundle, $plugin_name, $op) {
  $args = func_get_args();

  // Remove the handler and the bundle.
  array_shift($args);
  array_shift($args);
  $js = !empty($_REQUEST['js']);

  // Break our bundle up as necessary.
  if (strpos($bundle, '.') !== FALSE) {
    list($bundle, $view_mode) = explode('.', $bundle);
  }
  else {
    $view_mode = 'page_manager';
  }

  // Load the $plugin information.
  ctools_include('export-ui');
  $plugin = ctools_get_export_ui($plugin_name);
  $handler = ctools_export_ui_get_handler($plugin);
  if ($handler) {
    if (is_string($entity_handler)) {
      $entity_handler = panelizer_entity_plugin_get_handler($entity_handler);
    }
    $handler->entity_handler = $entity_handler;
    $handler->entity_bundle = $bundle;
    $handler->entity_view_mode = $view_mode;
    if (empty($entity_handler->entity_admin_root) || substr($_GET['q'], 30) == 'admin/structure/panelizer') {
      $handler->plugin['menu']['menu prefix'] = 'admin/structure/panelizer' . $entity_handler->entity_type;
      $handler->plugin['menu']['menu item'] = $bundle;
    }
    else {
      $base_path = $entity_handler->entity_admin_root . '/panelizer/' . $view_mode;
      if (is_numeric($entity_handler->entity_admin_bundle)) {
        $bits = explode('/', $base_path);
        $bits[$entity_handler->entity_admin_bundle] = $bundle;
        $base_path = implode('/', $bits);
      }
      $handler->plugin['menu']['menu prefix'] = dirname($base_path);
      $handler->plugin['menu']['menu item'] = basename($base_path);
      foreach ($handler->plugin['menu']['items'] as $key => &$item) {
        $item['path'] = str_replace('list/', '', $item['path']);
      }
    }
    $path = $handler->plugin['menu']['menu prefix'] . '/' . $handler->plugin['menu']['menu item'];
    foreach ($handler->plugin['redirect'] as $key => $old_path) {
      if ($key == 'add') {
        $handler->plugin['redirect'][$key] = $path . '/%ctools_export_ui/settings';
      }
      else {
        $handler->plugin['redirect'][$key] = $path;
      }
    }
    $method = $op . '_page';
    if (method_exists($handler, $method)) {

      // Replace the first two arguments.
      $args[0] = $js;
      $args[1] = $_POST;
      return call_user_func_array(array(
        $handler,
        $method,
      ), $args);
    }
  }
  else {
    return t('Configuration error. No handler found.');
  }
}