]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
[ROUTES] Allow accept-header specification during router creation
authorbrunoccast <brvnocasteleiro@gmail.com>
Thu, 11 Jul 2019 18:14:03 +0000 (19:14 +0100)
committerDiogo Cordeiro <diogo@fc.up.pt>
Sat, 3 Aug 2019 16:47:16 +0000 (17:47 +0100)
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

48 files changed:
extlib/AcceptHeader.php [new file with mode: 0644]
lib/router.php
lib/urlmapper.php
plugins/AccountManager/AccountManagerPlugin.php
plugins/ActivitySpam/ActivitySpamPlugin.php
plugins/Autocomplete/AutocompletePlugin.php
plugins/BitlyUrl/BitlyUrlPlugin.php
plugins/Blacklist/BlacklistPlugin.php
plugins/Bookmark/BookmarkPlugin.php
plugins/ChooseTheme/ChooseThemePlugin.php
plugins/ClientSideShorten/ClientSideShortenPlugin.php
plugins/DirectMessage/DirectMessagePlugin.php
plugins/Directory/DirectoryPlugin.php
plugins/DomainStatusNetwork/DomainStatusNetworkPlugin.php
plugins/Event/EventPlugin.php
plugins/Favorite/FavoritePlugin.php
plugins/GNUsocialPhoto/GNUsocialPhotoPlugin.php
plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php
plugins/GNUsocialProfileExtensions/GNUsocialProfileExtensionsPlugin.php
plugins/GNUsocialVideo/GNUsocialVideoPlugin.php
plugins/GroupFavorited/GroupFavoritedPlugin.php
plugins/GroupPrivateMessage/GroupPrivateMessagePlugin.php
plugins/Linkback/LinkbackPlugin.php
plugins/Mapstraction/MapstractionPlugin.php
plugins/Nodeinfo/NodeinfoPlugin.php
plugins/OStatus/OStatusPlugin.php
plugins/Oembed/OembedPlugin.php
plugins/OfflineBackup/OfflineBackupPlugin.php
plugins/OpenX/OpenXPlugin.php
plugins/OpportunisticQM/OpportunisticQMPlugin.php
plugins/Poll/PollPlugin.php
plugins/QnA/QnAPlugin.php
plugins/RSSCloud/RSSCloudPlugin.php
plugins/Realtime/RealtimePlugin.php
plugins/RegisterThrottle/RegisterThrottlePlugin.php
plugins/RequireValidatedEmail/RequireValidatedEmailPlugin.php
plugins/Sample/SamplePlugin.php
plugins/SearchSub/SearchSubPlugin.php
plugins/SensitiveContent/SensitiveContentPlugin.php
plugins/Share/SharePlugin.php
plugins/Sitemap/SitemapPlugin.php
plugins/SlicedFavorites/SlicedFavoritesPlugin.php
plugins/SubMirror/SubMirrorPlugin.php
plugins/TagCloud/TagCloudPlugin.php
plugins/TagSub/TagSubPlugin.php
plugins/TwitterBridge/TwitterBridgePlugin.php
plugins/UserFlag/UserFlagPlugin.php
plugins/WebFinger/WebFingerPlugin.php

diff --git a/extlib/AcceptHeader.php b/extlib/AcceptHeader.php
new file mode 100644 (file)
index 0000000..e146ec8
--- /dev/null
@@ -0,0 +1,116 @@
+<?php
+/**
+ * Note : Code is released under the GNU LGPL
+ *
+ * Please do not change the header of this file
+ *
+ * This library is free software; you can redistribute it and/or modify it under the terms of the GNU
+ * Lesser General Public License as published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU Lesser General Public License for more details.
+ */
+
+/**
+ * The AcceptHeader page will parse and sort the different
+ * allowed types for the content negociations
+ *
+ * @author Pierrick Charron <pierrick@webstart.fr>
+ */
+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;
+        }
+    }
+}
index d6f63ab0265acbd5c50b5b16be8c94e329467747..09dc43e6485a5f74748ce855784fad25ba304422 100644 (file)
@@ -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;
index 735a330ccc23ecbbfedb59d14a97a172e2cfb0d3..01e4e6fa6c37f9026967a2f91cf7920200954068 100644 (file)
@@ -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 <evan@status.net>
+     * @author Bruno Casteleiro <brunoccast@fc.up.pt>
+     * @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 <diogo@fc.up.pt>
+     * @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;
     }
 }
 
index 1aea7f72e48e02876826a7da09dc154e77a91fc5..1b6d57e46c8868d048868a90607f2ae39ff02de9 100644 (file)
@@ -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;
     }
 
index 7c9287437d80959e1a6043552390d17f4fce3696..85f356fd0ced34749e64b4b700021e231a82bb2a 100644 (file)
@@ -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;
     }
 
