Misc code formatting and whitespace fixes

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7020 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2008-05-23 05:11:41 +00:00
parent d3f772cfb4
commit 7402680cc1
21 changed files with 163 additions and 133 deletions

View file

@ -51,19 +51,19 @@ class ErrorHandler extends Object {
*/ */
function __construct($method, $messages) { function __construct($method, $messages) {
App::import('Controller', 'App'); App::import('Controller', 'App');
App::import('Core', 'Sanitize');
$this->controller =& new AppController(); $this->controller =& new AppController();
$this->controller->_set(Router::getPaths()); $this->controller->_set(Router::getPaths());
$this->controller->params = Router::getParams(); $this->controller->params = Router::getParams();
$this->controller->constructClasses(); $this->controller->constructClasses();
$this->controller->cacheAction = false; $this->controller->_set(array('cacheAction' => false, 'viewPath' => 'errors'));
$this->controller->viewPath = 'errors';
$allow = array('.', '/', '_', ' ', '-', '~'); $allow = array('.', '/', '_', ' ', '-', '~');
if (substr(PHP_OS, 0, 3) == "WIN") { if (substr(PHP_OS, 0, 3) == "WIN") {
$allow = array_merge($allow, array('\\', ':')); $allow = array_merge($allow, array('\\', ':'));
} }
App::import('Core', 'Sanitize');
$messages = Sanitize::paranoid($messages, $allow); $messages = Sanitize::paranoid($messages, $allow);
if (!isset($messages[0])) { if (!isset($messages[0])) {
@ -81,6 +81,9 @@ class ErrorHandler extends Object {
if ($method == 'error') { if ($method == 'error') {
$this->dispatchMethod($method, $messages); $this->dispatchMethod($method, $messages);
$this->stop(); $this->stop();
} elseif (Configure::read() == 0 && (isset($code) && $code == 500)) {
$this->dispatchMethod('error500', $messages);
exit();
} elseif (Configure::read() == 0) { } elseif (Configure::read() == 0) {
$this->dispatchMethod('error404', $messages); $this->dispatchMethod('error404', $messages);
$this->stop(); $this->stop();
@ -97,10 +100,12 @@ class ErrorHandler extends Object {
*/ */
function error($params) { function error($params) {
extract($params, EXTR_OVERWRITE); extract($params, EXTR_OVERWRITE);
$this->controller->set(array('code' => $code, $this->controller->set(array(
'code' => $code,
'name' => $name, 'name' => $name,
'message' => $message, 'message' => $message,
'title' => $code . ' ' . $name)); 'title' => $code . ' ' . $name
));
$this->__outputMessage('error404'); $this->__outputMessage('error404');
} }
/** /**
@ -117,10 +122,12 @@ class ErrorHandler extends Object {
} }
$url = Router::normalize($url); $url = Router::normalize($url);
header("HTTP/1.0 404 Not Found"); header("HTTP/1.0 404 Not Found");
$this->controller->set(array('code' => '404', $this->controller->set(array(
'code' => '404',
'name' => __('Not Found', true), 'name' => __('Not Found', true),
'message' => sprintf(__("The requested address %s was not found on this server.", true), "<strong>'{$url}'</strong>"), 'message' => sprintf(__("The requested address %s was not found on this server.", true), "<strong>'{$url}'</strong>"),
'base' => $this->controller->base)); 'base' => $this->controller->base
));
$this->__outputMessage('error404'); $this->__outputMessage('error404');
} }
/** /**

View file

@ -492,8 +492,12 @@ class TreeBehavior extends ModelBehavior {
return false; return false;
} }
} }
$previousNode = $model->find('first', array('conditions' => array($scope, $model->escapeField($right) => ($node[$left] - 1)), $previousNode = $model->find('first', array(
'fields' => array($model->primaryKey, $left, $right), 'recursive' => $recursive)); 'conditions' => array($scope, $model->escapeField($right) => ($node[$left] - 1)),
'fields' => array($model->primaryKey, $left, $right),
'recursive' => $recursive
));
if ($previousNode) { if ($previousNode) {
list($previousNode) = array_values($previousNode); list($previousNode) = array_values($previousNode);
} else { } else {
@ -540,8 +544,12 @@ class TreeBehavior extends ModelBehavior {
'fields' => array($model->primaryKey, $left, $right, $parent, 'fields' => array($model->primaryKey, $left, $right, $parent,
'actsAs' => '') 'actsAs' => '')
)))); ))));
$missingParents = $model->find('list', array('recursive' => 0, 'conditions' => $missingParents = $model->find('list', array(
array($scope, array('NOT' => array($model->escapeField($parent) => null), $model->VerifyParent->escapeField() => null)))); 'recursive' => 0,
'conditions' => array($scope, array(
'NOT' => array($model->escapeField($parent) => null), $model->VerifyParent->escapeField() => null
))
));
$model->unbindModel(array('belongsTo' => array('VerifyParent'))); $model->unbindModel(array('belongsTo' => array('VerifyParent')));
if ($missingParents) { if ($missingParents) {
if ($missingParentAction == 'return') { if ($missingParentAction == 'return') {
@ -632,9 +640,13 @@ class TreeBehavior extends ModelBehavior {
extract (array_merge($id, array('id' => null))); extract (array_merge($id, array('id' => null)));
} }
extract($this->settings[$model->alias]); extract($this->settings[$model->alias]);
list($node) = array_values($model->find('first', array('conditions' => array($scope, $model->escapeField() => $id),
'fields' => array($model->primaryKey, $left, $right, $parent), 'recursive' => $recursive)) list($node) = array_values($model->find('first', array(
); 'conditions' => array($scope, $model->escapeField() => $id),
'fields' => array($model->primaryKey, $left, $right, $parent),
'recursive' => $recursive
)));
if ($node[$right] == $node[$left] + 1) { if ($node[$right] == $node[$left] + 1) {
if ($delete) { if ($delete) {
$model->delete(); $model->delete();
@ -642,12 +654,15 @@ class TreeBehavior extends ModelBehavior {
return false; return false;
} }
} elseif ($node[$parent]) { } elseif ($node[$parent]) {
list($parentNode) = array_values($model->find('first', array('conditions' => array($scope, $model->escapeField() => $node[$parent]), list($parentNode) = array_values($model->find('first', array(
'fields' => array($model->primaryKey, $left, $right), 'recursive' => $recursive)) 'conditions' => array($scope, $model->escapeField() => $node[$parent]),
); 'fields' => array($model->primaryKey, $left, $right),
'recursive' => $recursive
)));
} else { } else {
$parentNode[$right] = $node[$right] + 1; $parentNode[$right] = $node[$right] + 1;
} }
$model->updateAll(array($parent => $node[$parent]), array($parent => $node[$model->primaryKey])); $model->updateAll(array($parent => $node[$parent]), array($parent => $node[$model->primaryKey]));
$this->__sync($model, 1, '-', 'BETWEEN ' . ($node[$left] + 1) . ' AND ' . ($node[$right] - 1)); $this->__sync($model, 1, '-', 'BETWEEN ' . ($node[$left] + 1) . ' AND ' . ($node[$right] - 1));
$this->__sync($model, 2, '-', '> ' . ($node[$right])); $this->__sync($model, 2, '-', '> ' . ($node[$right]));
@ -655,7 +670,11 @@ class TreeBehavior extends ModelBehavior {
if ($delete) { if ($delete) {
$model->updateAll( $model->updateAll(
array($model->escapeField($left) => 0, $model->escapeField($right) => 0, $model->escapeField($parent) => null), array(
$model->escapeField($left) => 0,
$model->escapeField($right) => 0,
$model->escapeField($parent) => null
),
array($model->escapeField() => $id) array($model->escapeField() => $id)
); );
return $model->delete($id); return $model->delete($id);
@ -705,7 +724,9 @@ class TreeBehavior extends ModelBehavior {
$errors = array(); $errors = array();
for ($i = $min; $i <= $edge; $i++) { for ($i = $min; $i <= $edge; $i++) {
$count = $model->find('count', array('conditions' => array($scope, 'OR' => array($model->escapeField($left) => $i, $model->escapeField($right) => $i)))); $count = $model->find('count', array('conditions' => array(
$scope, 'OR' => array($model->escapeField($left) => $i, $model->escapeField($right) => $i)
)));
if ($count != 1) { if ($count != 1) {
if ($count == 0) { if ($count == 0) {
$errors[] = array('index', $i, 'missing'); $errors[] = array('index', $i, 'missing');

View file

@ -261,20 +261,19 @@ class DboPostgres extends DboSource {
case 'integer': case 'integer':
if ($data === '') { if ($data === '') {
return 'DEFAULT'; return 'DEFAULT';
} else {
$data = pg_escape_string($data);
} }
break;
case 'binary': case 'binary':
$data = pg_escape_bytea($data); $data = pg_escape_bytea($data);
break; break;
case 'boolean': case 'boolean':
default:
if ($data === true) { if ($data === true) {
return 'TRUE'; return 'TRUE';
} elseif ($data === false) { } elseif ($data === false) {
return 'FALSE'; return 'FALSE';
} }
return 'DEFAULT';
break;
default:
$data = pg_escape_string($data); $data = pg_escape_string($data);
break; break;
} }

View file

@ -613,6 +613,7 @@ class Validation extends Object {
function money($check, $symbolPosition = 'left') { function money($check, $symbolPosition = 'left') {
$_this =& Validation::getInstance(); $_this =& Validation::getInstance();
$_this->check = $check; $_this->check = $check;
switch ($symbolPosition) { switch ($symbolPosition) {
case 'left': case 'left':
$_this->regex = '/^(?!\x{00a2})\p{Sc}?(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?$/u'; $_this->regex = '/^(?!\x{00a2})\p{Sc}?(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?$/u';

View file

@ -490,6 +490,7 @@ class HtmlHelper extends AppHelper {
$useCount = true; $useCount = true;
$oddTrOptions = null; $oddTrOptions = null;
} }
if ($evenTrOptions === false) { if ($evenTrOptions === false) {
$continueOddEven = false; $continueOddEven = false;
$evenTrOptions = null; $evenTrOptions = null;

View file

@ -58,9 +58,6 @@ class ScaffoldViewTest extends CakeTestCase {
$this->Controller = new ScaffoldMockController(); $this->Controller = new ScaffoldMockController();
} }
function tearDown() {
unset($this->Controller);
}
function testGetViewFilename() { function testGetViewFilename() {
$this->Controller->action = 'index'; $this->Controller->action = 'index';
$ScaffoldView =& new TestScaffoldView($this->Controller); $ScaffoldView =& new TestScaffoldView($this->Controller);
@ -68,10 +65,14 @@ class ScaffoldViewTest extends CakeTestCase {
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS . 'scaffolds' . DS . 'index.ctp'; $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS . 'scaffolds' . DS . 'index.ctp';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $ScaffoldView->testGetFilename('error'); $result = $ScaffoldView->testGetFilename('error');
$expected = 'cake' . DS . 'libs' . DS . 'view' . DS . 'errors' . DS . 'scaffold_error.ctp'; $expected = 'cake' . DS . 'libs' . DS . 'view' . DS . 'errors' . DS . 'scaffold_error.ctp';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }
function tearDown() {
unset($this->Controller);
} }
}
?> ?>