You are here

function biblio_menu in Bibliography Module 5

Same name and namespace in other branches
  1. 6.2 biblio.module \biblio_menu()
  2. 6 biblio.module \biblio_menu()
  3. 7 biblio.module \biblio_menu()
  4. 7.2 biblio.module \biblio_menu()

Implementation of hook_menu().

Here we define some built in links for the biblio module, links exposed are: /node/add/biblio => to add a single entry /biblio => lists all entries in the biblio database /biblio/list => default local task for /biblio /biblio/filter => local task which allows users to add filters to their query /biblio/filter/clear => used internally to remove all filters /biblio/help => displays a help page /biblio/export/endnote => used to export information in Endnote Tagged format /biblio/import/form => presents a form to allow the user to upload a file to import

File

./biblio.module, line 644

Code

function biblio_menu($may_cache) {
  global $user;
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'node/add/biblio',
      'title' => t('Bibliography'),
      'access' => user_access('create biblio'),
    );

    // The next two "LOCAL TASKS" are for the admin/settings/biblio page
    $items[] = array(
      'path' => 'admin/settings/biblio',
      'title' => t('Biblio settings'),
      'description' => t('Configure default behavior of the biblio module.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'biblio_settings',
      ),
    );
    $items[] = array(
      'path' => 'admin/settings/biblio/basic',
      'title' => t('Preferences'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -10,
    );
    $items[] = array(
      'path' => 'admin/settings/biblio/import',
      'title' => t('File Import'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'biblio_form_import',
      ),
      'type' => MENU_LOCAL_TASK,
      'weight' => -7,
    );
    $items[] = array(
      'path' => 'admin/settings/biblio/types',
      'title' => t('Type Customization'),
      'callback' => 'biblio_form_types',
      'type' => MENU_LOCAL_TASK,
      'weight' => -8,
    );
    $items[] = array(
      'path' => 'admin/settings/biblio/defaults',
      'title' => t('Field Defaults'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'biblio_form_types_edit',
      ),
      'type' => MENU_LOCAL_TASK,
      'weight' => -9,
    );
    $items[] = array(
      'path' => 'admin/settings/biblio/types/add',
      'title' => '',
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'biblio_form_types_add',
      ),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'admin/settings/biblio/types/edit',
      'title' => '',
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'biblio_form_types_edit',
      ),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'admin/settings/biblio/types/delete',
      'title' => '',
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'biblio_form_types_delete',
      ),
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'admin/settings/biblio/types/new',
      'title' => t('Add New Type'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'biblio_form_types_add',
      ),
      'type' => MENU_LOCAL_TASK,
      'weight' => -9,
    );
    $items[] = array(
      'path' => 'admin/settings/biblio/types/reset',
      'title' => t('Reset all types to defaults'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'biblio_types_reset',
      ),
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/settings/biblio/types/hide',
      'title' => '',
      'callback' => 'biblio_types_hide',
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'admin/settings/biblio/types/show',
      'title' => '',
      'callback' => 'biblio_types_show',
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'biblio/autocomplete',
      'title' => t('Autocomplete'),
      'callback' => 'biblio_autocomplete',
      'access' => user_access('access content'),
      'type' => MENU_CALLBACK,
    );
  }

  // end if ($may_cache)
  $base = variable_get('biblio_base', 'biblio');
  $items[] = array(
    'path' => $base,
    'title' => '',
    'callback' => 'biblio_db_search',
    'access' => user_access('access content'),
    'type' => MENU_CALLBACK,
  );
  if ($user->uid && variable_get('biblio_my_pubs_menu', '0') && (isset($user->biblio_my_pubs_menu) ? $user->biblio_my_pubs_menu : 0)) {
    $items[] = array(
      'path' => "{$base}/user",
      'title' => t('My publications'),
      'callback' => '_biblio_get_user_pubs',
      'callback arguments' => array(
        $user,
      ),
      'type' => MENU_DYNAMIC_ITEM,
    );
  }
  if (arg(0) == 'user' && is_numeric(arg(1))) {
    $account = user_load(array(
      'uid' => arg(1),
    ));
    if (variable_get('biblio_show_profile', '0') == 1 && variable_get('biblio_show_profile_tab', '0') == 1 || $account->biblio_show_profile_tab == 1) {
      $items[] = array(
        'path' => 'user/' . arg(1) . '/biblio',
        'title' => t('Publications'),
        'callback' => '_biblio_get_user_pubs',
        'callback arguments' => array(
          $account,
          'profile',
        ),
        'access' => user_access('access content'),
        'type' => MENU_IS_LOCAL_TASK,
      );
    }
  }
  $items[] = array(
    'path' => "{$base}/list",
    'title' => t('List'),
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
  );
  $items[] = array(
    'path' => "{$base}/filter",
    'title' => t('Filter'),
    'callback' => 'drupal_get_form',
    'callback arguments' => array(
      'biblio_form_filter',
    ),
    'access' => user_access('show filter tab'),
    'type' => MENU_LOCAL_TASK,
    'weight' => -9,
  );
  $items[] = array(
    'path' => "{$base}/filter/clear",
    'title' => '',
    'callback' => 'biblio_filter_clear',
    'access' => user_access('access content'),
    'type' => MENU_CALLBACK,
  );
  $items[] = array(
    'path' => "{$base}/help",
    'title' => t('Help'),
    'callback' => 'biblio_help_page',
    'access' => user_access('access content'),
    'type' => MENU_CALLBACK,
  );
  $items[] = array(
    'path' => "{$base}/import/form",
    'title' => '',
    'callback' => 'drupal_get_form',
    'callback arguments' => array(
      'biblio_form_import',
    ),
    'access' => user_access('import from file'),
    'type' => MENU_CALLBACK,
  );
  $items[] = array(
    'path' => "{$base}/export",
    'title' => '',
    'callback' => '_biblio_export',
    'access' => user_access('show export links'),
    'type' => MENU_CALLBACK,
  );
  $items[] = array(
    'path' => "{$base}/type/add",
    'title' => '',
    'callback' => 'biblio_type_add',
    'type' => MENU_CALLBACK,
  );
  $items[] = array(
    'path' => "{$base}/type/remove",
    'title' => '',
    'callback' => 'biblio_type_remove',
    'type' => MENU_CALLBACK,
  );
  $items[] = array(
    'path' => "{$base}/citekey",
    'title' => '',
    'callback' => 'biblio_citekey_view',
    'type' => MENU_CALLBACK,
  );
  if (arg(1) == 'viewinline' && is_numeric(arg(2))) {
    $node = node_load(arg(2));
    if ($node->nid) {
      $items[] = array(
        'path' => "{$base}/viewinline/" . arg(2),
        'title' => '',
        'callback' => 'biblio_view_inline',
        'callback arguments' => array(
          $node,
        ),
        'access' => node_access('view', $node),
        'type' => MENU_CALLBACK,
      );
    }
  }
  if (variable_get('biblio_rss', 0)) {
    $items[] = array(
      'path' => "{$base}/rss.xml",
      'title' => t('RSS feed'),
      'callback' => 'biblio_feed',
      'access' => user_access('access content'),
      'type' => MENU_CALLBACK,
    );
  }
  return $items;
}