From 7a9fff407a03658018889eb6216f04132e5b0b0c Mon Sep 17 00:00:00 2001 From: phpnut Date: Sat, 25 Feb 2006 04:42:31 +0000 Subject: [PATCH] Merging fixes and enhancements into trunk. Revision: [2120] Added fix for error in Controller::cleanUpFields(). Fixed typo in Scaffold::__scaffoldUpdate(). Revision: [2119] Added fix for missing view error. Added changes to allow SessionComponent::flash() to return similar to what was suggested in Ticket #430. Changed delimiter to -! in the arrays used in DboSource::conditions(). Fixed single quotes being added when value was empty Revision: [2118] Corrected some bugs found in DboSource::conditions(); Added loading of app/config/bootstrap.php to index.php after the core bootstrap.php loads. Changed doc block comment in app/config/bootstrap.php Revision: [2117] "Adding app/config/bootstrap.php. Used for application wide settings" Revision: [2116] "Added better regex to the DboSource::fields()" Revision: [2115] Moving the DIRECTORY_SEPARATOR to top section of the file git-svn-id: https://svn.cakephp.org/repo/trunk/cake@2121 3807eeeb-6ff5-0310-8944-8be069107fe0 --- VERSION.txt | 2 +- app/config/bootstrap.php | 42 ++++++++++++++ app/webroot/index.php | 16 ++++-- cake/libs/controller/components/session.php | 27 ++++++--- cake/libs/controller/controller.php | 61 ++++++++++----------- cake/libs/controller/scaffold.php | 2 +- cake/libs/model/datasources/dbo_source.php | 39 ++++--------- cake/libs/view/view.php | 2 +- 8 files changed, 115 insertions(+), 76 deletions(-) create mode 100644 app/config/bootstrap.php diff --git a/VERSION.txt b/VERSION.txt index 9a4008f1f..063ae3bae 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -6,4 +6,4 @@ // +---------------------------------------------------------------------------------------------------+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////// -0.10.8.2114 \ No newline at end of file +0.10.8.2121 \ No newline at end of file diff --git a/app/config/bootstrap.php b/app/config/bootstrap.php new file mode 100644 index 000000000..515b9a2ce --- /dev/null +++ b/app/config/bootstrap.php @@ -0,0 +1,42 @@ + + * Copyright (c) 2006, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright (c) 2006, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project + * @package cake + * @subpackage cake.cake.app.webroot + * @since CakePHP v 0.10.8.2117 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ + +/** + * + * This file is loaded automatically by the app/webroot/index.php file after the core bootstrap.php is loaded + * This is an application wide file to load any function that is not used within a class define. + * You can also use this to include or require any files in your application. + * + */ + + + +//EOF +?> \ No newline at end of file diff --git a/app/webroot/index.php b/app/webroot/index.php index e471da78f..a418b876b 100644 --- a/app/webroot/index.php +++ b/app/webroot/index.php @@ -28,16 +28,24 @@ * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ +/** + * Do not change + */ +if (!defined('DS')) +{ + define('DS', DIRECTORY_SEPARATOR); +} + /** * These defines should only be edited if you have cake installed in * a directory layout other than the way it is distributed. * Each define has a commented line of code that explains what you would change. * */ - if (!defined('ROOT')) { //define('ROOT', 'FULL PATH TO DIRECTORY WHERE APP DIRECTORY IS LOCATED DO NOT ADD A TRAILING DIRECTORY SEPARATOR'; +//You should also use the DS define to seperate your directories define('ROOT', dirname(dirname(dirname(__FILE__)))); } @@ -54,16 +62,13 @@ if (!defined('APP_DIR')) if (!defined('CAKE_CORE_INCLUDE_PATH')) { //define ('CAKE_CORE_INCLUDE_PATH', FULL PATH TO DIRECTORY WHERE CAKE CORE IS INSTALLED DO NOT ADD A TRAILING DIRECTORY SEPARATOR'; +//You should also use the DS define to seperate your directories define('CAKE_CORE_INCLUDE_PATH', ROOT); } /////////////////////////////// //DO NOT EDIT BELOW THIS LINE// /////////////////////////////// -if (!defined('DS')) -{ - define('DS', DIRECTORY_SEPARATOR); -} if (!defined('WEBROOT_DIR')) { @@ -75,6 +80,7 @@ define('WWW_ROOT', dirname(__FILE__)); ini_set('include_path',ini_get('include_path').PATH_SEPARATOR.CAKE_CORE_INCLUDE_PATH.PATH_SEPARATOR.ROOT.DS.APP_DIR.DS); require 'cake'.DS.'bootstrap.php'; +require 'config'.DS.'bootstrap.php'; if(isset($_GET['url']) && $_GET['url'] === 'favicon.ico') { diff --git a/cake/libs/controller/components/session.php b/cake/libs/controller/components/session.php index 0be680248..367a942df 100644 --- a/cake/libs/controller/components/session.php +++ b/cake/libs/controller/components/session.php @@ -140,24 +140,33 @@ class SessionComponent extends Object } /** - * Enter description here... + * Used to output or return the value of the Message flash. * - * Use like this. $this->Session->flash(); - * - * @return - */ - function flash() + * @param string $css css class used in the div tag + * @param boolean $return setting to true return the value of the flash message instead of displaying + * @return message output + * */ + function flash($css = 'message', $return = false) { if($this->check('Message.flash')) { - echo '
'.$this->read('Message.flash').'
'; - $this->del('Message.flash'); + if($return === false) + { + echo '
'.$this->read('Message.flash').'
'; + $this->del('Message.flash'); + return; + } + else + { + $return = $this->read('Message.flash'); + $this->del('Message.flash'); + return $return; + } } else { return false; } - } /** diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 2a99ac552..e5b201b4a 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -809,53 +809,52 @@ class Controller extends Object */ function cleanUpFields() { - - foreach( $this->{$this->modelKey}->_tableInfo as $table ) + foreach( $this->{$this->modelClass}->_tableInfo as $table ) { foreach ($table as $field) { - if('date' == $field['type'] && isset($this->params['data'][$this->modelKey][$field['name'].'_year'])) + if('date' == $field['type'] && isset($this->params['data'][$this->modelClass][$field['name'].'_year'])) { - $newDate = $this->params['data'][$this->modelKey][$field['name'].'_year'].'-'; - $newDate .= $this->params['data'][$this->modelKey][$field['name'].'_month'].'-'; - $newDate .= $this->params['data'][$this->modelKey][$field['name'].'_day'].' '; - unset($this->params['data'][$this->modelKey][$field['name'].'_year']); - unset($this->params['data'][$this->modelKey][$field['name'].'_month']); - unset($this->params['data'][$this->modelKey][$field['name'].'_day']); - unset($this->params['data'][$this->modelKey][$field['name'].'_hour']); - unset($this->params['data'][$this->modelKey][$field['name'].'_min']); - unset($this->params['data'][$this->modelKey][$field['name'].'_meridian']); - $this->params['data'][$this->modelKey][$field['name']] = $newDate; + $newDate = $this->params['data'][$this->modelClass][$field['name'].'_year'].'-'; + $newDate .= $this->params['data'][$this->modelClass][$field['name'].'_month'].'-'; + $newDate .= $this->params['data'][$this->modelClass][$field['name'].'_day'].' '; + unset($this->params['data'][$this->modelClass][$field['name'].'_year']); + unset($this->params['data'][$this->modelClass][$field['name'].'_month']); + unset($this->params['data'][$this->modelClass][$field['name'].'_day']); + unset($this->params['data'][$this->modelClass][$field['name'].'_hour']); + unset($this->params['data'][$this->modelClass][$field['name'].'_min']); + unset($this->params['data'][$this->modelClass][$field['name'].'_meridian']); + $this->params['data'][$this->modelClass][$field['name']] = $newDate; } - else if( 'datetime' == $field['type'] && isset($this->params['data'][$this->modelKey][$field['name'].'_year'] ) ) + else if( 'datetime' == $field['type'] && isset($this->params['data'][$this->modelClass][$field['name'].'_year'] ) ) { - $hour = $this->params['data'][$this->modelKey][$field['name'].'_hour']; - if( $hour != 12 && 'pm' == $this->params['data'][$this->modelKey][$field['name'].'_meridian'] ) + $hour = $this->params['data'][$this->modelClass][$field['name'].'_hour']; + if( $hour != 12 && 'pm' == $this->params['data'][$this->modelClass][$field['name'].'_meridian'] ) { $hour = $hour + 12; } - $newDate = $this->params['data'][$this->modelKey][$field['name'].'_year'].'-'; - $newDate .= $this->params['data'][$this->modelKey][$field['name'].'_month'].'-'; - $newDate .= $this->params['data'][$this->modelKey][$field['name'].'_day'].' '; - $newDate .= $hour.':'.$this->params['data'][$this->modelKey][$field['name'].'_min'].':00'; - unset($this->params['data'][$this->modelKey][$field['name'].'_year']); - unset($this->params['data'][$this->modelKey][$field['name'].'_month']); - unset($this->params['data'][$this->modelKey][$field['name'].'_day']); - unset($this->params['data'][$this->modelKey][$field['name'].'_hour']); - unset($this->params['data'][$this->modelKey][$field['name'].'_min']); - unset($this->params['data'][$this->modelKey][$field['name'].'_meridian']); - $this->params['data'][$this->modelKey][$field['name']] = $newDate; + $newDate = $this->params['data'][$this->modelClass][$field['name'].'_year'].'-'; + $newDate .= $this->params['data'][$this->modelClass][$field['name'].'_month'].'-'; + $newDate .= $this->params['data'][$this->modelClass][$field['name'].'_day'].' '; + $newDate .= $hour.':'.$this->params['data'][$this->modelClass][$field['name'].'_min'].':00'; + unset($this->params['data'][$this->modelClass][$field['name'].'_year']); + unset($this->params['data'][$this->modelClass][$field['name'].'_month']); + unset($this->params['data'][$this->modelClass][$field['name'].'_day']); + unset($this->params['data'][$this->modelClass][$field['name'].'_hour']); + unset($this->params['data'][$this->modelClass][$field['name'].'_min']); + unset($this->params['data'][$this->modelClass][$field['name'].'_meridian']); + $this->params['data'][$this->modelClass][$field['name']] = $newDate; } else if( 'tinyint(1)' == $field['type'] ) { - if( isset( $this->params['data'][$this->modelKey][$field['name']]) && - "on" == $this->params['data'][$this->modelKey][$field['name']] ) + if( isset( $this->params['data'][$this->modelClass][$field['name']]) && + "on" == $this->params['data'][$this->modelClass][$field['name']] ) { - $this->params['data'][$this->modelKey][$field['name']] = true; + $this->params['data'][$this->modelClass][$field['name']] = true; } else { - $this->params['data'][$this->modelKey][$field['name']] = false; + $this->params['data'][$this->modelClass][$field['name']] = false; } } } diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php index 8d878064c..2707c63ef 100644 --- a/cake/libs/controller/scaffold.php +++ b/cake/libs/controller/scaffold.php @@ -375,7 +375,7 @@ class Scaffold extends Object { } } } - else if($this->controllerClass->_scaffoldError('index') === false) + else if($this->controllerClass->_scaffoldError('update') === false) { return $this->__scaffoldError(); } diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 29d9d7305..df55724f3 100644 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -988,7 +988,7 @@ class DboSource extends DataSource { for ($i = 0; $i < $count; $i++) { - if(!preg_match('/^avg\\(|^count\\(|^count_big\\(|^min\\(|^max\\(|^distinct|^sum\\(|^concat\\(|^rand\\(|^stddev_pop|^var_pop|^least\\(|^greatest\\(|^octet_length\\(|^length\\(|^extract\\(^translate\\(|^conv\\(/i', $fields[$i])) + if(!preg_match('/^.+\\(.*\\)/', $fields[$i])) { $dot = strrpos($fields[$i], '.'); if ($dot === false) @@ -1082,49 +1082,32 @@ class DboSource extends DataSource { $data = ' '. $value; } - elseif (preg_match('/^(\\x20(?P[\\w]+|<=?|>=?|<>|!?=)\\x20)?(?P.*)/i', $value, $match)) + elseif (preg_match('/^(?P[a-z]*\\([a-z0-9]*\\)\\x20?|like\\x20?|or\\x20?|between\\x20?|[<>=!]{1,3}\\x20?)?(?P.*)/i', $value, $match)) { if (preg_match('/(?P\\x20[\\w]*\\x20)/', $key, $regs)) { - $operator = $regs['conditional']; + $clause = $regs['conditional']; $key = preg_replace('/'.$regs['conditional'].'/', '', $key); } if(empty($match['operator'])) { $match['operator'] = ' = '; } - if (strpos($match['value'], '--return') === 0) + + if (strpos($match['value'], '-!') === 0) { - $match['value'] = str_replace('--return', '', $match['value']); + $match['value'] = str_replace('-!', '', $match['value']); $data = $this->name($key) . ' '.$match['operator'].' '. $match['value']; } else { - $data = $this->name($key) . ' '.$match['operator'].' '. $this->value($match['value']); + if($match['value'] != '' && !is_numeric($match['value'])) + { + $match['value'] = $this->value($match['value']); + } + $data = $this->name($key) . ' '.$match['operator'].' '. $match['value']; } } - else - { - if (strpos($value, '--return') === 0) - { - $value = str_replace('--return', '', $value); - } - elseif (($value != '{$__cakeID__$}') && ($value != '{$__cakeForeignKey__$}')) - { - $value = $this->value($value); - } - - $data = $this->name($key) . ' = '; - - if ($value === null) - { - $data .= 'null'; - } - else - { - $data .= $value; - } - } $count++; $out[] = $operator.$data; } diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index 8f9428e8c..d9ed99537 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -282,7 +282,7 @@ class View extends Object return $this->pluginView($action, $layout); } - if (!is_file($viewFileName) && !fileExistsInPath($viewFileName) || $viewFileName === DS) + if (!is_file($viewFileName) && !fileExistsInPath($viewFileName) || $viewFileName === '/' || $viewFileName === '\\') { if (strpos($action, 'missingAction') !== false)