index 9f6ef401cfb0696d403a58d6acefcb8b87ccbbac..1a9252d5a5b05d75be3a89aaea8782bacf026a73 100644 (file)
@@ -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)
index fd9a24b2ca8908fc3936ffb4510f989d632e611b..3bf0399dfba6c7f38c3d40b2d54b3fa37b9c42fb 100644 (file)
@@ -169,7 +169,7 @@ class BitlyUrlPlugin extends UrlShortenerPlugin
     public function onRouterInitialized(URLMapper $m)
     {
         $m->connect('panel/bitly',
-                    array('action' => 'bitlyadminpanel'));
+                    ['action' => 'bitlyadminpanel']);
         return true;
     }
 
index 6d4ded70c45aeb5df0c72353c501dc5333703cf2..ca76c3e96deae820ec1bee2e95c6398bdc39112f 100644 (file)
@@ -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;
     }
 
index 98e9a3881cb94d32cdc9b6328c9d26fa5339923a..771a46c1ccfa296453e0ec7d5e865c8302abe807 100644 (file)
@@ -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;
     }
index fe7ba52e861022613f64f5113f6f799a7fb008b1..bcfd5ba8a75ad70a75786b6885ab579b890a7ecd 100644 (file)
@@ -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) {
index d341f0258f1aeed5e054e47b05e09131ab00fbe6..167dff56ee9e37f37863ff125d8ebce9735447ac 100644 (file)
@@ -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']);
         }
     }
 
index 2b500ec80734d1b80c25cfd0c6158cb03d3d40e9..57492189dfc8a19cd2c589f1196a1b6f05e138a0 100644 (file)
@@ -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;
     }
index 1d00a2cdb8aba39627adae32f3059c4573419584..3c8d1e5910c28689ef464b04babf15db55fa88e7 100644 (file)
@@ -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;
     }
index 28b29d1f9ee2563c779148d8f6fa779cf032915d..64ea4baec0bd5fd4200dfd5a17905bbb2cc61d14 100644 (file)
@@ -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;
index 58f7fabbe90d5380dcd3326140939d0339643c3f..834f29cdf81705ea3e6a7e289799fd16e7485a7f 100644 (file)
@@ -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;
     }
 
index 01fe534724eb5c7e286a90b2d6b6fdded6c14662..415671cce16bd5f55d5703f1fbf35c75efa7f0ab 100644 (file)
@@ -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!
index 44a6e3fe346ebc895e1fa469ba20d7a11058bd7c..ae2e1366641a623f4b7aec2a3d86ec8d8be18f5a 100644 (file)
@@ -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;
     }
 
index 36956e5b9b3b750a90f15c4aacb691b3826c4526..fce0fb4f1bb2d2159d7582f26cbf0b4a12e5f08b 100644 (file)
@@ -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;
     }
 
index c4628c4ecc844041e931b71b3719782f67c1ff74..66014f0c6d77dbe7921de8453442cd1d21d2587e 100644 (file)
@@ -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;
     }
 
index 3310712ba76da6b470a6ea6383fd3eb7212044d2..91a7c980aacc24da74f49f1285245fbdb22a513a 100644 (file)
@@ -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;
     }
 
index 350da9400c6b9036540eec7b332b4b28210cf565..3dd9ac132328e2fc3480f25a88f782a9da14d163 100644 (file)
@@ -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;
     }
index 7aabbe59b16555a77a6ca38ab67f087c02da8409..e3148e0f1a1cdffdd5eea4db7650f1dba28de9a3 100644 (file)
@@ -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;
     }
index bb0f1370da54560bb99d1f0f1a718b0789e00c79..212aaca55f6eafad916b7a4ef227ae3f9d4c9ea5 100644 (file)
@@ -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)
index 9c7b1190afa8dbada2fa6fe49836a8319b3bd8b3..80b3900997dda81ec93036381e77481ec973deb5 100644 (file)
@@ -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;
     }
 
index 361b020158cf5543d2ce25ba70dcb90b79970f16..3417603c996aa0b796eadcb71a541ca00e479344 100644 (file)
@@ -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;
     }
index 615a01bd7e9ea196505a5811d5f2a54824486ce7..3fdc11451f829fa4becde68deb223cdbabfca6d9 100644 (file)
@@ -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;
     }
 
