]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/router.php
* i18n/L10n fixes.
[quix0rs-gnu-social.git] / lib / router.php
index b046b240c951147de3556df514d554add0bd9fcb..b1cc8d52941347bec09400c38c7affdba68a1ed2 100644 (file)
@@ -33,6 +33,33 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
 
 require_once 'Net/URL/Mapper.php';
 
+class StatusNet_URL_Mapper extends Net_URL_Mapper {
+
+    private static $_singleton = null;
+
+    private function __construct()
+    {
+    }
+
+    public static function getInstance($id = '__default__')
+    {
+        if (empty(self::$_singleton)) {
+            self::$_singleton = new StatusNet_URL_Mapper();
+        }
+        return self::$_singleton;
+    }
+
+    public function connect($path, $defaults = array(), $rules = array())
+    {
+        $result = null;
+        if (Event::handle('StartConnectPath', array(&$path, &$defaults, &$rules, &$result))) {
+            $result = parent::connect($path, $defaults, $rules);
+            Event::handle('EndConnectPath', array($path, $defaults, $rules, $result));
+        }
+        return $result;
+    }
+}
+
 /**
  * URL Router
  *
@@ -69,7 +96,7 @@ class Router
 
     function initialize()
     {
-        $m = Net_URL_Mapper::getInstance();
+        $m = StatusNet_URL_Mapper::getInstance();
 
         if (Event::handle('StartInitializeRouter', array(&$m))) {
 
@@ -98,6 +125,7 @@ class Router
                           'groupblock', 'groupunblock',
                           'sandbox', 'unsandbox',
                           'silence', 'unsilence',
+                          'grantrole', 'revokerole',
                           'repeat',
                           'deleteuser',
                           'geocode',
@@ -108,6 +136,11 @@ class Router
                 $m->connect('main/'.$a, array('action' => $a));
             }
 
+            // Also need a block variant accepting ID on URL for mail links
+            $m->connect('main/block/:profileid',
+                        array('action' => 'block'),
+                        array('profileid' => '[0-9]+'));
+
             $m->connect('main/sup/:seconds', array('action' => 'sup'),
                         array('seconds' => '[0-9]+'));
 
@@ -152,6 +185,10 @@ class Router
                 array('action' => 'editapplication'),
                 array('id' => '[0-9]+')
             );
+            $m->connect('settings/oauthapps/delete/:id',
+                array('action' => 'deleteapplication'),
+                array('id' => '[0-9]+')
+            );
 
             // search
 
@@ -226,7 +263,7 @@ class Router
             $m->connect('tag', array('action' => 'publictagcloud'));
             $m->connect('tag/:tag/rss',
                         array('action' => 'tagrss'),
-                        array('tag' => '[a-zA-Z0-9]+'));
+                        array('tag' => '[\pL\pN_\-\.]{1,64}'));
             $m->connect('tag/:tag',
                         array('action' => 'tag'),
                         array('tag' => '[\pL\pN_\-\.]{1,64}'));
@@ -239,10 +276,13 @@ class Router
 
             $m->connect('group/new', array('action' => 'newgroup'));
 
-            foreach (array('edit', 'join', 'leave') as $v) {
+            foreach (array('edit', 'join', 'leave', 'delete') as $v) {
                 $m->connect('group/:nickname/'.$v,
                             array('action' => $v.'group'),
                             array('nickname' => '[a-zA-Z0-9]+'));
+                $m->connect('group/:id/id/'.$v,
+                            array('action' => $v.'group'),
+                            array('id' => '[0-9]+'));
             }
 
             foreach (array('members', 'logo', 'rss', 'designsettings') as $n) {
@@ -448,19 +488,19 @@ class Router
             // Social graph
 
             $m->connect('api/friends/ids/:id.:format',
-                        array('action' => 'apiuserfriends',
+                        array('action' => 'ApiUserFriends',
                               'ids_only' => true));
 
             $m->connect('api/followers/ids/:id.:format',
-                        array('action' => 'apiuserfollowers',
+                        array('action' => 'ApiUserFollowers',
                               'ids_only' => true));
 
             $m->connect('api/friends/ids.:format',
-                        array('action' => 'apiuserfriends',
+                        array('action' => 'ApiUserFriends',
                               'ids_only' => true));
 
             $m->connect('api/followers/ids.:format',
-                        array('action' => 'apiuserfollowers',
+                        array('action' => 'ApiUserFollowers',
                               'ids_only' => true));
 
             // account
@@ -500,7 +540,7 @@ class Router
             $m->connect('api/favorites/:id.:format',
                         array('action' => 'ApiTimelineFavorites',
                               'id' => '[a-zA-Z0-9]+',
-                              'format' => '(xmljson|rss|atom)'));
+                              'format' => '(xml|json|rss|atom)'));
 
             $m->connect('api/favorites/create/:id.:format',
                         array('action' => 'ApiFavoriteCreate',
@@ -557,7 +597,7 @@ class Router
             $m->connect('api/statusnet/groups/timeline/:id.:format',
                         array('action' => 'ApiTimelineGroup',
                               'id' => '[a-zA-Z0-9]+',
-                              'format' => '(xmljson|rss|atom)'));
+                              'format' => '(xml|json|rss|atom)'));
 
             $m->connect('api/statusnet/groups/show.:format',
                         array('action' => 'ApiGroupShow',
@@ -618,21 +658,27 @@ class Router
             // Tags
             $m->connect('api/statusnet/tags/timeline/:tag.:format',
                         array('action' => 'ApiTimelineTag',
-                              'format' => '(xmljson|rss|atom)'));
+                              'format' => '(xml|json|rss|atom)'));
+
+            // media related
+            $m->connect(
+                'api/statusnet/media/upload',
+                array('action' => 'ApiMediaUpload')
+            );
 
             // search
-            $m->connect('api/search.atom', array('action' => 'twitapisearchatom'));
-            $m->connect('api/search.json', array('action' => 'twitapisearchjson'));
-            $m->connect('api/trends.json', array('action' => 'twitapitrends'));
+            $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/oauth/request_token',
-                        array('action' => 'apioauthrequesttoken'));
+                        array('action' => 'ApiOauthRequestToken'));
 
             $m->connect('api/oauth/access_token',
-                        array('action' => 'apioauthaccesstoken'));
+                        array('action' => 'ApiOauthAccessToken'));
 
             $m->connect('api/oauth/authorize',
-                        array('action' => 'apioauthauthorize'));
+                        array('action' => 'ApiOauthAuthorize'));
 
             // Admin
 
@@ -642,6 +688,10 @@ class Router
                $m->connect('admin/access', array('action' => 'accessadminpanel'));
             $m->connect('admin/paths', array('action' => 'pathsadminpanel'));
             $m->connect('admin/sessions', array('action' => 'sessionsadminpanel'));
+            $m->connect('admin/sitenotice', array('action' => 'sitenoticeadminpanel'));
+            $m->connect('admin/snapshot', array('action' => 'snapshotadminpanel'));
+            $m->connect('admin/license', array('action' => 'licenseadminpanel'));
+
 
             $m->connect('getfile/:filename',
                         array('action' => 'getfile'),
@@ -664,7 +714,7 @@ class Router
 
                 foreach (array('subscriptions', 'subscribers',
                                'all', 'foaf', 'xrds',
-                               'replies', 'microsummary') as $a) {
+                               'replies', 'microsummary', 'hcard') as $a) {
                     $m->connect($a,
                                 array('action' => $a,
                                       'nickname' => $nickname));
@@ -701,12 +751,12 @@ class Router
                 $m->connect('tag/:tag/rss',
                             array('action' => 'userrss',
                                   'nickname' => $nickname),
-                            array('tag' => '[a-zA-Z0-9]+'));
+                            array('tag' => '[\pL\pN_\-\.]{1,64}'));
 
                 $m->connect('tag/:tag',
                             array('action' => 'showstream',
                                   'nickname' => $nickname),
-                            array('tag' => '[a-zA-Z0-9]+'));
+                            array('tag' => '[\pL\pN_\-\.]{1,64}'));
 
                 $m->connect('rsd.xml',
                             array('action' => 'rsd',
@@ -730,7 +780,7 @@ class Router
 
                 foreach (array('subscriptions', 'subscribers',
                                'nudge', 'all', 'foaf', 'xrds',
-                               'replies', 'inbox', 'outbox', 'microsummary') as $a) {
+                               'replies', 'inbox', 'outbox', 'microsummary', 'hcard') as $a) {
                     $m->connect(':nickname/'.$a,
                                 array('action' => $a),
                                 array('nickname' => '[a-zA-Z0-9]{1,64}'));
@@ -767,12 +817,12 @@ class Router
                 $m->connect(':nickname/tag/:tag/rss',
                             array('action' => 'userrss'),
                             array('nickname' => '[a-zA-Z0-9]{1,64}'),
-                            array('tag' => '[a-zA-Z0-9]+'));
+                            array('tag' => '[\pL\pN_\-\.]{1,64}'));
 
                 $m->connect(':nickname/tag/:tag',
                             array('action' => 'showstream'),
                             array('nickname' => '[a-zA-Z0-9]{1,64}'),
-                            array('tag' => '[a-zA-Z0-9]+'));
+                            array('tag' => '[\pL\pN_\-\.]{1,64}'));
 
                 $m->connect(':nickname/rsd.xml',
                             array('action' => 'rsd'),