]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/GroupFavorited/GroupFavoritedPlugin.php
90a1fe5ca04ddd94a054ce0ee1f9bf29b2197c2f
[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     /**
30      * Hook for RouterInitialized event.
31      *
32      * @param Net_URL_Mapper $m path-to-action mapper
33      * @return boolean hook return
34      */
35     function onRouterInitialized(Net_URL_Mapper $m)
36     {
37         $m->connect('group/:nickname/favorited',
38                     array('action' => 'groupfavorited'),
39                     array('nickname' => '[a-zA-Z0-9]+'));
40
41         return true;
42     }
43
44     function onEndGroupGroupNav(Menu $nav)
45     {
46         $action_name = $nav->action->trimmed('action');
47         $nickname = $nav->group->nickname;
48         $nav->out->menuItem(common_local_url('groupfavorited', array('nickname' =>
49                                                                      $nickname)),
50                             // TRANS: Menu item in the group navigation page.
51                             _m('MENU', 'Popular'),
52                             // TRANS: Tooltip for menu item in the group navigation page.
53                             // TRANS: %s is the nickname of the group.
54                             sprintf(_m('TOOLTIP','Popular notices in %s group'), $nickname),
55                             $action_name == 'groupfavorited',
56                             'nav_group_group');
57     }
58
59     /**
60      * Provide plugin version information.
61      *
62      * This data is used when showing the version page.
63      *
64      * @param array &$versions array of version data arrays; see EVENTS.txt
65      *
66      * @return boolean hook value
67      */
68     function onPluginVersion(array &$versions)
69     {
70         $url = 'http://status.net/wiki/Plugin:GroupFavorited';
71
72         $versions[] = array('name' => 'GroupFavorited',
73             'version' => GNUSOCIAL_VERSION,
74             'author' => 'Brion Vibber',
75             'homepage' => $url,
76             'rawdescription' =>
77             // TRANS: Plugin description.
78             _m('This plugin adds a menu item for popular notices in groups.'));
79
80         return true;
81     }
82 }