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

View file

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

View file

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

View file

@ -613,6 +613,7 @@ class Validation extends Object {
function money($check, $symbolPosition = 'left') {
$_this =& Validation::getInstance();
$_this->check = $check;
switch ($symbolPosition) {
case 'left':
$_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;
$oddTrOptions = null;
}
if ($evenTrOptions === false) {
$continueOddEven = false;
$evenTrOptions = null;

View file

@ -58,9 +58,6 @@ class ScaffoldViewTest extends CakeTestCase {
$this->Controller = new ScaffoldMockController();
}
function tearDown() {
unset($this->Controller);
}
function testGetViewFilename() {
$this->Controller->action = 'index';
$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';
$this->assertEqual($result, $expected);
$result = $ScaffoldView->testGetFilename('error');
$expected = 'cake' . DS . 'libs' . DS . 'view' . DS . 'errors' . DS . 'scaffold_error.ctp';
$this->assertEqual($result, $expected);
}
function tearDown() {
unset($this->Controller);
}
}
?>