### Eclipse Workspace Patch 1.0 #P feed_node Index: feed_node.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feed_node/feed_node.install,v retrieving revision 1.1 diff -u -r1.1 feed_node.install --- feed_node.install 13 Dec 2006 17:09:03 -0000 1.1 +++ feed_node.install 8 Apr 2007 22:08:11 -0000 @@ -2,32 +2,30 @@ // $Id: feed_node.install,v 1.1 2006/12/13 17:09:03 dayre Exp $ /** - * Implementation of the hook_install() module. + * Implementation of hook_install(). */ function feed_node_install() { switch ($GLOBALS['db_type']) { case 'mysql': case 'mysqli': db_query("CREATE TABLE feed_node ( - nid int(10) unsigned NOT NULL default '0', - fid int(10) NOT NULL default '0', - numItems int(10) NOT NULL default '0', - displayStyle tinyint(1) NOT NULL default '0', - PRIMARY KEY (nid,fid) - ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;"); + nid int(10) unsigned NOT NULL default '0', + fid int(10) NOT NULL default '0', + numItems int(10) NOT NULL default '0', + displayStyle tinyint(1) NOT NULL default '0', + PRIMARY KEY (nid,fid) + ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;"); break; } if (!db_error()) { - drupal_set_message("The feed node module has been installed successfully."); + drupal_set_message("The feed node module has been installed successfully."); } else { - drupal_set_message(t("A database error occured installing the feed node DB schema. Feed node may not work."), "error"); + drupal_set_message(t("A database error occured installing the feed node DB schema. Feed node may not work."), "error"); } include_once(drupal_get_path('module', 'feed_node') .'/feed_node.module'); _feed_node_aggregator_dependency_check(); } - -?> \ No newline at end of file Index: aggregation_api.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feed_node/aggregation_api.inc,v retrieving revision 1.2 diff -u -r1.2 aggregation_api.inc --- aggregation_api.inc 19 Dec 2006 19:17:25 -0000 1.2 +++ aggregation_api.inc 8 Apr 2007 14:59:43 -0000 @@ -39,7 +39,7 @@ * @param $title * @param $url * @return - * Returns the id for the corresponding aggregator feed in the database or + * Returns the id for the corresponding aggregator feed in the database or * -1 if a conflict exists with an existing feed in the database. */ function aggregation_sync_feed($title, $url) { @@ -51,8 +51,8 @@ // if there is no feed with the given url or title, we have an insert if (!$urlfeed && !$titlefeed) { $newfeed['url']=$url; - $newfeed['title']=$title; - return _aggregation_insert_feed($newfeed); + $newfeed['title']=$title; + return _aggregation_insert_feed($newfeed); } // if a feed exists with the URL, but none with the given title, // we update the title @@ -67,14 +67,14 @@ return _aggregation_update_feed($titlefeed); } - // if feeds exists with the given url and title and they are the same, - // then there is nothing to update - if ($urlfeed['fid'] == $titlefeed['fid']) { - return $urlfeed['fid']; - } + // if feeds exists with the given url and title and they are the same, + // then there is nothing to update + if ($urlfeed['fid'] == $titlefeed['fid']) { + return $urlfeed['fid']; + } - // else a feed exists with the given URL, and a different feed exists with - // the given title, so we have a conflict the user must resolve + // else a feed exists with the given URL, and a different feed exists with + // the given title, so we have a conflict the user must resolve return -1; } @@ -107,7 +107,7 @@ * * @param $fid */ -function aggregation_remove_feed_items($fid){ +function aggregation_remove_feed_items($fid) { aggregator_remove($fid); } @@ -141,7 +141,7 @@ * * @param $title * @return - * A array of aggregator feed information. + * A array of aggregator feed information. */ function aggregation_get_feed_by_title($title) { if (!$title) return FALSE; @@ -159,7 +159,7 @@ * @param $fid Feed Id * @param $categories An array of categories to assign */ - function aggregation_set_feed_categories($fid,$categories){ + function aggregation_set_feed_categories($fid, $categories) { aggregation_clear_feed_categories($fid); if (is_array($categories)) { foreach ($categories as $cid) { @@ -173,7 +173,7 @@ * * @param $fid Feed Id */ - function aggregation_clear_feed_categories($fid){ + function aggregation_clear_feed_categories($fid) { db_query('DELETE FROM {aggregator_category_feed} WHERE fid=%d', $fid); } @@ -185,9 +185,9 @@ * @return * An array of category IDs */ - function aggregation_get_assigned_feed_categories($fid){ + function aggregation_get_assigned_feed_categories($fid) { $result=db_query('SELECT cid FROM {aggregator_category_feed} WHERE fid = %d', $fid); - while($category=db_fetch_array($result)) { + while ($category=db_fetch_array($result)) { $values[]=$category[cid]; } return $values; @@ -199,16 +199,16 @@ * * @return A list of options, Id as key, title as value */ - function aggregation_get_all_feed_categories(){ + function aggregation_get_all_feed_categories() { static $options; if (!$options) { // get aggregator categories $result = db_query('SELECT title, cid FROM {aggregator_category} ORDER BY title'); while ($category = db_fetch_array($result)) { - $options[$category['cid']]=$category['title']; + $options[$category['cid']]=$category['title']; } } - return $options; + return $options; } @@ -227,16 +227,11 @@ * @return * A feed id for the inserted feed */ - function _aggregation_insert_feed($feed){ + function _aggregation_insert_feed($feed) { $fid = db_next_id('{aggregator_feed}_fid'); $feed['refresh'] or $feed['refresh']=3600; $feed['block_id'] or $feed['block_id']=5; - db_query("INSERT INTO {aggregator_feed} (fid, title, url, refresh, block) VALUES (%d, '%s', '%s', %d, %d)", - $fid, - $feed['title'], - $feed['url'], - $feed['refresh'], - $feed['block_id']); + db_query("INSERT INTO {aggregator_feed} (fid, title, url, refresh, block) VALUES (%d, '%s', '%s', %d, %d)", $fid, $feed['title'], $feed['url'], $feed['refresh'], $feed['block_id']); if (!db_error()) { drupal_set_message(t('A new aggregator feed "%title" was created', array('%title' => $feed['title']))); @@ -254,13 +249,9 @@ * @return * A feed id for the updated feed */ - function _aggregation_update_feed($feed){ + function _aggregation_update_feed($feed) { $feed['refresh'] or $feed['refresh']=3600; - db_query("UPDATE {aggregator_feed} SET title = '%s', url = '%s', refresh = %d WHERE fid = %d", - $feed['title'], - $feed['url'], - $feed['refresh'], - $feed['fid']); + db_query("UPDATE {aggregator_feed} SET title = '%s', url = '%s', refresh = %d WHERE fid = %d", $feed['title'], $feed['url'], $feed['refresh'], $feed['fid']); return $feed['fid']; } ?> \ No newline at end of file Index: feed_node.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feed_node/feed_node.module,v retrieving revision 1.3 diff -u -r1.3 feed_node.module --- feed_node.module 19 Dec 2006 19:57:57 -0000 1.3 +++ feed_node.module 8 Apr 2007 14:59:43 -0000 @@ -13,7 +13,7 @@ */ // Currently, the feedfield project also uses the same aggregation_api.inc file -// which we need to check if already included. feed_node and feedfield are +// which we need to check if already included. feed_node and feedfield are // working towards adding more stability and functionality to the api for // wider usage with other aggregator related modules. if (!function_exists('aggregation_sync_feed')) { @@ -26,11 +26,11 @@ function feed_node_help($section) { switch ($section) { case 'admin/modules#description': - $output = t('The feed node module enables a node to have an aggregator feed associated with it.'); - break; - case "admin/settings/feed_node": - $output = '
' . t('The feed node module allows you to associate an aggregator feed with a particular node so that aggregator feed items can be displayed within the node body.') . '
'; - break; + $output = t('The feed node module enables a node to have an aggregator feed associated with it.'); + break; + case "admin/settings/feed_node": + $output = ''. t('The feed node module allows you to associate an aggregator feed with a particular node so that aggregator feed items can be displayed within the node body.') .'
'; + break; } return $output; @@ -40,13 +40,13 @@ * Implementation of hook_menu(). */ function feed_node_menu($may_cache) { - $items = array(); - - $items[] = array('path' => 'admin/settings/feed_node', 'title' => t('feed node'), + $items = array(); + + $items[] = array('path' => 'admin/settings/feed_node', 'title' => t('feed node'), 'callback' => 'feed_node_settings', 'access' => user_access('administer feed node')); - return $items; + return $items; } /** @@ -57,9 +57,9 @@ } function _feed_node_aggregator_dependency_check() { - if (!module_exist("aggregator")) { - drupal_set_message(t("You do not have the aggregator module installed. Please ensure this is enabled or feed node will not work."), "error"); - } + if (!module_exist("aggregator")) { + drupal_set_message(t("You do not have the aggregator module installed. Please ensure this is enabled or feed node will not work."), "error"); + } } /** @@ -67,43 +67,43 @@ */ function feed_node_settings() { - _feed_node_aggregator_dependency_check(); + _feed_node_aggregator_dependency_check(); - $form = array(); - $form['feed_node_allowed_html_tags'] = array( - '#type' => 'textfield', - '#title' => t('Allowed HTML tags'), - '#size' => 80, - '#maxlength' => 255, - '#default_value' => variable_get("feed_node_allowed_html_tags", ' -
-
- '),
- '#description' => t('The list of tags which are allowed in feed items, i.e., which will not be stripped out.')
- );
-
- $form['feed_node_teaser_length'] = array(
- '#type' => 'textfield',
- '#title' => t('Teaser length'),
- '#size' => 10,
- '#maxlength' => 5,
- '#default_value' => variable_get('feed_node_teaser_length', 200),
- '#description' => t('The maximum length for feed items. Feed items longer than this will be truncated.')
- );
-
- $form['feed_node_delete_flag'] = array(
- '#type' => 'checkbox',
- '#title' => t('Delete aggregator feed on node delete'),
- '#default_value' => variable_get('feed_node_delete_flag', 1),
- '#description' => t('Each feed enabled node is associated with a corresponding aggregator feed. If this is checked, then when the node is deleted, the corresponding aggregator feed is also deleted.')
- );
-
- // we could just to a standard 4.7 forms API returning of the $form variable,
- // but the only way to get a admin/settings menu title that says "feed node" instead
- // of "feed_node" is to specify a custom menu callback hook to this settings method, where
- // we now have to do some more traditional form stuff... like create a corresponding
- // submit method
- $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
- $form['clear'] = array('#type' => 'submit', '#value' => t('Reset to defaults'));
-
- return drupal_get_form('feed_node_settings', $form);
+ $form = array();
+ $form['feed_node_allowed_html_tags'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed HTML tags'),
+ '#size' => 80,
+ '#maxlength' => 255,
+ '#default_value' => variable_get("feed_node_allowed_html_tags", '
-
-
- '),
+ '#description' => t('The list of tags which are allowed in feed items, i.e., which will not be stripped out.'),
+ );
+
+ $form['feed_node_teaser_length'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Teaser length'),
+ '#size' => 10,
+ '#maxlength' => 5,
+ '#default_value' => variable_get('feed_node_teaser_length', 200),
+ '#description' => t('The maximum length for feed items. Feed items longer than this will be truncated.'),
+ );
+
+ $form['feed_node_delete_flag'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Delete aggregator feed on node delete'),
+ '#default_value' => variable_get('feed_node_delete_flag', 1),
+ '#description' => t('Each feed enabled node is associated with a corresponding aggregator feed. If this is checked, then when the node is deleted, the corresponding aggregator feed is also deleted.'),
+ );
+
+ // we could just to a standard 4.7 forms API returning of the $form variable,
+ // but the only way to get a admin/settings menu title that says "feed node" instead
+ // of "feed_node" is to specify a custom menu callback hook to this settings method, where
+ // we now have to do some more traditional form stuff... like create a corresponding
+ // submit method
+ $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
+ $form['clear'] = array('#type' => 'submit', '#value' => t('Reset to defaults'));
+
+ return drupal_get_form('feed_node_settings', $form);
}
function feed_node_settings_submit($form_id, $values) {
@@ -137,19 +137,16 @@
function _feed_node_validate($form) {
// if only one of feedtitle or feedurl exist, error
- // if both exist, then numitems must exist
- if (trim($form->feed_node['aggregator_feed']['title'])
- && !trim($form->feed_node['aggregator_feed']['url'])) {
- form_set_error('feed_node][aggregator_feed][url', t('If you specify a feed title, you must also specify a feed URL.'));
- }
- if (!trim($form->feed_node['aggregator_feed']['title'])
- && trim($form->feed_node['aggregator_feed']['url'])) {
- form_set_error('feed_node][aggregator_feed][title', t('If you specify a feed URL, you must also specify a feed title.'));
+ // if both exist, then numitems must exist
+ if (trim($form->feed_node['aggregator_feed']['title']) && !trim($form->feed_node['aggregator_feed']['url'])) {
+ form_set_error('feed_node][aggregator_feed][url', t('If you specify a feed title, you must also specify a feed URL.'));
+ }
+ if (!trim($form->feed_node['aggregator_feed']['title']) && trim($form->feed_node['aggregator_feed']['url'])) {
+ form_set_error('feed_node][aggregator_feed][title', t('If you specify a feed URL, you must also specify a feed title.'));
}
- if (trim($form->feed_node['aggregator_feed']['title'])
- && trim($form->feed_node['aggregator_feed']['url']) && !trim($form->feed_node['numItems'])) {
- form_set_error('feed_node][numItems', t('If you specify a feed, you must also specify how many feed items to list.'));
+ if (trim($form->feed_node['aggregator_feed']['title']) && trim($form->feed_node['aggregator_feed']['url']) && !trim($form->feed_node['numItems'])) {
+ form_set_error('feed_node][numItems', t('If you specify a feed, you must also specify how many feed items to list.'));
}
// check to see that we don't have a conflict with an existing feed
@@ -169,11 +166,11 @@
* @param $node
* @param $op
*/
-function feed_node_nodeapi(&$node, $op) {
-
+function feed_node_nodeapi(&$node, $op) {
+
switch ($op) {
case 'validate':
- _feed_node_validate($node);
+ _feed_node_validate($node);
break;
// load the extended node attributes
@@ -181,71 +178,67 @@
// fetch the feed node
$feed_node = db_fetch_array(db_query('SELECT * FROM {feed_node} WHERE nid = %d', $node->nid));
-
- // if no feed attached to the node, nothing to do...
- if ($feed_node) {
- // fetch the aggregator feed
- $aggregator_feed = aggregation_get_feed_by_id($feed_node['fid']);
-
- // fetch the aggregator items for the feed
- $result = db_query('SELECT * FROM {aggregator_item} WHERE fid = %d ORDER BY timestamp DESC, iid DESC LIMIT %d', $feed_node['fid'], $feed_node['numItems']);
- while ($data = db_fetch_array($result)) {
- $aggregator_items[] = $data;
- }
-
- // tack on the feed and feed items
- $feed_node['aggregator_feed'] = $aggregator_feed;
- $feed_node['aggregator_items'] = $aggregator_items;
-
- // return the additional node attributes
- return array('feed_node' => $feed_node);
- }
+
+ // if no feed attached to the node, nothing to do...
+ if ($feed_node) {
+ // fetch the aggregator feed
+ $aggregator_feed = aggregation_get_feed_by_id($feed_node['fid']);
+
+ // fetch the aggregator items for the feed
+ $result = db_query('SELECT * FROM {aggregator_item} WHERE fid = %d ORDER BY timestamp DESC, iid DESC LIMIT %d', $feed_node['fid'], $feed_node['numItems']);
+ while ($data = db_fetch_array($result)) {
+ $aggregator_items[] = $data;
+ }
+
+ // tack on the feed and feed items
+ $feed_node['aggregator_feed'] = $aggregator_feed;
+ $feed_node['aggregator_items'] = $aggregator_items;
+
+ // return the additional node attributes
+ return array('feed_node' => $feed_node);
+ }
break;
// insert the extended feed node attributes, only if we a feed title or feed url
case 'insert':
case 'update':
if ($op == "update") {
- // do a fresh insert
- db_query('DELETE FROM {feed_node} WHERE nid = %d', $node->nid);
- }
-
- // if we have a feed, ensure it is synced with the aggregator feed. Syncing ensures that
- // the feed exists in the aggregator table. If it doesn't, a new entry is created. If the
- // title or URL matches an existing entry, then the call to aggregation_sync_feed() ensures that
- // the aggregator feed item is updated so that the title and URL specified are updated for that
- // feed.
- if (trim($node->feed_node['aggregator_feed']['title']) && trim($node->feed_node['aggregator_feed']['url'])) {
- $fid = aggregation_sync_feed($node->feed_node['aggregator_feed']['title'], $node->feed_node['aggregator_feed']['url']);
- if ($fid != -1) {
- db_query('INSERT INTO {feed_node} (nid, fid, numItems, displayStyle) VALUES (%d, %d, %d, %d)', $node->nid, $fid, $node->feed_node['numItems'], $node->feed_node['displayStyle']);
- }
- else {
-
- }
- }
-
+ // do a fresh insert
+ db_query('DELETE FROM {feed_node} WHERE nid = %d', $node->nid);
+ }
+
+ // if we have a feed, ensure it is synced with the aggregator feed. Syncing ensures that
+ // the feed exists in the aggregator table. If it doesn't, a new entry is created. If the
+ // title or URL matches an existing entry, then the call to aggregation_sync_feed() ensures that
+ // the aggregator feed item is updated so that the title and URL specified are updated for that
+ // feed.
+ if (trim($node->feed_node['aggregator_feed']['title']) && trim($node->feed_node['aggregator_feed']['url'])) {
+ $fid = aggregation_sync_feed($node->feed_node['aggregator_feed']['title'], $node->feed_node['aggregator_feed']['url']);
+ if ($fid != -1) {
+ db_query('INSERT INTO {feed_node} (nid, fid, numItems, displayStyle) VALUES (%d, %d, %d, %d)', $node->nid, $fid, $node->feed_node['numItems'], $node->feed_node['displayStyle']);
+ }
+ }
break;
// delete the extended feed node attributes
case 'delete':
db_query('DELETE FROM {feed_node} WHERE nid = %d', $node->nid);
- // if this node has an associated feed and the delete flag is set,
+ // if this node has an associated feed and the delete flag is set,
// delete the feed and feed items
if (aggregation_get_feed_by_id($node->feed_node['fid']) && variable_get('feed_node_delete_flag', 1)) {
- aggregation_delete_feed($node->feed_node['fid']);
+ aggregation_delete_feed($node->feed_node['fid']);
}
break;
case 'view':
- // if we have an attached feed, display it in the body of the node
- if ($node->feed_node) {
- $node->body = $node->body . theme('feed_node', $node->feed_node);
- }
+ // if we have an attached feed, display it in the body of the node
+ if ($node->feed_node) {
+ $node->body = $node->body . theme('feed_node', $node->feed_node);
+ }
break;
}
-}
+}
/**
* Hook to alter the node edit form so we can allow the user to specify feed information and
@@ -286,61 +279,61 @@
case $type .'_node_form':
- // If the feed is enabled for this node type, we insert our control
+ // If the feed is enabled for this node type, we insert our control
// into the form.
if ($enabled) {
-
- // if we have a feed, body isn't mandatory, we override the
- // default of a mandatory body.
- $form['body_filter']['body']['#required'] = 0;
-
- $form['feed_node'] = array(
- '#type' => 'fieldset',
- '#title' => t('Feed information'),
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
- '#tree' => TRUE,
- '#weight' => 1
- );
-
- // fetch feed data to populate title and url form elements
- $feed = aggregation_get_feed_by_id($form['#node']->feed_node['fid']);
-
- $form['feed_node']['aggregator_feed']['title'] = array(
- '#type' => 'textfield',
- '#title' => t('Title of feed'),
- '#default_value' => $feed['title'],
- '#required' => FALSE,
- '#maxlength' => 255,
- '#tree' => TRUE,
- '#weight' => 0,
- );
-
- $form['feed_node']['aggregator_feed']['url'] = array(
- '#type' => 'textfield',
- '#title' => t('Feed URL'),
- '#default_value' => $feed['url'],
- '#required' => FALSE,
- '#maxlength' => 255,
- '#weight' => 0,
- );
-
- $numItems = $form['#node']->feed_node['numItems'];
- $form['feed_node']['numItems'] = array(
- '#type' => 'textfield',
- '#title' => t('Number of feed items to display'),
- '#default_value' => $numItems ? $numItems : 10 ,
- '#required' => FALSE,
- '#maxlength' => 10,
- '#weight' => 1,
- );
-
- $form['feed_node']['displayStyle'] = array(
- '#type' => 'radios',
- '#title' => t('Display style'),
- '#default_value' => $form['#node']->feed_node['displayStyle'],
- '#options' => array(t('Title + Teaser'), t('Title only')),
- );
+
+ // if we have a feed, body isn't mandatory, we override the
+ // default of a mandatory body.
+ $form['body_filter']['body']['#required'] = 0;
+
+ $form['feed_node'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Feed information'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#tree' => TRUE,
+ '#weight' => 1,
+ );
+
+ // fetch feed data to populate title and url form elements
+ $feed = aggregation_get_feed_by_id($form['#node']->feed_node['fid']);
+
+ $form['feed_node']['aggregator_feed']['title'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Title of feed'),
+ '#default_value' => $feed['title'],
+ '#required' => FALSE,
+ '#maxlength' => 255,
+ '#tree' => TRUE,
+ '#weight' => 0,
+ );
+
+ $form['feed_node']['aggregator_feed']['url'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Feed URL'),
+ '#default_value' => $feed['url'],
+ '#required' => FALSE,
+ '#maxlength' => 255,
+ '#weight' => 0,
+ );
+
+ $numItems = $form['#node']->feed_node['numItems'];
+ $form['feed_node']['numItems'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Number of feed items to display'),
+ '#default_value' => $numItems ? $numItems : 10 ,
+ '#required' => FALSE,
+ '#maxlength' => 10,
+ '#weight' => 1,
+ );
+
+ $form['feed_node']['displayStyle'] = array(
+ '#type' => 'radios',
+ '#title' => t('Display style'),
+ '#default_value' => $form['#node']->feed_node['displayStyle'],
+ '#options' => array(t('Title + Teaser'), t('Title only')),
+ );
} // endif
break;
@@ -368,14 +361,14 @@
function _feed_node_fetch_unique_feed_items($result) {
$item_tracker = array();
- if (db_num_rows($result)) {
- while ($item = db_fetch_array($result)) {
- if ($item_tracker[$item['timestamp']] != md5($item['description'])) {
- $item_tracker[$item['timestamp']] = md5($item['description']);
- $items[] = $item;
- }
- }
- }
+ if (db_num_rows($result)) {
+ while ($item = db_fetch_array($result)) {
+ if ($item_tracker[$item['timestamp']] != md5($item['description'])) {
+ $item_tracker[$item['timestamp']] = md5($item['description']);
+ $items[] = $item;
+ }
+ }
+ }
return $items;
}
@@ -394,9 +387,9 @@
$output .= '
'. t($feed['title']) .'
';
if ($feed['link']) {
- $output .= ''. t('URL:') .' '. l($feed['link'], $feed['link'], array(), NULL, NULL, TRUE) ."\n";
+ $output .= ''. t('URL:') .' '. l($feed['link'], $feed['link'], array(), NULL, NULL, TRUE) ."\n";
}
-
+
if ($feed['checked']) {
$updated = t('%time ago', array('%time' => format_interval(time() - $feed['checked'])));
}
@@ -408,19 +401,17 @@
$updated = l($updated, 'admin/aggregator');
}
- $output .= ''. t('Updated:') . " $updated";
+ $output .= ''. t('Updated:') ." $updated";
// output individual feed items
$aggregator_items = $feed_node['aggregator_items'];
if ($aggregator_items) {
- foreach ($aggregator_items as $aggregator_item) {
- $item_outputs[] = $feed_node['displayStyle']
- ? theme('feed_node_item_summary', $aggregator_item)
- : theme('feed_node_item', $aggregator_item);
- }
+ foreach ($aggregator_items as $aggregator_item) {
+ $item_outputs[] = $feed_node['displayStyle'] ? theme('feed_node_item_summary', $aggregator_item) : theme('feed_node_item', $aggregator_item);
+ }
}
else {
- $item_outputs[] = t("No feed items available.");
+ $item_outputs[] = t("No feed items available.");
}
// if title only, theme as a list, else concatenate item outputs.
@@ -428,23 +419,19 @@
$output .= '';
- return $output;
+ return $output;
}
/**
* Returns a themed summary display for an individual aggregator feed item.
*
* @param $item
- * The item array from the aggregator module.
+ * The item array from the aggregator module.
* @return
- * A string containing the HTML fragment.
+ * A string containing the HTML fragment.
*/
function theme_feed_node_item_summary($item) {
- $output = '' .
- check_plain($item['title']) .
- ' '.
- t('%age old', array('%age' => format_interval(time() - $item['timestamp']))) .'';
+ $output = ''. check_plain($item['title']) .' '. t('%age old', array('%age' => format_interval(time() - $item['timestamp']))) .'';
return $output ."\n";
}
@@ -453,9 +440,9 @@
* Returns a themed detail display for an individual aggregator feed item.
*
* @param $item
- * The item array from the aggregator module.
+ * The item array from the aggregator module.
* @return
- * A string containing the HTML fragment.
+ * A string containing the HTML fragment.
*/
function theme_feed_node_item($item) {
@@ -496,30 +483,28 @@
* to the specified length.
*
* @param $html
- * The HTML fragment to summarize
+ * The HTML fragment to summarize
* @param $length
- * The maximum length the truncated fragment should be.
+ * The maximum length the truncated fragment should be.
* @return
- * The truncated HTMl fragment.
+ * The truncated HTMl fragment.
*/
function _feed_node_truncate($html, $length = 200) {
- // similar to feedburner summarize feature, strips out links, then truncates to approximate
- // length.
- $html = filter_xss($html, preg_split('/\s+|<|>/', variable_get("feed_node_allowed_html_tags", ' -
-
- '), -1, PREG_SPLIT_NO_EMPTY));
-
- // zip in $length chars, then skip to the next word boundary
- if (preg_match("/(.{" . $length . "})(.*?)\W/", $html, $m)) {
- $html = $m[1] . $m[2] . "...";
- }
-
- // if still over the length due to extremely long word, chop it
- if (strlen($html) > $length) {
- $html = substr($html, 0, $length) . "...";
- }
-
- return $html;
+ // similar to feedburner summarize feature, strips out links, then truncates to approximate
+ // length.
+ $html = filter_xss($html, preg_split('/\s+|<|>/', variable_get("feed_node_allowed_html_tags", '
-
-
- '), -1, PREG_SPLIT_NO_EMPTY));
+
+ // zip in $length chars, then skip to the next word boundary
+ if (preg_match("/(.{". $length ."})(.*?)\W/", $html, $m)) {
+ $html = $m[1] . $m[2] ."...";
+ }
+
+ // if still over the length due to extremely long word, chop it
+ if (strlen($html) > $length) {
+ $html = substr($html, 0, $length) ."...";
+ }
+
+ return $html;
}
-
-?>
\ No newline at end of file