Stripping CVS keywords
[project/feeds.git] / plugins / FeedsFetcher.inc
CommitLineData
eabfe21e 1<?php
eabfe21e
AB
2
3/**
eabfe21e
AB
4 * Abstract class, defines shared functionality between fetchers.
5 *
6 * Implements FeedsSourceInfoInterface to expose source forms to Feeds.
7 */
8abstract class FeedsFetcher extends FeedsPlugin {
9
10 /**
11 * Fetch content from a source and return it.
12 *
0221b8f8 13 * Every class that extends FeedsFetcher must implement this method.
eabfe21e
AB
14 *
15 * @param $source
16 * Source value as entered by user through sourceForm().
eabfe21e
AB
17 */
18 public abstract function fetch(FeedsSource $source);
19
20 /**
21 * Clear all caches for results for given source.
22 *
23 * @param FeedsSource $source
24 * Source information for this expiry. Implementers can choose to only clear
25 * caches pertaining to this source.
26 */
27 public function clear(FeedsSource $source) {}
2c769fda
AB
28
29 /**
30 * Request handler invoked if callback URL is requested. Locked down by
31 * default. For a example usage see FeedsHTTPFetcher.
32 *
33 * Note: this method may exit the script.
34 *
35 * @return
36 * A string to be returned to the client.
37 */
38 public function request($feed_nid = 0) {
39 drupal_access_denied();
40 }
41
42 /**
43 * Construct a path for a concrete fetcher/source combination. The result of
44 * this method matches up with the general path definition in
45 * FeedsFetcher::menuItem(). For example usage look at FeedsHTTPFetcher.
46 *
47 * @return
48 * Path for this fetcher/source combination.
49 */
50 public function path($feed_nid = 0) {
5664ae73
AB
51 $id = urlencode($this->id);
52 if ($feed_nid && is_numeric($feed_nid)) {
53 return "feeds/importer/$id/$feed_nid";
2c769fda 54 }
5664ae73 55 return "feeds/importer/$id";
2c769fda
AB
56 }
57
58 /**
59 * Menu item definition for fetchers of this class. Note how the path
60 * component in the item definition matches the return value of
61 * FeedsFetcher::path();
62 *
63 * Requests to this menu item will be routed to FeedsFetcher::request().
64 *
65 * @return
66 * An array where the key is the Drupal menu item path and the value is
67 * a valid Drupal menu item definition.
68 */
69 public function menuItem() {
70 return array(
71 'feeds/importer/%feeds_importer' => array(
72 'page callback' => 'feeds_fetcher_callback',
73 'page arguments' => array(2, 3),
74 'access callback' => TRUE,
75 'file' => 'feeds.pages.inc',
76 'type' => MENU_CALLBACK,
77 ),
78 );
79 }
80
81 /**
82 * Subscribe to a source. Only implement if fetcher requires subscription.
83 *
84 * @param FeedsSource $source
85 * Source information for this subscription.
86 */
87 public function subscribe(FeedsSource $source) {}
88
89 /**
90 * Unsubscribe from a source. Only implement if fetcher requires subscription.
91 *
92 * @param FeedsSource $source
93 * Source information for unsubscribing.
94 */
95 public function unsubscribe(FeedsSource $source) {}
5959bcb0
AB
96
97 /**
98 * Override import period settings. This can be used to force a certain import
99 * interval.
100 *
101 * @param $source
102 * A FeedsSource object.
103 *
104 * @return
105 * A time span in seconds if periodic import should be overridden for given
106 * $source, NULL otherwise.
107 */
108 public function importPeriod(FeedsSource $source) {}
eabfe21e 109}