summaryrefslogtreecommitdiff
path: root/kolab.org
diff options
context:
space:
mode:
authorTorsten Grote <grote@kolabsys.com>2013-05-27 09:14:26 (GMT)
committerTorsten Grote <grote@kolabsys.com>2013-05-27 09:14:26 (GMT)
commitdab170e32f9ab7e9a918dcef4636f64769c1b171 (patch)
treea32317df7e143ddad4d5dd05b58131303aee983c /kolab.org
parente53acca6089f933bbe456891b0b24cef8dcbb5fe (diff)
downloadkolab.org-www-dab170e32f9ab7e9a918dcef4636f64769c1b171.tar.gz
update feeds module
Diffstat (limited to 'kolab.org')
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/CHANGELOG.txt196
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/README.txt2
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.api.php90
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.info27
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.install104
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.module63
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.pages.inc7
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.plugins.inc24
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.rules.inc45
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.tokens.inc2
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_import/feeds_import.feeds_importer_default.inc2
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_import/feeds_import.info6
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_news/feeds_news.feeds_importer_default.inc4
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_news/feeds_news.info6
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.admin.inc234
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.css120
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.info6
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.js62
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.module8
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.test9
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/includes/FeedsConfigurable.inc9
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/includes/FeedsSource.inc4
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/libraries/ParserCSV.inc1
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/libraries/common_syndication_parser.inc37
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/libraries/http_request.inc42
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/mappers/date.inc24
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/mappers/file.inc7
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/mappers/taxonomy.inc245
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/mappers/text.inc3
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsCSVParser.inc22
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsFetcher.inc7
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsFileFetcher.inc180
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsHTTPFetcher.inc29
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsNodeProcessor.inc62
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsParser.inc41
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsPlugin.inc13
-rwxr-xr-xkolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsProcessor.inc162
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsTermProcessor.inc46
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsUserProcessor.inc16
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds.test6
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/multi-date.xml29
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/nodes_comma.csv10
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/nodes_pipe.csv10
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/nodes_plus.csv10
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/nodes_semicolon.csv10
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/nodes_tab.csv10
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_date_time.test2
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_fetcher_file.test62
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_date.test29
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_date_multiple.test118
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_field.test2
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_file.test9
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_link.test2
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_path.test14
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_taxonomy.test217
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_processor_node.test6
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_processor_term.test41
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_tests.info6
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/parser_csv.test66
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/feeds/views/feeds.views_default.inc152
60 files changed, 2019 insertions, 759 deletions
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/CHANGELOG.txt b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/CHANGELOG.txt
index fcbdda8..cee98c0 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/CHANGELOG.txt
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/CHANGELOG.txt
@@ -1,3 +1,199 @@
+Feeds 7.x 2.0 Alpha 8, 2012-04-22
+---------------------------------
+
+- Issue #1555974 by twistor | andyg5000: Fixed Save button should also add field
+ mapping; Add button should also save config changes.
+- Allow 0 as a term name.
+- Issue #630288 by kulfi: Added import date compatibility issues with Google
+ Groups' feeds.
+- Issue #1878254 by facine: Fixed SimplePie download page url.
+- Issue #1166100 by twistor | Niklas Fiekas: Fixed Notices and warnings on
+ mapping page, when no content type is selected for NodeProcessor.
+- Issue #1941302 by jshimota01: Fixed Radio buttons hidden in IE 7.
+- Fix formatting of feeds_ui.css
+- Issue #1362378 by gordon, colan, Sutharsan, MegaChriz | mukesh.agarwal17:
+ Added is_new addtribute to feeds_item.
+- Fixed: missing comma.
+- Issue #1961998 by gordon: Added new hook hook_feeds_before_update().
+- Issue #1025468 by 30equals: Added Allow operations to be performed on disabled
+ Importers.
+- Issue #1953008 by MegaChriz | carn1x: Fixed PHP Fatal error: Nesting level
+ too deep - recursive dependency? in FeedsProcessor.inc on line 199.
+- git commit -m Issue
+- Fix capitalization of Feeds on Importer import page.
+- Issue #777888 by WorldFallz, liquidcms, firfin | timwood: Added UI to import
+ views-style exportable (a.k.a. How to import importers?).
+- Issue #697842 by eiriksm, franz, Webmaster Perpignan: Added Support array of
+ values for dates.
+- Tests for #1019688.
+- Issue #1019688 by johnv, philipz, twistor, sin, ts145nera, David Hernández:
+ Fixed Taxonomy mapper options: term name +tid, term name, tid, guid (avoids
+ mapping error for Numeric taxonomy term, too).
+- Issue #1958864 by DamienMcKenna: Fixed 'Division by zero' error in
+ feeds_update_7208.
+- Issue #1147734 by philipnorton42, znerol, David_Rothstein, twistor | johnv:
+ Added Import files in public://feeds/ vs. private://feeds/.
+- Issue #857216 by yareckon, wuinfo: behavior on importing empty/NULL/invalid
+ dates.
+- Fix coding standards.
+- Ensure that headers is always set.
+- Fix uid validation for Node processor.
+- Issue #1201638 by rfay: Fixed Plugins should be listed in info file.
+- Issue #1848726 by ojohansson, twistor: Fixed Hash check fails when running
+ multiple importers on cron.
+- Issue #1620110 by Cottser, JvE | Alan D.: Fixed Update default views fixes
+ 'Missing text format: 1.' in watchdog.
+- Issue #1156982 by dooug, dotman: Fixed SQLSTATE[HY000]: General error: 1366
+ Incorrect integer value: '' for column 'last_comment_uid()' at row 1.
+- Issue #1660950 by valthebald: Fixed FeedsSource expects stored to be array,
+ which is not always the case.
+- Use bundle() method.
+- Use plugin key rather than class name.
+- Issue #1300940 by colin_young: Fixed Undefined Index: unique in
+ FeedsCSVParser.inc.
+- Issue #1874322: Remove PHP version check from Common Syndication Parser.
+- Issue #1870528 by cmriley: Fixed Undefined index: content_type() in
+ feeds_rules_event_info() (line 56 feeds/feeds.rules.inc.
+- Issue #1711648 Upgrade path.
+- Issue #1711648 by twistor: Fixes for tests.
+- Issue #1711648 by twistor: Abstract bundle handling.
+- Issue #1827780 by pfrenssen: Type hinting missing from
+ hook_feeds_parser_sources_alter() callback example.
+- Issue #1825016 by David_Rothstein: Make it easier for the FeedsCSVParser
+ source form to be altered.
+- Issue #1744570 by Staratel: Added Invoke Before import event before start
+ import.
+- Move static method to member method.
+- Issue #1843146 by twistor: Add pluginType() method to be able to determine the
+ plugin type without having to lookup the inheritance.
+- Always set is_new on node create rather than node_save().
+- Re-fix replace existing behavior.
+- Fix replace existing behavior.
+- Issue #1165506 by Mile23 | 7wonders: Added pipe delimiter to csv parser.
+- Use user_delete_multiple()
+- Issue #1835106 by twistor: Make entity loading generic.
+- Issue #1480902 by Staratel | faunt: Added Are there timeouts on Feed
+ importers?.
+- Issue #912682 by alex_b, snyderp, dman | dwhogg: Added CSV Parser: Support
+ Mac-style line endings.
+- Issue #1817992 by OnkelTem: Fixed Notice: Undefined property: stdClass:: in
+ feeds_tokens()
+
+Feeds 7.x 2.0 Alpha 7, 2012-10-12
+---------------------------------
+
+- Make sure target array is always initialized.
+- Issue #1807920 by Rob_Feature: Fixed Imported nodes have NULL format.
+- Make datetime tests fake unit tests.
+
+Feeds 7.x 2.0 Alpha 6, 2012-10-10
+---------------------------------
+
+- Port authorization from 6.x to 7.x.
+- Make FeedsDateTimeTest a real unit test.
+- Don't hard code delta to 10.
+- Issue #1567508 by kruser, beansboxchrispang: Fixed User import is incorrectly
+ changing passwords.
+- Fix failing test after making them stricter.
+- Issue #837922 by twistor, andrewlevine: Added removeMappings() to test suite
+ and more extensive addMapping testing.
+- Issue #1074520 by ccheu: Commit #783098 not included in 7.x-2.0-alpha3.
+- Fix for mapping ui and multiple mappings with configuration.
+- Re-organize FeedsProcessor::process() so that it is clearer.
+- Issue #1191498 by dooug, twistor: Set drupal_set_message() to not repeat
+ 'Missing Feeds plugin...'.
+- Allow for 0 to be used in the number mapping.
+- Issue #1420360 by anarchocoder: Fixed Common Syndication Parser sometimes
+ creates php warning when feed item title is empty.
+- Issue #1728634 by David_Rothstein: Fixed User and node 'created' dates (from
+ feeds_to_unixtime()) default to the wrong timezone.
+- Coder review fixes.
+- Dang it. Add feeds_alter() back because contrib depends on it.
+- Remove stupid feeds_alter().
+- Issue #1466170 by peter.sogaard: Added Text format support in taxonomy term
+ fields.
+- Use consistent set target callbacks.
+- Move text and numeric mappers to their own include.
+- Simplify forced updating.
+- Make link mapper less retarded.
+- Issue #1551852 by Sergii: Fixed Text field mapper: support for FeedsElement
+ object.
+- Issue #1715124 by theduke: Fixed feeds_importer() 'config' column to short -
+ change size to big.
+- Issue #1784436 by stefan.norman: Fixed FeedsTermProcessor existingEntityId
+ doesn't honour id column in feeds_item().
+- Issue #1792318 by psynaptic: Fixed Invalid multibyte sequence in
+ tests/feeds.test.
+- Add quick test for skip_hash_check.
+- Issue #1364116 by axel.rutz | Les Lim: Added Option to skip hash check on
+ re-import.
+- Revert term specific forced updating.
+- Remove debug statements.
+- Issue #1410296 by logaritmisk, vinmassaro: Added Reorder mappings.
+- Don't set unique flag for things that don't have it.
+- Add test for new mapping config.
+- Issue #860748 by Niklas Fiekas, franz, twistor | infojunkie: Added Config for
+ mappers?.
+- Add support for SimplePie 1.3
+- Fix path alias test for taxonomy terms.
+- Un-prefix node path test.
+- Move path mapping to path.inc and add tests.
+- Issue #1724200 by balazs.hegedus: Added Support for drupal_http_request()
+ timeout.
+- Issue #1736976 by Chaulky: Added Trim feed urls to remove accidental spaces.
+- Issue #1110762 by vaartio, franz, bancarddata, axel.rutz: Fixed Feeds does not
+ catch file exceptions properly in file mapper and FeedsParser.inc getFile()
+ function.
+- Issue #1742740 by Staratel: Fixed Add magic method __isset() to
+ FeedsConfigurable to use default entity wrapping.
+- Issue #1739704 by axel.rutz: Fixed Node lookup by title in Nodeprocessor does
+ not respect nodetype.
+- Issue #1690434 by twistor | jzornig: Fixed Notice: Undefined variable: job in
+ FeedsSource->scheduleClear() (line 319 of sites/all/modules/feeds/includes/FeedsSource.inc).
+- Issue #1703074 by theduke: Added Include parser result in
+ hook_feeds_presave().
+- Issue #1070604 by Bobík: Added Feed's nid in mappings.
+- Issue #1300500 by milesw | derekwormdahl: Fixed Not loading node status in
+ FeedsNodeProcessor.inc is causing issue with Content Access module.
+- Coder review fixes.
+- Add stricter test for integer value.
+- Fix doc strings.
+- Issue #1112876 by chx: Added Support digest auth.
+- Get FeedsMapperFileTestCase tests to pass.
+- Issue #1688294 by twistor | Rob_Feature: Fixed Invalid URL (even though it's
+ valid).
+- Issue #1402788 by tbosviel | Cottser: Added All files are imported as MIME
+ application/octet-stream.
+- Issue #1271502 by twistor | oobie11: Fixed Im getting an error when I run
+ cron.
+- Issue #1460282 by elliotttf, MegaChriz | jday: Fixed Call to undefined method
+ FeedsMissingPlugin::entityType() .
+- Use entity type if entity label is not set.
+- Issue #1661014 by twistor | johnv: Fixed feeds_entity_load() called too often
+ / is not cached.
+- Issue #1665450: Path alias target when using pathauto.
+- Fixed: feeds_mapper_file.test.
+- Method for downloading and extracting the simplepie library during tests.
+- Try to shut up SimplePie.
+- Allow setting a variable for the library path.
+- Fix for taxonomy mapper test.
+- Make descriptions in taxonomy term processor consistent.
+- Make labels for taxonomy processor consistent.
+- Issue #1044874 by marek.trunkat, bdragon | seth.vincent: Fixed Debug message:
+ missing handler: feeds_log() feed_nid() field.
+- Issue #1424992 by stevector: Added implementation of hook_entity_info_alter()
+ so that ->feed_nid() is available to Rules.
+- Issue #1662550 by pvhee: Fixed Invoke hook_feeds_after_import() after writing
+ to the logs.
+- Issue #1454666: Fixing unlock feature to also work with locked imports.
+- Issue #1241754: Add targets for author name and email in node processor.
+- Issue #1454666: Add tool to reset locked feeds
+- Issue #1612246: Fixing introduced error on filepath generation.
+- Small fix on comment alignment
+- Issue #1632286 by facine: Fixed Cannot redeclare
+ FeedsTermProcessor::setTargetElement().
+- Issue #1001590 by tristanoneil, twistor, Bevan: Path alias mapping target.
+
Feeds 7.x 2.0 Alpha 5, 2012-05-28
---------------------------------
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/README.txt b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/README.txt
index 5c137a2..7e57d6d 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/README.txt
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/README.txt
@@ -191,6 +191,8 @@ Default: 50
Name: http_request_timeout
Default: 15
Description: Timeout in seconds to wait for an HTTP get request to finish.
+Note: This setting could be overridden per importer in admin UI :
+ admin/structure/feeds/<your_importer>/settings/<your_fetcher> page.
Name: feeds_never_use_curl
Default: FALSE
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.api.php b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.api.php
index 0154e90..e0dfc12 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.api.php
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.api.php
@@ -87,9 +87,9 @@ function hook_feeds_plugins() {
/**
* Invoked after a feed source has been parsed, before it will be processed.
*
- * @param $source
+ * @param FeedsSource $source
* FeedsSource object that describes the source that has been imported.
- * @param $result
+ * @param FeedsParserResult $result
* FeedsParserResult object that has been parsed from the source.
*/
function hook_feeds_after_parse(FeedsSource $source, FeedsParserResult $result) {
@@ -98,14 +98,52 @@ function hook_feeds_after_parse(FeedsSource $source, FeedsParserResult $result)
}
/**
+ * Invoked before a feed source import starts.
+ *
+ * @param FeedsSource $source
+ * FeedsSource object that describes the source that is going to be imported.
+ */
+function hook_feeds_before_import(FeedsSource $source) {
+ // See feeds_rules module's implementation for an example.
+}
+
+/**
+ * Invoked before a feed item is updated/created/replaced.
+ *
+ * This is called every time a feed item is processed no matter if the item gets
+ * updated or not.
+ *
+ * @param FeedsSource $source
+ * The source for the current feed.
+ * @param array $item
+ * All the current item from the feed.
+ * @param int|null $entity_id
+ * The id of the current item which is going to be updated. If this is a new
+ * item, then NULL is passed.
+ */
+function hook_feeds_before_update(FeedsSource $source, $item, $entity_id) {
+ if ($entity_id) {
+ $processor = $source->importer->processor;
+ db_update('foo_bar')
+ ->fields(array('entity_type' => $processor->entityType(), 'entity_id' => $entity_id, 'last_seen' => REQUEST_TIME))
+ ->condition('entity_type', $processor->entityType())
+ ->condition('entity_id', $entity_id)
+ ->execute();
+ }
+}
+
+/**
* Invoked before a feed item is saved.
*
- * @param $source
+ * @param FeedsSource $source
* FeedsSource object that describes the source that is being imported.
* @param $entity
* The entity object.
- * @param $item
+ * @param array $item
* The parser result for this entity.
+ * @param int|null $entity_id
+ * The id of the current item which is going to be updated. If this is a new
+ * item, then NULL is passed.
*/
function hook_feeds_presave(FeedsSource $source, $entity, $item) {
if ($entity->feeds_item->entity_type == 'node') {
@@ -115,9 +153,37 @@ function hook_feeds_presave(FeedsSource $source, $entity, $item) {
}
/**
+ * Invoked after a feed item has been saved.
+ *
+ * @param FeedsSource $source
+ * FeedsSource object that describes the source that is being imported.
+ * @param $entity
+ * The entity object that has just been saved.
+ * @param array $item
+ * The parser result for this entity.
+ * @param int|null $entity_id
+ * The id of the current item which is going to be updated. If this is a new
+ * item, then NULL is passed.
+ */
+function hook_feeds_after_save(FeedsSource $source, $entity, $item, $entity_id) {
+ // Use $entity->nid of the saved node.
+
+ // Although the $entity object is passed by reference, any changes made in
+ // this function will be ignored by the FeedsProcessor.
+ $config = $source->importer->getConfig();
+
+ if ($config['processor']['config']['purge_unseen_items'] && isset($entity->feeds_item)) {
+ $feeds_item = $entity->feeds_item;
+ $feeds_item->batch_id = feeds_delete_get_current_batch($feeds_item->feed_nid);
+
+ drupal_write_record('feeds_delete_item', $feeds_item);
+ }
+}
+
+/**
* Invoked after a feed source has been imported.
*
- * @param $source
+ * @param FeedsSource $source
* FeedsSource object that describes the source that has been imported.
*/
function hook_feeds_after_import(FeedsSource $source) {
@@ -127,7 +193,7 @@ function hook_feeds_after_import(FeedsSource $source) {
/**
* Invoked after a feed source has been cleared of its items.
*
- * @param $source
+ * @param FeedsSource $source
* FeedsSource object that describes the source that has been cleared.
*/
function hook_feeds_after_clear(FeedsSource $source) {
@@ -175,10 +241,10 @@ function hook_feeds_parser_sources_alter(&$sources, $content_type) {
* @return
* The value to be extracted from the source.
*
- * @see hook_feeds_parser_sources_alter().
- * @see locale_feeds_get_source().
+ * @see hook_feeds_parser_sources_alter()
+ * @see locale_feeds_get_source()
*/
-function my_source_get_source($source, FeedsParserResult $result, $key) {
+function my_source_get_source(FeedsSource $source, FeedsParserResult $result, $key) {
$item = $result->currentItem();
return my_source_parse_images($item['description']);
}
@@ -240,7 +306,7 @@ function hook_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_nam
function my_module_set_target($source, $entity, $target, $value, $mapping) {
$entity->{$target}[$entity->language][0]['value'] = $value;
if (isset($source->importer->processor->config['input_format'])) {
- $entity->{$target}[$entity->language][0]['format'] =
+ $entity->{$target}[$entity->language][0]['format'] =
$source->importer->processor->config['input_format'];
}
}
@@ -280,11 +346,11 @@ function my_module_summary_callback($mapping, $target, $form, $form_state) {
*
* The arguments are the same that my_module_summary_callback() gets.
*
- * @see my_module_summary_callback()
- *
* @return
* The per mapping configuration form. Once the form is saved, $mapping will
* be populated with the form values.
+ *
+ * @see my_module_summary_callback()
*/
function my_module_form_callback($mapping, $target, $form, $form_state) {
return array(
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.info b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.info
index c5d164d..98a021a 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.info
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.info
@@ -11,9 +11,28 @@ files[] = includes/FeedsSource.inc
files[] = libraries/ParserCSV.inc
files[] = libraries/http_request.inc
files[] = libraries/PuSHSubscriber.inc
+
+; Plugins
+files[] = plugins/FeedsCSVParser.inc
+files[] = plugins/FeedsFetcher.inc
+files[] = plugins/FeedsFileFetcher.inc
+files[] = plugins/FeedsHTTPFetcher.inc
+files[] = plugins/FeedsNodeProcessor.inc
+files[] = plugins/FeedsOPMLParser.inc
+files[] = plugins/FeedsParser.inc
+files[] = plugins/FeedsPlugin.inc
+files[] = plugins/FeedsProcessor.inc
+files[] = plugins/FeedsSimplePieParser.inc
+files[] = plugins/FeedsSitemapParser.inc
+files[] = plugins/FeedsSyndicationParser.inc
+files[] = plugins/FeedsTermProcessor.inc
+files[] = plugins/FeedsUserProcessor.inc
+
+; Tests
files[] = tests/feeds.test
files[] = tests/feeds_date_time.test
files[] = tests/feeds_mapper_date.test
+files[] = tests/feeds_mapper_date_multiple.test
files[] = tests/feeds_mapper_field.test
files[] = tests/feeds_mapper_file.test
files[] = tests/feeds_mapper_path.test
@@ -28,6 +47,8 @@ files[] = tests/feeds_scheduler.test
files[] = tests/feeds_mapper_link.test
files[] = tests/feeds_mapper_taxonomy.test
files[] = tests/parser_csv.test
+
+; Views integration
files[] = views/feeds_views_handler_argument_importer_id.inc
files[] = views/feeds_views_handler_field_importer_name.inc
files[] = views/feeds_views_handler_field_log_message.inc
@@ -35,9 +56,9 @@ files[] = views/feeds_views_handler_field_severity.inc
files[] = views/feeds_views_handler_field_source.inc
files[] = views/feeds_views_handler_filter_severity.inc
-; Information added by drupal.org packaging script on 2012-10-10
-version = "7.x-2.0-alpha6"
+; Information added by drupal.org packaging script on 2013-04-22
+version = "7.x-2.0-alpha8"
core = "7.x"
project = "feeds"
-datestamp = "1349851321"
+datestamp = "1366671911"
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.install b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.install
index 7584f4e..344f7e1 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.install
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.install
@@ -6,6 +6,59 @@
*/
/**
+ * Implements hook_requirements().
+ */
+function feeds_requirements($phase) {
+ $t = get_t();
+
+ $requirements = array(
+ 'simplexml' => array(
+ 'title' => $t('SimpleXML'),
+ 'value' => extension_loaded('SimpleXML') ? $t('Enabled') : $t('Disabled'),
+ 'description' => $t('SimpleXML PHP module is required for Feeds Syndication Parser.'),
+ 'severity' => REQUIREMENT_INFO,
+ ),
+ 'simplepie' => array(
+ 'title' => $t('SimplePie'),
+ 'value' => $t('Unknown at install time.'),
+ 'description' => $t('SimplePie library is required for Feeds SimplePie Parser.'),
+ 'severity' => REQUIREMENT_INFO,
+ )
+ );
+ if ($phase == 'runtime') {
+ // Check for SimpleXML, required by FeedsSyndicationParser.
+ if (extension_loaded('SimpleXML')) {
+ $requirements['simplexml']['severity'] = REQUIREMENT_OK;
+ }
+ else {
+ $requirements['simplexml']['severity'] = REQUIREMENT_WARNING;
+ $requirements['simplexml']['description'] .= ' ' . t('It has been disabled at compile time, seek instructions from the server mantainers to enable it.');
+ }
+ // Check for SimplePie, required by FeedsSimplePieParser.
+ if (feeds_simplepie_exists()) {
+ $requirements['simplepie']['value'] = t('Enabled');
+ $requirements['simplepie']['severity'] = REQUIREMENT_OK;
+ }
+ else {
+ $requirements['simplepie']['value'] = t('Not installed');
+ $requirements['simplepie']['severity'] = REQUIREMENT_WARNING;
+ $requirements['simplepie']['description'] .= ' ' . t(
+ 'Download the compiled version of the library from <a href="@simplepie-download-url">SimplePie download page</a>.',
+ array('@simplepie-download-url' => 'http://simplepie.org/downloads/')
+ );
+ }
+ }
+ return $requirements;
+}
+
+/**
+ * Implement hook_uninstall()
+ */
+function feeds_uninstall() {
+ variable_del('http_request_timeout');
+}
+
+/**
* Implements hook_schema().
*/
function feeds_schema() {
@@ -561,3 +614,54 @@ function feeds_update_7207() {
'serialize' => TRUE,
));
}
+
+/**
+ * Update to use generic bundle handling.
+ */
+function feeds_update_7208(&$sandbox) {
+
+ if (!isset($sandbox['importers'])) {
+ // Get all importers.
+ $sandbox['importers'] = db_query("SELECT id FROM {feeds_importer}")->fetchCol();
+ $sandbox['total'] = count($sandbox['importers']);
+ }
+
+ $importer = array_pop($sandbox['importers']);
+ $config = db_query("SELECT config FROM {feeds_importer} WHERE id = :id", array(':id' => $importer))->fetchField();
+
+ if ($config) {
+ $config = unserialize($config);
+
+ switch ($config['processor']['plugin_key']) {
+ case 'FeedsNodeProcessor':
+ $config_key = 'content_type';
+ break;
+
+ case 'FeedsTermProcessor':
+ $config_key = 'vocabulary';
+ break;
+
+ default:
+ $config_key = FALSE;
+ break;
+ }
+
+ if ($config_key && isset($config['processor']['config'][$config_key])) {
+ $config['processor']['config']['bundle'] = $config['processor']['config'][$config_key];
+ unset($config['processor']['config'][$config_key]);
+
+ // Update databse.
+ db_update('feeds_importer')
+ ->fields(array(
+ 'config' => serialize($config),
+ ))
+ ->condition('id', $importer)
+ ->execute();
+ }
+
+ $sandbox['#finished'] = 1 - count($sandbox['importers']) / $sandbox['total'];
+ }
+ else {
+ $sandbox['#finished'] = 1;
+ }
+}
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.module b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.module
index 0e1bda4..4dc7c34 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.module
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.module
@@ -27,7 +27,12 @@ define('FEEDS_BATCH_ACTIVE', 0.0);
*/
function feeds_hook_info() {
$hooks = array(
+ 'feeds_plugins',
'feeds_after_parse',
+ 'feeds_before_import',
+ 'feeds_before_update',
+ 'feeds_presave',
+ 'feeds_after_save',
'feeds_after_import',
'feeds_after_clear',
'feeds_processor_targets_alter',
@@ -417,6 +422,16 @@ function feeds_access($action, $param) {
}
/**
+ * Access callback to determine if the user can import Feeds importers.
+ *
+ * Feeds imports require an additional access check because they are PHP
+ * code and PHP is more locked down than administer feeds.
+ */
+function feeds_importer_import_access() {
+ return user_access('administer feeds') && user_access('use PHP for settings');
+}
+
+/**
* Menu access callback.
*/
function feeds_page_access() {
@@ -1178,3 +1193,51 @@ function feeds_get_feed_nid_entity_callback($entity, array $options, $name, $ent
}
return $feed_nid;
}
+
+/**
+ * Implements hook_file_download().
+ */
+function feeds_file_download($uri) {
+ $id = db_query("SELECT id FROM {feeds_source} WHERE source = :uri", array(':uri' => $uri))->fetchField();
+
+ if (!$id) {
+ // File is not associated with a feed.
+ return;
+ }
+
+ // Get the file record based on the URI. If not in the database just return.
+ $files = file_load_multiple(array(), array('uri' => $uri));
+ foreach ($files as $item) {
+ // Since some database servers sometimes use a case-insensitive comparison
+ // by default, double check that the filename is an exact match.
+ if ($item->uri === $uri) {
+ $file = $item;
+ break;
+ }
+ }
+ if (!isset($file)) {
+ return;
+ }
+
+ // Check if this file belongs to Feeds.
+ $usage_list = file_usage_list($file);
+ if (!isset($usage_list['feeds'])) {
+ return;
+ }
+
+ if (!feeds_access('import', $id)) {
+ // User does not have permission to import this feed.
+ return -1;
+ }
+
+ // Return file headers.
+ return file_get_content_headers($file);
+}
+
+/**
+ * Feeds API version.
+ */
+function feeds_api_version() {
+ $version = feeds_ctools_plugin_api('feeds', 'plugins');
+ return $version['version'];
+}
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.pages.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.pages.inc
index 6f1481e..f976d9c 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.pages.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.pages.inc
@@ -341,7 +341,12 @@ function theme_feeds_upload($variables) {
$wrapper = file_stream_wrapper_get_instance_by_uri($file->uri);
$description .= '<div class="file-info">';
$description .= '<div class="file-name">';
- $description .= l($file->filename, $wrapper->getExternalUrl());
+ if ($wrapper) {
+ $description .= l($file->filename, $wrapper->getExternalUrl());
+ }
+ else {
+ $description .= t('URI scheme %scheme not available.', array('%scheme' => file_uri_scheme($uri)));
+ }
$description .= '</div>';
$description .= '<div class="file-size">';
$description .= format_size($file->filesize);
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.plugins.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.plugins.inc
index 3f23cb8..c7d5d81 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.plugins.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.plugins.inc
@@ -85,17 +85,19 @@ function _feeds_feeds_plugins() {
'path' => $path,
),
);
- $info['FeedsSyndicationParser'] = array(
- 'name' => 'Common syndication parser',
- 'description' => 'Parse RSS and Atom feeds.',
- 'help' => 'Parse XML feeds in RSS 1, RSS 2 and Atom format.',
- 'handler' => array(
- 'parent' => 'FeedsParser',
- 'class' => 'FeedsSyndicationParser',
- 'file' => 'FeedsSyndicationParser.inc',
- 'path' => $path,
- ),
- );
+ if (extension_loaded('SimpleXML')) {
+ $info['FeedsSyndicationParser'] = array(
+ 'name' => 'Common syndication parser',
+ 'description' => 'Parse RSS and Atom feeds.',
+ 'help' => 'Parse XML feeds in RSS 1, RSS 2 and Atom format.',
+ 'handler' => array(
+ 'parent' => 'FeedsParser',
+ 'class' => 'FeedsSyndicationParser',
+ 'file' => 'FeedsSyndicationParser.inc',
+ 'path' => $path,
+ ),
+ );
+ }
$info['FeedsOPMLParser'] = array(
'name' => 'OPML parser',
'description' => 'Parse OPML files.',
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.rules.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.rules.inc
index 84b4685..dce753a 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.rules.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.rules.inc
@@ -9,9 +9,21 @@
* Implements hook_rules_event_info().
*/
function feeds_rules_event_info() {
- $info = array();
+ // General events definitions.
+ $info = array(
+ 'feeds_before_import' => array(
+ 'label' => t('Before importing feed'),
+ 'group' => t('Feeds'),
+ 'variables' => array('source' => array('type' => 'feeds_source', 'label' => 'Feeds source')),
+ ),
+ 'feeds_after_import' => array(
+ 'label' => t('After importing feed'),
+ 'group' => t('Feeds'),
+ 'variables' => array('source' => array('type' => 'feeds_source', 'label' => 'Feeds source')),
+ ),
+ );
+ // Per importer events definitions.
$entity_info = entity_get_info();
-
foreach (feeds_importer_load_all() as $importer) {
$config = $importer->getConfig();
$processor = feeds_plugin($config['processor']['plugin_key'], $importer->id);
@@ -40,8 +52,7 @@ function feeds_rules_event_info() {
);
// Add bundle information if the node processor is used.
if ($processor instanceof FeedsNodeProcessor) {
- $config = $processor->getConfig();
- $info['feeds_import_'. $importer->id]['variables'][$entity_type]['bundle'] = $config['content_type'];
+ $info['feeds_import_'. $importer->id]['variables'][$entity_type]['bundle'] = $processor->bundle();
}
}
return $info;
@@ -65,6 +76,32 @@ function feeds_rules_action_info() {
}
/**
+ * Implements hook_rules_data_info().
+ */
+function feeds_rules_data_info() {
+ return array(
+ 'feeds_source' => array(
+ 'label' => t('Feeds source'),
+ 'group' => t('Feeds'),
+ 'wrap' => TRUE,
+ 'property info' => array(
+ 'id' => array(
+ 'label' => t('ID'),
+ 'type' => 'text',
+ 'description' => t("The machine readable name of the source importer."),
+ ),
+ 'imported' => array(
+ 'label' => t('Date imported'),
+ 'type' => 'date',
+ 'description' => t("The date the source was last imported."),
+ ),
+ // @TODO: fetcher, parser, state ...
+ ),
+ ),
+ );
+}
+
+/**
* Mark feeds import item as skipped.
*/
function feeds_action_skip_item($entity_wrapper) {
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.tokens.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.tokens.inc
index cb7dc4c..a5145b6 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.tokens.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds.tokens.inc
@@ -25,7 +25,7 @@ function feeds_token_info() {
function feeds_tokens($type, $tokens, array $data, array $options) {
$replacements = array();
- if ($type == 'node' && !empty($data['node'])) {
+ if ($type == 'node' && !empty($data['node']) && !empty($data['node']->nid)) {
$sanitize = !empty($options['sanitize']);
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_import/feeds_import.feeds_importer_default.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_import/feeds_import.feeds_importer_default.inc
index 7b1f681..71c053e 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_import/feeds_import.feeds_importer_default.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_import/feeds_import.feeds_importer_default.inc
@@ -32,7 +32,7 @@ function feeds_import_feeds_importer_default() {
'processor' => array(
'plugin_key' => 'FeedsNodeProcessor',
'config' => array(
- 'content_type' => 'article',
+ 'bundle' => 'article',
'update_existing' => 1,
'expire' => '-1',
'mappings' => array(
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_import/feeds_import.info b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_import/feeds_import.info
index 4d507eb..71cc8ff 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_import/feeds_import.info
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_import/feeds_import.info
@@ -9,9 +9,9 @@ name = "Feeds Import"
package = "Feeds"
php = "5.2.4"
-; Information added by drupal.org packaging script on 2012-10-10
-version = "7.x-2.0-alpha6"
+; Information added by drupal.org packaging script on 2013-04-22
+version = "7.x-2.0-alpha8"
core = "7.x"
project = "feeds"
-datestamp = "1349851321"
+datestamp = "1366671911"
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_news/feeds_news.feeds_importer_default.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_news/feeds_news.feeds_importer_default.inc
index f42ad0c..3ace081 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_news/feeds_news.feeds_importer_default.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_news/feeds_news.feeds_importer_default.inc
@@ -32,7 +32,7 @@ function feeds_news_feeds_importer_default() {
'processor' => array(
'plugin_key' => 'FeedsNodeProcessor',
'config' => array(
- 'content_type' => 'feed_item',
+ 'bundle' => 'feed_item',
'update_existing' => '0',
'expire' => '-1',
'mappings' => array(
@@ -95,7 +95,7 @@ function feeds_news_feeds_importer_default() {
'processor' => array(
'plugin_key' => 'FeedsNodeProcessor',
'config' => array(
- 'content_type' => 'feed',
+ 'bundle' => 'feed',
'update_existing' => 0,
'expire' => '-1',
'mappings' => array(
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_news/feeds_news.info b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_news/feeds_news.info
index 6e3e7e7..c160e12 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_news/feeds_news.info
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_news/feeds_news.info
@@ -17,9 +17,9 @@ name = "Feeds News"
package = "Feeds"
php = "5.2.4"
-; Information added by drupal.org packaging script on 2012-10-10
-version = "7.x-2.0-alpha6"
+; Information added by drupal.org packaging script on 2013-04-22
+version = "7.x-2.0-alpha8"
core = "7.x"
project = "feeds"
-datestamp = "1349851321"
+datestamp = "1366671911"
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.admin.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.admin.inc
index ee3f15e..fb63c8c 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.admin.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.admin.inc
@@ -93,23 +93,17 @@ function feeds_ui_overview_form($form, &$form_status) {
$importer_form['status'] = array(
'#markup' => $status,
);
- if (!$importer->disabled) {
- $importer_form['operations'] = array(
- '#markup' =>
- l($edit, 'admin/structure/feeds/' . $importer->id) . ' | ' .
- l(t('Export'), 'admin/structure/feeds/' . $importer->id . '/export') . ' | ' .
- l(t('Clone'), 'admin/structure/feeds/' . $importer->id . '/clone') .
- (empty($delete) ? '' : ' | ' . l($delete, 'admin/structure/feeds/' . $importer->id . '/delete')),
- );
- }
- else {
- $importer_form['operations']['#markup'] = '&nbsp;';
- }
+ $importer_form['operations'] = array(
+ '#markup' =>
+ l($edit, 'admin/structure/feeds/' . $importer->id) . ' | ' .
+ l(t('Export'), 'admin/structure/feeds/' . $importer->id . '/export') . ' | ' .
+ l(t('Clone'), 'admin/structure/feeds/' . $importer->id . '/clone') .
+ (empty($delete) ? '' : ' | ' . l($delete, 'admin/structure/feeds/' . $importer->id . '/delete')),
+ );
$importer_form[$importer->id] = array(
'#type' => 'checkbox',
'#default_value' => !$importer->disabled,
- '#attributes' => array('class' => array('feeds-ui-trigger-submit')),
);
if ($importer->disabled) {
@@ -122,7 +116,6 @@ function feeds_ui_overview_form($form, &$form_status) {
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
- '#attributes' => array('class' => array('feeds-ui-hidden-submit')),
);
return $form;
}
@@ -150,7 +143,6 @@ function feeds_ui_overview_form_submit($form, &$form_state) {
* of $from_importer.
*/
function feeds_ui_create_form($form, &$form_state, $from_importer = NULL) {
- $form['#attached']['js'][] = drupal_get_path('module', 'feeds_ui') . '/feeds_ui.js';
$form['#from_importer'] = $from_importer;
$form['name'] = array(
'#type' => 'textfield',
@@ -427,24 +419,25 @@ function feeds_ui_edit_page($importer, $active = 'help', $plugin_key = '') {
function feeds_ui_plugin_form($form, &$form_state, $importer, $type) {
$plugins = FeedsPlugin::byType($type);
- $form = array();
$form['#importer'] = $importer->id;
$form['#plugin_type'] = $type;
+ $importer_key = $importer->config[$type]['plugin_key'];
+
foreach ($plugins as $key => $plugin) {
+
$form['plugin_key'][$key] = array(
'#type' => 'radio',
'#parents' => array('plugin_key'),
'#title' => check_plain($plugin['name']),
'#description' => filter_xss(isset($plugin['help']) ? $plugin['help'] : $plugin['description']),
'#return_value' => $key,
- '#default_value' => ($plugin['handler']['class'] == get_class($importer->$type)) ? $key : '',
+ '#default_value' => ($key == $importer_key) ? $key : '',
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
- '#attributes' => array('class' => array('feeds-ui-hidden-submit')),
);
return $form;
}
@@ -465,7 +458,6 @@ function feeds_ui_plugin_form_submit($form, &$form_state) {
*/
function theme_feeds_ui_plugin_form($variables) {
$form = $variables['form'];
- drupal_add_js(drupal_get_path('module', 'feeds_ui') . '/feeds_ui.js');
$output = '';
foreach (element_children($form['plugin_key']) as $key) {
@@ -495,9 +487,6 @@ function theme_feeds_ui_plugin_form($variables) {
* FeedsProcessor, a flag can tell whether mapping is supported or not.
*/
function feeds_ui_mapping_form($form, &$form_state, $importer) {
- drupal_add_js(drupal_get_path('module', 'feeds_ui') . '/feeds_ui.js');
-
- $form = array();
$form['#importer'] = $importer->id;
$form['#mappings'] = $mappings = $importer->processor->getMappings();
$form['help']['#markup'] = feeds_ui_mapping_help();
@@ -519,6 +508,7 @@ function feeds_ui_mapping_form($form, &$form_state, $importer) {
}
$targets = $importer->processor->getMappingTargets();
$target_options = _feeds_ui_format_options($targets);
+ $legend['targets'] = array();
foreach ($targets as $k => $target) {
$legend['targets'][$k]['name']['#markup'] = empty($target['name']) ? $k : $target['name'];
$legend['targets'][$k]['description']['#markup'] = empty($target['description']) ? '' : $target['description'];
@@ -571,31 +561,36 @@ function feeds_ui_mapping_form($form, &$form_state, $importer) {
if (isset($source_options)) {
$form['source'] = array(
'#type' => 'select',
- '#options' => array('' => t('Select a source')) + $source_options,
+ '#title' => t('Source'),
+ '#title_display' => 'invisible',
+ '#options' => $source_options,
+ '#empty_option' => t('- Select a source -'),
+ '#description' => t('An element from the feed.'),
);
}
else {
$form['source'] = array(
'#type' => 'textfield',
+ '#title' => t('Source'),
+ '#title_display' => 'invisible',
'#size' => 20,
- '#default_value' => t('Name of source field'),
- '#attributes' => array('class' => array('hide-text-on-focus')),
+ '#default_value' => '',
+ '#description' => t('The name of source field.'),
);
}
$form['target'] = array(
'#type' => 'select',
- '#options' => array('' => t('Select a target')) + $target_options,
- );
- $form['add'] = array(
- '#type' => 'submit',
- '#value' => t('Add'),
- '#submit' => array('feeds_ui_mapping_form_add_submit'),
- '#validate' => array('feeds_ui_mapping_form_add_validate'),
+ '#title' => t('Target'),
+ '#title_display' => 'invisible',
+ '#options' => $target_options,
+ '#empty_option' => t('- Select a target -'),
+ '#description' => t('The field that stores the data.'),
);
- $form['save'] = array(
+
+ $form['actions'] = array('#type' => 'actions');
+ $form['actions']['save'] = array(
'#type' => 'submit',
'#value' => t('Save'),
- '#attributes' => array('class' => array('feeds-ui-hidden-submit')),
);
return $form;
}
@@ -720,40 +715,36 @@ function feeds_ui_mapping_settings_form_callback($form, $form_state) {
}
/**
- * Validation for source and target selection.
+ * Validation handler for feeds_ui_mapping_form().
*/
-function feeds_ui_mapping_form_add_validate($form, &$form_state) {
- if ($form_state['values']['source'] == '') {
- form_set_error('source', t('You must select a mapping source.'));
- }
- if ($form_state['values']['target'] == '') {
- form_set_error('target', t('You must select a mapping target.'));
- }
-}
+function feeds_ui_mapping_form_validate($form, &$form_state) {
+ if (empty($form_state['values']['source']) xor empty($form_state['values']['target'])) {
-/**
- * Submit handler for add button on feeds_ui_mapping_form().
- */
-function feeds_ui_mapping_form_add_submit($form, &$form_state) {
- $importer = feeds_importer($form['#importer']);
- try {
- $mappings = $form['#mappings'];
- $mappings[] = array(
- 'source' => $form_state['values']['source'],
- 'target' => $form_state['values']['target'],
- 'unique' => FALSE,
- );
- $importer->processor->addConfig(array('mappings' => $mappings));
- $importer->save();
- drupal_set_message(t('Mapping has been added.'));
- }
- catch (Exception $e) {
- drupal_set_message($e->getMessage(), 'error');
+ // Check triggering_element here so we can react differently for ajax
+ // submissions.
+ switch ($form_state['triggering_element']['#name']) {
+
+ // Regular form submission.
+ case 'op':
+ if (empty($form_state['values']['source'])) {
+ form_error($form['source'], t('You must select a mapping source.'));
+ }
+ else {
+ form_error($form['target'], t('You must select a mapping target.'));
+ }
+ break;
+
+ // Be more relaxed on ajax submission.
+ default:
+ form_set_value($form['source'], '', $form_state);
+ form_set_value($form['target'], '', $form_state);
+ break;
+ }
}
}
/**
- * Submit handler for save button on feeds_ui_mapping_form().
+ * Submission handler for feeds_ui_mapping_form().
*/
function feeds_ui_mapping_form_submit($form, &$form_state) {
$importer = feeds_importer($form['#importer']);
@@ -786,6 +777,7 @@ function feeds_ui_mapping_form_submit($form, &$form_state) {
foreach ($remove_flags as $k) {
unset($mappings[$k]);
unset($form_state['values']['mapping_weight'][$k]);
+ drupal_set_message(t('Mapping has been removed.'), 'status', FALSE);
}
}
@@ -797,6 +789,23 @@ function feeds_ui_mapping_form_submit($form, &$form_state) {
}
$processor->addConfig(array('mappings' => $mappings));
+
+ if (!empty($form_state['values']['source']) && !empty($form_state['values']['target'])) {
+ try {
+ $mappings = $processor->getMappings();
+ $mappings[] = array(
+ 'source' => $form_state['values']['source'],
+ 'target' => $form_state['values']['target'],
+ 'unique' => FALSE,
+ );
+ $processor->addConfig(array('mappings' => $mappings));
+ drupal_set_message(t('Mapping has been added.'));
+ }
+ catch (Exception $e) {
+ drupal_set_message($e->getMessage(), 'error');
+ }
+ }
+
$importer->save();
drupal_set_message(t('Your changes have been saved.'));
}
@@ -861,7 +870,6 @@ function feeds_ui_mapping_settings_optional_unique_form($mapping, $target, $form
*/
function theme_feeds_ui_overview_form($variables) {
$form = $variables['form'];
- drupal_add_js(drupal_get_path('module', 'feeds_ui') . '/feeds_ui.js');
drupal_add_css(drupal_get_path('module', 'feeds_ui') . '/feeds_ui.css');
// Iterate through all importers and build a table.
@@ -1074,3 +1082,103 @@ function theme_feeds_ui_mapping_form($variables) {
drupal_add_tabledrag('feeds-ui-mapping-overview', 'order', 'sibling', 'feeds-ui-mapping-weight');
return $output;
}
+
+/**
+ * Page callback to import a Feeds importer.
+ */
+function feeds_ui_importer_import($form, &$form_state) {
+ $form['id'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Importer id'),
+ '#description' => t('Enter the id to use for this importer if it is different from the source importer. Leave blank to use the id of the importer.'),
+ );
+ $form['id_override'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Replace an existing importer if one exists with the same id.'),
+ );
+ $form['bypass_validation'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Bypass importer validation'),
+ '#description' => t('Bypass the validation of plugins when importing.'),
+ );
+ $form['importer'] = array(
+ '#type' => 'textarea',
+ '#rows' => 10,
+ );
+ $form['actions'] = array('#type' => 'actions');
+ $form['actions']['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Import'),
+ );
+ return $form;
+}
+
+/**
+ * Form validation handler for feeds_ui_importer_import().
+ *
+ * @see feeds_ui_importer_import_submit()
+ */
+function feeds_ui_importer_import_validate($form, &$form_state) {
+ $form_state['values']['importer'] = trim($form_state['values']['importer']);
+ $form_state['values']['id'] = trim($form_state['values']['id']);
+
+ if (!empty($form_state['values']['id']) && preg_match('/[^a-zA-Z0-9_]/', $form_state['values']['id'])) {
+ form_error($form['id'], t('Feeds importer id must be alphanumeric with underscores only.'));
+ }
+
+ if (substr($form_state['values']['importer'], 0, 5) == '<?php') {
+ $form_state['values']['importer'] = substr($form_state['values']['importer'], 5);
+ }
+
+ $feeds_importer = NULL;
+ ob_start();
+ eval($form_state['values']['importer']);
+ ob_end_clean();
+
+ if (!is_object($feeds_importer)) {
+ return form_error($form['importer'], t('Unable to interpret Feeds importer code.'));
+ }
+
+ if (empty($feeds_importer->api_version) || $feeds_importer->api_version < 1) {
+ form_error($form['importer'], t('The importer is not compatible with this version of Feeds.'));
+ }
+ elseif (version_compare($feeds_importer->api_version, feeds_api_version(), '>')) {
+ form_error($form['importer'], t('That importer is created for the version %import_version of Feeds, but you only have version %api_version.', array(
+ '%import_version' => $feeds_importer->api_version,
+ '%api_version' => feeds_api_version())));
+ }
+
+ $existing = feeds_importer($feeds_importer->id);
+ if ($existing && !$form_state['values']['id_override'] && $existing->export_type != EXPORT_IN_CODE) {
+ return form_error($form['id'], t('Feeds importer already exists with that id.'));
+ }
+
+ if (!$form_state['values']['bypass_validation']) {
+ foreach (array('fetcher', 'parser', 'processor') as $type) {
+ $plugin = feeds_plugin($feeds_importer->config[$type]['plugin_key'], $feeds_importer->id);
+ if (get_class($plugin) == 'FeedsMissingPlugin') {
+ form_error($form['importer'], t('The plugin %plugin is unavailable.', array('%plugin' => $feeds_importer->config[$type]['plugin_key'])));
+ }
+ }
+ }
+
+ $form_state['importer'] = $feeds_importer;
+}
+
+/**
+ * Form submission handler for feeds_ui_importer_import().
+ *
+ * @see feeds_ui_importer_import_validate()
+ */
+function feeds_ui_importer_import_submit($form, &$form_state) {
+ $importer = $form_state['importer'];
+ $importer = feeds_importer($importer->id);
+ $importer->setConfig($importer->config);
+ foreach (array('fetcher', 'parser', 'processor') as $type) {
+ $importer->$type->setConfig($importer->config[$type]['config']);
+ }
+ $importer->save();
+
+ drupal_set_message(t('Successfully imported the %id feeds importer.', array('%id' => $importer->id)));
+ $form_state['redirect'] = 'admin/structure/feeds';
+}
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.css b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.css
index b1b9e4c..017c345 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.css
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.css
@@ -1,90 +1,106 @@
-
/* Feeds admin overview form. */
table.feeds-admin-importers thead th {
border: none;
- }
+}
+
table.feeds-admin-importers td.disabled {
color: #aaa;
- }
+}
+
table.feeds-admin-importers tr.disabled.odd,
table.feeds-admin-importers tr.disabled.even {
border-color: #eee;
- }
+}
+
table.feeds-admin-importers tr.disabled.odd {
background-color: #f5f5f5;
- }
+}
/* Feeds edit form layout. */
div.feeds-settings {
- }
+}
+
div.left-bar {
float: left;
position: relative;
width: 240px;
border-right: 1px solid #DDD;
padding: 10px 10px 0 0;
- }
+}
+
div.configuration {
padding: 10px 0 0 250px;
margin-left: -240px;
- }
- div.configuration-squeeze {
- margin-left: 250px;
- }
+}
+
+div.configuration-squeeze {
+ margin-left: 250px;
+}
/* Container theming. */
div.feeds-container {
- }
+
+}
+
div.feeds-container h4 {
font-size: 1.2em;
font-weight: bold;
- }
+}
+
div.feeds-container.plain {
background-color: #EEE;
border-bottom: 1px solid #DDD;
border-top: 2px solid #DDD;
padding: 5px;
margin: 10px 0;
- }
- div.feeds-container.plain h4 {
- font-size: 1.0em;
- margin: 0;
- padding: 0;
- }
- div.feeds-container-body p {
- padding: 5px 0;
- margin: 0;
- }
- div.feeds-container-body div.item-list ul {
- margin: 0;
- }
- div.feeds-container-body div.item-list ul li {
- list-style-type: none;
- margin: 0;
- padding: 0;
- background-image: none;
- }
- ul.container-actions {
- font-family: Arial, Helvetica;
- float: right;
- margin: 0;
- }
- ul.container-actions li {
- list-style-type: none;
- text-align: right;
- background-image: none;
- margin: 0;
- padding: 0;
- }
- ul.container-actions .form-item,
- ul.container-actions li form,
- ul.container-actions li form input {
- padding: 0;
- margin: 0;
- display: inline;
- }
+}
+
+div.feeds-container.plain h4 {
+ font-size: 1.0em;
+ margin: 0;
+ padding: 0;
+}
+
+div.feeds-container-body p {
+ padding: 5px 0;
+ margin: 0;
+}
+
+div.feeds-container-body div.item-list ul {
+ margin: 0;
+}
+
+div.feeds-container-body div.item-list ul li {
+ list-style-type: none;
+ margin: 0;
+ padding: 0;
+ background-image: none;
+}
+
+ul.container-actions {
+ font-family: Arial, Helvetica;
+ float: right;
+ margin: 0;
+}
+
+ul.container-actions li {
+ list-style-type: none;
+ text-align: right;
+ background-image: none;
+ margin: 0;
+ padding: 0;
+ position: relative; /* Fix for IE 7 compatability mode. */
+}
+
+ul.container-actions .form-item,
+ul.container-actions li form,
+ul.container-actions li form input {
+ padding: 0;
+ margin: 0;
+ display: inline;
+}
/* Mapping form. */
#center table form {
margin: 0;
- }
+}
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.info b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.info
index c75c154..f84feec 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.info
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.info
@@ -7,9 +7,9 @@ configure = admin/structure/feeds
files[] = feeds_ui.test
-; Information added by drupal.org packaging script on 2012-10-10
-version = "7.x-2.0-alpha6"
+; Information added by drupal.org packaging script on 2013-04-22
+version = "7.x-2.0-alpha8"
core = "7.x"
project = "feeds"
-datestamp = "1349851321"
+datestamp = "1366671911"
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.js b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.js
deleted file mode 100644
index f5e8b7b..0000000
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.js
+++ /dev/null
@@ -1,62 +0,0 @@
-
-Drupal.behaviors.feeds = function() {
-
- // Hide text in specific input fields.
- $('.hide-text-on-focus').focus(function() {
- $(this).val('');
- });
-
-
- // Hide submit buttons of .feeds-ui-hidden-submit class.
- $('input.form-submit.feeds-ui-hidden-submit').hide();
-
- /**
- * Tune checkboxes on mapping forms.
- * @see feeds_ui_mapping_form() in feeds_ui.admin.inc
- */
-
- // Attach submit behavior to elements with feeds-ui-trigger-submit class.
- $('.feeds-ui-trigger-submit').click(function() {
- // Use click, not form.submit() - submit() would use the wrong submission
- // handler.
- $('input.form-submit.feeds-ui-hidden-submit').click();
- });
-
- // Replace checkbox with .feeds-ui-checkbox-link class with a link.
- $('.feeds-ui-checkbox-link:not(.processed)').each(function(i) {
- $(this).addClass('processed').after(
- '<a href="#" onclick="return false;" class="feeds-ui-trigger-remove">' + $('label', this).text() + '</a>'
- ).hide();
- });
-
- // Check the box and then submit.
- $('.feeds-ui-trigger-remove').click(function() {
- // Use click, not form.submit() - submit() would use the wrong submission
- // handler.
- $(this).prev().children().children().children().attr('checked', 1);
- $('input.form-submit.feeds-ui-hidden-submit').click();
- });
-
- // Replace radio with .feeds-ui-radio-link class with a link.
- $('.feeds-ui-radio-link:not(.processed)').parent().each(function(i) {
- checked = '';
- if ($(this).children('input').attr('checked')) {
- checked = ' checked';
- }
- $(this).addClass('processed').after(
- '<a href="#" onclick="return false;" class="feeds-ui-check-submit' + checked + '" id="' + $(this).children('input').attr('id') + '">' + $(this).parent().text() + '</a>'
- );
- $(this).hide();
- });
-
- // Hide the the radio that is selected.
- $('.feeds-ui-check-submit.checked').parent().hide();
-
- // Check the radio and then submit.
- $('.feeds-ui-check-submit').click(function() {
- // Use click, not form.submit() - submit() would use the wrong submission
- // handler.
- $('#' + $(this).attr('id')).attr('checked', 1);
- $('input.form-submit.feeds-ui-hidden-submit').click();
- });
-};
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.module b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.module
index ba76d6f..08cc40f 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.module
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.module
@@ -35,6 +35,14 @@ function feeds_ui_menu() {
'file' => 'feeds_ui.admin.inc',
'type' => MENU_LOCAL_ACTION,
);
+ $items['admin/structure/feeds/import'] = array(
+ 'title' => 'Import importer',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('feeds_ui_importer_import'),
+ 'access callback' => 'feeds_importer_import_access',
+ 'file' => 'feeds_ui.admin.inc',
+ 'type' => MENU_LOCAL_ACTION,
+ );
$items['admin/structure/feeds/%feeds_importer'] = array(
'title callback' => 'feeds_ui_importer_title',
'title arguments' => array(3),
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.test b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.test
index 39da765..d1e1a84 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.test
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/feeds_ui/feeds_ui.test
@@ -87,7 +87,7 @@ class FeedsUIUserInterfaceTestCase extends FeedsWebTestCase {
'content_type' => 'page',
'import_period' => 3600,
);
- $this->drupalPost('admin/structure/feeds/test_feed/settings', $edit, 'Save');
+ $this->setSettings('test_feed', NULL, $edit);
// Assert results of change.
$this->assertText('Syndication feed');
@@ -98,11 +98,8 @@ class FeedsUIUserInterfaceTestCase extends FeedsWebTestCase {
$this->assertLink('Basic page');
// Configure processor.
- $edit = array(
- 'content_type' => 'article',
- );
- $this->drupalPost('admin/structure/feeds/test_feed/settings/FeedsNodeProcessor', $edit, 'Save');
- $this->assertFieldByName('content_type', 'article');
+ $this->setSettings('test_feed', 'FeedsNodeProcessor', array('bundle' => 'article'));
+ $this->assertFieldByName('bundle', 'article');
// Create a feed node.
$edit = array(
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/includes/FeedsConfigurable.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/includes/FeedsConfigurable.inc
index 0f3b013..0530013 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/includes/FeedsConfigurable.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/includes/FeedsConfigurable.inc
@@ -136,7 +136,7 @@ abstract class FeedsConfigurable {
}
/**
- * Override magic method __get(). Make sure that $this->config goes through
+ * Override magic method __get(). Make sure that $this->config goes through
* getConfig().
*/
public function __get($name) {
@@ -265,6 +265,8 @@ function feeds_form_submit($form, &$form_state) {
/**
* Helper for Feeds validate and submit callbacks.
+ *
+ * @todo This is all terrible. Remove.
*/
function _feeds_form_helper($form, &$form_state, $action) {
$method = $form['#feeds_form_method'] . $action;
@@ -277,12 +279,13 @@ function _feeds_form_helper($form, &$form_state, $action) {
// This will re-initialize all of the plugins anyway, causing some tricky
// saving issues in certain cases.
// See http://drupal.org/node/1672880.
-
if ($class == variable_get('feeds_importer_class', 'FeedsImporter')) {
$form['#configurable'] = feeds_importer($id);
}
else {
- $form['#configurable'] = feeds_plugin($class, $id);
+ $importer = feeds_importer($id);
+ $plugin_key = $importer->config[$form['#configurable']->pluginType()]['plugin_key'];
+ $form['#configurable'] = feeds_plugin($plugin_key, $id);
}
if (method_exists($form['#configurable'], $method)) {
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/includes/FeedsSource.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/includes/FeedsSource.inc
index 7133842..98cd0f1 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/includes/FeedsSource.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/includes/FeedsSource.inc
@@ -237,6 +237,7 @@ class FeedsSource extends FeedsConfigurable {
* method may throw the same exceptions as FeedsSource::import().
*/
public function startImport() {
+ module_invoke_all('feeds_before_import', $this);
$config = $this->importer->getConfig();
if ($config['process_in_background']) {
$this->startBackgroundJob('import');
@@ -526,6 +527,9 @@ class FeedsSource extends FeedsConfigurable {
if (!empty($record->state)) {
$this->state = unserialize($record->state);
}
+ if (!is_array($this->state)) {
+ $this->state = array();
+ }
if (!empty($record->fetcher_result)) {
$this->fetcher_result = unserialize($record->fetcher_result);
}
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/libraries/ParserCSV.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/libraries/ParserCSV.inc
index 6a3ff70..4ddc77a 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/libraries/ParserCSV.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/libraries/ParserCSV.inc
@@ -83,6 +83,7 @@ class ParserCSV {
$this->startByte = 0;
$this->lineLimit = 0;
$this->lastLinePos = 0;
+ ini_set('auto_detect_line_endings', TRUE);
}
/**
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/libraries/common_syndication_parser.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/libraries/common_syndication_parser.inc
index 1b7ef61..9589950 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/libraries/common_syndication_parser.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/libraries/common_syndication_parser.inc
@@ -19,12 +19,7 @@
* stdClass The structured datas extracted from the feed.
*/
function common_syndication_parser_parse($string) {
- if (!defined('LIBXML_VERSION') || (version_compare(phpversion(), '5.1.0', '<'))) {
- @ $xml = simplexml_load_string($string, NULL);
- }
- else {
- @ $xml = simplexml_load_string($string, NULL, LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NOCDATA);
- }
+ @ $xml = simplexml_load_string($string, NULL, LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NOCDATA);
// Got a malformed XML.
if ($xml === FALSE || is_null($xml)) {
@@ -262,9 +257,8 @@ function _parser_common_syndication_RDF10_parse($feed_XML) {
'rss' => 'http://purl.org/rss/1.0/',
);
- // Get all namespaces declared in the feed element, with special handling
- // for PHP versions prior to 5.1.2 as they don't handle namespaces.
- $namespaces = version_compare(phpversion(), '5.1.2', '<') ? array() : $feed_XML->getNamespaces(TRUE);
+ // Get all namespaces declared in the feed element.
+ $namespaces = $feed_XML->getNamespaces(TRUE);
// Process the <rss:channel> resource containing feed metadata:
foreach ($feed_XML->children($canonical_namespaces['rss'])->channel as $rss_channel) {
@@ -379,11 +373,9 @@ function _parser_common_syndication_RSS20_parse($feed_XML) {
$category = $news->xpath('category');
// Get children for current namespace.
- if (version_compare(phpversion(), '5.1.2', '>')) {
- $content = (array)$news->children($ns["content"]);
- $dc = (array)$news->children($ns["dc"]);
- $georss = (array)$news->children($ns["georss"]);
- }
+ $content = (array)$news->children($ns["content"]);
+ $dc = (array)$news->children($ns["dc"]);
+ $georss = (array)$news->children($ns["georss"]);
$news = (array) $news;
$news['category'] = $category;
@@ -505,12 +497,25 @@ function _parser_common_syndication_RSS20_parse($feed_XML) {
*/
function _parser_common_syndication_parse_date($date_str) {
// PHP < 5.3 doesn't like the GMT- notation for parsing timezones.
- $date_str = str_replace("GMT-", "-", $date_str);
- $date_str = str_replace("GMT+", "+", $date_str);
+ $date_str = str_replace('GMT-', '-', $date_str);
+ $date_str = str_replace('GMT+', '+', $date_str);
$parsed_date = strtotime($date_str);
+
if ($parsed_date === FALSE || $parsed_date == -1) {
$parsed_date = _parser_common_syndication_parse_w3cdtf($date_str);
}
+
+ if (($parsed_date === FALSE || $parsed_date == -1)) {
+ // PHP does not support the UT timezone. Fake it. The system that generated
+ // this, Google Groups, probably meant UTC.
+ $date_str = strtolower(trim($date_str));
+ $last_three = substr($date_str, strlen($date_str) - 3, 3);
+
+ if ($last_three == ' ut') {
+ $parsed_date = strtotime($date_str . 'c');
+ }
+ }
+
return $parsed_date === FALSE ? time() : $parsed_date;
}
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/libraries/http_request.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/libraries/http_request.inc
index 44f4fb5..1ed19c2 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/libraries/http_request.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/libraries/http_request.inc
@@ -24,8 +24,10 @@ define('HTTP_REQUEST_PCRE_TAG_ATTRIBUTES', '/[\x09\x0A\x0B\x0C\x0D\x20]+([^\x09\
class HRCurlException extends Exception {}
/**
- * Discover RSS or atom feeds at the given URL. If document in given URL is an
- * HTML document, function attempts to discover RSS or Atom feeds.
+ * Discovers RSS or atom feeds at the given URL.
+ *
+ * If document in given URL is an HTML document, function attempts to discover
+ * RSS or Atom feeds.
*
* @param string $url
* The url of the feed to retrieve.
@@ -77,11 +79,13 @@ function http_request_get_common_syndication($url, $settings = NULL) {
* If the URL uses authentication, supply the password.
* @param bool $accept_invalid_cert
* Whether to accept invalid certificates.
-
+ * @param integer $timeout
+ * Timeout in seconds to wait for an HTTP get request to finish.
+ *
* @return stdClass
* An object that describes the data downloaded from $url.
*/
-function http_request_get($url, $username = NULL, $password = NULL, $accept_invalid_cert = FALSE) {
+function http_request_get($url, $username = NULL, $password = NULL, $accept_invalid_cert = FALSE, $timeout = NULL) {
// Intra-pagedownload cache, avoid to download the same content twice within
// one page download (it's possible, compatible and parse calls).
static $download_cache = array();
@@ -89,6 +93,9 @@ function http_request_get($url, $username = NULL, $password = NULL, $accept_inva
return $download_cache[$url];
}
+ // Determine request timeout.
+ $request_timeout = !empty($timeout) ? $timeout : variable_get('http_request_timeout', 30);
+
if (!$username && valid_url($url, TRUE)) {
// Handle password protected feeds.
$url_parts = parse_url($url);
@@ -134,6 +141,7 @@ function http_request_get($url, $username = NULL, $password = NULL, $accept_inva
if ($curl) {
$headers[] = 'User-Agent: Drupal (+http://drupal.org/)';
$result = new stdClass();
+ $result->headers = array();
// Parse the URL and make sure we can handle the schema.
// cURL can only support either http:// or https://.
@@ -149,6 +157,7 @@ function http_request_get($url, $username = NULL, $password = NULL, $accept_inva
case 'https':
// Valid scheme.
break;
+
default:
$result->error = 'invalid schema ' . $uri['scheme'];
$result->code = -1003;
@@ -168,7 +177,7 @@ function http_request_get($url, $username = NULL, $password = NULL, $accept_inva
curl_setopt($download, CURLOPT_HEADER, TRUE);
curl_setopt($download, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($download, CURLOPT_ENCODING, '');
- curl_setopt($download, CURLOPT_TIMEOUT, variable_get('http_request_timeout', 30));
+ curl_setopt($download, CURLOPT_TIMEOUT, $request_timeout);
if ($accept_invalid_cert) {
curl_setopt($download, CURLOPT_SSL_VERIFYPEER, 0);
}
@@ -179,7 +188,7 @@ function http_request_get($url, $username = NULL, $password = NULL, $accept_inva
t('cURL error (@code) @error for @url', array(
'@code' => curl_errno($download),
'@error' => curl_error($download),
- '@url' => $url
+ '@url' => $url,
)), curl_errno($download)
);
}
@@ -189,8 +198,8 @@ function http_request_get($url, $username = NULL, $password = NULL, $accept_inva
$result->data = substr($data, $header_size);
$headers = preg_split("/(\r\n){2}/", $header);
$header_lines = preg_split("/\r\n|\n|\r/", end($headers));
- $result->headers = array();
- array_shift($header_lines); // skip HTTP response status
+ // Skip HTTP response status.
+ array_shift($header_lines);
while ($line = trim(array_shift($header_lines))) {
list($header, $value) = explode(':', $line, 2);
@@ -212,7 +221,8 @@ function http_request_get($url, $username = NULL, $password = NULL, $accept_inva
}
}
else {
- $result = drupal_http_request($url, array('headers' => $headers, 'timeout' => variable_get('http_request_timeout', 30)));
+ $result = drupal_http_request($url, array('headers' => $headers, 'timeout' => $request_timeout));
+ $result->headers = isset($result->headers) ? $result->headers : array();
}
$result->code = isset($result->code) ? $result->code : 200;
@@ -228,7 +238,7 @@ function http_request_get($url, $username = NULL, $password = NULL, $accept_inva
// It's a tragedy, this file must exist and contain good data.
// In this case, clear cache and repeat.
cache_clear_all('feeds_http_download_' . md5($url), 'cache');
- return http_request_get($url, $username, $password);
+ return http_request_get($url, $username, $password, $accept_invalid_cert, $request_timeout);
}
}
@@ -243,7 +253,7 @@ function http_request_get($url, $username = NULL, $password = NULL, $accept_inva
* Decides if it's possible to use cURL or not.
*
* @return bool
- * TRUE if curl is available, FALSE otherwise.
+ * TRUE if cURL is available, FALSE otherwise.
*/
function http_request_use_curl() {
// Allow site administrators to choose to not use cURL.
@@ -267,13 +277,13 @@ function http_request_clear_cache($url) {
* Returns if the provided $content_type is a feed.
*
* @param string $content_type
- * The Content-Type header.
+ * The Content-Type header.
*
* @param string $data
- * The actual data from the http request.
+ * The actual data from the http request.
*
* @return bool
- * Returns TRUE if this is a parsable feed.
+ * Returns TRUE if this is a parsable feed.
*/
function http_request_is_feed($content_type, $data) {
$pos = strpos($content_type, ';');
@@ -294,10 +304,10 @@ function http_request_is_feed($content_type, $data) {
* Finds potential feed tags in the HTML document.
*
* @param string $html
- * The html string to search.
+ * The html string to search.
*
* @return array
- * An array of href to feeds.
+ * An array of href to feeds.
*/
function http_request_find_feeds($html) {
$matches = array();
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/mappers/date.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/mappers/date.inc
index 3de6a69..9344d27 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/mappers/date.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/mappers/date.inc
@@ -43,20 +43,26 @@ function date_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_nam
* The value to be mapped. Should be either a (flexible) date string
* or a FeedsDateTimeElement object.
*
- * @todo Support array of values for dates.
*/
function date_feeds_set_target($source, $entity, $target, $feed_element) {
list($field_name, $sub_field) = explode(':', $target, 2);
if (!($feed_element instanceof FeedsDateTimeElement)) {
- if (is_array($feed_element)) {
- $feed_element = $feed_element[0];
+ if (!is_array($feed_element)) {
+ $feed_element = array($feed_element);
}
- if ($sub_field == 'end') {
- $feed_element = new FeedsDateTimeElement(NULL, $feed_element);
- }
- else {
- $feed_element = new FeedsDateTimeElement($feed_element, NULL);
+ $delta = 0;
+ foreach ($feed_element as $f) {
+ if (empty($f) || !is_numeric($f) && !date_create($f)) {
+ $array_element = new FeedsDateTimeElement(NULL, NULL);
+ }
+ elseif ($sub_field == 'end') {
+ $array_element = new FeedsDateTimeElement(NULL, $f);
+ }
+ else {
+ $array_element = new FeedsDateTimeElement($f, NULL);
+ }
+ $array_element->buildDateField($entity, $field_name, $delta);
+ $delta++;
}
}
- $feed_element->buildDateField($entity, $field_name);
}
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/mappers/file.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/mappers/file.inc
index 2cc5dc3..646d055 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/mappers/file.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/mappers/file.inc
@@ -60,14 +60,15 @@ function file_feeds_set_target($source, $entity, $target, $value) {
return;
}
+ $entity_type = $source->importer->processor->entityType();
+
// Determine file destination.
// @todo This needs review and debugging.
- list($entity_id, $vid, $bundle_name) = entity_extract_ids($entity->feeds_item->entity_type, $entity);
- $instance_info = field_info_instance($entity->feeds_item->entity_type, $target, $bundle_name);
+ $instance_info = field_info_instance($entity_type, $target, $source->importer->processor->bundle());
$info = field_info_field($target);
$data = array();
if (!empty($entity->uid)) {
- $data[$entity->feeds_item->entity_type] = $entity;
+ $data[$entity_type] = $entity;
}
$destination = file_field_widget_uri($info, $instance_info, $data);
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/mappers/taxonomy.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/mappers/taxonomy.inc
index 201dff6..02ac54e 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/mappers/taxonomy.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/mappers/taxonomy.inc
@@ -2,13 +2,26 @@
/**
* @file
- * Mapper that exposes a node's taxonomy vocabularies as mapping targets.
+ * On behalf implementation of Feeds mapping API for taxonomy.module.
*/
/**
+ * Search by term name.
+ */
+define('FEEDS_TAXONOMY_SEARCH_TERM_NAME', 0);
+
+/**
+ * Search by term id.
+ */
+define('FEEDS_TAXONOMY_SEARCH_TERM_ID', 1);
+
+/**
+ * Search by GUID.
+ */
+define('FEEDS_TAXONOMY_SEARCH_TERM_GUID', 2);
+
+/**
* Implements hook_feeds_parser_sources_alter().
- *
- * @todo: Upgrade to 7.
*/
function taxonomy_feeds_parser_sources_alter(&$sources, $content_type) {
if (!empty($content_type)) {
@@ -36,6 +49,7 @@ function taxonomy_feeds_get_source(FeedsSource $source, FeedsParserResult $resul
$result[] = new FeedsTermElement($term);
}
}
+
return $result;
}
}
@@ -50,7 +64,9 @@ function taxonomy_feeds_processor_targets_alter(&$targets, $entity_type, $bundle
$targets[$name] = array(
'name' => check_plain($instance['label']),
'callback' => 'taxonomy_feeds_set_target',
- 'description' => t('The @label field of the node.', array('@label' => $instance['label'])),
+ 'description' => t('The @label field of the entity.', array('@label' => $instance['label'])),
+ 'summary_callback' => 'taxonomy_feeds_summary_callback',
+ 'form_callback' => 'taxonomy_feeds_form_callback',
);
}
}
@@ -61,8 +77,10 @@ function taxonomy_feeds_processor_targets_alter(&$targets, $entity_type, $bundle
*
* @todo Do not create new terms for non-autotag fields.
*/
-function taxonomy_feeds_set_target($source, $entity, $target, $terms) {
- if (empty($terms)) {
+function taxonomy_feeds_set_target($source, $entity, $target, $terms, $mapping = array()) {
+
+ // Allow mapping the string '0' to a term name.
+ if (empty($terms) && $terms != 0) {
return;
}
@@ -71,42 +89,98 @@ function taxonomy_feeds_set_target($source, $entity, $target, $terms) {
$terms = array($terms);
}
+ // Add in default values.
+ $mapping += array(
+ 'term_search' => FEEDS_TAXONOMY_SEARCH_TERM_NAME,
+ 'autocreate' => FALSE,
+ );
+
$info = field_info_field($target);
- // See http://drupal.org/node/881530
- if (isset($info['settings']['allowed_values'][0]['vocabulary'])) {
- $vocabulary = taxonomy_vocabulary_machine_name_load($info['settings']['allowed_values'][0]['vocabulary']);
+ $cache = &drupal_static(__FUNCTION__);
+ if (!isset($cache['allowed_values'][$target])) {
+ $cache['allowed_values'][$target] = taxonomy_allowed_values($info);
}
- else {
- $vocabulary = taxonomy_vocabulary_load($info['settings']['allowed_values'][0]['vid']);
+
+ if (!isset($cache['allowed_vocabularies'][$target])) {
+ foreach ($info['settings']['allowed_values'] as $tree) {
+ if ($vocabulary = taxonomy_vocabulary_machine_name_load($tree['vocabulary'])) {
+ $cache['allowed_vocabularies'][$target][$vocabulary->vid] = $vocabulary->machine_name;
+ }
+ }
}
- $i = 0;
- $entity->$target = isset($entity->$target) ? $entity->$target : array();
+ $query = new EntityFieldQuery();
+ $query->entityCondition('entity_type', 'taxonomy_term')
+ ->entityCondition('bundle', $cache['allowed_vocabularies'][$target])
+ ->range(0, 1);
+
+
+ $field = isset($entity->$target) ? $entity->$target : array('und' => array());
+
+ // Allow for multiple mappings to the same target.
+ $delta = count($field['und']);
+
+ // Iterate over all values.
foreach ($terms as $term) {
- $tid = 0;
+
+ if ($info['cardinality'] == $delta) {
+ break;
+ }
+
+ $tid = FALSE;
+
+ // FeedsTermElement already is a term.
if ($term instanceof FeedsTermElement) {
$tid = $term->tid;
}
- elseif (is_numeric($term)) {
- $tid = $term;
- }
- elseif (is_string($term)) {
- $tid = taxonomy_term_check_term($term, $vocabulary->vid);
- }
- if ($tid) {
- $entity->{$target}['und'][$i]['tid'] = $tid;
+ else {
+ switch ($mapping['term_search']) {
+
+ // Lookup by name.
+ case FEEDS_TAXONOMY_SEARCH_TERM_NAME:
+ $name_query = clone $query;
+ if ($tids = $name_query->propertyCondition('name', $term)->execute()) {
+ $tid = key($tids['taxonomy_term']);
+ }
+ elseif ($mapping['autocreate']) {
+ $term = (object) array(
+ 'name' => $term,
+ 'vid' => key($cache['allowed_vocabularies'][$target]),
+ 'vocabulary_machine_name' => reset($cache['allowed_vocabularies'][$target]),
+ );
+ taxonomy_term_save($term);
+ $tid = $term->tid;
+ // Add to the list of allowed values.
+ $cache['allowed_values'][$target][$tid] = $term->name;
+ }
+ break;
+
+ // Lookup by tid.
+ case FEEDS_TAXONOMY_SEARCH_TERM_ID:
+ if (is_numeric($term)) {
+ $tid = $term;
+ }
+ break;
+
+ // Lookup by GUID.
+ case FEEDS_TAXONOMY_SEARCH_TERM_GUID:
+ $tid = taxonomy_feeds_term_lookup_term_by_guid($term);
+ break;
+ }
}
- if ($info['cardinality'] == 1) {
- break;
+ if ($tid && isset($cache['allowed_values'][$target][$tid])) {
+ $field['und'][$delta]['tid'] = $tid;
+ $delta++;
}
- $i++;
}
+
+ $entity->$target = $field;
}
/**
- * Find all terms associated with the given node, within one vocabulary.
+ * Finds all terms associated with the given node, within one vocabulary.
*/
function taxonomy_feeds_node_get_terms($node, $key = 'tid') {
$terms = &drupal_static(__FUNCTION__);
@@ -118,7 +192,7 @@ function taxonomy_feeds_node_get_terms($node, $key = 'tid') {
foreach ($fields as $field_name => $field) {
if ($field['type'] == 'taxonomy_term_reference' && field_info_instance('node', $field_name, $node->type)) {
if (($items = field_get_items('node', $node, $field_name)) && is_array($items)) {
- $tids = array_merge($tids, array_map('_taxonomy_extract_tid', $items));
+ $tids = array_merge($tids, array_map('_taxonomy_feeds_extract_tid', $items));
}
}
}
@@ -134,53 +208,106 @@ function taxonomy_feeds_node_get_terms($node, $key = 'tid') {
}
/**
- * Helper function used in taxonomy_feeds_node_get_terms(). Extracts
- * tid from array item returned by field_get_items().
+ * Extracts tid from array item returned by field_get_items().
*
- * @param $item tid information in a form of single element array (key == 'tid', value == tid we're looking for)
+ * @param array $item
+ * Tid information in the form of a single element array
+ * (key == 'tid', value == tid we're looking for)
*
- * @return tid extracted from $item.
+ * @return int
+ * Term id extracted from $item.
*
* @see taxonomy_feeds_node_get_terms()
* @see field_get_items()
*/
-function _taxonomy_extract_tid($item) {
+function _taxonomy_feeds_extract_tid($item) {
return $item['tid'];
}
/**
- * Checks whether a term identified by name and vocabulary exists. Creates a
- * new term if it does not exist.
+ * Looks up a term by GUID, assumes SQL storage backend.
+ *
+ * @param string $guid
+ * The Feeds GUID to compare against.
+ *
+ * @return int|FALSE
+ * The term id, or FALSE if one was not found.
+ */
+function taxonomy_feeds_term_lookup_term_by_guid($guid) {
+ return db_select('feeds_item')
+ ->fields('feeds_item', array('entity_id'))
+ ->condition('entity_type', 'taxonomy_term')
+ ->condition('guid', $guid)
+ ->execute()
+ ->fetchField();
+}
+
+/**
+ * Mapping configuration summary for taxonomy.module.
*
- * @param $name
- * A term name.
- * @param $vid
- * A vocabulary id.
+ * @param array $mapping
+ * Associative array of the mapping settings.
+ * @param array $target
+ * Array of target settings, as defined by the processor or
+ * hook_feeds_processor_targets_alter().
+ * @param array $form
+ * The whole mapping form.
+ * @param array $form_state
+ * The form state of the mapping form.
*
- * @return
- * A term id.
+ * @return string
+ * Returns, as a string that may contain HTML, the summary to display while
+ * the full form isn't visible.
+ * If the return value is empty, no summary and no option to view the form
+ * will be displayed.
*/
-function taxonomy_term_check_term($name, $vid) {
- $name = trim($name);
- $term = taxonomy_term_lookup_term($name, $vid);
- if (empty($term)) {
- $term = new stdClass();
- $term->name = $name;
- $term->vid = $vid;
- taxonomy_term_save($term);
- return $term->tid;
+function taxonomy_feeds_summary_callback($mapping, $target, $form, $form_state) {
+ $options = _taxonomy_feeds_form_callback_options();
+ if (empty($mapping['term_search'])) {
+ return t('Search taxonomy terms by: <strong>@search</strong>', array('@search' => $options[FEEDS_TAXONOMY_SEARCH_TERM_NAME]));
}
- return $term->tid;
+ return t('Search taxonomy terms by: <strong>@search</strong>', array('@search' => $options[$mapping['term_search']]));
}
/**
- * Looks up a term, assumes SQL storage backend.
+ * Settings form callback.
+ *
+ * @return array
+ * The per mapping configuration form. Once the form is saved, $mapping will
+ * be populated with the form values.
*/
-function taxonomy_term_lookup_term($name, $vid) {
- return db_select('taxonomy_term_data', 'td')
- ->fields('td', array('tid', 'name'))
- ->condition('name', $name)
- ->condition('vid', $vid)
- ->execute()
- ->fetchObject();
-} \ No newline at end of file
+function taxonomy_feeds_form_callback($mapping, $target, $form, $form_state) {
+ return array(
+ 'term_search' => array(
+ '#type' => 'select',
+ '#title' => t('Search taxonomy terms by'),
+ '#options' => _taxonomy_feeds_form_callback_options(),
+ '#default_value' => !empty($mapping['term_search']) ? $mapping['term_search'] : FEEDS_TAXONOMY_SEARCH_TERM_NAME,
+ ),
+ 'autocreate' => array(
+ '#type' => 'checkbox',
+ '#title' => t('Auto create'),
+ '#description' => t("Create the term if it doesn't exist."),
+ '#default_value' => !empty($mapping['autocreate']) ? $mapping['autocreate'] : 0,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name$="[settings][term_search]"]' => array('value' => FEEDS_TAXONOMY_SEARCH_TERM_NAME),
+ ),
+ ),
+ ),
+ );
+}
+
+/**
+ * Returns the list of available term search methods.
+ *
+ * @return array
+ * An array of taxonomy search option titles.
+ */
+function _taxonomy_feeds_form_callback_options() {
+ return array(
+ FEEDS_TAXONOMY_SEARCH_TERM_NAME => 'Term name',
+ FEEDS_TAXONOMY_SEARCH_TERM_ID => 'Term ID',
+ FEEDS_TAXONOMY_SEARCH_TERM_GUID => 'GUID',
+ );
+}
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/mappers/text.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/mappers/text.inc
index 3e51ffc..48447d7 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/mappers/text.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/mappers/text.inc
@@ -66,11 +66,12 @@ function text_feeds_set_target($source, $entity, $target, $value) {
if (is_scalar($v)) {
$field['und'][$delta]['value'] = $v;
- $delta++;
if (isset($format)) {
$field['und'][$delta]['format'] = $format;
}
+
+ $delta++;
}
}
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsCSVParser.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsCSVParser.inc
index 337dd68..7044440 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsCSVParser.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsCSVParser.inc
@@ -123,7 +123,7 @@ class FeedsCSVParser extends FeedsParser {
$sources = $uniques = array();
foreach ($mappings as $mapping) {
$sources[] = check_plain($mapping['source']);
- if ($mapping['unique']) {
+ if (!empty($mapping['unique'])) {
$uniques[] = check_plain($mapping['source']);
}
}
@@ -132,7 +132,19 @@ class FeedsCSVParser extends FeedsParser {
$items = array();
$items[] = format_plural(count($uniques), t('Column <strong>!column</strong> is mandatory and considered unique: only one item per !column value will be created.', array('!column' => implode(', ', $uniques))), t('Columns <strong>!columns</strong> are mandatory and values in these columns are considered unique: only one entry per value in one of these column will be created.', array('!columns' => implode(', ', $uniques))));
$items[] = l(t('Download a template'), 'import/' . $this->id . '/template');
- $form['help']['#markup'] = '<div class="help"><p>' . $output . '</p>' . theme('item_list', array('items' => $items)) . '</div>';
+ $form['help'] = array(
+ '#prefix' => '<div class="help">',
+ '#suffix' => '</div>',
+ 'description' => array(
+ '#prefix' => '<p>',
+ '#markup' => $output,
+ '#suffix' => '</p>',
+ ),
+ 'list' => array(
+ '#theme' => 'item_list',
+ '#items' => $items,
+ ),
+ );
$form['delimiter'] = array(
'#type' => 'select',
'#title' => t('Delimiter'),
@@ -141,6 +153,8 @@ class FeedsCSVParser extends FeedsParser {
',' => ',',
';' => ';',
'TAB' => 'TAB',
+ '|' => '|',
+ '+' => '+',
),
'#default_value' => isset($source_config['delimiter']) ? $source_config['delimiter'] : ',',
);
@@ -176,6 +190,8 @@ class FeedsCSVParser extends FeedsParser {
',' => ',',
';' => ';',
'TAB' => 'TAB',
+ '|' => '|',
+ '+' => '+',
),
'#default_value' => $this->config['delimiter'],
);
@@ -192,7 +208,7 @@ class FeedsCSVParser extends FeedsParser {
$mappings = feeds_importer($this->id)->processor->config['mappings'];
$sources = $uniques = array();
foreach ($mappings as $mapping) {
- if ($mapping['unique']) {
+ if (!empty($mapping['unique'])) {
$uniques[] = check_plain($mapping['source']);
}
else {
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsFetcher.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsFetcher.inc
index 4bba44d..33457de 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsFetcher.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsFetcher.inc
@@ -114,6 +114,13 @@ class FeedsFetcherResult extends FeedsResult {
abstract class FeedsFetcher extends FeedsPlugin {
/**
+ * Implements FeedsPlugin::pluginType().
+ */
+ public function pluginType() {
+ return 'fetcher';
+ }
+
+ /**
* Fetch content from a source and return it.
*
* Every class that extends FeedsFetcher must implement this method.
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsFileFetcher.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsFileFetcher.inc
index 03ef72a..5e8e116 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsFileFetcher.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsFileFetcher.inc
@@ -19,7 +19,7 @@ class FeedsFileFetcherResult extends FeedsFetcherResult {
}
/**
- * Overrides parent::getRaw();
+ * Overrides parent::getRaw().
*/
public function getRaw() {
return $this->sanitizeRaw(file_get_contents($this->file_path));
@@ -69,14 +69,14 @@ class FeedsFileFetcher extends FeedsFetcher {
}
/**
- * Return an array of files in a directory.
+ * Returns an array of files in a directory.
*
- * @param $dir
+ * @param string $dir
* A stream wreapper URI that is a directory.
*
- * @return
- * An array of stream wrapper URIs pointing to files. The array is empty
- * if no files could be found. Never contains directories.
+ * @return array
+ * An array of stream wrapper URIs pointing to files. The array is empty if
+ * no files could be found. Never contains directories.
*/
protected function listFiles($dir) {
$dir = file_stream_wrapper_uri_normalize($dir);
@@ -118,7 +118,7 @@ class FeedsFileFetcher extends FeedsFetcher {
$form['source'] = array(
'#type' => 'textfield',
'#title' => t('File'),
- '#description' => t('Specify a path to a file or a directory. Path must start with @scheme://', array('@scheme' => file_default_scheme())),
+ '#description' => t('Specify a path to a file or a directory. Prefix the path with a scheme. Available schemes: @schemes.', array('@schemes' => implode(', ', $this->config['allowed_schemes']))),
'#default_value' => empty($source_config['source']) ? '' : $source_config['source'],
);
}
@@ -126,34 +126,53 @@ class FeedsFileFetcher extends FeedsFetcher {
}
/**
- * Override parent::sourceFormValidate().
+ * Overrides parent::sourceFormValidate().
*/
public function sourceFormValidate(&$values) {
$values['source'] = trim($values['source']);
- $feed_dir = 'public://feeds';
- file_prepare_directory($feed_dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
+ if (empty($this->config['direct'])) {
- // If there is a file uploaded, save it, otherwise validate input on
- // file.
- // @todo: Track usage of file, remove file when removing source.
- if ($file = file_save_upload('feeds', array('file_validate_extensions' => array(0 => $this->config['allowed_extensions'])), $feed_dir)) {
- $values['source'] = $file->uri;
- $values['file'] = $file;
- }
- elseif (empty($values['source'])) {
- form_set_error('feeds][source', t('Upload a file first.'));
+ $feed_dir = $this->config['directory'];
+
+ if (!file_prepare_directory($feed_dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
+ if (user_access('administer feeds')) {
+ $plugin_key = feeds_importer($this->id)->config[$this->pluginType()]['plugin_key'];
+ $link = url('admin/structure/feeds/' . $this->id . '/settings/' . $plugin_key);
+ form_set_error('feeds][FeedsFileFetcher][source', t('Upload failed. Please check the upload <a href="@link">settings.</a>', array('@link' => $link)));
+ }
+ else {
+ form_set_error('feeds][FeedsFileFetcher][source', t('Upload failed. Please contact your site administrator.'));
+ }
+ watchdog('feeds', 'The upload directory %directory required by a feed could not be created or is not accessible. A newly uploaded file could not be saved in this directory as a consequence, and the upload was canceled.', array('%directory' => $feed_dir));
+ }
+ // Validate and save uploaded file.
+ elseif ($file = file_save_upload('feeds', array('file_validate_extensions' => array(0 => $this->config['allowed_extensions'])), $feed_dir)) {
+ $values['source'] = $file->uri;
+ $values['file'] = $file;
+ }
+ elseif (empty($values['source'])) {
+ form_set_error('feeds][FeedsFileFetcher][source', t('Please upload a file.'));
+ }
+ else {
+ // File present from previous upload. Nothing to validate.
+ }
}
- // If a file has not been uploaded and $values['source'] is not empty, make
- // sure that this file is within Drupal's files directory as otherwise
- // potentially any file that the web server has access to could be exposed.
- elseif (strpos($values['source'], file_default_scheme()) !== 0) {
- form_set_error('feeds][source', t('File needs to reside within the site\'s file directory, its path needs to start with @scheme://.', array('@scheme' => file_default_scheme())));
+ else {
+ // Check if chosen url scheme is allowed.
+ $scheme = file_uri_scheme($values['source']);
+ if (!$scheme || !in_array($scheme, $this->config['allowed_schemes'])) {
+ form_set_error('feeds][FeedsFileFetcher][source', t("The file needs to reside within the site's files directory, its path needs to start with scheme://. Available schemes: @schemes.", array('@schemes' => implode(', ', $this->config['allowed_schemes']))));
+ }
+ // Check wether the given path exists.
+ elseif (!file_exists($values['source'])) {
+ form_set_error('feeds][FeedsFileFetcher][source', t('The specified file or directory does not exist.'));
+ }
}
}
/**
- * Override parent::sourceSave().
+ * Overrides parent::sourceSave().
*/
public function sourceSave(FeedsSource $source) {
$source_config = $source->getConfigFor($this);
@@ -176,7 +195,7 @@ class FeedsFileFetcher extends FeedsFetcher {
}
/**
- * Override parent::sourceDelete().
+ * Overrides parent::sourceDelete().
*/
public function sourceDelete(FeedsSource $source) {
$source_config = $source->getConfigFor($this);
@@ -186,17 +205,22 @@ class FeedsFileFetcher extends FeedsFetcher {
}
/**
- * Override parent::configDefaults().
+ * Overrides parent::configDefaults().
*/
public function configDefaults() {
+ $schemes = $this->getSchemes();
+ $scheme = in_array('private', $schemes) ? 'private' : 'public';
+
return array(
'allowed_extensions' => 'txt csv tsv xml opml',
'direct' => FALSE,
+ 'directory' => $scheme . '://feeds',
+ 'allowed_schemes' => $schemes,
);
}
/**
- * Override parent::configForm().
+ * Overrides parent::configForm().
*/
public function configForm(&$form_state) {
$form = array();
@@ -214,16 +238,112 @@ class FeedsFileFetcher extends FeedsFetcher {
are already on the server.'),
'#default_value' => $this->config['direct'],
);
+ $form['directory'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Upload directory'),
+ '#description' => t('Directory where uploaded files get stored. Prefix the path with a scheme. Available schemes: @schemes.', array('@schemes' => implode(', ', $this->getSchemes()))),
+ '#default_value' => $this->config['directory'],
+ '#states' => array(
+ 'visible' => array(':input[name="direct"]' => array('checked' => FALSE)),
+ 'required' => array(':input[name="direct"]' => array('checked' => FALSE)),
+ ),
+ );
+ if ($options = $this->getSchemeOptions()) {
+ $form['allowed_schemes'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Allowed schemes'),
+ '#default_value' => $this->config['allowed_schemes'],
+ '#options' => $options,
+ '#description' => t('Select the schemes you want to allow for direct upload.'),
+ '#states' => array(
+ 'visible' => array(':input[name="direct"]' => array('checked' => TRUE)),
+ ),
+ );
+ }
+
return $form;
}
/**
- * Helper. Deletes a file.
+ * Overrides parent::configFormValidate().
+ *
+ * Ensure that the chosen directory is accessible.
+ */
+ public function configFormValidate(&$values) {
+
+ $values['directory'] = trim($values['directory']);
+ $values['allowed_schemes'] = array_filter($values['allowed_schemes']);
+
+ if (!$values['direct']) {
+ // Ensure that the upload directory field is not empty when not in
+ // direct-mode.
+ if (!$values['directory']) {
+ form_set_error('directory', t('Please specify an upload directory.'));
+ // Do not continue validating the directory if none was specified.
+ return;
+ }
+
+ // Validate the URI scheme of the upload directory.
+ $scheme = file_uri_scheme($values['directory']);
+ if (!$scheme || !in_array($scheme, $this->getSchemes())) {
+ form_set_error('directory', t('Please enter a valid scheme into the directory location.'));
+
+ // Return here so that attempts to create the directory below don't
+ // throw warnings.
+ return;
+ }
+
+ // Ensure that the upload directory exists.
+ if (!file_prepare_directory($values['directory'], FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
+ form_set_error('directory', t('The chosen directory does not exist and attempts to create it failed.'));
+ }
+ }
+ }
+
+ /**
+ * Deletes a file.
+ *
+ * @param int $fid
+ * The file id.
+ * @param int $feed_nid
+ * The feed node's id, or 0 if a standalone feed.
+ *
+ * @return bool|array
+ * TRUE for success, FALSE in the event of an error, or an array if the file
+ * is being used by any modules.
+ *
+ * @see file_delete()
*/
protected function deleteFile($fid, $feed_nid) {
if ($file = file_load($fid)) {
file_usage_delete($file, 'feeds', get_class($this), $feed_nid);
- file_delete($file);
+ return file_delete($file);
}
+ return FALSE;
}
+
+ /**
+ * Returns available schemes.
+ *
+ * @return array
+ * The available schemes.
+ */
+ protected function getSchemes() {
+ return array_keys(file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE));
+ }
+
+ /**
+ * Returns available scheme options for use in checkboxes or select list.
+ *
+ * @return array
+ * The available scheme array keyed scheme => description
+ */
+ protected function getSchemeOptions() {
+ $options = array();
+ foreach (file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE) as $scheme => $info) {
+ $options[$scheme] = check_plain($scheme . ': ' . $info['description']);
+ }
+ return $options;
+ }
+
}
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsHTTPFetcher.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsHTTPFetcher.inc
index 119c0bf..4e7afc7 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsHTTPFetcher.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsHTTPFetcher.inc
@@ -13,6 +13,7 @@ feeds_include_library('PuSHSubscriber.inc', 'PuSHSubscriber');
class FeedsHTTPFetcherResult extends FeedsFetcherResult {
protected $url;
protected $file_path;
+ protected $timeout;
/**
* Constructor.
@@ -27,12 +28,20 @@ class FeedsHTTPFetcherResult extends FeedsFetcherResult {
*/
public function getRaw() {
feeds_include_library('http_request.inc', 'http_request');
- $result = http_request_get($this->url);
+ $result = http_request_get($this->url, NULL, NULL, NULL, $this->timeout);
if (!in_array($result->code, array(200, 201, 202, 203, 204, 205, 206))) {
throw new Exception(t('Download of @url failed with code !code.', array('@url' => $this->url, '!code' => $result->code)));
}
return $this->sanitizeRaw($result->data);
}
+
+ public function getTimeout() {
+ return $this->timeout;
+ }
+
+ public function setTimeout($timeout) {
+ $this->timeout = $timeout;
+ }
}
/**
@@ -48,7 +57,10 @@ class FeedsHTTPFetcher extends FeedsFetcher {
if ($this->config['use_pubsubhubbub'] && ($raw = $this->subscriber($source->feed_nid)->receive())) {
return new FeedsFetcherResult($raw);
}
- return new FeedsHTTPFetcherResult($source_config['source']);
+ $fetcher_result = new FeedsHTTPFetcherResult($source_config['source']);
+ // When request_timeout is empty, the global value is used.
+ $fetcher_result->setTimeout($this->config['request_timeout']);
+ return $fetcher_result;
}
/**
@@ -95,6 +107,7 @@ class FeedsHTTPFetcher extends FeedsFetcher {
'auto_detect_feeds' => FALSE,
'use_pubsubhubbub' => FALSE,
'designated_hub' => '',
+ 'request_timeout' => NULL,
);
}
@@ -124,6 +137,18 @@ class FeedsHTTPFetcher extends FeedsFetcher {
'edit-use-pubsubhubbub' => array(1),
),
);
+ // Per importer override of global http request timeout setting.
+ $form['request_timeout'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Request timeout'),
+ '#description' => t('Timeout in seconds to wait for an HTTP get request to finish.</br>' .
+ '<b>Note:</b> this setting will override the global setting.</br>' .
+ 'When left empty, the global value is used.'),
+ '#default_value' => $this->config['request_timeout'],
+ '#element_validate' => array('element_validate_integer_positive'),
+ '#maxlength' => 3,
+ '#size'=> 30,
+ );
return $form;
}
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsNodeProcessor.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsNodeProcessor.inc
index d208047..519dfc5 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsNodeProcessor.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsNodeProcessor.inc
@@ -9,6 +9,7 @@
* Creates nodes from feed items.
*/
class FeedsNodeProcessor extends FeedsProcessor {
+
/**
* Define entity type.
*/
@@ -30,10 +31,11 @@ class FeedsNodeProcessor extends FeedsProcessor {
*/
protected function newEntity(FeedsSource $source) {
$node = new stdClass();
- $node->type = $this->config['content_type'];
+ $node->type = $this->bundle();
$node->changed = REQUEST_TIME;
$node->created = REQUEST_TIME;
$node->language = LANGUAGE_NONE;
+ $node->is_new = TRUE;
node_object_prepare($node);
// Populate properties that are set by node_object_prepare().
$node->log = 'Created by FeedsNodeProcessor';
@@ -50,14 +52,12 @@ class FeedsNodeProcessor extends FeedsProcessor {
* @todo Reevaluate the use of node_object_prepare().
*/
protected function entityLoad(FeedsSource $source, $nid) {
- if ($this->config['update_existing'] == FEEDS_UPDATE_EXISTING) {
- $node = node_load($nid, NULL, TRUE);
- }
- else {
- // We're replacing the existing node. Only save the absolutely necessary.
- $node = db_query("SELECT created, nid, vid, type, status FROM {node} WHERE nid = :nid", array(':nid' => $nid))->fetchObject();
+ $node = parent::entityLoad($source, $nid);
+
+ if ($this->config['update_existing'] != FEEDS_UPDATE_EXISTING) {
$node->uid = $this->config['author'];
}
+
node_object_prepare($node);
// Workaround for issue #1247506. See #1245094 for backstory.
@@ -87,7 +87,7 @@ class FeedsNodeProcessor extends FeedsProcessor {
$author = user_load($entity->uid);
- // If the uid was mapped directly, rather than by email or username, it
+ // If the uid was mapped directly, rather than by email or username, it
// could be invalid.
if (!$author) {
$message = 'User %uid is not a valid user.';
@@ -111,13 +111,18 @@ class FeedsNodeProcessor extends FeedsProcessor {
}
/**
+ * Validates a node.
+ */
+ protected function entityValidate($entity) {
+ if (!isset($entity->uid) || !is_numeric($entity->uid)) {
+ $entity->uid = $this->config['author'];
+ }
+ }
+
+ /**
* Save a node.
*/
public function entitySave($entity) {
- // If nid is set and a node with that id doesn't exist, flag as new.
- if (!empty($entity->nid) && !node_load($entity->nid)) {
- $entity->is_new = TRUE;
- }
node_save($entity);
}
@@ -164,10 +169,7 @@ class FeedsNodeProcessor extends FeedsProcessor {
* Override parent::configDefaults().
*/
public function configDefaults() {
- $types = node_type_get_names();
- $type = isset($types['article']) ? 'article' : key($types);
return array(
- 'content_type' => $type,
'expire' => FEEDS_EXPIRE_NEVER,
'author' => 0,
'authorize' => TRUE,
@@ -178,16 +180,8 @@ class FeedsNodeProcessor extends FeedsProcessor {
* Override parent::configForm().
*/
public function configForm(&$form_state) {
- $types = node_type_get_names();
- array_walk($types, 'check_plain');
$form = parent::configForm($form_state);
- $form['content_type'] = array(
- '#type' => 'select',
- '#title' => t('Content type'),
- '#description' => t('Select the content type for the nodes to be created. <strong>Note:</strong> Users with "import !feed_id feeds" permissions will be able to <strong>import</strong> nodes of the content type selected here regardless of the node level permissions. Further, users with "clear !feed_id permissions" will be able to <strong>delete</strong> imported nodes regardless of their node level permissions.', array('!feed_id' => $this->id)),
- '#options' => $types,
- '#default_value' => $this->config['content_type'],
- );
+
$author = user_load($this->config['author']);
$form['author'] = array(
'#type' => 'textfield',
@@ -210,11 +204,6 @@ class FeedsNodeProcessor extends FeedsProcessor {
'#description' => t('Select after how much time nodes should be deleted. The node\'s published date will be used for determining the node\'s age, see Mapping settings.'),
'#default_value' => $this->config['expire'],
);
- $form['update_existing']['#options'] = array(
- FEEDS_SKIP_EXISTING => 'Do not update existing nodes',
- FEEDS_REPLACE_EXISTING => 'Replace existing nodes',
- FEEDS_UPDATE_EXISTING => 'Update existing nodes (slower than replacing them)',
- );
return $form;
}
@@ -251,7 +240,7 @@ class FeedsNodeProcessor extends FeedsProcessor {
case 'feeds_source':
// Get the class of the feed node importer's fetcher and set the source
// property. See feeds_node_update() how $node->feeds gets stored.
- if ($id = feeds_get_importer_id($this->config['content_type'])) {
+ if ($id = feeds_get_importer_id($this->bundle())) {
$class = get_class(feeds_importer($id)->fetcher);
$target_node->feeds[$class]['source'] = $value;
// This effectively suppresses 'import on submission' feature.
@@ -279,9 +268,10 @@ class FeedsNodeProcessor extends FeedsProcessor {
* Return available mapping targets.
*/
public function getMappingTargets() {
- $type = node_type_get_type($this->config['content_type']);
+ $type = node_type_get_type($this->bundle());
+
$targets = parent::getMappingTargets();
- if ($type->has_title) {
+ if ($type && $type->has_title) {
$targets['title'] = array(
'name' => t('Title'),
'description' => t('The title of the node.'),
@@ -339,7 +329,7 @@ class FeedsNodeProcessor extends FeedsProcessor {
}
// If the target content type is a Feed node, expose its source field.
- if ($id = feeds_get_importer_id($this->config['content_type'])) {
+ if ($id = feeds_get_importer_id($this->bundle())) {
$name = feeds_importer($id)->config['name'];
$targets['feeds_source'] = array(
'name' => t('Feed source'),
@@ -351,7 +341,7 @@ class FeedsNodeProcessor extends FeedsProcessor {
// Let other modules expose mapping targets.
self::loadMappers();
$entity_type = $this->entityType();
- $bundle = $this->config['content_type'];
+ $bundle = $this->bundle();
drupal_alter('feeds_processor_targets', $targets, $entity_type, $bundle);
return $targets;
@@ -373,10 +363,10 @@ class FeedsNodeProcessor extends FeedsProcessor {
$nid = db_query("SELECT nid FROM {node} WHERE nid = :nid", array(':nid' => $value))->fetchField();
break;
case 'title':
- $nid = db_query("SELECT nid FROM {node} WHERE title = :title AND type = :type", array(':title' => $value, ':type' => $this->config['content_type']))->fetchField();
+ $nid = db_query("SELECT nid FROM {node} WHERE title = :title AND type = :type", array(':title' => $value, ':type' => $this->bundle()))->fetchField();
break;
case 'feeds_source':
- if ($id = feeds_get_importer_id($this->config['content_type'])) {
+ if ($id = feeds_get_importer_id($this->bundle())) {
$nid = db_query("SELECT fs.feed_nid FROM {node} n JOIN {feeds_source} fs ON n.nid = fs.feed_nid WHERE fs.id = :id AND fs.source = :source", array(':id' => $id, ':source' => $value))->fetchField();
}
break;
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsParser.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsParser.inc
index c492317..13fcaa0 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsParser.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsParser.inc
@@ -54,6 +54,13 @@ class FeedsParserResult extends FeedsResult {
abstract class FeedsParser extends FeedsPlugin {
/**
+ * Implements FeedsPlugin::pluginType().
+ */
+ public function pluginType() {
+ return 'parser';
+ }
+
+ /**
* Parse content fetched by fetcher.
*
* Extending classes must implement this method.
@@ -458,13 +465,13 @@ class FeedsDateTimeElement extends FeedsElement {
* Helper method for buildDateField(). Build a FeedsDateTimeElement object
* from a standard formatted node.
*/
- protected static function readDateField($entity, $field_name) {
+ protected static function readDateField($entity, $field_name, $delta = 0) {
$ret = new FeedsDateTimeElement();
- if (isset($entity->{$field_name}['und'][0]['date']) && $entity->{$field_name}['und'][0]['date'] instanceof FeedsDateTime) {
- $ret->start = $entity->{$field_name}['und'][0]['date'];
+ if (isset($entity->{$field_name}['und'][$delta]['date']) && $entity->{$field_name}['und'][$delta]['date'] instanceof FeedsDateTime) {
+ $ret->start = $entity->{$field_name}['und'][$delta]['date'];
}
- if (isset($entity->{$field_name}['und'][0]['date2']) && $entity->{$field_name}['und'][0]['date2'] instanceof FeedsDateTime) {
- $ret->end = $entity->{$field_name}['und'][0]['date2'];
+ if (isset($entity->{$field_name}['und'][$delta]['date2']) && $entity->{$field_name}['und'][$delta]['date2'] instanceof FeedsDateTime) {
+ $ret->end = $entity->{$field_name}['und'][$delta]['date2'];
}
return $ret;
}
@@ -472,15 +479,17 @@ class FeedsDateTimeElement extends FeedsElement {
/**
* Build a entity's date field from our object.
*
- * @param $entity
+ * @param object $entity
* The entity to build the date field on.
- * @param $field_name
+ * @param str $field_name
* The name of the field to build.
+ * @param int $delta
+ * The delta in the field.
*/
- public function buildDateField($entity, $field_name) {
+ public function buildDateField($entity, $field_name, $delta = 0) {
$info = field_info_field($field_name);
- $oldfield = FeedsDateTimeElement::readDateField($entity, $field_name);
+ $oldfield = FeedsDateTimeElement::readDateField($entity, $field_name, $delta);
// Merge with any preexisting objects on the field; we take precedence.
$oldfield = $this->merge($oldfield);
$use_start = $oldfield->start;
@@ -516,24 +525,24 @@ class FeedsDateTimeElement extends FeedsElement {
$entity->{$field_name} = array('und' => array());
}
if ($use_start) {
- $entity->{$field_name}['und'][0]['timezone'] = $use_start->getTimezone()->getName();
- $entity->{$field_name}['und'][0]['offset'] = $use_start->getOffset();
+ $entity->{$field_name}['und'][$delta]['timezone'] = $use_start->getTimezone()->getName();
+ $entity->{$field_name}['und'][$delta]['offset'] = $use_start->getOffset();
$use_start->setTimezone($db_tz);
- $entity->{$field_name}['und'][0]['date'] = $use_start;
+ $entity->{$field_name}['und'][$delta]['date'] = $use_start;
/**
* @todo the date_type_format line could be simplified based upon a patch
* DO issue #259308 could affect this, follow up on at some point.
* Without this, all granularity info is lost.
* $use_start->format(date_type_format($field['type'], $use_start->granularity));
*/
- $entity->{$field_name}['und'][0]['value'] = $use_start->format(date_type_format($info['type']));
+ $entity->{$field_name}['und'][$delta]['value'] = $use_start->format(date_type_format($info['type']));
}
if ($use_end) {
// Don't ever use end to set timezone (for now)
- $entity->{$field_name}['und'][0]['offset2'] = $use_end->getOffset();
+ $entity->{$field_name}['und'][$delta]['offset2'] = $use_end->getOffset();
$use_end->setTimezone($db_tz);
- $entity->{$field_name}['und'][0]['date2'] = $use_end;
- $entity->{$field_name}['und'][0]['value2'] = $use_end->format(date_type_format($info['type']));
+ $entity->{$field_name}['und'][$delta]['date2'] = $use_end;
+ $entity->{$field_name}['und'][$delta]['value2'] = $use_end->format(date_type_format($info['type']));
}
}
}
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsPlugin.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsPlugin.inc
index be83393..259eedb 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsPlugin.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsPlugin.inc
@@ -30,6 +30,14 @@ abstract class FeedsPlugin extends FeedsConfigurable implements FeedsSourceInter
}
/**
+ * Returns the type of plugin.
+ *
+ * @return string
+ * One of either 'fetcher', 'parser', or 'processor'.
+ */
+ abstract public function pluginType();
+
+ /**
* Save changes to the configuration of this object.
* Delegate saving to parent (= Feed) which will collect
* information from this object by way of getConfig() and store it.
@@ -90,7 +98,7 @@ abstract class FeedsPlugin extends FeedsConfigurable implements FeedsSourceInter
*
* @todo: Use CTools Plugin API.
*/
- protected static function loadMappers() {
+ public static function loadMappers() {
static $loaded = FALSE;
if (!$loaded) {
$path = drupal_get_path('module', 'feeds') . '/mappers';
@@ -203,6 +211,9 @@ abstract class FeedsPlugin extends FeedsConfigurable implements FeedsSourceInter
* Used when a plugin is missing.
*/
class FeedsMissingPlugin extends FeedsPlugin {
+ public function pluginType() {
+ return 'missing';
+ }
public function menuItem() {
return array();
}
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsProcessor.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsProcessor.inc
index 80e54d5..c2b0af5 100755
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsProcessor.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsProcessor.inc
@@ -28,6 +28,14 @@ class FeedsAccessException extends Exception {}
* Abstract class, defines interface for processors.
*/
abstract class FeedsProcessor extends FeedsPlugin {
+
+ /**
+ * Implements FeedsPlugin::pluginType().
+ */
+ public function pluginType() {
+ return 'processor';
+ }
+
/**
* @defgroup entity_api_wrapper Entity API wrapper.
*/
@@ -38,6 +46,37 @@ abstract class FeedsProcessor extends FeedsPlugin {
public abstract function entityType();
/**
+ * Bundle type this processor operates on.
+ *
+ * Defaults to the entity type for entities that do not define bundles.
+ *
+ * @return string|NULL
+ * The bundle type this processor operates on, or NULL if it is undefined.
+ */
+ public function bundle() {
+ return $this->config['bundle'];
+ }
+
+ /**
+ * Provides a list of bundle options for use in select lists.
+ *
+ * @return array
+ * A keyed array of bundle => label.
+ */
+ public function bundleOptions() {
+ $options = array();
+ foreach (field_info_bundles($this->entityType()) as $bundle => $info) {
+ if (!empty($info['label'])) {
+ $options[$bundle] = $info['label'];
+ }
+ else {
+ $options[$bundle] = $bundle;
+ }
+ }
+ return $options;
+ }
+
+ /**
* Create a new entity.
*
* @param $source
@@ -58,8 +97,25 @@ abstract class FeedsProcessor extends FeedsPlugin {
*
* @return
* A new entity object.
+ *
+ * @todo We should be able to batch load these, if we found all of the
+ * existing ids first.
*/
- protected abstract function entityLoad(FeedsSource $source, $entity_id);
+ protected function entityLoad(FeedsSource $source, $entity_id) {
+ if ($this->config['update_existing'] == FEEDS_UPDATE_EXISTING) {
+ $entities = entity_load($this->entityType(), array($entity_id));
+ return reset($entities);
+ }
+
+ $info = $this->entityInfo();
+
+ $args = array(':entity_id' => $entity_id);
+
+ $table = db_escape_table($info['base table']);
+ $key = db_escape_field($info['entity keys']['id']);
+
+ return db_query("SELECT * FROM {" . $table . "} WHERE $key = :entity_id", $args)->fetchObject();
+ }
/**
* Validate an entity.
@@ -127,6 +183,8 @@ abstract class FeedsProcessor extends FeedsPlugin {
$entity_id = $this->existingEntityId($source, $parser_result);
$skip_existing = $this->config['update_existing'] == FEEDS_SKIP_EXISTING;
+ module_invoke_all('feeds_before_update', $source, $item, $entity_id);
+
// If it exists, and we are not updating, pass onto the next item.
if ($entity_id && $skip_existing) {
continue;
@@ -144,20 +202,21 @@ abstract class FeedsProcessor extends FeedsPlugin {
try {
- // Build a new entity.
- if (empty($entity_id)) {
- $entity = $this->newEntity($source);
- $this->newItemInfo($entity, $source->feed_nid, $hash);
- }
-
// Load an existing entity.
- else {
+ if ($entity_id) {
$entity = $this->entityLoad($source, $entity_id);
- // The feeds_item table is always updated with the info for the most recently processed entity.
- // The only carryover is the entity_id.
+ // The feeds_item table is always updated with the info for the most
+ // recently processed entity. The only carryover is the entity_id.
$this->newItemInfo($entity, $source->feed_nid, $hash);
$entity->feeds_item->entity_id = $entity_id;
+ $entity->feeds_item->is_new = FALSE;
+ }
+
+ // Build a new entity.
+ else {
+ $entity = $this->newEntity($source);
+ $this->newItemInfo($entity, $source->feed_nid, $hash);
}
// Set property and field values.
@@ -165,7 +224,7 @@ abstract class FeedsProcessor extends FeedsPlugin {
$this->entityValidate($entity);
// Allow modules to alter the entity before saving.
- module_invoke_all('feeds_presave', $source, $entity, $item);
+ module_invoke_all('feeds_presave', $source, $entity, $item, $entity_id);
if (module_exists('rules')) {
rules_invoke_event('feeds_import_'. $source->importer()->id, $entity);
}
@@ -179,6 +238,10 @@ abstract class FeedsProcessor extends FeedsPlugin {
$this->entitySaveAccess($entity);
$this->entitySave($entity);
+ // Allow modules to perform operations using the saved entity data.
+ // $entity contains the updated entity after saving.
+ module_invoke_all('feeds_after_save', $source, $entity, $item, $entity_id);
+
// Track progress.
if (empty($entity_id)) {
$state->created++;
@@ -192,11 +255,7 @@ abstract class FeedsProcessor extends FeedsPlugin {
catch (Exception $e) {
$state->failed++;
drupal_set_message($e->getMessage(), 'warning');
- $message = $e->getMessage();
- $message .= '<h3>Original item</h3>';
- $message .= '<pre>' . var_export($item, TRUE) . '</pre>';
- $message .= '<h3>Entity</h3>';
- $message .= '<pre>' . var_export($entity, TRUE) . '</pre>';
+ $message = $this->createLogMessage($e, $entity, $item);
$source->log('import', $message, array(), WATCHDOG_ERROR);
}
}
@@ -468,11 +527,17 @@ abstract class FeedsProcessor extends FeedsPlugin {
* Declare default configuration.
*/
public function configDefaults() {
+ $info = $this->entityInfo();
+ $bundle = NULL;
+ if (empty($info['entity keys']['bundle'])) {
+ $bundle = $this->entityType();
+ }
return array(
'mappings' => array(),
'update_existing' => FEEDS_SKIP_EXISTING,
'input_format' => NULL,
'skip_hash_check' => FALSE,
+ 'bundle' => $bundle,
);
}
@@ -482,7 +547,25 @@ abstract class FeedsProcessor extends FeedsPlugin {
public function configForm(&$form_state) {
$info = $this->entityInfo();
$form = array();
+
+ if (!empty($info['entity keys']['bundle'])) {
+ $form['bundle'] = array(
+ '#type' => 'select',
+ '#options' => $this->bundleOptions(),
+ '#title' => !empty($info['bundle name']) ? $info['bundle name'] : t('Bundle'),
+ '#required' => TRUE,
+ '#default_value' => $this->bundle(),
+ );
+ }
+ else {
+ $form['bundle'] = array(
+ '#type' => 'value',
+ '#value' => $this->entityType(),
+ );
+ }
+
$tokens = array('@entities' => strtolower($info['label plural']));
+
$form['update_existing'] = array(
'#type' => 'radios',
'#title' => t('Update existing @entities', $tokens),
@@ -490,6 +573,7 @@ abstract class FeedsProcessor extends FeedsPlugin {
t('Existing @entities will be determined using mappings that are a "unique target".', $tokens),
'#options' => array(
FEEDS_SKIP_EXISTING => t('Do not update existing @entities', $tokens),
+ FEEDS_REPLACE_EXISTING => t('Replace existing @entities', $tokens),
FEEDS_UPDATE_EXISTING => t('Update existing @entities', $tokens),
),
'#default_value' => $this->config['update_existing'],
@@ -513,6 +597,7 @@ abstract class FeedsProcessor extends FeedsPlugin {
'#default_value' => isset($this->config['input_format']) ? $this->config['input_format'] : 'plain_text',
'#required' => TRUE,
);
+
return $form;
}
@@ -534,6 +619,16 @@ abstract class FeedsProcessor extends FeedsPlugin {
* FALSE otherwise.
*/
public function getMappingTargets() {
+
+ // The bundle has not been selected.
+ if (!$this->bundle()) {
+ $info = $this->entityInfo();
+ $bundle_name = !empty($info['bundle name']) ? drupal_strtolower($info['bundle name']) : t('bundle');
+ $plugin_key = feeds_importer($this->id)->config['processor']['plugin_key'];
+ $url = url('admin/structure/feeds/' . $this->id . '/settings/' . $plugin_key);
+ drupal_set_message(t('Please <a href="@url">select a @bundle_name</a>.', array('@url' => $url, '@bundle_name' => $bundle_name)), 'warning', FALSE);
+ }
+
return array(
'url' => array(
'name' => t('URL'),
@@ -620,7 +715,7 @@ abstract class FeedsProcessor extends FeedsPlugin {
$parser = feeds_importer($this->id)->parser;
$targets = array();
foreach ($this->config['mappings'] as $mapping) {
- if ($mapping['unique']) {
+ if (!empty($mapping['unique'])) {
// Invoke the parser's getSourceElement to retrieve the value for this
// mapping's source.
$targets[$mapping['target']] = $parser->getSourceElement($source, $result, $mapping['source']);
@@ -641,6 +736,7 @@ abstract class FeedsProcessor extends FeedsPlugin {
*/
protected function newItemInfo($entity, $feed_nid, $hash = '') {
$entity->feeds_item = new stdClass();
+ $entity->feeds_item->is_new = TRUE;
$entity->feeds_item->entity_id = 0;
$entity->feeds_item->entity_type = $this->entityType();
$entity->feeds_item->id = $this->id;
@@ -681,11 +777,7 @@ abstract class FeedsProcessor extends FeedsPlugin {
* Empty/NULL/FALSE strings return d41d8cd98f00b204e9800998ecf8427e
*/
protected function hash($item) {
- static $serialized_mappings;
- if (!$serialized_mappings) {
- $serialized_mappings = serialize($this->config['mappings']);
- }
- return hash('md5', serialize($item) . $serialized_mappings);
+ return hash('md5', serialize($item) . serialize($this->config['mappings']));
}
/**
@@ -702,4 +794,30 @@ abstract class FeedsProcessor extends FeedsPlugin {
}
return '';
}
+
+ /**
+ * Creates a log message for when an exception occured during import.
+ *
+ * @param Exception $e
+ * The exception that was throwned during processing the item.
+ * @param $entity
+ * The entity object.
+ * @param $item
+ * The parser result for this entity.
+ *
+ * @return string
+ * The message to log.
+ */
+ protected function createLogMessage(Exception $e, $entity, $item) {
+ include_once DRUPAL_ROOT . '/includes/utility.inc';
+ $message = $e->getMessage();
+ $message .= '<h3>Original item</h3>';
+ $message .= '<pre>' . drupal_var_export($item). '</pre>';
+ $message .= '<h3>Entity</h3>';
+ $message .= '<pre>' . drupal_var_export($entity) . '</pre>';
+ return $message;
+ }
+
}
+
+class FeedsProcessorBundleNotDefined extends Exception {}
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsTermProcessor.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsTermProcessor.inc
index 7721ff0..b336096 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsTermProcessor.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsTermProcessor.inc
@@ -22,6 +22,7 @@ class FeedsTermProcessor extends FeedsProcessor {
protected function entityInfo() {
$info = parent::entityInfo();
$info['label plural'] = t('Terms');
+ $info['bundle name'] = t('Vocabulary');
return $info;
}
@@ -38,17 +39,10 @@ class FeedsTermProcessor extends FeedsProcessor {
}
/**
- * Loads an existing term.
- */
- protected function entityLoad(FeedsSource $source, $tid) {
- return taxonomy_term_load($tid);
- }
-
- /**
* Validates a term.
*/
protected function entityValidate($term) {
- if (empty($term->name)) {
+ if (drupal_strlen($term->name) == 0) {
throw new FeedsValidationException(t('Term name missing.'));
}
}
@@ -90,34 +84,6 @@ class FeedsTermProcessor extends FeedsProcessor {
}
/**
- * Override parent::configForm().
- */
- public function configForm(&$form_state) {
- $options = array(0 => t('Select a vocabulary'));
- foreach (taxonomy_get_vocabularies() as $vocab) {
- $options[$vocab->machine_name] = $vocab->name;
- }
- $form = parent::configForm($form_state);
- $form['vocabulary'] = array(
- '#type' => 'select',
- '#title' => t('Import to vocabulary'),
- '#description' => t('Choose the vocabulary to import into. <strong>CAUTION:</strong> when deleting terms through the "Delete items" tab, Feeds will delete <em>all</em> terms from this vocabulary.'),
- '#options' => $options,
- '#default_value' => $this->config['vocabulary'],
- );
- return $form;
- }
-
- /**
- * Override parent::configFormValidate().
- */
- public function configFormValidate(&$values) {
- if (empty($values['vocabulary'])) {
- form_set_error('vocabulary', t('Choose a vocabulary'));
- }
- }
-
- /**
* Override setTargetElement to operate on a target item that is a taxonomy term.
*/
public function setTargetElement(FeedsSource $source, $target_term, $target_element, $value) {
@@ -202,7 +168,7 @@ class FeedsTermProcessor extends FeedsProcessor {
try {
self::loadMappers();
$entity_type = $this->entityType();
- $bundle = $this->vocabulary()->machine_name;
+ $bundle = $this->bundle();
drupal_alter('feeds_processor_targets', $targets, $entity_type, $bundle);
}
catch (Exception $e) {
@@ -235,10 +201,8 @@ class FeedsTermProcessor extends FeedsProcessor {
* Return vocabulary to map to.
*/
public function vocabulary() {
- if (isset($this->config['vocabulary'])) {
- if ($vocabulary = taxonomy_vocabulary_machine_name_load($this->config['vocabulary'])) {
- return $vocabulary;
- }
+ if ($vocabulary = taxonomy_vocabulary_machine_name_load($this->bundle())) {
+ return $vocabulary;
}
throw new Exception(t('No vocabulary defined for Taxonomy Term processor.'));
}
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsUserProcessor.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsUserProcessor.inc
index b067c41..d01db43 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsUserProcessor.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/plugins/FeedsUserProcessor.inc
@@ -40,8 +40,9 @@ class FeedsUserProcessor extends FeedsProcessor {
* Loads an existing user.
*/
protected function entityLoad(FeedsSource $source, $uid) {
+ $user = parent::entityLoad($source, $uid);
+
// Copy the password so that we can compare it again at save.
- $user = user_load($uid);
$user->feeds_original_pass = $user->pass;
return $user;
}
@@ -87,9 +88,7 @@ class FeedsUserProcessor extends FeedsProcessor {
* Delete multiple user accounts.
*/
protected function entityDeleteMultiple($uids) {
- foreach ($uids as $uid) {
- user_delete($uid);
- }
+ user_delete_multiple($uids);
}
/**
@@ -127,13 +126,6 @@ class FeedsUserProcessor extends FeedsProcessor {
'#options' => $roles,
);
}
- // @todo Implement true updating.
- $form['update_existing'] = array(
- '#type' => 'checkbox',
- '#title' => t('Replace existing users'),
- '#description' => t('If an existing user is found for an imported user, replace it. Existing users will be determined using mappings that are a "unique target".'),
- '#default_value' => $this->config['update_existing'],
- );
$form['defuse_mail'] = array(
'#type' => 'checkbox',
'#title' => t('Defuse e-mail addresses'),
@@ -204,7 +196,7 @@ class FeedsUserProcessor extends FeedsProcessor {
// Let other modules expose mapping targets.
self::loadMappers();
$entity_type = $this->entityType();
- $bundle = $this->entityType();
+ $bundle = $this->bundle();
drupal_alter('feeds_processor_targets', $targets, $entity_type, $bundle);
return $targets;
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds.test b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds.test
index 4bcb20c..480a5db 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds.test
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds.test
@@ -188,6 +188,8 @@ class FeedsWebTestCase extends DrupalWebTestCase {
$this->assertPlugins($id, 'FeedsHTTPFetcher', 'FeedsSyndicationParser', 'FeedsNodeProcessor');
// Per default attach to page content type.
$this->setSettings($id, NULL, array('content_type' => 'page'));
+ // Per default attached to article content type.
+ $this->setSettings($id, 'FeedsNodeProcessor', array('bundle' => 'article'));
}
/**
@@ -407,7 +409,7 @@ class FeedsWebTestCase extends DrupalWebTestCase {
$mapping = array('source' => $mapping['source'], 'target' => $mapping['target']);
// Add mapping.
- $this->drupalPost($path, $mapping, t('Add'));
+ $this->drupalPost($path, $mapping, t('Save'));
// If there are other configuration options, set them.
if ($config) {
@@ -432,8 +434,6 @@ class FeedsWebTestCase extends DrupalWebTestCase {
/**
* Remove mappings from a given configuration.
*
- * This function mimicks the Javascript behavior in feeds_ui.js
- *
* @param array $mappings
* An array of mapping arrays. Each mapping array must have a source and
* a target key and can have a unique key.
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/multi-date.xml b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/multi-date.xml
new file mode 100644
index 0000000..13a705d
--- /dev/null
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/multi-date.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<items>
+ <item>
+ <title>2 date values</title>
+ <guid>123456789</guid>
+ <date>Wed, 06 Jan 2010 15:05:00 GMT+00:00</date>
+ <date>Thu, 07 Jan 2010 15:08:00 GMT+00:00</date>
+ </item>
+ <item>
+ <title>4 date values</title>
+ <guid>1234567890</guid>
+ <date>Wed, 06 Jan 2010 15:00:00 GMT+00:00</date>
+ <date>Thu, 07 Jan 2010 15:00:00 GMT+00:00</date>
+ <date>Fri, 08 Jan 2010 15:00:00 GMT+00:00</date>
+ <date>Sat, 09 Jan 2010 15:00:00 GMT+00:00</date>
+ </item>
+ <item>
+ <title>Bogus date values</title>
+ <guid>1234567892</guid>
+ <date>Wed, 36 Jan 2010 15:00:00 GMT+00:00</date>
+ <date>Foo, 07 Bar 2010 95:00:00 GMT+00:00</date>
+ <date>This is just pure bogus. No date here!</date>
+ </item>
+ <item>
+ <title>Single date value</title>
+ <guid>1234567894</guid>
+ <date>Wed, 06 Jan 2010 14:00:00 GMT+00:00</date>
+ </item>
+</items>
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/nodes_comma.csv b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/nodes_comma.csv
new file mode 100644
index 0000000..8b1b46d
--- /dev/null
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/nodes_comma.csv
@@ -0,0 +1,10 @@
+Title,Body,published,GUID
+"Ut wisi enim ad minim veniam", "Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.",205200720,2
+"Duis autem vel eum iriure dolor", "Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.",428112720,3
+"Nam liber tempor", "Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum.",1151766000,1
+Typi non habent"", "Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem.",1256326995,4
+"Lorem ipsum","Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.",1251936720,1
+"Investigationes demonstraverunt", "Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius.",946702800,5
+"Claritas est etiam", "Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum.",438112720,6
+"Mirum est notare", "Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima.",1151066000,7
+"Eodem modo typi", "Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.",1201936720,8 \ No newline at end of file
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/nodes_pipe.csv b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/nodes_pipe.csv
new file mode 100644
index 0000000..bd2346d
--- /dev/null
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/nodes_pipe.csv
@@ -0,0 +1,10 @@
+Title|Body|published|GUID
+"Ut wisi enim ad minim veniam"| "Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat."|205200720|2
+"Duis autem vel eum iriure dolor"| "Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi."|428112720|3
+"Nam liber tempor"| "Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum."|1151766000|1
+Typi non habent""| "Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem."|1256326995|4
+"Lorem ipsum"|"Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat."|1251936720|1
+"Investigationes demonstraverunt"| "Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius."|946702800|5
+"Claritas est etiam"| "Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum."|438112720|6
+"Mirum est notare"| "Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima."|1151066000|7
+"Eodem modo typi"| "Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum."|1201936720|8 \ No newline at end of file
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/nodes_plus.csv b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/nodes_plus.csv
new file mode 100644
index 0000000..fd1e3ad
--- /dev/null
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/nodes_plus.csv
@@ -0,0 +1,10 @@
+Title+Body+published+GUID
+"Ut wisi enim ad minim veniam"+ "Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat."+205200720+2
+"Duis autem vel eum iriure dolor"+ "Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi."+428112720+3
+"Nam liber tempor"+ "Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum."+1151766000+1
+Typi non habent""+ "Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem."+1256326995+4
+"Lorem ipsum"+"Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat."+1251936720+1
+"Investigationes demonstraverunt"+ "Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius."+946702800+5
+"Claritas est etiam"+ "Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum."+438112720+6
+"Mirum est notare"+ "Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima."+1151066000+7
+"Eodem modo typi"+ "Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum."+1201936720+8 \ No newline at end of file
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/nodes_semicolon.csv b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/nodes_semicolon.csv
new file mode 100644
index 0000000..0d03dd2
--- /dev/null
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/nodes_semicolon.csv
@@ -0,0 +1,10 @@
+Title;Body;published;GUID
+"Ut wisi enim ad minim veniam"; "Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.";205200720;2
+"Duis autem vel eum iriure dolor"; "Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.";428112720;3
+"Nam liber tempor"; "Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum.";1151766000;1
+Typi non habent""; "Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem.";1256326995;4
+"Lorem ipsum";"Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.";1251936720;1
+"Investigationes demonstraverunt"; "Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius.";946702800;5
+"Claritas est etiam"; "Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum.";438112720;6
+"Mirum est notare"; "Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima.";1151066000;7
+"Eodem modo typi"; "Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.";1201936720;8 \ No newline at end of file
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/nodes_tab.csv b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/nodes_tab.csv
new file mode 100644
index 0000000..a7e31a3
--- /dev/null
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds/nodes_tab.csv
@@ -0,0 +1,10 @@
+Title Body published GUID
+"Ut wisi enim ad minim veniam" "Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat." 205200720 2
+"Duis autem vel eum iriure dolor" "Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi." 428112720 3
+"Nam liber tempor" "Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum." 1151766000 1
+Typi non habent"" "Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem." 1256326995 4
+"Lorem ipsum" "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat." 1251936720 1
+"Investigationes demonstraverunt" "Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius." 946702800 5
+"Claritas est etiam" "Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum." 438112720 6
+"Mirum est notare" "Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima." 1151066000 7
+"Eodem modo typi" "Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum." 1201936720 8 \ No newline at end of file
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_date_time.test b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_date_time.test
index eac3d9f..a449458 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_date_time.test
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_date_time.test
@@ -12,7 +12,7 @@
* Not inheriting from Feeds base class as ParserCSV should be moved out of
* Feeds at some time.
*/
-class FeedsDateTimeTest extends FeedsUnitTestHelper {
+class FeedsDateTimeTest extends FeedsWebTestCase {
protected $profile = 'testing';
public static function getInfo() {
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_fetcher_file.test b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_fetcher_file.test
index 6431698..6573603 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_fetcher_file.test
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_fetcher_file.test
@@ -17,18 +17,14 @@ class FeedsFileFetcherTestCase extends FeedsWebTestCase {
);
}
-
/**
* Test scheduling on cron.
*/
- public function test() {
+ public function testPublicFiles() {
// Set up an importer.
$this->createImporterConfiguration('Node import', 'node');
// Set and configure plugins and mappings.
- $edit = array(
- 'content_type' => '',
- );
- $this->drupalPost('admin/structure/feeds/node/settings', $edit, 'Save');
+ $this->setSettings('node', NULL, array('content_type' => ''));
$this->setPlugin('node', 'FeedsFileFetcher');
$this->setPlugin('node', 'FeedsCSVParser');
$mappings = array(
@@ -40,15 +36,19 @@ class FeedsFileFetcherTestCase extends FeedsWebTestCase {
$this->addMappings('node', $mappings);
// Straight up upload is covered in other tests, focus on direct mode
// and file batching here.
- $this->setSettings('node', 'FeedsFileFetcher', array('direct' => TRUE));
+ $settings = array(
+ 'direct' => TRUE,
+ 'directory' => 'public://feeds',
+ );
+ $this->setSettings('node', 'FeedsFileFetcher', $settings);
// Verify that invalid paths are not accepted.
- foreach (array('private://', '/tmp/') as $path) {
+ foreach (array('/tmp/') as $path) {
$edit = array(
'feeds[FeedsFileFetcher][source]' => $path,
);
$this->drupalPost('import/node', $edit, t('Import'));
- $this->assertText("File needs to reside within the site's file directory, its path needs to start with public://.");
+ $this->assertText("The file needs to reside within the site's files directory, its path needs to start with scheme://. Available schemes:");
$count = db_query("SELECT COUNT(*) FROM {feeds_source} WHERE feed_nid = 0")->fetchField();
$this->assertEqual($count, 0);
}
@@ -67,4 +67,48 @@ class FeedsFileFetcherTestCase extends FeedsWebTestCase {
$this->drupalPost('import/node', $edit, t('Import'));
$this->assertText('Created 18 nodes');
}
+
+ /**
+ * Test uploading private files.
+ */
+ public function testPrivateFiles() {
+ // Set up an importer.
+ $this->createImporterConfiguration('Node import', 'node');
+ // Set and configure plugins and mappings.
+ $edit = array(
+ 'content_type' => '',
+ );
+ $this->drupalPost('admin/structure/feeds/node/settings', $edit, 'Save');
+ $this->setPlugin('node', 'FeedsFileFetcher');
+ $this->setPlugin('node', 'FeedsCSVParser');
+ $mappings = array(
+ '0' => array(
+ 'source' => 'title',
+ 'target' => 'title',
+ ),
+ );
+ $this->addMappings('node', $mappings);
+ // Straight up upload is covered in other tests, focus on direct mode
+ // and file batching here.
+ $settings = array(
+ 'direct' => TRUE,
+ 'directory' => 'private://feeds',
+ );
+ $this->setSettings('node', 'FeedsFileFetcher', $settings);
+
+ // Verify batching through directories.
+ // Copy directory of files.
+ $dir = 'private://batchtest';
+ $this->copyDir($this->absolutePath() . '/tests/feeds/batch', $dir);
+
+ // Ingest directory of files. Set limit to 5 to force processor to batch,
+ // too.
+ variable_set('feeds_process_limit', 5);
+ $edit = array(
+ 'feeds[FeedsFileFetcher][source]' => $dir,
+ );
+ $this->drupalPost('import/node', $edit, t('Import'));
+ $this->assertText('Created 18 nodes');
+ }
+
}
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_date.test b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_date.test
index 60fb383..c3cb067 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_date.test
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_date.test
@@ -39,12 +39,33 @@ class FeedsMapperDateTestCase extends FeedsMapperTestCase {
//'datetime' => 'datetime', // REMOVED because the field is broken ATM.
));
+ // Hack to get date fields to not round to every 15 minutes.
+ foreach (array('date', 'datestamp') as $field) {
+ $field = 'field_' . $field;
+ $edit = array(
+ 'widget_type' => 'date_select',
+ );
+ $this->drupalPost('admin/structure/types/manage/' . $typename . '/fields/' . $field . '/widget-type', $edit, 'Continue');
+ $edit = array(
+ 'instance[widget][settings][increment]' => 1,
+ );
+ $this->drupalPost('admin/structure/types/manage/' . $typename . '/fields/' . $field, $edit, 'Save settings');
+ $edit = array(
+ 'widget_type' => 'date_text',
+ );
+ $this->drupalPost('admin/structure/types/manage/' . $typename . '/fields/' . $field . '/widget-type', $edit, 'Continue');
+ }
+
// Create and configure importer.
$this->createImporterConfiguration('Date RSS', 'daterss');
- $this->setSettings('daterss', NULL, array('content_type' => '', 'import_period' => FEEDS_SCHEDULE_NEVER));
+ $this->setSettings('daterss', NULL, array(
+ 'content_type' => '',
+ 'import_period' => FEEDS_SCHEDULE_NEVER,
+ ));
$this->setPlugin('daterss', 'FeedsFileFetcher');
- $this->setPlugin('daterss', 'FeedsSyndicationParser');
- $this->setSettings('daterss', 'FeedsNodeProcessor', array('content_type' => $typename));
+ $this->setSettings('daterss', 'FeedsNodeProcessor', array(
+ 'bundle' => $typename,
+ ));
$this->addMappings('daterss', array(
0 => array(
'source' => 'title',
@@ -81,7 +102,7 @@ class FeedsMapperDateTestCase extends FeedsMapperTestCase {
'01/06/2010 - 06:05',
'01/06/2010 - 11:26',
'01/07/2010 - 00:26',
- );
+ );
for ($i = 1; $i <= 6; $i++) {
$this->drupalGet("node/$i/edit");
$this->assertNodeFieldValue('date', $values[$i-1]);
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_date_multiple.test b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_date_multiple.test
new file mode 100644
index 0000000..3886c5a
--- /dev/null
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_date_multiple.test
@@ -0,0 +1,118 @@
+<?php
+
+/**
+ * @file
+ * Test case for CCK date multi-field mapper mappers/date.inc.
+ */
+
+/**
+ * Class for testing Feeds <em>content</em> mapper.
+ *
+ * @todo: Add test method iCal
+ * @todo: Add test method for end date
+ */
+class FeedsMapperDateMultipleTestCase extends FeedsMapperTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Mapper: Date, multi value fields',
+ 'description' => 'Test Feeds Mapper support for CCK multi valiue Date fields.',
+ 'group' => 'Feeds',
+ 'dependencies' => array('date', 'feeds_xpathparser'),
+ );
+ }
+
+ public function setUp() {
+ parent::setUp(array('date_api', 'date', 'feeds_xpathparser'));
+ variable_set('date_default_timezone', 'UTC');
+ }
+
+ /**
+ * Testing import by loading a 4 item XML file.
+ */
+ public function test() {
+ $this->drupalGet('admin/config/regional/settings');
+
+ // Create content type.
+ $typename = $this->createContentType(array(), array(
+ 'date' => 'date',
+ ));
+ // Make the field hold unlimited values
+ $edit = array(
+ 'field[cardinality]' => -1,
+ );
+ $this->drupalPost('admin/structure/types/manage/' . $typename . '/fields/field_date', $edit, 'Save settings');
+ $this->assertText('Saved date_date_label configuration');
+
+ // Create and configure importer.
+ $this->createImporterConfiguration('Multi dates', 'multidates');
+ $this->setSettings('multidates', NULL, array(
+ 'content_type' => '',
+ 'import_period' => FEEDS_SCHEDULE_NEVER,
+ ));
+ $this->setPlugin('multidates', 'FeedsFileFetcher');
+ $this->setPlugin('multidates', 'FeedsXPathParserXML');
+
+ $this->setSettings('multidates', 'FeedsNodeProcessor', array(
+ 'bundle' => $typename,
+ ));
+ $this->addMappings('multidates', array(
+ 0 => array(
+ 'source' => 'xpathparser:0',
+ 'target' => 'title',
+ ),
+ 1 => array(
+ 'source' => 'xpathparser:1',
+ 'target' => 'guid',
+ ),
+ 2 => array(
+ 'source' => 'xpathparser:2',
+ 'target' => 'field_date:start',
+ ),
+ ));
+
+ $edit = array(
+ 'xpath[context]' => '//item',
+ 'xpath[sources][xpathparser:0]' => 'title',
+ 'xpath[sources][xpathparser:1]' => 'guid',
+ 'xpath[sources][xpathparser:2]' => 'date',
+ 'xpath[allow_override]' => FALSE,
+ );
+ $this->setSettings('multidates', 'FeedsXPathParserXML', $edit);
+
+ $edit = array(
+ 'allowed_extensions' => 'xml',
+ 'directory' => 'public://feeds',
+ );
+ $this->setSettings('multidates', 'FeedsFileFetcher', $edit);
+
+ // Import XML file.
+ $this->importFile('multidates', $this->absolutePath() . '/tests/feeds/multi-date.xml');
+ $this->assertText('Created 4 nodes');
+
+ // Check the imported nodes.
+ $values = array(
+ 1 => array(
+ '01/06/2010 - 15:00',
+ '01/07/2010 - 15:15',
+ ),
+ 2 => array(
+ '01/06/2010 - 15:00',
+ '01/07/2010 - 15:00',
+ '01/08/2010 - 15:00',
+ '01/09/2010 - 15:00',
+ ),
+ 3 => array(
+ '', // Bogus date was filtered out.
+ ),
+ 4 => array(
+ '01/06/2010 - 14:00',
+ )
+ );
+ foreach ($values as $v => $key) {
+ $this->drupalGet("node/$v/edit");
+ foreach ($key as $delta => $value) {
+ $this->assertFieldById('edit-field-date-und-' . $delta . '-value-date', $value);
+ }
+ }
+ }
+}
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_field.test b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_field.test
index 130d0af..2506a29 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_field.test
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_field.test
@@ -38,7 +38,7 @@ class FeedsMapperFieldTestCase extends FeedsMapperTestCase {
$this->setSettings('csv', NULL, array('content_type' => '', 'import_period' => FEEDS_SCHEDULE_NEVER));
$this->setPlugin('csv', 'FeedsFileFetcher');
$this->setPlugin('csv', 'FeedsCSVParser');
- $this->setSettings('csv', 'FeedsNodeProcessor', array('content_type' => $typename));
+ $this->setSettings('csv', 'FeedsNodeProcessor', array('bundle' => $typename));
$this->addMappings('csv', array(
0 => array(
'source' => 'title',
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_file.test b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_file.test
index 909e47e..20c7912 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_file.test
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_file.test
@@ -47,7 +47,7 @@ class FeedsMapperFileTestCase extends FeedsMapperTestCase {
// Create importer configuration.
$this->createImporterConfiguration();
$this->setPlugin('syndication', 'FeedsSimplePieParser');
- $this->setSettings('syndication', 'FeedsNodeProcessor', array('content_type' => $typename));
+ $this->setSettings('syndication', 'FeedsNodeProcessor', array('bundle' => $typename));
$this->addMappings('syndication', array(
0 => array(
'source' => 'title',
@@ -90,7 +90,8 @@ class FeedsMapperFileTestCase extends FeedsMapperTestCase {
// Create a CSV importer configuration.
$this->createImporterConfiguration('Node import from CSV', 'node');
$this->setPlugin('node', 'FeedsCSVParser');
- $this->setSettings('node', 'FeedsNodeProcessor', array('content_type' => $typename));
+ $this->setSettings('node', 'FeedsNodeProcessor', array('bundle' => $typename));
+ $this->setSettings('node', NULL, array('content_type' => ''));
$this->addMappings('node', array(
0 => array(
'source' => 'title',
@@ -101,10 +102,6 @@ class FeedsMapperFileTestCase extends FeedsMapperTestCase {
'target' => 'field_files'
),
));
- $edit = array(
- 'content_type' => '',
- );
- $this->drupalPost('admin/structure/feeds/node/settings', $edit, 'Save');
// Import.
$edit = array(
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_link.test b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_link.test
index 5fddbb1..a64fc94 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_link.test
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_link.test
@@ -59,7 +59,7 @@ class FeedsMapperLinkTestCase extends FeedsMapperTestCase {
// Create importer configuration.
$this->createImporterConfiguration(); //Create a default importer configuration
- $this->setSettings('syndication', 'FeedsNodeProcessor', array('content_type' => $typename)); //Processor settings
+ $this->setSettings('syndication', 'FeedsNodeProcessor', array('bundle' => $typename)); //Processor settings
$this->addMappings('syndication', array(
0 => array(
'source' => 'title',
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_path.test b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_path.test
index 55f75b0..bb408db 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_path.test
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_path.test
@@ -94,10 +94,7 @@ class FeedsMapperPathTestCase extends FeedsMapperTestCase {
);
$this->drupalPost('admin/structure/taxonomy/add', $edit, t('Save'));
- $this->setSettings('path_test', 'FeedsTermProcessor', array('vocabulary' => 'addams'));
-
- // Turn on update existing.
- $this->setSettings('path_test', 'FeedsTermProcessor', array('update_existing' => 2));
+ $this->setSettings('path_test', 'FeedsTermProcessor', array('bundle' => 'addams', 'update_existing' => 2));
// Add mappings.
$this->addMappings('path_test', array(
@@ -208,7 +205,7 @@ class FeedsMapperPathPathautoTestCase extends FeedsMapperTestCase {
$aliases = array();
for ($i = 1; $i <= 9; $i++) {
- $aliases[] = "path$i";
+ $aliases[] = "content/pathauto$i";
}
$this->assertAliasCount($aliases);
@@ -229,12 +226,7 @@ class FeedsMapperPathPathautoTestCase extends FeedsMapperTestCase {
}
public function assertAliasCount($aliases) {
- $in_db = db_select('url_alias', 'a')
- ->fields('a')
- ->condition('a.alias', $aliases)
- ->execute()
- ->fetchAll();
-
+ $in_db = db_query("SELECT * FROM {url_alias} WHERE alias IN (:aliases)", array(':aliases' => $aliases))->fetchAll();
$this->assertEqual(count($in_db), count($aliases), 'Correct number of aliases in db.');
}
}
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_taxonomy.test b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_taxonomy.test
index 94dd188..2c6dfb6 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_taxonomy.test
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_mapper_taxonomy.test
@@ -112,7 +112,7 @@ class FeedsMapperTaxonomyTestCase extends FeedsMapperTestCase {
}
/**
- * Test inheriting taxonomy from the feed node.
+ * Tests inheriting taxonomy from the feed node.
*/
function testInheritTaxonomy() {
@@ -152,120 +152,165 @@ class FeedsMapperTaxonomyTestCase extends FeedsMapperTestCase {
}
/**
- * Test aggregating RSS categories to taxonomy.
+ * Tests searching taxonomy terms by name.
*/
- /*
- function testRSSCategoriesToTaxonomy() {
- // Add mapping to tags vocabulary.
- $this->addMappings('syndication',
- array(
- array(
- 'source' => 'tags',
- 'target' => 'taxonomy:1',
- ),
- )
- );
-
- // Aggregate feed node with "Tag" vocabulary.
- $nid = $this->createFeedNode();
- // Assert 10 items aggregated after creation of the node.
- $this->assertText('Created 10 nodes');
- // There should be 30 terms and 44 term-node relations.
- $this->assertEqual(30, db_query("SELECT count(*) FROM {term_data}")->fetchField(), "Found correct number of terms.");
- $this->assertEqual(44, db_query("SELECT count(*) FROM {term_node}")->fetchField(), "Found correct number of term-node relations.");
-
- // Take a look at the actual terms on frontpage.
- $this->drupalGet('node');
+ public function testSearchByName() {
$terms = array(
- 'authentication',
- 'custom mapping',
- 'data visualization',
'Drupal',
- 'Drupal planet',
- 'faceted search',
- 'GeoDC',
- 'graphs',
- 'interface',
- 'intranet',
'localization',
'localization client',
'localization server',
- 'map-basec browser',
- 'mapbox',
- 'microfinance',
- 'MIX Market',
'open atrium',
- 'open data',
- 'open source',
- 'Peru',
- 'salesforce',
- 'siteminder',
- 'siteminder module',
- 'software freedom day',
'translation',
'translation server',
- 'usability',
- 'Washington DC',
- 'World Bank',
+ 'Drupal planet',
);
+
+ $this->setSettings('syndication', 'FeedsNodeProcessor', array(
+ 'skip_hash_check' => TRUE,
+ 'update_existing' => 2,
+ ));
+ $mappings = array(
+ 5 => array(
+ 'source' => 'tags',
+ 'target' => 'field_tags',
+ 'term_search' => 0,
+ ),
+ );
+ $this->addMappings('syndication', $mappings);
+ $nid = $this->createFeedNode('syndication', NULL, 'Syndication');
+ $this->assertText('Created 10 nodes.');
+ // Check that terms we not auto-created.
+ $this->drupalGet('node/2');
+ foreach ($terms as $term) {
+ $this->assertNoTaxonomyTerm($term);
+ }
+ $this->drupalGet('node/3');
+ $this->assertNoTaxonomyTerm('Washington DC');
+
+ // Change the mapping configuration.
+ $this->removeMappings('syndication', $mappings);
+ // Turn on autocreate.
+ $mappings[5]['autocreate'] = TRUE;
+ $this->addMappings('syndication', $mappings);
+ $this->drupalPost('node/' . $nid . '/import', array(), t('Import'));
+ $this->assertText('Updated 10 nodes.');
+
+ $this->drupalGet('node/2');
foreach ($terms as $term) {
$this->assertTaxonomyTerm($term);
}
+ $this->drupalGet('node/3');
+ $this->assertTaxonomyTerm('Washington DC');
- // Delete all items, all associations are gone.
- $this->drupalPost("node/$nid/delete-items", array(), 'Delete');
- $this->assertText('Deleted 10 nodes');
- $this->assertEqual(30, db_query("SELECT count(*) FROM {term_data}")->fetchField(), "Found correct number of terms.");
- $this->assertEqual(0, db_query("SELECT count(*) FROM {term_node}")->fetchField(), "Found correct number of term-node relations.");
+ $names = db_query('SELECT name FROM {taxonomy_term_data}')->fetchCol();
+ $this->assertEqual(count($names), 31, 'Found correct number of terms in the database.');
- // Remove "Tag" setting, import again.
- $edit = array(
- 'tags' => FALSE,
- );
- $this->drupalPost('admin/content/taxonomy/edit/vocabulary/1', $edit, 'Save');
- $this->drupalPost("node/$nid/import", array(), 'Import');
- $this->assertText('Created 10 nodes');
+ // Run import again. This verifys that the terms we found by name.
+ $this->drupalPost('node/' . $nid . '/import', array(), t('Import'));
+ $this->assertText('Updated 10 nodes.');
+ $names = db_query('SELECT name FROM {taxonomy_term_data}')->fetchCol();
+ $this->assertEqual(count($names), 31, 'Found correct number of terms in the database.');
+ }
- // We should only get one term-node association per node.
- $this->assertEqual(30, db_query("SELECT count(*) FROM {term_data}")->fetchField(), "Found correct number of terms.");
- $this->assertEqual(10, db_query("SELECT count(*) FROM {term_node}")->fetchField(), "Found correct number of term-node relations.");
+ /**
+ * Tests mapping to taxonomy terms by tid.
+ */
+ public function testSearchByID() {
+ // Create 10 terms. The first one was created in setup.
+ $terms = array(1);
+ foreach (range(2, 10) as $i) {
+ $term = (object) array(
+ 'name' => 'term' . $i,
+ 'vid' => 1,
+ );
+ taxonomy_term_save($term);
+ $terms[] = $term->tid;
+ }
- // Delete all items.
- $this->drupalPost("node/$nid/delete-items", array(), 'Delete');
+ FeedsPlugin::loadMappers();
- // Set vocabulary to multiple terms, import again.
- $edit = array(
- 'multiple' => TRUE,
+ $entity = new stdClass();
+ $target = 'field_tags';
+ $mapping = array(
+ 'term_search' => FEEDS_TAXONOMY_SEARCH_TERM_ID,
);
- $this->drupalPost('admin/content/taxonomy/edit/vocabulary/1', $edit, 'Save');
- $this->drupalPost("node/$nid/import", array(), 'Import');
- $this->assertText('Created 10 nodes');
- // We should get all term-node associations again.
- $this->assertEqual(30, db_query("SELECT count(*) FROM {term_data}")->fetchField(), "Found correct number of terms.");
- $this->assertEqual(44, db_query("SELECT count(*) FROM {term_node}")->fetchField(), "Found correct number of term-node relations.");
+ taxonomy_feeds_set_target(NULL, $entity, $target, $terms, $mapping);
+ $this->assertEqual(count($entity->field_tags[LANGUAGE_NONE]), 10);
- // Delete all items.
- $this->drupalPost("node/$nid/delete-items", array(), 'Delete');
+ // Test a second mapping with a bogus term id.
+ taxonomy_feeds_set_target(NULL, $entity, $target, array(1234), $mapping);
+ $this->assertEqual(count($entity->field_tags[LANGUAGE_NONE]), 10);
+ }
- // Remove a term, import again.
- $this->drupalPost('admin/content/taxonomy/edit/term/1', array(), 'Delete');
- $this->drupalPost(NULL, array(), 'Delete');
- $this->assertText('Deleted term');
- $this->drupalPost("node/$nid/import", array(), 'Import');
- $this->assertText('Created 10 nodes');
+ /**
+ * Tests mapping to a taxonomy term's guid.
+ */
+ public function testSearchByGUID() {
+ // Create 10 terms. The first one was created in setup.
+ $tids = array(1);
+ foreach (range(2, 10) as $i) {
+ $term = (object) array(
+ 'name' => 'term' . $i,
+ 'vid' => 1,
+ );
+ taxonomy_term_save($term);
+ $tids[] = $term->tid;
+ }
+
+ // Create a bunch of bogus imported terms.
+ $guids = array();
+ foreach ($tids as $tid) {
+ $guid = 100 * $tid;
+ $guids[] = $guid;
+ $record = array(
+ 'entity_type' => 'taxonomy_term',
+ 'entity_id' => $tid,
+ 'id' => 'does_not_exist',
+ 'feed_nid' => 0,
+ 'imported' => REQUEST_TIME,
+ 'url' => '',
+ 'guid' => $guid,
+ );
+ drupal_write_record('feeds_item', $record);
+ }
+
+ FeedsPlugin::loadMappers();
+
+ $entity = new stdClass();
+ $target = 'field_tags';
+ $mapping = array(
+ 'term_search' => FEEDS_TAXONOMY_SEARCH_TERM_GUID,
+ );
+
+ taxonomy_feeds_set_target(NULL, $entity, $target, $guids, $mapping);
+ $this->assertEqual(count($entity->field_tags[LANGUAGE_NONE]), 10);
+ foreach ($entity->field_tags[LANGUAGE_NONE] as $delta => $values) {
+ $this->assertEqual($tids[$delta], $values['tid'], 'Correct term id foud.');
+ }
- // This term should now be missing from term-node associations.
- $this->assertEqual(29, db_query("SELECT count(*) FROM {term_data}")->fetchField(), "Found correct number of terms.");
- $this->assertEqual(39, db_query("SELECT count(*) FROM {term_node}")->fetchField(), "Found correct number of term-node relations.");
+ // Test a second mapping with a bogus term id.
+ taxonomy_feeds_set_target(NULL, $entity, $target, array(1234), $mapping);
+ $this->assertEqual(count($entity->field_tags[LANGUAGE_NONE]), 10);
+ foreach ($entity->field_tags[LANGUAGE_NONE] as $delta => $values) {
+ $this->assertEqual($tids[$delta], $values['tid'], 'Correct term id foud.');
+ }
}
- */
/**
- * Helper, finds node style taxonomy term markup in DOM.
+ * Finds node style taxonomy term markup in DOM.
*/
public function assertTaxonomyTerm($term) {
$term = check_plain($term);
$this->assertPattern('/<a href="\/.*taxonomy\/term\/[0-9]+">' . $term . '<\/a>/', 'Found ' . $term);
}
+
+ /**
+ * Asserts that the term does not exist on a node page.
+ */
+ public function assertNoTaxonomyTerm($term) {
+ $term = check_plain($term);
+ $this->assertNoPattern('/<a href="\/.*taxonomy\/term\/[0-9]+">' . $term . '<\/a>/', 'Did not find ' . $term);
+ }
}
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_processor_node.test b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_processor_node.test
index 677bd95..a61df78 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_processor_node.test
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_processor_node.test
@@ -408,13 +408,13 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase {
}
/**
- * Test that nodes will not be created if the user is unauthorized to create
+ * Test that nodes will not be created if the user is unauthorized to create
* them.
*/
public function testAuthorize() {
- // Create a user with limited permissions. We can't use
- // $this->drupalCreateUser here because we need to to set a specific user
+ // Create a user with limited permissions. We can't use
+ // $this->drupalCreateUser here because we need to to set a specific user
// name.
$edit = array(
'name' => 'Development Seed',
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_processor_term.test b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_processor_term.test
index 4adcd08..571222c 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_processor_term.test
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_processor_term.test
@@ -18,9 +18,10 @@ class FeedsCSVtoTermsTest extends FeedsWebTestCase {
}
/**
- * Test node creation, refreshing/deleting feeds and feed items.
+ * Set up test.
*/
- public function test() {
+ public function setUp() {
+ parent::setUp();
// Create an importer.
$this->createImporterConfiguration('Term import', 'term_import');
@@ -29,31 +30,33 @@ class FeedsCSVtoTermsTest extends FeedsWebTestCase {
$this->setPlugin('term_import', 'FeedsFileFetcher');
$this->setPlugin('term_import', 'FeedsCSVParser');
$this->setPlugin('term_import', 'FeedsTermProcessor');
- $mappings = array(
- 0 => array(
- 'source' => 'name',
- 'target' => 'name',
- 'unique' => 1,
- ),
- );
- $this->addMappings('term_import', $mappings);
-
- // Use standalone form.
- $edit = array(
- 'content_type' => '',
- );
- $this->drupalPost('admin/structure/feeds/term_import/settings', $edit, 'Save');
+ // Create vocabulary.
$edit = array(
'name' => 'Addams vocabulary',
'machine_name' => 'addams',
);
$this->drupalPost('admin/structure/taxonomy/add', $edit, t('Save'));
- $edit = array(
- 'vocabulary' => 'addams',
+ $this->setSettings('term_import', 'FeedsTermProcessor', array('bundle' => 'addams'));
+
+ // Use standalone form.
+ $this->setSettings('term_import', NULL, array('content_type' => ''));
+ }
+
+ /**
+ * Test term creation, refreshing/deleting feeds and feed items.
+ */
+ public function test() {
+
+ $mappings = array(
+ 0 => array(
+ 'source' => 'name',
+ 'target' => 'name',
+ 'unique' => 1,
+ ),
);
- $this->drupalPost('admin/structure/feeds/term_import/settings/FeedsTermProcessor', $edit, t('Save'));
+ $this->addMappings('term_import', $mappings);
// Import and assert.
$this->importFile('term_import', $this->absolutePath() . '/tests/feeds/users.csv');
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_tests.info b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_tests.info
index deff209..5d887e2 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_tests.info
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/feeds_tests.info
@@ -6,9 +6,9 @@ core = 7.x
files[] = feeds_test.module
hidden = TRUE
-; Information added by drupal.org packaging script on 2012-10-10
-version = "7.x-2.0-alpha6"
+; Information added by drupal.org packaging script on 2013-04-22
+version = "7.x-2.0-alpha8"
core = "7.x"
project = "feeds"
-datestamp = "1349851321"
+datestamp = "1366671911"
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/parser_csv.test b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/parser_csv.test
index 6c8adfb..2905b39 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/parser_csv.test
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/tests/parser_csv.test
@@ -38,42 +38,50 @@ class ParserCSVTest extends DrupalWebTestCase {
* Simple test of parsing functionality.
*/
protected function _testSimple() {
- $file = $this->absolutePath() . '/tests/feeds/nodes.csv';
+ // Pull in the $control_result array.
include $this->absolutePath() . '/tests/feeds/nodes.csv.php';
- $iterator = new ParserCSVIterator($file);
- $parser = new ParserCSV();
- $parser->setDelimiter(',');
- $rows = $parser->parse($iterator);
- $this->assertFalse($parser->lastLinePos(), t('Parser reports all lines parsed'));
- $this->assertEqual(md5(serialize($rows)), md5(serialize($control_result)), t('Parsed result matches control result.'));
+ $delimiters = $this->getDelimiters();
+ foreach($delimiters as $delimiterType => $delimiter) {
+ $file = $this->absolutePath() . '/tests/feeds/nodes_' . $delimiterType . '.csv';
+ $iterator = new ParserCSVIterator($file);
+ $parser = new ParserCSV();
+ $parser->setDelimiter($delimiter);
+ $rows = $parser->parse($iterator);
+ $this->assertFalse($parser->lastLinePos(), t('CSV reports all lines parsed, with delimiter: ') . $delimiterType);
+ $this->assertEqual(md5(serialize($rows)), md5(serialize($control_result)), t('Parsed result matches control result.'));
+ }
}
/**
* Test batching.
*/
protected function _testBatching() {
- $file = $this->absolutePath() . '/tests/feeds/nodes.csv';
+ // Pull in the $control_result array
include $this->absolutePath() . '/tests/feeds/nodes.csv.php';
- // Set up parser with 2 lines to parse per call.
- $iterator = new ParserCSVIterator($file);
- $parser = new ParserCSV();
- $parser->setDelimiter(',');
- $parser->setLineLimit(2);
- $rows = array();
- $pos = 0;
+ $delimiters = $this->getDelimiters();
+ foreach($delimiters as $delimiterType => $delimiter) {
+ $file = $this->absolutePath() . '/tests/feeds/nodes_' . $delimiterType . '.csv';
+ // Set up parser with 2 lines to parse per call.
+ $iterator = new ParserCSVIterator($file);
+ $parser = new ParserCSV();
+ $parser->setDelimiter($delimiter);
+ $parser->setLineLimit(2);
+ $rows = array();
+ $pos = 0;
- // Call parser until all lines are parsed, then compare to control result.
- do {
- $parser->setStartByte($pos);
- $rows = array_merge($rows, $parser->parse($iterator));
- $pos = $parser->lastLinePos();
- $this->assertTrue($parser->lastLinePos() || count($rows) == 10, t('Parser reports line limit correctly'));
- }
- while ($pos = $parser->lastLinePos());
+ // Call parser until all lines are parsed, then compare to control result.
+ do {
+ $parser->setStartByte($pos);
+ $rows = array_merge($rows, $parser->parse($iterator));
+ $pos = $parser->lastLinePos();
+ $this->assertTrue($parser->lastLinePos() || count($rows) == 10, t('Parser reports line limit correctly'));
+ }
+ while ($pos = $parser->lastLinePos());
- $this->assertEqual(md5(serialize($rows)), md5(serialize($control_result)), t('Parsed result matches control result.'));
+ $this->assertEqual(md5(serialize($rows)), md5(serialize($control_result)), t('Batch parsed result matches control result for delimiter: ') . $delimiterType);
+ }
}
/**
@@ -82,4 +90,14 @@ class ParserCSVTest extends DrupalWebTestCase {
public function absolutePath() {
return DRUPAL_ROOT . '/' . drupal_get_path('module', 'feeds');
}
+
+ static function getDelimiters() {
+ return array(
+ 'comma' => ',',
+ 'pipe' => '|',
+ 'semicolon' => ';',
+ 'plus' => '+',
+ 'tab' => "\t",
+ );
+ }
}
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/views/feeds.views_default.inc b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/views/feeds.views_default.inc
index 97d7298..75dd53c 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/feeds/views/feeds.views_default.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/feeds/views/feeds.views_default.inc
@@ -11,16 +11,19 @@
function feeds_views_default_views() {
$views = array();
- $view = new view;
+ $view = new view();
$view->name = 'feeds_log';
$view->description = 'Feeds log displays for overview, standalone importers and feed nodes.';
$view->tag = 'Feeds';
$view->base_table = 'feeds_log';
- $view->api_version = '3.0-alpha1';
+ $view->human_name = 'Feeds log';
+ $view->core = 0;
+ $view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Defaults */
$handler = $view->new_display('default', 'Defaults', 'default');
+ $handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'administer feeds';
$handler->display->display_options['cache']['type'] = 'none';
@@ -30,73 +33,72 @@ function feeds_views_default_views() {
$handler->display->display_options['pager']['options']['items_per_page'] = '50';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['pager']['options']['id'] = '0';
+ $handler->display->display_options['pager']['options']['quantity'] = '9';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
'log_time' => 'log_time',
'request_time' => 'request_time',
'message' => 'message',
'severity' => 'severity',
+ 'importer_name' => 'importer_name',
+ 'title' => 'title',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
'log_time' => array(
'sortable' => 0,
+ 'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
+ 'empty_column' => 0,
),
'request_time' => array(
'sortable' => 0,
+ 'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
+ 'empty_column' => 0,
),
'message' => array(
'align' => '',
'separator' => '',
+ 'empty_column' => 0,
),
'severity' => array(
'align' => '',
'separator' => '',
+ 'empty_column' => 0,
+ ),
+ 'importer_name' => array(
+ 'align' => '',
+ 'separator' => '',
+ 'empty_column' => 0,
+ ),
+ 'title' => array(
+ 'sortable' => 0,
+ 'default_sort_order' => 'asc',
+ 'align' => '',
+ 'separator' => '',
+ 'empty_column' => 0,
),
);
- $handler->display->display_options['style_options']['override'] = 1;
- $handler->display->display_options['style_options']['sticky'] = 0;
- /* Empty text: Global: Text area */
+ /* No results behavior: Global: Text area */
$handler->display->display_options['empty']['area']['id'] = 'area';
$handler->display->display_options['empty']['area']['table'] = 'views';
$handler->display->display_options['empty']['area']['field'] = 'area';
- $handler->display->display_options['empty']['area']['empty'] = FALSE;
+ $handler->display->display_options['empty']['area']['empty'] = TRUE;
$handler->display->display_options['empty']['area']['content'] = 'There are no log messages.';
- $handler->display->display_options['empty']['area']['format'] = '1';
+ $handler->display->display_options['empty']['area']['format'] = 'plain_text';
/* Field: Feeds log: Log time */
$handler->display->display_options['fields']['log_time']['id'] = 'log_time';
$handler->display->display_options['fields']['log_time']['table'] = 'feeds_log';
$handler->display->display_options['fields']['log_time']['field'] = 'log_time';
- $handler->display->display_options['fields']['log_time']['alter']['alter_text'] = 0;
- $handler->display->display_options['fields']['log_time']['alter']['make_link'] = 0;
- $handler->display->display_options['fields']['log_time']['alter']['absolute'] = 0;
- $handler->display->display_options['fields']['log_time']['alter']['trim'] = 0;
- $handler->display->display_options['fields']['log_time']['alter']['word_boundary'] = 1;
- $handler->display->display_options['fields']['log_time']['alter']['ellipsis'] = 1;
- $handler->display->display_options['fields']['log_time']['alter']['strip_tags'] = 0;
- $handler->display->display_options['fields']['log_time']['alter']['html'] = 0;
- $handler->display->display_options['fields']['log_time']['hide_empty'] = 0;
- $handler->display->display_options['fields']['log_time']['empty_zero'] = 0;
$handler->display->display_options['fields']['log_time']['date_format'] = 'custom';
$handler->display->display_options['fields']['log_time']['custom_date_format'] = 'Y-m-d H:i:s';
/* Field: Feeds log: Request time */
$handler->display->display_options['fields']['request_time']['id'] = 'request_time';
$handler->display->display_options['fields']['request_time']['table'] = 'feeds_log';
$handler->display->display_options['fields']['request_time']['field'] = 'request_time';
- $handler->display->display_options['fields']['request_time']['alter']['alter_text'] = 0;
- $handler->display->display_options['fields']['request_time']['alter']['make_link'] = 0;
- $handler->display->display_options['fields']['request_time']['alter']['absolute'] = 0;
- $handler->display->display_options['fields']['request_time']['alter']['trim'] = 0;
- $handler->display->display_options['fields']['request_time']['alter']['word_boundary'] = 1;
- $handler->display->display_options['fields']['request_time']['alter']['ellipsis'] = 1;
- $handler->display->display_options['fields']['request_time']['alter']['strip_tags'] = 0;
- $handler->display->display_options['fields']['request_time']['alter']['html'] = 0;
- $handler->display->display_options['fields']['request_time']['hide_empty'] = 0;
- $handler->display->display_options['fields']['request_time']['empty_zero'] = 0;
$handler->display->display_options['fields']['request_time']['date_format'] = 'custom';
$handler->display->display_options['fields']['request_time']['custom_date_format'] = 'Y-m-d H:i:s';
/* Field: Feeds log: Log message */
@@ -104,85 +106,87 @@ function feeds_views_default_views() {
$handler->display->display_options['fields']['message']['table'] = 'feeds_log';
$handler->display->display_options['fields']['message']['field'] = 'message';
$handler->display->display_options['fields']['message']['label'] = 'Message';
- $handler->display->display_options['fields']['message']['hide_empty'] = 0;
- $handler->display->display_options['fields']['message']['empty_zero'] = 0;
/* Field: Feeds log: Severity */
$handler->display->display_options['fields']['severity']['id'] = 'severity';
$handler->display->display_options['fields']['severity']['table'] = 'feeds_log';
$handler->display->display_options['fields']['severity']['field'] = 'severity';
- $handler->display->display_options['fields']['severity']['hide_empty'] = 0;
- $handler->display->display_options['fields']['severity']['empty_zero'] = 0;
/* Sort criterion: Feeds log: Log time */
$handler->display->display_options['sorts']['log_time']['id'] = 'log_time';
$handler->display->display_options['sorts']['log_time']['table'] = 'feeds_log';
$handler->display->display_options['sorts']['log_time']['field'] = 'log_time';
$handler->display->display_options['sorts']['log_time']['order'] = 'DESC';
- /* Argument: Feeds log: Importer id */
+ /* Contextual filter: Feeds log: Importer id */
$handler->display->display_options['arguments']['id']['id'] = 'id';
$handler->display->display_options['arguments']['id']['table'] = 'feeds_log';
$handler->display->display_options['arguments']['id']['field'] = 'id';
$handler->display->display_options['arguments']['id']['default_action'] = 'empty';
- $handler->display->display_options['arguments']['id']['style_plugin'] = 'default_summary';
$handler->display->display_options['arguments']['id']['default_argument_type'] = 'fixed';
- $handler->display->display_options['arguments']['id']['validate_fail'] = 'empty';
- $handler->display->display_options['arguments']['id']['glossary'] = 0;
+ $handler->display->display_options['arguments']['id']['summary']['number_of_records'] = '0';
+ $handler->display->display_options['arguments']['id']['summary']['format'] = 'default_summary';
+ $handler->display->display_options['arguments']['id']['summary_options']['items_per_page'] = '25';
+ $handler->display->display_options['arguments']['id']['specify_validation'] = TRUE;
+ $handler->display->display_options['arguments']['id']['validate']['fail'] = 'empty';
$handler->display->display_options['arguments']['id']['limit'] = '0';
- $handler->display->display_options['arguments']['id']['transform_dash'] = 0;
- /* Filter: Feeds log: Feed node id */
+ /* Filter criterion: Feeds log: Feed node id */
$handler->display->display_options['filters']['feed_nid']['id'] = 'feed_nid';
$handler->display->display_options['filters']['feed_nid']['table'] = 'feeds_log';
$handler->display->display_options['filters']['feed_nid']['field'] = 'feed_nid';
$handler->display->display_options['filters']['feed_nid']['value']['value'] = '0';
- /* Filter: Feeds log: Severity */
+ /* Filter criterion: Feeds log: Severity */
$handler->display->display_options['filters']['severity']['id'] = 'severity';
$handler->display->display_options['filters']['severity']['table'] = 'feeds_log';
$handler->display->display_options['filters']['severity']['field'] = 'severity';
$handler->display->display_options['filters']['severity']['exposed'] = TRUE;
- $handler->display->display_options['filters']['severity']['expose']['operator'] = 'severity_op';
+ $handler->display->display_options['filters']['severity']['expose']['operator_id'] = 'severity_op';
$handler->display->display_options['filters']['severity']['expose']['label'] = 'Severity';
- $handler->display->display_options['filters']['severity']['expose']['use_operator'] = FALSE;
+ $handler->display->display_options['filters']['severity']['expose']['operator'] = 'severity_op';
$handler->display->display_options['filters']['severity']['expose']['identifier'] = 'severity';
- $handler->display->display_options['filters']['severity']['expose']['reduce'] = 0;
/* Display: Standalone importer page */
$handler = $view->new_display('page', 'Standalone importer page', 'page_1');
+ $handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['path'] = 'import/%/log';
$handler->display->display_options['menu']['type'] = 'tab';
$handler->display->display_options['menu']['title'] = 'Log';
$handler->display->display_options['menu']['weight'] = '0';
+ $handler->display->display_options['menu']['context'] = 0;
/* Display: Feed node page */
$handler = $view->new_display('page', 'Feed node page', 'page_2');
+ $handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['defaults']['arguments'] = FALSE;
- /* Argument: Feeds log: Feed node id */
+ /* Contextual filter: Feeds log: Feed node id */
$handler->display->display_options['arguments']['feed_nid']['id'] = 'feed_nid';
$handler->display->display_options['arguments']['feed_nid']['table'] = 'feeds_log';
$handler->display->display_options['arguments']['feed_nid']['field'] = 'feed_nid';
$handler->display->display_options['arguments']['feed_nid']['default_action'] = 'not found';
- $handler->display->display_options['arguments']['feed_nid']['style_plugin'] = 'default_summary';
$handler->display->display_options['arguments']['feed_nid']['default_argument_type'] = 'fixed';
- $handler->display->display_options['arguments']['feed_nid']['break_phrase'] = 0;
- $handler->display->display_options['arguments']['feed_nid']['not'] = 0;
+ $handler->display->display_options['arguments']['feed_nid']['summary']['number_of_records'] = '0';
+ $handler->display->display_options['arguments']['feed_nid']['summary']['format'] = 'default_summary';
+ $handler->display->display_options['arguments']['feed_nid']['summary_options']['items_per_page'] = '25';
+ $handler->display->display_options['defaults']['filter_groups'] = FALSE;
$handler->display->display_options['defaults']['filters'] = FALSE;
- /* Filter: Feeds log: Severity */
+ /* Filter criterion: Feeds log: Severity */
$handler->display->display_options['filters']['severity']['id'] = 'severity';
$handler->display->display_options['filters']['severity']['table'] = 'feeds_log';
$handler->display->display_options['filters']['severity']['field'] = 'severity';
$handler->display->display_options['filters']['severity']['exposed'] = TRUE;
- $handler->display->display_options['filters']['severity']['expose']['operator'] = 'severity_op';
+ $handler->display->display_options['filters']['severity']['expose']['operator_id'] = 'severity_op';
$handler->display->display_options['filters']['severity']['expose']['label'] = 'Severity';
- $handler->display->display_options['filters']['severity']['expose']['use_operator'] = FALSE;
+ $handler->display->display_options['filters']['severity']['expose']['operator'] = 'severity_op';
$handler->display->display_options['filters']['severity']['expose']['identifier'] = 'severity';
- $handler->display->display_options['filters']['severity']['expose']['reduce'] = 0;
+
$handler->display->display_options['path'] = 'node/%/log';
$handler->display->display_options['menu']['type'] = 'tab';
$handler->display->display_options['menu']['title'] = 'Log';
$handler->display->display_options['menu']['weight'] = '12';
+ $handler->display->display_options['menu']['context'] = 0;
/* Display: All entries */
$handler = $view->new_display('page', 'All entries', 'page_3');
$handler->display->display_options['defaults']['title'] = FALSE;
$handler->display->display_options['title'] = 'Feeds log';
+ $handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['defaults']['relationships'] = FALSE;
/* Relationship: Feeds log: Feed node */
$handler->display->display_options['relationships']['feed_nid']['id'] = 'feed_nid';
@@ -193,32 +197,12 @@ function feeds_views_default_views() {
$handler->display->display_options['fields']['log_time']['id'] = 'log_time';
$handler->display->display_options['fields']['log_time']['table'] = 'feeds_log';
$handler->display->display_options['fields']['log_time']['field'] = 'log_time';
- $handler->display->display_options['fields']['log_time']['alter']['alter_text'] = 0;
- $handler->display->display_options['fields']['log_time']['alter']['make_link'] = 0;
- $handler->display->display_options['fields']['log_time']['alter']['absolute'] = 0;
- $handler->display->display_options['fields']['log_time']['alter']['trim'] = 0;
- $handler->display->display_options['fields']['log_time']['alter']['word_boundary'] = 1;
- $handler->display->display_options['fields']['log_time']['alter']['ellipsis'] = 1;
- $handler->display->display_options['fields']['log_time']['alter']['strip_tags'] = 0;
- $handler->display->display_options['fields']['log_time']['alter']['html'] = 0;
- $handler->display->display_options['fields']['log_time']['hide_empty'] = 0;
- $handler->display->display_options['fields']['log_time']['empty_zero'] = 0;
$handler->display->display_options['fields']['log_time']['date_format'] = 'custom';
$handler->display->display_options['fields']['log_time']['custom_date_format'] = 'Y-m-d H:i:s';
/* Field: Feeds log: Request time */
$handler->display->display_options['fields']['request_time']['id'] = 'request_time';
$handler->display->display_options['fields']['request_time']['table'] = 'feeds_log';
$handler->display->display_options['fields']['request_time']['field'] = 'request_time';
- $handler->display->display_options['fields']['request_time']['alter']['alter_text'] = 0;
- $handler->display->display_options['fields']['request_time']['alter']['make_link'] = 0;
- $handler->display->display_options['fields']['request_time']['alter']['absolute'] = 0;
- $handler->display->display_options['fields']['request_time']['alter']['trim'] = 0;
- $handler->display->display_options['fields']['request_time']['alter']['word_boundary'] = 1;
- $handler->display->display_options['fields']['request_time']['alter']['ellipsis'] = 1;
- $handler->display->display_options['fields']['request_time']['alter']['strip_tags'] = 0;
- $handler->display->display_options['fields']['request_time']['alter']['html'] = 0;
- $handler->display->display_options['fields']['request_time']['hide_empty'] = 0;
- $handler->display->display_options['fields']['request_time']['empty_zero'] = 0;
$handler->display->display_options['fields']['request_time']['date_format'] = 'custom';
$handler->display->display_options['fields']['request_time']['custom_date_format'] = 'Y-m-d H:i:s';
/* Field: Feeds log: Log message */
@@ -226,58 +210,44 @@ function feeds_views_default_views() {
$handler->display->display_options['fields']['message']['table'] = 'feeds_log';
$handler->display->display_options['fields']['message']['field'] = 'message';
$handler->display->display_options['fields']['message']['label'] = 'Message';
- $handler->display->display_options['fields']['message']['hide_empty'] = 0;
- $handler->display->display_options['fields']['message']['empty_zero'] = 0;
/* Field: Feeds log: Severity */
$handler->display->display_options['fields']['severity']['id'] = 'severity';
$handler->display->display_options['fields']['severity']['table'] = 'feeds_log';
$handler->display->display_options['fields']['severity']['field'] = 'severity';
- $handler->display->display_options['fields']['severity']['hide_empty'] = 0;
- $handler->display->display_options['fields']['severity']['empty_zero'] = 0;
/* Field: Feeds log: Importer name */
$handler->display->display_options['fields']['importer_name']['id'] = 'importer_name';
$handler->display->display_options['fields']['importer_name']['table'] = 'feeds_log';
$handler->display->display_options['fields']['importer_name']['field'] = 'importer_name';
$handler->display->display_options['fields']['importer_name']['label'] = 'Importer';
- $handler->display->display_options['fields']['importer_name']['hide_empty'] = 0;
- $handler->display->display_options['fields']['importer_name']['empty_zero'] = 0;
$handler->display->display_options['fields']['importer_name']['link'] = '2';
- /* Field: Node: Title */
+ /* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['relationship'] = 'feed_nid';
$handler->display->display_options['fields']['title']['label'] = 'Feed node';
- $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
- $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
- $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
- $handler->display->display_options['fields']['title']['alter']['trim'] = 1;
$handler->display->display_options['fields']['title']['alter']['max_length'] = '40';
- $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 1;
- $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 1;
- $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
- $handler->display->display_options['fields']['title']['alter']['html'] = 0;
- $handler->display->display_options['fields']['title']['hide_empty'] = 0;
- $handler->display->display_options['fields']['title']['empty_zero'] = 0;
- $handler->display->display_options['fields']['title']['link_to_node'] = 1;
+ $handler->display->display_options['fields']['title']['alter']['trim'] = TRUE;
$handler->display->display_options['defaults']['arguments'] = FALSE;
+ $handler->display->display_options['defaults']['filter_groups'] = FALSE;
$handler->display->display_options['defaults']['filters'] = FALSE;
- /* Filter: Feeds log: Severity */
+ /* Filter criterion: Feeds log: Severity */
$handler->display->display_options['filters']['severity']['id'] = 'severity';
$handler->display->display_options['filters']['severity']['table'] = 'feeds_log';
$handler->display->display_options['filters']['severity']['field'] = 'severity';
$handler->display->display_options['filters']['severity']['exposed'] = TRUE;
- $handler->display->display_options['filters']['severity']['expose']['operator'] = 'severity_op';
+ $handler->display->display_options['filters']['severity']['expose']['operator_id'] = 'severity_op';
$handler->display->display_options['filters']['severity']['expose']['label'] = 'Severity';
- $handler->display->display_options['filters']['severity']['expose']['use_operator'] = FALSE;
+ $handler->display->display_options['filters']['severity']['expose']['operator'] = 'severity_op';
$handler->display->display_options['filters']['severity']['expose']['identifier'] = 'severity';
- $handler->display->display_options['filters']['severity']['expose']['reduce'] = 0;
+
$handler->display->display_options['path'] = 'admin/reports/feeds';
$handler->display->display_options['menu']['type'] = 'normal';
$handler->display->display_options['menu']['title'] = 'Feeds log';
$handler->display->display_options['menu']['description'] = 'Review log messages of imports and subscriptions to feeds.';
$handler->display->display_options['menu']['weight'] = '0';
$handler->display->display_options['menu']['name'] = 'management';
+ $handler->display->display_options['menu']['context'] = 0;
$views[$view->name] = $view;