You are here

function tweet_feed_feeds_table in Tweet Feed 7.3

Same name and namespace in other branches
  1. 7.2 tweet_feed_admin.inc \tweet_feed_feeds_table()

Feeds Table

A table of configured feeds we will pull on each cron run or drush command. Each feed can be tied to a specific feed account above.

1 string reference to 'tweet_feed_feeds_table'
tweet_feed_menu in ./tweet_feed.module
Implements hook_menu().

File

./tweet_feed_admin.inc, line 81

Code

function tweet_feed_feeds_table() {
  $rows = array();
  $header = array(
    'feed_name' => array(
      'data' => t('Feed name'),
      'style' => 'text-align: center;',
    ),
    'feed_type' => array(
      'data' => t('Type'),
      'style' => 'text-align: center;',
    ),
    'feed_criteria' => array(
      'data' => t('Feed Criteria'),
      'style' => 'text-align: center;',
    ),
    'number_per_pull' => array(
      'data' => t('# Per Pull'),
      'style' => 'text-align: center;',
    ),
    'new_window' => array(
      'data' => t('New Window'),
      'style' => 'text-align: center;',
    ),
    'truncate' => array(
      'data' => t('Truncate'),
      'style' => 'text-align: center;',
    ),
    'edit' => array(
      'data' => t('Edit'),
      'style' => 'text-align: center;',
    ),
    'delete' => array(
      'data' => t('Delete'),
      'style' => 'text-align: center;',
    ),
    'import' => array(
      'data' => t('Import'),
      'style' => 'text-align: center;',
    ),
  );
  $result = db_select('tweet_feeds', 'f')
    ->fields('f')
    ->orderBy('feed_name', 'ASC')
    ->execute();
  while ($data = $result
    ->fetchObject()) {
    switch ($data->query_type) {
      case QUERY_SEARCH:
        $query_type = 'Timeline Search';
        $feed_criteria = $data->search_term;
        break;
      case QUERY_TIMELINE:
        $query_type = 'User Timeline';
        $feed_criteria = $data->timeline_id;
        break;
      case QUERY_LIST:
        $query_type = 'User List';
        $feed_criteria = $data->timeline_id . '/' . $data->list_name;
        break;
      default:
        $query_type = t('Unknown');
        $feed_criteria = t('Unknown');
    }
    $row = array();
    $row[] = $data->feed_name;
    $row[] = array(
      'data' => $query_type,
      'align' => 'center',
    );
    $row[] = array(
      'data' => $feed_criteria,
      'align' => 'center',
    );
    $row[] = array(
      'data' => number_format($data->pull_count * 100),
      'align' => 'center',
    );
    $row[] = array(
      'data' => $data->new_window,
      'align' => 'center',
    );
    $row[] = array(
      'data' => $data->clear_prior,
      'align' => 'center',
    );
    $row[] = array(
      'data' => l(t('Edit'), 'admin/config/services/tweet_feed/feeds/edit/' . $data->fid),
      'align' => 'center',
    );
    $row[] = array(
      'data' => l(t('Delete'), 'admin/config/services/tweet_feed/feeds/delete/' . $data->fid),
      'align' => 'center',
    );
    $row[] = array(
      'data' => l(t('Import'), 'admin/config/services/tweet_feed/feeds/run/' . $data->fid),
      'align' => 'center',
    );
    $rows[] = $row;
  }
  if (count($rows) == 0) {
    $rows = array(
      array(
        'data' => array(
          array(
            'align' => 'center',
            'colspan' => 9,
            'data' => t('THERE ARE CURRENTLY NO CONFIGURED TWITTER FEEDS.'),
          ),
        ),
      ),
    );
  }
  $output = theme('table', array(
    'header' => $header,
    'rows' => $rows,
  ));
  return $output;
}