You are here

function feed_import_list_feeds in Feed Import 7

Same name and namespace in other branches
  1. 7.3 feed_import.module \feed_import_list_feeds()
  2. 7.2 feed_import.module \feed_import_list_feeds()

List all feeds

Return value

string A formatted table containing all feeds

1 string reference to 'feed_import_list_feeds'
feed_import_menu in ./feed_import.module
Implements hook_menu().

File

./feed_import.module, line 456
User interface, cron functions for feed_import module

Code

function feed_import_list_feeds() {

  // Load all feeds
  $feeds = FeedImport::loadFeeds();
  $rows = array();
  foreach ($feeds as &$feed) {
    $feed['name'] = l($feed['name'], FEED_IMPORT_PATH . '/edit/' . $feed['id'] . '/feed');
    $feed['url'] = l($feed['url'], $feed['url'], array(
      'attributes' => array(
        'target' => '_new',
      ),
    ));
    if ($feed['enabled']) {
      $enabled = TRUE;
      $feed['enabled'] = t('Yes') . ' ' . l('Disable', FEED_IMPORT_PATH . '/disable/' . $feed['id']);
    }
    else {
      $enabled = FALSE;
      $feed['enabled'] = t('No') . ' ' . l('Enable', FEED_IMPORT_PATH . '/enable/' . $feed['id']);
    }

    // Add operations
    $feed['operations']['edit'] = l(t('Edit'), FEED_IMPORT_PATH . '/edit/' . $feed['id'] . '/feed');
    $feed['operations']['process'] = l(t('Process'), FEED_IMPORT_PATH . '/process/' . $feed['id']);
    $feed['operations']['export'] = l(t('Export'), FEED_IMPORT_PATH . '/export/' . $feed['id']);
    $feed['operations']['delete'] = l(t('Delete'), FEED_IMPORT_PATH . '/delete/' . $feed['id']);
    $rows[] = array(
      'data' => array(
        $feed['name'],
        $feed['url'],
        $feed['enabled'],
        $feed['operations']['edit'],
        $feed['operations']['process'],
        $feed['operations']['export'],
        $feed['operations']['delete'],
      ),
      'class' => array(
        $enabled ? 'enabled-feed' : 'disabled-feed',
      ),
    );
  }

  // Path to CSS file
  $path = drupal_get_path('module', 'feed_import') . '/feed_import.css';
  return array(
    '#theme' => 'table',
    '#header' => array(
      t('Name'),
      t('Url'),
      t('Enabled'),
      array(
        'data' => t('Operations'),
        'colspan' => 4,
      ),
    ),
    '#rows' => $rows,
    '#empty' => t('There are no feeds.'),
    '#attached' => array(
      'css' => array(
        $path => array(
          'type' => 'file',
        ),
      ),
    ),
  );
}