Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

first pruning of core modules, updated README

  • Loading branch information...
commit f1e1607e24b28748bfe0f200123dca7b394b66c1 1 parent 8821a4b
@mike503 authored
Showing with 47 additions and 29,171 deletions.
  1. +47 −2 README
  2. +0 −34 modules/aggregator/aggregator-feed-source.tpl.php
  3. +0 −45 modules/aggregator/aggregator-item.tpl.php
  4. +0 −4 modules/aggregator/aggregator-rtl.css
  5. +0 −23 modules/aggregator/aggregator-summary-item.tpl.php
  6. +0 −23 modules/aggregator/aggregator-summary-items.tpl.php
  7. +0 −18 modules/aggregator/aggregator-wrapper.tpl.php
  8. +0 −597 modules/aggregator/aggregator.admin.inc
  9. +0 −231 modules/aggregator/aggregator.api.php
  10. +0 −38 modules/aggregator/aggregator.css
  11. +0 −61 modules/aggregator/aggregator.fetcher.inc
  12. +0 −14 modules/aggregator/aggregator.info
  13. +0 −308 modules/aggregator/aggregator.install
  14. +0 −763 modules/aggregator/aggregator.module
  15. +0 −524 modules/aggregator/aggregator.pages.inc
  16. +0 −328 modules/aggregator/aggregator.parser.inc
  17. +0 −200 modules/aggregator/aggregator.processor.inc
  18. +0 −859 modules/aggregator/aggregator.test
  19. +0 −12 modules/aggregator/tests/aggregator_test.info
  20. +0 −58 modules/aggregator/tests/aggregator_test.module
  21. +0 −20 modules/aggregator/tests/aggregator_test_atom.xml
  22. +0 −30 modules/aggregator/tests/aggregator_test_rss091.xml
  23. +0 −12 modules/blog/blog.info
  24. +0 −23 modules/blog/blog.install
  25. +0 −272 modules/blog/blog.module
  26. +0 −127 modules/blog/blog.pages.inc
  27. +0 −213 modules/blog/blog.test
  28. +0 −18 modules/book/book-all-books-block.tpl.php
  29. +0 −50 modules/book/book-export-html.tpl.php
  30. +0 −51 modules/book/book-navigation.tpl.php
  31. +0 −24 modules/book/book-node-export-html.tpl.php
  32. +0 −11 modules/book/book-rtl.css
  33. +0 −264 modules/book/book.admin.inc
  34. +0 −54 modules/book/book.css
  35. +0 −14 modules/book/book.info
  36. +0 −92 modules/book/book.install
  37. +0 −22 modules/book/book.js
  38. +0 −1,315 modules/book/book.module
  39. +0 −220 modules/book/book.pages.inc
  40. +0 −284 modules/book/book.test
  41. +0 −44 modules/color/color-rtl.css
  42. +0 −81 modules/color/color.css
  43. +0 −12 modules/color/color.info
  44. +0 −57 modules/color/color.install
  45. +0 −243 modules/color/color.js
  46. +0 −740 modules/color/color.module
  47. +0 −133 modules/color/color.test
  48. BIN  modules/color/images/hook-rtl.png
  49. BIN  modules/color/images/hook.png
  50. BIN  modules/color/images/lock.png
  51. +0 −7 modules/color/preview.html
  52. +0 −34 modules/color/preview.js
  53. +0 −32 modules/comment/comment-node-form.js
  54. +0 −5 modules/comment/comment-rtl.css
  55. +0 −51 modules/comment/comment-wrapper.tpl.php
  56. +0 −283 modules/comment/comment.admin.inc
  57. +0 −145 modules/comment/comment.api.php
  58. +0 −13 modules/comment/comment.css
  59. +0 −16 modules/comment/comment.info
  60. +0 −552 modules/comment/comment.install
  61. +0 −2,697 modules/comment/comment.module
  62. +0 −119 modules/comment/comment.pages.inc
  63. +0 −1,980 modules/comment/comment.test
  64. +0 −241 modules/comment/comment.tokens.inc
  65. +0 −90 modules/comment/comment.tpl.php
  66. +0 −206 modules/contact/contact.admin.inc
  67. +0 −13 modules/contact/contact.info
  68. +0 −168 modules/contact/contact.install
  69. +0 −257 modules/contact/contact.module
  70. +0 −291 modules/contact/contact.pages.inc
  71. +0 −416 modules/contact/contact.test
  72. +0 −24 modules/forum/forum-icon.tpl.php
  73. +0 −76 modules/forum/forum-list.tpl.php
  74. +0 −16 modules/forum/forum-rtl.css
  75. +0 −28 modules/forum/forum-submitted.tpl.php
  76. +0 −68 modules/forum/forum-topic-list.tpl.php
  77. +0 −313 modules/forum/forum.admin.inc
  78. +0 −50 modules/forum/forum.css
  79. +0 −16 modules/forum/forum.info
  80. +0 −429 modules/forum/forum.install
  81. +0 −1,295 modules/forum/forum.module
  82. +0 −28 modules/forum/forum.pages.inc
  83. +0 −550 modules/forum/forum.test
  84. +0 −22 modules/forum/forums.tpl.php
  85. BIN  modules/openid/login-bg.png
  86. +0 −18 modules/openid/openid-rtl.css
  87. +0 −110 modules/openid/openid.api.php
  88. +0 −46 modules/openid/openid.css
  89. +0 −795 modules/openid/openid.inc
  90. +0 −12 modules/openid/openid.info
  91. +0 −160 modules/openid/openid.install
  92. +0 −49 modules/openid/openid.js
  93. +0 −950 modules/openid/openid.module
  94. +0 −115 modules/openid/openid.pages.inc
  95. +0 −591 modules/openid/openid.test
  96. +0 −13 modules/openid/tests/openid_test.info
  97. +0 −17 modules/openid/tests/openid_test.install
  98. +0 −317 modules/openid/tests/openid_test.module
  99. BIN  modules/overlay/images/background.png
  100. BIN  modules/overlay/images/close-rtl.png
  101. BIN  modules/overlay/images/close.png
  102. +0 −35 modules/overlay/overlay-child-rtl.css
  103. +0 −166 modules/overlay/overlay-child.css
  104. +0 −192 modules/overlay/overlay-child.js
  105. +0 −50 modules/overlay/overlay-parent.css
  106. +0 −991 modules/overlay/overlay-parent.js
  107. +0 −40 modules/overlay/overlay.api.php
  108. +0 −11 modules/overlay/overlay.info
  109. +0 −19 modules/overlay/overlay.install
  110. +0 −975 modules/overlay/overlay.module
  111. +0 −37 modules/overlay/overlay.tpl.php
  112. +0 −26 modules/poll/poll-bar--block.tpl.php
  113. +0 −26 modules/poll/poll-bar.tpl.php
  114. +0 −28 modules/poll/poll-results--block.tpl.php
  115. +0 −28 modules/poll/poll-results.tpl.php
  116. +0 −10 modules/poll/poll-rtl.css
  117. +0 −29 modules/poll/poll-vote.tpl.php
  118. +0 −51 modules/poll/poll.css
  119. +0 −13 modules/poll/poll.info
  120. +0 −206 modules/poll/poll.install
  121. +0 −1,012 modules/poll/poll.module
  122. +0 −97 modules/poll/poll.pages.inc
  123. +0 −784 modules/poll/poll.test
  124. +0 −107 modules/poll/poll.tokens.inc
  125. +0 −48 modules/shortcut/shortcut-rtl.css
  126. +0 −8 modules/shortcut/shortcut.admin.css
  127. +0 −770 modules/shortcut/shortcut.admin.inc
  128. +0 −99 modules/shortcut/shortcut.admin.js
  129. +0 −42 modules/shortcut/shortcut.api.php
  130. +0 −106 modules/shortcut/shortcut.css
  131. +0 −13 modules/shortcut/shortcut.info
  132. +0 −115 modules/shortcut/shortcut.install
  133. +0 −745 modules/shortcut/shortcut.module
  134. BIN  modules/shortcut/shortcut.png
