diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/aggregator.module | 18 | ||||
-rw-r--r-- | modules/aggregator/aggregator.module | 18 | ||||
-rw-r--r-- | modules/blog.module | 4 | ||||
-rw-r--r-- | modules/blog/blog.module | 4 | ||||
-rw-r--r-- | modules/comment.module | 2 | ||||
-rw-r--r-- | modules/comment/comment.module | 2 | ||||
-rw-r--r-- | modules/node.module | 53 | ||||
-rw-r--r-- | modules/node/node.module | 53 | ||||
-rw-r--r-- | modules/system.module | 6 | ||||
-rw-r--r-- | modules/system/system.module | 6 | ||||
-rw-r--r-- | modules/taxonomy.module | 2 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.module | 2 |
12 files changed, 134 insertions, 36 deletions
diff --git a/modules/aggregator.module b/modules/aggregator.module index 2f7498d19..99cfed63e 100644 --- a/modules/aggregator.module +++ b/modules/aggregator.module @@ -1058,21 +1058,33 @@ function aggregator_page_rss() { $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, iid DESC'; - $result = db_query_range($sql, $category->cid, 0, 15); + $result = db_query_range($sql, $category->cid, 0, variable_get('feed_default_items', 10)); } // or, get the default aggregator items else { $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'; - $result = db_query_range($sql, 0, 15); + $result = db_query_range($sql, 0, variable_get('feed_default_items', 10)); } while ($item = db_fetch_object($result)) { + switch (variable_get('feed_item_length', 'teaser')) { + case 'teaser': + $teaser = node_teaser($item->description); + if ($teaser != $item_description) { + $teaser .= '<p><a href="'. check_url($item->link) .'">'. t('read more') ."</a></p>\n"; + } + $item->description = $teaser; + break; + case 'title': + $item->description = ''; + break; + } $items .= format_rss_item($item->ftitle . ': ' . $item->title, $item->link, $item->description, array('pubDate' => date('r', $item->timestamp))); } $output .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $output .= "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">]>\n"; - $output .= "<rss version=\"0.92\">\n"; + $output .= "<rss version=\"2.0\">\n"; $output .= format_rss_channel(variable_get('site_name', t('Drupal')) . ' ' . t('aggregator'), $base_url . '/' . url('aggregator' . $url), variable_get('site_name', t('Drupal')) . ' - ' . t('aggregated feeds') . $title, $items, 'en'); $output .= "</rss>\n"; diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module index 2f7498d19..99cfed63e 100644 --- a/modules/aggregator/aggregator.module +++ b/modules/aggregator/aggregator.module @@ -1058,21 +1058,33 @@ function aggregator_page_rss() { $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, iid DESC'; - $result = db_query_range($sql, $category->cid, 0, 15); + $result = db_query_range($sql, $category->cid, 0, variable_get('feed_default_items', 10)); } // or, get the default aggregator items else { $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'; - $result = db_query_range($sql, 0, 15); + $result = db_query_range($sql, 0, variable_get('feed_default_items', 10)); } while ($item = db_fetch_object($result)) { + switch (variable_get('feed_item_length', 'teaser')) { + case 'teaser': + $teaser = node_teaser($item->description); + if ($teaser != $item_description) { + $teaser .= '<p><a href="'. check_url($item->link) .'">'. t('read more') ."</a></p>\n"; + } + $item->description = $teaser; + break; + case 'title': + $item->description = ''; + break; + } $items .= format_rss_item($item->ftitle . ': ' . $item->title, $item->link, $item->description, array('pubDate' => date('r', $item->timestamp))); } $output .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $output .= "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">]>\n"; - $output .= "<rss version=\"0.92\">\n"; + $output .= "<rss version=\"2.0\">\n"; $output .= format_rss_channel(variable_get('site_name', t('Drupal')) . ' ' . t('aggregator'), $base_url . '/' . url('aggregator' . $url), variable_get('site_name', t('Drupal')) . ' - ' . t('aggregated feeds') . $title, $items, 'en'); $output .= "</rss>\n"; diff --git a/modules/blog.module b/modules/blog.module index bed0e311c..a773a566e 100644 --- a/modules/blog.module +++ b/modules/blog.module @@ -77,7 +77,7 @@ function blog_feed_user($uid = 0) { $account = $user; } - $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, r.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {node_revisions} r ON n.vid = r.vid INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = %d AND n.status = 1 ORDER BY n.created DESC"), $uid, 0, 15); + $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, r.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {node_revisions} r ON n.vid = r.vid INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = %d AND n.status = 1 ORDER BY n.created DESC"), $uid, 0, variable_get('feed_default_items', 10)); $channel['title'] = $account->name ."'s blog"; $channel['link'] = url("blog/$uid", NULL, NULL, TRUE); $channel['description'] = $term->description; @@ -88,7 +88,7 @@ function blog_feed_user($uid = 0) { * Displays an RSS feed containing recent blog entries of all users. */ function blog_feed_last() { - $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, r.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {node_revisions} r ON n.vid = r.vid INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, 15); + $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, r.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {node_revisions} r ON n.vid = r.vid INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, variable_get('feed_default_items', 10)); $channel['title'] = variable_get('site_name', 'drupal') .' blogs'; $channel['link'] = url('blog', NULL, NULL, TRUE); $channel['description'] = $term->description; diff --git a/modules/blog/blog.module b/modules/blog/blog.module index bed0e311c..a773a566e 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -77,7 +77,7 @@ function blog_feed_user($uid = 0) { $account = $user; } - $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, r.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {node_revisions} r ON n.vid = r.vid INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = %d AND n.status = 1 ORDER BY n.created DESC"), $uid, 0, 15); + $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, r.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {node_revisions} r ON n.vid = r.vid INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = %d AND n.status = 1 ORDER BY n.created DESC"), $uid, 0, variable_get('feed_default_items', 10)); $channel['title'] = $account->name ."'s blog"; $channel['link'] = url("blog/$uid", NULL, NULL, TRUE); $channel['description'] = $term->description; @@ -88,7 +88,7 @@ function blog_feed_user($uid = 0) { * Displays an RSS feed containing recent blog entries of all users. */ function blog_feed_last() { - $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, r.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {node_revisions} r ON n.vid = r.vid INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, 15); + $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, r.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {node_revisions} r ON n.vid = r.vid INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, variable_get('feed_default_items', 10)); $channel['title'] = variable_get('site_name', 'drupal') .' blogs'; $channel['link'] = url('blog', NULL, NULL, TRUE); $channel['description'] = $term->description; diff --git a/modules/comment.module b/modules/comment.module index be05f3c9d..261743094 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -284,6 +284,8 @@ function comment_nodeapi(&$node, $op, $arg = 0) { case 'search result': $comments = db_result(db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = %d', $node->nid)); return format_plural($comments, '1 comment', '%count comments'); + case 'rss item': + return array(array('key' => 'comments', 'value' => url('node/'.$node->nid, NULL, 'comment', TRUE))); } } diff --git a/modules/comment/comment.module b/modules/comment/comment.module index be05f3c9d..261743094 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -284,6 +284,8 @@ function comment_nodeapi(&$node, $op, $arg = 0) { case 'search result': $comments = db_result(db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = %d', $node->nid)); return format_plural($comments, '1 comment', '%count comments'); + case 'rss item': + return array(array('key' => 'comments', 'value' => url('node/'.$node->nid, NULL, 'comment', TRUE))); } } diff --git a/modules/node.module b/modules/node.module index 331267551..3a17febf5 100644 --- a/modules/node.module +++ b/modules/node.module @@ -1160,29 +1160,58 @@ function node_feed($nodes = 0, $channel = array()) { global $base_url, $locale; if (!$nodes) { - $nodes = db_query_range(db_rewrite_sql('SELECT n.nid FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.created DESC'), 0, 15); + $nodes = db_query_range(db_rewrite_sql('SELECT n.nid FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.created DESC'), 0, variable_get('feed_default_items', 10)); } + $item_length = variable_get('feed_item_length', 'teaser'); + $namespaces = array('xmlns:dc="http://purl.org/dc/elements/1.1/"'); + while ($node = db_fetch_object($nodes)) { // Load the specified node: $item = node_load($node->nid); $link = url("node/$node->nid", NULL, NULL, 1); - // Filter and prepare node teaser - if (node_hook($item, 'view')) { - node_invoke($item, 'view', TRUE, FALSE); - } - else { - $item = node_prepare($item, TRUE); + if ($item_length != 'title') { + $teaser = ($item_length == 'teaser') ? TRUE : FALSE; + + // Filter and prepare node teaser + if (node_hook($item, 'view')) { + node_invoke($item, 'view', $teaser, FALSE); + } + else { + $item = node_prepare($item, $teaser); + } + + // Allow modules to change $node->teaser before viewing. + node_invoke_nodeapi($item, 'view', $teaser, FALSE); } - // Allow modules to change $node->teaser before viewing. - node_invoke_nodeapi($item, 'view', true, false); + // Prepare the item description + switch ($item_length) { + case 'fulltext': + $item_text = $item->body; + break; + case 'teaser': + $item_text = $item->teaser; + if ($item->readmore) { + $item_text .= '<p>'. l(t('read more'), 'node/'. $item->nid, NULL, NULL, NULL, TRUE) .'</p>'; + } + break; + case 'title': + $item_text = ''; + break; + } // Allow modules to add additional item fields $extra = node_invoke_nodeapi($item, 'rss item'); - $extra = array_merge($extra, array(array('key' => 'pubDate', 'value' => date('r', $item->created)))); - $items .= format_rss_item($item->title, $link, $item->teaser, $extra); + $extra = array_merge($extra, array(array('key' => 'pubDate', 'value' => date('r', $item->created)), + array('key' => 'dc:creator', 'value' => $item->name))); + foreach ($extra as $element) { + if ($element['namespace']) { + $namespaces = array_merge($namespaces, array($element['namespace'])); + } + } + $items .= format_rss_item($item->title, $link, $item_text, $extra); } $channel_defaults = array( @@ -1196,7 +1225,7 @@ function node_feed($nodes = 0, $channel = array()) { $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $output .= "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">]>\n"; - $output .= "<rss version=\"". $channel["version"] . "\" xml:base=\"". $base_url ."\">\n"; + $output .= "<rss version=\"". $channel["version"] . "\" xml:base=\"". $base_url ."\" ". implode(' ', $namespaces) .">\n"; $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']); $output .= "</rss>\n"; diff --git a/modules/node/node.module b/modules/node/node.module index 331267551..3a17febf5 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1160,29 +1160,58 @@ function node_feed($nodes = 0, $channel = array()) { global $base_url, $locale; if (!$nodes) { - $nodes = db_query_range(db_rewrite_sql('SELECT n.nid FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.created DESC'), 0, 15); + $nodes = db_query_range(db_rewrite_sql('SELECT n.nid FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.created DESC'), 0, variable_get('feed_default_items', 10)); } + $item_length = variable_get('feed_item_length', 'teaser'); + $namespaces = array('xmlns:dc="http://purl.org/dc/elements/1.1/"'); + while ($node = db_fetch_object($nodes)) { // Load the specified node: $item = node_load($node->nid); $link = url("node/$node->nid", NULL, NULL, 1); - // Filter and prepare node teaser - if (node_hook($item, 'view')) { - node_invoke($item, 'view', TRUE, FALSE); - } - else { - $item = node_prepare($item, TRUE); + if ($item_length != 'title') { + $teaser = ($item_length == 'teaser') ? TRUE : FALSE; + + // Filter and prepare node teaser + if (node_hook($item, 'view')) { + node_invoke($item, 'view', $teaser, FALSE); + } + else { + $item = node_prepare($item, $teaser); + } + + // Allow modules to change $node->teaser before viewing. + node_invoke_nodeapi($item, 'view', $teaser, FALSE); } - // Allow modules to change $node->teaser before viewing. - node_invoke_nodeapi($item, 'view', true, false); + // Prepare the item description + switch ($item_length) { + case 'fulltext': + $item_text = $item->body; + break; + case 'teaser': + $item_text = $item->teaser; + if ($item->readmore) { + $item_text .= '<p>'. l(t('read more'), 'node/'. $item->nid, NULL, NULL, NULL, TRUE) .'</p>'; + } + break; + case 'title': + $item_text = ''; + break; + } // Allow modules to add additional item fields $extra = node_invoke_nodeapi($item, 'rss item'); - $extra = array_merge($extra, array(array('key' => 'pubDate', 'value' => date('r', $item->created)))); - $items .= format_rss_item($item->title, $link, $item->teaser, $extra); + $extra = array_merge($extra, array(array('key' => 'pubDate', 'value' => date('r', $item->created)), + array('key' => 'dc:creator', 'value' => $item->name))); + foreach ($extra as $element) { + if ($element['namespace']) { + $namespaces = array_merge($namespaces, array($element['namespace'])); + } + } + $items .= format_rss_item($item->title, $link, $item_text, $extra); } $channel_defaults = array( @@ -1196,7 +1225,7 @@ function node_feed($nodes = 0, $channel = array()) { $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $output .= "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">]>\n"; - $output .= "<rss version=\"". $channel["version"] . "\" xml:base=\"". $base_url ."\">\n"; + $output .= "<rss version=\"". $channel["version"] . "\" xml:base=\"". $base_url ."\" ". implode(' ', $namespaces) .">\n"; $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']); $output .= "</rss>\n"; diff --git a/modules/system.module b/modules/system.module index 1168a1223..56c648273 100644 --- a/modules/system.module +++ b/modules/system.module @@ -238,6 +238,12 @@ function system_view_general() { $output .= form_group_collapsible(t('Image handling'), '<p>'. $group .'</p>', TRUE); } + // Feed settings + $group = ''; + $group .= form_select(t('Number of items per feed'), 'feed_default_items', variable_get('feed_default_items', 10), drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)), t('The default number of items to include in a feed.')); + $group .= form_select(t('Display of XML feed items'), 'feed_item_length', variable_get('feed_item_length','teaser'), array('title' => t('Titles only'), 'teaser' => t('Titles plus teaser'), 'fulltext' => t('Full text')), t('Global setting for the length of XML feed items that are output by default.')); + $output .= form_group_collapsible(t('RSS feed settings'), $group, TRUE); + // Date settings: $zones = _system_zonelist(); diff --git a/modules/system/system.module b/modules/system/system.module index 1168a1223..56c648273 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -238,6 +238,12 @@ function system_view_general() { $output .= form_group_collapsible(t('Image handling'), '<p>'. $group .'</p>', TRUE); } + // Feed settings + $group = ''; + $group .= form_select(t('Number of items per feed'), 'feed_default_items', variable_get('feed_default_items', 10), drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)), t('The default number of items to include in a feed.')); + $group .= form_select(t('Display of XML feed items'), 'feed_item_length', variable_get('feed_item_length','teaser'), array('title' => t('Titles only'), 'teaser' => t('Titles plus teaser'), 'fulltext' => t('Full text')), t('Global setting for the length of XML feed items that are output by default.')); + $output .= form_group_collapsible(t('RSS feed settings'), $group, TRUE); + // Date settings: $zones = _system_zonelist(); diff --git a/modules/taxonomy.module b/modules/taxonomy.module index c773ac628..083d8af29 100644 --- a/modules/taxonomy.module +++ b/modules/taxonomy.module @@ -979,7 +979,7 @@ function taxonomy_select_nodes($tids = array(), $operator = 'or', $depth = 0, $p $result = pager_query($sql, variable_get('default_nodes_main', 10), 0, $sql_count); } else { - $result = db_query_range($sql, 0, 15); + $result = db_query_range($sql, 0, variable_get('feed_default_items', 10)); } } diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index c773ac628..083d8af29 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -979,7 +979,7 @@ function taxonomy_select_nodes($tids = array(), $operator = 'or', $depth = 0, $p $result = pager_query($sql, variable_get('default_nodes_main', 10), 0, $sql_count); } else { - $result = db_query_range($sql, 0, 15); + $result = db_query_range($sql, 0, variable_get('feed_default_items', 10)); } } |