X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Frouter.php;h=70ee0f3fb05d6302b66994f863ccacde82ee096c;hb=76aa85fe5ef408cecf7c40c0c56d58ff9ac9fcbb;hp=d34b84cd43fe0f264ae48a25974795fe1656799c;hpb=16a6aa53907de29c6d993fd18e62d45e4380f451;p=quix0rs-gnu-social.git diff --git a/lib/router.php b/lib/router.php index d34b84cd43..70ee0f3fb0 100644 --- a/lib/router.php +++ b/lib/router.php @@ -50,7 +50,8 @@ class Router var $m = null; static $inst = null; static $bare = array('requesttoken', 'accesstoken', 'userauthorization', - 'postnotice', 'updateprofile', 'finishremotesubscribe'); + 'postnotice', 'updateprofile', 'finishremotesubscribe', + 'finishopenidlogin', 'finishaddopenid'); static function get() { @@ -67,8 +68,8 @@ class Router } } - function initialize() { - + function initialize() + { $m = Net_URL_Mapper::getInstance(); // In the "root" @@ -100,12 +101,15 @@ class Router $main = array('login', 'logout', 'register', 'subscribe', 'unsubscribe', 'confirmaddress', 'recoverpassword', 'invite', 'favor', 'disfavor', 'sup', - 'block'); + 'block', 'subedit'); foreach ($main as $a) { $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 @@ -127,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')); } @@ -135,10 +139,25 @@ 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' => '.+')); + + $m->connect('attachment/:attachment/ajax', + array('action' => 'attachment_ajax'), + array('notice' => '[0-9]+')); + + $m->connect('attachment/:attachment', + array('action' => 'attachment'), + array('notice' => '[0-9]+')); // notice @@ -146,6 +165,12 @@ class Router $m->connect('notice/new?replyto=:replyto', array('action' => 'newnotice'), array('replyto' => '[A-Za-z0-9_-]+')); + $m->connect('notice/:notice/attachments/ajax', + array('action' => 'attachments_ajax'), + array('notice' => '[0-9]+')); + $m->connect('notice/:notice/attachments', + array('action' => 'attachments'), + array('notice' => '[0-9]+')); $m->connect('notice/:notice', array('action' => 'shownotice'), array('notice' => '[0-9]+')); @@ -154,8 +179,14 @@ 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/new?to=:to', array('action' => 'newmessage'), array('to' => '[A-Za-z0-9_-]+')); $m->connect('message/:message', array('action' => 'showmessage'), array('message' => '[0-9]+')); @@ -220,12 +251,12 @@ class Router $m->connect('api/statuses/:method', array('action' => 'api', 'apiaction' => 'statuses'), - array('method' => '(public_timeline|friends_timeline|user_timeline|update|replies|friends|followers|featured)(\.(atom|rss|xml|json))?')); + array('method' => '(public_timeline|friends_timeline|user_timeline|update|replies|mentions|friends|followers|featured)(\.(atom|rss|xml|json))?')); $m->connect('api/statuses/:method/:argument', array('action' => 'api', 'apiaction' => 'statuses'), - array('method' => '(user_timeline|friends_timeline|show|destroy|friends|followers)')); + array('method' => '(user_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)')); // users @@ -256,10 +287,10 @@ class Router } foreach (array('xml', 'json', 'rss', 'atom') as $e) { - $m->connect('api/direct_message/sent.'.$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', @@ -276,7 +307,7 @@ class Router $m->connect('api/friendships/:method', array('action' => 'api', 'apiaction' => 'friendships'), - array('method' => 'exists(\.(xml|json|rss|atom))')); + array('method' => 'exists(\.(xml|json))')); // Social graph @@ -323,9 +354,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 @@ -359,7 +390,7 @@ class Router // user stuff - foreach (array('subscriptions', 'subscribers', + foreach (array('subscriptions', 'subscribers', 'nudge', 'xrds', 'all', 'foaf', 'replies', 'inbox', 'outbox', 'microsummary') as $a) { $m->connect(':nickname/'.$a, @@ -395,6 +426,16 @@ class Router array('size' => '(original|96|48|24)', 'nickname' => '[a-zA-Z0-9]{1,64}')); + $m->connect(':nickname/tag/:tag/rss', + array('action' => 'userrss'), + array('nickname' => '[a-zA-Z0-9]{1,64}'), + array('tag' => '[a-zA-Z0-9]+')); + + $m->connect(':nickname/tag/:tag', + array('action' => 'showstream'), + array('nickname' => '[a-zA-Z0-9]{1,64}'), + array('tag' => '[a-zA-Z0-9]+')); + $m->connect(':nickname', array('action' => 'showstream'), array('nickname' => '[a-zA-Z0-9]{1,64}')); @@ -410,7 +451,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(); } @@ -428,6 +469,17 @@ class Router $args = $action_arg; } - return $this->m->generate($args, $params, $fragment); + $url = $this->m->generate($args, $params, $fragment); + + // 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, '?'); + if ($qpos !== false) { + $url = substr($url, 0, $qpos+1) . + str_replace('?', '&', substr($url, $qpos+1)); + } + return $url; } }