Sorry, we could not display the entire diff because it was too big.
View
49 README
@@ -1,23 +1,55 @@
+What?
+This is a "hollow out" approach style fork of Drupal 7.8.
+
+- Many functions will be lifted up as-is, and re-examined for more streamlining.
+- Many constants will be removed.
+- Many core modules will be removed.
+- A decent amount of the core concepts in Drupal will be maintained, as they are "best of breed" I believe.
+
+Why?
+- The mix of arrays and objects is messy.
+- The introduction of more OO code, and PHP 5.3 requirements on some contrib modules is starting to fragment the supportability and consistency throughout the project.
+- I think a few things can be done cleaner, and better. Also, it's a hobby. :)
+
Things to keep, for the most part:
- hook system
-- module extensibility
- form API
- drush style management
- entity/field idea (anything and everything can be a first-class citizen, and reference each other)
+ - field, field_ui, but also node (node would be merged into generic "entity" type nomenclature)
- user and access management
+ - may get confusing if users are managed as entities instead. perhaps userid -> entity reference is all it stores
- CSS/JS aggregation/compression
+- menu router configuration
+- pathing
+ - pathauto, for sure
+- views
+- filters (input and output), text formats
+- taxonomy
+- logging
+ - watchdog/dblog can be expensive and difficult to follow
Things to improve:
- everything should use .php extension (no more webserver "blocking" having to be done)
- file API
- cron access
-- "Content Type" -> "Entity" management
+- "Content Type" management should be "Entity" management
+- Comments and Users will be managed as entities
+ - comment should be removed from core
+- multi-site; currently is too flexible, probably too much overhead
+- module code living inside of the web root; ideally, it could live outside, with menu router items established
+ - javascript/css would be applied using the drupal_add_css() style approach, and using special scheme:// file URI
+- profiles and distributions
+- update
+ - make it work as well as a drush update works
+- rename functions like check_plain() and such to be more descriptive
Things to reduce:
- decrease file i/o
- less includes
- less file scanning "magic" - heavy caching
- build-in modules - slimmer micro-kernel
+- memory usage can grow large with a Drupal install; examine various ways to decrease memory usage, and CPU spikes
Things to remove:
- all objects (especially when it is only attributes)
@@ -25,6 +57,10 @@ Things to remove:
- bad: ::
- all OO
- PDO - remove PDO, but keep the idea of generic data access
+ - generic data access may be a v2 thing. might need to get back to basics first
+- built-in "core" modules: aggregator, blog, book, color, comment, contact, forum, openid, overlay, poll, profile, shortcut, statistics, tracker, translation, trigger
+ - some of these belong in "beefier" contributed modules
+ - the "core" should be lightweight and expose only the most optimized set of APIs, hooks, and functionality to extend upon
Standards:
- no PHP 5.3 specific code
@@ -49,3 +85,12 @@ Focus on the priorities and desires:
- usability
- web services
- fix services to use CRUD properly, and not require PUT/DELETE
+
+Things to ensure are in place:
+- testing framework
+- internationalization
+ - translation
+ - localization
+- pluggable authentication
+ - authmap isn't very well documented. perhaps something better or easier to understand can be implemented
+- module extensibility
View
34 modules/aggregator/aggregator-feed-source.tpl.php
@@ -1,34 +0,0 @@
-<?php
-
-/**
- * @file
- * Default theme implementation to present the source of the feed.
- *
- * The contents are rendered above feed listings when browsing source feeds.
- * For example, "example.com/aggregator/sources/1".
- *
- * Available variables:
- * - $source_icon: Feed icon linked to the source. Rendered through
- * theme_feed_icon().
- * - $source_image: Image set by the feed source.
- * - $source_description: Description set by the feed source.
- * - $source_url: URL to the feed source.
- * - $last_checked: How long ago the feed was checked locally.
- *
- * @see template_preprocess()
- * @see template_preprocess_aggregator_feed_source()
- */
-?>
-<div class="feed-source">
- <?php print $source_icon; ?>
- <?php print $source_image; ?>
- <div class="feed-description">
- <?php print $source_description; ?>
- </div>
- <div class="feed-url">
- <em><?php print t('URL:'); ?></em> <a href="<?php print $source_url; ?>"><?php print $source_url; ?></a>
- </div>
- <div class="feed-updated">
- <em><?php print t('Updated:'); ?></em> <?php print $last_checked; ?>
- </div>
-</div>
View
45 modules/aggregator/aggregator-item.tpl.php
@@ -1,45 +0,0 @@
-<?php
-
-/**
- * @file
- * Default theme implementation to format an individual feed item for display
- * on the aggregator page.
- *
- * Available variables:
- * - $feed_url: URL to the originating feed item.
- * - $feed_title: Title of the feed item.
- * - $source_url: Link to the local source section.
- * - $source_title: Title of the remote source.
- * - $source_date: Date the feed was posted on the remote source.
- * - $content: Feed item content.
- * - $categories: Linked categories assigned to the feed.
- *
- * @see template_preprocess()
- * @see template_preprocess_aggregator_item()
- */
-?>
-<div class="feed-item">
- <h3 class="feed-item-title">
- <a href="<?php print $feed_url; ?>"><?php print $feed_title; ?></a>
- </h3>
-
- <div class="feed-item-meta">
- <?php if ($source_url) : ?>
- <a href="<?php print $source_url; ?>" class="feed-item-source"><?php print $source_title; ?></a> -
- <?php endif; ?>
- <span class="feed-item-date"><?php print $source_date; ?></span>
- </div>
-
-<?php if ($content) : ?>
- <div class="feed-item-body">
- <?php print $content; ?>
- </div>
-<?php endif; ?>
-
-<?php if ($categories) : ?>
- <div class="feed-item-categories">
- <?php print t('Categories'); ?>: <?php print implode(', ', $categories); ?>
- </div>
-<?php endif ;?>
-
-</div>
View
4 modules/aggregator/aggregator-rtl.css
@@ -1,4 +0,0 @@
-
-#aggregator .feed-source .feed-icon {
- float: left;
-}
View
23 modules/aggregator/aggregator-summary-item.tpl.php
@@ -1,23 +0,0 @@
-<?php
-
-/**
- * @file
- * Default theme implementation to present a linked feed item for summaries.
- *
- * Available variables:
- * - $feed_url: Link to originating feed.
- * - $feed_title: Title of feed.
- * - $feed_age: Age of remote feed.
- * - $source_url: Link to remote source.
- * - $source_title: Locally set title for the source.
- *
- * @see template_preprocess()
- * @see template_preprocess_aggregator_summary_item()
- */
-?>
-<a href="<?php print $feed_url; ?>"><?php print $feed_title; ?></a>
-<span class="age"><?php print $feed_age; ?></span>
-
-<?php if ($source_url) : ?>,
-<span class="source"><a href="<?php print $source_url; ?>"><?php print $source_title; ?></a></span>
-<?php endif; ?>
View
23 modules/aggregator/aggregator-summary-items.tpl.php
@@ -1,23 +0,0 @@
-<?php
-
-/**
- * @file
- * Default theme implementation to present feeds as list items.
- *
- * Each iteration generates a single feed source or category.
- *
- * Available variables:
- * - $title: Title of the feed or category.
- * - $summary_list: Unordered list of linked feed items generated through
- * theme_item_list().
- * - $source_url: URL to the local source or category.
- *
- * @see template_preprocess()
- * @see template_preprocess_aggregator_summary_items()
- */
-?>
-<h3><?php print $title; ?></h3>
-<?php print $summary_list; ?>
-<div class="links">
- <a href="<?php print $source_url; ?>"><?php print t('More'); ?></a>
-</div>
View
18 modules/aggregator/aggregator-wrapper.tpl.php
@@ -1,18 +0,0 @@
-<?php
-
-/**
- * @file
- * Default theme implementation to wrap aggregator content.
- *
- * Available variables:
- * - $content: All aggregator content.
- * - $page: Pager links rendered through theme_pager().
- *
- * @see template_preprocess()
- * @see template_preprocess_aggregator_wrapper()
- */
-?>
-<div id="aggregator">
- <?php print $content; ?>
- <?php print $pager; ?>
-</div>
View
597 modules/aggregator/aggregator.admin.inc
@@ -1,597 +0,0 @@
-<?php
-
-/**
- * @file
- * Admin page callbacks for the aggregator module.
- */
-
-/**
- * Menu callback; displays the aggregator administration page.
- */
-function aggregator_admin_overview() {
- return aggregator_view();
-}
-
-/**
- * Displays the aggregator administration page.
- *
- * @return
- * The page HTML.
- */
-function aggregator_view() {
- $result = db_query('SELECT f.fid, f.title, f.url, f.refresh, f.checked, f.link, f.description, f.hash, f.etag, f.modified, f.image, f.block, 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.hash, f.etag, f.modified, f.image, f.block ORDER BY f.title');
-
- $output = '<h3>' . t('Feed overview') . '</h3>';
-
- $header = array(t('Title'), t('Items'), t('Last update'), t('Next update'), array('data' => t('Operations'), 'colspan' => '3'));
- $rows = array();
- foreach ($result as $feed) {
- $rows[] = array(
- l($feed->title, "aggregator/sources/$feed->fid"),
- format_plural($feed->items, '1 item', '@count items'),
- ($feed->checked ? t('@time ago', array('@time' => format_interval(REQUEST_TIME - $feed->checked))) : t('never')),
- ($feed->checked && $feed->refresh ? t('%time left', array('%time' => format_interval($feed->checked + $feed->refresh - REQUEST_TIME))) : t('never')),
- l(t('edit'), "admin/config/services/aggregator/edit/feed/$feed->fid"),
- l(t('remove items'), "admin/config/services/aggregator/remove/$feed->fid"),
- l(t('update items'), "admin/config/services/aggregator/update/$feed->fid"),
- );
- }
- $output .= theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No feeds available. <a href="@link">Add feed</a>.', array('@link' => url('admin/config/services/aggregator/add/feed')))));
-
- $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');
-
- $output .= '<h3>' . t('Category overview') . '</h3>';
-
- $header = array(t('Title'), t('Items'), t('Operations'));
- $rows = array();
- foreach ($result as $category) {
- $rows[] = array(l($category->title, "aggregator/categories/$category->cid"), format_plural($category->items, '1 item', '@count items'), l(t('edit'), "admin/config/services/aggregator/edit/category/$category->cid"));
- }
- $output .= theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No categories available. <a href="@link">Add category</a>.', array('@link' => url('admin/config/services/aggregator/add/category')))));
-
- return $output;
-}
-
-/**
- * Form builder; Generate a form to add/edit feed sources.
- *
- * @ingroup forms
- * @see aggregator_form_feed_validate()
- * @see aggregator_form_feed_submit()
- */
-function aggregator_form_feed($form, &$form_state, stdClass $feed = NULL) {
- $period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
- $period[AGGREGATOR_CLEAR_NEVER] = t('Never');
-
- $form['title'] = array('#type' => 'textfield',
- '#title' => t('Title'),
- '#default_value' => isset($feed->title) ? $feed->title : '',
- '#maxlength' => 255,
- '#description' => t('The name of the feed (or the name of the website providing the feed).'),
- '#required' => TRUE,
- );
- $form['url'] = array('#type' => 'textfield',
- '#title' => t('URL'),
- '#default_value' => isset($feed->url) ? $feed->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' => isset($feed->refresh) ? $feed->refresh : 3600,
- '#options' => $period,
- '#description' => t('The length of time between feed updates. Requires a correctly configured <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status'))),
- );
- $form['block'] = array('#type' => 'select',
- '#title' => t('News items in block'),
- '#default_value' => isset($feed->block) ? $feed->block : 5,
- '#options' => drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)),
- '#description' => t("Drupal can make a block with the most recent news items of this feed. You can <a href=\"@block-admin\">configure blocks</a> to be displayed in the sidebar of your page. This setting lets you configure the number of news items to show in this feed's block. If you choose '0' this feed's block will be disabled.", array('@block-admin' => url('admin/structure/block'))),
- );
-
- // 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 = :fid ORDER BY title', array(':fid' => isset($feed->fid) ? $feed->fid : NULL));
- foreach ($categories as $category) {
- $options[$category->cid] = check_plain($category->title);
- if ($category->fid) $values[] = $category->cid;
- }
-
- if ($options) {
- $form['category'] = array(
- '#type' => 'checkboxes',
- '#title' => t('Categorize news items'),
- '#default_value' => $values,
- '#options' => $options,
- '#description' => t('New feed items are automatically filed in the checked categories.'),
- );
- }
-
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Save'),
- );
- if (!empty($feed->fid)) {
- $form['actions']['delete'] = array(
- '#type' => 'submit',
- '#value' => t('Delete'),
- );
- $form['fid'] = array(
- '#type' => 'hidden',
- '#value' => $feed->fid,
- );
- }
-
- return $form;
-}
-
-/**
- * Validate aggregator_form_feed() form submissions.
- */
-function aggregator_form_feed_validate($form, &$form_state) {
- if ($form_state['values']['op'] == t('Save')) {
- // Ensure URL is valid.
- if (!valid_url($form_state['values']['url'], TRUE)) {
- form_set_error('url', t('The URL %url is invalid. 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 = :title OR url = :url) AND fid <> :fid", array(':title' => $form_state['values']['title'], ':url' => $form_state['values']['url'], ':fid' => $form_state['values']['fid']));
- }
- else {
- $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE title = :title OR url = :url", array(':title' => $form_state['values']['title'], ':url' => $form_state['values']['url']));
- }
- foreach ($result as $feed) {
- if (strcasecmp($feed->title, $form_state['values']['title']) == 0) {
- form_set_error('title', t('A feed named %feed already exists. Enter a unique title.', array('%feed' => $form_state['values']['title'])));
- }
- if (strcasecmp($feed->url, $form_state['values']['url']) == 0) {
- form_set_error('url', t('A feed with this URL %url already exists. Enter a unique URL.', array('%url' => $form_state['values']['url'])));
- }
- }
- }
-}
-
-/**
- * Process aggregator_form_feed() form submissions.
- *
- * @todo Add delete confirmation dialog.
- */
-function aggregator_form_feed_submit($form, &$form_state) {
- if ($form_state['values']['op'] == t('Delete')) {
- $title = $form_state['values']['title'];
- // Unset the title.
- unset($form_state['values']['title']);
- }
- aggregator_save_feed($form_state['values']);
- if (isset($form_state['values']['fid'])) {
- if (isset($form_state['values']['title'])) {
- drupal_set_message(t('The feed %feed has been updated.', array('%feed' => $form_state['values']['title'])));
- if (arg(0) == 'admin') {
- $form_state['redirect'] = 'admin/config/services/aggregator/';
- return;
- }
- else {
- $form_state['redirect'] = 'aggregator/sources/' . $form_state['values']['fid'];
- return;
- }
- }
- else {
- watchdog('aggregator', 'Feed %feed deleted.', array('%feed' => $title));
- drupal_set_message(t('The feed %feed has been deleted.', array('%feed' => $title)));
- if (arg(0) == 'admin') {
- $form_state['redirect'] = 'admin/config/services/aggregator/';
- return;
- }
- else {
- $form_state['redirect'] = 'aggregator/sources/';
- return;
- }
- }
- }
- else {
- watchdog('aggregator', 'Feed %feed added.', array('%feed' => $form_state['values']['title']), WATCHDOG_NOTICE, l(t('view'), 'admin/config/services/aggregator'));
- drupal_set_message(t('The feed %feed has been added.', array('%feed' => $form_state['values']['title'])));
- }
-}
-
-function aggregator_admin_remove_feed($form, $form_state, $feed) {
- return confirm_form(
- array(
- 'feed' => array(
- '#type' => 'value',
- '#value' => $feed,
- ),
- ),
- t('Are you sure you want to remove all items from the feed %feed?', array('%feed' => $feed->title)),
- 'admin/config/services/aggregator',
- t('This action cannot be undone.'),
- t('Remove items'),
- t('Cancel')
- );
-}
-
-/**
- * Remove all items from a feed and redirect to the overview page.
- *
- * @param $feed
- * An associative array describing the feed to be cleared.
- */
-function aggregator_admin_remove_feed_submit($form, &$form_state) {
- aggregator_remove($form_state['values']['feed']);
- $form_state['redirect'] = 'admin/config/services/aggregator';
-}
-
-/**
- * Form builder; Generate a form to import feeds from OPML.
- *
- * @ingroup forms
- * @see aggregator_form_opml_validate()
- * @see aggregator_form_opml_submit()
- */
-function aggregator_form_opml($form, &$form_state) {
- $period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
-
- $form['upload'] = array(
- '#type' => 'file',
- '#title' => t('OPML File'),
- '#description' => t('Upload an OPML file containing a list of feeds to be imported.'),
- );
- $form['remote'] = array(
- '#type' => 'textfield',
- '#title' => t('OPML Remote URL'),
- '#maxlength' => 1024,
- '#description' => t('Enter the URL of an OPML file. This file will be downloaded and processed only once on submission of the form.'),
- );
- $form['refresh'] = array(
- '#type' => 'select',
- '#title' => t('Update interval'),
- '#default_value' => 3600,
- '#options' => $period,
- '#description' => t('The length of time between feed updates. Requires a correctly configured <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status'))),
- );
- $form['block'] = array('#type' => 'select',
- '#title' => t('News items in block'),
- '#default_value' => 5,
- '#options' => drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)),
- '#description' => t("Drupal can make a block with the most recent news items of a feed. You can <a href=\"@block-admin\">configure blocks</a> to be displayed in the sidebar of your page. This setting lets you configure the number of news items to show in a feed's block. If you choose '0' these feeds' blocks will be disabled.", array('@block-admin' => url('admin/structure/block'))),
- );
-
- // Handling of categories.
- $options = array_map('check_plain', db_query("SELECT cid, title FROM {aggregator_category} ORDER BY title")->fetchAllKeyed());
- if ($options) {
- $form['category'] = array(
- '#type' => 'checkboxes',
- '#title' => t('Categorize news items'),
- '#options' => $options,
- '#description' => t('New feed items are automatically filed in the checked categories.'),
- );
- }
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Import')
- );
-
- return $form;
-}
-
-/**
- * Validate aggregator_form_opml form submissions.
- */
-function aggregator_form_opml_validate($form, &$form_state) {
- // If both fields are empty or filled, cancel.
- if (empty($form_state['values']['remote']) == empty($_FILES['files']['name']['upload'])) {
- form_set_error('remote', t('You must <em>either</em> upload a file or enter a URL.'));
- }
-
- // Validate the URL, if one was entered.
- if (!empty($form_state['values']['remote']) && !valid_url($form_state['values']['remote'], TRUE)) {
- form_set_error('remote', t('This URL is not valid.'));
- }
-}
-
-/**
- * Process aggregator_form_opml form submissions.
- */
-function aggregator_form_opml_submit($form, &$form_state) {
- $data = '';
- $validators = array('file_validate_extensions' => array('opml xml'));
- if ($file = file_save_upload('upload', $validators)) {
- $data = file_get_contents($file->uri);
- }
- else {
- $response = drupal_http_request($form_state['values']['remote']);
- if (!isset($response->error)) {
- $data = $response->data;
- }
- }
-
- $feeds = _aggregator_parse_opml($data);
- if (empty($feeds)) {
- drupal_set_message(t('No new feed has been added.'));
- return;
- }
-
- $form_state['values']['op'] = t('Save');
-
- foreach ($feeds as $feed) {
- // Ensure URL is valid.
- if (!valid_url($feed['url'], TRUE)) {
- drupal_set_message(t('The URL %url is invalid.', array('%url' => $feed['url'])), 'warning');
- continue;
- }
-
- // Check for duplicate titles or URLs.
- $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE title = :title OR url = :url", array(':title' => $feed['title'], ':url' => $feed['url']));
- foreach ($result as $old) {
- if (strcasecmp($old->title, $feed['title']) == 0) {
- drupal_set_message(t('A feed named %title already exists.', array('%title' => $old->title)), 'warning');
- continue 2;
- }
- if (strcasecmp($old->url, $feed['url']) == 0) {
- drupal_set_message(t('A feed with the URL %url already exists.', array('%url' => $old->url)), 'warning');
- continue 2;
- }
- }
-
- $form_state['values']['title'] = $feed['title'];
- $form_state['values']['url'] = $feed['url'];
- drupal_form_submit('aggregator_form_feed', $form_state);
- }
-
- $form_state['redirect'] = 'admin/config/services/aggregator';
-}
-
-/**
- * Parse an OPML file.
- *
- * Feeds are recognized as <outline> elements with the attributes "text" and
- * "xmlurl" set.
- *
- * @param $opml
- * The complete contents of an OPML document.
- *
- * @return
- * An array of feeds, each an associative array with a "title" and a "url"
- * element, or NULL if the OPML document failed to be parsed. An empty
- * array will be returned if the document is valid but contains no feeds, as
- * some OPML documents do.
- */
-function _aggregator_parse_opml($opml) {
- $feeds = array();
- $xml_parser = drupal_xml_parser_create($opml);
- if (xml_parse_into_struct($xml_parser, $opml, $values)) {
- foreach ($values as $entry) {
- if ($entry['tag'] == 'OUTLINE' && isset($entry['attributes'])) {
- $item = $entry['attributes'];
- if (!empty($item['XMLURL']) && !empty($item['TEXT'])) {
- $feeds[] = array('title' => $item['TEXT'], 'url' => $item['XMLURL']);
- }
- }
- }
- }
- xml_parser_free($xml_parser);
-
- return $feeds;
-}
-
-/**
- * Menu callback; refreshes a feed, then redirects to the overview page.
- *
- * @param $feed
- * An object describing the feed to be refreshed.
- */
-function aggregator_admin_refresh_feed($feed) {
- aggregator_refresh($feed);
- drupal_goto('admin/config/services/aggregator');
-}
-
-/**
- * Form builder; Configure the aggregator system.
- *
- * @ingroup forms
- */
-function aggregator_admin_form($form, $form_state) {
- // Global aggregator settings.
- $form['aggregator_allowed_html_tags'] = array(
- '#type' => 'textfield',
- '#title' => t('Allowed HTML tags'),
- '#size' => 80,
- '#maxlength' => 255,
- '#default_value' => variable_get('aggregator_allowed_html_tags', '<a> <b> <br> <dd> <dl> <dt> <em> <i> <li> <ol> <p> <strong> <u> <ul>'),
- '#description' => t('A space-separated list of HTML tags allowed in the content of feed items. Disallowed tags are stripped from the content.'),
- );
-
- // Make sure configuration is sane.
- aggregator_sanitize_configuration();
-
- // Get all available fetchers.
- $fetchers = module_implements('aggregator_fetch');
- foreach ($fetchers as $k => $module) {
- if ($info = module_invoke($module, 'aggregator_fetch_info')) {
- $label = $info['title'] . ' <span class="description">' . $info['description'] . '</span>';
- }
- else {
- $label = $module;
- }
- unset($fetchers[$k]);
- $fetchers[$module] = $label;
- }
-
- // Get all available parsers.
- $parsers = module_implements('aggregator_parse');
- foreach ($parsers as $k => $module) {
- if ($info = module_invoke($module, 'aggregator_parse_info')) {
- $label = $info['title'] . ' <span class="description">' . $info['description'] . '</span>';
- }
- else {
- $label = $module;
- }
- unset($parsers[$k]);
- $parsers[$module] = $label;
- }
-
- // Get all available processors.
- $processors = module_implements('aggregator_process');
- foreach ($processors as $k => $module) {
- if ($info = module_invoke($module, 'aggregator_process_info')) {
- $label = $info['title'] . ' <span class="description">' . $info['description'] . '</span>';
- }
- else {
- $label = $module;
- }
- unset($processors[$k]);
- $processors[$module] = $label;
- }
-
- // Only show basic configuration if there are actually options.
- $basic_conf = array();
- if (count($fetchers) > 1) {
- $basic_conf['aggregator_fetcher'] = array(
- '#type' => 'radios',
- '#title' => t('Fetcher'),
- '#description' => t('Fetchers download data from an external source. Choose a fetcher suitable for the external source you would like to download from.'),
- '#options' => $fetchers,
- '#default_value' => variable_get('aggregator_fetcher', 'aggregator'),
- );
- }
- if (count($parsers) > 1) {
- $basic_conf['aggregator_parser'] = array(
- '#type' => 'radios',
- '#title' => t('Parser'),
- '#description' => t('Parsers transform downloaded data into standard structures. Choose a parser suitable for the type of feeds you would like to aggregate.'),
- '#options' => $parsers,
- '#default_value' => variable_get('aggregator_parser', 'aggregator'),
- );
- }
- if (count($processors) > 1) {
- $basic_conf['aggregator_processors'] = array(
- '#type' => 'checkboxes',
- '#title' => t('Processors'),
- '#description' => t('Processors act on parsed feed data, for example they store feed items. Choose the processors suitable for your task.'),
- '#options' => $processors,
- '#default_value' => variable_get('aggregator_processors', array('aggregator')),
- );
- }
- if (count($basic_conf)) {
- $form['basic_conf'] = array(
- '#type' => 'fieldset',
- '#title' => t('Basic configuration'),
- '#description' => t('For most aggregation tasks, the default settings are fine.'),
- '#collapsible' => TRUE,
- '#collapsed' => FALSE,
- );
- $form['basic_conf'] += $basic_conf;
- }
-
- // Implementing modules will expect an array at $form['modules'].
- $form['modules'] = array();
-
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Save configuration'),
- );
-
- return $form;
-}
-
-function aggregator_admin_form_submit($form, &$form_state) {
- if (isset($form_state['values']['aggregator_processors'])) {
- $form_state['values']['aggregator_processors'] = array_filter($form_state['values']['aggregator_processors']);
- }
- system_settings_form_submit($form, $form_state);
-}
-
-/**
- * Form builder; Generate a form to add/edit/delete aggregator categories.
- *
- * @ingroup forms
- * @see aggregator_form_category_validate()
- * @see aggregator_form_category_submit()
- */
-function aggregator_form_category($form, &$form_state, $edit = array('title' => '', 'description' => '', 'cid' => NULL)) {
- $form['title'] = array('#type' => 'textfield',
- '#title' => t('Title'),
- '#default_value' => $edit['title'],
- '#maxlength' => 64,
- '#required' => TRUE,
- );
- $form['description'] = array('#type' => 'textarea',
- '#title' => t('Description'),
- '#default_value' => $edit['description'],
- );
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
- if ($edit['cid']) {
- $form['actions']['delete'] = array('#type' => 'submit', '#value' => t('Delete'));
- $form['cid'] = array('#type' => 'hidden', '#value' => $edit['cid']);
- }
-
- return $form;
-}
-
-/**
- * Validate aggregator_form_feed form submissions.
- */
-function aggregator_form_category_validate($form, &$form_state) {
- if ($form_state['values']['op'] == t('Save')) {
- // Check for duplicate titles
- if (isset($form_state['values']['cid'])) {
- $category = db_query("SELECT cid FROM {aggregator_category} WHERE title = :title AND cid <> :cid", array(':title' => $form_state['values']['title'], ':cid' => $form_state['values']['cid']))->fetchObject();
- }
- else {
- $category = db_query("SELECT cid FROM {aggregator_category} WHERE title = :title", array(':title' => $form_state['values']['title']))->fetchObject();
- }
- if ($category) {
- form_set_error('title', t('A category named %category already exists. Enter a unique title.', array('%category' => $form_state['values']['title'])));
- }
- }
-}
-
-/**
- * Process aggregator_form_category form submissions.
- *
- * @todo Add delete confirmation dialog.
- */
-function aggregator_form_category_submit($form, &$form_state) {
- if ($form_state['values']['op'] == t('Delete')) {
- $title = $form_state['values']['title'];
- // Unset the title.
- unset($form_state['values']['title']);
- }
- aggregator_save_category($form_state['values']);
- if (isset($form_state['values']['cid'])) {
- if (isset($form_state['values']['title'])) {
- drupal_set_message(t('The category %category has been updated.', array('%category' => $form_state['values']['title'])));
- if (arg(0) == 'admin') {
- $form_state['redirect'] = 'admin/config/services/aggregator/';
- return;
- }
- else {
- $form_state['redirect'] = 'aggregator/categories/' . $form_state['values']['cid'];
- return;
- }
- }
- else {
- watchdog('aggregator', 'Category %category deleted.', array('%category' => $title));
- drupal_set_message(t('The category %category has been deleted.', array('%category' => $title)));
- if (arg(0) == 'admin') {
- $form_state['redirect'] = 'admin/config/services/aggregator/';
- return;
- }
- else {
- $form_state['redirect'] = 'aggregator/categories/';
- return;
- }
- }
- }
- else {
- watchdog('aggregator', 'Category %category added.', array('%category' => $form_state['values']['title']), WATCHDOG_NOTICE, l(t('view'), 'admin/config/services/aggregator'));
- drupal_set_message(t('The category %category has been added.', array('%category' => $form_state['values']['title'])));
- }
-}
View
231 modules/aggregator/aggregator.api.php
@@ -1,231 +0,0 @@
-<?php
-
-/**
- * @file
- * Documentation for aggregator API.
- */
-
-/**
- * @addtogroup hooks
- * @{
- */
-
-/**
- * Implement this hook to create an alternative fetcher for aggregator module.
- *
- * A fetcher downloads feed data to a Drupal site. The fetcher is called
- * at the first of the three aggregation stages: data is downloaded by the
- * active fetcher, it is converted to a common format by the active parser and
- * finally, it is passed to all active processors which manipulate or store the
- * data.
- *
- * Modules that define this hook can be set as active fetcher on
- * admin/config/services/aggregator. Only one fetcher can be active at a time.
- *
- * @param $feed
- * The $feed object that describes the resource to be downloaded.
- * $feed->url contains the link to the feed. Download the data at the URL
- * and expose it to other modules by attaching it to $feed->source_string.
- *
- * @return
- * TRUE if fetching was successful, FALSE otherwise.
- *
- * @see hook_aggregator_fetch_info()
- * @see hook_aggregator_parse()
- * @see hook_aggregator_process()
- *
- * @ingroup aggregator
- */
-function hook_aggregator_fetch($feed) {
- $feed->source_string = mymodule_fetch($feed->url);
-}
-
-/**
- * Implement this hook to expose the title and a short description of your
- * fetcher.
- *
- * The title and the description provided are shown on
- * admin/config/services/aggregator among other places. Use as title the human
- * readable name of the fetcher and as description a brief (40 to 80 characters)
- * explanation of the fetcher's functionality.
- *
- * This hook is only called if your module implements hook_aggregator_fetch().
- * If this hook is not implemented aggregator will use your module's file name
- * as title and there will be no description.
- *
- * @return
- * An associative array defining a title and a description string.
- *
- * @see hook_aggregator_fetch()
- *
- * @ingroup aggregator
- */
-function hook_aggregator_fetch_info() {
- return array(
- 'title' => t('Default fetcher'),
- 'description' => t('Default fetcher for resources available by URL.'),
- );
-}
-
-/**
- * Implement this hook to create an alternative parser for aggregator module.
- *
- * A parser converts feed item data to a common format. The parser is called
- * at the second of the three aggregation stages: data is downloaded by the
- * active fetcher, it is converted to a common format by the active parser and
- * finally, it is passed to all active processors which manipulate or store the
- * data.
- *
- * Modules that define this hook can be set as active parser on
- * admin/config/services/aggregator. Only one parser can be active at a time.
- *
- * @param $feed
- * The $feed object that describes the resource to be parsed.
- * $feed->source_string contains the raw feed data as a string. Parse data
- * from $feed->source_string and expose it to other modules as an array of
- * data items on $feed->items.
- *
- * Feed format:
- * - $feed->description (string) - description of the feed
- * - $feed->image (string) - image for the feed
- * - $feed->etag (string) - value of feed's entity tag header field
- * - $feed->modified (UNIX timestamp) - value of feed's last modified header
- * field
- * - $feed->items (Array) - array of feed items.
- *
- * By convention, the common format for a single feed item is:
- * $item[key-name] = value;
- *
- * Recognized keys:
- * TITLE (string) - the title of a feed item
- * DESCRIPTION (string) - the description (body text) of a feed item
- * TIMESTAMP (UNIX timestamp) - the feed item's published time as UNIX timestamp
- * AUTHOR (string) - the feed item's author
- * GUID (string) - RSS/Atom global unique identifier
- * LINK (string) - the feed item's URL
- *
- * @return
- * TRUE if parsing was successful, FALSE otherwise.
- *
- * @see hook_aggregator_parse_info()
- * @see hook_aggregator_fetch()
- * @see hook_aggregator_process()
- *
- * @ingroup aggregator
- */
-function hook_aggregator_parse($feed) {
- if ($items = mymodule_parse($feed->source_string)) {
- $feed->items = $items;
- return TRUE;
- }
- return FALSE;
-}
-
-/**
- * Implement this hook to expose the title and a short description of your
- * parser.
- *
- * The title and the description provided are shown on
- * admin/config/services/aggregator among other places. Use as title the human
- * readable name of the parser and as description a brief (40 to 80 characters)
- * explanation of the parser's functionality.
- *
- * This hook is only called if your module implements hook_aggregator_parse().
- * If this hook is not implemented aggregator will use your module's file name
- * as title and there will be no description.
- *
- * @return
- * An associative array defining a title and a description string.
- *
- * @see hook_aggregator_parse()
- *
- * @ingroup aggregator
- */
-function hook_aggregator_parse_info() {
- return array(
- 'title' => t('Default parser'),
- 'description' => t('Default parser for RSS, Atom and RDF feeds.'),
- );
-}
-
-/**
- * Implement this hook to create a processor for aggregator module.
- *
- * A processor acts on parsed feed data. Active processors are called at the
- * third and last of the aggregation stages: data is downloaded by the active
- * fetcher, it is converted to a common format by the active parser and
- * finally, it is passed to all active processors which manipulate or store the
- * data.
- *
- * Modules that define this hook can be activated as processor on
- * admin/config/services/aggregator.
- *
- * @param $feed
- * The $feed object that describes the resource to be processed. $feed->items
- * contains an array of feed items downloaded and parsed at the parsing
- * stage. See hook_aggregator_parse() for the basic format of a single item
- * in the $feed->items array. For the exact format refer to the particular
- * parser in use.
- *
- * @see hook_aggregator_process_info()
- * @see hook_aggregator_fetch()
- * @see hook_aggregator_parse()
- *
- * @ingroup aggregator
- */
-function hook_aggregator_process($feed) {
- foreach ($feed->items as $item) {
- mymodule_save($item);
- }
-}
-
-/**
- * Implement this hook to expose the title and a short description of your
- * processor.
- *
- * The title and the description provided are shown most importantly on
- * admin/config/services/aggregator. Use as title the natural name of the
- * processor and as description a brief (40 to 80 characters) explanation of
- * the functionality.
- *
- * This hook is only called if your module implements
- * hook_aggregator_process(). If this hook is not implemented aggregator
- * will use your module's file name as title and there will be no description.
- *
- * @return
- * An associative array defining a title and a description string.
- *
- * @see hook_aggregator_process()
- *
- * @ingroup aggregator
- */
-function hook_aggregator_process_info($feed) {
- return array(
- 'title' => t('Default processor'),
- 'description' => t('Creates lightweight records of feed items.'),
- );
-}
-
-/**
- * Implement this hook to remove stored data if a feed is being deleted or a
- * feed's items are being removed.
- *
- * Aggregator calls this hook if either a feed is deleted or a user clicks on
- * "remove items".
- *
- * If your module stores feed items for example on hook_aggregator_process() it
- * is recommended to implement this hook and to remove data related to $feed
- * when called.
- *
- * @param $feed
- * The $feed object whose items are being removed.
- *
- * @ingroup aggregator
- */
-function hook_aggregator_remove($feed) {
- mymodule_remove_items($feed->fid);
-}
-
-/**
- * @} End of "addtogroup hooks".
- */
View
38 modules/aggregator/aggregator.css
@@ -1,38 +0,0 @@
-
-#aggregator .feed-source .feed-title {
- margin-top: 0;
-}
-#aggregator .feed-source .feed-image img {
- margin-bottom: 0.75em;
-}
-#aggregator .feed-source .feed-icon {
- float: right; /* LTR */
- display: block;
-}
-#aggregator .feed-item {
- margin-bottom: 1.5em;
-}
-#aggregator .feed-item-title {
- margin-bottom: 0;
- font-size: 1.3em;
-}
-#aggregator .feed-item-meta,
-#aggregator .feed-item-body {
- margin-bottom: 0.5em;
-}
-#aggregator .feed-item-categories {
- font-size: 0.9em;
-}
-#aggregator td {
- vertical-align: bottom;
-}
-#aggregator td.categorize-item {
- white-space: nowrap;
-}
-#aggregator .categorize-item .news-item .body {
- margin-top: 0;
-}
-#aggregator .categorize-item h3 {
- margin-bottom: 1em;
- margin-top: 0;
-}
View
61 modules/aggregator/aggregator.fetcher.inc
@@ -1,61 +0,0 @@
-<?php
-
-/**
- * @file
- * Fetcher functions for the aggregator module.
- */
-
-/**
- * Implements hook_aggregator_fetch_info().
- */
-function aggregator_aggregator_fetch_info() {
- return array(
- 'title' => t('Default fetcher'),
- 'description' => t('Downloads data from a URL using Drupal\'s HTTP request handler.'),
- );
-}
-
-/**
- * Implements hook_aggregator_fetch().
- */
-function aggregator_aggregator_fetch($feed) {
- $feed->source_string = FALSE;
-
- // Generate conditional GET headers.
- $headers = array();
- if ($feed->etag) {
- $headers['If-None-Match'] = $feed->etag;
- }
- if ($feed->modified) {
- $headers['If-Modified-Since'] = gmdate(DATE_RFC1123, $feed->modified);
- }
-
- // Request feed.
- $result = drupal_http_request($feed->url, array('headers' => $headers));
-
- // Process HTTP response code.
- switch ($result->code) {
- case 304:
- break;
- case 301:
- $feed->url = $result->redirect_url;
- // Do not break here.
- case 200:
- case 302:
- case 307:
- if (!isset($result->data)) {
- $result->data = '';
- }
- if (!isset($result->headers)) {
- $result->headers = array();
- }
- $feed->source_string = $result->data;
- $feed->http_headers = $result->headers;
- break;
- default:
- watchdog('aggregator', 'The feed from %site seems to be broken, due to "%error".', array('%site' => $feed->title, '%error' => $result->code . ' ' . $result->error), WATCHDOG_WARNING);
- drupal_set_message(t('The feed from %site seems to be broken, because of error "%error".', array('%site' => $feed->title, '%error' => $result->code . ' ' . $result->error)));
- }
-
- return $feed->source_string === FALSE ? FALSE : TRUE;
-}
View
14 modules/aggregator/aggregator.info
@@ -1,14 +0,0 @@
-name = Aggregator
-description = "Aggregates syndicated content (RSS, RDF, and Atom feeds)."
-package = Core
-version = VERSION
-core = 7.x
-files[] = aggregator.test
-configure = admin/config/services/aggregator/settings
-stylesheets[all][] = aggregator.css
-
-; Information added by drupal.org packaging script on 2011-08-31
-version = "7.8"
-project = "drupal"
-datestamp = "1314817616"
-
View
308 modules/aggregator/aggregator.install
@@ -1,308 +0,0 @@
-<?php
-
-/**
- * @file
- * Install, update and uninstall functions for the aggregator module.
- */
-
-/**
- * Implements hook_uninstall().
- */
-function aggregator_uninstall() {
- variable_del('aggregator_allowed_html_tags');
- variable_del('aggregator_summary_items');
- variable_del('aggregator_clear');
- variable_del('aggregator_category_selector');
- variable_del('aggregator_fetcher');
- variable_del('aggregator_parser');
- variable_del('aggregator_processors');
- variable_del('aggregator_teaser_length');
-}
-
-/**
- * Implements hook_schema().
- */
-function aggregator_schema() {
- $schema['aggregator_category'] = array(
- 'description' => 'Stores categories for aggregator feeds and feed items.',
- 'fields' => array(
- 'cid' => array(
- 'type' => 'serial',
- 'not null' => TRUE,
- 'description' => 'Primary Key: Unique aggregator category ID.',
- ),
- 'title' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Title of the category.',
- ),
- 'description' => array(
- 'type' => 'text',
- 'not null' => TRUE,
- 'size' => 'big',
- 'description' => 'Description of the category',
- ),
- 'block' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'size' => 'tiny',
- 'description' => 'The number of recent items to show within the category block.',
- )
- ),
- 'primary key' => array('cid'),
- 'unique keys' => array(
- 'title' => array('title'),
- ),
- );
-
- $schema['aggregator_category_feed'] = array(
- 'description' => 'Bridge table; maps feeds to categories.',
- 'fields' => array(
- 'fid' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => "The feed's {aggregator_feed}.fid.",
- ),
- 'cid' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'The {aggregator_category}.cid to which the feed is being assigned.',
- )
- ),
- 'primary key' => array('cid', 'fid'),
- 'indexes' => array(
- 'fid' => array('fid'),
- ),
- 'foreign keys' => array(
- 'aggregator_category' => array(
- 'table' => 'aggregator_category',
- 'columns' => array('cid' => 'cid'),
- ),
- ),
- );
-
- $schema['aggregator_category_item'] = array(
- 'description' => 'Bridge table; maps feed items to categories.',
- 'fields' => array(
- 'iid' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => "The feed item's {aggregator_item}.iid.",
- ),
- 'cid' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'The {aggregator_category}.cid to which the feed item is being assigned.',
- )
- ),
- 'primary key' => array('cid', 'iid'),
- 'indexes' => array(
- 'iid' => array('iid'),
- ),
- 'foreign keys' => array(
- 'aggregator_category' => array(
- 'table' => 'aggregator_category',
- 'columns' => array('cid' => 'cid'),
- ),
- ),
- );
-
- $schema['aggregator_feed'] = array(
- 'description' => 'Stores feeds to be parsed by the aggregator.',
- 'fields' => array(
- 'fid' => array(
- 'type' => 'serial',
- 'not null' => TRUE,
- 'description' => 'Primary Key: Unique feed ID.',
- ),
- 'title' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Title of the feed.',
- ),
- 'url' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'URL to the feed.',
- ),
- 'refresh' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'How often to check for new feed items, in seconds.',
- ),
- 'checked' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'Last time feed was checked for new items, as Unix timestamp.',
- ),
- 'queued' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'Time when this feed was queued for refresh, 0 if not queued.',
- ),
- 'link' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'The parent website of the feed; comes from the <link> element in the feed.',
- ),
- 'description' => array(
- 'type' => 'text',
- 'not null' => TRUE,
- 'size' => 'big',
- 'description' => "The parent website's description; comes from the <description> element in the feed.",
- ),
- 'image' => array(
- 'type' => 'text',
- 'not null' => TRUE,
- 'size' => 'big',
- 'description' => 'An image representing the feed.',
- ),
- 'hash' => array(
- 'type' => 'varchar',
- 'length' => 64,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Calculated hash of the feed data, used for validating cache.',
- ),
- 'etag' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Entity tag HTTP response header, used for validating cache.',
- ),
- 'modified' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'When the feed was last modified, as a Unix timestamp.',
- ),
- 'block' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'size' => 'tiny',
- 'description' => "Number of items to display in the feed's block.",
- )
- ),
- 'primary key' => array('fid'),
- 'unique keys' => array(
- 'url' => array('url'),
- 'title' => array('title'),
- ),
- 'indexes' => array(
- 'queued' => array('queued'),
- ),
- );
-
- $schema['aggregator_item'] = array(
- 'description' => 'Stores the individual items imported from feeds.',
- 'fields' => array(
- 'iid' => array(
- 'type' => 'serial',
- 'not null' => TRUE,
- 'description' => 'Primary Key: Unique ID for feed item.',
- ),
- 'fid' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'The {aggregator_feed}.fid to which this item belongs.',
- ),
- 'title' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Title of the feed item.',
- ),
- 'link' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Link to the feed item.',
- ),
- 'author' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE,
- 'default' => '',
- 'description' => 'Author of the feed item.',
- ),
- 'description' => array(
- 'type' => 'text',
- 'not null' => TRUE,
- 'size' => 'big',
- 'description' => 'Body of the feed item.',
- ),
- 'timestamp' => array(
- 'type' => 'int',
- 'not null' => FALSE,
- 'description' => 'Posted date of the feed item, as a Unix timestamp.',
- ),
- 'guid' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => FALSE,
- 'description' => 'Unique identifier for the feed item.',
- )
- ),
- 'primary key' => array('iid'),
- 'indexes' => array(
- 'fid' => array('fid'),
- ),
- 'foreign keys' => array(
- 'aggregator_feed' => array(
- 'table' => 'aggregator_feed',
- 'columns' => array('fid' => 'fid'),
- ),
- ),
- );
-
- return $schema;
-}
-
-/**
- * Add hash column to aggregator_feed table.
- */
-function aggregator_update_7000() {
- db_add_field('aggregator_feed', 'hash', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''));
-}
-
-/**
- * Add aggregator teaser length to settings from old global default teaser length
- */
-function aggregator_update_7001() {
- variable_set('aggregator_teaser_length', variable_get('teaser_length'));
-}
-
-/**
- * Add queued timestamp.
- */
-function aggregator_update_7002() {
- db_add_field('aggregator_feed', 'queued', array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'Time when this feed was queued for refresh, 0 if not queued.',
- ));
- db_add_index('aggregator_feed', 'queued', array('queued'));
-}
-
View
763 modules/aggregator/aggregator.module
@@ -1,763 +0,0 @@
-<?php
-
-/**
- * @file
- * Used to aggregate syndicated content (RSS, RDF, and Atom).
- */
-
-/**
- * Denotes that a feed's items should never expire.
- */
-define('AGGREGATOR_CLEAR_NEVER', 0);
-
-/**
- * Implements hook_help().
- */
-function aggregator_help($path, $arg) {
- switch ($path) {
- case 'admin/help#aggregator':
- $output = '';
- $output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Aggregator module is an on-site syndicator and news reader that gathers and displays fresh content from RSS-, RDF-, and Atom-based feeds made available across the web. Thousands of sites (particularly news sites and blogs) publish their latest headlines in feeds, using a number of standardized XML-based formats. For more information, see the online handbook entry for <a href="@aggregator-module">Aggregator module</a>.', array('@aggregator-module' => 'http://drupal.org/handbook/modules/aggregator', '@aggregator' => url('aggregator'))) . '</p>';
- $output .= '<h3>' . t('Uses') . '</h3>';
- $output .= '<dl>';
- $output .= '<dt>' . t('Viewing feeds') . '</dt>';
- $output .= '<dd>' . t('Feeds contain published content, and may be grouped in categories, generally by topic. Users view feed content in the <a href="@aggregator">main aggregator display</a>, or by <a href="@aggregator-sources">their source</a> (usually via an RSS feed reader). The most recent content in a feed or category can be displayed as a block through the <a href="@admin-block">Blocks administration page</a>.', array('@aggregator' => url('aggregator'), '@aggregator-sources' => url('aggregator/sources'), '@admin-block' => url('admin/structure/block'))) . '</a></dd>';
- $output .= '<dt>' . t('Adding, editing, and deleting feeds') . '</dt>';
- $output .= '<dd>' . t('Administrators can add, edit, and delete feeds, and choose how often to check each feed for newly updated items on the <a href="@feededit">Feed aggregator administration page</a>.', array('@feededit' => url('admin/config/services/aggregator'))) . '</dd>';
- $output .= '<dt>' . t('OPML integration') . '</dt>';
- $output .= '<dd>' . t('A <a href="@aggregator-opml">machine-readable OPML file</a> of all feeds is available. OPML is an XML-based file format used to share outline-structured information such as a list of RSS feeds. Feeds can also be <a href="@import-opml">imported via an OPML file</a>.', array('@aggregator-opml' => url('aggregator/opml'), '@import-opml' => url('admin/config/services/aggregator'))) . '</dd>';
- $output .= '<dt>' . t('Configuring cron') . '</dt>';
- $output .= '<dd>' . t('A correctly configured <a href="@cron">cron maintenance task</a> is required to update feeds automatically.', array('@cron' => 'http://drupal.org/cron')) . '</dd>';
- $output .= '</dl>';
- return $output;
- case 'admin/config/services/aggregator':
- $output = '<p>' . t('Thousands of sites (particularly news sites and blogs) publish their latest headlines and posts in feeds, using a number of standardized XML-based formats. Formats supported by the aggregator include <a href="@rss">RSS</a>, <a href="@rdf">RDF</a>, and <a href="@atom">Atom</a>.', array('@rss' => 'http://cyber.law.harvard.edu/rss/', '@rdf' => 'http://www.w3.org/RDF/', '@atom' => 'http://www.atomenabled.org')) . '</p>';
- $output .= '<p>' . t('Current feeds are listed below, and <a href="@addfeed">new feeds may be added</a>. For each feed or feed category, the <em>latest items</em> block may be enabled at the <a href="@block">blocks administration page</a>.', array('@addfeed' => url('admin/config/services/aggregator/add/feed'), '@block' => url('admin/structure/block'))) . '</p>';
- return $output;
- case 'admin/config/services/aggregator/add/feed':
- return '<p>' . t('Add a feed in RSS, RDF or Atom format. A feed may only have one entry.') . '</p>';
- case 'admin/config/services/aggregator/add/category':
- return '<p>' . t('Categories allow feed items from different feeds to be grouped together. For example, several sport-related feeds may belong to a category named <em>Sports</em>. Feed items may be grouped automatically (by selecting a category when creating or editing a feed) or manually (via the <em>Categorize</em> page available from feed item listings). Each category provides its own feed page and block.') . '</p>';
- case 'admin/config/services/aggregator/add/opml':
- return '<p>' . t('<acronym title="Outline Processor Markup Language">OPML</acronym> is an XML format used to exchange multiple feeds between aggregators. A single OPML document may contain a collection of many feeds. Drupal can parse such a file and import all feeds at once, saving you the effort of adding them manually. You may either upload a local file from your computer or enter a URL where Drupal can download it.') . '</p>';
- }
-}
-
-/**
- * Implements hook_theme().
- */
-function aggregator_theme() {
- return array(
- 'aggregator_wrapper' => array(
- 'variables' => array('content' => NULL),
- 'file' => 'aggregator.pages.inc',
- 'template' => 'aggregator-wrapper',
- ),
- 'aggregator_categorize_items' => array(
- 'render element' => 'form',
- 'file' => 'aggregator.pages.inc',
- ),
- 'aggregator_feed_source' => array(
- 'variables' => array('feed' => NULL),
- 'file' => 'aggregator.pages.inc',
- 'template' => 'aggregator-feed-source',
- ),
- 'aggregator_block_item' => array(
- 'variables' => array('item' => NULL, 'feed' => 0),
- ),
- 'aggregator_summary_items' => array(
- 'variables' => array('summary_items' => NULL, 'source' => NULL),
- 'file' => 'aggregator.pages.inc',
- 'template' => 'aggregator-summary-items',
- ),
- 'aggregator_summary_item' => array(
- 'variables' => array('item' => NULL),
- 'file' => 'aggregator.pages.inc',
- 'template' => 'aggregator-summary-item',
- ),
- 'aggregator_item' => array(
- 'variables' => array('item' => NULL),
- 'file' => 'aggregator.pages.inc',
- 'template' => 'aggregator-item',
- ),
- 'aggregator_page_opml' => array(
- 'variables' => array('feeds' => NULL),
- 'file' => 'aggregator.pages.inc',
- ),
- 'aggregator_page_rss' => array(
- 'variables' => array('feeds' => NULL, 'category' => NULL),
- 'file' => 'aggregator.pages.inc',
- ),
- );
-}
-
-/**
- * Implements hook_menu().
- */
-function aggregator_menu() {
- $items['admin/config/services/aggregator'] = array(
- 'title' => 'Feed aggregator',
- 'description' => "Configure which content your site aggregates from other sites, how often it polls them, and how they're categorized.",
- 'page callback' => 'aggregator_admin_overview',
- 'access arguments' => array('administer news feeds'),
- 'weight' => 10,
- 'file' => 'aggregator.admin.inc',
- );
- $items['admin/config/services/aggregator/add/feed'] = array(
- 'title' => 'Add feed',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('aggregator_form_feed'),
- 'access arguments' => array('administer news feeds'),
- 'type' => MENU_LOCAL_ACTION,
- 'file' => 'aggregator.admin.inc',
- );
- $items['admin/config/services/aggregator/add/category'] = array(
- 'title' => 'Add category',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('aggregator_form_category'),
- 'access arguments' => array('administer news feeds'),
- 'type' => MENU_LOCAL_ACTION,
- 'file' => 'aggregator.admin.inc',
- );
- $items['admin/config/services/aggregator/add/opml'] = array(
- 'title' => 'Import OPML',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('aggregator_form_opml'),
- 'access arguments' => array('administer news feeds'),
- 'type' => MENU_LOCAL_ACTION,
- 'file' => 'aggregator.admin.inc',
- );
- $items['admin/config/services/aggregator/remove/%aggregator_feed'] = array(
- 'title' => 'Remove items',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('aggregator_admin_remove_feed', 5),
- 'access arguments' => array('administer news feeds'),
- 'file' => 'aggregator.admin.inc',
- );
- $items['admin/config/services/aggregator/update/%aggregator_feed'] = array(
- 'title' => 'Update items',
- 'page callback' => 'aggregator_admin_refresh_feed',
- 'page arguments' => array(5),
- 'access arguments' => array('administer news feeds'),
- 'file' => 'aggregator.admin.inc',
- );
- $items['admin/config/services/aggregator/list'] = array(
- 'title' => 'List',
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => -10,
- );
- $items['admin/config/services/aggregator/settings'] = array(
- 'title' => 'Settings',
- 'description' => 'Configure the behavior of the feed aggregator, including when to discard feed items and how to present feed items and categories.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('aggregator_admin_form'),
- 'access arguments' => array('administer news feeds'),
- 'type' => MENU_LOCAL_TASK,
- 'file' => 'aggregator.admin.inc',
- );
- $items['aggregator'] = array(
- 'title' => 'Feed aggregator',
- 'page callback' => 'aggregator_page_last',
- 'access arguments' => array('access news feeds'),
- 'weight' => 5,
- 'file' => 'aggregator.pages.inc',
- );
- $items['aggregator/sources'] = array(
- 'title' => 'Sources',
- 'page callback' => 'aggregator_page_sources',
- 'access arguments' => array('access news feeds'),
- 'file' => 'aggregator.pages.inc',
- );
- $items['aggregator/categories'] = array(
- 'title' => 'Categories',
- 'page callback' => 'aggregator_page_categories',
- 'access callback' => '_aggregator_has_categories',
- 'file' => 'aggregator.pages.inc',
- );
- $items['aggregator/rss'] = array(
- 'title' => 'RSS feed',
- 'page callback' => 'aggregator_page_rss',
- 'access arguments' => array('access news feeds'),
- 'type' => MENU_CALLBACK,
- 'file' => 'aggregator.pages.inc',
- );
- $items['aggregator/opml'] = array(
- 'title' => 'OPML feed',
- 'page callback' => 'aggregator_page_opml',
- 'access arguments' => array('access news feeds'),
- 'type' => MENU_CALLBACK,
- 'file' => 'aggregator.pages.inc',
- );
- $items['aggregator/categories/%aggregator_category'] = array(
- 'title callback' => '_aggregator_category_title',
- 'title arguments' => array(2),
- 'page callback' => 'aggregator_page_category',
- 'page arguments' => array(2),
- 'access arguments' => array('access news feeds'),
- 'file' => 'aggregator.pages.inc',
- );
- $items['aggregator/categories/%aggregator_category/view'] = array(
- 'title' => 'View',
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => -10,
- );
- $items['aggregator/categories/%aggregator_category/categorize'] = array(
- 'title' => 'Categorize',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('aggregator_page_category_form', 2),
- 'access arguments' => array('administer news feeds'),
- 'type' => MENU_LOCAL_TASK,
- 'file' => 'aggregator.pages.inc',
- );
- $items['aggregator/categories/%aggregator_category/configure'] = array(
- 'title' => 'Configure',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('aggregator_form_category', 2),
- 'access arguments' => array('administer news feeds'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 1,
- 'file' => 'aggregator.admin.inc',
- );
- $items['aggregator/sources/%aggregator_feed'] = array(
- 'page callback' => 'aggregator_page_source',
- 'page arguments' => array(2),
- 'access arguments' => array('access news feeds'),
- 'file' => 'aggregator.pages.inc',
- );
- $items['aggregator/sources/%aggregator_feed/view'] = array(
- 'title' => 'View',
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => -10,
- );
- $items['aggregator/sources/%aggregator_feed/categorize'] = array(
- 'title' => 'Categorize',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('aggregator_page_source_form', 2),
- 'access arguments' => array('administer news feeds'),
- 'type' => MENU_LOCAL_TASK,
- 'file' => 'aggregator.pages.inc',
- );
- $items['aggregator/sources/%aggregator_feed/configure'] = array(
- 'title' => 'Configure',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('aggregator_form_feed', 2),
- 'access arguments' => array('administer news feeds'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 1,
- 'file' => 'aggregator.admin.inc',
- );
- $items['admin/config/services/aggregator/edit/feed/%aggregator_feed'] = array(
- 'title' => 'Edit feed',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('aggregator_form_feed', 6),
- 'access arguments' => array('administer news feeds'),
- 'file' => 'aggregator.admin.inc',
- );
- $items['admin/config/services/aggregator/edit/category/%aggregator_category'] = array(
- 'title' => 'Edit category',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('aggregator_form_category', 6),
- 'access arguments' => array('administer news feeds'),
- 'file' => 'aggregator.admin.inc',
- );
-
- return $items;
-}
-
-/**
- * Title callback for aggregatory category pages.
- *
- * @return
- * An aggregator category title.
- */
-function _aggregator_category_title($category) {
- return $category['title'];
-}
-
-/**
- * Find out whether there are any aggregator categories.
- *
- * @return
- * TRUE if there is at least one category and the user has access to them, FALSE
- * otherwise.
- */
-function _aggregator_has_categories() {
- return user_access('access news feeds') && (bool) db_query_range('SELECT 1 FROM {aggregator_category}', 0, 1)->fetchField();
-}
-
-/**
- * Implements hook_permission().
- */
-function aggregator_permission() {
- return array(
- 'administer news feeds' => array(
- 'title' => t('Administer news feeds'),
- ),
- 'access news feeds' => array(
- 'title' => t('View news feeds'),
- ),
- );
-}
-
-/**
- * Implements hook_cron().
- *
- * Queues news feeds for updates once their refresh interval has elapsed.
- */
-function aggregator_cron() {
- $result = db_query('SELECT * FROM {aggregator_feed} WHERE queued = 0 AND checked + refresh < :time AND refresh <> :never', array(
- ':time' => REQUEST_TIME,
- ':never' => AGGREGATOR_CLEAR_NEVER
- ));
- $queue = DrupalQueue::get('aggregator_feeds');
- foreach ($result as $feed) {
- if ($queue->createItem($feed)) {
- // Add timestamp to avoid queueing item more than once.
- db_update('aggregator_feed')
- ->fields(array('queued' => REQUEST_TIME))
- ->condition('fid', $feed->fid)
- ->execute();
- }
- }
-
- // Remove queued timestamp after 6 hours assuming the update has failed.
- db_update('aggregator_feed')
- ->fields(array('queued' => 0))
- ->condition('queued', REQUEST_TIME - (3600 * 6), '<')
- ->execute();
-}
-
-/**
- * Implements hook_cron_queue_info().
- */
-function aggregator_cron_queue_info() {
- $queues['aggregator_feeds'] = array(
- 'worker callback' => 'aggregator_refresh',
- 'time' => 60,
- );
- return $queues;
-}
-
-/**
- * Implements hook_block_info().
- */
-function aggregator_block_info() {
- $blocks = array();
- $result = db_query('SELECT cid, title FROM {aggregator_category} ORDER BY title');
- foreach ($result as $category) {
- $blocks['category-' . $category->cid]['info'] = t('!title category latest items', array('!title' => $category->title));
- }
- $result = db_query('SELECT fid, title FROM {aggregator_feed} WHERE block <> 0 ORDER BY fid');
- foreach ($result as $feed) {
- $blocks['feed-' . $feed->fid]['info'] = t('!title feed latest items', array('!title' => $feed->title));
- }
- return $blocks;
-}
-
-/**
- * Implements hook_block_configure().
- */
-function aggregator_block_configure($delta = '') {
- list($type, $id) = explode('-', $delta);
- if ($type == 'category') {
- $value = db_query('SELECT block FROM {aggregator_category} WHERE cid = :cid', array(':cid' => $id))->fetchField();
- $form['block'] = array(
- '#type' => 'select',
- '#title' => t('Number of news items in block'),
- '#default_value' => $value,
- '#options' => drupal_map_assoc(range(2, 20)),
- );
- return $form;
- }
-}
-
-/**
- * Implements hook_block_save().
- */
-function aggregator_block_save($delta = '', $edit = array()) {
- list($type, $id) = explode('-', $delta);
- if ($type == 'category') {
- db_update('aggregator_category')
- ->fields(array('block' => $edit['block']))
- ->condition('cid', $id)
- ->execute();
- }
-}
-
-/**
- * Implements hook_block_view().
- *
- * Generates blocks for the latest news items in each category and feed.
- */
-function aggregator_block_view($delta = '') {
- if (user_access('access news feeds')) {
- $block = array();
- list($type, $id) = explode('-', $delta);
- switch ($type) {
- case 'feed':
- if ($feed = db_query('SELECT fid, title, block FROM {aggregator_feed} WHERE block <> 0 AND fid = :fid', array(':fid' => $id))->fetchObject()) {
- $block['subject'] = check_plain($feed->title);
- $result = db_query_range("SELECT * FROM {aggregator_item} WHERE fid = :fid ORDER BY timestamp DESC, iid DESC", 0, $feed->block, array(':fid' => $id));
- $read_more = theme('more_link', array('url' => 'aggregator/sources/' . $feed->fid, 'title' => t("View this feed's recent news.")));
- }
- break;
-
- case 'category':
- if ($category = db_query('SELECT cid, title, block FROM {aggregator_category} WHERE cid = :cid', array(':cid' => $id))->fetchObject()) {
- $block['subject'] = check_plain($category->title);
- $result = db_query_range('SELECT i.* FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON ci.iid = i.iid WHERE ci.cid = :cid ORDER BY i.timestamp DESC, i.iid DESC', 0, $category->block, array(':cid' => $category->cid));
- $read_more = theme('more_link', array('url' => 'aggregator/categories/' . $category->cid, 'title' => t("View this category's recent news.")));
- }
- break;
- }
- $items = array();
- foreach ($result as $item) {
- $items[] = theme('aggregator_block_item', array('item' => $item));
- }
-
- // Only display the block if there are items to show.
- if (count($items) > 0) {
- $block['content'] = theme('item_list', array('items' => $items)) . $read_more;
- }
- return $block;
- }
-}
-
-/**
- * Add/edit/delete aggregator categories.
- *
- * @param $edit
- * An associative array describing the category to be added/edited/deleted.
- */
-function aggregator_save_category($edit) {
- $link_path = 'aggregator/categories/';
- if (!empty($edit['cid'])) {
- $link_path .= $edit['cid'];
- if (!empty($edit['title'])) {
- db_merge('aggregator_category')
- ->key(array('cid' => $edit['cid']))
- ->fields(array(
- 'title' => $edit['title'],
- 'description' => $edit['description'],
- ))
- ->execute();
- $op = 'update';
- }
- else {
- db_delete('aggregator_category')
- ->condition('cid', $edit['cid'])
- ->execute();
- // Make sure there is no active block for this category.
- db_delete('block')
- ->condition('module', 'aggregator')
- ->condition('delta', 'category-' . $edit['cid'])
- ->execute();
- $edit['title'] = '';
- $op = 'delete';
- }
- }
- elseif (!empty($edit['title'])) {
- // A single unique id for bundles and feeds, to use in blocks.
- $link_path .= db_insert('aggregator_category')
- ->fields(array(
- 'title' => $edit['title'],
- 'description' => $edit['description'],
- 'block' => 5,
- ))
- ->execute();
- $op = 'insert';
- }
- if (isset($op)) {
- menu_link_maintain('aggregator', $op, $link_path, $edit['title']);
- }
-}
-
-/**
- * Add/edit/delete an aggregator feed.
- *
- * @param $edit
- * An associative array describing the feed to be added/edited/deleted.
- */
-function aggregator_save_feed($edit) {
- if (!empty($edit['fid'])) {
- // An existing feed is being modified, delete the category listings.
- db_delete('aggregator_category_feed')
- ->condition('fid', $edit['fid'])
- ->execute();
- }
- if (!empty($edit['fid']) && !empty($edit['title'])) {
- db_update('aggregator_feed')
- ->condition('fid', $edit['fid'])
- ->fields(array(
- 'title' => $edit['title'],
- 'url' => $edit['url'],
- 'refresh' => $edit['refresh'],
- 'block' => $edit['block'],
- ))
- ->execute();
- }
- elseif (!empty($edit['fid'])) {
- $iids = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $edit['fid']))->fetchCol();
- if ($iids) {
- db_delete('aggregator_category_item')
- ->condition('iid', $iids, 'IN')
- ->execute();
- }
- db_delete('aggregator_feed')->
- condition('fid', $edit['fid'])
- ->execute();
- db_delete('aggregator_item')
- ->condition('fid', $edit['fid'])
- ->execute();
- // Make sure there is no active block for this feed.
- db_delete('block')
- ->condition('module', 'aggregator')
- ->condition('delta', 'feed-' . $edit['fid'])
- ->execute();
- }
- elseif (!empty($edit['title'])) {
- $edit['fid'] = db_insert('aggregator_feed')
- ->fields(array(
- 'title' => $edit['title'],
- 'url' => $edit['url'],
- 'refresh' => $edit['refresh'],
- 'block' => $edit['block'],
- 'description' => '',
- 'image' => '',
- ))
- ->execute();
-
- }
- if (!empty($edit['title'])) {
- // The feed is being saved, save the categories as well.
- if (!empty($edit['category'])) {
- foreach ($edit['category'] as $cid => $value) {
- if ($value) {
- db_insert('aggregator_category_feed')
- ->fields(array(
- 'fid' => $edit['fid'],
- 'cid' => $cid,
- ))
- ->execute();
- }
- }
- }
- }
-}
-
-/**
- * Removes all items from a feed.
- *
- * @param $feed
- * An object describing the feed to be cleared.
- */
-function aggregator_remove($feed) {
- _aggregator_get_variables();
- // Call hook_aggregator_remove() on all modules.
- module_invoke_all('aggregator_remove', $feed);
- // Reset feed.
- db_merge('aggregator_feed')
- ->key(array('fid' => $feed->fid))
- ->fields(array(
- 'checked' => 0,
- 'hash' => '',
- 'etag' => '',
- 'modified' => 0,
- 'description' => $feed->description,
- 'image' => $feed->image,
- ))
- ->execute();
-}
-
-function _aggregator_get_variables() {
- // Fetch the feed.
- $fetcher = variable_get('aggregator_fetcher', 'aggregator');
- if ($fetcher == 'aggregator') {
- include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'aggregator') . '/aggregator.fetcher.inc';
- }
- $parser = variable_get('aggregator_parser', 'aggregator');
- if ($parser == 'aggregator') {
- include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'aggregator') . '/aggregator.parser.inc';
- }
- $processors = variable_get('aggregator_processors', array('aggregator'));
- if (in_array('aggregator', $processors)) {
- include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'aggregator') . '/aggregator.processor.inc';
- }
- return array($fetcher, $parser, $processors);
-}
-
-/**
- * Checks a news feed for new items.
- *
- * @param $feed
- * An object describing the feed to be refreshed.
- */
-function aggregator_refresh($feed) {
- // Store feed URL to track changes.
- $feed_url = $feed->url;
-
- // Fetch the feed.
- list($fetcher, $parser, $processors) = _aggregator_get_variables();
- $success = module_invoke($fetcher, 'aggregator_fetch', $feed);
-
- // We store the hash of feed data in the database. When refreshing a
- // feed we compare stored hash and new hash calculated from downloaded
- // data. If both are equal we say that feed is not updated.
- $hash = hash('sha256', $feed->source_string);
-
- if ($success && ($feed->hash != $hash)) {
- // Parse the feed.
- if (module_invoke($parser, 'aggregator_parse', $feed)) {
- // Update feed with parsed data.
- db_merge('aggregator_feed')
- ->key(array('fid' => $feed->fid))
- ->fields(array(
- 'url' => $feed->url,
- 'link' => empty($feed->link) ? $feed->url : $feed->link,
- 'description' => empty($feed->description) ? '' : $feed->description,
- 'image' => empty($feed->image) ? '' : $feed->image,
- 'hash' => $hash,
- 'etag' => empty($feed->etag) ? '' : $feed->etag,
- 'modified' => empty($feed->modified) ? 0 : $feed->modified,
- ))
- ->execute();
-
- // Log if feed URL has changed.
- if ($feed->url != $feed_url) {
- watchdog('aggregator', 'Updated URL for feed %title to %url.', array('%title' => $feed->title, '%url' => $feed->url));
- }
-
- watchdog('aggregator', 'There is new syndicated content from %site.', array('%site' => $feed->title));
- drupal_set_message(t('There is new syndicated content from %site.', array('%site' => $feed->title)));
-
- // If there are items on the feed, let all enabled processors do their work on it.
- if (@count($feed->items)) {
- foreach ($processors as $processor) {
- module_invoke($processor, 'aggregator_process', $feed);
- }
- }
- }
- }
- else {
- drupal_set_message(t('There is no new syndicated content from %site.', array('%site' => $feed->title)));
- }
-
- // Regardless of successful or not, indicate that this feed has been checked.
- db_update('aggregator_feed')
- ->fields(array('checked' => REQUEST_TIME, 'queued' => 0))
- ->condition('fid', $feed->fid)
- ->execute();
-
- // Expire old feed items.
- if (function_exists('aggregator_expire')) {
- aggregator_expire($feed);
- }
-}
-
-/**
- * Load an aggregator feed.
- *
- * @param $fid
- * The feed id.
- * @return
- * An object describing the feed.
- */
-function aggregator_feed_load($fid) {
- $feeds = &drupal_static(__FUNCTION__);
- if (!isset($feeds[$fid])) {
- $feeds[$fid] = db_query('SELECT * FROM {aggregator_feed} WHERE fid = :fid', array(':fid' => $fid))->fetchObject();
- }
-
- return $feeds[$fid];
-}
-
-/**
- * Load an aggregator category.
- *
- * @param $cid
- * The category id.
- * @return
- * An associative array describing the category.
- */
-function aggregator_category_load($cid) {
- $categories = &drupal_static(__FUNCTION__);
- if (!isset($categories[$cid])) {
- $categories[$cid] = db_query('SELECT * FROM {aggregator_category} WHERE cid = :cid', array(':cid' => $cid))->fetchAssoc();
- }
-
- return $categories[$cid];
-}
-
-/**
- * Returns HTML for an individual feed item for display in the block.
- *
- * @param $variables
- * An associative array containing:
- * - item: The item to be displayed.
- * - feed: Not used.
- *
- * @ingroup themeable
- */
-function theme_aggregator_block_item($variables) {
- // Display the external link to the item.
- return '<a href="' . check_url($variables['item']->link) . '">' . check_plain($variables['item']->title) . "</a>\n";
-}
-
-/**
- * Safely render HTML content, as allowed.
- *
- * @param $value
- * The content to be filtered.
- * @return
- * The filtered content.
- */
-function aggregator_filter_xss($value) {
- return filter_xss($value, preg_split('/\s+|<|>/', variable_get('aggregator_allowed_html_tags', '<a> <b> <br> <dd> <dl> <dt> <em> <i> <li> <ol> <p> <strong> <u> <ul>'), -1, PREG_SPLIT_NO_EMPTY));
-}
-
-/**
- * Check and sanitize aggregator configuration.
- *
- * Goes through all fetchers, parsers and processors and checks whether they are
- * available.
- * If one is missing resets to standard configuration.
- *
- * @return
- * TRUE if this function reset the configuration FALSE if not.
- */
-function aggregator_sanitize_configuration() {
- $reset = FALSE;
- list($fetcher, $parser, $processors) = _aggregator_get_variables();
- if (!module_exists($fetcher)) {
- $reset = TRUE;
- }
- if (!module_exists($parser)) {
- $reset = TRUE;
- }
- foreach ($processors as $processor) {
- if (!module_exists($processor)) {
- $reset = TRUE;
- break;
- }
- }
- if ($reset) {
- variable_del('aggregator_fetcher');
- variable_del('aggregator_parser');
- variable_del('aggregator_processors');
- return TRUE;
- }
- return FALSE;
-}
-
-/**
- * Helper function for drupal_map_assoc.
- *
- * @param $count
- * Items count.
- * @return
- * Plural-formatted "@count items"
- */
-function _aggregator_items($count) {
- return format_plural($count, '1 item', '@count items');
-}
View
524 modules/aggregator/aggregator.pages.inc
@@ -1,524 +0,0 @@
-<?php
-
-/**
- * @file
- * User page callbacks for the aggregator module.
- */
-
-/**
- * Menu callback; displays the most recent items gathered from any feed.
- *
- * @return
- * The items HTML.
- */
-function aggregator_page_last() {
- drupal_add_feed('aggregator/rss', variable_get('site_name', 'Drupal') . ' ' . t('aggregator'));
-
- $items = aggregator_feed_items_load('sum');
-
- return _aggregator_page_list($items, arg(1));
-}
-
-/**
- * Menu callback; displays all the items captured from a particular feed.
- *
- * @param $feed
- * The feed for which to display all items.
- *
- * @return
- * The rendered list of items for a feed.
- */
-function aggregator_page_source($feed) {
- drupal_set_title($feed->title);
- $feed_source = theme('aggregator_feed_source', array('feed' => $feed));
-
- // It is safe to include the fid in the query because it's loaded from the
- // database by aggregator_feed_load.
- $items = aggregator_feed_items_load('source', $feed);
-
- return _aggregator_page_list($items, arg(3), $feed_source);
-}
-
-/**
- * Menu callback; displays a form with all items captured from a feed.
- *
- * @param $feed
- * The feed for which to list all the aggregated items.
- *
- * @return
- * The rendered list of items for a feed.
- *
- * @see aggregator_page_source()
- */
-function aggregator_page_source_form($form, $form_state, $feed) {
- return aggregator_page_source($feed);
-}
-
-/**
- * Menu callback; displays all the items aggregated in a particular category.
- *
- * @param $category
- * The category for which to list all the aggregated items.
- *
- * @return
-* The rendered list of items for a category.
- */
-function aggregator_page_category($category) {
- drupal_add_feed('aggregator/rss/' . $category['cid'], variable_get('site_name', 'Drupal') . ' ' . t('aggregator - @title', array('@title' => $category['title'])));
-
- // It is safe to include the cid in the query because it's loaded from the
- // database by aggregator_category_load.
- $items = aggregator_feed_items_load('category', $category);
-
- return _aggregator_page_list($items, arg(3));
-}
-
-/**