]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch '0.7.x' of git@gitorious.org:laconica/dev into 0.7.x
authorEvan Prodromou <evan@controlyourself.ca>
Sat, 21 Feb 2009 15:10:33 +0000 (07:10 -0800)
committerEvan Prodromou <evan@controlyourself.ca>
Sat, 21 Feb 2009 15:10:33 +0000 (07:10 -0800)
1  2 
lib/router.php

diff --combined lib/router.php
index 85425bed2964854d1371a05b369ffe6be29aa058,9d0d3a3f0613382fb401fd47922b5ebae107098e..e842604e9a35d11abd55ba1194eaec80b56534f0
@@@ -47,7 -47,7 +47,7 @@@ require_once 'Net/URL/Mapper.php'
  
  class Router
  {
 -    static $m = null;
 +    var $m = null;
      static $inst = null;
  
      static function get()
          $main = array('login', 'logout', 'register', 'subscribe',
                        'unsubscribe', 'confirmaddress', 'recoverpassword',
                        'invite', 'favor', 'disfavor', 'sup',
 -                      'tagother', 'block');
 +                      'block');
  
          foreach ($main as $a) {
              $m->connect('main/'.$a, array('action' => $a));
          }
  
 +        $m->connect('main/tagother/:id', array('action' => 'tagother'));
 +
          // these take a code
  
          foreach (array('register', 'confirmaddress', 'recoverpassword') as $c) {
  
          // 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',
                            '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
  
  
      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, $fragment=null)
 +    function build($action, $args=null, $params=null, $fragment=null)
      {
          $action_arg = array('action' => $action);
  
              $args = $action_arg;
          }
  
 -        return $this->m->generate($args, null, $fragment);
 +        return $this->m->generate($args, $params, $fragment);
      }
  }