'. t("Redirects requests for your site's feed to a FeedBurner feed while still allowing FeedBurner to access the feed.") .'
'; break; case 'admin/settings/feedburner': $build_link = l('FeedBurner feeds', 'admin/build/feedburner'); return ''. t("These are the settings for the FeedBurner module. Once you have everything set, check out your site's $build_link") .'
'; break; case 'admin/build/feedburner': $settings_link = l('FeedBurner options', 'admin/settings/feedburner'); return ''. t("This is help for the FeedBurner site building page. Make sure to check out the $settings_link.") .'
'; break; case 'admin/build/feedburner/add': case 'admin/build/feedburner/edit': return ''. t('Be sure to check that you\'ve already created the FeedBurner feed. Future plans for this module possibly include the ability to automatically create new feeds with FeedBurner\'s Feed Management API.') .'
'; break; } } /** * Implementation of hook_menu() */ function feedburner_menu($may_cache) { $items = array(); if ($may_cache) { $items[] = array( 'path' => 'admin/settings/feedburner', 'title' => t('FeedBurner'), 'description' => t('Administer FeedBurner integration.'), 'callback' => 'drupal_get_form', 'callback arguments' => array('feedburner_admin_settings'), 'access' => user_access('administer site configuration'), 'type' => MENU_NORMAL_ITEM ); $items[] = array( 'path' => 'admin/build/feedburner', 'title' => t('FeedBurner'), 'description' => t('Change FeedBurner redirection'), 'callback' => 'feedburner_admin_build', 'access' => user_access('administer FeedBurner') ); $items[] = array( 'path' => 'admin/build/feedburner/edit', 'title' => t('Edit feed redirection'), 'callback' => 'drupal_get_form', 'callback arguments' => array('feedburner_admin_build_edit'), 'access' => user_access('administer FeedBurner'), 'type' => MENU_CALLBACK ); $items[] = array( 'path' => 'admin/build/feedburner/remove', 'title' => t('Delete feed redirection'), //'callback' => 'drupal_get_form', //'callback arguments' => array('feedburner_admin_build_remove'), 'callback' => 'feedburner_admin_build_remove', 'access' => user_access('administer FeedBurner'), 'type' => MENU_CALLBACK ); $items[] = array( 'path' => 'admin/build/feedburner/list', 'title' => t('List'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10 ); $items[] = array( 'path' => 'admin/build/feedburner/add', 'title' => t('Add feed redirection'), 'callback' => 'drupal_get_form', 'callback arguments' => array('feedburner_admin_build_edit'), 'access' => user_access('administer FeedBurner'), 'type' => MENU_LOCAL_TASK ); } else { _feedburner_do_redirect(); } return $items; } /** * Implementation of hook_perm(). */ function feedburner_perm() { return array('administer FeedBurner', 'view FeedFlare'); } /** * Implementation of hook_block(). */ function feedburner_block($op = 'list', $delta = 0, $edit = array()) { if ($op == 'list') { $blocks[0]['info'] = t('FeedBurner FeedFlare'); //$blocks[1]['info'] = t('FeedBurner Stats'); return $blocks; } else if ($op == 'view') { if ($delta == 0 && arg(0) == 'node' && is_numeric(arg(1))) { $node = node_load(arg(1)); $feedflare = _feedburner_get_feedflare($node->nid, $node->type, $node->path, TRUE); if ($feedflare != FALSE) { $block['subject'] = t('FeedFlare'); $block['content'] = $feedflare; } } /*else if ($delta == 1) { $block['subject'] = t('FeedBurner Stats'); $block['content'] = t('This is where I would put the FeedBurner Awareness API stats.'); }*/ return $block; } } /** * Implementation of hook_cron(). */ /*function feedburner_cron() { _feedburner_check_feedmedic(); } function _feedburner_check_feedmedic() { $cron_last = variable_get('cron_last'); include_once((drupal_get_path('module', 'feedburner'). '/xml.php.inc')); $fb_username = variable_get('feedburner_username', NULL); if (empty($fb_username)) { return FALSE; } $request = drupal_http_request('http://feeds.feedburner.com/~u/'. $fb_username); if ($request->code != 200) { return FALSE; } $fb_feedmedic = XML_unserialize($request->data); $fb_feedmedic = $fb_feedmedic['rss']['channel']; $feeds = _feedburner_get_redirects(); foreach($data['item'] as $item) { if (strtotime($item['pubDate']) > $cron_last) { foreach($feeds as $feed_uri => $feed_feedburner) { if (strpos($item['title'], 'http://feeds.feedburner.com/'. $feed_feedburner)) { //$watchdog = $item['title'] .'|\n|\r/i', ' |\n|\r/i', ' |\\n|\\r){1,}/i', ' FeedFlare is only enabled when you have a FeedBurner feed for your site\'s main feed (rss.xml).
', $item['description'])), '
');
//$watchdog = $item['title'] .'
'. strip_tags(preg_replace('/
', $item['description']), '
');
$watchdog = $item['title'] .'
'. strip_tags(preg_replace('/(?:
|
', $item['content:encoded']), '
');
$severity = (strpos($item['title'], 'PROBLEM') !== FALSE ? WATCHDOG_WARNING : WATCHDOG_NOTICE);
//echo "". htmlspecialchars($watchdog) ."
";
watchdog('feedburner', $watchdog, $severity, 'http://www.feedburner.com/fb/a/myfeeds');
}
}
}
else {
return;
}
}
$data = $data['rss']['channel'];
$build_date = $data['lastBuildDate'];
return $build_date;
}*/
/**
* Implementation of hook_user().
*
* Allows the user to set FeedBurner redirection for his/her own blog's feed.
*/
function feedburner_user($op, &$edit, &$account, $category = NULL) {
if (module_exists('blog') && user_access('edit own blog') && variable_get('feedburner_blogs', FALSE)) {
$user_blog = 'blog/'. $account->uid .'/feed';
if ($op == 'form' && $category == 'account') {
$feeds = _feedburner_get_redirects();
$form['feedburner'] = array(
'#type' => 'fieldset',
'#title' => t('Blog FeedBurner Redirection'),
'#weight' => 1,
'#collapsible' => TRUE,
'#description' => t('Requests for your blog\'s feed (%url) will be redirected to this FeedBurner feed. Leave this blank to disable redirection.', array('%url' => url($user_blog, NULL, NULL, TRUE))),
);
$form['feedburner']['feedburner_uri'] = array(
'#type' => 'textfield',
//'#title' => t('FeedBurner URL'),
'#maxlength' => 100,
'#size' => 30,
'#default_value' => $feeds[$user_blog],
'#field_prefix' => 'http://feeds.feedburner.com/',
'#description' => t('This URI is case-sensitive and alphanumeric.')
);
return $form;
}
elseif ($op == 'validate') {
$edit['feed_uri'] = $user_blog;
feedburner_admin_build_edit_validate(NULL, $edit);
unset($edit['feed_uri']);
}
elseif ($op == 'update') {
if ($edit['status'] == 0) {
_feedburner_update_feed($user_blog);
} else {
_feedburner_update_feed($user_blog, $edit['feedburner_uri']);
unset($edit['feedburner_uri']);
}
}
elseif ($op == 'delete') {
_feedburner_update_feed($user_blog);
}
}
}
/**
* Implementation of nodeapi().
*/
function feedburner_nodeapi(&$node, $op, $teaser, $page) {
if ($op == 'view') {
$display = variable_get('feedburner_feedflare', 0);
if ($display == 3 || ($display == 1 && $teaser) || ($display == 2 && $page)) {
$feedflare = _feedburner_get_feedflare($node->nid, $node->type, $node->path);
if ($feedflare != FALSE) {
$node->content['feedflare'] = array(
'#value' => $feedflare,
'#weight' => 10,
);
}
}
}
}
/**
* Implementation of hook_exit().
*
* Don't let requests by FeedBurner or Feed Validator be cached by the Drupal
* system. If feeds are cached, regular users then may be served the cached
* version of instead of being properly redirected.
*/
function feedburner_exit($destination = NULL) {
$useragent = $_SERVER['HTTP_USER_AGENT'];
$useragents = '/'. variable_get('feedburner_useragents', FEEDBURNER_DEFAULT_USERAGENTS) .'/i';
if (isset($_GET['no_feed_redirect']) || preg_match($useragents, $useragent)) {
global $base_root;
cache_clear_all($base_root . request_uri(), 'cache_page');
}
return;
}
function feedburner_admin_build() {
$feeds = _feedburner_get_feeds();
/*if (empty($_GET['order']) || $_GET['order'] == 'Feed URI') {
if ($_GET['sort'] == 'desc') {
krsort($feeds);
}
else {
ksort($feeds);
}
}
else {
uasort($feeds, create_function('$a,$b', '$field = strtolower($_GET["order"]); $result = strcmp($a[$field], $b[$field]); return ($_GET["sort"] == "desc" ? -$result : $result);'));
}*/
ksort($feeds);
$header = array(
array('data' => t('Feed URI'), /*'field' => 'uri'*/),
array('data' => t('Name'), /*'field' => 'title'*/),
array('data' => t('FeedBurner URI'), /*'field' => 'feedburner'*/),
array('data' => t('Redirect Operations'), 'colspan' => '2')
);
//$destination = drupal_get_destination();
foreach ($feeds as $feed_uri => $feed_values) {
$row = array(
check_plain($feed_uri),
check_plain($feed_values['name']));
if (empty($feed_values['feedburner_uri'])) {
$row[] = 'None';
$row[] = array('data' => l(t('add'), 'admin/build/feedburner/edit', array(), 'feed_uri='. $feed_uri /*.'&'. $destination*/), 'colspan' => '2');
}
else {
$row[] = l($feed_values['feedburner_uri'], 'http://feeds.feedburner.com/'. $feed_values['feedburner_uri']);
$row[] = l(t('edit'), 'admin/build/feedburner/edit', array(), 'feed_uri='. $feed_uri /*.'&'. $destination*/);
$row[] = l(t('remove'), 'admin/build/feedburner/remove', array(), 'feed_uri='. $feed_uri /*.'&'. $destination*/);
}
$rows[] = $row;
}
/*if (empty($feeds)) {
$rows[] = array(array('data' => t('No FeedBurner redirects available.'), 'colspan' => '4'));
}*/
$output = theme('table', $header, $rows);
//TODO: Split feed listings into two categories: regular and blog feeds
/*$output .= 'Blog Feeds