You are here

function feedapi_aggregator_menu in FeedAPI 5

Implementation of hook_menu().

File

feedapi_aggregator/feedapi_aggregator.module, line 26

Code

function feedapi_aggregator_menu($may_cache) {
  $items = array();
  $edit = user_access('administer feedapi');
  $view = user_access('access news feeds');
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/content/feed/category',
      'title' => t('Categories'),
      'callback' => 'feedapi_aggregator_category_view',
      'access' => $edit,
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'admin/content/feed/category/list',
      'title' => t('List'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -15,
    );
    $items[] = array(
      'path' => 'admin/content/feed/category/add',
      'title' => t('Add category'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'feedapi_aggregator_form_category',
      ),
      'access' => $edit,
      'type' => MENU_LOCAL_TASK,
    );
    $items[] = array(
      'path' => 'aggregator',
      'title' => t('News aggregator'),
      'callback' => 'feedapi_aggregator_page_last',
      'access' => $view,
      'weight' => 5,
    );
    $items[] = array(
      'path' => 'aggregator/sources',
      'title' => t('Sources'),
      'callback' => 'feedapi_aggregator_page_sources',
      'access' => $view,
    );
    $items[] = array(
      'path' => 'aggregator/categories',
      'title' => t('Categories'),
      'callback' => 'feedapi_aggregator_page_categories',
      'access' => $view,
    );
    $items[] = array(
      'path' => 'aggregator/rss',
      'title' => t('RSS feed'),
      'callback' => 'feedapi_aggregator_page_rss',
      'access' => $view,
      'type' => MENU_CALLBACK,
    );
    $result = db_query('SELECT title, cid FROM {feedapi_aggregator_category} ORDER BY title');
    while ($category = db_fetch_array($result)) {
      $items[] = array(
        'path' => 'aggregator/categories/' . $category['cid'],
        'title' => $category['title'],
        'callback' => 'feedapi_aggregator_page_category',
        'access' => $view,
      );
    }
    $items[] = array(
      'path' => 'admin/settings/feedapi_aggregator',
      'title' => t('FeedAPI Aggregator'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'feedapi_aggregator_admin_settings',
      ),
      'access' => user_access('administer feedapi'),
    );
  }
  else {

    // Add the CSS for this module
    // We put this in !$may_cache so it's only added once per request
    drupal_add_css(drupal_get_path('module', 'feedapi_aggregator') . '/aggregator.css');
    if (arg(0) == 'aggregator' && is_numeric(arg(2))) {
      if (arg(1) == 'sources') {
        $feed = new stdClass();
        $feed->nid = arg(2);
        $node = node_load(arg(2));
        $feed = $node->feed;
        if ($feed) {
          $items[] = array(
            'path' => 'aggregator/sources/' . $feed->nid,
            'title' => $feed->title,
            'callback' => 'feedapi_aggregator_page_source',
            'access' => $view,
            'type' => MENU_CALLBACK,
          );
          $items[] = array(
            'path' => 'aggregator/sources/' . $feed->nid . '/view',
            'title' => t('View'),
            'type' => MENU_DEFAULT_LOCAL_TASK,
            'weight' => -10,
          );
          $items[] = array(
            'path' => 'aggregator/sources/' . $feed->nid . '/categorize',
            'title' => t('Categorize'),
            'callback' => 'drupal_get_form',
            'callback arguments' => array(
              'feedapi_aggregator_page_source',
            ),
            'access' => $edit,
            'type' => MENU_LOCAL_TASK,
          );
          $items[] = array(
            'path' => 'aggregator/sources/' . $feed->nid . '/configure',
            'title' => t('Configure'),
            'callback' => 'node_page_edit',
            'callback arguments' => array(
              $node,
            ),
            'access' => $edit,
            'type' => MENU_LOCAL_TASK,
            'weight' => 1,
          );
        }
      }
      else {
        if (arg(1) == 'categories') {
          $category = feedapi_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' => 'drupal_get_form',
              'callback arguments' => array(
                'feedapi_aggregator_page_category',
              ),
              'access' => $edit,
              'type' => MENU_LOCAL_TASK,
            );
            $items[] = array(
              'path' => 'aggregator/categories/' . $category['cid'] . '/configure',
              'title' => t('Configure'),
              'callback' => 'drupal_get_form',
              'callback arguments' => array(
                'feedapi_aggregator_form_category',
                $category,
              ),
              'access' => $edit,
              'type' => MENU_LOCAL_TASK,
              'weight' => 1,
            );
          }
        }
      }
    }
  }
  return $items;
}