]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/router.php
Merge branch '0.7.x' of git@gitorious.org:laconica/dev into 0.7.x
[quix0rs-gnu-social.git] / lib / router.php
index 85425bed2964854d1371a05b369ffe6be29aa058..e842604e9a35d11abd55ba1194eaec80b56534f0 100644 (file)
@@ -228,20 +228,31 @@ class Router
 
         // direct messages
 
-        $m->connect('api/direct_messages/:method',
-                    array('action' => 'api',
-                          'apiaction' => 'direct_messages'),
-                    array('method' => '(sent|new)(\.(xml|json|atom|rss))?'));
+        foreach (array('xml', 'json') as $e) {
+            $m->connect('api/direct_messages/new.'.$e,
+                        array('action' => 'api',
+                              'apiaction' => 'direct_messages',
+                              'method' => 'create.'.$e));
+        }
+
+        foreach (array('xml', 'json', 'rss', 'atom') as $e) {
+            $m->connect('api/direct_messages.'.$e,
+                        array('action' => 'api',
+                              'apiaction' => 'direct_messages',
+                              'method' => 'direct_messages.'.$e));
+        }
+
+        foreach (array('xml', 'json', 'rss', 'atom') as $e) {
+            $m->connect('api/direct_message/sent.'.$e,
+                        array('action' => 'api',
+                        'apiaction' => 'direct_messages',
+                        'method' => 'sent.'.$e));
+        }
 
         $m->connect('api/direct_messages/destroy/:argument',
                     array('action' => 'api',
                           'apiaction' => 'direct_messages'));
 
-        $m->connect('api/:method',
-                    array('action' => 'api',
-                          'apiaction' => 'direct_messages'),
-                    array('method' => 'direct_messages(\.(xml|json|atom|rss))?'));
-
         // friendships
 
         $m->connect('api/friendships/:method/:argument',
@@ -271,10 +282,12 @@ class Router
                           'apiaction' => 'favorites',
                           'method' => 'favorites'));
 
-        $m->connect('api/:method',
-                    array('action' => 'api',
-                          'apiaction' => 'favorites'),
-                    array('method' => 'favorites(\.(xml|json|rss|atom))?'));
+        foreach (array('xml', 'json', 'rss', 'atom') as $e) {
+            $m->connect('api/favorites.'.$e,
+                array('action' => 'api',
+                      'apiaction' => 'favorites',
+                      'method' => 'favorites.'.$e));
+        }
 
         // notifications
 
@@ -347,7 +360,16 @@ class Router
 
     function map($path)
     {
-        return $this->m->match($path);
+        try {
+            $match = $this->m->match($path);
+        } catch (Net_URL_Mapper_InvalidException $e) {
+            common_log(LOG_ERR, "Problem getting route for $path - " .
+                $e->getMessage());
+            $cac = new ClientErrorAction("Page not found.", 404);
+            $cac->showPage();
+        }
+
+        return $match;
     }
 
     function build($action, $args=null, $params=null, $fragment=null)