]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/router.php
Merge branch '0.7.x' into 0.8.x
[quix0rs-gnu-social.git] / lib / router.php
index 135e07a0f0e3c13ab59a746b8447ed0ddd421255..5e16f34191d6466671acca84d2b9df6a1de9f3f9 100644 (file)
@@ -68,8 +68,8 @@ class Router
         }
     }
 
-    function initialize() {
-
+    function initialize()
+    {
         $m = Net_URL_Mapper::getInstance();
 
         // In the "root"
@@ -107,6 +107,9 @@ class Router
             $m->connect('main/'.$a, array('action' => $a));
         }
 
+        $m->connect('main/sup/:seconds', array('action' => 'sup'),
+                    array('seconds' => '[0-9]+'));
+
         $m->connect('main/tagother/:id', array('action' => 'tagother'));
 
         // these take a code
@@ -128,7 +131,7 @@ class Router
         // settings
 
         foreach (array('profile', 'avatar', 'password', 'openid', 'im',
-                       'email', 'sms', 'twitter', 'other') as $s) {
+                       'email', 'sms', 'twitter', 'design', 'other') as $s) {
             $m->connect('settings/'.$s, array('action' => $s.'settings'));
         }
 
@@ -136,10 +139,17 @@ class Router
 
         foreach (array('group', 'people', 'notice') as $s) {
             $m->connect('search/'.$s, array('action' => $s.'search'));
-            $m->connect('search/'.$s.'?q=:q', array('action' => $s.'search'), array('q' => '.+'));
+            $m->connect('search/'.$s.'?q=:q',
+                        array('action' => $s.'search'),
+                        array('q' => '.+'));
         }
 
+        // 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', array('action' => 'noticesearchrss'));
+        $m->connect('search/notice/rss?q=:q', array('action' => 'noticesearchrss'),
+                    array('q' => '.+'));
 
         // notice
 
@@ -155,6 +165,12 @@ class Router
                     array('action' => 'deletenotice'),
                     array('notice' => '[0-9]+'));
 
+        // conversation
+
+        $m->connect('conversation/:id',
+                    array('action' => 'conversation'),
+                    array('id' => '[0-9]+'));
+
         $m->connect('message/new', array('action' => 'newmessage'));
         $m->connect('message/new?to=:to', array('action' => 'newmessage'), array('to' => '[A-Za-z0-9_-]+'));
         $m->connect('message/:message',
@@ -259,8 +275,8 @@ class Router
         foreach (array('xml', 'json', 'rss', 'atom') as $e) {
             $m->connect('api/direct_messages/sent.'.$e,
                         array('action' => 'api',
-                        'apiaction' => 'direct_messages',
-                        'method' => 'sent.'.$e));
+                              'apiaction' => 'direct_messages',
+                              'method' => 'sent.'.$e));
         }
 
         $m->connect('api/direct_messages/destroy/:argument',
@@ -324,9 +340,9 @@ class Router
 
         foreach (array('xml', 'json', 'rss', 'atom') as $e) {
             $m->connect('api/favorites.'.$e,
-                array('action' => 'api',
-                      'apiaction' => 'favorites',
-                      'method' => 'favorites.'.$e));
+                        array('action' => 'api',
+                              'apiaction' => 'favorites',
+                              'method' => 'favorites.'.$e));
         }
 
         // notifications
@@ -411,7 +427,7 @@ class Router
             $match = $this->m->match($path);
         } catch (Net_URL_Mapper_InvalidException $e) {
             common_log(LOG_ERR, "Problem getting route for $path - " .
-                $e->getMessage());
+                       $e->getMessage());
             $cac = new ClientErrorAction("Page not found.", 404);
             $cac->showPage();
         }
@@ -434,10 +450,11 @@ class Router
         // Due to a bug in the Net_URL_Mapper code, the returned URL may
         // contain a malformed query of the form ?p1=v1?p2=v2?p3=v3. We
         // repair that here rather than modifying the upstream code...
-        $qpos = strpos($url,'?');
+
+        $qpos = strpos($url, '?');
         if ($qpos !== false) {
             $url = substr($url, 0, $qpos+1) .
-                     str_replace('?', '&', substr($url, $qpos+1));
+              str_replace('?', '&', substr($url, $qpos+1));
         }
         return $url;
     }