Révision 41cc1b08
Ajouté par Assos Assos il y a presque 9 ans
drupal7/sites/all/modules/feeds/plugins/FeedsPlugin.inc | ||
---|---|---|
20 | 20 |
abstract class FeedsPlugin extends FeedsConfigurable implements FeedsSourceInterface { |
21 | 21 |
|
22 | 22 |
/** |
23 |
* Constructor.
|
|
23 |
* The plugin definition.
|
|
24 | 24 |
* |
25 |
* Initialize class variables. |
|
25 |
* @var array |
|
26 |
*/ |
|
27 |
protected $pluginDefinition; |
|
28 |
|
|
29 |
/** |
|
30 |
* Constructs a FeedsPlugin object. |
|
31 |
* |
|
32 |
* A copy of FeedsConfigurable::__construct() that doesn't call |
|
33 |
* configDefaults() so that we avoid circular dependencies. |
|
34 |
* |
|
35 |
* @param string $id |
|
36 |
* The importer id. |
|
26 | 37 |
*/ |
27 | 38 |
protected function __construct($id) { |
28 |
parent::__construct($id); |
|
29 |
$this->source_config = $this->sourceDefaults(); |
|
39 |
$this->id = $id; |
|
40 |
$this->export_type = FEEDS_EXPORT_NONE; |
|
41 |
$this->disabled = FALSE; |
|
42 |
} |
|
43 |
|
|
44 |
/** |
|
45 |
* Instantiates a FeedsPlugin object. |
|
46 |
* |
|
47 |
* Don't use directly, use feeds_plugin() instead. |
|
48 |
* |
|
49 |
* @see feeds_plugin() |
|
50 |
*/ |
|
51 |
public static function instance($class, $id, array $plugin_definition = array()) { |
|
52 |
if (!strlen($id)) { |
|
53 |
throw new InvalidArgumentException(t('Empty configuration identifier.')); |
|
54 |
} |
|
55 |
|
|
56 |
static $instances = array(); |
|
57 |
|
|
58 |
if (!isset($instances[$class][$id])) { |
|
59 |
$instance = new $class($id); |
|
60 |
|
|
61 |
// The ordering here is important. The plugin definition should be usable |
|
62 |
// in getConfig(). |
|
63 |
$instance->setPluginDefinition($plugin_definition); |
|
64 |
$instance->setConfig($instance->configDefaults()); |
|
65 |
$instances[$class][$id] = $instance; |
|
66 |
} |
|
67 |
|
|
68 |
return $instances[$class][$id]; |
|
30 | 69 |
} |
31 | 70 |
|
32 | 71 |
/** |
... | ... | |
37 | 76 |
*/ |
38 | 77 |
abstract public function pluginType(); |
39 | 78 |
|
79 |
/** |
|
80 |
* Returns the plugin definition. |
|
81 |
* |
|
82 |
* @return array |
|
83 |
* The plugin definition array. |
|
84 |
* |
|
85 |
* @see ctools_get_plugins() |
|
86 |
*/ |
|
87 |
public function pluginDefinition() { |
|
88 |
return $this->pluginDefinition; |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* Sets the plugin definition. |
|
93 |
* |
|
94 |
* This is protected since we're only using it in FeedsPlugin::instance(). |
|
95 |
* |
|
96 |
* @param array $plugin_definition |
|
97 |
* The plugin definition. |
|
98 |
*/ |
|
99 |
protected function setPluginDefinition(array $plugin_definition) { |
|
100 |
$this->pluginDefinition = $plugin_definition; |
|
101 |
} |
|
102 |
|
|
40 | 103 |
/** |
41 | 104 |
* Save changes to the configuration of this object. |
42 | 105 |
* Delegate saving to parent (= Feed) which will collect |
... | ... | |
205 | 268 |
} |
206 | 269 |
return $result; |
207 | 270 |
} |
271 |
|
|
272 |
/** |
|
273 |
* Implements FeedsConfigurable::dependencies(). |
|
274 |
*/ |
|
275 |
public function dependencies() { |
|
276 |
$dependencies = parent::dependencies(); |
|
277 |
|
|
278 |
// Find out which module provides this plugin. |
|
279 |
$plugin_info = $this->pluginDefinition(); |
|
280 |
if (isset($plugin_info['module'])) { |
|
281 |
$dependencies[$plugin_info['module']] = $plugin_info['module']; |
|
282 |
} |
|
283 |
|
|
284 |
return $dependencies; |
|
285 |
} |
|
208 | 286 |
} |
209 | 287 |
|
210 | 288 |
/** |
... | ... | |
214 | 292 |
public function pluginType() { |
215 | 293 |
return 'missing'; |
216 | 294 |
} |
295 |
|
|
296 |
public function save() {} |
|
297 |
|
|
298 |
/** |
|
299 |
* Fetcher methods. |
|
300 |
*/ |
|
301 |
public function fetch(FeedsSource $source) { |
|
302 |
return new FeedsFetcherResult(''); |
|
303 |
} |
|
304 |
|
|
305 |
public function clear(FeedsSource $source) {} |
|
306 |
|
|
307 |
public function request($feed_nid = 0) { |
|
308 |
drupal_access_denied(); |
|
309 |
} |
|
310 |
|
|
217 | 311 |
public function menuItem() { |
218 | 312 |
return array(); |
219 | 313 |
} |
314 |
|
|
315 |
public function subscribe(FeedsSource $source) {} |
|
316 |
|
|
317 |
public function unsubscribe(FeedsSource $source) {} |
|
318 |
|
|
319 |
public function importPeriod(FeedsSource $source) {} |
|
320 |
|
|
321 |
/** |
|
322 |
* Parser methods. |
|
323 |
*/ |
|
324 |
public function parse(FeedsSource $source, FeedsFetcherResult $fetcher_result) { |
|
325 |
return new FeedsParserResult(); |
|
326 |
} |
|
327 |
|
|
328 |
public function getMappingSources() { |
|
329 |
return array(); |
|
330 |
} |
|
331 |
|
|
332 |
/** |
|
333 |
* Processor methods. |
|
334 |
*/ |
|
335 |
public function process(FeedsSource $source, FeedsParserResult $parser_result) {} |
|
336 |
|
|
337 |
public function entityType() {} |
|
338 |
|
|
339 |
public function bundle() {} |
|
340 |
|
|
341 |
public function bundleOptions() { |
|
342 |
return array(); |
|
343 |
} |
|
344 |
|
|
345 |
public function getLimit() { |
|
346 |
return 0; |
|
347 |
} |
|
348 |
|
|
349 |
public function getMappings() { |
|
350 |
return array(); |
|
351 |
} |
|
352 |
|
|
353 |
public function getMappingTargets() { |
|
354 |
return array(); |
|
355 |
} |
|
356 |
|
|
357 |
public function expire(FeedsSource $source, $time = NULL) {} |
|
358 |
|
|
359 |
public function itemCount(FeedsSource $source) { |
|
360 |
return 0; |
|
361 |
} |
|
362 |
|
|
363 |
public function expiryTime() { |
|
364 |
return FEEDS_EXPIRE_NEVER; |
|
365 |
} |
|
366 |
|
|
220 | 367 |
} |
221 | 368 |
|
222 | 369 |
/** |
Formats disponibles : Unified diff
Update feeds 7.x-2.0-alpha9 -> 7.x-2.0-beta1
Install lib simplepie 1.3.1