Révision ed9a13f1
Ajouté par Assos Assos il y a plus de 3 ans
drupal7/sites/all/modules/feeds/CHANGELOG.txt | ||
---|---|---|
573 | 573 |
- Issue #1739704 by axel.rutz: Fixed Node lookup by title in Nodeprocessor does |
574 | 574 |
not respect nodetype. |
575 | 575 |
- Issue #1690434 by twistor | jzornig: Fixed Notice: Undefined variable: job in |
576 |
FeedsSource->scheduleClear() |
|
576 |
FeedsSource->scheduleClear().
|
|
577 | 577 |
- Issue #1703074 by theduke: Added Include parser result in |
578 | 578 |
hook_feeds_presave(). |
579 | 579 |
- Issue #1070604 by Bobík: Added Feed's nid in mappings. |
... | ... | |
760 | 760 |
feed is updated. |
761 | 761 |
- Issue #1048642 by greg.harvey: Check for remove_flags in Feeds UI before using |
762 | 762 |
that variable. |
763 |
- #967018 jcarlson34, David Goode, alex_b: Mapping to String lists not supported |
|
763 |
- #967018 jcarlson34, David Goode, alex_b: Mapping to String lists not |
|
764 |
supported. |
|
764 | 765 |
|
765 | 766 |
Feeds 7.x 2.0 Alpha 3, 2011-01-14 |
766 | 767 |
--------------------------------- |
drupal7/sites/all/modules/feeds/feeds.api.php | ||
---|---|---|
6 | 6 |
*/ |
7 | 7 |
|
8 | 8 |
/** |
9 |
* Feeds offers a CTools based plugin API. Fetchers, parsers and processors are |
|
10 |
* declared to Feeds as plugins. |
|
9 |
* @defgroup pluginapi Plugin API |
|
10 |
* @{ |
|
11 |
* Feeds offers a CTools based plugin API. |
|
12 |
* |
|
13 |
* Fetchers, parsers and processors are declared to Feeds as plugins. |
|
11 | 14 |
* |
12 | 15 |
* @see feeds_feeds_plugins() |
13 | 16 |
* @see FeedsFetcher |
14 | 17 |
* @see FeedsParser |
15 | 18 |
* @see FeedsProcessor |
16 |
* |
|
17 |
* @defgroup pluginapi Plugin API |
|
18 |
* @{ |
|
19 | 19 |
*/ |
20 | 20 |
|
21 | 21 |
/** |
22 |
* Example of a CTools plugin hook that needs to be implemented to make |
|
22 |
* CTools plugin hook example. |
|
23 |
* |
|
24 |
* This example of a CTools plugin hook needs to be implemented to make |
|
23 | 25 |
* hook_feeds_plugins() discoverable by CTools and Feeds. The hook specifies |
24 | 26 |
* that the hook_feeds_plugins() returns Feeds Plugin API version 1 style |
25 | 27 |
* plugins. |
... | ... | |
31 | 33 |
} |
32 | 34 |
|
33 | 35 |
/** |
34 |
* A hook_feeds_plugins() declares available Fetcher, Parser or Processor |
|
35 |
* plugins to Feeds. For an example look at feeds_feeds_plugin(). For exposing |
|
36 |
* this hook hook_ctools_plugin_api() MUST be implemented, too. |
|
36 |
* Declare Feeds plugins. |
|
37 |
* |
|
38 |
* Implement this hook to declare Fetcher, Parser or Processor plugins for |
|
39 |
* Feeds. For a working example implementation, see feeds_feeds_plugin(). |
|
40 |
* In order for this hook to be invoked, you MUST implement |
|
41 |
* hook_ctools_plugin_api() as well. |
|
37 | 42 |
* |
38 | 43 |
* @see feeds_feeds_plugin() |
39 | 44 |
*/ |
... | ... | |
47 | 52 |
'parent' => 'FeedsFetcher', |
48 | 53 |
'class' => 'MyFetcher', |
49 | 54 |
'file' => 'MyFetcher.inc', |
50 |
'path' => drupal_get_path('module', 'my_module'), // Feeds will look for MyFetcher.inc in the my_module directory. |
|
55 |
// Feeds will look for MyFetcher.inc in the my_module directory. |
|
56 |
'path' => drupal_get_path('module', 'my_module'), |
|
51 | 57 |
), |
52 | 58 |
); |
53 | 59 |
$info['MyParser'] = array( |
... | ... | |
55 | 61 |
'description' => 'Parse my stuff.', |
56 | 62 |
'help' => 'More verbose description here. Will be displayed on parser selection menu.', |
57 | 63 |
'handler' => array( |
58 |
'parent' => 'FeedsParser', // Being directly or indirectly an extension of FeedsParser makes a plugin a parser plugin. |
|
64 |
// Being directly or indirectly an extension of FeedsParser makes a plugin |
|
65 |
// a parser plugin. |
|
66 |
'parent' => 'FeedsParser', |
|
59 | 67 |
'class' => 'MyParser', |
60 | 68 |
'file' => 'MyParser.inc', |
61 | 69 |
'path' => drupal_get_path('module', 'my_module'), |
... | ... | |
76 | 84 |
} |
77 | 85 |
|
78 | 86 |
/** |
79 |
* @} |
|
87 |
* @} End of "defgroup pluginapi".
|
|
80 | 88 |
*/ |
81 | 89 |
|
82 | 90 |
/** |
... | ... | |
88 | 96 |
* Invoked after a feed source has been parsed, before it will be processed. |
89 | 97 |
* |
90 | 98 |
* @param FeedsSource $source |
91 |
* FeedsSource object that describes the source that has been imported. |
|
99 |
* FeedsSource object that describes the source that has been imported.
|
|
92 | 100 |
* @param FeedsParserResult $result |
93 | 101 |
* FeedsParserResult object that has been parsed from the source. |
94 | 102 |
*/ |
... | ... | |
101 | 109 |
* Invoked before a feed source import starts. |
102 | 110 |
* |
103 | 111 |
* @param FeedsSource $source |
104 |
* FeedsSource object that describes the source that is going to be imported. |
|
112 |
* FeedsSource object that describes the source that is going to be imported.
|
|
105 | 113 |
*/ |
106 | 114 |
function hook_feeds_before_import(FeedsSource $source) { |
107 | 115 |
// See feeds_rules module's implementation for an example. |
... | ... | |
114 | 122 |
* updated or not. |
115 | 123 |
* |
116 | 124 |
* @param FeedsSource $source |
117 |
* The source for the current feed. |
|
125 |
* The source for the current feed.
|
|
118 | 126 |
* @param array $item |
119 |
* All the current item from the feed. |
|
127 |
* All the current item from the feed.
|
|
120 | 128 |
* @param int|null $entity_id |
121 |
* The id of the current item which is going to be updated. If this is a new |
|
122 |
* item, then NULL is passed. |
|
129 |
* The id of the current item which is going to be updated. If this is a new
|
|
130 |
* item, then NULL is passed.
|
|
123 | 131 |
*/ |
124 | 132 |
function hook_feeds_before_update(FeedsSource $source, $item, $entity_id) { |
125 | 133 |
if ($entity_id) { |
126 | 134 |
$processor = $source->importer->processor; |
127 | 135 |
db_update('foo_bar') |
128 |
->fields(array('entity_type' => $processor->entityType(), 'entity_id' => $entity_id, 'last_seen' => REQUEST_TIME)) |
|
136 |
->fields(array( |
|
137 |
'entity_type' => $processor->entityType(), |
|
138 |
'entity_id' => $entity_id, |
|
139 |
'last_seen' => REQUEST_TIME, |
|
140 |
)) |
|
129 | 141 |
->condition('entity_type', $processor->entityType()) |
130 | 142 |
->condition('entity_id', $entity_id) |
131 | 143 |
->execute(); |
132 | 144 |
} |
133 | 145 |
} |
134 | 146 |
|
147 |
/** |
|
148 |
* Invoked before a feed item is validated. |
|
149 |
* |
|
150 |
* @param FeedsSource $source |
|
151 |
* FeedsSource object that describes the source that is being imported. |
|
152 |
* @param object $entity |
|
153 |
* The entity object. |
|
154 |
* @param array $item |
|
155 |
* The parser result for this entity. |
|
156 |
* @param int|null $entity_id |
|
157 |
* The id of the current item which is going to be updated. If this is a new |
|
158 |
* item, then NULL is passed. |
|
159 |
*/ |
|
160 |
function hook_feeds_prevalidate(FeedsSource $source, $entity, $item, $entity_id) { |
|
161 |
// Correct a field value to make it pass validation. |
|
162 |
if (isset($entity->myfield)) { |
|
163 |
foreach ($entity->myfield as $language => &$values) { |
|
164 |
// There are only three values allowed. Throw away the rest. |
|
165 |
if (count($values) > 3) { |
|
166 |
$values = array_slice($values, 0, 3); |
|
167 |
} |
|
168 |
} |
|
169 |
} |
|
170 |
} |
|
171 |
|
|
135 | 172 |
/** |
136 | 173 |
* Invoked before a feed item is saved. |
137 | 174 |
* |
138 | 175 |
* @param FeedsSource $source |
139 | 176 |
* FeedsSource object that describes the source that is being imported. |
140 |
* @param $entity |
|
177 |
* @param object $entity
|
|
141 | 178 |
* The entity object. |
142 | 179 |
* @param array $item |
143 | 180 |
* The parser result for this entity. |
... | ... | |
156 | 193 |
* Invoked after a feed item has been saved. |
157 | 194 |
* |
158 | 195 |
* @param FeedsSource $source |
159 |
* FeedsSource object that describes the source that is being imported. |
|
160 |
* @param $entity |
|
196 |
* FeedsSource object that describes the source that is being imported.
|
|
197 |
* @param object $entity
|
|
161 | 198 |
* The entity object that has just been saved. |
162 | 199 |
* @param array $item |
163 | 200 |
* The parser result for this entity. |
164 | 201 |
* @param int|null $entity_id |
165 |
* The id of the current item which is going to be updated. If this is a new |
|
166 |
* item, then NULL is passed. |
|
202 |
* The id of the current item which is going to be updated. If this is a new
|
|
203 |
* item, then NULL is passed.
|
|
167 | 204 |
*/ |
168 | 205 |
function hook_feeds_after_save(FeedsSource $source, $entity, $item, $entity_id) { |
169 |
// Use $entity->nid of the saved node. |
|
170 |
|
|
171 | 206 |
// Although the $entity object is passed by reference, any changes made in |
172 | 207 |
// this function will be ignored by the FeedsProcessor. |
173 | 208 |
$config = $source->importer->getConfig(); |
... | ... | |
184 | 219 |
* Invoked after a feed source has been imported. |
185 | 220 |
* |
186 | 221 |
* @param FeedsSource $source |
187 |
* FeedsSource object that describes the source that has been imported. |
|
222 |
* FeedsSource object that describes the source that has been imported.
|
|
188 | 223 |
*/ |
189 | 224 |
function hook_feeds_after_import(FeedsSource $source) { |
190 |
// See geotaxonomy module's implementation for an example. |
|
191 |
|
|
192 | 225 |
// We can also check for an exception in this hook. The exception should not |
193 | 226 |
// be thrown here, Feeds will handle it. |
194 | 227 |
if (isset($source->exception)) { |
... | ... | |
201 | 234 |
* Invoked after a feed source has been cleared of its items. |
202 | 235 |
* |
203 | 236 |
* @param FeedsSource $source |
204 |
* FeedsSource object that describes the source that has been cleared. |
|
237 |
* FeedsSource object that describes the source that has been cleared.
|
|
205 | 238 |
*/ |
206 | 239 |
function hook_feeds_after_clear(FeedsSource $source) { |
207 | 240 |
} |
208 | 241 |
|
209 | 242 |
/** |
210 |
* @} |
|
243 |
* @} End of "defgroup import".
|
|
211 | 244 |
*/ |
212 | 245 |
|
213 | 246 |
/** |
... | ... | |
221 | 254 |
* Use this hook to add additional mapping sources for any parser. Allows for |
222 | 255 |
* registering a callback to be invoked at mapping time. |
223 | 256 |
* |
224 |
* @see my_source_get_source().
|
|
225 |
* @see locale_feeds_parser_sources_alter().
|
|
257 |
* @see my_source_get_source() |
|
258 |
* @see locale_feeds_parser_sources_alter() |
|
226 | 259 |
*/ |
227 | 260 |
function hook_feeds_parser_sources_alter(&$sources, $content_type) { |
228 | 261 |
$sources['my_source'] = array( |
229 | 262 |
'name' => t('Images in description element'), |
230 | 263 |
'description' => t('Images occurring in the description element of a feed item.'), |
231 |
'callback' => 'my_source_get_source', |
|
264 |
'callback' => 'callback_my_source_get_source',
|
|
232 | 265 |
); |
233 | 266 |
} |
234 | 267 |
|
235 | 268 |
/** |
236 |
* Example callback specified in hook_feeds_parser_sources_alter().
|
|
269 |
* Returns a value to use as a mapping source.
|
|
237 | 270 |
* |
238 |
* To be invoked on mapping time.
|
|
271 |
* Callback for hook_feeds_parser_sources_alter().
|
|
239 | 272 |
* |
240 |
* @param $source |
|
273 |
* This function is called on mapping time. |
|
274 |
* |
|
275 |
* @param FeedsSource $source |
|
241 | 276 |
* The FeedsSource object being imported. |
242 |
* @param $result |
|
277 |
* @param FeedsParserResult $result
|
|
243 | 278 |
* The FeedsParserResult object being mapped from. |
244 |
* @param $key |
|
279 |
* @param string $key
|
|
245 | 280 |
* The key specified in the $sources array in |
246 | 281 |
* hook_feeds_parser_sources_alter(). |
247 | 282 |
* |
248 |
* @return |
|
283 |
* @return mixed
|
|
249 | 284 |
* The value to be extracted from the source. |
250 | 285 |
* |
251 | 286 |
* @see hook_feeds_parser_sources_alter() |
252 | 287 |
* @see locale_feeds_get_source() |
288 |
* |
|
289 |
* @ingroup callbacks |
|
253 | 290 |
*/ |
254 |
function my_source_get_source(FeedsSource $source, FeedsParserResult $result, $key) { |
|
291 |
function callback_my_source_get_source(FeedsSource $source, FeedsParserResult $result, $key) {
|
|
255 | 292 |
$item = $result->currentItem(); |
256 | 293 |
return my_source_parse_images($item['description']); |
257 | 294 |
} |
... | ... | |
310 | 347 |
$targets['my_node_field'] = array( |
311 | 348 |
'name' => t('My custom node field'), |
312 | 349 |
'description' => t('Description of what my custom node field does.'), |
313 |
'callback' => 'my_module_set_target', |
|
350 |
'callback' => 'callback_my_module_set_target',
|
|
314 | 351 |
); |
315 | 352 |
|
316 | 353 |
// Example 2: specify "real_target" if the target name is different from |
... | ... | |
335 | 372 |
'description' => t('A field that can be set as an unique target.'), |
336 | 373 |
'callback' => 'my_module_set_target3', |
337 | 374 |
'optional_unique' => TRUE, |
338 |
'unique_callbacks' => array('my_module_mapper_unique'), |
|
375 |
'unique_callbacks' => array('callback_my_module_mapper_unique'),
|
|
339 | 376 |
); |
340 | 377 |
|
341 | 378 |
// Example 4: use the form and summary callbacks to add additional |
... | ... | |
348 | 385 |
'name' => t('My fourth custom node field'), |
349 | 386 |
'description' => t('A field with additional configuration.'), |
350 | 387 |
'callback' => 'my_module_set_target4', |
351 |
'form_callbacks' => array('my_module_form_callback'), |
|
352 |
'summary_callbacks' => array('my_module_summary_callback'), |
|
388 |
'form_callbacks' => array('callback_my_module_form_callback'),
|
|
389 |
'summary_callbacks' => array('callback_my_module_summary_callback'),
|
|
353 | 390 |
); |
354 | 391 |
|
355 | 392 |
// Example 5: use preprocess callbacks to set or change mapping options. |
... | ... | |
358 | 395 |
'name' => t('My fifth custom node field'), |
359 | 396 |
'description' => t('A field with additional configuration.'), |
360 | 397 |
'callback' => 'my_module_set_target5', |
361 |
'preprocess_callbacks' => array('my_module_preprocess_callback'), |
|
398 |
'preprocess_callbacks' => array('callback_my_module_preprocess_callback'),
|
|
362 | 399 |
); |
363 | 400 |
|
364 | 401 |
// Example 6: when you want to remove or rename previously provided targets, |
... | ... | |
402 | 439 |
} |
403 | 440 |
|
404 | 441 |
/** |
405 |
* Example callback specified in hook_feeds_processor_targets(). |
|
442 |
* Sets a value on a target. |
|
443 |
* |
|
444 |
* Callback for hook_feeds_processor_targets(). |
|
445 |
* |
|
446 |
* This callback is specified on the 'callback' key of the target definition. |
|
447 |
* A target can for example be a field or property on an entity. |
|
406 | 448 |
* |
407 | 449 |
* @param FeedsSource $source |
408 | 450 |
* Field mapper source settings. |
... | ... | |
413 | 455 |
* @param array $values |
414 | 456 |
* The value to populate the target with. |
415 | 457 |
* @param array $mapping |
416 |
* Associative array of the mapping settings from the per mapping |
|
417 |
* configuration form. |
|
458 |
* Associative array of the mapping settings from the per mapping |
|
459 |
* configuration form. |
|
460 |
* |
|
461 |
* @see hook_feeds_processor_targets() |
|
462 |
* |
|
463 |
* @ingroup callbacks |
|
418 | 464 |
*/ |
419 |
function my_module_set_target(FeedsSource $source, $entity, $target, array $values, array $mapping) { |
|
465 |
function callback_my_module_set_target(FeedsSource $source, $entity, $target, array $values, array $mapping) {
|
|
420 | 466 |
$entity->{$target}[$entity->language][0]['value'] = reset($values); |
421 | 467 |
if (isset($source->importer->processor->config['input_format'])) { |
422 | 468 |
$entity->{$target}[$entity->language][0]['format'] = $source->importer->processor->config['input_format']; |
... | ... | |
424 | 470 |
} |
425 | 471 |
|
426 | 472 |
/** |
427 |
* Example of the form_callback specified in hook_feeds_processor_targets(). |
|
473 |
* Returns a form for configuring a target. |
|
474 |
* |
|
475 |
* Callback for hook_feeds_processor_targets(). |
|
428 | 476 |
* |
429 |
* The arguments are the same that my_module_summary_callback() gets. |
|
477 |
* This callback is specified on the 'form_callbacks' key of the target |
|
478 |
* definition. |
|
479 |
* The arguments are the same that callback_my_module_summary_callback() gets. |
|
430 | 480 |
* |
431 | 481 |
* @return array |
432 | 482 |
* The per mapping configuration form. Once the form is saved, $mapping will |
433 | 483 |
* be populated with the form values. |
434 | 484 |
* |
435 |
* @see my_module_summary_callback() |
|
485 |
* @see hook_feeds_processor_targets() |
|
486 |
* @see callback_my_module_summary_callback() |
|
487 |
* |
|
488 |
* @ingroup callbacks |
|
436 | 489 |
*/ |
437 |
function my_module_form_callback(array $mapping, $target, array $form, array $form_state) { |
|
490 |
function callback_my_module_form_callback(array $mapping, $target, array $form, array $form_state) {
|
|
438 | 491 |
return array( |
439 | 492 |
'my_setting' => array( |
440 | 493 |
'#type' => 'checkbox', |
... | ... | |
445 | 498 |
} |
446 | 499 |
|
447 | 500 |
/** |
448 |
* Example of the summary_callback specified in hook_feeds_processor_targets(). |
|
501 |
* Returns a string for displaying the target configuration. |
|
502 |
* |
|
503 |
* Callback for hook_feeds_processor_targets(). |
|
504 |
* |
|
505 |
* This callback is specified on the 'summary_callbacks' key of the target |
|
506 |
* definition. |
|
507 |
* The arguments are the same that callback_my_module_form_callback() gets. |
|
449 | 508 |
* |
450 | 509 |
* @param array $mapping |
451 | 510 |
* Associative array of the mapping settings. |
... | ... | |
462 | 521 |
* the full form isn't visible. |
463 | 522 |
* If the return value is empty, no summary and no option to view the form |
464 | 523 |
* will be displayed. |
524 |
* |
|
525 |
* @see hook_feeds_processor_targets() |
|
526 |
* @see callback_my_module_form_callback() |
|
527 |
* |
|
528 |
* @ingroup callbacks |
|
465 | 529 |
*/ |
466 |
function my_module_summary_callback(array $mapping, $target, array $form, array $form_state) { |
|
530 |
function callback_my_module_summary_callback(array $mapping, $target, array $form, array $form_state) {
|
|
467 | 531 |
if (empty($mapping['my_setting'])) { |
468 | 532 |
return t('My setting <strong>not</strong> active'); |
469 | 533 |
} |
... | ... | |
473 | 537 |
} |
474 | 538 |
|
475 | 539 |
/** |
476 |
* Example of the unique_callbacks specified in hook_feeds_processor_targets(). |
|
540 |
* Looks for an existing entity and returns an entity ID if found. |
|
541 |
* |
|
542 |
* Callback for hook_feeds_processor_targets(). |
|
543 |
* |
|
544 |
* This callback is specified on the 'unique_callbacks' key of the target |
|
545 |
* definition. |
|
477 | 546 |
* |
478 | 547 |
* @param FeedsSource $source |
479 | 548 |
* The Feed source. |
... | ... | |
491 | 560 |
* |
492 | 561 |
* @see hook_feeds_processor_targets() |
493 | 562 |
* @see FeedsProcessor::existingEntityId() |
563 |
* |
|
564 |
* @ingroup callbacks |
|
494 | 565 |
*/ |
495 |
function my_module_mapper_unique(FeedsSource $source, $entity_type, $bundle, $target, array $values) { |
|
566 |
function callback_my_module_mapper_unique(FeedsSource $source, $entity_type, $bundle, $target, array $values) {
|
|
496 | 567 |
list($field_name, $column) = explode(':', $target . ':value'); |
497 | 568 |
// Example for if the target is a field. |
498 | 569 |
$query = new EntityFieldQuery(); |
... | ... | |
508 | 579 |
} |
509 | 580 |
|
510 | 581 |
/** |
511 |
* Example of the preprocess_callbacks specified in hook_feeds_processor_targets(). |
|
582 |
* Changes or sets a mapping option. |
|
583 |
* |
|
584 |
* Callback for hook_feeds_processor_targets(). |
|
585 |
* |
|
586 |
* This callback is specified on the 'preprocess_callbacks' key of the target |
|
587 |
* definition. |
|
512 | 588 |
* |
513 | 589 |
* @param array $target |
514 | 590 |
* The full target definition. |
... | ... | |
516 | 592 |
* The mapping configuration. |
517 | 593 |
* |
518 | 594 |
* @see hook_feeds_processor_targets() |
595 |
* |
|
596 |
* @ingroup callbacks |
|
519 | 597 |
*/ |
520 |
function my_module_preprocess_callback(array $target, array &$mapping) { |
|
598 |
function callback_my_module_preprocess_callback(array $target, array &$mapping) {
|
|
521 | 599 |
// Add in default values. |
522 | 600 |
$mapping += array('setting_value' => TRUE); |
523 | 601 |
} |
524 | 602 |
|
525 | 603 |
/** |
526 |
* This hooks allows you add additional configuration keys to a |
|
527 |
* FeedsConfigurable. |
|
604 |
* Add additional configuration keys to FeedsConfigurable. |
|
605 |
* |
|
606 |
* This hooks allows you to add additional configuration keys to a |
|
607 |
* FeedsConfigurable. This is useful if you also implement a form alter hook to |
|
608 |
* provide extra options for existing Feeds plugins. By implementing one of the |
|
609 |
* Feeds hooks that are invoked during importing, you can act upon such setting. |
|
528 | 610 |
* |
529 | 611 |
* @param FeedsConfigurable $configurable |
530 | 612 |
* The configurable item to add default configuration to. |
... | ... | |
542 | 624 |
} |
543 | 625 |
|
544 | 626 |
/** |
545 |
* A plugin-specific hook to add additional configuration keys instead of the |
|
546 |
* global hook_feeds_config_defaults(). |
|
627 |
* A plugin-specific hook to add additional configuration keys. |
|
628 |
* |
|
629 |
* This hook can be used instead of the global hook_feeds_config_defaults() and |
|
630 |
* allows you to add additional configuration keys to a FeedsPlugin. |
|
547 | 631 |
* |
548 | 632 |
* The plugin type can be: |
549 |
* - fetcher |
|
550 |
* - parser |
|
551 |
* - processor |
|
633 |
* - fetcher;
|
|
634 |
* - parser;
|
|
635 |
* - processor.
|
|
552 | 636 |
* |
553 | 637 |
* @param FeedsPlugin $plugin |
554 | 638 |
* The plugin to add default configuration to. |
555 | 639 |
* |
556 | 640 |
* @return array |
557 | 641 |
* Return an array of default configuration. |
642 |
* |
|
643 |
* @see hook_feeds_config_defaults() |
|
558 | 644 |
*/ |
559 | 645 |
function hook_feeds_PLUGIN_TYPE_config_defaults(FeedsPlugin $plugin) { |
560 | 646 |
if ($plugin instanceof FeedsCSVParser) { |
... | ... | |
565 | 651 |
} |
566 | 652 |
|
567 | 653 |
/** |
568 |
* @} |
|
654 |
* @} End of "defgroup mappingapi".
|
|
569 | 655 |
*/ |
drupal7/sites/all/modules/feeds/feeds.drush.inc | ||
---|---|---|
139 | 139 |
switch ($section) { |
140 | 140 |
case 'drush:feeds-list-importers': |
141 | 141 |
return dt('Show a list of available Feeds importers with information about them.'); |
142 |
|
|
142 | 143 |
case 'drush:feeds-list-feeds': |
143 | 144 |
return dt("List all feed sources. You can limit the number of feed sources to display by setting the option '--limit'."); |
145 |
|
|
144 | 146 |
case 'drush:feeds-import': |
145 | 147 |
$help = dt("Import items from a feed. Follow the command with the importer name to import items with. If the importer is attached to a content type, specify also the feed node with the option '--nid'."); |
146 | 148 |
$help .= "\n" . dt("Note that the options '--file', '--stdin' and '--url' temporary bypass the configured fetcher and do *not* update the source configuration. For example, if a file was uploaded for the feed source, that file will remain there even when you specify a different file using the '--file' option. Same story applies for when importing from a url. If you omit these options, the last stored source will be used."); |
147 | 149 |
return $help; |
150 |
|
|
148 | 151 |
case 'drush:feeds-import-all': |
149 | 152 |
return dt('Import items from all feeds. Optionally specify the importer name to import all feeds for.'); |
153 |
|
|
150 | 154 |
case 'drush:feeds-clear': |
151 | 155 |
return dt("Delete all items from a feed. Follow the command with the importer name to delete items from. If the importer is attached to a content type, specify also the feed node with the option '--nid'."); |
156 |
|
|
152 | 157 |
case 'drush:feeds-enable': |
153 | 158 |
return dt('Enable the specified Feeds importers. Follow the command with a space delimited list of importer names.'); |
159 |
|
|
154 | 160 |
case 'drush:feeds-disable': |
155 | 161 |
return dt('Disable the specified Feeds importers. Follow the command with a space delimited list of importer names.'); |
162 |
|
|
156 | 163 |
case 'drush:feeds-delete': |
157 | 164 |
return dt('Delete the specified Feeds importers. Follow the command with a space delimited list of importer names.'); |
165 |
|
|
158 | 166 |
case 'drush:feeds-revert': |
159 | 167 |
return dt('Revert the specified Feeds importers. Follow the command with a space delimited list of importer names.'); |
160 | 168 |
} |
... | ... | |
841 | 849 |
* NULL otherwise. |
842 | 850 |
*/ |
843 | 851 |
function _drush_feeds_find_file($filename) { |
844 |
// If the full path to the file is specified, the file will be found right away. |
|
852 |
// If the full path to the file is specified, the file will be found right |
|
853 |
// away. |
|
845 | 854 |
if (is_file($filename)) { |
846 | 855 |
// Found! |
847 | 856 |
return $filename; |
drupal7/sites/all/modules/feeds/feeds.info | ||
---|---|---|
5 | 5 |
dependencies[] = ctools |
6 | 6 |
dependencies[] = job_scheduler |
7 | 7 |
|
8 |
test_dependencies[] = ctools:ctools (<= 7.x-1.12) |
|
8 | 9 |
test_dependencies[] = date:date |
9 | 10 |
test_dependencies[] = entity_translation:entity_translation |
10 | 11 |
test_dependencies[] = feeds_xpathparser:feeds_xpathparser |
11 | 12 |
test_dependencies[] = i18n:i18n_taxonomy |
12 | 13 |
test_dependencies[] = link:link |
14 |
test_dependencies[] = og:og |
|
13 | 15 |
test_dependencies[] = rules:rules |
14 | 16 |
test_dependencies[] = variable:variable |
15 | 17 |
|
18 |
files[] = includes/FeedsAccountSwitcher.inc |
|
19 |
files[] = includes/FeedsAccountSwitcherException.inc |
|
20 |
files[] = includes/FeedsAccountSwitcherInterface.inc |
|
16 | 21 |
files[] = includes/FeedsConfigurable.inc |
17 | 22 |
files[] = includes/FeedsHTTPCache.inc |
18 | 23 |
files[] = includes/FeedsHTTPCacheItem.inc |
... | ... | |
65 | 70 |
files[] = tests/feeds_i18n_node.test |
66 | 71 |
files[] = tests/feeds_i18n_taxonomy.test |
67 | 72 |
files[] = tests/feeds_install.test |
73 |
files[] = tests/feeds_og.test |
|
68 | 74 |
files[] = tests/feeds_parser_csv.test |
69 | 75 |
files[] = tests/feeds_parser_sitemap.test |
70 | 76 |
files[] = tests/feeds_parser_syndication.test |
... | ... | |
78 | 84 |
files[] = tests/feeds_mapper_summary.test |
79 | 85 |
files[] = tests/feeds_mapper_taxonomy.test |
80 | 86 |
files[] = tests/feeds_tokens.test |
87 |
files[] = tests/FeedsAccountSwitcherTest.test |
|
81 | 88 |
files[] = tests/FeedsEnclosureTest.test |
82 | 89 |
files[] = tests/FeedsFetcherResultTest.test |
83 | 90 |
files[] = tests/FeedsHTTPCacheTest.test |
... | ... | |
94 | 101 |
files[] = views/feeds_views_handler_filter_severity.inc |
95 | 102 |
files[] = views/feeds_views_plugin_argument_validate_feed_nid.inc |
96 | 103 |
|
97 |
; Information added by Drupal.org packaging script on 2017-09-24
|
|
98 |
version = "7.x-2.0-beta4"
|
|
104 |
; Information added by Drupal.org packaging script on 2020-08-13
|
|
105 |
version = "7.x-2.0-beta5"
|
|
99 | 106 |
core = "7.x" |
100 | 107 |
project = "feeds" |
101 |
datestamp = "1506257048" |
|
102 |
|
|
108 |
datestamp = "1597331284" |
drupal7/sites/all/modules/feeds/feeds.install | ||
---|---|---|
106 | 106 |
'export' => array( |
107 | 107 |
'key' => 'id', |
108 | 108 |
'identifier' => 'feeds_importer', |
109 |
'default hook' => 'feeds_importer_default', // Function hook name. |
|
109 |
// Function hook name. |
|
110 |
'default hook' => 'feeds_importer_default', |
|
110 | 111 |
'api' => array( |
111 | 112 |
'owner' => 'feeds', |
112 |
'api' => 'feeds_importer_default', // Base name for api include files. |
|
113 |
// Base name for api include files. |
|
114 |
'api' => 'feeds_importer_default', |
|
113 | 115 |
'minimum_version' => 1, |
114 | 116 |
'current_version' => 1, |
115 | 117 |
), |
... | ... | |
233 | 235 |
'guid' => array( |
234 | 236 |
'type' => 'text', |
235 | 237 |
'not null' => TRUE, |
236 |
'description' => 'Unique identifier for the feed item.' |
|
238 |
'description' => 'Unique identifier for the feed item.',
|
|
237 | 239 |
), |
238 | 240 |
'hash' => array( |
239 | 241 |
'type' => 'varchar', |
240 |
'length' => 32, // The length of an MD5 hash. |
|
242 |
// 32 is the length of an MD5 hash. |
|
243 |
'length' => 32, |
|
241 | 244 |
'not null' => TRUE, |
242 | 245 |
'default' => '', |
243 | 246 |
'description' => 'The hash of the source item.', |
... | ... | |
476 | 479 |
'guid' => array( |
477 | 480 |
'type' => 'text', |
478 | 481 |
'not null' => TRUE, |
479 |
'description' => 'Unique identifier for the feed item.' |
|
482 |
'description' => 'Unique identifier for the feed item.',
|
|
480 | 483 |
), |
481 | 484 |
'hash' => array( |
482 | 485 |
'type' => 'varchar', |
483 |
'length' => 32, // The length of an MD5 hash. |
|
486 |
// 32 is the length of an MD5 hash. |
|
487 |
'length' => 32, |
|
484 | 488 |
'not null' => TRUE, |
485 | 489 |
'default' => '', |
486 | 490 |
'description' => 'The hash of the source item.', |
... | ... | |
585 | 589 |
* Add index for looking up by entity_type + url/ guid to feeds_item table. |
586 | 590 |
*/ |
587 | 591 |
function feeds_update_7204() { |
588 |
db_add_index('feeds_item', 'global_lookup_url', array('entity_type', array('url', 128))); |
|
589 |
db_add_index('feeds_item', 'global_lookup_guid', array('entity_type', array('guid', 128))); |
|
592 |
db_add_index('feeds_item', 'global_lookup_url', array( |
|
593 |
'entity_type', |
|
594 |
array('url', 128), |
|
595 |
)); |
|
596 |
db_add_index('feeds_item', 'global_lookup_guid', array( |
|
597 |
'entity_type', |
|
598 |
array('guid', 128), |
|
599 |
)); |
|
590 | 600 |
} |
591 | 601 |
|
592 | 602 |
/** |
... | ... | |
608 | 618 |
)); |
609 | 619 |
|
610 | 620 |
db_add_primary_key('feeds_item', array('entity_type', 'entity_id')); |
611 |
db_add_index('feeds_item', 'lookup_url', array('entity_type', 'id', 'feed_nid', array('url', 128))); |
|
612 |
db_add_index('feeds_item', 'lookup_guid', array('entity_type', 'id', 'feed_nid', array('guid', 128))); |
|
613 |
db_add_index('feeds_item', 'global_lookup_url', array('entity_type', array('url', 128))); |
|
614 |
db_add_index('feeds_item', 'global_lookup_guid', array('entity_type', array('guid', 128))); |
|
621 |
db_add_index('feeds_item', 'lookup_url', array( |
|
622 |
'entity_type', |
|
623 |
'id', |
|
624 |
'feed_nid', |
|
625 |
array('url', 128), |
|
626 |
)); |
|
627 |
db_add_index('feeds_item', 'lookup_guid', array( |
|
628 |
'entity_type', |
|
629 |
'id', |
|
630 |
'feed_nid', |
|
631 |
array('guid', 128), |
|
632 |
)); |
|
633 |
db_add_index('feeds_item', 'global_lookup_url', array( |
|
634 |
'entity_type', |
|
635 |
array('url', 128), |
|
636 |
)); |
|
637 |
db_add_index('feeds_item', 'global_lookup_guid', array( |
|
638 |
'entity_type', |
|
639 |
array('guid', 128), |
|
640 |
)); |
|
615 | 641 |
} |
616 | 642 |
|
617 | 643 |
/** |
... | ... | |
722 | 748 |
DrupalQueue::get('feeds_importer_expire')->deleteQueue(); |
723 | 749 |
} |
724 | 750 |
|
725 |
/**
|
|
726 |
* Does nothing. Update removed.
|
|
727 |
*/
|
|
751 |
/** |
|
752 |
* Does nothing. Update removed. |
|
753 |
*/ |
|
728 | 754 |
function feeds_update_7211(&$sandbox) { |
729 | 755 |
} |
730 | 756 |
|
... | ... | |
743 | 769 |
* Set cache class for Feeds HTTP cache. |
744 | 770 |
*/ |
745 | 771 |
function feeds_update_7213() { |
772 |
// Check if Feeds is enabled first. |
|
773 |
if (!class_exists('FeedsHTTPCache') && !module_exists('feeds')) { |
|
774 |
throw new DrupalUpdateException('Please enable the Feeds module to perform this update.'); |
|
775 |
} |
|
776 |
|
|
746 | 777 |
// Perform a registry rebuild so the system hopefully discovers the |
747 | 778 |
// FeedsHTTPCache class. |
748 |
if (function_exists('registry_rebuild')) { |
|
779 |
if (!class_exists('FeedsHTTPCache') && function_exists('registry_rebuild')) {
|
|
749 | 780 |
registry_rebuild(); |
750 | 781 |
} |
751 | 782 |
|
drupal7/sites/all/modules/feeds/feeds.module | ||
---|---|---|
31 | 31 |
'feeds_after_parse', |
32 | 32 |
'feeds_before_import', |
33 | 33 |
'feeds_before_update', |
34 |
'feeds_prevalidate', |
|
34 | 35 |
'feeds_presave', |
35 | 36 |
'feeds_after_save', |
36 | 37 |
'feeds_after_import', |
... | ... | |
96 | 97 |
'queue name' => 'feeds_source_import', |
97 | 98 |
); |
98 | 99 |
// feeds_source_clear never gets called, since we now use the queue directly. |
99 |
// This is left in case any background jobs still running after an |
|
100 |
// This is left in case any background jobs are still running after an
|
|
100 | 101 |
// upgrade. |
101 | 102 |
$info['feeds_source_clear'] = array( |
102 | 103 |
'queue name' => 'feeds_source_clear', |
... | ... | |
137 | 138 |
|
138 | 139 |
/** |
139 | 140 |
* Scheduler callback for importing from a source. |
141 |
* |
|
142 |
* @param array $job |
|
143 |
* A job definition, which consists of at least the following elements: |
|
144 |
* - type (string) |
|
145 |
* The importer ID. |
|
146 |
* - id (int) |
|
147 |
* The Feed node ID if the importer is attached to a content type. Otherwise |
|
148 |
* 0. |
|
140 | 149 |
*/ |
141 | 150 |
function feeds_source_import(array $job) { |
142 | 151 |
$source = _feeds_queue_worker_helper($job, 'import'); |
... | ... | |
147 | 156 |
|
148 | 157 |
/** |
149 | 158 |
* Scheduler callback for deleting all items from a source. |
159 |
* |
|
160 |
* @param array $job |
|
161 |
* A job definition, which consists of at least the following elements: |
|
162 |
* - type (string) |
|
163 |
* The importer ID. |
|
164 |
* - id (int) |
|
165 |
* The Feed node ID if the importer is attached to a content type. Otherwise |
|
166 |
* 0. |
|
150 | 167 |
*/ |
151 | 168 |
function feeds_source_clear(array $job) { |
152 | 169 |
$source = _feeds_queue_worker_helper($job, 'clear'); |
... | ... | |
157 | 174 |
|
158 | 175 |
/** |
159 | 176 |
* Scheduler callback for expiring content. |
177 |
* |
|
178 |
* @param array $job |
|
179 |
* A job definition, which consists of at least the following elements: |
|
180 |
* - type (string) |
|
181 |
* The importer ID. |
|
182 |
* - id (int) |
|
183 |
* The Feed node ID if the importer is attached to a content type. Otherwise |
|
184 |
* 0. |
|
160 | 185 |
*/ |
161 | 186 |
function feeds_source_expire(array $job) { |
162 | 187 |
$source = _feeds_queue_worker_helper($job, 'expire'); |
... | ... | |
169 | 194 |
* Executes a method on a feed source. |
170 | 195 |
* |
171 | 196 |
* @param array $job |
172 |
* The job being run. |
|
197 |
* A job definition, which consists of at least the following elements: |
|
198 |
* - type (string) |
|
199 |
* The importer ID. |
|
200 |
* - id (int) |
|
201 |
* The Feed node ID if the importer is attached to a content type. Otherwise |
|
202 |
* 0. |
|
173 | 203 |
* @param string $method |
174 | 204 |
* The method to execute. |
175 | 205 |
*/ |
... | ... | |
190 | 220 |
} |
191 | 221 |
|
192 | 222 |
/** |
193 |
* Scheduler callback for syncing the feeds cache directory with the entries in |
|
194 |
* the cache. |
|
223 |
* Scheduler callback for keeping the cache dir and cache entries in sync. |
|
224 |
* |
|
225 |
* This makes sure that files that appear in the Feeds cache directory that are |
|
226 |
* no longer referenced in the cache_feeds_http bin, are cleaned up. |
|
227 |
* The entries saved in the cache_feeds_http bin and the actual cached files |
|
228 |
* saved on the file system can get out of sync when: |
|
229 |
* - Truncating the cache_feeds_http table manually. |
|
230 |
* - When using an alternative cache class for the cache_feeds_http bin |
|
231 |
* (other than 'FeedsHTTPCache'). |
|
195 | 232 |
*/ |
196 | 233 |
function feeds_sync_cache_feeds_http(array $job) { |
197 | 234 |
FeedsHTTPCache::getInstance('cache_feeds_http')->sync($job['files']); |
... | ... | |
199 | 236 |
|
200 | 237 |
/** |
201 | 238 |
* Scheduler callback for unsubscribing from PuSH hubs. |
239 |
* |
|
240 |
* @param array $job |
|
241 |
* A job definition, which consists of at least the following elements: |
|
242 |
* - type (string) |
|
243 |
* The importer ID. |
|
244 |
* - id (int) |
|
245 |
* The Feed node ID if the importer is attached to a content type. Otherwise |
|
246 |
* 0. |
|
202 | 247 |
*/ |
203 | 248 |
function feeds_push_unsubscribe($job) { |
204 | 249 |
$source = feeds_source($job['type'], $job['id']); |
250 |
/** @var FeedsFetcher $fetcher */ |
|
205 | 251 |
$fetcher = feeds_plugin('FeedsHTTPFetcher', $source->importer->id); |
206 | 252 |
$fetcher->unsubscribe($source); |
207 | 253 |
} |
... | ... | |
209 | 255 |
/** |
210 | 256 |
* Batch API worker callback. Used by FeedsSource::startBatchAPIJob(). |
211 | 257 |
* |
212 |
* @see FeedsSource::startBatchAPIJob(). |
|
213 |
* |
|
214 | 258 |
* @todo Harmonize Job Scheduler API callbacks with Batch API callbacks? |
215 | 259 |
* |
216 |
* @param $method |
|
260 |
* @param string $method
|
|
217 | 261 |
* Method to execute on importer; one of 'import' or 'clear'. |
218 |
* @param $importer_id |
|
262 |
* @param string $importer_id
|
|
219 | 263 |
* Identifier of a FeedsImporter object. |
220 |
* @param $feed_nid |
|
264 |
* @param int $feed_nid
|
|
221 | 265 |
* If importer is attached to content type, feed node id identifying the |
222 | 266 |
* source to be imported. |
223 |
* @param $context |
|
267 |
* @param array $context
|
|
224 | 268 |
* Batch context. |
269 |
* |
|
270 |
* @see FeedsSource::startBatchAPIJob() |
|
225 | 271 |
*/ |
226 | 272 |
function feeds_batch($method, $importer_id, $feed_nid = 0, &$context) { |
227 | 273 |
$context['finished'] = FEEDS_BATCH_COMPLETE; |
... | ... | |
236 | 282 |
/** |
237 | 283 |
* Reschedule one or all importers. |
238 | 284 |
* |
239 |
* @param string $importer_id |
|
285 |
* @param string|bool|null $importer_id
|
|
240 | 286 |
* If TRUE, all importers will be rescheduled, if FALSE, no importers will |
241 | 287 |
* be rescheduled, if an importer id, only importer of that id will be |
242 | 288 |
* rescheduled. |
243 | 289 |
* |
244 |
* @return array
|
|
245 |
* An list of importers that need rescheduling.
|
|
290 |
* @return string[]
|
|
291 |
* A list of importer ids that need rescheduling.
|
|
246 | 292 |
*/ |
247 | 293 |
function feeds_reschedule($importer_id = NULL) { |
248 | 294 |
$reschedule = variable_get('feeds_reschedule', FALSE); |
... | ... | |
270 | 316 |
} |
271 | 317 |
|
272 | 318 |
/** |
273 |
* Implements feeds_permission().
|
|
319 |
* Implements hook_permission().
|
|
274 | 320 |
*/ |
275 | 321 |
function feeds_permission() { |
276 | 322 |
$perms = array( |
277 | 323 |
'administer feeds' => array( |
278 | 324 |
'title' => t('Administer Feeds'), |
279 |
'description' => t('Create, update, delete importers, execute import and delete tasks on any importer.') |
|
325 |
'description' => t('Create, update, delete importers, execute import and delete tasks on any importer.'),
|
|
280 | 326 |
), |
281 | 327 |
); |
282 | 328 |
foreach (feeds_importer_load_all() as $importer) { |
... | ... | |
288 | 334 |
); |
289 | 335 |
$perms["unlock $importer->id feeds"] = array( |
290 | 336 |
'title' => t('Unlock imports from @name feeds', array('@name' => $importer->config['name'])), |
291 |
'description' => t('If a feed importation breaks for some reason, users with this permission can unlock them.') |
|
337 |
'description' => t('If a feed importation breaks for some reason, users with this permission can unlock them.'),
|
|
292 | 338 |
); |
293 | 339 |
} |
294 | 340 |
return $perms; |
... | ... | |
419 | 465 |
|
420 | 466 |
/** |
421 | 467 |
* Menu loader callback. |
468 |
* |
|
469 |
* @param string $id |
|
470 |
* The ID of the importer to load. |
|
471 |
* |
|
472 |
* @return FeedsImporter|false |
|
473 |
* A FeedsImporter instance if found. False otherwise. |
|
422 | 474 |
*/ |
423 | 475 |
function feeds_importer_load($id) { |
424 | 476 |
try { |
... | ... | |
427 | 479 |
return $importer; |
428 | 480 |
} |
429 | 481 |
} |
430 |
catch (InvalidArgumentException $e) {} |
|
482 |
catch (InvalidArgumentException $e) { |
|
483 |
} |
|
431 | 484 |
|
432 | 485 |
return FALSE; |
433 | 486 |
} |
434 | 487 |
|
435 | 488 |
/** |
436 | 489 |
* Title callback. |
490 |
* |
|
491 |
* @param FeedsImporter $importer |
|
492 |
* The importer to return the page title for. |
|
493 |
* |
|
494 |
* @return string |
|
495 |
* A page title. |
|
437 | 496 |
*/ |
438 | 497 |
function feeds_importer_title(FeedsImporter $importer) { |
439 | 498 |
return $importer->config['name']; |
... | ... | |
463 | 522 |
/** |
464 | 523 |
* Menu access callback. |
465 | 524 |
* |
466 |
* @param $action |
|
525 |
* @param string $action
|
|
467 | 526 |
* The action to be performed. Possible values are: |
468 |
* - import |
|
469 |
* - clear |
|
470 |
* - unlock |
|
471 |
* @param $param |
|
527 |
* - import;
|
|
528 |
* - clear;
|
|
529 |
* - unlock.
|
|
530 |
* @param object|string $param
|
|
472 | 531 |
* Node object or FeedsImporter id. |
532 |
* |
|
533 |
* @return bool |
|
534 |
* True if access is granted. False otherwise. |
|
473 | 535 |
*/ |
474 | 536 |
function feeds_access($action, $param) { |
475 | 537 |
if (!in_array($action, array('import', 'clear', 'unlock'))) { |
... | ... | |
502 | 564 |
* |
503 | 565 |
* Feeds imports require an additional access check because they are PHP |
504 | 566 |
* code and PHP is more locked down than administer feeds. |
567 |
* |
|
568 |
* @return bool |
|
569 |
* True if access is granted. False otherwise. |
|
505 | 570 |
*/ |
506 | 571 |
function feeds_importer_import_access() { |
507 | 572 |
return user_access('administer feeds') && user_access('use PHP for settings'); |
... | ... | |
509 | 574 |
|
510 | 575 |
/** |
511 | 576 |
* Menu access callback. |
577 |
* |
|
578 |
* @return bool |
|
579 |
* True if access is granted. False otherwise. |
|
512 | 580 |
*/ |
513 | 581 |
function feeds_page_access() { |
514 | 582 |
if (user_access('administer feeds')) { |
... | ... | |
531 | 599 |
foreach ($jobs as $job) { |
532 | 600 |
if (!isset($job['fetcher']) || !isset($job['source'])) { |
533 | 601 |
continue; |
534 |
}
|
|
602 |
} |
|
535 | 603 |
$job['fetcher']->subscribe($job['source']); |
536 | 604 |
} |
537 | 605 |
|
... | ... | |
782 | 850 |
} |
783 | 851 |
|
784 | 852 |
/** |
785 |
* Implements hook_features_pipe_COMPONENT_alter() for component "feeds_importer".
|
|
853 |
* Implements hook_features_pipe_COMPONENT_alter() for 'feeds_importer'.
|
|
786 | 854 |
* |
787 | 855 |
* Automatically adds dependencies when a Feed importer is selected in Features. |
788 | 856 |
*/ |
... | ... | |
930 | 998 |
|
931 | 999 |
foreach (feeds_importer_load_all() as $importer) { |
932 | 1000 |
$content['menu']['admin/content']['admin/content/feeds_import'][$importer->id] = array( |
933 |
'#title' => t($importer->config['name']),
|
|
1001 |
'#title' => check_plain($importer->config['name']),
|
|
934 | 1002 |
'#href' => !empty($importer->config['content_type']) ? 'node/add/' . str_replace('_', '-', $importer->config['content_type']) : 'import/' . check_plain($importer->id), |
935 | 1003 |
'#access' => user_access('administer feeds') || user_access("import $importer->id feeds"), |
936 | 1004 |
); |
... | ... | |
962 | 1030 |
} |
963 | 1031 |
} |
964 | 1032 |
|
965 |
|
|
966 | 1033 |
/** |
967 | 1034 |
* @} |
968 | 1035 |
*/ |
... | ... | |
975 | 1042 |
/** |
976 | 1043 |
* Loads all importers. |
977 | 1044 |
* |
978 |
* @param $load_disabled |
|
1045 |
* @param bool $load_disabled
|
|
979 | 1046 |
* Pass TRUE to load all importers, enabled or disabled, pass FALSE to only |
980 | 1047 |
* retrieve enabled importers. |
981 | 1048 |
* |
982 |
* @return |
|
1049 |
* @return array
|
|
983 | 1050 |
* An array of all feed configurations available. |
984 | 1051 |
*/ |
985 | 1052 |
function feeds_importer_load_all($load_disabled = FALSE) { |
... | ... | |
1019 | 1086 |
/** |
1020 | 1087 |
* Gets an array of enabled importer ids. |
1021 | 1088 |
* |
1022 |
* @return |
|
1089 |
* @return string[]
|
|
1023 | 1090 |
* An array where the values contain ids of enabled importers. |
1024 | 1091 |
*/ |
1025 | 1092 |
function feeds_enabled_importers() { |
... | ... | |
1029 | 1096 |
/** |
1030 | 1097 |
* Gets an enabled importer configuration by content type. |
1031 | 1098 |
* |
1032 |
* @param $content_type |
|
1099 |
* @param string $content_type
|
|
1033 | 1100 |
* A node type string. |
1034 | 1101 |
* |
1035 |
* @return |
|
1102 |
* @return string|false
|
|
1036 | 1103 |
* A FeedsImporter id if there is an importer for the given content type, |
1037 | 1104 |
* FALSE otherwise. |
1038 | 1105 |
*/ |
... | ... | |
1177 | 1244 |
/** |
1178 | 1245 |
* Gets an importer instance. |
1179 | 1246 |
* |
1180 |
* @param $id |
|
1247 |
* @param string $id
|
|
1181 | 1248 |
* The unique id of the importer object. |
1182 | 1249 |
* |
1183 |
* @return |
|
1250 |
* @return FeedsImporter
|
|
1184 | 1251 |
* A FeedsImporter object or an object of a class defined by the Drupal |
1185 | 1252 |
* variable 'feeds_importer_class'. There is only one importer object |
1186 | 1253 |
* per $id system-wide. |
... | ... | |
1192 | 1259 |
/** |
1193 | 1260 |
* Gets an instance of a source object. |
1194 | 1261 |
* |
1195 |
* @param $importer_id |
|
1262 |
* @param string $importer_id
|
|
1196 | 1263 |
* A FeedsImporter id. |
1197 |
* @param $feed_nid |
|
1264 |
* @param int $feed_nid
|
|
1198 | 1265 |
* The node id of a feed node if the source is attached to a feed node. |
1199 | 1266 |
* |
1200 |
* @return |
|
1201 |
* A FeedsSource object or an object of a class defiend by the Drupal
|
|
1267 |
* @return FeedsSource
|
|
1268 |
* A FeedsSource object or an object of a class defined by the Drupal
|
|
1202 | 1269 |
* variable 'source_class'. |
1203 | 1270 |
*/ |
1204 | 1271 |
function feeds_source($importer_id, $feed_nid = 0) { |
... | ... | |
1260 | 1327 |
* The name of the library. If libraries module is installed, |
1261 | 1328 |
* feeds_include_library() will look for libraries with this name managed by |
1262 | 1329 |
* libraries module. |
1330 |
* |
|
1331 |
* @return bool |
|
1332 |
* True if the requested library was found and included with success. False |
|
1333 |
* otherwise. |
|
1263 | 1334 |
*/ |
1264 | 1335 |
function feeds_include_library($file, $library) { |
1265 | 1336 |
static $included = array(); |
... | ... | |
1307 | 1378 |
* The name of the library. If libraries module is installed, |
1308 | 1379 |
* feeds_library_exists() will look for libraries with this name managed by |
1309 | 1380 |
* libraries module. |
1381 |
* |
|
1382 |
* @return bool |
|
1383 |
* True if the library exists. False otherwise. |
|
1310 | 1384 |
*/ |
1311 | 1385 |
function feeds_library_exists($file, $library) { |
1312 | 1386 |
$path = module_exists('libraries') ? libraries_get_path($library) : FALSE; |
... | ... | |
1328 | 1402 |
return FALSE; |
1329 | 1403 |
} |
1330 | 1404 |
|
1331 |
/**
|
|
1405 |
/** |
|
1332 | 1406 |
* Checks whether simplepie exists. |
1333 | 1407 |
*/ |
1334 | 1408 |
function feeds_simplepie_exists() { |
... | ... | |
1360 | 1434 |
return FALSE; |
1361 | 1435 |
} |
1362 | 1436 |
|
1363 |
/** |
|
1364 |
* @deprecated |
|
1365 |
* |
|
1366 |
* Simplified drupal_alter(). |
|
1367 |
* |
|
1368 |
* - None of that 'multiple parameters by ref' crazyness. |
|
1369 |
* - Don't use module_implements() to allow hot including on behalf |
|
1370 |
* implementations (see mappers/). |
|
1371 |
* |
|
1372 |
* @todo This needs to be removed and drupal_alter() used. This is crazy dumb. |
|
1373 |
*/ |
|
1374 |
function feeds_alter($type, &$data) { |
|
1375 |
$args = array(&$data); |
|
1376 |
$additional_args = func_get_args(); |
|
1377 |
array_shift($additional_args); |
|
1378 |
array_shift($additional_args); |
|
1379 |
$args = array_merge($args, $additional_args); |
|
1380 |
|
|
1381 |
$hook = $type . '_alter'; |
|
1382 |
foreach (module_list() as $module) { |
|
1383 |
if (module_hook($module, $hook)) { |
|
1384 |
call_user_func_array($module . '_' . $hook, $args); |
|
1385 |
} |
|
1386 |
} |
|
1387 |
} |
|
1388 |
|
|
1389 | 1437 |
/** |
1390 | 1438 |
* @} |
1391 | 1439 |
*/ |
... | ... | |
1393 | 1441 |
/** |
1394 | 1442 |
* Copy of valid_url() that supports the webcal scheme. |
1395 | 1443 |
* |
1396 |
* @see valid_url().
|
|
1444 |
* @see valid_url() |
|
1397 | 1445 |
* |
1398 | 1446 |
* @todo Replace with valid_url() when http://drupal.org/node/295021 is fixed. |
1399 | 1447 |
*/ |
... | ... | |
1428 | 1476 |
* Information about a new job to queue; or if set to NULL (default), leaves |
1429 | 1477 |
* the current queued jobs unchanged. |
1430 | 1478 |
* |
1431 |
* @return |
|
1479 |
* @return array
|
|
1432 | 1480 |
* An array of subscribe jobs to process. |
1433 | 1481 |
* |
1434 | 1482 |
* @see feeds_exit() |
... | ... | |
1445 | 1493 |
/** |
1446 | 1494 |
* Returns the list of queued jobs to be run. |
1447 | 1495 |
* |
1448 |
* @return |
|
1496 |
* @return array
|
|
1449 | 1497 |
* An array of subscribe jobs to process. |
1450 | 1498 |
* |
1451 | 1499 |
* @see feeds_set_subscription_job() |
... | ... | |
1519 | 1567 |
} |
1520 | 1568 |
|
1521 | 1569 |
// No feed item. Try to load the feed item if the entity has an ID. |
1522 |
list($entity_id, , ) = entity_extract_ids($entity_type, $entity);
|
|
1570 |
list($entity_id) = entity_extract_ids($entity_type, $entity); |
|
1523 | 1571 |
if ($entity_id) { |
1524 | 1572 |
$feeds_item = feeds_item_info_load($entity_type, $entity_id); |
1525 | 1573 |
|
... | ... | |
1541 | 1589 |
return; |
1542 | 1590 |
} |
1543 | 1591 |
|
1544 |
// Get the file record based on the URI. If not in the database just return.
|
|
1592 |
// Get the file record based on the URI. If not in the database just return. |
|
1545 | 1593 |
$files = file_load_multiple(array(), array('uri' => $uri)); |
1546 | 1594 |
foreach ($files as $item) { |
1547 | 1595 |
// Since some database servers sometimes use a case-insensitive comparison |
drupal7/sites/all/modules/feeds/feeds.pages.inc | ||
---|---|---|
89 | 89 |
if ($source->importer->config['import_on_create']) { |
90 | 90 |
$submit = t('Import'); |
91 | 91 |
if ($source->importer->config['process_in_background']) { |
92 |
// When processing the import in background, the import job is put in the queue. |
|
92 |
// When processing the import in background, the import job is put in the |
|
93 |
// queue. |
|
93 | 94 |
$submit = t('Schedule import'); |
94 | 95 |
} |
95 | 96 |
} |
... | ... | |
105 | 106 |
$submit = t('Save'); |
106 | 107 |
} |
107 | 108 |
|
108 |
$form['submit'] = array( |
|
109 |
$form['actions'] = array('#type' => 'actions'); |
|
110 |
$form['actions']['submit'] = array( |
|
109 | 111 |
'#type' => 'submit', |
110 | 112 |
'#value' => $submit, |
111 | 113 |
); |
... | ... | |
113 | 115 |
// Disable submit button if import is initiated. |
114 | 116 |
$progress = $source->progressImporting(); |
115 | 117 |
if ($progress !== FEEDS_BATCH_COMPLETE) { |
116 |
$form['submit']['#disabled'] = TRUE; |
|
117 |
$form['submit']['#value'] = |
|
118 |
t('Importing (@progress %)', array('@progress' => number_format(100 * $progress, 0))); |
|
118 |
$form['actions']['submit']['#disabled'] = TRUE; |
|
119 |
$form['actions']['submit']['#value'] = t('Importing (@progress %)', array( |
|
120 |
'@progress' => number_format(100 * $progress, 0), |
|
121 |
)); |
|
119 | 122 |
|
120 | 123 |
// Check if import task is queued. |
121 | 124 |
if ($source->isQueued()) { |
... | ... | |
196 | 199 |
$progress = $source->progressImporting(); |
197 | 200 |
if ($progress !== FEEDS_BATCH_COMPLETE) { |
198 | 201 |
$form['actions']['submit']['#disabled'] = TRUE; |
199 |
$form['actions']['submit']['#value'] = |
|
200 |
t('Importing (@progress %)', array('@progress' => number_format(100 * $progress, 0))); |
|
202 |
$form['actions']['submit']['#value'] = t('Importing (@progress %)', array( |
|
203 |
'@progress' => number_format(100 * $progress, 0), |
|
204 |
)); |
|
201 | 205 |
|
202 | 206 |
// Check if import task is queued. |
203 | 207 |
if ($source->isQueued()) { |
... | ... | |
258 | 262 |
$progress = $source->progressClearing(); |
259 | 263 |
if ($progress !== FEEDS_BATCH_COMPLETE) { |
260 | 264 |
$form['actions']['submit']['#disabled'] = TRUE; |
261 |
$form['actions']['submit']['#value'] = |
|
262 |
t('Deleting (@progress %)', array('@progress' => number_format(100 * $progress, 0))); |
|
265 |
$form['actions']['submit']['#value'] = t('Deleting (@progress %)', array( |
|
266 |
'@progress' => number_format(100 * $progress, 0), |
|
267 |
)); |
|
263 | 268 |
$form['source_status']['#value'] .= t('Run cron to continue the deletion of items.'); |
264 | 269 |
} |
265 | 270 |
|
... | ... | |
352 | 357 |
} |
353 | 358 |
|
354 | 359 |
/** |
355 |
* Template generation |
|
360 |
* Template generation.
|
|
356 | 361 |
*/ |
357 | 362 |
function feeds_importer_template(FeedsImporter $importer) { |
358 | 363 |
if ($importer->parser instanceof FeedsCSVParser) { |
... | ... | |
390 | 395 |
$items = array(); |
391 | 396 |
if ($v['progress_importing']) { |
392 | 397 |
$progress = number_format(100.0 * $v['progress_importing'], 0); |
393 |
$items[] = t('Importing - @progress % complete.', array('@progress' => $progress)); |
|
398 |
$items[] = t('Importing - @progress % complete.', array( |
|
399 |
'@progress' => $progress, |
|
400 |
)); |
|
394 | 401 |
} |
395 | 402 |
if ($v['progress_clearing']) { |
396 | 403 |
$progress = number_format(100.0 * $v['progress_clearing'], 0); |
397 |
$items[] = t('Deleting items - @progress % complete.', array('@progress' => $progress)); |
|
404 |
$items[] = t('Deleting items - @progress % complete.', array( |
|
405 |
'@progress' => $progress, |
|
406 |
)); |
|
398 | 407 |
} |
399 | 408 |
if (!count($items)) { |
400 | 409 |
if ($v['count']) { |
401 | 410 |
if ($v['imported']) { |
402 |
$items[] = t('Last import: @ago ago.', array('@ago' => format_interval(REQUEST_TIME - $v['imported'], 1))); |
|
411 |
$items[] = t('Last import: @ago ago.', array( |
|
412 |
'@ago' => format_interval(REQUEST_TIME - $v['imported'], 1), |
|
413 |
)); |
|
403 | 414 |
} |
404 |
$items[] = t('@count imported items total.', array('@count' => $v['count'])); |
|
415 |
$items[] = t('@count imported items total.', array( |
|
416 |
'@count' => $v['count'], |
|
417 |
)); |
|
405 | 418 |
} |
406 | 419 |
else { |
407 | 420 |
$items[] = t('No imported items.'); |
... | ... | |
455 | 468 |
$summary .= l($file->filename, $wrapper->getExternalUrl()); |
456 | 469 |
} |
457 | 470 |
else { |
458 |
$summary .= t('URI scheme %scheme not available.', array('%scheme' => file_uri_scheme($uri))); |
|
471 |
$summary .= t('URI scheme %scheme not available.', array( |
|
472 |
'%scheme' => file_uri_scheme($uri), |
|
473 |
)); |
|
459 | 474 |
} |
460 | 475 |
$summary .= '</div>'; |
461 | 476 |
$summary .= '<div class="file-size">'; |
drupal7/sites/all/modules/feeds/feeds.plugins.inc | ||
---|---|---|
60 | 60 |
'name' => 'HTTP Fetcher', |
61 | 61 |
'description' => 'Download content from a URL.', |
62 | 62 |
'handler' => array( |
63 |
'parent' => 'FeedsFetcher', // This is the key name, not the class name. |
|
63 |
// This is the key name, not the class name. |
|
64 |
'parent' => 'FeedsFetcher', |
|
64 | 65 |
'class' => 'FeedsHTTPFetcher', |
65 | 66 |
'file' => 'FeedsHTTPFetcher.inc', |
66 | 67 |
'path' => $path, |
drupal7/sites/all/modules/feeds/feeds.rules.inc | ||
---|---|---|
37 | 37 |
$entity_type = $processor->entityType(); |
38 | 38 |
$label = isset($entity_info[$entity_type]['label']) ? $entity_info[$entity_type]['label'] : $entity_type; |
39 | 39 |
|
40 |
$info['feeds_import_'. $importer->id] = array( |
|
40 |
$info['feeds_import_' . $importer->id] = array(
|
|
41 | 41 |
'label' => t('Before saving an item imported via @name.', array('@name' => $importer->config['name'])), |
42 | 42 |
'group' => t('Feeds'), |
43 | 43 |
'variables' => array( |
... | ... | |
56 | 56 |
} |
57 | 57 |
|
58 | 58 |
/** |
59 |
* Implements of hook_rules_action_info().
|
|
59 |
* Implements hook_rules_action_info(). |
|
60 | 60 |
*/ |
61 | 61 |
function feeds_rules_action_info() { |
62 | 62 |
return array( |
63 |
'feeds_import_feed' => array( |
|
64 |
'base' => 'feeds_action_import_feed', |
|
65 |
'label' => t('Execute feeds importer'), |
|
66 |
'parameter' => array( |
|
67 |
'importer' => array( |
|
68 |
'type' => 'text', |
|
69 |
'label' => t('Feeds importer'), |
|
70 |
'options list' => 'feeds_importer_list', |
|
71 |
'default mode' => 'input', |
|
72 |
), |
|
73 |
'feed_nid' => array( |
|
74 |
'type' => 'node', |
|
75 |
'label' => t('Feed node'), |
|
76 |
'default mode' => 'input', |
|
77 |
'description' => t("The feed node, if the importer is attached to a content type. Put in '0' if the importer is not attached to a content type."), |
|
78 |
), |
|
79 |
), |
|
80 |
'group' => t('Feeds'), |
|
81 |
'access callback' => 'feeds_rules_access_callback', |
|
82 |
), |
|
63 | 83 |
'feeds_skip_item' => array( |
64 | 84 |
'base' => 'feeds_action_skip_item', |
65 | 85 |
'label' => t('Skip import of feeds item'), |
... | ... | |
98 | 118 |
); |
99 | 119 |
} |
100 | 120 |
|
121 |
/** |
|
122 |
* Rules action callback for "feeds_import_feed" action. |
|
123 |
* |
|
124 |
* @param string $importer_id |
|
125 |
* ID of the importer. |
|
126 |
* @param object|null $feed_node |
|
127 |
* The feed node, if found. Null otherwise. |
|
128 |
* @param array $params |
|
129 |
* The raw parameters. |
|
130 |
*/ |
|
131 |
function feeds_action_import_feed($importer_id, $feed_node, array $params) { |
|
132 |
$source = feeds_source($importer_id, $params['feed_nid']); |
|
133 |
try { |
|
134 |
$source->existing()->startImport(); |
|
135 |
|
|
136 |
// Execute batch, if there is any. Set 'progressive' to false to prevent |
|
137 |
// batch from triggering a drupal_goto(). |
|
138 |
$batch =& batch_get(); |
|
139 |
if (!empty($batch)) { |
|
140 |
$batch['progressive'] = FALSE; |
|
141 |
batch_process(); |
|
142 |
} |
|
143 |
} |
|
144 |
catch (FeedsNotExistingException $e) { |
|
145 |
// Ignore this kind of exception. |
|
146 |
} |
|
147 |
catch (Exception $e) { |
|
148 |
$source->log('import', $e->getMessage(), array(), WATCHDOG_ERROR); |
|
149 |
} |
|
150 |
} |
|
151 |
|
|
101 | 152 |
/** |
102 | 153 |
* Mark feeds import item as skipped. |
103 | 154 |
*/ |
... | ... | |
115 | 166 |
return t("This action allows skipping certain feed items during feeds processing, i.e. before an imported item is saved. Once this action is used on a item, the changes to the entity of the feed item are not saved."); |
116 | 167 |
} |
117 | 168 |
|
169 |
/** |
|
170 |
* List callback for selecting a Feeds importer. |
|
171 |
*/ |
|
172 |
function feeds_importer_list() { |
|
173 |
$list = array(); |
|
174 |
ctools_include('export'); |
|
175 |
$configs = ctools_export_load_object('feeds_importer', 'all'); |
|
176 |
foreach ($configs as $id => $config) { |
|
177 |
if (empty($config->disabled)) { |
|
178 |
$list[$id] = $config->config['name']; |
|
179 |
} |
|
180 |
} |
|
181 |
return $list; |
|
182 |
} |
|
183 |
|
|
118 | 184 |
/** |
119 | 185 |
* Access callback for the feeds rules integration. |
120 | 186 |
*/ |
drupal7/sites/all/modules/feeds/feeds_import/feeds_import.features.inc | ||
---|---|---|
1 | 1 |
<?php |
2 |
|
|
2 | 3 |
/** |
3 | 4 |
* @file |
4 | 5 |
* feeds_import.features.inc |
drupal7/sites/all/modules/feeds/feeds_import/feeds_import.feeds_importer_default.inc | ||
---|---|---|
1 | 1 |
<?php |
2 |
|
|
2 | 3 |
/** |
3 | 4 |
* @file |
4 | 5 |
* feeds_import.feeds_importer_default.inc |
drupal7/sites/all/modules/feeds/feeds_import/feeds_import.info | ||
---|---|---|
10 | 10 |
features[feeds_importer][] = user |
11 | 11 |
files[] = feeds_import.test |
12 | 12 |
|
13 |
; Information added by Drupal.org packaging script on 2017-09-24
|
|
14 |
version = "7.x-2.0-beta4"
|
|
13 |
; Information added by Drupal.org packaging script on 2020-08-13
|
|
14 |
version = "7.x-2.0-beta5"
|
|
15 | 15 |
core = "7.x" |
16 | 16 |
project = "feeds" |
17 |
datestamp = "1506257048" |
|
18 |
|
|
17 |
datestamp = "1597331284" |
drupal7/sites/all/modules/feeds/feeds_import/feeds_import.module | ||
---|---|---|
5 | 5 |
* Empty module file. |
6 | 6 |
*/ |
7 | 7 |
|
8 |
include_once('feeds_import.features.inc'); |
|
8 |
include_once 'feeds_import.features.inc'; |
Formats disponibles : Unified diff
Weekly update of contrib modules