Fixed bug which was kicking us out of the dev/sandbox when editing a customer. Actually, seems like more of a workaround for a CakePHP bug, but it's not certain.

git-svn-id: file:///svn-source/pmgr/branches/v0.2_work@945 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2010-03-02 18:05:37 +00:00
parent 8f5c3031fc
commit a47d5d54b4
2 changed files with 34 additions and 7 deletions

View File

@@ -32,15 +32,22 @@
* *
*/ */
function sandbox() { function _box($type) {
$r = Router::requestRoute(); static $box = array('type' => null, 'test' => array());
return !empty($r[3]['sand_route']); if (!isset($box['type']) && !isset($box['test'][$type])) {
$r = Router::requestRoute();
/* if (!preg_match("/gridData/", $_SERVER['REQUEST_URI'])) { */
/* print("<PRE>Route:\n");print_r($r);print("\n</PRE>\n"); */
/* } */
$box['test'][$type] = !empty($r[3]["${type}_route"]);
if ($box['test'][$type])
$box['type'] = $type;
}
return $box['type'] == $type;
} }
function devbox() { function sandbox() { return _box('sand'); }
$r = Router::requestRoute(); function devbox() { return _box('dev'); }
return !empty($r[3]['dev_route']);
}
function server_request_var($var) { function server_request_var($var) {
if (preg_match("/^HTTP_ACCEPT|REMOTE_PORT/", $var)) if (preg_match("/^HTTP_ACCEPT|REMOTE_PORT/", $var))

View File

@@ -43,6 +43,16 @@ Router::connect('/sand',
array('sand_route' => true) + $default_path); array('sand_route' => true) + $default_path);
Router::connect('/sand/:controller/:action/*', Router::connect('/sand/:controller/:action/*',
array('sand_route' => true, 'action' => null)); array('sand_route' => true, 'action' => null));
/* Unfortunately, for some reason we need an extra route to solve
* a bug with form generation. When $this->data is set by the
* controller, and a URL is generated by the FormHelper, this
* route is required to ensure the form action is correct. An
* example of a broken page is for /customers/edit/XX. It appears
* the page location uses the route above, it's only URL generation
* that seems to be broken.
*/
Router::connect('/sand/:controller/:action/:id/*',
array('sand_route' => true,'action' => null, 'id'=>null));
/* /*
* Route for developement functionality * Route for developement functionality
@@ -51,5 +61,15 @@ Router::connect('/dev',
array('dev_route' => true) + $default_path); array('dev_route' => true) + $default_path);
Router::connect('/dev/:controller/:action/*', Router::connect('/dev/:controller/:action/*',
array('dev_route' => true, 'action' => null)); array('dev_route' => true, 'action' => null));
/* Unfortunately, for some reason we need an extra route to solve
* a bug with form generation. When $this->data is set by the
* controller, and a URL is generated by the FormHelper, this
* route is required to ensure the form action is correct. An
* example of a broken page is for /customers/edit/XX. It appears
* the page location uses the route above, it's only URL generation
* that seems to be broken.
*/
Router::connect('/dev/:controller/:action/:id/*',
array('dev_route' => true,'action' => null, 'id'=>null));
?> ?>