123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class DirectoryPlugin extends Plugin
- {
- const PLUGIN_VERSION = '2.0.0';
- private $dir = null;
-
- function initialize()
- {
- return true;
- }
-
- function cleanup()
- {
- return true;
- }
-
- public function onRouterInitialized(URLMapper $m)
- {
- $m->connect('directory/users/:filter/sort_by/:sort/reverse/:reverse',
- ['action' => 'userdirectory'],
- ['filter' => '[0-9a-zA-Z]|(0-9)',
- 'sort' => '[a-z]+',
- 'reverse' => '[0-9]']);
- $m->connect('directory/users/:filter/sort_by/:sort',
- ['action' => 'userdirectory'],
- ['filter' => '[0-9a-zA-Z]|(0-9)',
- 'sort' => '[a-z]+']);
- $m->connect('directory/users/:filter',
- ['action' => 'userdirectory'],
- ['filter' => '[0-9a-zA-Z]|(0-9)']);
-
- $m->connect('directory/users/sort_by/:sort/reverse/:reverse',
- ['action' => 'userdirectory'],
- ['sort' => '[a-z]+',
- 'reverse' => '[0-9]']);
- $m->connect('directory/users/sort_by/:sort',
- ['action' => 'userdirectory'],
- ['sort' => '[a-z]+']);
- $m->connect('directory/users',
- ['action' => 'userdirectory']);
- $m->connect('groups/:filter',
- ['action' => 'groupdirectory'],
- ['filter' => '[0-9a-zA-Z]|(0-9)']);
- $m->connect('groups',
- ['action' => 'groupdirectory']);
- $m->connect('groups/all',
- ['action' => 'groupdirectory']);
- return true;
- }
-
- function onStartConnectPath(&$path, &$defaults, &$rules, &$result)
- {
- if (in_array($path, array('group', 'group/', 'groups', 'groups/'))) {
- $defaults['action'] = 'groupdirectory';
- return true;
- }
- return true;
- }
-
-
-
- function onEndLocalURL(&$action, &$params, &$fragment, &$addSession, &$url) {
- if (in_array($action, array('group', 'group/', 'groups', 'groups/'))) {
- $url = common_local_url('groupdirectory');
- }
- return true;
- }
-
- public function onEndShowStylesheets(Action $action)
- {
- if (in_array(
- $action->trimmed('action'),
- array('userdirectory', 'groupdirectory'))
- ) {
- $action->cssLink($this->path('css/directory.css'));
- }
- return true;
- }
-
- function onStartPublicGroupNav($action)
- {
- if ($action->trimmed('action') == 'groupdirectory') {
- $action->actionName = 'groups';
- }
- return true;
- }
-
- function onEndPublicGroupNav($nav)
- {
-
- $actionName = $nav->action->trimmed('action');
- $nav->out->menuItem(
- common_local_url('userdirectory'),
-
- _m('MENU','People'),
-
- _m('People.'),
- $actionName == 'userdirectory',
- 'nav_directory'
- );
- return true;
- }
-
- public function onPluginVersion(array &$versions): bool
- {
- $versions[] = array(
- 'name' => 'Directory',
- 'version' => self::PLUGIN_VERSION,
- 'author' => 'Zach Copley',
- 'homepage' => GNUSOCIAL_ENGINE_REPO_URL . 'tree/master/plugins/Directory',
-
- 'rawdescription' => _m('Add a user directory.')
- );
- return true;
- }
- }
|