You are here

function _aggregator_page_list in Drupal 4

Same name and namespace in other branches
  1. 5 modules/aggregator/aggregator.module \_aggregator_page_list()
  2. 6 modules/aggregator/aggregator.pages.inc \_aggregator_page_list()
  3. 7 modules/aggregator/aggregator.pages.inc \_aggregator_page_list()

Prints an aggregator page listing a number of feed items. Various menu callbacks use this function to print their feeds.

3 calls to _aggregator_page_list()
aggregator_page_category in modules/aggregator.module
Menu callback; displays all the items aggregated in a particular category.
aggregator_page_last in modules/aggregator.module
Menu callback; displays the most recent items gathered from any feed.
aggregator_page_source in modules/aggregator.module
Menu callback; displays all the items captured from a particular feed.

File

modules/aggregator.module, line 1068
Used to aggregate syndicated content (RSS, RDF, and Atom).

Code

function _aggregator_page_list($sql, $op, $header = '') {
  $categorize = user_access('administer news feeds') && $op == 'categorize';
  $output = '<div id="aggregator">';
  $form['header'] = array(
    '#value' => $header,
  );
  $output .= $form['header']['#value'];
  $result = pager_query($sql, 20);
  $categories = array();
  $form['categories'] = array(
    '#tree' => TRUE,
  );
  while ($item = db_fetch_object($result)) {
    $form['items'][$item->iid] = array(
      '#value' => theme('aggregator_page_item', $item),
    );
    $output .= $form['items'][$item->iid]['#value'];
    $form['categories'][$item->iid] = array();
    if ($categorize) {
      $categories_result = db_query('SELECT c.cid, c.title, ci.iid FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid AND ci.iid = %d', $item->iid);
      $selected = array();
      while ($category = db_fetch_object($categories_result)) {
        if (!$done) {
          $categories[$category->cid] = check_plain($category->title);
        }
        if ($category->iid) {
          $selected[] = $category->cid;
        }
      }
      $done = true;
      $form['categories'][$item->iid] = array(
        '#type' => variable_get('aggregator_category_selector', 'checkboxes'),
        '#default_value' => $selected,
        '#options' => $categories,
        '#size' => 10,
        '#multiple' => true,
      );
    }
  }
  $output .= '</div>';
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save categories'),
  );
  $form['pager'] = array(
    '#value' => theme('pager', NULL, 20, 0),
  );
  $output .= $form['pager']['#value'];

  // arg(1) is undefined if we are at the top aggregator URL
  // is there a better way to do this?
  if (!arg(1)) {
    $form['feed_icon'] = array(
      '#value' => theme('feed_icon', url('aggregator/rss')),
    );
  }
  elseif (arg(1) == 'categories' && arg(2) && !arg(3)) {
    $form['feed_icon'] = array(
      '#value' => theme('feed_icon', url('aggregator/rss/' . arg(2))),
    );
  }
  $output .= $form['feed_icon']['#value'];
  return $categorize ? drupal_get_form('aggregator_page_list', $form) : $output;
}