]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/router.php
* i18n/L10n fixes.
[quix0rs-gnu-social.git] / lib / router.php
index 7e8e22a7dba0985c89a33f72439044c01d3e7994..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]+'));
 
@@ -230,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}'));
@@ -243,7 +276,7 @@ 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]+'));
@@ -455,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
@@ -507,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',
@@ -564,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',
@@ -625,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
 
@@ -650,6 +689,9 @@ class Router
             $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'),
@@ -709,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',
@@ -775,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'),