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
29 const PLUGIN_VERSION = '2.0.0';
34 * addPlugin('SlicedFavorites', array(
36 * // show only pop's notices on /favorited
37 * 'default' => array('include' => array('pop')),
39 * // show only son's notices on /favorited/blog
40 * 'blog' => array('include' => array('son')),
42 * // show all favorited notices except pop's and son's on /favorited/submitted
43 * 'submitted' => array('exclude' => array('pop', 'son')),
45 * // show all favorited notices on /favorited/everybody
46 * 'everybody' => array(),
52 public $slices = array();
55 * Hook for RouterInitialized event.
57 * @param URLMapper $m path-to-action mapper
58 * @return boolean hook return
60 public function onRouterInitialized(URLMapper $m)
62 $m->connect('favorited/:slice',
63 ['action' => 'favoritedslice'],
64 ['slice' => '[a-zA-Z0-9]+']);
69 // Take over the default... :D
70 function onArgsInitialize(array &$args)
72 if (array_key_exists('action', $args)) {
73 $action = trim($args['action']);
74 if ($action == 'favorited') {
75 common_redirect(common_local_url('favoritedslice', array('slice' => 'default')));
82 function onSlicedFavoritesGetSettings($slice, &$data)
84 if (isset($this->slices[$slice])) {
85 $data = $this->slices[$slice];
92 * Provide plugin version information.
94 * This data is used when showing the version page.
96 * @param array &$versions array of version data arrays; see EVENTS.txt
98 * @return boolean hook value
100 function onPluginVersion(array &$versions)
102 $url = 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/SlicedFavorites';
104 $versions[] = array('name' => 'SlicedFavorites',
105 'version' => self::PLUGIN_VERSION,
106 'author' => 'Brion Vibber',
109 // TRANS: Plugin description.
110 _m('Shows timelines of popular notices for defined subsets of users.'));