You are here

function aggregator_page_list in Drupal 5

1 call to aggregator_page_list()
_aggregator_page_list in modules/aggregator/aggregator.module
Prints an aggregator page listing a number of feed items. Various menu callbacks use this function to print their feeds.

File

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

Code

function aggregator_page_list($sql, $header, $categorize) {
  $form['#base'] = 'aggregator_page_list';
  $form['header'] = array(
    '#value' => $header,
  );
  $result = pager_query($sql, 20);
  $categories = array();
  $done = FALSE;
  $form['items'] = array();
  $form['categories'] = array(
    '#tree' => TRUE,
  );
  while ($item = db_fetch_object($result)) {
    $form['items'][$item->iid] = array(
      '#value' => theme('aggregator_page_item', $item),
    );
    $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,
      );
    }
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save categories'),
  );
  $form['pager'] = array(
    '#value' => theme('pager', NULL, 20, 0),
  );
  return $form;
}