You are here

function feeds_page in Feeds 7.2

Same name and namespace in other branches
  1. 8.2 feeds.pages.inc \feeds_page()
  2. 6 feeds.pages.inc \feeds_page()
  3. 7 feeds.pages.inc \feeds_page()

Render a page of available importers.

1 string reference to 'feeds_page'
feeds_menu in ./feeds.module
Implements hook_menu().

File

./feeds.pages.inc, line 11
Menu callbacks, form callbacks and helpers.

Code

function feeds_page() {
  $rows = array();
  if ($importers = feeds_importer_load_all()) {
    foreach ($importers as $importer) {
      if ($importer->disabled) {
        continue;
      }
      if (!(user_access('import ' . $importer->id . ' feeds') || user_access('administer feeds'))) {
        continue;
      }
      if (empty($importer->config['content_type'])) {
        $link = 'import/' . $importer->id;
        $title = $importer->config['name'];
      }
      elseif (node_access('create', $importer->config['content_type'])) {
        $link = 'node/add/' . str_replace('_', '-', $importer->config['content_type']);
        $title = node_type_get_name($importer->config['content_type']);
      }
      else {
        continue;
      }
      $rows[] = array(
        l($title, $link),
        check_plain($importer->config['description']),
      );
    }
  }
  if (empty($rows)) {

    // The feeds_ui module is enabled.
    if (module_exists('feeds_ui') && user_access('administer feeds')) {
      drupal_set_message(t('There are no importers, go to <a href="@importers">Feed importers</a> to create one or enable an existing one.', array(
        '@importers' => url('admin/structure/feeds'),
      )));
    }
    else {

      // The feeds_ui module is not enabled but the current user has access to
      // Modules to enable it.
      if (user_access('administer modules')) {
        drupal_set_message(t('The Feeds UI Admin module is not enabled and there are no importers, go to <a href="@modules">Modules</a> and enable Feeds Admin UI. Then go to <a href="@importers">Feed importers</a> to create one or enable an existing one.', array(
          '@modules' => url('admin/modules'),
          '@importers' => url('admin/structure/feeds'),
        )));
      }
      else {

        // The feeds_ui module is not enabled and the current user cannot
        // enable it.
        drupal_set_message(t("The Feeds UI Admin module is not enabled. Please contact the Administrator for your site and ask them to enable it."));
      }
    }
  }
  $header = array(
    t('Import'),
    t('Description'),
  );
  return theme('table', array(
    'header' => $header,
    'rows' => $rows,
  ));
}