You are here

function feedapi_menu in FeedAPI 5

Same name and namespace in other branches
  1. 6 feedapi.module \feedapi_menu()

Implementation of hook_menu().

File

./feedapi.module, line 39
Handle the submodules (for feed and item processing) Provide a basic management of feeds

Code

function feedapi_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/content/feed',
      'title' => t('Feeds'),
      'description' => t("Overview which content your site aggregates from other sites and see detailed statistics about the feeds."),
      'callback' => 'feedapi_admin_overview',
      'access' => user_access('administer feedapi'),
    );
    $items[] = array(
      'path' => 'admin/content/feed/list',
      'title' => t('List'),
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'access' => user_access('administer feedapi'),
      'weight' => -15,
    );
    $items[] = array(
      'path' => 'admin/content/feed/import_opml',
      'title' => t('Import OPML'),
      'access' => user_access('administer feedapi'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'feedapi_import_feeds_form',
      ),
    );
    $items[] = array(
      'path' => 'admin/content/feed/export_opml',
      'title' => t('Export all feeds as OPML'),
      'access' => user_access('administer feedapi'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'feedapi_export_opml',
      ),
    );
    $items[] = array(
      'path' => 'admin/settings/feedapi',
      'title' => t('FeedAPI settings'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'feedapi_admin_settings',
      ),
      'access' => user_access('administer feedapi'),
    );
  }
  else {
    if (arg(0) == 'node' && is_numeric(arg(1))) {
      $node = node_load(arg(1));
      if (isset($node->feed)) {
        global $user;
        $own_feed = $node->uid == $user->uid && user_access('edit own ' . $node->type . ' content') ? TRUE : FALSE;
        $items[] = array(
          'path' => 'node/' . $node->nid . '/refresh',
          'title' => t('Refresh'),
          'callback' => 'feedapi_refresh',
          'callback arguments' => array(
            $node,
            'node/' . $node->nid,
          ),
          'type' => MENU_LOCAL_TASK,
          'access' => user_access('administer feedapi') || $own_feed,
        );
        $items[] = array(
          'path' => 'node/' . $node->nid . '/purge',
          'title' => t('Remove items'),
          'callback' => 'feedapi_invoke',
          'callback arguments' => array(
            "purge",
            $node->feed,
            'items',
          ),
          'type' => MENU_LOCAL_TASK,
          'access' => user_access('administer feedapi') || $own_feed,
        );
      }
    }
  }
  return $items;
}