]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/TagCloud/TagCloudPlugin.php
Merge branch 'profile' into 'nightly'
[quix0rs-gnu-social.git] / plugins / TagCloud / TagCloudPlugin.php
1 <?php
2 /**
3  * GNU social plugin for "tag clouds" in the UI
4  *
5  * @category  UI
6  * @package   GNUsocial
7  * @author    Mikael Nordfeldth <mmn@hethane.se>
8  * @copyright 2016 Free Software Foundation, Inc.
9  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
10  * @link      http://gnu.io/social/
11  */
12
13 if (!defined('GNUSOCIAL')) { exit(1); }
14
15 class TagCloudPlugin extends Plugin {
16
17     public function onRouterInitialized(URLMapper $m)
18     {
19         $m->connect('tags/', array('action' => 'publictagcloud'));
20         $m->connect('tag/', array('action' => 'publictagcloud'));
21         $m->connect('tags', array('action' => 'publictagcloud'));
22         $m->connect('tag', array('action' => 'publictagcloud'));
23     }
24
25     public function onEndPublicGroupNav(Menu $menu)
26     {
27         // TRANS: Menu item in search group navigation panel.
28         $menu->out->menuItem(common_local_url('publictagcloud'), _m('MENU','Recent tags'),
29                              // TRANS: Menu item title in search group navigation panel.
30                              _('Recent tags'), $menu->actionName === 'publictagcloud', 'nav_recent-tags');
31     }
32
33     public function onEndShowSections(Action $action)
34     {
35         $cloud = null;
36
37         switch (true) {
38         case $action instanceof AllAction:
39             $cloud = new InboxTagCloudSection($action, $action->getTarget());
40             break;
41         case $action instanceof AttachmentAction:
42             $cloud = new AttachmentTagCloudSection($action);
43             break;
44         case $action instanceof PublicAction:
45             $cloud = new PublicTagCloudSection($action);
46             break;
47         case $action instanceof ShowstreamAction:
48             $cloud = new PersonalTagCloudSection($action, $action->getTarget());
49             break;
50         case $action instanceof GroupAction:
51             $cloud = new GroupTagCloudSection($action, $action->getGroup());
52         }
53
54         if (!is_null($cloud)) {
55             $cloud->show();
56         }
57     }
58
59     public function onPluginVersion(array &$versions)
60     {
61         $versions[] = array('name' => 'TagCloud',
62                             'version' => GNUSOCIAL_VERSION,
63                             'author' => 'Mikael Nordfeldth',
64                             'homepage' => 'https://gnu.io/social',
65                             'description' =>
66                             // TRANS: Plugin description.
67                             _m('Adds tag clouds to stream pages'));
68         return true;
69     }
70 }