3 * StatusNet, the distributed open-source microblogging tool
5 * Utility class for plugins
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Evan Prodromou <evan@status.net>
25 * @copyright 2008 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('STATUSNET') && !defined('LACONICA')) {
35 * Base class for plugins
37 * A base class for StatusNet plugins. Mostly a light wrapper around
38 * the Event framework.
40 * Subclasses of Plugin will automatically handle an event if they define
41 * a method called "onEventName". (Well, OK -- only if they call parent::__construct()
42 * in their constructors.)
44 * They will also automatically handle the InitializePlugin and CleanupPlugin with the
45 * initialize() and cleanup() methods, respectively.
49 * @author Evan Prodromou <evan@status.net>
50 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
51 * @link http://status.net/
58 function __construct()
60 Event::addHandler('InitializePlugin', array($this, 'initialize'));
61 Event::addHandler('CleanupPlugin', array($this, 'cleanup'));
63 foreach (get_class_methods($this) as $method) {
64 if (mb_substr($method, 0, 2) == 'on') {
65 Event::addHandler(mb_substr($method, 2), array($this, $method));
81 * the name of the shortener
82 * shortenerInfo associative array with additional information. One possible element is 'freeService' which can be true or false
83 * shortener array, first element is the name of the class, second element is an array to be passed as constructor parameters to the class
85 function registerUrlShortener($name, $shortenerInfo, $shortener)
88 if(!is_array($_shorteners)){
91 $_shorteners[$name]=array('info'=>$shortenerInfo, 'callInfo'=>$shortener);