index fb3fe43fc5b0250b9ba4ae0f0731d3314201a148..77674c567788d0b08e0e26e1918cf94f75f64fbf 100644 (file)
@@ -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']);
     }
 
     /**
index ae751b9e601d4cd3d09ebfe6b26cade66f1da070..93d4e11dd2d7b41bdabd3ea8b04e03ce35e31a46 100644 (file)
@@ -54,7 +54,7 @@ class OfflineBackupPlugin extends Plugin
     function onRouterInitialized($m)
     {
         $m->connect('main/backupaccount',
-                    array('action' => 'offlinebackup'));
+                    ['action' => 'offlinebackup']);
         return true;
     }
 
index 24516d8a124d2d8b4152f13856e109516eade140..b857a7440bd38263a20078c84519f1c4cdc4049c 100644 (file)
@@ -178,7 +178,7 @@ ENDOFSCRIPT;
     function onRouterInitialized($m)
     {
         $m->connect('panel/openx',
-                    array('action' => 'openxadminpanel'));
+                    ['action' => 'openxadminpanel']);
 
         return true;
     }
index 4dfa32ff4a7fd18efcd222ede1d4c1ddb9c932a0..c8d5a96770c3bc283627c46d3baf9fa18db86118 100644 (file)
@@ -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']);
     }
 
     /**
index 47a30823e1dd6410f009f823a1e9ecf009466dfd..45a7086f0e1225f381b7268a5092df10988db6e9 100644 (file)
@@ -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;
     }
index 7cca3d2c7ef8a7796500877a03c7a94a3050dfe2..d9dfc9a02bf4616b2d9dffa886b98fddf3593c42 100644 (file)
@@ -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;
     }
index 77d60551a3f1ca53d9fcde8e6499fc6b006d24c1..f99054b26d081dffde14e3c6c440712979539d57 100644 (file)
@@ -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.
index 8b7767ac15001deea27ded6fb2dd421b471aee01..cb228b2bff88605b541299faaf022c580cfb1d0a 100644 (file)
@@ -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;
     }
 
index 7d358f19dfc2aa4209fd7b9f840fdd69f2eb9c64..3c8eca4286fbf45cd64255dd02f518f2a3be6881 100644 (file)
@@ -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\.\:]+']);
     }
 
     /**
index 3a874fbb40493a4c6f8e661dfa7723ade006760c..aa94c349d0054526e4249aaae87b3c8ed5521912 100644 (file)
@@ -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;
     }
 
index cd4d25150df66c37103c6c9278c8abdcf91f5011..44cb08260c2da2bfd8dd92a555f2debda05abef8 100644 (file)
@@ -191,7 +191,7 @@ class SamplePlugin extends Plugin
     public function onRouterInitialized(URLMapper $m)
     {
         $m->connect('main/hello',
-                    array('action' => 'hello'));
+                    ['action' => 'hello']);
         return true;
     }
 
index 96e976c55c016884d8daf9b75ff0144a21c9e015..546648eb8835fd76a877a3cb54c478eba3339138 100644 (file)
@@ -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;
     }
 
index ce5516923bddb278a8519fbea975294d8e857341..25cb7dbf9d829d2497d79cc03f7249411b926c59 100644 (file)
@@ -49,7 +49,7 @@ class SensitiveContentPlugin extends Plugin
        public function onRouterInitialized(URLMapper $m)
        {
                $m->connect('settings/sensitivecontent',
-                       array('action' => 'sensitivecontentsettings'));
+                    ['action' => 'sensitivecontentsettings']);
        }
 
 
index 615cda7893802a4321ca2f65aaf6a616c4c31248..31bc55038f7165351d287af060e089f359e27791 100644 (file)
@@ -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!
index c4c34eccc99c565babf034b047c83b1caf866595..059aa401489c978c11d75e9fc8b83588a8140089 100644 (file)
@@ -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;
     }
index 8048bb1f0209e2a7bfb60e037ce2777c60041c7c..0d1d05351f1816906748666f233420eefd78302c 100644 (file)
@@ -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;
     }
index b4c1dac51960c859d88d35ceaeab08391214843f..3bad0911ecb31cc1f8ea94e453e02a2c26ec5f9c 100644 (file)
@@ -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;
     }
 
index e47d697839383e16c69d15f156ff23412f6b5a28..931e29f898df1444aca8cbf164b8b57faebab8cd 100644 (file)
@@ -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)
index 705ad2cc2c977da774dc7a28c0be7a9b45ef5d2a..407e13d3dbc22227db8cd769f86a6b37e4f9881b 100644 (file)
@@ -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;
     }
 
index b67c996e1dd455f449245d7134e828722febf0d9..79d705c2555cffc1cc9cff82a3881f4d812886b8 100644 (file)
@@ -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']);
             }
         }
 
index ed1b281fce848451d76029ccc6b6f7e277f4ce19..b6464b22dec5f72902c6b63e66ee6460f03bc7e5 100644 (file)
@@ -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;
     }
 
index 938fd8446abf64817f10b15609c77287becb2d7c..32af193f911d14cddaefd12dcb110206c026d6c7 100644 (file)
@@ -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;
     }