]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/TwitterBridge/TwitterBridgePlugin.php
a8de1c66444eb0eb0a304f9ed0b23e1069dcf74e
[quix0rs-gnu-social.git] / plugins / TwitterBridge / TwitterBridgePlugin.php
1 <?php
2 /**
3  * Laconica, the distributed open-source microblogging tool
4  *
5  * PHP version 5
6  *
7  * LICENCE: This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  *
20  * @category  Plugin
21  * @package   Laconica
22  * @author    Zach Copley <zach@controlyourself.ca>
23  * @copyright 2009 Control Yourself, Inc.
24  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
25  * @link      http://laconi.ca/
26  */
27
28 if (!defined('LACONICA')) {
29     exit(1);
30 }
31
32 /**
33  * Plugin for sending and importing Twitter statuses
34  *
35  * This class allows users to link their Twitter accounts
36  *
37  * @category Plugin
38  * @package  Laconica
39  * @author   Zach Copley <zach@controlyourself.ca>
40  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
41  * @link     http://laconi.ca/
42  * @link     http://twitter.com/
43  */
44
45 class TwitterBridgePlugin extends Plugin
46 {
47     /**
48      * Initializer for the plugin.
49      */
50
51     function __construct()
52     {
53         parent::__construct();
54     }
55
56     /**
57      * Add Twitter-related paths to the router table
58      *
59      * Hook for RouterInitialized event.
60      *
61      * @return boolean hook return
62      */
63
64     function onRouterInitialized(&$m)
65     {
66         $m->connect('twitter/authorization', array('action' => 'twitterauthorization'));
67         $m->connect('settings/twitter', array('action' => 'twittersettings'));
68
69         return true;
70     }
71
72     function onEndConnectSettingsNav(&$action)
73     {
74         $action_name = $action->trimmed('action');
75
76         $action->menuItem(common_local_url('twittersettings'),
77                           _('Twitter'),
78                           _('Twitter integration options'),
79                           $action_name === 'twittersettings');
80
81         return true;
82     }
83
84     function onAutoload($cls)
85     {
86         switch ($cls)
87         {
88          case 'TwittersettingsAction':
89          case 'TwitterauthorizationAction':
90             require_once(INSTALLDIR.'/plugins/TwitterBridge/' . strtolower(mb_substr($cls, 0, -6)) . '.php');
91             return false;
92          case 'TwitterOAuthClient':
93             require_once(INSTALLDIR.'/plugins/TwitterBridge/twitteroauthclient.php');
94             return false;
95          default:
96             return true;
97         }
98     }
99
100
101 }