3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2011, StatusNet, Inc.
6 * Adds a user directory
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.
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.
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/>.
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/
31 if (!defined('STATUSNET')) {
36 * Directory plugin main class
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/
45 class DirectoryPlugin extends Plugin
50 * Initializer for this plugin
52 * @return boolean hook value; true means continue processing,
61 * Cleanup for this plugin.
63 * @return boolean hook value; true means continue processing,
72 * Load related modules when needed
74 * @param string $cls Name of the class to be loaded
76 * @return boolean hook value; true means continue processing,
79 function onAutoload($cls)
81 // common_debug("class = $cls");
83 $dir = dirname(__FILE__);
87 case 'UserdirectoryAction':
89 . '/actions/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
93 . '/lib/' . strtolower($cls) . '.php';
95 case 'SortableSubscriptionList':
97 . '/lib/' . strtolower($cls) . '.php';
105 * Map URLs to actions
107 * @param Net_URL_Mapper $m path-to-action mapper
109 * @return boolean hook value; true means continue processing,
112 function onRouterInitialized($m)
116 array('action' => 'userdirectory'),
117 array('filter' => 'all')
121 'directory/users/:filter',
122 array('action' => 'userdirectory'),
123 array('filter' => '([0-9a-zA-Z_]{1,64}|0-9)')
130 * Link in a styelsheet for the onboarding actions
132 * @param Action $action Action being shown
134 * @return boolean hook flag
136 function onEndShowStatusNetStyles($action)
139 $action->trimmed('action'),
140 array('userdirectory'))
142 $action->cssLink($this->path('css/directory.css'));
149 * Modify the public local nav to add a link to the user directory
151 * @param Action $action The current action handler. Use this to
154 * @return boolean hook value; true means continue processing,
159 function onEndPublicGroupNav($nav)
161 // XXX: Maybe this should go under search instead?
163 $actionName = $nav->action->trimmed('action');
166 common_local_url('userdirectory'),
167 // TRANS: Menu item text for user directory.
168 _m('MENU','Directory'),
169 // TRANS: Menu item title for user directory.
170 _m('User Directory.'),
171 $actionName == 'userdirectory',
181 function onPluginVersion(&$versions)
184 'name' => 'Directory',
185 'version' => STATUSNET_VERSION,
186 'author' => 'Zach Copley',
187 'homepage' => 'http://status.net/wiki/Plugin:Directory',
188 // TRANS: Plugin description.
189 'rawdescription' => _m('Add a user directory.')