You are here

function panels_layouts_ui::hook_menu in Panels 6.3

Same name and namespace in other branches
  1. 7.3 plugins/export_ui/panels_layouts_ui.class.php \panels_layouts_ui::hook_menu()

hook_menu() entry point.

Child implementations that need to add or modify menu items should probably call parent::hook_menu($items) and then modify as needed.

Overrides ctools_export_ui::hook_menu

File

plugins/export_ui/panels_layouts_ui.class.php, line 6

Class

panels_layouts_ui

Code

function hook_menu(&$items) {

  // During updates, this can run before our schema is set up, so our
  // plugin can be empty.
  if (empty($this->plugin['menu']['items']['add'])) {
    return;
  }

  // Change the item to a tab on the Panels page.
  $this->plugin['menu']['items']['list callback']['type'] = MENU_LOCAL_TASK;

  // Establish a base for adding plugins
  $base = $this->plugin['menu']['items']['add'];

  // Remove the default 'add' menu item.
  unset($this->plugin['menu']['items']['add']);
  ctools_include('plugins', 'panels');
  $this->builders = panels_get_layout_builders();
  asort($this->builders);
  foreach ($this->builders as $name => $builder) {

    // Create a new menu item for the builder
    $item = $base;
    $item['title'] = !empty($builder['builder tab title']) ? $builder['builder tab title'] : 'Add ' . $builder['title'];
    $item['page arguments'][] = $name;
    $item['path'] = 'add-' . $name;
    $this->plugin['menu']['items']['add ' . $name] = $item;
  }
  parent::hook_menu($items);
}