]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/ModPlus/ModPlusPlugin.php
$related must contain class names, no table names ("all" lower-case) + fixed some...
[quix0rs-gnu-social.git] / plugins / ModPlus / ModPlusPlugin.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 if (!defined('STATUSNET')) {
21     exit(1);
22 }
23
24 /**
25  * Some UI extras for now...
26  *
27  * @package ModPlusPlugin
28  * @maintainer Brion Vibber <brion@status.net>
29  */
30 class ModPlusPlugin extends Plugin
31 {
32     function onPluginVersion(array &$versions)
33     {
34         $versions[] = array('name' => 'ModPlus',
35                             'version' => GNUSOCIAL_VERSION,
36                             'author' => 'Brion Vibber',
37                             'homepage' => 'http://status.net/wiki/Plugin:ModPlus',
38                             'rawdescription' =>
39                             // TRANS: Plugin description.
40                             _m('UI extension for profile moderation actions.'));
41
42         return true;
43     }
44
45     /**
46      * Load JS at runtime.
47      *
48      * @param Action $action
49      * @return boolean hook result
50      */
51     function onEndShowScripts(Action $action)
52     {
53         $action->script($this->path('js/modplus.js'));
54         return true;
55     }
56
57     public function onEndShowStylesheets(Action $action) {
58         $action->cssLink($this->path('css/modplus.css'));
59         return true;
60     }
61
62     /**
63      * Add ModPlus-related paths to the router table
64      *
65      * Hook for RouterInitialized event.
66      *
67      * @param URLMapper $m URL mapper
68      *
69      * @return boolean hook return
70      */
71     public function onStartInitializeRouter(URLMapper $m)
72     {
73         $m->connect('user/remote/:id',
74                 array('action' => 'remoteprofile'),
75                 array('id' => '[\d]+'));
76
77         return true;
78     }
79
80     /**
81      * Add per-profile info popup menu for author on notice lists.
82      *
83      * @param NoticeListItem $item
84      * @return boolean hook value
85      */
86     function onEndShowNoticeItemAuthor(Profile $profile, HTMLOutputter $out)
87     {
88         $this->showProfileOptions($out, $profile);
89         return true;
90     }
91
92     /**
93      * Add per-profile info popup menu on profile lists.
94      *
95      * @param ProfileListItem $item
96      */
97     function onStartProfileListItemProfile($item)
98     {
99         $this->showProfileOptions($item->out, $item->profile->getProfile());
100         return true;
101     }
102
103     /**
104      * Build common remote-profile options structure.
105      * Currently only adds output for remote profiles, nothing for local users.
106      *
107      * @param HTMLOutputter $out
108      * @param Profile $profile
109      */
110     protected function showProfileOptions(HTMLOutputter $out, Profile $profile)
111     {
112         if (!$profile->isGroup() && !$profile->isLocal()) {
113             $target = common_local_url('remoteprofile', array('id' => $profile->id));
114             // TRANS: Label for access to remote profile options.
115             $label = _m('Remote profile options...');
116             $out->elementStart('div', 'remote-profile-options');
117             $out->element('a', array('href' => $target), $label);
118             $out->elementEnd('div');
119         }
120     }
121 }