summaryrefslogtreecommitdiff
path: root/lib/router.php
diff options
context:
space:
mode:
authorSarven Capadisli <csarven@controlyourself.ca>2009-03-30 15:15:40 +0000
committerSarven Capadisli <csarven@controlyourself.ca>2009-03-30 15:15:40 +0000
commit27b45eeb4882e6c8d5de65d913a148437e91b50c (patch)
treeb90fa9d4c2d8c75e33126f6a67f0f968255c1d8e /lib/router.php
parent8c073a34ce472fc8d0385659a222339a5ba4254a (diff)
parent559cf75edbbf60a0d9f8e4991333d85a79359a99 (diff)
Merge branch '0.7.x' into 0.8.x
Diffstat (limited to 'lib/router.php')
-rw-r--r--lib/router.php44
1 files changed, 27 insertions, 17 deletions
diff --git a/lib/router.php b/lib/router.php
index 5a00a7fea..67b8b8ae6 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -68,8 +68,8 @@ class Router
}
}
- function initialize() {
-
+ function initialize()
+ {
$m = Net_URL_Mapper::getInstance();
// In the "root"
@@ -136,14 +136,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.
+ // 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('search/notice/rss?q=:q', array('action' => 'noticesearchrss'),
+ array('q' => '.+'));
// notice
@@ -269,8 +272,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',
@@ -334,9 +337,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
@@ -421,7 +424,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();
}
@@ -431,8 +434,6 @@ class Router
function build($action, $args=null, $params=null, $fragment=null)
{
- if($params!=null)
- common_log(LOG_DEBUG,"build: ".$action." ".print_r($args,true)." ".print_r($params,true));
$action_arg = array('action' => $action);
if ($args) {
@@ -441,8 +442,17 @@ class Router
$args = $action_arg;
}
- if($params!=null)
- common_log(LOG_DEBUG,"generate args:".print_r($args,true));
- 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;
}
}