diff -Nurp ./modules/syndicate/atom/atom.info /home/stabile/Projects/drupal/drupal-7.x-dev-syndicate/modules/syndicate/atom/atom.info
--- ./modules/syndicate/atom/atom.info 1969-12-31 18:00:00.000000000 -0600
+++ /home/stabile/Projects/drupal/drupal-7.x-dev-syndicate/modules/syndicate/atom/atom.info 2008-03-06 06:13:18.000000000 -0600
@@ -0,0 +1,6 @@
+name = Atom
+description = "Provides an Atom 1.0 feed"
+package = Syndicate
+dependencies[] = syndicate
+version = VERSION
+core = 7.x
\ No newline at end of file
diff -Nurp ./modules/syndicate/atom/atom.module /home/stabile/Projects/drupal/drupal-7.x-dev-syndicate/modules/syndicate/atom/atom.module
--- ./modules/syndicate/atom/atom.module 1969-12-31 18:00:00.000000000 -0600
+++ /home/stabile/Projects/drupal/drupal-7.x-dev-syndicate/modules/syndicate/atom/atom.module 2008-03-06 06:13:18.000000000 -0600
@@ -0,0 +1,292 @@
+');
+ }
+ elseif (arg(0) == 'node' && is_numeric(arg(1))) {
+ drupal_set_html_head('');
+ }
+ elseif (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
+ drupal_set_html_head('');
+ }
+ elseif (arg(0) == 'blog') {
+ drupal_set_html_head('');
+ }
+ else {
+ drupal_set_html_head('');
+ }
+}
+
+/**
+ * Implementation of hook_menu()
+ *
+ * @return array
+ */
+function atom_menu() {
+ $items = array();
+
+ $items['feed/atom'] = array(
+ 'title' => 'atom feed',
+ 'page callback' => 'atom_feed',
+ 'access callback' => 'user_access',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK
+ );
+ $items['blog/feed/atom'] = array(
+ 'title' => 'atom blog feed',
+ 'page callback' => 'atom_blog_feed',
+ 'access callback' => 'user_access',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK
+ );
+ $items['node/%/feed/atom'] = array(
+ 'title' => 'atom node feed',
+ 'page callback' => 'atom_node_feed',
+ 'page arguments' => array(1),
+ 'access callback' => 'user_access',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK
+ );
+ $items['blog/%/feed/atom'] = array(
+ 'title' => 'atom blog feed',
+ 'page callback' => 'atom_user_blog_feed',
+ 'page arguments' => array(1),
+ 'access callback' => 'user_access',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK
+ );
+ $items['taxonomy/term/%/feed/atom'] = array(
+ 'title' => 'atom taxonomy feed',
+ 'page callback' => 'atom_taxonomy_feed',
+ 'page arguments' => array(2),
+ 'access callback' => 'user_access',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK
+ );
+
+ return $items;
+}
+
+/**
+ * Produces an atom 1.0 feed for the front page content.
+ */
+function atom_feed() {
+ if (strpos(arg(2), 'atom') === 0 || strpos(arg(2), 'feed') === 0) {
+ die(drupal_not_found());
+ }
+ global $base_url;
+ $nodes = db_query_range("SELECT n.nid FROM {node} n WHERE n.promote = '1' AND n.status = '1' ORDER BY n.created DESC", 0, variable_get('atom_feed_entries', 15));
+
+ $feed_info = array();
+ $feed_info['title'] = strip_tags(variable_get('site_name', 'Drupal'));
+ $feed_info['subtitle'] = strip_tags(variable_get('site_slogan', ''));
+ $feed_info['html_url'] = $base_url;
+ $feed_info['atom_url'] = url('feed/atom', array('absolute' => true));
+ _atom_print_feed($nodes, $feed_info);
+}
+
+function atom_blog_feed() {
+ if (strpos(arg(3), 'atom') === 0 || strpos(arg(3), 'feed') === 0) {
+ die(drupal_not_found());
+ }
+ $nodes = db_query_range("SELECT n.nid FROM {node} n WHERE n.type = 'blog' AND n.status = '1' ORDER BY n.created DESC", 0, variable_get('atom_feed_entries', 15));
+
+ $feed_info = array();
+ $feed_info['title'] = strip_tags(sprintf(t('%s blogs'), variable_get('site_name', 'Drupal')));
+ $feed_info['subtitle'] = strip_tags(variable_get('site_slogan', ''));
+ $feed_info['html_url'] = url('blog', array('absolute' => true));
+ $feed_info['atom_url'] = url('blog/feed/atom', array('absolute' => true));
+ _atom_print_feed($nodes, $feed_info);
+}
+
+function atom_node_feed($nid) {
+ if (strpos(arg(4), 'atom') === 0 || strpos(arg(4), 'feed') === 0) {
+ die(drupal_not_found());
+ }
+ $nodes = db_query("SELECT n.nid FROM {node} n WHERE n.nid = %d AND n.status = '1' ORDER BY n.created DESC LIMIT 1", $nid);
+
+ $feed_info = array();
+ $feed_info['title'] = variable_get('site_name', 'Drupal');
+ $feed_info['subtitle'] = strip_tags(variable_get('site_slogan', ''));
+ $feed_info['html_url'] = url("node/$nid", array('absolute' => true));
+ $feed_info['atom_url'] = url("node/$nid/feed/atom", array('absolute' => true));
+ _atom_print_feed($nodes, $feed_info);
+}
+
+function atom_user_blog_feed($uid) {
+ if (strpos(arg(4), 'atom') === 0 || strpos(arg(4), 'feed') === 0) {
+ die(drupal_not_found());
+ }
+ $user_result = db_query_range("SELECT u.name FROM {users} u WHERE u.uid = %d", $uid, 0, 1);
+ if (!$user = db_result($user_result)) {
+ return t('User does not exist.');
+ }
+
+ $nodes = db_query_range("SELECT n.nid FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = '1' ORDER BY n.created DESC", $uid, 0, variable_get('syndication_feed_entries', 15));
+
+ $feed_info = array();
+ $feed_info['title'] = sprintf(t("%s's blog"), $user);
+ $feed_info['subtitle'] = '';
+ $feed_info['html_url'] = url("blog/$uid", array('absolute' => true));
+ $feed_info['atom_url'] = url("blog/$uid/feed/atom", array('absolute' => true));
+ _atom_print_feed($nodes, $feed_info);
+}
+
+function atom_taxonomy_feed($str_tids) {
+ if (!module_exists('taxonomy') || strpos(arg(5), 'atom') === 0 || strpos(arg(6), 'feed') === 0) {
+ die(drupal_not_found());
+ }
+ $terms = taxonomy_terms_parse_string($str_tids);
+ $result = db_query(db_rewrite_sql('SELECT t.tid FROM {term_data} t WHERE t.tid IN ('. db_placeholders($terms['tids']) .')', 't', 'tid'), $terms['tids']);
+ $tids = array();
+ while ($term = db_fetch_object($result)) {
+ $tids[] = $term->tid;
+ }
+ $nodes = taxonomy_select_nodes($tids, $terms['operator'], 0, TRUE);
+
+ $feed_info = array();
+ if (count($tids) == 1) {
+ $term = taxonomy_get_term($tids[0]);
+ $feed_info['title'] = $term->name;
+ $feed_info['subtitle'] = $term->description;
+ }
+ else {
+ $feed_info['title'] = variable_get('site_name', 'Drupal');
+ $feed_info['subtitle'] = '';
+ }
+ $feed_info['html_url'] = url("taxonomy/term/$str_tids", array('absolute' => true));
+ $feed_info['atom_url'] = url("taxonomy/term/$str_tids/feed/atom", array('absolute' => true));
+ _atom_print_feed($nodes, $feed_info);
+}
+
+/**
+ * prints feed information from query of either front page or blog content
+ *
+ * @param object $nodes query result
+ * @param array feed information
+ */
+function _atom_print_feed($nodes, $feed_info) {
+ $output = '';
+ $last_mod = 0;
+ while ($node = db_fetch_object($nodes)) {
+ $item = node_load(array('nid' => $node->nid));
+ if (!node_access('view', $item)) {
+ continue;
+ }
+
+ $link = url("node/$node->nid", array('absolute' => true));
+
+ if (node_hook($item, 'view')) {
+ node_invoke($item, 'view', TRUE, FALSE);
+ }
+ else {
+ $item = node_prepare($item, TRUE);
+ }
+
+ // Allow modules to change $node->teaser before viewing.
+ node_invoke_nodeapi($item, 'view', true, false);
+
+ $output .= " \n";
+ $output .= ' '. check_plain(strip_tags($item->title)) ."\n";
+ $output .= ' '. "\n";
+ $output .= ' '. $link ."\n";
+ $output .= ' '. _atom_timestamp2w3dtf($item->created) ."\n";
+ $output .= ' '. _atom_timestamp2w3dtf($item->changed) ."\n";
+ $last_mod = $item->changed;
+ $output .= " \n";
+ if ($item->name) {
+ $output .= ' '. $item->name ."\n";
+ }
+ else {
+ $output .= ' '. variable_get('anonymous', 'Anonymous') ."\n";
+ }
+ $output .= " \n";
+ if (module_exists('taxonomy')) {
+ $terms = taxonomy_node_get_terms($item);
+ foreach ($terms as $term) {
+ $output .= ' '. "\n";
+ }
+ }
+
+ if (variable_get('syndication_display_summary', SYNDICATION_DISPLAY_SUMMARY)) {
+ // Summary
+ $output .= ' teaser, $item->format, FALSE);
+ $output .= " ]]>\n";
+ }
+
+
+ if (variable_get('syndication_display_content', SYNDICATION_DISPLAY_CONTENT)) {
+ // Body
+ $output .= ' body, $item->format, FALSE);
+ $output .= " ]]>\n";
+ }
+ $output .= " \n";
+ }
+
+ print theme('atom_feed', $feed_info, $last_mod, $output);
+}
+
+/**
+ * Implementation of hook_theme()
+ *
+ * @return array
+ */
+function atom_theme() {
+ return array(
+ 'atom_feed' => array(
+ 'arguments' => array(
+ 'feed_info' => array(),
+ 'last_mod' => 0,
+ 'output' => ''
+ )
+ )
+ );
+}
+
+function theme_atom_feed($feed_info, $last_mod, $output) {
+ drupal_set_header('Content-Type: application/xml');
+
+ $feed = ''. "\n";
+ $feed .= ''. "\n";
+ $feed .= ' '. $feed_info['title'] ."\n";
+ $feed .= $feed_info['subtitle'] == '' ? '' : ' '. $feed_info['subtitle'] . "\n";
+ $feed .= ' '. "\n";
+ $feed .= ' '. "\n";
+ $feed .= ' '. $feed_info['atom_url'] ."\n";
+ $feed .= ' '. _atom_timestamp2w3dtf($last_mod) ."\n";
+ $feed .= $output;
+ $feed .= "\n";
+
+ return $feed;
+}
+
+/**
+ * @return string
+ */
+function _atom_timestamp2w3dtf($timestamp) {
+ $tz = date("O", $timestamp);
+ return date("Y-m-d", $timestamp) .'T'. date("H:i:s", $timestamp) . substr($tz, 0, 3) . ':' . substr($tz, 3, 2);
+}
+
+
diff -Nurp ./modules/syndicate/syndicate.info /home/stabile/Projects/drupal/drupal-7.x-dev-syndicate/modules/syndicate/syndicate.info
--- ./modules/syndicate/syndicate.info 1969-12-31 18:00:00.000000000 -0600
+++ /home/stabile/Projects/drupal/drupal-7.x-dev-syndicate/modules/syndicate/syndicate.info 2008-03-06 06:13:18.000000000 -0600
@@ -0,0 +1,5 @@
+name = Syndicate
+description = Control syndication settings and feeds
+package = Core - optional
+version = VERSION
+core = 7.x
\ No newline at end of file
diff -Nurp ./modules/syndicate/syndicate.module /home/stabile/Projects/drupal/drupal-7.x-dev-syndicate/modules/syndicate/syndicate.module
--- ./modules/syndicate/syndicate.module 1969-12-31 18:00:00.000000000 -0600
+++ /home/stabile/Projects/drupal/drupal-7.x-dev-syndicate/modules/syndicate/syndicate.module 2008-03-06 06:13:18.000000000 -0600
@@ -0,0 +1,81 @@
+ 'Syndication',
+ 'description' => 'Configure number of entries in the feed',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('syndicate_admin_settings'),
+ 'access callback' => 'user_access',
+ 'access arguments' => array('administer syndication'),
+ 'type' => MENU_NORMAL_ITEM
+ );
+
+ return $items;
+}
+
+/**
+ * Module configuration settings
+ *
+ * @return array of settings form options or deny access
+ */
+function syndication_admin_settings() {
+ $form = array();
+
+ $form['syndicate_feed_options'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Feed display options'),
+ '#collapsible' => true,
+ '#collapsed' => true
+ );
+ $form['syndicate_feed_options']['syndicate_feed_entries'] = array(
+ '#type' => 'select',
+ '#title' => t('Maximum number of entries to include in feeds'),
+ '#default_value' => variable_get('syndication_feed_entries', 15),
+ '#options' => drupal_map_assoc(range(1, 30))
+ );
+ $form['syndicate_feed_options']['syndicate_display_summary'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Output the summary'),
+ '#description' => t('aka the teaser'),
+ '#default_value' => variable_get('syndicate_display_summary', SYNDICATION_DISPLAY_SUMMARY)
+ );
+ $form['syndicate_feed_options']['syndicate_display_content'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Output the content'),
+ '#description' => t('aka the body'),
+ '#default_value' => variable_get('syndicate_display_content', SYNDICATION_DISPLAY_CONTENT)
+ );
+
+ return system_settings_form($form);
+}
+?>