]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/GroupFavorited/GroupFavoritedPlugin.php
GroupFavorited plugin: adds 'Popular' tab to group navigation showing a popular pages...
[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($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     /**
45      * Automatically load the actions and libraries used by the plugin
46      *
47      * @param Class $cls the class
48      *
49      * @return boolean hook return
50      *
51      */
52     function onAutoload($cls)
53     {
54         $base = dirname(__FILE__);
55         $lower = strtolower($cls);
56         switch ($lower) {
57         case 'groupfavoritedaction':
58             require_once "$base/$lower.php";
59             return false;
60         default:
61             return true;
62         }
63     }
64
65     function onEndGroupGroupNav(GroupNav $nav)
66     {
67         $action_name = $nav->action->trimmed('action');
68         $nickname = $nav->group->nickname;
69         $nav->out->menuItem(common_local_url('groupfavorited', array('nickname' =>
70                                                                      $nickname)),
71                             // TRANS: Menu item in the group navigation page.
72                             _m('MENU', 'Popular'),
73                             // TRANS: Tooltip for menu item in the group navigation page.
74                             // TRANS: %s is the nickname of the group.
75                             sprintf(_m('TOOLTIP','Popular notices in %s group'), $nickname),
76                             $action_name == 'groupfavorited',
77                             'nav_group_group');
78     }
79 }