Skip to content

Commit

Permalink
fixing error with \n\r [#100 state:resolved]
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Jan 13, 2010
1 parent 702cf14 commit a7ef218
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
22 changes: 3 additions & 19 deletions config/routes.php
Expand Up @@ -11,28 +11,12 @@
if (!$routes) {
$routes = Classregistry::init('Management.Route')->getRoutes();
if (empty($routes)) {
//something is broken
// @todo -c Implement .some error message or something
}
}

foreach($routes as $route ){
//Router::connect($route['Route']['url'], $route['Route']['values'], $route['Route']['regex'] );
//Router::connect('/p/:year/:month/:day', array('plugin'=>'blog','controller'=>'posts','day'=>null,'admin'=>null), array('year'=>'[12][0-9]{3}','month'=>'0[1-9]|1[012]','day'=>'0[1-9]|[12][0-9]|3[01]') );
Router::connect($route['Route']['url'], $route['Route']['values'], $route['Route']['regex'] );
}
$db = array(
'url' => $routes[0]['Route']['url'],
'values' => $routes[0]['Route']['values'],
'regex' => $routes[0]['Route']['regex']

);

$code = array(
'url' => '/p/:year/:month/:day',
'values' => array('plugin'=>'blog','controller'=>'posts','day'=>null,'admin'=>null),
'regex' => array('year'=>'[12][0-9]{3}','month'=>'0[1-9]|1[012]','day'=>'0[1-9]|[12][0-9]|3[01]')
);

var_dump( $db );
echo '<br/>';
var_dump( $code );
exit;
?>
10 changes: 9 additions & 1 deletion infinitas/management/models/route.php
Expand Up @@ -145,6 +145,7 @@ function _getRegex($field){
foreach((array)$_v as $line ){
$parts = explode( ':', $line );
if (count($parts) == 2 ) {

$values[$parts[0]] = $this->_getType($parts[1]);
}
}
Expand All @@ -153,9 +154,16 @@ function _getRegex($field){
}

function _getType($field = false){
$replace = array(
"\r",
"\n",
"\n\r",
"\r\n",
' '
);
$field = str_replace( $replace, '', $field );
switch($field){
case 'null':
case strstr($field, 'null'): // var_dump has "null " and trim/rtrim/str_replace("\n".. || "\n\r"..) wont remove the space
return null;
break;

Expand Down

0 comments on commit a7ef218

Please sign in to comment.