]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/FeedSub/FeedSubPlugin.php
Merge branch 'inblob' of git@gitorious.org:~evan/statusnet/evans-mainline into inblob
[quix0rs-gnu-social.git] / plugins / FeedSub / FeedSubPlugin.php
1 <?php
2 /*
3 StatusNet Plugin: 0.9
4 Plugin Name: FeedSub
5 Plugin URI: http://status.net/wiki/Feed_subscription
6 Description: FeedSub allows subscribing to real-time updates from external feeds supporting PubHubSubbub protocol.
7 Version: 0.1
8 Author: Brion Vibber <brion@status.net>
9 Author URI: http://status.net/
10 */
11
12 /*
13  * StatusNet - the distributed open-source microblogging tool
14  * Copyright (C) 2009, StatusNet, Inc.
15  *
16  * This program is free software: you can redistribute it and/or modify
17  * it under the terms of the GNU Affero General Public License as published by
18  * the Free Software Foundation, either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU Affero General Public License for more details.
25  *
26  * You should have received a copy of the GNU Affero General Public License
27  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
28  */
29
30 /**
31  * @package FeedSubPlugin
32  * @maintainer Brion Vibber <brion@status.net>
33  */
34
35 if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
36
37 define('FEEDSUB_SERVICE', 100); // fixme -- avoid hardcoding these?
38
39 // We bundle the XML_Parse_Feed library...
40 set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/extlib');
41
42 class FeedSubException extends Exception
43 {
44 }
45
46 class FeedSubPlugin extends Plugin
47 {
48     /**
49      * Hook for RouterInitialized event.
50      *
51      * @param Net_URL_Mapper $m path-to-action mapper
52      * @return boolean hook return
53      */
54     function onRouterInitialized($m)
55     {
56         $m->connect('feedsub/callback/:feed',
57                     array('action' => 'feedsubcallback'),
58                     array('feed' => '[0-9]+'));
59         $m->connect('settings/feedsub',
60                     array('action' => 'feedsubsettings'));
61         return true;
62     }
63
64     /**
65      * Add the feed settings page to the Connect Settings menu
66      *
67      * @param Action &$action The calling page
68      *
69      * @return boolean hook return
70      */
71     function onEndConnectSettingsNav(&$action)
72     {
73         $action_name = $action->trimmed('action');
74
75         $action->menuItem(common_local_url('feedsubsettings'),
76                           _m('Feeds'),
77                           _m('Feed subscription options'),
78                           $action_name === 'feedsubsettings');
79
80         return true;
81     }
82
83     /**
84      * Automatically load the actions and libraries used by the plugin
85      *
86      * @param Class $cls the class
87      *
88      * @return boolean hook return
89      *
90      */
91     function onAutoload($cls)
92     {
93         $base = dirname(__FILE__);
94         $lower = strtolower($cls);
95         $files = array("$base/$lower.php");
96         if (substr($lower, -6) == 'action') {
97             $files[] = "$base/actions/" . substr($lower, 0, -6) . ".php";
98         }
99         foreach ($files as $file) {
100             if (file_exists($file)) {
101                 include_once $file;
102                 return false;
103             }
104         }
105         return true;
106     }
107
108     function onCheckSchema() {
109         // warning: the autoincrement doesn't seem to set.
110         // alter table feedinfo change column id id int(11) not null  auto_increment;
111         $schema = Schema::get();
112         $schema->ensureTable('feedinfo', Feedinfo::schemaDef());
113         return true;
114     }
115 }