_aggregator_page_list

Versions
4.6 – 5
_aggregator_page_list($sql, $op, $header = '')
6 – 7
_aggregator_page_list($items, $op, $feed_source = '')

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

▾ 3 functions call _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.

Code

modules/aggregator.module, line 875

<?php
function _aggregator_page_list($sql, $op, $header = '') {
  if (user_access('administer news feeds') && $op == 'categorize') {
    if ($edit = $_POST['edit']) {
      foreach ($edit['categories'] as $iid => $selection) {
        db_query('DELETE FROM {aggregator_category_item} WHERE iid = %d', $iid);
        foreach ($selection as $cid) {
          if ($cid) {
            db_query('INSERT INTO {aggregator_category_item} (cid, iid) VALUES (%d, %d)', $cid, $iid);
          }
        }
      }
      drupal_set_message(t('The categories have been saved.'));
      drupal_goto($_GET['q']);
    }
    else {
      $categorize = true;
    }
  }

  $output = '<div id="aggregator">';
  if ($header) {
    $output .= $header;
  }
  if ($links) {
    $output .= theme('links', $links);
  }

  $result = pager_query($sql, 20);

  $rows = array();
  $categories = array();
  while ($item = db_fetch_object($result)) {
    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);
      if (variable_get('aggregator_category_selector', 'check') == 'select') {
        $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 = form_select(NULL, 'categories]['. $item->iid, $selected, $categories, NULL, 'size="10"', true);
      }
      else {
        $form = '';
        while ($category = db_fetch_object($categories_result)) {
          $form .= form_checkbox(check_plain($category->title), 'categories]['. $item->iid .'][', $category->cid, !is_null($category->iid));
        }
      }
      $rows[] = array(theme('aggregator_page_item', $item), array('data' => $form, 'class' => 'categorize-item'));
    }
    else {
      $output .= theme('aggregator_page_item', $item);
    }
  }
  if ($categorize) {
    $output .= form(theme('table', array('', t('Categorize')), $rows) . form_submit(t('Save categories')));
  }
  $output .= '</div>';

  if ($pager = theme('pager', NULL, 20, 0)) {
    $output .= $pager;
  }

  print theme('page', $output);
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.