From: brunoccast Date: Thu, 11 Jul 2019 18:14:03 +0000 (+0100) Subject: [ROUTES] Allow accept-header specification during router creation X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5c0a3102ff60472f60da76d69b0830dca726cca4;p=quix0rs-gnu-social.git [ROUTES] Allow accept-header specification during router creation Router: - Fix calls to connect, most of them were misusing the function's params URLMapper: - Minor fixes - Documentation - Add support for accept-header specification Plugins/*: - Fix calls to connect --- diff --git a/extlib/AcceptHeader.php b/extlib/AcceptHeader.php new file mode 100644 index 0000000000..e146ec8231 --- /dev/null +++ b/extlib/AcceptHeader.php @@ -0,0 +1,116 @@ + + */ +class AcceptHeader extends \ArrayObject +{ + /** + * Constructor + * + * @param string $header Value of the Accept header + * @return void + */ + public function __construct($header) + { + $acceptedTypes = $this->_parse($header); + usort($acceptedTypes, [$this, '_compare']); + parent::__construct($acceptedTypes); + } + + /** + * Parse the accept header and return an array containing + * all the informations about the Accepted types + * + * @param string $data Value of the Accept header + * @return array + */ + private function _parse($data) + { + $array = []; + $items = explode(',', $data); + foreach ($items as $item) { + $elems = explode(';', $item); + + $acceptElement = []; + $mime = current($elems); + list($type, $subtype) = explode('/', $mime); + $acceptElement['type'] = trim($type); + $acceptElement['subtype'] = trim($subtype); + $acceptElement['raw'] = $mime; + + $acceptElement['params'] = []; + while (next($elems)) { + list($name, $value) = explode('=', current($elems)); + $acceptElement['params'][trim($name)] = trim($value); + } + + $array[] = $acceptElement; + } + return $array; + } + + /** + * Compare two Accepted types with their parameters to know + * if one media type should be used instead of an other + * + * @param array $a The first media type and its parameters + * @param array $b The second media type and its parameters + * @return int + */ + private function _compare($a, $b) + { + $a_q = isset($a['params']['q']) ? floatval($a['params']['q']) : 1.0; + $b_q = isset($b['params']['q']) ? floatval($b['params']['q']) : 1.0; + if ($a_q === $b_q) { + $a_count = count($a['params']); + $b_count = count($b['params']); + if ($a_count === $b_count) { + if ($r = $this->_compareSubType($a['subtype'], $b['subtype'])) { + return $r; + } else { + return $this->_compareSubType($a['type'], $b['type']); + } + } else { + return $a_count < $b_count; + } + } else { + return $a_q < $b_q; + } + } + + /** + * Compare two subtypes + * + * @param string $a First subtype to compare + * @param string $b Second subtype to compare + * @return int + */ + private function _compareSubType($a, $b) + { + if ($a === '*' && $b !== '*') { + return 1; + } elseif ($b === '*' && $a !== '*') { + return -1; + } else { + return 0; + } + } +} diff --git a/lib/router.php b/lib/router.php index d6f63ab026..09dc43e648 100644 --- a/lib/router.php +++ b/lib/router.php @@ -104,120 +104,124 @@ class Router { $m = new URLMapper(); - if (Event::handle('StartInitializeRouter', array(&$m))) { + if (Event::handle('StartInitializeRouter', [&$m])) { // top of the menu hierarchy, sometimes "Home" - $m->connect('', array('action' => 'top')); + $m->connect('', ['action' => 'top']); // public endpoints - $m->connect('robots.txt', array('action' => 'robotstxt')); + $m->connect('robots.txt', ['action' => 'robotstxt']); - $m->connect('opensearch/people', array('action' => 'opensearch', - 'type' => 'people')); - $m->connect('opensearch/notice', array('action' => 'opensearch', - 'type' => 'notice')); + $m->connect('opensearch/people', + ['action' => 'opensearch', + 'type' => 'people']); + + $m->connect('opensearch/notice', + ['action' => 'opensearch', + 'type' => 'notice']); // docs - $m->connect('doc/:title', array('action' => 'doc')); + $m->connect('doc/:title', ['action' => 'doc']); $m->connect('main/otp/:user_id/:token', - array('action' => 'otp'), - array('user_id' => '[0-9]+', - 'token' => '.+')); + ['action' => 'otp'], + ['user_id' => '[0-9]+', + 'token' => '.+']); // these take a code; before the main part - foreach (array('register', 'confirmaddress', 'recoverpassword') as $c) { - $m->connect('main/'.$c.'/:code', array('action' => $c)); + foreach (['register', 'confirmaddress', 'recoverpassword'] as $c) { + $m->connect('main/'.$c.'/:code', ['action' => $c]); } // Also need a block variant accepting ID on URL for mail links $m->connect('main/block/:profileid', - array('action' => 'block'), - array('profileid' => '[0-9]+')); + ['action' => 'block'], + ['profileid' => '[0-9]+']); - $m->connect('main/sup/:seconds', array('action' => 'sup'), - array('seconds' => '[0-9]+')); + $m->connect('main/sup/:seconds', + ['action' => 'sup'], + ['seconds' => '[0-9]+']); // main stuff is repetitive - $main = array('login', 'logout', 'register', 'subscribe', - 'unsubscribe', 'cancelsubscription', 'approvesub', - 'confirmaddress', 'recoverpassword', - 'invite', 'sup', - 'block', 'unblock', 'subedit', - 'groupblock', 'groupunblock', - 'sandbox', 'unsandbox', - 'silence', 'unsilence', - 'grantrole', 'revokerole', - 'deleteuser', - 'geocode', - 'version', - 'backupaccount', - 'deleteaccount', - 'restoreaccount', - 'top', - 'public', - ); + $main = ['login', 'logout', 'register', 'subscribe', + 'unsubscribe', 'cancelsubscription', 'approvesub', + 'confirmaddress', 'recoverpassword', + 'invite', 'sup', + 'block', 'unblock', 'subedit', + 'groupblock', 'groupunblock', + 'sandbox', 'unsandbox', + 'silence', 'unsilence', + 'grantrole', 'revokerole', + 'deleteuser', + 'geocode', + 'version', + 'backupaccount', + 'deleteaccount', + 'restoreaccount', + 'top', + 'public']; foreach ($main as $a) { - $m->connect('main/'.$a, array('action' => $a)); + $m->connect('main/'.$a, ['action' => $a]); } - $m->connect('main/all', array('action' => 'networkpublic')); + $m->connect('main/all', ['action' => 'networkpublic']); - $m->connect('main/tagprofile/:id', array('action' => 'tagprofile'), - array('id' => '[0-9]+')); + $m->connect('main/tagprofile/:id', + ['action' => 'tagprofile'], + ['id' => '[0-9]+']); - $m->connect('main/tagprofile', array('action' => 'tagprofile')); + $m->connect('main/tagprofile', ['action' => 'tagprofile']); $m->connect('main/xrds', - array('action' => 'publicxrds')); + ['action' => 'publicxrds']); // settings - foreach (array('profile', 'avatar', 'password', 'im', 'oauthconnections', - 'oauthapps', 'email', 'sms', 'url') as $s) { - $m->connect('settings/'.$s, array('action' => $s.'settings')); + foreach (['profile', 'avatar', 'password', 'im', 'oauthconnections', + 'oauthapps', 'email', 'sms', 'url'] as $s) { + $m->connect('settings/'.$s, ['action' => $s.'settings']); } if (common_config('oldschool', 'enabled')) { - $m->connect('settings/oldschool', array('action' => 'oldschoolsettings')); + $m->connect('settings/oldschool', ['action' => 'oldschoolsettings']); } $m->connect('settings/oauthapps/show/:id', - array('action' => 'showapplication'), - array('id' => '[0-9]+') - ); + ['action' => 'showapplication'], + ['id' => '[0-9]+']); + $m->connect('settings/oauthapps/new', - array('action' => 'newapplication') - ); + ['action' => 'newapplication']); + $m->connect('settings/oauthapps/edit/:id', - array('action' => 'editapplication'), - array('id' => '[0-9]+') - ); + ['action' => 'editapplication'], + ['id' => '[0-9]+']); + $m->connect('settings/oauthapps/delete/:id', - array('action' => 'deleteapplication'), - array('id' => '[0-9]+') - ); + ['action' => 'deleteapplication'], + ['id' => '[0-9]+']); // search - foreach (array('group', 'people', 'notice') as $s) { + foreach (['group', 'people', 'notice'] as $s) { $m->connect('search/'.$s.'?q=:q', - array('action' => $s.'search'), - array('q' => '.+')); - $m->connect('search/'.$s, array('action' => $s.'search')); + ['action' => $s.'search'], + ['q' => '.+']); + $m->connect('search/'.$s, ['action' => $s.'search']); } // The second of these is needed to make the link work correctly // when inserted into the page. The first is needed to match the // route on the way in. Seems to be another Net_URL_Mapper bug to me. - $m->connect('search/notice/rss?q=:q', array('action' => 'noticesearchrss'), - array('q' => '.+')); - $m->connect('search/notice/rss', array('action' => 'noticesearchrss')); + $m->connect('search/notice/rss?q=:q', + ['action' => 'noticesearchrss'], + ['q' => '.+']); + $m->connect('search/notice/rss', ['action' => 'noticesearchrss']); foreach (['' => 'attachment', '/view' => 'attachment_view', @@ -232,372 +236,383 @@ class Router } $m->connect('notice/new?replyto=:replyto&inreplyto=:inreplyto', - array('action' => 'newnotice'), - array('replyto' => Nickname::DISPLAY_FMT), - array('inreplyto' => '[0-9]+')); + ['action' => 'newnotice'], + ['replyto' => Nickname::DISPLAY_FMT, + 'inreplyto' => '[0-9]+']); $m->connect('notice/new?replyto=:replyto', - array('action' => 'newnotice'), - array('replyto' => Nickname::DISPLAY_FMT)); + ['action' => 'newnotice'], + ['replyto' => Nickname::DISPLAY_FMT]); - $m->connect('notice/new', array('action' => 'newnotice')); + $m->connect('notice/new', ['action' => 'newnotice']); $m->connect('notice/:notice', - array('action' => 'shownotice'), - array('notice' => '[0-9]+')); + ['action' => 'shownotice'], + ['notice' => '[0-9]+']); $m->connect('notice/:notice/delete', - array('action' => 'deletenotice'), - array('notice' => '[0-9]+')); + ['action' => 'deletenotice'], + ['notice' => '[0-9]+']); // conversation $m->connect('conversation/:id', - array('action' => 'conversation'), - array('id' => '[0-9]+')); + ['action' => 'conversation'], + ['id' => '[0-9]+']); $m->connect('user/:id', - array('action' => 'userbyid'), - array('id' => '[0-9]+')); + ['action' => 'userbyid'], + ['id' => '[0-9]+']); $m->connect('tag/:tag/rss', - array('action' => 'tagrss'), - array('tag' => self::REGEX_TAG)); + ['action' => 'tagrss'], + ['tag' => self::REGEX_TAG]); $m->connect('tag/:tag', - array('action' => 'tag'), - array('tag' => self::REGEX_TAG)); + ['action' => 'tag'], + ['tag' => self::REGEX_TAG]); // groups - $m->connect('group/new', array('action' => 'newgroup')); + $m->connect('group/new', ['action' => 'newgroup']); - foreach (array('edit', 'join', 'leave', 'delete', 'cancel', 'approve') as $v) { + foreach (['edit', 'join', 'leave', 'delete', 'cancel', 'approve'] as $v) { $m->connect('group/:nickname/'.$v, - array('action' => $v.'group'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => $v.'group'], + ['nickname' => Nickname::DISPLAY_FMT]); $m->connect('group/:id/id/'.$v, - array('action' => $v.'group'), - array('id' => '[0-9]+')); + ['action' => $v.'group'], + ['id' => '[0-9]+']); } - foreach (array('members', 'logo', 'rss') as $n) { + foreach (['members', 'logo', 'rss'] as $n) { $m->connect('group/:nickname/'.$n, - array('action' => 'group'.$n), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'group'.$n], + ['nickname' => Nickname::DISPLAY_FMT]); } $m->connect('group/:nickname/foaf', - array('action' => 'foafgroup'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'foafgroup'], + ['nickname' => Nickname::DISPLAY_FMT]); $m->connect('group/:nickname/blocked', - array('action' => 'blockedfromgroup'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'blockedfromgroup'], + ['nickname' => Nickname::DISPLAY_FMT]); $m->connect('group/:nickname/makeadmin', - array('action' => 'makeadmin'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'makeadmin'], + ['nickname' => Nickname::DISPLAY_FMT]); $m->connect('group/:nickname/members/pending', - array('action' => 'groupqueue'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'groupqueue'], + ['nickname' => Nickname::DISPLAY_FMT]); $m->connect('group/:id/id', - array('action' => 'groupbyid'), - array('id' => '[0-9]+')); + ['action' => 'groupbyid'], + ['id' => '[0-9]+']); $m->connect('group/:nickname', - array('action' => 'showgroup'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'showgroup'], + ['nickname' => Nickname::DISPLAY_FMT]); $m->connect('group/:nickname/', - array('action' => 'showgroup'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'showgroup'], + ['nickname' => Nickname::DISPLAY_FMT]); - $m->connect('group/', array('action' => 'groups')); - $m->connect('group', array('action' => 'groups')); - $m->connect('groups/', array('action' => 'groups')); - $m->connect('groups', array('action' => 'groups')); + $m->connect('group/', ['action' => 'groups']); + $m->connect('group', ['action' => 'groups']); + $m->connect('groups/', ['action' => 'groups']); + $m->connect('groups', ['action' => 'groups']); // Twitter-compatible API // statuses API $m->connect('api', - array('action' => 'Redirect', - 'nextAction' => 'doc', - 'args' => array('title' => 'api'))); + ['action' => 'Redirect', + 'nextAction' => 'doc', + 'args' => ['title' => 'api']]); $m->connect('api/statuses/public_timeline.:format', - array('action' => 'ApiTimelinePublic', - 'format' => '(xml|json|rss|atom|as)')); + ['action' => 'ApiTimelinePublic'], + ['format' => '(xml|json|rss|atom|as)']); // this is not part of the Twitter API. Also may require authentication depending on server config! $m->connect('api/statuses/networkpublic_timeline.:format', - array('action' => 'ApiTimelineNetworkPublic', - 'format' => '(xml|json|rss|atom|as)')); + ['action' => 'ApiTimelineNetworkPublic'], + ['format' => '(xml|json|rss|atom|as)']); $m->connect('api/statuses/friends_timeline/:id.:format', - array('action' => 'ApiTimelineFriends', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json|rss|atom|as)')); + ['action' => 'ApiTimelineFriends'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json|rss|atom|as)']); $m->connect('api/statuses/friends_timeline.:format', - array('action' => 'ApiTimelineFriends', - 'format' => '(xml|json|rss|atom|as)')); + ['action' => 'ApiTimelineFriends'], + ['format' => '(xml|json|rss|atom|as)']); $m->connect('api/statuses/home_timeline/:id.:format', - array('action' => 'ApiTimelineHome', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json|rss|atom|as)')); + ['action' => 'ApiTimelineHome'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json|rss|atom|as)']); $m->connect('api/statuses/home_timeline.:format', - array('action' => 'ApiTimelineHome', - 'format' => '(xml|json|rss|atom|as)')); + ['action' => 'ApiTimelineHome'], + ['format' => '(xml|json|rss|atom|as)']); $m->connect('api/statuses/user_timeline/:id.:format', - array('action' => 'ApiTimelineUser', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json|rss|atom|as)')); + ['action' => 'ApiTimelineUser'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json|rss|atom|as)']); $m->connect('api/statuses/user_timeline.:format', - array('action' => 'ApiTimelineUser', - 'format' => '(xml|json|rss|atom|as)')); + ['action' => 'ApiTimelineUser'], + ['format' => '(xml|json|rss|atom|as)']); $m->connect('api/statuses/mentions/:id.:format', - array('action' => 'ApiTimelineMentions', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json|rss|atom|as)')); + ['action' => 'ApiTimelineMentions'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json|rss|atom|as)']); $m->connect('api/statuses/mentions.:format', - array('action' => 'ApiTimelineMentions', - 'format' => '(xml|json|rss|atom|as)')); + ['action' => 'ApiTimelineMentions'], + ['format' => '(xml|json|rss|atom|as)']); $m->connect('api/statuses/replies/:id.:format', - array('action' => 'ApiTimelineMentions', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json|rss|atom|as)')); + ['action' => 'ApiTimelineMentions'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json|rss|atom|as)']); $m->connect('api/statuses/replies.:format', - array('action' => 'ApiTimelineMentions', - 'format' => '(xml|json|rss|atom|as)')); + ['action' => 'ApiTimelineMentions'], + ['format' => '(xml|json|rss|atom|as)']); $m->connect('api/statuses/mentions_timeline/:id.:format', - array('action' => 'ApiTimelineMentions', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json|rss|atom|as)')); + ['action' => 'ApiTimelineMentions'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json|rss|atom|as)']); $m->connect('api/statuses/mentions_timeline.:format', - array('action' => 'ApiTimelineMentions', - 'format' => '(xml|json|rss|atom|as)')); + ['action' => 'ApiTimelineMentions'], + ['format' => '(xml|json|rss|atom|as)']); $m->connect('api/statuses/friends/:id.:format', - array('action' => 'ApiUserFriends', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json)')); + ['action' => 'ApiUserFriends'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json)']); $m->connect('api/statuses/friends.:format', - array('action' => 'ApiUserFriends', - 'format' => '(xml|json)')); + ['action' => 'ApiUserFriends'], + ['format' => '(xml|json)']); $m->connect('api/statuses/followers/:id.:format', - array('action' => 'ApiUserFollowers', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json)')); + ['action' => 'ApiUserFollowers'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json)']); $m->connect('api/statuses/followers.:format', - array('action' => 'ApiUserFollowers', - 'format' => '(xml|json)')); + ['action' => 'ApiUserFollowers'], + ['format' => '(xml|json)']); $m->connect('api/statuses/show/:id.:format', - array('action' => 'ApiStatusesShow', - 'id' => '[0-9]+', - 'format' => '(xml|json|atom)')); + ['action' => 'ApiStatusesShow'], + ['id' => '[0-9]+', + 'format' => '(xml|json|atom)']); $m->connect('api/statuses/show.:format', - array('action' => 'ApiStatusesShow', - 'format' => '(xml|json|atom)')); + ['action' => 'ApiStatusesShow'], + ['format' => '(xml|json|atom)']); $m->connect('api/statuses/update.:format', - array('action' => 'ApiStatusesUpdate', - 'format' => '(xml|json|atom)')); + ['action' => 'ApiStatusesUpdate'], + ['format' => '(xml|json|atom)']); $m->connect('api/statuses/destroy/:id.:format', - array('action' => 'ApiStatusesDestroy', - 'id' => '[0-9]+', - 'format' => '(xml|json)')); + ['action' => 'ApiStatusesDestroy'], + ['id' => '[0-9]+', + 'format' => '(xml|json)']); $m->connect('api/statuses/destroy.:format', - array('action' => 'ApiStatusesDestroy', - 'format' => '(xml|json)')); + ['action' => 'ApiStatusesDestroy'], + ['format' => '(xml|json)']); // START qvitter API additions $m->connect('api/attachment/:id.:format', - array('action' => 'ApiAttachment', - 'id' => '[0-9]+', - 'format' => '(xml|json)')); + ['action' => 'ApiAttachment'], + ['id' => '[0-9]+', + 'format' => '(xml|json)']); $m->connect('api/checkhub.:format', - array('action' => 'ApiCheckHub', - 'format' => '(xml|json)')); + ['action' => 'ApiCheckHub'], + ['format' => '(xml|json)']); $m->connect('api/externalprofile/show.:format', - array('action' => 'ApiExternalProfileShow', - 'format' => '(xml|json)')); + ['action' => 'ApiExternalProfileShow'], + ['format' => '(xml|json)']); $m->connect('api/statusnet/groups/admins/:id.:format', - array('action' => 'ApiGroupAdmins', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json)')); + ['action' => 'ApiGroupAdmins'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json)']); $m->connect('api/account/update_link_color.:format', - array('action' => 'ApiAccountUpdateLinkColor', - 'format' => '(xml|json)')); + ['action' => 'ApiAccountUpdateLinkColor'], + ['format' => '(xml|json)']); $m->connect('api/account/update_background_color.:format', - array('action' => 'ApiAccountUpdateBackgroundColor', - 'format' => '(xml|json)')); + ['action' => 'ApiAccountUpdateBackgroundColor'], + ['format' => '(xml|json)']); $m->connect('api/account/register.:format', - array('action' => 'ApiAccountRegister', - 'format' => '(xml|json)')); + ['action' => 'ApiAccountRegister'], + ['format' => '(xml|json)']); $m->connect('api/check_nickname.:format', - array('action' => 'ApiCheckNickname', - 'format' => '(xml|json)')); + ['action' => 'ApiCheckNickname'], + ['format' => '(xml|json)']); // END qvitter API additions // users $m->connect('api/users/show/:id.:format', - array('action' => 'ApiUserShow', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json)')); + ['action' => 'ApiUserShow'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json)']); $m->connect('api/users/show.:format', - array('action' => 'ApiUserShow', - 'format' => '(xml|json)')); + ['action' => 'ApiUserShow'], + ['format' => '(xml|json)']); $m->connect('api/users/profile_image/:screen_name.:format', - array('action' => 'ApiUserProfileImage', - 'screen_name' => Nickname::DISPLAY_FMT, - 'format' => '(xml|json)')); + ['action' => 'ApiUserProfileImage'], + ['screen_name' => Nickname::DISPLAY_FMT, + 'format' => '(xml|json)']); // friendships $m->connect('api/friendships/show.:format', - array('action' => 'ApiFriendshipsShow', - 'format' => '(xml|json)')); + ['action' => 'ApiFriendshipsShow'], + ['format' => '(xml|json)']); $m->connect('api/friendships/exists.:format', - array('action' => 'ApiFriendshipsExists', - 'format' => '(xml|json)')); + ['action' => 'ApiFriendshipsExists'], + ['format' => '(xml|json)']); $m->connect('api/friendships/create/:id.:format', - array('action' => 'ApiFriendshipsCreate', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json)')); + ['action' => 'ApiFriendshipsCreate'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json)']); $m->connect('api/friendships/create.:format', - array('action' => 'ApiFriendshipsCreate', - 'format' => '(xml|json)')); + ['action' => 'ApiFriendshipsCreate'], + ['format' => '(xml|json)']); $m->connect('api/friendships/destroy/:id.:format', - array('action' => 'ApiFriendshipsDestroy', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json)')); + ['action' => 'ApiFriendshipsDestroy'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json)']); $m->connect('api/friendships/destroy.:format', - array('action' => 'ApiFriendshipsDestroy', - 'format' => '(xml|json)')); + ['action' => 'ApiFriendshipsDestroy'], + ['format' => '(xml|json)']); // Social graph $m->connect('api/friends/ids/:id.:format', - array('action' => 'ApiUserFriends', - 'ids_only' => true)); + ['action' => 'ApiUserFriends', + 'ids_only' => true], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json)']); $m->connect('api/followers/ids/:id.:format', - array('action' => 'ApiUserFollowers', - 'ids_only' => true)); + ['action' => 'ApiUserFollowers', + 'ids_only' => true], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json)']); $m->connect('api/friends/ids.:format', - array('action' => 'ApiUserFriends', - 'ids_only' => true)); + ['action' => 'ApiUserFriends', + 'ids_only' => true], + ['format' => '(xml|json)']); $m->connect('api/followers/ids.:format', - array('action' => 'ApiUserFollowers', - 'ids_only' => true)); + ['action' => 'ApiUserFollowers', + 'ids_only' => true], + ['format' => '(xml|json)']); // account $m->connect('api/account/verify_credentials.:format', - array('action' => 'ApiAccountVerifyCredentials')); + ['action' => 'ApiAccountVerifyCredentials'], + ['format' => '(xml|json)']); $m->connect('api/account/update_profile.:format', - array('action' => 'ApiAccountUpdateProfile')); + ['action' => 'ApiAccountUpdateProfile'], + ['format' => '(xml|json)']); $m->connect('api/account/update_profile_image.:format', - array('action' => 'ApiAccountUpdateProfileImage')); + ['action' => 'ApiAccountUpdateProfileImage'], + ['format' => '(xml|json)']); $m->connect('api/account/update_delivery_device.:format', - array('action' => 'ApiAccountUpdateDeliveryDevice')); + ['action' => 'ApiAccountUpdateDeliveryDevice'], + ['format' => '(xml|json)']); // special case where verify_credentials is called w/out a format $m->connect('api/account/verify_credentials', - array('action' => 'ApiAccountVerifyCredentials')); + ['action' => 'ApiAccountVerifyCredentials']); $m->connect('api/account/rate_limit_status.:format', - array('action' => 'ApiAccountRateLimitStatus')); + ['action' => 'ApiAccountRateLimitStatus'], + ['format' => '(xml|json)']); // blocks $m->connect('api/blocks/create/:id.:format', - array('action' => 'ApiBlockCreate', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json)')); + ['action' => 'ApiBlockCreate'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json)']); $m->connect('api/blocks/create.:format', - array('action' => 'ApiBlockCreate', - 'format' => '(xml|json)')); + ['action' => 'ApiBlockCreate'], + ['format' => '(xml|json)']); $m->connect('api/blocks/destroy/:id.:format', - array('action' => 'ApiBlockDestroy', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json)')); + ['action' => 'ApiBlockDestroy'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json)']); $m->connect('api/blocks/destroy.:format', - array('action' => 'ApiBlockDestroy', - 'format' => '(xml|json)')); + ['action' => 'ApiBlockDestroy'], + ['format' => '(xml|json)']); // help $m->connect('api/help/test.:format', - array('action' => 'ApiHelpTest', - 'format' => '(xml|json)')); + ['action' => 'ApiHelpTest'], + ['format' => '(xml|json)']); // statusnet $m->connect('api/statusnet/version.:format', - array('action' => 'ApiGNUsocialVersion', - 'format' => '(xml|json)')); + ['action' => 'ApiGNUsocialVersion'], + ['format' => '(xml|json)']); $m->connect('api/statusnet/config.:format', - array('action' => 'ApiGNUsocialConfig', - 'format' => '(xml|json)')); + ['action' => 'ApiGNUsocialConfig'], + ['format' => '(xml|json)']); // For our current software name, we provide "gnusocial" base action $m->connect('api/gnusocial/version.:format', - array('action' => 'ApiGNUsocialVersion', - 'format' => '(xml|json)')); + ['action' => 'ApiGNUsocialVersion'], + ['format' => '(xml|json)']); $m->connect('api/gnusocial/config.:format', - array('action' => 'ApiGNUsocialConfig', - 'format' => '(xml|json)')); + ['action' => 'ApiGNUsocialConfig'], + ['format' => '(xml|json)']); // Groups and tags are newer than 0.8.1 so no backward-compatibility // necessary @@ -606,217 +621,214 @@ class Router //'list' has to be handled differently, as php will not allow a method to be named 'list' $m->connect('api/statusnet/groups/timeline/:id.:format', - array('action' => 'ApiTimelineGroup', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json|rss|atom|as)')); + ['action' => 'ApiTimelineGroup'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json|rss|atom|as)']); $m->connect('api/statusnet/groups/show/:id.:format', - array('action' => 'ApiGroupShow', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json)')); + ['action' => 'ApiGroupShow'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json)']); $m->connect('api/statusnet/groups/show.:format', - array('action' => 'ApiGroupShow', - 'format' => '(xml|json)')); + ['action' => 'ApiGroupShow'], + ['format' => '(xml|json)']); $m->connect('api/statusnet/groups/join/:id.:format', - array('action' => 'ApiGroupJoin', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json)')); + ['action' => 'ApiGroupJoin'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json)']); $m->connect('api/statusnet/groups/join.:format', - array('action' => 'ApiGroupJoin', - 'format' => '(xml|json)')); + ['action' => 'ApiGroupJoin'], + ['format' => '(xml|json)']); $m->connect('api/statusnet/groups/leave/:id.:format', - array('action' => 'ApiGroupLeave', - 'format' => '(xml|json)')); + ['action' => 'ApiGroupLeave'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json)']); $m->connect('api/statusnet/groups/leave.:format', - array('action' => 'ApiGroupLeave', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json)')); + ['action' => 'ApiGroupLeave'], + ['format' => '(xml|json)']); $m->connect('api/statusnet/groups/is_member.:format', - array('action' => 'ApiGroupIsMember', - 'format' => '(xml|json)')); + ['action' => 'ApiGroupIsMember'], + ['format' => '(xml|json)']); $m->connect('api/statusnet/groups/list/:id.:format', - array('action' => 'ApiGroupList', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json|rss|atom)')); + ['action' => 'ApiGroupList'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json|rss|atom)']); $m->connect('api/statusnet/groups/list.:format', - array('action' => 'ApiGroupList', - 'format' => '(xml|json|rss|atom)')); + ['action' => 'ApiGroupList'], + ['format' => '(xml|json|rss|atom)']); $m->connect('api/statusnet/groups/list_all.:format', - array('action' => 'ApiGroupListAll', - 'format' => '(xml|json|rss|atom)')); + ['action' => 'ApiGroupListAll'], + ['format' => '(xml|json|rss|atom)']); $m->connect('api/statusnet/groups/membership/:id.:format', - array('action' => 'ApiGroupMembership', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json)')); + ['action' => 'ApiGroupMembership'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json)']); $m->connect('api/statusnet/groups/membership.:format', - array('action' => 'ApiGroupMembership', - 'format' => '(xml|json)')); + ['action' => 'ApiGroupMembership'], + ['format' => '(xml|json)']); $m->connect('api/statusnet/groups/create.:format', - array('action' => 'ApiGroupCreate', - 'format' => '(xml|json)')); + ['action' => 'ApiGroupCreate'], + ['format' => '(xml|json)']); $m->connect('api/statusnet/groups/update/:id.:format', - array('action' => 'ApiGroupProfileUpdate', - 'id' => '[a-zA-Z0-9]+', - 'format' => '(xml|json)')); + ['action' => 'ApiGroupProfileUpdate'], + ['id' => '[a-zA-Z0-9]+', + 'format' => '(xml|json)']); $m->connect('api/statusnet/conversation/:id.:format', - array('action' => 'apiconversation', - 'id' => '[0-9]+', - 'format' => '(xml|json|rss|atom|as)')); + ['action' => 'apiconversation'], + ['id' => '[0-9]+', + 'format' => '(xml|json|rss|atom|as)']); // Lists (people tags) $m->connect('api/lists/list.:format', - array('action' => 'ApiListSubscriptions', - 'format' => '(xml|json)')); + ['action' => 'ApiListSubscriptions'], + ['format' => '(xml|json)']); $m->connect('api/lists/memberships.:format', - array('action' => 'ApiListMemberships', - 'format' => '(xml|json)')); + ['action' => 'ApiListMemberships'], + ['format' => '(xml|json)']); $m->connect('api/:user/lists/memberships.:format', - array('action' => 'ApiListMemberships', - 'user' => '[a-zA-Z0-9]+', - 'format' => '(xml|json)')); + ['action' => 'ApiListMemberships'], + ['user' => '[a-zA-Z0-9]+', + 'format' => '(xml|json)']); $m->connect('api/lists/subscriptions.:format', - array('action' => 'ApiListSubscriptions', - 'format' => '(xml|json)')); + ['action' => 'ApiListSubscriptions'], + ['format' => '(xml|json)']); $m->connect('api/:user/lists/subscriptions.:format', - array('action' => 'ApiListSubscriptions', - 'user' => '[a-zA-Z0-9]+', - 'format' => '(xml|json)')); + ['action' => 'ApiListSubscriptions'], + ['user' => '[a-zA-Z0-9]+', + 'format' => '(xml|json)']); $m->connect('api/lists.:format', - array('action' => 'ApiLists', - 'format' => '(xml|json)')); + ['action' => 'ApiLists'], + ['format' => '(xml|json)']); $m->connect('api/:user/lists/:id.:format', - array('action' => 'ApiList', - 'user' => '[a-zA-Z0-9]+', - 'id' => '[a-zA-Z0-9]+', - 'format' => '(xml|json)')); + ['action' => 'ApiList'], + ['user' => '[a-zA-Z0-9]+', + 'id' => '[a-zA-Z0-9]+', + 'format' => '(xml|json)']); $m->connect('api/:user/lists.:format', - array('action' => 'ApiLists', - 'user' => '[a-zA-Z0-9]+', - 'format' => '(xml|json)')); + ['action' => 'ApiLists'], + ['user' => '[a-zA-Z0-9]+', + 'format' => '(xml|json)']); $m->connect('api/:user/lists/:id/statuses.:format', - array('action' => 'ApiTimelineList', - 'user' => '[a-zA-Z0-9]+', - 'id' => '[a-zA-Z0-9]+', - 'format' => '(xml|json|rss|atom)')); + ['action' => 'ApiTimelineList'], + ['user' => '[a-zA-Z0-9]+', + 'id' => '[a-zA-Z0-9]+', + 'format' => '(xml|json|rss|atom)']); $m->connect('api/:user/:list_id/members/:id.:format', - array('action' => 'ApiListMember', - 'user' => '[a-zA-Z0-9]+', - 'list_id' => '[a-zA-Z0-9]+', - 'id' => '[a-zA-Z0-9]+', - 'format' => '(xml|json)')); + ['action' => 'ApiListMember'], + ['user' => '[a-zA-Z0-9]+', + 'list_id' => '[a-zA-Z0-9]+', + 'id' => '[a-zA-Z0-9]+', + 'format' => '(xml|json)']); $m->connect('api/:user/:list_id/members.:format', - array('action' => 'ApiListMembers', - 'user' => '[a-zA-Z0-9]+', - 'list_id' => '[a-zA-Z0-9]+', - 'format' => '(xml|json)')); + ['action' => 'ApiListMembers'], + ['user' => '[a-zA-Z0-9]+', + 'list_id' => '[a-zA-Z0-9]+', + 'format' => '(xml|json)']); $m->connect('api/:user/:list_id/subscribers/:id.:format', - array('action' => 'ApiListSubscriber', - 'user' => '[a-zA-Z0-9]+', - 'list_id' => '[a-zA-Z0-9]+', - 'id' => '[a-zA-Z0-9]+', - 'format' => '(xml|json)')); + ['action' => 'ApiListSubscriber'], + ['user' => '[a-zA-Z0-9]+', + 'list_id' => '[a-zA-Z0-9]+', + 'id' => '[a-zA-Z0-9]+', + 'format' => '(xml|json)']); $m->connect('api/:user/:list_id/subscribers.:format', - array('action' => 'ApiListSubscribers', - 'user' => '[a-zA-Z0-9]+', - 'list_id' => '[a-zA-Z0-9]+', - 'format' => '(xml|json)')); + ['action' => 'ApiListSubscribers'], + ['user' => '[a-zA-Z0-9]+', + 'list_id' => '[a-zA-Z0-9]+', + 'format' => '(xml|json)']); // Tags $m->connect('api/statusnet/tags/timeline/:tag.:format', - array('action' => 'ApiTimelineTag', - 'tag' => self::REGEX_TAG, - 'format' => '(xml|json|rss|atom|as)')); + ['action' => 'ApiTimelineTag'], + ['tag' => self::REGEX_TAG, + 'format' => '(xml|json|rss|atom|as)']); // media related - $m->connect( - 'api/statusnet/media/upload', - array('action' => 'ApiMediaUpload') - ); - $m->connect( - 'api/statuses/update_with_media.json', - array('action' => 'ApiMediaUpload') - ); + $m->connect('api/statusnet/media/upload', + ['action' => 'ApiMediaUpload']); + + $m->connect('api/statuses/update_with_media.json', + ['action' => 'ApiMediaUpload']); + // Twitter Media upload API v1.1 - $m->connect( - 'api/media/upload.:format', - array('action' => 'ApiMediaUpload', - 'format' => '(xml|json)', - ) - ); + $m->connect('api/media/upload.:format', + ['action' => 'ApiMediaUpload'], + ['format' => '(xml|json)']); // search - $m->connect('api/search.atom', array('action' => 'ApiSearchAtom')); - $m->connect('api/search.json', array('action' => 'ApiSearchJSON')); - $m->connect('api/trends.json', array('action' => 'ApiTrends')); + $m->connect('api/search.atom', ['action' => 'ApiSearchAtom']); + $m->connect('api/search.json', ['action' => 'ApiSearchJSON']); + $m->connect('api/trends.json', ['action' => 'ApiTrends']); $m->connect('api/oauth/request_token', - array('action' => 'ApiOAuthRequestToken')); + ['action' => 'ApiOAuthRequestToken']); $m->connect('api/oauth/access_token', - array('action' => 'ApiOAuthAccessToken')); + ['action' => 'ApiOAuthAccessToken']); $m->connect('api/oauth/authorize', - array('action' => 'ApiOAuthAuthorize')); + ['action' => 'ApiOAuthAuthorize']); // Admin - $m->connect('panel/site', array('action' => 'siteadminpanel')); - $m->connect('panel/user', array('action' => 'useradminpanel')); - $m->connect('panel/access', array('action' => 'accessadminpanel')); - $m->connect('panel/paths', array('action' => 'pathsadminpanel')); - $m->connect('panel/sessions', array('action' => 'sessionsadminpanel')); - $m->connect('panel/sitenotice', array('action' => 'sitenoticeadminpanel')); - $m->connect('panel/license', array('action' => 'licenseadminpanel')); + $m->connect('panel/site', ['action' => 'siteadminpanel']); + $m->connect('panel/user', ['action' => 'useradminpanel']); + $m->connect('panel/access', ['action' => 'accessadminpanel']); + $m->connect('panel/paths', ['action' => 'pathsadminpanel']); + $m->connect('panel/sessions', ['action' => 'sessionsadminpanel']); + $m->connect('panel/sitenotice', ['action' => 'sitenoticeadminpanel']); + $m->connect('panel/license', ['action' => 'licenseadminpanel']); - $m->connect('panel/plugins', array('action' => 'pluginsadminpanel')); + $m->connect('panel/plugins', ['action' => 'pluginsadminpanel']); $m->connect('panel/plugins/enable/:plugin', - array('action' => 'pluginenable'), - array('plugin' => '[A-Za-z0-9_]+')); + ['action' => 'pluginenable'], + ['plugin' => '[A-Za-z0-9_]+']); $m->connect('panel/plugins/disable/:plugin', - array('action' => 'plugindisable'), - array('plugin' => '[A-Za-z0-9_]+')); + ['action' => 'plugindisable'], + ['plugin' => '[A-Za-z0-9_]+']); // Common people-tag stuff - $m->connect('peopletag/:tag', array('action' => 'peopletag', - 'tag' => self::REGEX_TAG)); + $m->connect('peopletag/:tag', + ['action' => 'peopletag'], + ['tag' => self::REGEX_TAG]); - $m->connect('selftag/:tag', array('action' => 'selftag', - 'tag' => self::REGEX_TAG)); + $m->connect('selftag/:tag', + ['action' => 'selftag'], + ['tag' => self::REGEX_TAG]); - $m->connect('main/addpeopletag', array('action' => 'addpeopletag')); + $m->connect('main/addpeopletag', ['action' => 'addpeopletag']); - $m->connect('main/removepeopletag', array('action' => 'removepeopletag')); + $m->connect('main/removepeopletag', ['action' => 'removepeopletag']); - $m->connect('main/profilecompletion', array('action' => 'profilecompletion')); + $m->connect('main/profilecompletion', ['action' => 'profilecompletion']); - $m->connect('main/peopletagautocomplete', array('action' => 'peopletagautocomplete')); + $m->connect('main/peopletagautocomplete', ['action' => 'peopletagautocomplete']); // In the "root" @@ -824,269 +836,272 @@ class Router $nickname = User::singleUserNickname(); - foreach (array('subscriptions', 'subscribers', - 'all', 'foaf', 'replies', - ) as $a) { + foreach (['subscriptions', 'subscribers', 'all', 'foaf', 'replies'] as $a) { $m->connect($a, - array('action' => $a, - 'nickname' => $nickname)); + ['action' => $a, + 'nickname' => $nickname]); } - foreach (array('subscriptions', 'subscribers') as $a) { + foreach (['subscriptions', 'subscribers'] as $a) { $m->connect($a.'/:tag', - array('action' => $a, - 'nickname' => $nickname), - array('tag' => self::REGEX_TAG)); + ['action' => $a, + 'nickname' => $nickname], + ['tag' => self::REGEX_TAG]); } $m->connect('subscribers/pending', - array('action' => 'subqueue', - 'nickname' => $nickname)); + ['action' => 'subqueue', + 'nickname' => $nickname]); - foreach (array('rss', 'groups') as $a) { + foreach (['rss', 'groups'] as $a) { $m->connect($a, - array('action' => 'user'.$a, - 'nickname' => $nickname)); + ['action' => 'user'.$a, + 'nickname' => $nickname]); } - foreach (array('all', 'replies') as $a) { + foreach (['all', 'replies'] as $a) { $m->connect($a.'/rss', - array('action' => $a.'rss', - 'nickname' => $nickname)); + ['action' => $a.'rss', + 'nickname' => $nickname]); } $m->connect('avatar', - array('action' => 'avatarbynickname', - 'nickname' => $nickname)); + ['action' => 'avatarbynickname', + 'nickname' => $nickname]); + $m->connect('avatar/:size', - array('action' => 'avatarbynickname', - 'nickname' => $nickname), - array('size' => '(|original|\d+)')); + ['action' => 'avatarbynickname', + 'nickname' => $nickname], + ['size' => '(|original|\d+)']); $m->connect('tag/:tag/rss', - array('action' => 'userrss', - 'nickname' => $nickname), - array('tag' => self::REGEX_TAG)); + ['action' => 'userrss', + 'nickname' => $nickname], + ['tag' => self::REGEX_TAG]); $m->connect('tag/:tag', - array('action' => 'showstream', - 'nickname' => $nickname), - array('tag' => self::REGEX_TAG)); + ['action' => 'showstream', + 'nickname' => $nickname], + ['tag' => self::REGEX_TAG]); $m->connect('rsd.xml', - array('action' => 'rsd', - 'nickname' => $nickname)); + ['action' => 'rsd', + 'nickname' => $nickname]); // peopletags $m->connect('peopletags', - array('action' => 'peopletagsbyuser')); + ['action' => 'peopletagsbyuser']); $m->connect('peopletags/private', - array('action' => 'peopletagsbyuser', - 'private' => 1)); + ['action' => 'peopletagsbyuser', + 'private' => 1]); $m->connect('peopletags/public', - array('action' => 'peopletagsbyuser', - 'public' => 1)); + ['action' => 'peopletagsbyuser', + 'public' => 1]); $m->connect('othertags', - array('action' => 'peopletagsforuser')); + ['action' => 'peopletagsforuser']); $m->connect('peopletagsubscriptions', - array('action' => 'peopletagsubscriptions')); + ['action' => 'peopletagsubscriptions']); $m->connect('all/:tag/subscribers', - array('action' => 'peopletagsubscribers', - 'tag' => self::REGEX_TAG)); + ['action' => 'peopletagsubscribers'], + ['tag' => self::REGEX_TAG]); $m->connect('all/:tag/tagged', - array('action' => 'peopletagged', - 'tag' => self::REGEX_TAG)); + ['action' => 'peopletagged'], + ['tag' => self::REGEX_TAG]); $m->connect('all/:tag/edit', - array('action' => 'editpeopletag', - 'tag' => self::REGEX_TAG)); + ['action' => 'editpeopletag'], + ['tag' => self::REGEX_TAG]); - foreach(array('subscribe', 'unsubscribe') as $v) { + foreach (['subscribe', 'unsubscribe'] as $v) { $m->connect('peopletag/:id/'.$v, - array('action' => $v.'peopletag', - 'id' => '[0-9]{1,64}')); + ['action' => $v.'peopletag'], + ['id' => '[0-9]{1,64}']); } + $m->connect('user/:tagger_id/profiletag/:id/id', - array('action' => 'profiletagbyid', - 'tagger_id' => '[0-9]+', - 'id' => '[0-9]+')); + ['action' => 'profiletagbyid'], + ['tagger_id' => '[0-9]+', + 'id' => '[0-9]+']); $m->connect('all/:tag', - array('action' => 'showprofiletag', - 'tagger' => $nickname, - 'tag' => self::REGEX_TAG)); + ['action' => 'showprofiletag', + 'tagger' => $nickname], + ['tag' => self::REGEX_TAG]); - foreach (array('subscriptions', 'subscribers') as $a) { + foreach (['subscriptions', 'subscribers'] as $a) { $m->connect($a.'/:tag', - array('action' => $a), - array('tag' => self::REGEX_TAG)); + ['action' => $a], + ['tag' => self::REGEX_TAG]); } } - $m->connect('rss', array('action' => 'publicrss')); - $m->connect('featuredrss', array('action' => 'featuredrss')); - $m->connect('featured/', array('action' => 'featured')); - $m->connect('featured', array('action' => 'featured')); - $m->connect('rsd.xml', array('action' => 'rsd')); + $m->connect('rss', ['action' => 'publicrss']); + $m->connect('featuredrss', ['action' => 'featuredrss']); + $m->connect('featured/', ['action' => 'featured']); + $m->connect('featured', ['action' => 'featured']); + $m->connect('rsd.xml', ['action' => 'rsd']); - foreach (array('subscriptions', 'subscribers', + foreach (['subscriptions', 'subscribers', 'nudge', 'all', 'foaf', 'replies', - 'inbox', 'outbox') as $a) { + 'inbox', 'outbox'] as $a) { $m->connect(':nickname/'.$a, - array('action' => $a), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => $a], + ['nickname' => Nickname::DISPLAY_FMT]); } + $m->connect(':nickname/subscribers/pending', - array('action' => 'subqueue'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'subqueue'], + ['nickname' => Nickname::DISPLAY_FMT]); // some targeted RSS 1.0 actions (extends TargetedRss10Action) - foreach (array('all', 'replies') as $a) { + foreach (['all', 'replies'] as $a) { $m->connect(':nickname/'.$a.'/rss', - array('action' => $a.'rss'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => $a.'rss'], + ['nickname' => Nickname::DISPLAY_FMT]); } // people tags $m->connect(':nickname/peopletags', - array('action' => 'peopletagsbyuser', - 'nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'peopletagsbyuser'], + ['nickname' => Nickname::DISPLAY_FMT]); $m->connect(':nickname/peopletags/private', - array('action' => 'peopletagsbyuser', - 'nickname' => Nickname::DISPLAY_FMT, - 'private' => 1)); + ['action' => 'peopletagsbyuser', + 'private' => 1], + ['nickname' => Nickname::DISPLAY_FMT]); $m->connect(':nickname/peopletags/public', - array('action' => 'peopletagsbyuser', - 'nickname' => Nickname::DISPLAY_FMT, - 'public' => 1)); + ['action' => 'peopletagsbyuser', + 'public' => 1], + ['nickname' => Nickname::DISPLAY_FMT]); $m->connect(':nickname/othertags', - array('action' => 'peopletagsforuser', - 'nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'peopletagsforuser'], + ['nickname' => Nickname::DISPLAY_FMT]); $m->connect(':nickname/peopletagsubscriptions', - array('action' => 'peopletagsubscriptions', - 'nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'peopletagsubscriptions'], + ['nickname' => Nickname::DISPLAY_FMT]); $m->connect(':tagger/all/:tag/subscribers', - array('action' => 'peopletagsubscribers', - 'tagger' => Nickname::DISPLAY_FMT, - 'tag' => self::REGEX_TAG)); + ['action' => 'peopletagsubscribers'], + ['tagger' => Nickname::DISPLAY_FMT, + 'tag' => self::REGEX_TAG]); $m->connect(':tagger/all/:tag/tagged', - array('action' => 'peopletagged', - 'tagger' => Nickname::DISPLAY_FMT, - 'tag' => self::REGEX_TAG)); + ['action' => 'peopletagged'], + ['tagger' => Nickname::DISPLAY_FMT, + 'tag' => self::REGEX_TAG]); $m->connect(':tagger/all/:tag/edit', - array('action' => 'editpeopletag', - 'tagger' => Nickname::DISPLAY_FMT, - 'tag' => self::REGEX_TAG)); + ['action' => 'editpeopletag'], + ['tagger' => Nickname::DISPLAY_FMT, + 'tag' => self::REGEX_TAG]); - foreach(array('subscribe', 'unsubscribe') as $v) { + foreach (['subscribe', 'unsubscribe'] as $v) { $m->connect('peopletag/:id/'.$v, - array('action' => $v.'peopletag', - 'id' => '[0-9]{1,64}')); + ['action' => $v.'peopletag'], + ['id' => '[0-9]{1,64}']); } + $m->connect('user/:tagger_id/profiletag/:id/id', - array('action' => 'profiletagbyid', - 'tagger_id' => '[0-9]+', - 'id' => '[0-9]+')); + ['action' => 'profiletagbyid'], + ['tagger_id' => '[0-9]+', + 'id' => '[0-9]+']); $m->connect(':nickname/all/:tag', - array('action' => 'showprofiletag'), - array('nickname' => Nickname::DISPLAY_FMT, - 'tag' => self::REGEX_TAG)); + ['action' => 'showprofiletag'], + ['nickname' => Nickname::DISPLAY_FMT, + 'tag' => self::REGEX_TAG]); - foreach (array('subscriptions', 'subscribers') as $a) { + foreach (['subscriptions', 'subscribers'] as $a) { $m->connect(':nickname/'.$a.'/:tag', - array('action' => $a), - array('tag' => self::REGEX_TAG, - 'nickname' => Nickname::DISPLAY_FMT)); + ['action' => $a], + ['tag' => self::REGEX_TAG, + 'nickname' => Nickname::DISPLAY_FMT]); } - foreach (array('rss', 'groups') as $a) { + foreach (['rss', 'groups'] as $a) { $m->connect(':nickname/'.$a, - array('action' => 'user'.$a), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'user'.$a], + ['nickname' => Nickname::DISPLAY_FMT]); } $m->connect(':nickname/avatar', - array('action' => 'avatarbynickname'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'avatarbynickname'], + ['nickname' => Nickname::DISPLAY_FMT]); + $m->connect(':nickname/avatar/:size', - array('action' => 'avatarbynickname'), - array('size' => '(|original|\d+)', - 'nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'avatarbynickname'], + ['size' => '(|original|\d+)', + 'nickname' => Nickname::DISPLAY_FMT]); $m->connect(':nickname/tag/:tag/rss', - array('action' => 'userrss'), - array('nickname' => Nickname::DISPLAY_FMT), - array('tag' => self::REGEX_TAG)); + ['action' => 'userrss'], + ['nickname' => Nickname::DISPLAY_FMT, + 'tag' => self::REGEX_TAG]); $m->connect(':nickname/tag/:tag', - array('action' => 'showstream'), - array('nickname' => Nickname::DISPLAY_FMT), - array('tag' => self::REGEX_TAG)); + ['action' => 'showstream'], + ['nickname' => Nickname::DISPLAY_FMT, + 'tag' => self::REGEX_TAG]); $m->connect(':nickname/rsd.xml', - array('action' => 'rsd'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'rsd'], + ['nickname' => Nickname::DISPLAY_FMT]); $m->connect(':nickname', - array('action' => 'showstream'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'showstream'], + ['nickname' => Nickname::DISPLAY_FMT]); $m->connect(':nickname/', - array('action' => 'showstream'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'showstream'], + ['nickname' => Nickname::DISPLAY_FMT]); // AtomPub API $m->connect('api/statusnet/app/service/:id.xml', - array('action' => 'ApiAtomService'), - array('id' => Nickname::DISPLAY_FMT)); + ['action' => 'ApiAtomService'], + ['id' => Nickname::DISPLAY_FMT]); $m->connect('api/statusnet/app/service.xml', - array('action' => 'ApiAtomService')); + ['action' => 'ApiAtomService']); $m->connect('api/statusnet/app/subscriptions/:subscriber/:subscribed.atom', - array('action' => 'AtomPubShowSubscription'), - array('subscriber' => '[0-9]+', - 'subscribed' => '[0-9]+')); + ['action' => 'AtomPubShowSubscription'], + ['subscriber' => '[0-9]+', + 'subscribed' => '[0-9]+']); $m->connect('api/statusnet/app/subscriptions/:subscriber.atom', - array('action' => 'AtomPubSubscriptionFeed'), - array('subscriber' => '[0-9]+')); + ['action' => 'AtomPubSubscriptionFeed'], + ['subscriber' => '[0-9]+']); $m->connect('api/statusnet/app/memberships/:profile/:group.atom', - array('action' => 'AtomPubShowMembership'), - array('profile' => '[0-9]+', - 'group' => '[0-9]+')); + ['action' => 'AtomPubShowMembership'], + ['profile' => '[0-9]+', + 'group' => '[0-9]+']); $m->connect('api/statusnet/app/memberships/:profile.atom', - array('action' => 'AtomPubMembershipFeed'), - array('profile' => '[0-9]+')); + ['action' => 'AtomPubMembershipFeed'], + ['profile' => '[0-9]+']); // URL shortening $m->connect('url/:id', - array('action' => 'redirecturl', - 'id' => '[0-9]+')); + ['action' => 'redirecturl'], + ['id' => '[0-9]+']); // user stuff - Event::handle('RouterInitialized', array($m)); + Event::handle('RouterInitialized', [$m]); } return $m; diff --git a/lib/urlmapper.php b/lib/urlmapper.php index 735a330ccc..01e4e6fa6c 100644 --- a/lib/urlmapper.php +++ b/lib/urlmapper.php @@ -60,12 +60,35 @@ class URLMapper protected $reverse = []; protected $allpaths = []; - public function connect($path, $args, $paramPatterns = array()) + /** + * Route creation. + * $acceptHeaders should be set to true when, for whatever reason, + * a path is being re-connected. The $headers list is still optional, + * in this case, given that being empty means "accept everything". + * + * @author Evan Prodromou + * @author Bruno Casteleiro + * @param string $path route path + * @param array $args route action and, if needed, action settings + * @param array $paramPatterns regex patterns for path's parameters + * @param bool $acceptHeaders whether a path is being re-connected + * @param array $headers headers that should be set for route creation + * @return void + */ + public function connect(string $path, array $args, array $paramPatterns = [], bool $acceptHeaders = false, array $headers = []) { if (!array_key_exists(self::ACTION, $args)) { throw new Exception(sprintf("Can't connect %s; path has no action.", $path)); } + $should = true; + if ($acceptHeaders) { + // even if it shouldn't be used as a route, we still want + // to store some information to allow common_local_url + // to generate urls + $should = empty($headers) || self::should($headers); + } + $this->allpaths[] = $path; $action = $args[self::ACTION]; @@ -75,15 +98,12 @@ class URLMapper if (empty($paramNames)) { $this->statics[$path] = $args; if (array_key_exists($action, $this->reverse)) { - $this->reverse[$args[self::ACTION]][] = [$args, $path]; + $this->reverse[$action][] = [$args, $path]; } else { - $this->reverse[$args[self::ACTION]] = [[$args, $path]]; + $this->reverse[$action] = [[$args, $path]]; } } else { - - // Eff if I understand why some go here and some go there. - // Anyways, fixup my preconceptions - + // fix for the code that still make improper use of this function's params foreach ($paramNames as $name) { if (!array_key_exists($name, $paramPatterns) && array_key_exists($name, $args)) { @@ -92,16 +112,26 @@ class URLMapper } } - $regex = self::makeRegex($path, $paramPatterns); - - $this->variables[] = [$args, $regex, $paramNames]; + // $variables is used for path matching, so we can't store invalid routes + if ($should) { + $regex = self::makeRegex($path, $paramPatterns); + + if (isset($this->variables[$regex]) || !$acceptHeaders) { + $this->variables[$regex] = [$args, $paramNames]; + } else { + // URLs that differ only in the attribute names will generate + // different regexes, so in order to avoid the wrong one (oldest) + // to be matched first, fresh regexes are stored at the front + $this->variables = [$regex => [$args, $paramNames]] + $this->variables; + } + } - $format = $this->makeFormat($path, $paramPatterns); + $format = $this->makeFormat($path); if (array_key_exists($action, $this->reverse)) { - $this->reverse[$args[self::ACTION]][] = [$args, $format, $paramNames]; + $this->reverse[$action][] = [$args, $format, $paramNames]; } else { - $this->reverse[$args[self::ACTION]] = [[$args, $format, $paramNames]]; + $this->reverse[$action] = [[$args, $format, $paramNames]]; } } } @@ -112,8 +142,8 @@ class URLMapper return $this->statics[$path]; } - foreach ($this->variables as $pattern) { - list($args, $regex, $paramNames) = $pattern; + foreach ($this->variables as $regex => $pattern) { + list($args, $paramNames) = $pattern; if (preg_match($regex, $path, $match)) { $results = $args; foreach ($paramNames as $name) { @@ -220,7 +250,7 @@ class URLMapper return $regex; } - protected function makeFormat($path, $paramPatterns) + protected function makeFormat($path) { $format = preg_replace('/(:\w+)/', '%s', $path); @@ -229,7 +259,33 @@ class URLMapper public function getPaths() { - return $this->allpaths; + return array_unique($this->allpaths); + } + + /** + * Determines whether the route should or not be overwrited. + * If ACCEPT header isn't set, false will be returned. + * + * @author Diogo Cordeiro + * @param array $headers accept-headers that should be set to + * mark the route for overwrite. This array must be associative + * and contain the headers in the value-set. + * @return bool true if should overwrite, false otherwise + */ + public static function should(array $headers): bool + { + if (!isset($_SERVER['HTTP_ACCEPT'])) { + return false; + } + + $acceptHeader = new AcceptHeader($_SERVER['HTTP_ACCEPT']); + foreach ($acceptHeader as $ah) { + if (isset($headers[$ah['raw']])) { + return true; + } + } + + return false; } } diff --git a/plugins/AccountManager/AccountManagerPlugin.php b/plugins/AccountManager/AccountManagerPlugin.php index 1aea7f72e4..1b6d57e46c 100644 --- a/plugins/AccountManager/AccountManagerPlugin.php +++ b/plugins/AccountManager/AccountManagerPlugin.php @@ -52,9 +52,9 @@ class AccountManagerPlugin extends Plugin { // Discovery actions $m->connect('main/amcd.json', - array('action' => 'AccountManagementControlDocument')); + ['action' => 'AccountManagementControlDocument']); $m->connect('main/amsessionstatus', - array('action' => 'AccountManagementSessionStatus')); + ['action' => 'AccountManagementSessionStatus']); return true; } diff --git a/plugins/ActivitySpam/ActivitySpamPlugin.php b/plugins/ActivitySpam/ActivitySpamPlugin.php index 7c9287437d..85f356fd0c 100644 --- a/plugins/ActivitySpam/ActivitySpamPlugin.php +++ b/plugins/ActivitySpam/ActivitySpamPlugin.php @@ -185,11 +185,13 @@ class ActivitySpamPlugin extends Plugin public function onRouterInitialized(URLMapper $m) { $m->connect('main/train/spam', - array('action' => 'train', 'category' => 'spam')); + ['action' => 'train', + 'category' => 'spam']); $m->connect('main/train/ham', - array('action' => 'train', 'category' => 'ham')); + ['action' => 'train', + 'category' => 'ham']); $m->connect('main/spam', - array('action' => 'spam')); + ['action' => 'spam']); return true; } diff --git a/plugins/Autocomplete/AutocompletePlugin.php b/plugins/Autocomplete/AutocompletePlugin.php index 9f6ef401cf..1a9252d5a5 100644 --- a/plugins/Autocomplete/AutocompletePlugin.php +++ b/plugins/Autocomplete/AutocompletePlugin.php @@ -50,7 +50,8 @@ class AutocompletePlugin extends Plugin function onRouterInitialized($m) { - $m->connect('main/autocomplete/suggest', array('action'=>'autocomplete')); + $m->connect('main/autocomplete/suggest', + ['action' => 'autocomplete']); } function onPluginVersion(array &$versions) diff --git a/plugins/BitlyUrl/BitlyUrlPlugin.php b/plugins/BitlyUrl/BitlyUrlPlugin.php index fd9a24b2ca..3bf0399dfb 100644 --- a/plugins/BitlyUrl/BitlyUrlPlugin.php +++ b/plugins/BitlyUrl/BitlyUrlPlugin.php @@ -169,7 +169,7 @@ class BitlyUrlPlugin extends UrlShortenerPlugin public function onRouterInitialized(URLMapper $m) { $m->connect('panel/bitly', - array('action' => 'bitlyadminpanel')); + ['action' => 'bitlyadminpanel']); return true; } diff --git a/plugins/Blacklist/BlacklistPlugin.php b/plugins/Blacklist/BlacklistPlugin.php index 6d4ded70c4..ca76c3e96d 100644 --- a/plugins/Blacklist/BlacklistPlugin.php +++ b/plugins/Blacklist/BlacklistPlugin.php @@ -251,7 +251,8 @@ class BlacklistPlugin extends Plugin */ public function onRouterInitialized(URLMapper $m) { - $m->connect('panel/blacklist', array('action' => 'blacklistadminpanel')); + $m->connect('panel/blacklist', + ['action' => 'blacklistadminpanel']); return true; } diff --git a/plugins/Bookmark/BookmarkPlugin.php b/plugins/Bookmark/BookmarkPlugin.php index 98e9a3881c..771a46c1cc 100644 --- a/plugins/Bookmark/BookmarkPlugin.php +++ b/plugins/Bookmark/BookmarkPlugin.php @@ -114,43 +114,44 @@ class BookmarkPlugin extends MicroAppPlugin if (common_config('singleuser', 'enabled')) { $nickname = User::singleUserNickname(); $m->connect('bookmarks', - array('action' => 'bookmarks', 'nickname' => $nickname)); + ['action' => 'bookmarks', + 'nickname' => $nickname]); $m->connect('bookmarks/rss', - array('action' => 'bookmarksrss', 'nickname' => $nickname)); + ['action' => 'bookmarksrss', + 'nickname' => $nickname]); } else { $m->connect(':nickname/bookmarks', - array('action' => 'bookmarks'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'bookmarks'], + ['nickname' => Nickname::DISPLAY_FMT]); $m->connect(':nickname/bookmarks/rss', - array('action' => 'bookmarksrss'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'bookmarksrss'], + ['nickname' => Nickname::DISPLAY_FMT]); } $m->connect('api/bookmarks/:id.:format', - array('action' => 'ApiTimelineBookmarks', - 'id' => Nickname::INPUT_FMT, - 'format' => '(xml|json|rss|atom|as)')); + ['action' => 'ApiTimelineBookmarks'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json|rss|atom|as)']); $m->connect('main/bookmark/new', - array('action' => 'newbookmark'), - array('id' => '[0-9]+')); + ['action' => 'newbookmark']); $m->connect('main/bookmark/popup', - array('action' => 'bookmarkpopup')); + ['action' => 'bookmarkpopup']); $m->connect('main/bookmark/import', - array('action' => 'importdelicious')); + ['action' => 'importdelicious']); $m->connect('main/bookmark/forurl', - array('action' => 'bookmarkforurl')); + ['action' => 'bookmarkforurl']); $m->connect('bookmark/:id', - array('action' => 'showbookmark'), - array('id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}')); + ['action' => 'showbookmark'], + ['id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}']); $m->connect('notice/by-url/:id', - array('action' => 'noticebyurl'), - array('id' => '[0-9]+')); + ['action' => 'noticebyurl'], + ['id' => '[0-9]+']); return true; } diff --git a/plugins/ChooseTheme/ChooseThemePlugin.php b/plugins/ChooseTheme/ChooseThemePlugin.php index fe7ba52e86..bcfd5ba8a7 100644 --- a/plugins/ChooseTheme/ChooseThemePlugin.php +++ b/plugins/ChooseTheme/ChooseThemePlugin.php @@ -26,7 +26,7 @@ class ChooseThemePlugin extends Plugin { const PLUGIN_VERSION = '0.1.0'; public function onRouterInitialized(URLMapper $m) { - $m->connect('main/choosethemesettings', array('action' => 'choosethemesettings')); + $m->connect('main/choosethemesettings', ['action' => 'choosethemesettings']); } public function onPluginVersion(array &$versions) { diff --git a/plugins/ClientSideShorten/ClientSideShortenPlugin.php b/plugins/ClientSideShorten/ClientSideShortenPlugin.php index d341f0258f..167dff56ee 100644 --- a/plugins/ClientSideShorten/ClientSideShortenPlugin.php +++ b/plugins/ClientSideShorten/ClientSideShortenPlugin.php @@ -51,7 +51,8 @@ class ClientSideShortenPlugin extends Plugin function onRouterInitialized($m) { if (common_logged_in()) { - $m->connect('plugins/ClientSideShorten/shorten', array('action'=>'shorten')); + $m->connect('plugins/ClientSideShorten/shorten', + ['action'=>'shorten']); } } diff --git a/plugins/DirectMessage/DirectMessagePlugin.php b/plugins/DirectMessage/DirectMessagePlugin.php index 2b500ec807..57492189df 100644 --- a/plugins/DirectMessage/DirectMessagePlugin.php +++ b/plugins/DirectMessage/DirectMessagePlugin.php @@ -36,23 +36,25 @@ class DirectMessagePlugin extends Plugin public function onRouterInitialized(URLMapper $m) { // web front-end actions - $m->connect('message/new', array('action' => 'newmessage')); - $m->connect('message/new?to=:to', array('action' => 'newmessage'), array('to' => Nickname::DISPLAY_FMT)); + $m->connect('message/new', ['action' => 'newmessage']); + $m->connect('message/new?to=:to', + ['action' => 'newmessage'], + ['to' => Nickname::DISPLAY_FMT]); $m->connect('message/:message', - array('action' => 'showmessage'), - array('message' => '[0-9]+')); + ['action' => 'showmessage'], + ['message' => '[0-9]+']); // direct messages $m->connect('api/direct_messages.:format', - array('action' => 'ApiDirectMessage', - 'format' => '(xml|json|rss|atom)')); + ['action' => 'ApiDirectMessage'], + ['format' => '(xml|json|rss|atom)']); $m->connect('api/direct_messages/sent.:format', - array('action' => 'ApiDirectMessage', - 'format' => '(xml|json|rss|atom)', - 'sent' => true)); + ['action' => 'ApiDirectMessage', + 'sent' => true], + ['format' => '(xml|json|rss|atom)']); $m->connect('api/direct_messages/new.:format', - array('action' => 'ApiDirectMessageNew', - 'format' => '(xml|json)')); + ['action' => 'ApiDirectMessageNew'], + ['format' => '(xml|json)']); return true; } diff --git a/plugins/Directory/DirectoryPlugin.php b/plugins/Directory/DirectoryPlugin.php index 1d00a2cdb8..3c8d1e5910 100644 --- a/plugins/Directory/DirectoryPlugin.php +++ b/plugins/Directory/DirectoryPlugin.php @@ -81,62 +81,42 @@ class DirectoryPlugin extends Plugin public function onRouterInitialized(URLMapper $m) { - $m->connect( - 'directory/users/:filter/sort_by/:sort/reverse/:reverse', - array('action' => 'userdirectory'), - array('filter' => '[0-9a-zA-Z]|(0-9)'), - array('sort' => '[a-z]+'), - array('reverse' => '[0-9]') - ); - - $m->connect( - 'directory/users/:filter/sort_by/:sort', - array('action' => 'userdirectory'), - array('filter' => '[0-9a-zA-Z]|(0-9)'), - array('sort' => '[a-z]+') - ); - - - $m->connect( - 'directory/users/:filter', - array('action' => 'userdirectory'), - array('filter' => '[0-9a-zA-Z]|(0-9)') - ); + $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', - array('action' => 'userdirectory'), - array('sort' => '[a-z]+'), - array('reverse' => '[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', - array('action' => 'userdirectory'), - array('sort' => '[a-z]+') - ); + $m->connect('directory/users/sort_by/:sort', + ['action' => 'userdirectory'], + ['sort' => '[a-z]+']); - $m->connect( - 'directory/users', - array('action' => 'userdirectory') - ); + $m->connect('directory/users', + ['action' => 'userdirectory']); - $m->connect( - 'groups/:filter', - array('action' => 'groupdirectory'), - array('filter' => '[0-9a-zA-Z]|(0-9)') - ); + $m->connect('groups/:filter', + ['action' => 'groupdirectory'], + ['filter' => '[0-9a-zA-Z]|(0-9)']); - $m->connect( - 'groups', - array('action' => 'groupdirectory') - ); - - $m->connect( - 'groups/all', - array('action' => 'groupdirectory') - ); + $m->connect('groups', + ['action' => 'groupdirectory']); + $m->connect('groups/all', + ['action' => 'groupdirectory']); return true; } diff --git a/plugins/DomainStatusNetwork/DomainStatusNetworkPlugin.php b/plugins/DomainStatusNetwork/DomainStatusNetworkPlugin.php index 28b29d1f9e..64ea4baec0 100644 --- a/plugins/DomainStatusNetwork/DomainStatusNetworkPlugin.php +++ b/plugins/DomainStatusNetwork/DomainStatusNetworkPlugin.php @@ -131,7 +131,7 @@ class DomainStatusNetworkPlugin extends Plugin if (common_config('globalapi', 'enabled')) { foreach (array('register', 'login', 'recover') as $method) { $m->connect('api/statusnet/global/'.$method, - array('action' => 'global'.$method)); + ['action' => 'global'.$method]); } } return true; diff --git a/plugins/Event/EventPlugin.php b/plugins/Event/EventPlugin.php index 58f7fabbe9..834f29cdf8 100644 --- a/plugins/Event/EventPlugin.php +++ b/plugins/Event/EventPlugin.php @@ -78,24 +78,24 @@ class EventPlugin extends ActivityVerbHandlerPlugin public function onRouterInitialized(URLMapper $m) { $m->connect('main/event/new', - array('action' => 'newevent')); + ['action' => 'newevent']); $m->connect('main/event/rsvp', - array('action' => 'rsvp')); + ['action' => 'rsvp']); $m->connect('main/event/rsvp/:rsvp', // this will probably change to include event notice id - array('action' => 'rsvp'), - array('rsvp' => '[a-z]+')); + ['action' => 'rsvp'], + ['rsvp' => '[a-z]+']); $m->connect('event/:id', - array('action' => 'showevent'), - array('id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}')); + ['action' => 'showevent'], + ['id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}']); $m->connect('rsvp/:id', - array('action' => 'showrsvp'), - array('id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}')); + ['action' => 'showrsvp'], + ['id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}']); $m->connect('main/event/updatetimes', - array('action' => 'timelist')); + ['action' => 'timelist']); $m->connect(':nickname/events', - array('action' => 'events'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'events'], + ['nickname' => Nickname::DISPLAY_FMT]); return true; } diff --git a/plugins/Favorite/FavoritePlugin.php b/plugins/Favorite/FavoritePlugin.php index 01fe534724..415671cce1 100644 --- a/plugins/Favorite/FavoritePlugin.php +++ b/plugins/Favorite/FavoritePlugin.php @@ -114,72 +114,77 @@ class FavoritePlugin extends ActivityVerbHandlerPlugin public function onRouterInitialized(URLMapper $m) { // Web UI actions - $m->connect('main/favor', array('action' => 'favor')); - $m->connect('main/disfavor', array('action' => 'disfavor')); + $m->connect('main/favor', + ['action' => 'favor']); + $m->connect('main/disfavor', + ['action' => 'disfavor']); if (common_config('singleuser', 'enabled')) { $nickname = User::singleUserNickname(); $m->connect('favorites', - array('action' => 'showfavorites', - 'nickname' => $nickname)); + ['action' => 'showfavorites', + 'nickname' => $nickname]); $m->connect('favoritesrss', - array('action' => 'favoritesrss', - 'nickname' => $nickname)); + ['action' => 'favoritesrss', + 'nickname' => $nickname]); } else { - $m->connect('favoritedrss', array('action' => 'favoritedrss')); - $m->connect('favorited/', array('action' => 'favorited')); - $m->connect('favorited', array('action' => 'favorited')); + $m->connect('favoritedrss', + ['action' => 'favoritedrss']); + $m->connect('favorited/', + ['action' => 'favorited']); + $m->connect('favorited', + ['action' => 'favorited']); $m->connect(':nickname/favorites', - array('action' => 'showfavorites'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'showfavorites'], + ['nickname' => Nickname::DISPLAY_FMT]); $m->connect(':nickname/favorites/rss', - array('action' => 'favoritesrss'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'favoritesrss'], + ['nickname' => Nickname::DISPLAY_FMT]); } // Favorites for API $m->connect('api/favorites/create.:format', - array('action' => 'ApiFavoriteCreate'), - array('format' => '(xml|json)')); + ['action' => 'ApiFavoriteCreate'], + ['format' => '(xml|json)']); $m->connect('api/favorites/destroy.:format', - array('action' => 'ApiFavoriteDestroy'), - array('format' => '(xml|json)')); + ['action' => 'ApiFavoriteDestroy'], + ['format' => '(xml|json)']); $m->connect('api/favorites/list.:format', - array('action' => 'ApiTimelineFavorites'), - array('format' => '(xml|json|rss|atom|as)')); + ['action' => 'ApiTimelineFavorites'], + ['format' => '(xml|json|rss|atom|as)']); $m->connect('api/favorites/:id.:format', - array('action' => 'ApiTimelineFavorites'), - array('id' => Nickname::INPUT_FMT, - 'format' => '(xml|json|rss|atom|as)')); + ['action' => 'ApiTimelineFavorites'], + ['id' => Nickname::INPUT_FMT, + 'format' => '(xml|json|rss|atom|as)']); $m->connect('api/favorites.:format', - array('action' => 'ApiTimelineFavorites'), - array('format' => '(xml|json|rss|atom|as)')); + ['action' => 'ApiTimelineFavorites'], + ['format' => '(xml|json|rss|atom|as)']); $m->connect('api/favorites/create/:id.:format', - array('action' => 'ApiFavoriteCreate'), - array('id' => '[0-9]+', - 'format' => '(xml|json)')); + ['action' => 'ApiFavoriteCreate'], + ['id' => '[0-9]+', + 'format' => '(xml|json)']); $m->connect('api/favorites/destroy/:id.:format', - array('action' => 'ApiFavoriteDestroy'), - array('id' => '[0-9]+', - 'format' => '(xml|json)')); + ['action' => 'ApiFavoriteDestroy'], + ['id' => '[0-9]+', + 'format' => '(xml|json)']); // AtomPub API $m->connect('api/statusnet/app/favorites/:profile/:notice.atom', - array('action' => 'AtomPubShowFavorite'), - array('profile' => '[0-9]+', - 'notice' => '[0-9]+')); + ['action' => 'AtomPubShowFavorite'], + ['profile' => '[0-9]+', + 'notice' => '[0-9]+']); $m->connect('api/statusnet/app/favorites/:profile.atom', - array('action' => 'AtomPubFavoriteFeed'), - array('profile' => '[0-9]+')); + ['action' => 'AtomPubFavoriteFeed'], + ['profile' => '[0-9]+']); // Required for qvitter API $m->connect('api/statuses/favs/:id.:format', - array('action' => 'ApiStatusesFavs'), - array('id' => '[0-9]+', - 'format' => '(xml|json)')); + ['action' => 'ApiStatusesFavs'], + ['id' => '[0-9]+', + 'format' => '(xml|json)']); } // FIXME: Set this to abstract public in lib/activityhandlerplugin.php ddwhen all plugins have migrated! diff --git a/plugins/GNUsocialPhoto/GNUsocialPhotoPlugin.php b/plugins/GNUsocialPhoto/GNUsocialPhotoPlugin.php index 44a6e3fe34..ae2e136664 100644 --- a/plugins/GNUsocialPhoto/GNUsocialPhotoPlugin.php +++ b/plugins/GNUsocialPhoto/GNUsocialPhotoPlugin.php @@ -46,8 +46,8 @@ class GNUsocialPhotoPlugin extends MicroAppPlugin function onRouterInitialized($m) { - $m->connect('main/photo/new', array('action' => 'newphoto')); - $m->connect('main/photo/:id', array('action' => 'showphoto')); + $m->connect('main/photo/new', ['action' => 'newphoto']); + $m->connect('main/photo/:id', ['action' => 'showphoto']); return true; } diff --git a/plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php b/plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php index 36956e5b9b..fce0fb4f1b 100644 --- a/plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php +++ b/plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php @@ -46,11 +46,11 @@ class GNUsocialPhotosPlugin extends Plugin function onRouterInitialized($m) { - $m->connect(':nickname/photos', array('action' => 'photos')); - $m->connect(':nickname/photos/:albumid', array('action' => 'photos')); - $m->connect('main/uploadphoto', array('action' => 'photoupload')); - $m->connect('photo/:photoid', array('action' => 'photo')); - $m->connect('editphoto/:photoid', array('action' => 'editphoto')); + $m->connect(':nickname/photos', ['action' => 'photos']); + $m->connect(':nickname/photos/:albumid', ['action' => 'photos']); + $m->connect('main/uploadphoto', ['action' => 'photoupload']); + $m->connect('photo/:photoid', ['action' => 'photo']); + $m->connect('editphoto/:photoid', ['action' => 'editphoto']); return true; } diff --git a/plugins/GNUsocialProfileExtensions/GNUsocialProfileExtensionsPlugin.php b/plugins/GNUsocialProfileExtensions/GNUsocialProfileExtensionsPlugin.php index c4628c4ecc..66014f0c6d 100644 --- a/plugins/GNUsocialProfileExtensions/GNUsocialProfileExtensionsPlugin.php +++ b/plugins/GNUsocialProfileExtensions/GNUsocialProfileExtensionsPlugin.php @@ -45,9 +45,9 @@ class GNUsocialProfileExtensionsPlugin extends Plugin function onRouterInitialized($m) { - $m->connect(':nickname/bio', array('action' => 'bio')); - $m->connect('admin/profilefields', array('action' => 'profilefieldsAdminPanel')); - $m->connect('notice/respond', array('action' => 'newresponse')); + $m->connect(':nickname/bio', ['action' => 'bio']); + $m->connect('admin/profilefields', ['action' => 'profilefieldsAdminPanel']); + $m->connect('notice/respond', ['action' => 'newresponse']); return true; } diff --git a/plugins/GNUsocialVideo/GNUsocialVideoPlugin.php b/plugins/GNUsocialVideo/GNUsocialVideoPlugin.php index 3310712ba7..91a7c980aa 100644 --- a/plugins/GNUsocialVideo/GNUsocialVideoPlugin.php +++ b/plugins/GNUsocialVideo/GNUsocialVideoPlugin.php @@ -46,8 +46,8 @@ class GNUsocialVideoPlugin extends MicroAppPlugin function onRouterInitialized($m) { - $m->connect('main/postvideo', array('action' => 'postvideo')); - $m->connect('showvideo/:id', array('action' => 'showvideo')); + $m->connect('main/postvideo', ['action' => 'postvideo']); + $m->connect('showvideo/:id', ['action' => 'showvideo']); return true; } diff --git a/plugins/GroupFavorited/GroupFavoritedPlugin.php b/plugins/GroupFavorited/GroupFavoritedPlugin.php index 350da9400c..3dd9ac1323 100644 --- a/plugins/GroupFavorited/GroupFavoritedPlugin.php +++ b/plugins/GroupFavorited/GroupFavoritedPlugin.php @@ -37,8 +37,8 @@ class GroupFavoritedPlugin extends Plugin function onRouterInitialized(URLMapper $m) { $m->connect('group/:nickname/favorited', - array('action' => 'groupfavorited'), - array('nickname' => '[a-zA-Z0-9]+')); + ['action' => 'groupfavorited'], + ['nickname' => '[a-zA-Z0-9]+']); return true; } diff --git a/plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php b/plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php index 7aabbe59b1..e3148e0f1a 100644 --- a/plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php +++ b/plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php @@ -79,16 +79,16 @@ class GroupPrivateMessagePlugin extends Plugin public function onRouterInitialized(URLMapper $m) { $m->connect('group/:nickname/inbox', - array('action' => 'groupinbox'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'groupinbox'], + ['nickname' => Nickname::DISPLAY_FMT]); $m->connect('group/message/:id', - array('action' => 'showgroupmessage'), - array('id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}')); + ['action' => 'showgroupmessage'], + ['id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}']); $m->connect('group/:nickname/message/new', - array('action' => 'newgroupmessage'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'newgroupmessage'], + ['nickname' => Nickname::DISPLAY_FMT]); return true; } diff --git a/plugins/Linkback/LinkbackPlugin.php b/plugins/Linkback/LinkbackPlugin.php index bb0f1370da..212aaca55f 100644 --- a/plugins/Linkback/LinkbackPlugin.php +++ b/plugins/Linkback/LinkbackPlugin.php @@ -338,8 +338,10 @@ class LinkbackPlugin extends Plugin public function onRouterInitialized(URLMapper $m) { - $m->connect('main/linkback/webmention', array('action' => 'webmention')); - $m->connect('main/linkback/pingback', array('action' => 'pingback')); + $m->connect('main/linkback/webmention', + ['action' => 'webmention']); + $m->connect('main/linkback/pingback', + ['action' => 'pingback']); } public function onStartShowHTML($action) diff --git a/plugins/Mapstraction/MapstractionPlugin.php b/plugins/Mapstraction/MapstractionPlugin.php index 9c7b1190af..80b3900997 100644 --- a/plugins/Mapstraction/MapstractionPlugin.php +++ b/plugins/Mapstraction/MapstractionPlugin.php @@ -66,11 +66,11 @@ class MapstractionPlugin extends Plugin function onRouterInitialized($m) { $m->connect(':nickname/all/map', - array('action' => 'allmap'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'allmap'], + ['nickname' => Nickname::DISPLAY_FMT]); $m->connect(':nickname/map', - array('action' => 'usermap'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'usermap'], + ['nickname' => Nickname::DISPLAY_FMT]); return true; } diff --git a/plugins/Nodeinfo/NodeinfoPlugin.php b/plugins/Nodeinfo/NodeinfoPlugin.php index 361b020158..3417603c99 100644 --- a/plugins/Nodeinfo/NodeinfoPlugin.php +++ b/plugins/Nodeinfo/NodeinfoPlugin.php @@ -10,19 +10,11 @@ class NodeinfoPlugin extends Plugin public function onRouterInitialized($m) { - $m->connect( - '.well-known/nodeinfo', - array( - 'action' => 'nodeinfojrd' - ) - ); - - $m->connect( - 'main/nodeinfo/2.0', - array( - 'action' => 'nodeinfo_2_0' - ) - ); + $m->connect('.well-known/nodeinfo', + ['action' => 'nodeinfojrd']); + + $m->connect('main/nodeinfo/2.0', + ['action' => 'nodeinfo_2_0']); return true; } diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index 615a01bd7e..3fdc11451f 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -42,44 +42,48 @@ class OStatusPlugin extends Plugin { // Discovery actions $m->connect('main/ostatustag', - array('action' => 'ostatustag')); + ['action' => 'ostatustag']); $m->connect('main/ostatustag?nickname=:nickname', - array('action' => 'ostatustag'), array('nickname' => '[A-Za-z0-9_-]+')); + ['action' => 'ostatustag'], + ['nickname' => '[A-Za-z0-9_-]+']); $m->connect('main/ostatus/nickname/:nickname', - array('action' => 'ostatusinit'), array('nickname' => '[A-Za-z0-9_-]+')); + ['action' => 'ostatusinit'], + ['nickname' => '[A-Za-z0-9_-]+']); $m->connect('main/ostatus/group/:group', - array('action' => 'ostatusinit'), array('group' => '[A-Za-z0-9_-]+')); + ['action' => 'ostatusinit'], + ['group' => '[A-Za-z0-9_-]+']); $m->connect('main/ostatus/peopletag/:peopletag/tagger/:tagger', - array('action' => 'ostatusinit'), array('tagger' => '[A-Za-z0-9_-]+', - 'peopletag' => '[A-Za-z0-9_-]+')); + ['action' => 'ostatusinit'], + ['tagger' => '[A-Za-z0-9_-]+', + 'peopletag' => '[A-Za-z0-9_-]+']); $m->connect('main/ostatus', - array('action' => 'ostatusinit')); + ['action' => 'ostatusinit']); // Remote subscription actions $m->connect('main/ostatussub', - array('action' => 'ostatussub')); + ['action' => 'ostatussub']); $m->connect('main/ostatusgroup', - array('action' => 'ostatusgroup')); + ['action' => 'ostatusgroup']); $m->connect('main/ostatuspeopletag', - array('action' => 'ostatuspeopletag')); + ['action' => 'ostatuspeopletag']); // WebSub actions - $m->connect('main/push/hub', array('action' => 'pushhub')); + $m->connect('main/push/hub', ['action' => 'pushhub']); $m->connect('main/push/callback/:feed', - array('action' => 'pushcallback'), - array('feed' => '[0-9]+')); + ['action' => 'pushcallback'], + ['feed' => '[0-9]+']); // Salmon endpoint $m->connect('main/salmon/user/:id', - array('action' => 'usersalmon'), - array('id' => '[0-9]+')); + ['action' => 'usersalmon'], + ['id' => '[0-9]+']); $m->connect('main/salmon/group/:id', - array('action' => 'groupsalmon'), - array('id' => '[0-9]+')); + ['action' => 'groupsalmon'], + ['id' => '[0-9]+']); $m->connect('main/salmon/peopletag/:id', - array('action' => 'peopletagsalmon'), - array('id' => '[0-9]+')); + ['action' => 'peopletagsalmon'], + ['id' => '[0-9]+']); return true; } diff --git a/plugins/Oembed/OembedPlugin.php b/plugins/Oembed/OembedPlugin.php index fb3fe43fc5..77674c5677 100644 --- a/plugins/Oembed/OembedPlugin.php +++ b/plugins/Oembed/OembedPlugin.php @@ -84,7 +84,7 @@ class OembedPlugin extends Plugin */ public function onRouterInitialized(URLMapper $m) { - $m->connect('main/oembed', array('action' => 'oembed')); + $m->connect('main/oembed', ['action' => 'oembed']); } /** diff --git a/plugins/OfflineBackup/OfflineBackupPlugin.php b/plugins/OfflineBackup/OfflineBackupPlugin.php index ae751b9e60..93d4e11dd2 100644 --- a/plugins/OfflineBackup/OfflineBackupPlugin.php +++ b/plugins/OfflineBackup/OfflineBackupPlugin.php @@ -54,7 +54,7 @@ class OfflineBackupPlugin extends Plugin function onRouterInitialized($m) { $m->connect('main/backupaccount', - array('action' => 'offlinebackup')); + ['action' => 'offlinebackup']); return true; } diff --git a/plugins/OpenX/OpenXPlugin.php b/plugins/OpenX/OpenXPlugin.php index 24516d8a12..b857a7440b 100644 --- a/plugins/OpenX/OpenXPlugin.php +++ b/plugins/OpenX/OpenXPlugin.php @@ -178,7 +178,7 @@ ENDOFSCRIPT; function onRouterInitialized($m) { $m->connect('panel/openx', - array('action' => 'openxadminpanel')); + ['action' => 'openxadminpanel']); return true; } diff --git a/plugins/OpportunisticQM/OpportunisticQMPlugin.php b/plugins/OpportunisticQM/OpportunisticQMPlugin.php index 4dfa32ff4a..c8d5a96770 100644 --- a/plugins/OpportunisticQM/OpportunisticQMPlugin.php +++ b/plugins/OpportunisticQM/OpportunisticQMPlugin.php @@ -10,7 +10,8 @@ class OpportunisticQMPlugin extends Plugin { public function onRouterInitialized($m) { - $m->connect('main/runqueue', array('action' => 'runqueue')); + $m->connect('main/runqueue', + ['action' => 'runqueue']); } /** diff --git a/plugins/Poll/PollPlugin.php b/plugins/Poll/PollPlugin.php index 47a30823e1..45a7086f0e 100644 --- a/plugins/Poll/PollPlugin.php +++ b/plugins/Poll/PollPlugin.php @@ -92,33 +92,23 @@ class PollPlugin extends MicroAppPlugin */ public function onRouterInitialized(URLMapper $m) { - $m->connect( - 'main/poll/new', - array('action' => 'newpoll') - ); + $m->connect('main/poll/new', + ['action' => 'newpoll']); - $m->connect( - 'main/poll/:id', - array('action' => 'showpoll'), - array('id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}') - ); + $m->connect('main/poll/:id', + ['action' => 'showpoll'], + ['id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}']); - $m->connect( - 'main/poll/response/:id', - array('action' => 'showpollresponse'), - array('id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}') - ); + $m->connect('main/poll/response/:id', + ['action' => 'showpollresponse'], + ['id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}']); - $m->connect( - 'main/poll/:id/respond', - array('action' => 'respondpoll'), - array('id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}') - ); + $m->connect('main/poll/:id/respond', + ['action' => 'respondpoll'], + ['id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}']); - $m->connect( - 'settings/poll', - array('action' => 'pollsettings') - ); + $m->connect('settings/poll', + ['action' => 'pollsettings']); return true; } diff --git a/plugins/QnA/QnAPlugin.php b/plugins/QnA/QnAPlugin.php index 7cca3d2c7e..d9dfc9a02b 100644 --- a/plugins/QnA/QnAPlugin.php +++ b/plugins/QnA/QnAPlugin.php @@ -85,42 +85,35 @@ class QnAPlugin extends MicroAppPlugin { $UUIDregex = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'; - $m->connect( - 'main/qna/newquestion', - array('action' => 'qnanewquestion') - ); - $m->connect( - 'answer/qna/closequestion', - array('action' => 'qnaclosequestion') - ); - $m->connect( - 'main/qna/newanswer', - array('action' => 'qnanewanswer') - ); - $m->connect( - 'main/qna/reviseanswer', - array('action' => 'qnareviseanswer') - ); - $m->connect( - 'question/vote/:id', - array('action' => 'qnavote', 'type' => 'question'), - array('id' => $UUIDregex) - ); - $m->connect( - 'question/:id', - array('action' => 'qnashowquestion'), - array('id' => $UUIDregex) - ); - $m->connect( - 'answer/vote/:id', - array('action' => 'qnavote', 'type' => 'answer'), - array('id' => $UUIDregex) - ); - $m->connect( - 'answer/:id', - array('action' => 'qnashowanswer'), - array('id' => $UUIDregex) - ); + $m->connect('main/qna/newquestion', + ['action' => 'qnanewquestion']); + + $m->connect('answer/qna/closequestion', + ['action' => 'qnaclosequestion']); + + $m->connect('main/qna/newanswer', + ['action' => 'qnanewanswer']); + + $m->connect('main/qna/reviseanswer', + ['action' => 'qnareviseanswer']); + + $m->connect('question/vote/:id', + ['action' => 'qnavote', + 'type' => 'question'], + ['id' => $UUIDregex]); + + $m->connect('question/:id', + ['action' => 'qnashowquestion'], + ['id' => $UUIDregex]); + + $m->connect('answer/vote/:id', + ['action' => 'qnavote', + 'type' => 'answer'], + ['id' => $UUIDregex]); + + $m->connect('answer/:id', + ['action' => 'qnashowanswer'], + ['id' => $UUIDregex]); return true; } diff --git a/plugins/RSSCloud/RSSCloudPlugin.php b/plugins/RSSCloud/RSSCloudPlugin.php index 77d60551a3..f99054b26d 100644 --- a/plugins/RSSCloud/RSSCloudPlugin.php +++ b/plugins/RSSCloud/RSSCloudPlugin.php @@ -105,7 +105,7 @@ class RSSCloudPlugin extends Plugin function onRouterInitialized($m) { $m->connect('/main/rsscloud/request_notify', - array('action' => 'RSSCloudRequestNotify')); + ['action' => 'RSSCloudRequestNotify']); // XXX: This is just for end-to-end testing. Uncomment if you need to pretend // to be a cloud hub for some reason. diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php index 8b7767ac15..cb228b2bff 100644 --- a/plugins/Realtime/RealtimePlugin.php +++ b/plugins/Realtime/RealtimePlugin.php @@ -77,11 +77,11 @@ class RealtimePlugin extends Plugin public function onRouterInitialized(URLMapper $m) { $m->connect('main/channel/:channelkey/keepalive', - array('action' => 'keepalivechannel'), - array('channelkey' => '[a-z0-9]{32}')); + ['action' => 'keepalivechannel'], + ['channelkey' => '[a-z0-9]{32}']); $m->connect('main/channel/:channelkey/close', - array('action' => 'closechannel'), - array('channelkey' => '[a-z0-9]{32}')); + ['action' => 'closechannel'], + ['channelkey' => '[a-z0-9]{32}']); return true; } diff --git a/plugins/RegisterThrottle/RegisterThrottlePlugin.php b/plugins/RegisterThrottle/RegisterThrottlePlugin.php index 7d358f19df..3c8eca4286 100644 --- a/plugins/RegisterThrottle/RegisterThrottlePlugin.php +++ b/plugins/RegisterThrottle/RegisterThrottlePlugin.php @@ -94,8 +94,8 @@ class RegisterThrottlePlugin extends Plugin public function onRouterInitialized(URLMapper $m) { $m->connect('main/ipregistrations/:ipaddress', - array('action' => 'ipregistrations'), - array('ipaddress' => '[0-9a-f\.\:]+')); + ['action' => 'ipregistrations'], + ['ipaddress' => '[0-9a-f\.\:]+']); } /** diff --git a/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php b/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php index 3a874fbb40..aa94c349d0 100644 --- a/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php +++ b/plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php @@ -84,8 +84,8 @@ class RequireValidatedEmailPlugin extends Plugin public function onRouterInitialized(URLMapper $m) { - $m->connect('main/confirmfirst/:code', - array('action' => 'confirmfirstemail')); + $m->('main/confirmfirst/:code', + ['action' => 'confirmfirstemail']); return true; } diff --git a/plugins/Sample/SamplePlugin.php b/plugins/Sample/SamplePlugin.php index cd4d25150d..44cb08260c 100644 --- a/plugins/Sample/SamplePlugin.php +++ b/plugins/Sample/SamplePlugin.php @@ -191,7 +191,7 @@ class SamplePlugin extends Plugin public function onRouterInitialized(URLMapper $m) { $m->connect('main/hello', - array('action' => 'hello')); + ['action' => 'hello']); return true; } diff --git a/plugins/SearchSub/SearchSubPlugin.php b/plugins/SearchSub/SearchSubPlugin.php index 96e976c55c..546648eb88 100644 --- a/plugins/SearchSub/SearchSubPlugin.php +++ b/plugins/SearchSub/SearchSubPlugin.php @@ -70,14 +70,14 @@ class SearchSubPlugin extends Plugin public function onRouterInitialized(URLMapper $m) { $m->connect('search/:search/subscribe', - array('action' => 'searchsub'), - array('search' => Router::REGEX_TAG)); + ['action' => 'searchsub'], + ['search' => Router::REGEX_TAG]); $m->connect('search/:search/unsubscribe', - array('action' => 'searchunsub'), - array('search' => Router::REGEX_TAG)); + ['action' => 'searchunsub'], + ['search' => Router::REGEX_TAG]); $m->connect(':nickname/search-subscriptions', - array('action' => 'searchsubs'), - array('nickname' => Nickname::DISPLAY_FMT)); + ['action' => 'searchsubs'], + ['nickname' => Nickname::DISPLAY_FMT]); return true; } diff --git a/plugins/SensitiveContent/SensitiveContentPlugin.php b/plugins/SensitiveContent/SensitiveContentPlugin.php index ce5516923b..25cb7dbf9d 100644 --- a/plugins/SensitiveContent/SensitiveContentPlugin.php +++ b/plugins/SensitiveContent/SensitiveContentPlugin.php @@ -49,7 +49,7 @@ class SensitiveContentPlugin extends Plugin public function onRouterInitialized(URLMapper $m) { $m->connect('settings/sensitivecontent', - array('action' => 'sensitivecontentsettings')); + ['action' => 'sensitivecontentsettings']); } diff --git a/plugins/Share/SharePlugin.php b/plugins/Share/SharePlugin.php index 615cda7893..31bc55038f 100644 --- a/plugins/Share/SharePlugin.php +++ b/plugins/Share/SharePlugin.php @@ -53,30 +53,30 @@ class SharePlugin extends ActivityVerbHandlerPlugin public function onRouterInitialized(URLMapper $m) { // Web UI actions - $m->connect('main/repeat', array('action' => 'repeat')); + $m->connect('main/repeat', ['action' => 'repeat']); // Share for Twitter API ("Retweet") $m->connect('api/statuses/retweeted_by_me.:format', - array('action' => 'ApiTimelineRetweetedByMe', - 'format' => '(xml|json|atom|as)')); + ['action' => 'ApiTimelineRetweetedByMe'], + ['format' => '(xml|json|atom|as)']); $m->connect('api/statuses/retweeted_to_me.:format', - array('action' => 'ApiTimelineRetweetedToMe', - 'format' => '(xml|json|atom|as)')); + ['action' => 'ApiTimelineRetweetedToMe'], + ['format' => '(xml|json|atom|as)']); $m->connect('api/statuses/retweets_of_me.:format', - array('action' => 'ApiTimelineRetweetsOfMe', - 'format' => '(xml|json|atom|as)')); + ['action' => 'ApiTimelineRetweetsOfMe'], + ['format' => '(xml|json|atom|as)']); $m->connect('api/statuses/retweet/:id.:format', - array('action' => 'ApiStatusesRetweet', - 'id' => '[0-9]+', - 'format' => '(xml|json)')); + ['action' => 'ApiStatusesRetweet'], + ['id' => '[0-9]+', + 'format' => '(xml|json)']); $m->connect('api/statuses/retweets/:id.:format', - array('action' => 'ApiStatusesRetweets', - 'id' => '[0-9]+', - 'format' => '(xml|json)')); + ['action' => 'ApiStatusesRetweets'], + ['id' => '[0-9]+', + 'format' => '(xml|json)']); } // FIXME: Set this to abstract public in lib/activityhandlerplugin.php when all plugins have migrated! diff --git a/plugins/Sitemap/SitemapPlugin.php b/plugins/Sitemap/SitemapPlugin.php index c4c34eccc9..059aa40148 100644 --- a/plugins/Sitemap/SitemapPlugin.php +++ b/plugins/Sitemap/SitemapPlugin.php @@ -77,24 +77,24 @@ class SitemapPlugin extends Plugin public function onRouterInitialized(URLMapper $m) { $m->connect('sitemapindex.xml', - array('action' => 'sitemapindex')); + ['action' => 'sitemapindex']); $m->connect('notice-sitemap-:year-:month-:day-:index.xml', - array('action' => 'noticesitemap'), - array('year' => '[0-9]{4}', - 'month' => '[01][0-9]', - 'day' => '[0123][0-9]', - 'index' => '[1-9][0-9]*')); + ['action' => 'noticesitemap'], + ['year' => '[0-9]{4}', + 'month' => '[01][0-9]', + 'day' => '[0123][0-9]', + 'index' => '[1-9][0-9]*']); $m->connect('user-sitemap-:year-:month-:day-:index.xml', - array('action' => 'usersitemap'), - array('year' => '[0-9]{4}', - 'month' => '[01][0-9]', - 'day' => '[0123][0-9]', - 'index' => '[1-9][0-9]*')); + ['action' => 'usersitemap'), + ['year' => '[0-9]{4}', + 'month' => '[01][0-9]', + 'day' => '[0123][0-9]', + 'index' => '[1-9][0-9]*']); $m->connect('panel/sitemap', - array('action' => 'sitemapadminpanel')); + ['action' => 'sitemapadminpanel']); return true; } diff --git a/plugins/SlicedFavorites/SlicedFavoritesPlugin.php b/plugins/SlicedFavorites/SlicedFavoritesPlugin.php index 8048bb1f02..0d1d05351f 100644 --- a/plugins/SlicedFavorites/SlicedFavoritesPlugin.php +++ b/plugins/SlicedFavorites/SlicedFavoritesPlugin.php @@ -60,8 +60,8 @@ class SlicedFavoritesPlugin extends Plugin public function onRouterInitialized(URLMapper $m) { $m->connect('favorited/:slice', - array('action' => 'favoritedslice'), - array('slice' => '[a-zA-Z0-9]+')); + ['action' => 'favoritedslice'], + ['slice' => '[a-zA-Z0-9]+']); return true; } diff --git a/plugins/SubMirror/SubMirrorPlugin.php b/plugins/SubMirror/SubMirrorPlugin.php index b4c1dac519..3bad0911ec 100644 --- a/plugins/SubMirror/SubMirrorPlugin.php +++ b/plugins/SubMirror/SubMirrorPlugin.php @@ -36,14 +36,14 @@ class SubMirrorPlugin extends Plugin public function onRouterInitialized(URLMapper $m) { $m->connect('settings/mirror', - array('action' => 'mirrorsettings')); + ['action' => 'mirrorsettings']); $m->connect('settings/mirror/add/:provider', - array('action' => 'mirrorsettings'), - array('provider' => '[A-Za-z0-9_-]+')); + ['action' => 'mirrorsettings'], + ['provider' => '[A-Za-z0-9_-]+']); $m->connect('settings/mirror/add', - array('action' => 'addmirror')); + ['action' => 'addmirror']); $m->connect('settings/mirror/edit', - array('action' => 'editmirror')); + ['action' => 'editmirror']); return true; } diff --git a/plugins/TagCloud/TagCloudPlugin.php b/plugins/TagCloud/TagCloudPlugin.php index e47d697839..931e29f898 100644 --- a/plugins/TagCloud/TagCloudPlugin.php +++ b/plugins/TagCloud/TagCloudPlugin.php @@ -17,10 +17,10 @@ class TagCloudPlugin extends Plugin { public function onRouterInitialized(URLMapper $m) { - $m->connect('tags/', array('action' => 'publictagcloud')); - $m->connect('tag/', array('action' => 'publictagcloud')); - $m->connect('tags', array('action' => 'publictagcloud')); - $m->connect('tag', array('action' => 'publictagcloud')); + $m->connect('tags/', ['action' => 'publictagcloud']); + $m->connect('tag/', ['action' => 'publictagcloud']); + $m->connect('tags', ['action' => 'publictagcloud']); + $m->connect('tag', ['action' => 'publictagcloud']); } public function onEndPublicGroupNav(Menu $menu) diff --git a/plugins/TagSub/TagSubPlugin.php b/plugins/TagSub/TagSubPlugin.php index 705ad2cc2c..407e13d3db 100644 --- a/plugins/TagSub/TagSubPlugin.php +++ b/plugins/TagSub/TagSubPlugin.php @@ -69,22 +69,18 @@ class TagSubPlugin extends Plugin */ public function onRouterInitialized(URLMapper $m) { - $m->connect( - 'tag/:tag/subscribe', - array('action' => 'tagsub'), - array('tag' => Router::REGEX_TAG) - ); - $m->connect( - 'tag/:tag/unsubscribe', - array('action' => 'tagunsub'), - array('tag' => Router::REGEX_TAG) - ); + $m->connect('tag/:tag/subscribe', + ['action' => 'tagsub'], + ['tag' => Router::REGEX_TAG]); + + $m->connect('tag/:tag/unsubscribe', + ['action' => 'tagunsub'], + ['tag' => Router::REGEX_TAG]); + + $m->connect(':nickname/tag-subscriptions', + ['action' => 'tagsubs'], + ['nickname' => Nickname::DISPLAY_FMT]); - $m->connect( - ':nickname/tag-subscriptions', - array('action' => 'tagsubs'), - array('nickname' => Nickname::DISPLAY_FMT) - ); return true; } diff --git a/plugins/TwitterBridge/TwitterBridgePlugin.php b/plugins/TwitterBridge/TwitterBridgePlugin.php index b67c996e1d..79d705c255 100644 --- a/plugins/TwitterBridge/TwitterBridgePlugin.php +++ b/plugins/TwitterBridge/TwitterBridgePlugin.php @@ -111,23 +111,17 @@ class TwitterBridgePlugin extends Plugin */ public function onRouterInitialized(URLMapper $m) { - $m->connect('panel/twitter', array('action' => 'twitteradminpanel')); + $m->connect('panel/twitter', ['action' => 'twitteradminpanel']); if (self::hasKeys()) { - $m->connect( - 'twitter/authorization', - array('action' => 'twitterauthorization') - ); - $m->connect( - 'settings/twitter', array( - 'action' => 'twittersettings' - ) - ); + $m->connect('twitter/authorization', + ['action' => 'twitterauthorization']); + $m->connect('settings/twitter', + ['action' => 'twittersettings']); + if (common_config('twitter', 'signin')) { - $m->connect( - 'main/twitterlogin', - array('action' => 'twitterlogin') - ); + $m->connect('main/twitterlogin', + ['action' => 'twitterlogin']); } } diff --git a/plugins/UserFlag/UserFlagPlugin.php b/plugins/UserFlag/UserFlagPlugin.php index ed1b281fce..b6464b22de 100644 --- a/plugins/UserFlag/UserFlagPlugin.php +++ b/plugins/UserFlag/UserFlagPlugin.php @@ -75,9 +75,9 @@ class UserFlagPlugin extends Plugin */ public function onRouterInitialized(URLMapper $m) { - $m->connect('main/flag/profile', array('action' => 'flagprofile')); - $m->connect('main/flag/clear', array('action' => 'clearflag')); - $m->connect('panel/profile/flag', array('action' => 'adminprofileflag')); + $m->connect('main/flag/profile', ['action' => 'flagprofile']); + $m->connect('main/flag/clear', ['action' => 'clearflag']); + $m->connect('panel/profile/flag', ['action' => 'adminprofileflag']); return true; } diff --git a/plugins/WebFinger/WebFingerPlugin.php b/plugins/WebFinger/WebFingerPlugin.php index 938fd8446a..32af193f91 100644 --- a/plugins/WebFinger/WebFingerPlugin.php +++ b/plugins/WebFinger/WebFingerPlugin.php @@ -39,16 +39,16 @@ class WebFingerPlugin extends Plugin public function onRouterInitialized(URLMapper $m) { - $m->connect('.well-known/host-meta', array('action' => 'hostmeta')); + $m->connect('.well-known/host-meta', ['action' => 'hostmeta']); $m->connect('.well-known/host-meta.:format', - array('action' => 'hostmeta', - 'format' => '(xml|json)')); + ['action' => 'hostmeta'], + ['format' => '(xml|json)']); // the resource GET parameter can be anywhere, so don't mention it here - $m->connect('.well-known/webfinger', array('action' => 'webfinger')); + $m->connect('.well-known/webfinger', ['action' => 'webfinger']); $m->connect('.well-known/webfinger.:format', - array('action' => 'webfinger', - 'format' => '(xml|json)')); - $m->connect('main/ownerxrd', array('action' => 'ownerxrd')); + ['action' => 'webfinger'], + ['format' => '(xml|json)']); + $m->connect('main/ownerxrd', ['action' => 'ownerxrd']); return true; }