$items = aggregator_feed_items_load('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_item} i INNER JOIN {aggregator_feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC, i.iid DESC');
return _aggregator_page_list($items, arg(1));
}
/**
* Menu callback; displays all the items captured from a particular feed.
*
* If there are two arguments then this function is the categorize form.
*
* @param $arg1
* If there are two arguments then $arg1 is $form_state. Otherwise, $arg1 is $feed.
* @param $arg2
* If there are two arguments then $arg2 is feed.
* @return
* The items HTML.
*/
function aggregator_page_source($arg1, $arg2 = NULL) {
// If there are two arguments then this function is the categorize form, and
// $arg1 is $form_state and $arg2 is $feed. Otherwise, $arg1 is $feed.
// It is safe to include the cid in the query because it's loaded from the
// database by aggregator_category_load.
$items = aggregator_feed_items_load('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_category_item} c LEFT JOIN {aggregator_item} i ON c.iid = i.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE cid = '. $category['cid'] .' ORDER BY timestamp DESC, i.iid DESC');
return _aggregator_page_list($items, arg(3));
}
/**
* Load feed items by passing a SQL query.
*
* @param $sql
* The query to be executed.
* @return
* An array of the feed items.
*/
function aggregator_feed_items_load($sql) {
$items = array();
if (isset($sql)) {
$result = pager_query($sql, 20);
while ($item = db_fetch_object($result)) {
$result_category = db_query('SELECT c.title, c.cid FROM {aggregator_category_item} ci LEFT JOIN {aggregator_category} c ON ci.cid = c.cid WHERE ci.iid = %d ORDER BY c.title', $item->iid);
$item->categories = array();
while ($item_categories = db_fetch_object($result_category)) {
$item->categories[] = $item_categories;
}
$items[$item->iid] = $item;
}
}
return $items;
}
/**
* Prints an aggregator page listing a number of feed items.
*
* Various menu callbacks use this function to print their feeds.
*
* @param $items
* The items to be listed.
* @param $op
* Which form should be added to the items. Only 'categorize' is now recognized.
* @param $feed_source
* The feed source URL.
* @return
* The items HTML.
*/
function _aggregator_page_list($items, $op, $feed_source = '') {
if (user_access('administer news feeds') && ($op == '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)) {
* Menu callback; displays all the feeds used by the aggregator.
*/
function aggregator_page_sources() {
$result = db_query('SELECT f.fid, f.title, f.description, f.image, MAX(i.timestamp) AS last FROM {aggregator_feed} f LEFT JOIN {aggregator_item} i ON f.fid = i.fid GROUP BY f.fid, f.title, f.description, f.image ORDER BY last DESC, f.title');
$output = '';
while ($feed = db_fetch_object($result)) {
// Most recent items:
$summary_items = array();
if (variable_get('aggregator_summary_items', 3)) {
$items = db_query_range('SELECT i.title, i.timestamp, i.link FROM {aggregator_item} i WHERE i.fid = %d ORDER BY i.timestamp DESC', $feed->fid, 0, variable_get('aggregator_summary_items', 3));
* Menu callback; displays all the categories used by the aggregator.
*/
function aggregator_page_categories() {
$result = db_query('SELECT c.cid, c.title, c.description FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid LEFT JOIN {aggregator_item} i ON ci.iid = i.iid GROUP BY c.cid, c.title, c.description');
$output = '';
while ($category = db_fetch_object($result)) {
if (variable_get('aggregator_summary_items', 3)) {
$summary_items = array();
$items = db_query_range('SELECT i.title, i.timestamp, i.link, f.title as feed_title, f.link as feed_link FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON i.iid = ci.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE ci.cid = %d ORDER BY i.timestamp DESC', $category->cid, 0, variable_get('aggregator_summary_items', 3));
* Menu callback; generate an RSS 0.92 feed of aggregator items or categories.
*/
function aggregator_page_rss() {
$result = NULL;
// arg(2) is the passed cid, only select for that category
if (arg(2)) {
$category = db_fetch_object(db_query('SELECT cid, title FROM {aggregator_category} WHERE cid = %d', arg(2)));
$sql = 'SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_category_item} c LEFT JOIN {aggregator_item} i ON c.iid = i.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE cid = %d ORDER BY timestamp DESC, i.iid DESC';
$sql = 'SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_item} i INNER JOIN {aggregator_feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC, i.iid DESC';
* Menu callback; generates an OPML representation of all feeds.
*
* @param $cid
* If set, feeds are exported only from a category with this ID. Otherwise, all feeds are exported.
* @return
* The output XML.
*/
function aggregator_page_opml($cid = NULL) {
if ($cid) {
$result = db_query('SELECT f.title, f.url FROM {aggregator_feed} f LEFT JOIN {aggregator_category_feed} c on f.fid = c.fid WHERE c.cid = %d ORDER BY title', $cid);
}
else {
$result = db_query('SELECT * FROM {aggregator_feed} ORDER BY title');