Merge branch 'master' into 0.7.x

Conflicts:
	lib/router.php
This commit is contained in:
Evan Prodromou 2009-03-25 12:56:52 -04:00
commit 2becd5849d
2 changed files with 20 additions and 19 deletions

View File

@ -125,6 +125,7 @@ class NoticesearchAction extends SearchAction
$this->pagination($page > 1, $cnt > NOTICES_PER_PAGE, $this->pagination($page > 1, $cnt > NOTICES_PER_PAGE,
$page, 'noticesearch', array('q' => $q)); $page, 'noticesearch', array('q' => $q));
} }
function isReadOnly() function isReadOnly()
{ {
return true; return true;

View File

@ -68,8 +68,8 @@ class Router
} }
} }
function initialize() { function initialize()
{
$m = Net_URL_Mapper::getInstance(); $m = Net_URL_Mapper::getInstance();
// In the "root" // In the "root"
@ -136,14 +136,17 @@ class Router
foreach (array('group', 'people', 'notice') as $s) { foreach (array('group', 'people', 'notice') as $s) {
$m->connect('search/'.$s, array('action' => $s.'search')); $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 // The second of these is needed to make the link work correctly
// when inserted into the page. The first is needed to match the // 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. // 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', 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 // notice
@ -263,8 +266,8 @@ class Router
foreach (array('xml', 'json', 'rss', 'atom') as $e) { foreach (array('xml', 'json', 'rss', 'atom') as $e) {
$m->connect('api/direct_messages/sent.'.$e, $m->connect('api/direct_messages/sent.'.$e,
array('action' => 'api', array('action' => 'api',
'apiaction' => 'direct_messages', 'apiaction' => 'direct_messages',
'method' => 'sent.'.$e)); 'method' => 'sent.'.$e));
} }
$m->connect('api/direct_messages/destroy/:argument', $m->connect('api/direct_messages/destroy/:argument',
@ -328,9 +331,9 @@ class Router
foreach (array('xml', 'json', 'rss', 'atom') as $e) { foreach (array('xml', 'json', 'rss', 'atom') as $e) {
$m->connect('api/favorites.'.$e, $m->connect('api/favorites.'.$e,
array('action' => 'api', array('action' => 'api',
'apiaction' => 'favorites', 'apiaction' => 'favorites',
'method' => 'favorites.'.$e)); 'method' => 'favorites.'.$e));
} }
// notifications // notifications
@ -415,7 +418,7 @@ class Router
$match = $this->m->match($path); $match = $this->m->match($path);
} catch (Net_URL_Mapper_InvalidException $e) { } catch (Net_URL_Mapper_InvalidException $e) {
common_log(LOG_ERR, "Problem getting route for $path - " . common_log(LOG_ERR, "Problem getting route for $path - " .
$e->getMessage()); $e->getMessage());
$cac = new ClientErrorAction("Page not found.", 404); $cac = new ClientErrorAction("Page not found.", 404);
$cac->showPage(); $cac->showPage();
} }
@ -425,8 +428,6 @@ class Router
function build($action, $args=null, $params=null, $fragment=null) 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); $action_arg = array('action' => $action);
if ($args) { if ($args) {
@ -435,17 +436,16 @@ class Router
$args = $action_arg; $args = $action_arg;
} }
if($params!=null) $url = $this->m->generate($args, $params, $fragment);
common_log(LOG_DEBUG,"generate args:".print_r($args,true));
$url=$this->m->generate($args, $params, $fragment);
// Due to a bug in the Net_URL_Mapper code, the returned URL may // 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 // contain a malformed query of the form ?p1=v1?p2=v2?p3=v3. We
// repair that here rather than modifying the upstream code... // repair that here rather than modifying the upstream code...
$qpos = strpos($url,'?');
$qpos = strpos($url, '?');
if ($qpos !== false) { if ($qpos !== false) {
$url = substr($url, 0, $qpos+1) . $url = substr($url, 0, $qpos+1) .
str_replace('?', '&', substr($url, $qpos+1)); str_replace('?', '&', substr($url, $qpos+1));
} }
return $url; return $url;
} }