]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Directory/DirectoryPlugin.php
Merge branch '1.0.x' into directory
[quix0rs-gnu-social.git] / plugins / Directory / DirectoryPlugin.php
1 <?php
2 /**
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2011, StatusNet, Inc.
5  *
6  * Adds a user directory
7  *
8  * PHP version 5
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Affero General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Affero General Public License for more details.
19  *
20  * You should have received a copy of the GNU Affero General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  * @category  Plugin
24  * @package   StatusNet
25  * @author    Zach Copely <zach@status.net>
26  * @copyright 2011 StatusNet, Inc.
27  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
28  * @link      http://status.net/
29  */
30
31 if (!defined('STATUSNET')) {
32     exit(1);
33 }
34
35 /**
36  * Directory plugin main class
37  *
38  * @category  Plugin
39  * @package   StatusNet
40  * @author    Zach Copley <zach@status.net>
41  * @copyright 2011 StatusNet, Inc.
42  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
43  * @link      http://status.net/
44  */
45 class DirectoryPlugin extends Plugin
46 {
47     /**
48      * Initializer for this plugin
49      *
50      * @return boolean hook value; true means continue processing,
51      *         false means stop.
52      */
53     function initialize()
54     {
55         return true;
56     }
57
58     /**
59      * Cleanup for this plugin.
60      *
61      * @return boolean hook value; true means continue processing,
62      *         false means stop.
63      */
64     function cleanup()
65     {
66         return true;
67     }
68
69     /**
70      * Load related modules when needed
71      *
72      * @param string $cls Name of the class to be loaded
73      *
74      * @return boolean hook value; true means continue processing,
75      *         false means stop.
76      */
77     function onAutoload($cls)
78     {
79         $dir = dirname(__FILE__);
80
81         // common_debug("class = $cls");
82
83         switch ($cls)
84         {
85         case 'UserdirectoryAction':
86             include_once $dir
87                 . '/actions/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
88             return false;
89         case 'AlphaNav':
90             include_once $dir
91                 . '/lib/' . strtolower($cls) . '.php';
92             return false;
93         default:
94             return true;
95         }
96     }
97
98     /**
99      * Map URLs to actions
100      *
101      * @param Net_URL_Mapper $m path-to-action mapper
102      *
103      * @return boolean hook value; true means continue processing,
104      *         false means stop.
105      */
106     function onRouterInitialized($m)
107     {
108         $m->connect(
109             'main/directory',
110             array('action' => 'userdirectory')
111         );
112
113         return true;
114     }
115
116     /**
117      * Modify the public local nav to add a link to the user directory
118      *
119      * @param Action $action The current action handler. Use this to
120      *                       do any output.
121      *
122      * @return boolean hook value; true means continue processing,
123      *         false means stop.
124      *
125      * @see Action
126      */
127     function onEndPublicGroupNav($nav)
128     {
129         // XXX: Maybe this should go under search instead?
130
131         $actionName = $nav->action->trimmed('action');
132
133         $nav->out->menuItem(
134             common_local_url('userdirectory'),
135             _('Directory'),
136             _('User Directory'),
137             $actionName == 'userdirectory',
138             'nav_directory'
139         );
140
141         return true;
142     }
143
144     /*
145      * Version info
146      */
147     function onPluginVersion(&$versions)
148     {
149         $versions[] = array(
150             'name' => 'Directory',
151             'version' => STATUSNET_VERSION,
152             'author' => 'Zach Copley',
153             'homepage' => 'http://status.net/wiki/Plugin:Directory',
154             'rawdescription' => _m('Add a user directory.')
155         );
156
157         return true;
158     }
159 }