* Menu callback; displays the aggregator administration page.
*/
functionaggregator_admin_overview(){
returnaggregator_view();
}
functionaggregator_view(){
$result=db_query('SELECT f.*, COUNT(i.iid) AS items FROM {aggregator_feed} f LEFT JOIN {aggregator_item} i ON f.fid = i.fid GROUP BY f.fid, f.title, f.url, f.refresh, f.checked, f.link, f.description, f.etag, f.modified, f.image, f.block ORDER BY f.title');
$result=db_query('SELECT c.cid, c.title, count(ci.iid) as items FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid GROUP BY c.cid, c.title ORDER BY title');
'#description'=>t('The name of the feed; typically the name of the website you syndicate content from.'),
'#required'=>TRUE,
);
$form['url']=array('#type'=>'textfield',
'#title'=>t('URL'),
'#default_value'=>$edit['url'],
'#maxlength'=>255,
'#description'=>t('The fully-qualified URL of the feed.'),
'#required'=>TRUE,
);
$form['refresh']=array('#type'=>'select',
'#title'=>t('Update interval'),
'#default_value'=>$edit['refresh'],
'#options'=>$period,
'#description'=>t('The refresh interval indicating how often you want to update this feed. Requires crontab.'),
);
// Handling of categories:
$options=array();
$values=array();
$categories=db_query('SELECT c.cid, c.title, f.fid FROM {aggregator_category} c LEFT JOIN {aggregator_category_feed} f ON c.cid = f.cid AND f.fid = %d ORDER BY title',$edit['fid']);
form_set_error('url',t('The URL %url is invalid. Please enter a fully-qualified URL, such as http://www.example.com/feed.xml.',array('%url'=>$form_state['values']['url'])));
}
// Check for duplicate titles.
if(isset($form_state['values']['fid'])){
$result=db_query("SELECT title, url FROM {aggregator_feed} WHERE (title = '%s' OR url='%s') AND fid != %d",$form_state['values']['title'],$form_state['values']['url'],$form_state['values']['fid']);
}
else{
$result=db_query("SELECT title, url FROM {aggregator_feed} WHERE title = '%s' OR url='%s'",$form_state['values']['title'],$form_state['values']['url']);
'#description'=>t('The type of category selection widget which is shown on categorization pages. Checkboxes are easier to use; a multiple selector is good for working with large numbers of categories.')
);
returnsystem_settings_form($form);
}
/**
* Form builder; Generate a form to add/edit/delete aggregator categories.
$category=db_fetch_object(db_query("SELECT cid FROM {aggregator_category} WHERE title = '%s' AND cid != %d",$form_state['values']['title'],$form_state['values']['cid']));
}
else{
$category=db_fetch_object(db_query("SELECT cid FROM {aggregator_category} WHERE title = '%s'",$form_state['values']['title']));
}
if($category){
form_set_error('title',t('A category named %category already exists. Please enter a unique title.',array('%category'=>$form_state['values']['title'])));
}
}
}
/**
* Process aggregator_form_category form submissions.
return_aggregator_page_list('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',arg(1));
}
/**
* Menu callback; displays all the items captured from a particular feed.
*/
functionaggregator_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.
$feed=is_array($arg2)?$arg2:$arg1;
$feed=(object)$feed;
drupal_set_title(check_plain($feed->title));
$info=theme('aggregator_feed',$feed);
return_aggregator_page_list('SELECT * FROM {aggregator_item} WHERE fid = '.$feed->fid.' ORDER BY timestamp DESC, iid DESC',arg(3),$info);
}
/**
* Menu callback; displays all the items aggregated in a particular category.
// It is safe to include the cid in the query because it's loaded from the
// database by aggregator_category_load.
return_aggregator_page_list('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',arg(3));
}
/**
* Prints an aggregator page listing a number of feed items. Various
* menu callbacks use this function to print their feeds.
$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);
$result=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);
* Menu callback; displays all the feeds used by the aggregator.
*/
functionaggregator_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');
$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.
*/
functionaggregator_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');
$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.
*/
functionaggregator_page_rss(){
// arg(2) is the passed cid, only select for that category
$result=NULL;
if(arg(2)){
$category=db_fetch_object(db_query('SELECT cid, title FROM {aggregator_category} WHERE cid = %d',arg(2)));
$url='/categories/'.$category->cid;
$title=' '.t('in category').' '.$category->title;
$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';