You are here

function panels_menu in Panels 5

Same name and namespace in other branches
  1. 8.3 panels.module \panels_menu()
  2. 5.2 panels.module \panels_menu()
  3. 6.3 panels.module \panels_menu()
  4. 6.2 panels.module \panels_menu()
  5. 7.3 panels.module \panels_menu()

Implementation of hook_menu()

File

./panels.module, line 54

Code

function panels_menu($may_cache) {
  if ($may_cache) {
    $access = user_access('create panels');
    $items[] = array(
      'path' => 'admin/build/panels',
      'title' => t('Panels'),
      'access' => $access,
      'callback' => 'panels_list_page',
      'description' => t('Create pages on your site that are 2 or 3 columns'),
    );
    $items[] = array(
      'path' => 'admin/build/panels/list',
      'title' => t('List'),
      'access' => $access,
      'callback' => 'panels_list_page',
      'weight' => -10,
      'type' => MENU_DEFAULT_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/build/panels/add',
      'title' => t('Add'),
      'access' => $access,
      'callback' => 'panels_add_page',
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/build/panels/add/layout',
      'title' => t('Add'),
      'access' => $access,
      'callback' => 'panels_add_layout_page',
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/build/panels/edit',
      'title' => t('Edit panels'),
      'access' => $access,
      'callback' => 'panels_edit_page',
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'admin/build/panels/delete',
      'title' => t('Delete panels'),
      'access' => $access,
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'panels_delete_confirm',
      ),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'panels/node/autocomplete',
      'title' => t('Autocomplete node'),
      'callback' => 'panels_node_autocomplete',
      'access' => user_access('access content'),
      'type' => MENU_CALLBACK,
    );

    // load panels from database
    $result = db_query("SELECT * FROM {panels_info}");

    // FIXME: Fow now we're making these all callbacks, but we
    // should steal code from Views so they can be normal, tabs,
    // etc
    while ($panels = db_fetch_object($result)) {
      $panels->access = $panels->access ? explode(', ', $panels->access) : array();
      $items[] = array(
        'path' => $panels->path,
        'title' => filter_xss_admin($panels->title),
        'access' => panels_access($panels),
        'callback' => 'panels_panels_page',
        'callback arguments' => array(
          $panels->did,
        ),
        'type' => MENU_CALLBACK,
      );
    }
  }
  return $items;
}