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
This commit is contained in:
phpnut 2006-02-25 04:42:31 +00:00
parent a1170b57d4
commit 7a9fff407a
8 changed files with 115 additions and 76 deletions

View file

@ -6,4 +6,4 @@
// +---------------------------------------------------------------------------------------------------+ //
///////////////////////////////////////////////////////////////////////////////////////////////////////////
0.10.8.2114
0.10.8.2121

42
app/config/bootstrap.php Normal file
View file

@ -0,0 +1,42 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* 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
?>

View file

@ -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')
{

View file

@ -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 '<div class="message">'.$this->read('Message.flash').'</div>';
$this->del('Message.flash');
if($return === false)
{
echo '<div class="'.$css.'">'.$this->read('Message.flash').'</div>';
$this->del('Message.flash');
return;
}
else
{
$return = $this->read('Message.flash');
$this->del('Message.flash');
return $return;
}
}
else
{
return false;
}
}
/**

View file

@ -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;
}
}
}

View file

@ -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();
}

View file

@ -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<operator>[\\w]+|<=?|>=?|<>|!?=)\\x20)?(?P<value>.*)/i', $value, $match))
elseif (preg_match('/^(?P<operator>[a-z]*\\([a-z0-9]*\\)\\x20?|like\\x20?|or\\x20?|between\\x20?|[<>=!]{1,3}\\x20?)?(?P<value>.*)/i', $value, $match))
{
if (preg_match('/(?P<conditional>\\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;
}

View file

@ -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)