_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.
Code
modules/aggregator.module, line 1068
<?php
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;
}
?>Login or register to post comments 