aggregator_menu

  1. drupal
    1. 4.7
    2. 5 aggregator.module
    3. 6 aggregator.module
    4. 7 aggregator.module
Versions
4.7 – 5 aggregator_menu($may_cache)
6 – 7 aggregator_menu()

Implementation of hook_menu().

Code

modules/aggregator.module, line 44

<?php
function aggregator_menu($may_cache) {
  $items = array();
  $edit = user_access('administer news feeds');
  $view = user_access('access news feeds');

  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/aggregator', 
      'title' => t('aggregator'), 
      'callback' => 'aggregator_admin_overview', 
      'access' => $edit,
    );
    $items[] = array(
      'path' => 'admin/aggregator/add/feed', 
      'title' => t('add feed'), 
      'callback' => 'aggregator_form_feed', 
      'access' => $edit, 
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/aggregator/add/category', 
      'title' => t('add category'), 
      'callback' => 'aggregator_form_category', 
      'access' => $edit, 
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/aggregator/remove', 
      'title' => t('remove items'), 
      'callback' => 'aggregator_admin_remove_feed', 
      'access' => $edit, 
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'admin/aggregator/update', 
      'title' => t('update items'), 
      'callback' => 'aggregator_admin_refresh_feed', 
      'access' => $edit, 
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'admin/aggregator/list', 
      'title' => t('list'), 
      'type' => MENU_DEFAULT_LOCAL_TASK, 
      'weight' => -10,
    );

    $items[] = array(
      'path' => 'aggregator', 
      'title' => t('news aggregator'), 
      'callback' => 'aggregator_page_last', 
      'access' => $view, 
      'weight' => 5,
    );
    $items[] = array(
      'path' => 'aggregator/sources', 
      'title' => t('sources'), 
      'callback' => 'aggregator_page_sources', 
      'access' => $view,
    );
    $items[] = array(
      'path' => 'aggregator/categories', 
      'title' => t('categories'), 
      'callback' => 'aggregator_page_categories', 
      'access' => $view, 
      'type' => MENU_ITEM_GROUPING,
    );
    $items[] = array(
      'path' => 'aggregator/rss', 
      'title' => t('RSS feed'), 
      'callback' => 'aggregator_page_rss', 
      'access' => $view, 
      'type' => MENU_CALLBACK,
    );
    $items[] = array(
      'path' => 'aggregator/opml', 
      'title' => t('OPML feed'), 
      'callback' => 'aggregator_page_opml', 
      'access' => $view, 
      'type' => MENU_CALLBACK,
    );

    $result = db_query('SELECT title, cid FROM {aggregator_category} ORDER BY title');
    while ($category = db_fetch_array($result)) {
      $items[] = array(
        'path' => 'aggregator/categories/' . $category['cid'], 
        'title' => $category['title'], 
        'callback' => 'aggregator_page_category', 
        'access' => $view,
      );
    }
  }
  else {
    if (arg(0) == 'aggregator' && is_numeric(arg(2))) {
      if (arg(1) == 'sources') {
        $feed = aggregator_get_feed(arg(2));
        if ($feed) {
          $items[] = array(
            'path' => 'aggregator/sources/' . $feed['fid'], 
            'title' => $feed['title'], 
            'callback' => 'aggregator_page_source', 
            'access' => $view, 
            'type' => MENU_CALLBACK,
          );
          $items[] = array(
            'path' => 'aggregator/sources/' . $feed['fid'] . '/view', 
            'title' => t('view'), 
            'type' => MENU_DEFAULT_LOCAL_TASK, 
            'weight' => -10,
          );
          $items[] = array(
            'path' => 'aggregator/sources/' . $feed['fid'] . '/categorize', 
            'title' => t('categorize'), 
            'callback' => 'aggregator_page_source', 
            'access' => $edit, 
            'type' => MENU_LOCAL_TASK,
          );
          $items[] = array(
            'path' => 'aggregator/sources/' . $feed['fid'] . '/configure', 
            'title' => t('configure'), 
            'callback' => 'aggregator_form_feed', 
            'callback arguments' => array($feed), 
            'access' => $edit, 
            'type' => MENU_LOCAL_TASK, 
            'weight' => 1,
          );
        }
      }
      else if (arg(1) == 'categories') {
        $category = aggregator_get_category(arg(2));
        if ($category) {
          $items[] = array(
            'path' => 'aggregator/categories/' . $category['cid'] . '/view', 
            'title' => t('view'), 
            'type' => MENU_DEFAULT_LOCAL_TASK, 
            'weight' => -10,
          );
          $items[] = array(
            'path' => 'aggregator/categories/' . $category['cid'] . '/categorize', 
            'title' => t('categorize'), 
            'callback' => 'aggregator_page_category', 
            'access' => $edit, 
            'type' => MENU_LOCAL_TASK,
          );
          $items[] = array(
            'path' => 'aggregator/categories/' . $category['cid'] . '/configure', 
            'title' => t('configure'), 
            'callback' => 'aggregator_form_category', 
            'callback arguments' => array($category), 
            'access' => $edit, 
            'type' => MENU_LOCAL_TASK, 
            'weight' => 1,
          );
        }
      }
    }
    else if (arg(1) == 'aggregator' && is_numeric(arg(4))) {
      if (arg(3) == 'feed') {
        $feed = aggregator_get_feed(arg(4));
        if ($feed) {
          $items[] = array(
            'path' => 'admin/aggregator/edit/feed/' . $feed['fid'], 
            'title' => t('edit feed'), 
            'callback' => 'aggregator_form_feed', 
            'callback arguments' => array($feed), 
            'access' => $edit, 
            'type' => MENU_CALLBACK,
          );
        }
      }
      else {
        $category = aggregator_get_category(arg(4));
        if ($category) {
          $items[] = array(
            'path' => 'admin/aggregator/edit/category/' . $category['cid'], 
            'title' => t('edit category'), 
            'callback' => 'aggregator_form_category', 
            'callback arguments' => array($category), 
            'access' => $edit, 
            'type' => MENU_CALLBACK,
          );
        }
      }
    }
  }

  return $items;
}
?>