]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/GroupFavorited/GroupFavoritedPlugin.php
[ROUTES] Allow accept-header specification during router creation
[quix0rs-gnu-social.git] / plugins / GroupFavorited / GroupFavoritedPlugin.php
1 <?php
2 /*
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2010, StatusNet, Inc.
5  *
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.
10  *
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.
15  *
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/>.
18  */
19
20 /**
21  * @package GroupFavoritedPlugin
22  * @maintainer Brion Vibber <brion@status.net>
23  */
24
25 if (!defined('STATUSNET')) { exit(1); }
26
27 class GroupFavoritedPlugin extends Plugin
28 {
29     const PLUGIN_VERSION = '2.0.0';
30
31     /**
32      * Hook for RouterInitialized event.
33      *
34      * @param URLMapper $m path-to-action mapper
35      * @return boolean hook return
36      */
37     function onRouterInitialized(URLMapper $m)
38     {
39         $m->connect('group/:nickname/favorited',
40                     ['action' => 'groupfavorited'],
41                     ['nickname' => '[a-zA-Z0-9]+']);
42
43         return true;
44     }
45
46     function onEndGroupGroupNav(Menu $nav)
47     {
48         $action_name = $nav->action->trimmed('action');
49         $nickname = $nav->group->nickname;
50         $nav->out->menuItem(common_local_url('groupfavorited', array('nickname' =>
51                                                                      $nickname)),
52                             // TRANS: Menu item in the group navigation page.
53                             _m('MENU', 'Popular'),
54                             // TRANS: Tooltip for menu item in the group navigation page.
55                             // TRANS: %s is the nickname of the group.
56                             sprintf(_m('TOOLTIP','Popular notices in %s group'), $nickname),
57                             $action_name == 'groupfavorited',
58                             'nav_group_group');
59     }
60
61     /**
62      * Provide plugin version information.
63      *
64      * This data is used when showing the version page.
65      *
66      * @param array &$versions array of version data arrays; see EVENTS.txt
67      *
68      * @return boolean hook value
69      */
70     function onPluginVersion(array &$versions)
71     {
72         $url = 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/GroupFavorited';
73
74         $versions[] = array('name' => 'GroupFavorited',
75             'version' => self::PLUGIN_VERSION,
76             'author' => 'Brion Vibber',
77             'homepage' => $url,
78             'rawdescription' =>
79             // TRANS: Plugin description.
80             _m('This plugin adds a menu item for popular notices in groups.'));
81
82         return true;
83     }
84 }