3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2010, StatusNet, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * @package SlicedFavoritesPlugin
22 * @maintainer Brion Vibber <brion@status.net>
25 if (!defined('STATUSNET')) { exit(1); }
27 class SlicedFavoritesPlugin extends Plugin
32 * addPlugin('SlicedFavorites', array(
34 * // show only pop's notices on /favorited
35 * 'default' => array('include' => array('pop')),
37 * // show only son's notices on /favorited/blog
38 * 'blog' => array('include' => array('son')),
40 * // show all favorited notices except pop's and son's on /favorited/submitted
41 * 'submitted' => array('exclude' => array('pop', 'son')),
43 * // show all favorited notices on /favorited/everybody
44 * 'everybody' => array(),
50 public $slices = array();
53 * Hook for RouterInitialized event.
55 * @param Net_URL_Mapper $m path-to-action mapper
56 * @return boolean hook return
58 function onRouterInitialized($m)
60 $m->connect('favorited/:slice',
61 array('action' => 'favoritedslice'),
62 array('slice' => '[a-zA-Z0-9]+'));
67 // Take over the default... :D
68 function onArgsInitialize($args)
70 if (array_key_exists('action', $args)) {
71 $action = trim($args['action']);
72 if ($action == 'favorited') {
73 common_redirect(common_local_url('favoritedslice', array('slice' => 'default')));
81 * Automatically load the actions and libraries used by the plugin
83 * @param Class $cls the class
85 * @return boolean hook return
88 function onAutoload($cls)
90 $base = dirname(__FILE__);
91 $lower = strtolower($cls);
93 case 'favoritedsliceaction':
94 require_once "$base/$lower.php";
101 function onSlicedFavoritesGetSettings($slice, &$data)
103 if (isset($this->slices[$slice])) {
104 $data = $this->slices[$slice];
111 * Provide plugin version information.
113 * This data is used when showing the version page.
115 * @param array &$versions array of version data arrays; see EVENTS.txt
117 * @return boolean hook value
119 function onPluginVersion(&$versions)
121 $url = 'http://status.net/wiki/Plugin:SlicedFavorites';
123 $versions[] = array('name' => 'SlicedFavorites',
124 'version' => STATUSNET_VERSION,
125 'author' => 'Brion Vibber',
128 // TRANS: Plugin description.
129 _m('Shows timelines of popular notices for defined subsets of users.'));