Merging fixes to trunk

Revision: [1786]
Little more cleaning up of the code

Revision: [1785]
Deleting old dbo files

Revision: [1784]
Adding [1780] fix lost in [1782]

Revision: [1783]
Added patch from Ticket #267.
Removed all debug output in the error views, this is moved to one error element that is loaded in View::renderLayout() if  DEBUG > 2.
Added fix to Ajax::dropRemote().

Revision: [1782]
Added controller dump view when DEBUG is set greater than 2

Revision: [1781]
Adding elements directory to the core

Revision: [1780]
Adding this to close Ticket #265

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1787 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2006-01-13 05:56:04 +00:00
parent 7eb2555405
commit d0b9721473
15 changed files with 153 additions and 808 deletions

View file

@ -6,4 +6,4 @@
// +---------------------------------------------------------------------------------------------------+ //
///////////////////////////////////////////////////////////////////////////////////////////////////////////
0.10.4.1701_beta
0.10.5.1787 RC 1

View file

@ -476,12 +476,10 @@ class Controller extends Object
function generateFieldNames( $data = null, $doCreateOptions = true )
{
$fieldNames = array();
$model = $this->modelClass;
$modelKey = $this->modelKey;
$table = $this->{$model}->table;
$association = array_search($table,$this->{$model}->alias);
$objRegistryModel = ClassRegistry::getObject($modelKey);
foreach ($objRegistryModel->_tableInfo as $tables)
@ -489,12 +487,10 @@ class Controller extends Object
foreach ($tables as $tabl)
{
$alias = null;
// set up the prompt
if ($objRegistryModel->isForeignKey($tabl['name']))
{
$niceName = substr( $tabl['name'], 0, strpos( $tabl['name'], "_id" ) );
$fieldNames[ $tabl['name'] ]['prompt'] = Inflector::humanize($niceName);
// this is a foreign key, also set up the other controller
$fieldNames[ $tabl['name'] ]['table'] = Inflector::pluralize($niceName);
$association = array_search($fieldNames[ $tabl['name'] ]['table'],$this->{$model}->alias);
if($this->{$model}->tableToModel[$fieldNames[ $tabl['name'] ]['table']] == $model)
@ -519,27 +515,16 @@ class Controller extends Object
{
$fieldNames[$tabl['name']]['prompt'] = 'Modified';
}
// Now, set up some other attributes that will be useful for auto generating a form.
//tagName is in the format table/field "post/title"
$fieldNames[ $tabl['name']]['tagName'] = $model.'/'.$tabl['name'];
// Now, find out if this is a required field.
//$validationFields = ClassRegistry::getObject($table)->validate;
$fieldNames[ $tabl['name']]['tagName'] = $model.'/'.$tabl['name'];
$validationFields = $objRegistryModel->validate;
if( isset( $validationFields[ $tabl['name'] ] ) )
{
// Now, we know that this field has some validation set.
// find out if it is a required field.
if( VALID_NOT_EMPTY == $validationFields[ $tabl['name'] ] )
{
// this is a required field.
$fieldNames[$tabl['name']]['required'] = true;
$fieldNames[$tabl['name']]['errorMsg'] = "Required Field";
}
}
// now, determine what the input type should be for this database field.
$lParenPos = strpos( $tabl['type'], '(');
$rParenPos = strpos( $tabl['type'], ')');
if( false != $lParenPos )
@ -553,26 +538,17 @@ class Controller extends Object
}
switch( $type )
{
case "text":
case "mediumtext":
{
$fieldNames[ $tabl['name']]['type'] = 'area';
//$fieldNames[ $tabl['name']]['size'] = $fieldLength;
}
break;
case "varchar":
case "char":
{
if (isset($fieldNames[ $tabl['name']]['foreignKey']))
{
$fieldNames[ $tabl['name']]['type'] = 'select';
// This is a foreign key select dropdown box. now, we have to add the options.
$fieldNames[ $tabl['name']]['options'] = array();
// get the list of options from the other model.
$otherModel = ClassRegistry::getObject(Inflector::underscore($fieldNames[$tabl['name']]['modelKey']));
if (is_object($otherModel))
{
if ($doCreateOptions)
@ -582,7 +558,6 @@ class Controller extends Object
{
foreach ($pass as $key => $value)
{
if($alias.$key == $this->{$model}->tableToModel[$fieldNames[ $tabl['name'] ]['table']] && isset( $value['id'] ) && isset( $value[$otherDisplayField]))
{
$fieldNames[ $tabl['name']]['options'][$value['id']] = $value[$otherDisplayField];
@ -597,19 +572,17 @@ class Controller extends Object
{
$fieldNames[ $tabl['name']]['type'] = 'input';
}
}
break;
case "tinyint":
{
if( $fieldLength > 1 )
{
$fieldNames[ $tabl['name']]['type'] = 'input';
}
else
{
$fieldNames[ $tabl['name']]['type'] = 'checkbox';
}
}
if( $fieldLength > 1 )
{
$fieldNames[ $tabl['name']]['type'] = 'input';
}
else
{
$fieldNames[ $tabl['name']]['type'] = 'checkbox';
}
break;
case "int":
case "smallint":
@ -618,11 +591,6 @@ class Controller extends Object
case "decimal":
case "float":
case "double":
{
//BUGBUG: Need a better way to determine if this field is an auto increment foreign key.
// If it is a number, and it is a foreign key, we'll make a HUGE assumption that it is an auto increment field.
// for foreign key autonumber fields, we'll set the type to 'key' so that it does not display in the input form.
$charCount = strlen($this->$model->primaryKey);
if(0 == strncmp($tabl['name'], $this->$model->primaryKey, $charCount))
{
@ -631,12 +599,8 @@ class Controller extends Object
else if( isset( $fieldNames[ $tabl['name']]['foreignKey'] ) )
{
$fieldNames[ $tabl['name']]['type'] = 'select';
// This is a foreign key select dropdown box. now, we have to add the options.
$fieldNames[ $tabl['name']]['options'] = array();
// get the list of options from the other model.
$otherModel = ClassRegistry::getObject(Inflector::underscore($fieldNames[$tabl['name']]['modelKey']));
if( is_object($otherModel) )
{
if( $doCreateOptions )
@ -660,15 +624,10 @@ class Controller extends Object
{
$fieldNames[ $tabl['name']]['type'] = 'input';
}
}
break;
case "enum":
{
// for enums, the $fieldLength variable is actually the list of enums.
$fieldNames[ $tabl['name']]['type'] = 'select';
// This is a foreign key select dropdown box. now, we have to add the options.
$fieldNames[ $tabl['name']]['options'] = array();
$enumValues = split(',', $fieldLength );
foreach ($enumValues as $enum )
{
@ -676,73 +635,60 @@ class Controller extends Object
$fieldNames[$tabl['name']]['options'][$enum] = $enum;
}
$fieldNames[ $tabl['name']]['selected'] = $data[$model][$tabl['name']];
}
break;
case "date":
case "datetime":
{
if(0 != strncmp( "created", $tabl['name'], 6 ) && 0 != strncmp("modified",$tabl['name'], 8))
{
$fieldNames[ $tabl['name']]['type'] = $type;
}
if(isset($data[$model][$tabl['name']]))
{
$fieldNames[ $tabl['name']]['selected'] = $data[$model][$tabl['name']];
}
else
{
$ieldNames[ $tabl['name']]['selected'] = null;
}
}
break;
default:
//sorry, this database field type is not yet set up.
break;
} // end switch
}
// now, add any necessary hasAndBelongsToMany list boxes
// loop through the many to many relations to make a list box.
foreach($objRegistryModel->hasAndBelongsToMany as $relation => $relData)
{
$modelName = $relData['className'];
$manyAssociation = $relation;
$modelKeyM = Inflector::underscore($modelName);
$modelObject = new $modelName();
if($doCreateOptions)
{
$otherDisplayField = $modelObject->getDisplayField();
$fieldNames[$modelKeyM]['model'] = $modelName;
$fieldNames[$modelKeyM]['prompt'] = "Related ".Inflector::humanize(Inflector::pluralize($modelName));
$fieldNames[$modelKeyM]['type'] = "selectMultiple";
$fieldNames[$modelKeyM]['tagName'] = $manyAssociation.'/'.$manyAssociation;
foreach($modelObject->findAll() as $pass)
{
foreach($pass as $key=>$value)
{
if($key == $modelName && isset($value[$modelObject->primaryKey]) && isset( $value[$otherDisplayField]))
{
$fieldNames[$modelKeyM]['options'][$value[$modelObject->primaryKey]] = $value[$otherDisplayField];
}
}
}
if( isset( $data[$manyAssociation] ) )
{
foreach( $data[$manyAssociation] as $key => $row )
break;
case "date":
case "datetime":
if(0 != strncmp( "created", $tabl['name'], 6 ) && 0 != strncmp("modified",$tabl['name'], 8))
{
$fieldNames[ $tabl['name']]['type'] = $type;
}
if(isset($data[$model][$tabl['name']]))
{
$fieldNames[ $tabl['name']]['selected'] = $data[$model][$tabl['name']];
}
else
{
$fieldNames[ $tabl['name']]['selected'] = null;
}
break;
default:
break;
}
}
foreach($objRegistryModel->hasAndBelongsToMany as $relation => $relData)
{
$modelName = $relData['className'];
$manyAssociation = $relation;
$modelKeyM = Inflector::underscore($modelName);
$modelObject = new $modelName();
if($doCreateOptions)
{
$otherDisplayField = $modelObject->getDisplayField();
$fieldNames[$modelKeyM]['model'] = $modelName;
$fieldNames[$modelKeyM]['prompt'] = "Related ".Inflector::humanize(Inflector::pluralize($modelName));
$fieldNames[$modelKeyM]['type'] = "selectMultiple";
$fieldNames[$modelKeyM]['tagName'] = $manyAssociation.'/'.$manyAssociation;
foreach($modelObject->findAll() as $pass)
{
$fieldNames[$modelKeyM]['selected'][$row[$modelObject->primaryKey]] = $row[$modelObject->primaryKey];
foreach($pass as $key=>$value)
{
if($key == $modelName && isset($value[$modelObject->primaryKey]) && isset( $value[$otherDisplayField]))
{
$fieldNames[$modelKeyM]['options'][$value[$modelObject->primaryKey]] = $value[$otherDisplayField];
}
}
}
}
}
} // end loop through manytomany relations.
if( isset( $data[$manyAssociation] ) )
{
foreach( $data[$manyAssociation] as $key => $row )
{
$fieldNames[$modelKeyM]['selected'][$row[$modelObject->primaryKey]] = $row[$modelObject->primaryKey];
}
}
}
}
}
return $fieldNames;
return $fieldNames;
}
}
?>

View file

@ -120,11 +120,6 @@ class DboSource extends DataSource
$this->numRows = $this->lastNumRows($this->_result);
$this->logQuery($sql);
if (($this->debug && $this->error) || ($this->fullDebug))
{
$this->showQuery($sql);
}
if ($this->error)
{
return false;
@ -233,7 +228,15 @@ class DboSource extends DataSource
sortByKey($this->_queriesLog, 'took', 'desc', SORT_NUMERIC):
$this->_queriesLog;
print("<table border=1>\n<tr><th colspan=7>{$this->_queriesCnt} queries took {$this->_queriesTime} ms</th></tr>\n");
if($this->_queriesCnt >1)
{
$text = 'queries';
}
else
{
$text = 'query';
}
print("<table border=1>\n<tr><th colspan=7>{$this->_queriesCnt} {$text} took {$this->_queriesTime} ms</th></tr>\n");
print("<tr><td>Nr</td><td>Query</td><td>Error</td><td>Affected</td><td>Num. rows</td><td>Took (ms)</td></tr>\n");
foreach($log AS $k=>$i)
@ -680,7 +683,7 @@ class DboSource extends DataSource
function conditions ($conditions)
{
$rt = '';
if (!strpos(low($conditions), 'where') || strpos(low($conditions), 'where') === 0)
if (!is_array($conditions) && (!strpos(low($conditions), 'where') || strpos(low($conditions), 'where') === 0))
{
$rt = ' WHERE ';
}
@ -698,17 +701,31 @@ class DboSource extends DataSource
$out = array();
foreach ($conditions as $key => $value)
{
$slashedValue = $this->value($value);
//TODO: Remove the = below so LIKE and other compares can be used
$data = $key . '=';
if ($value === null)
{
$data .= 'null';
}
else
{
$data = $slashedValue;
}
// Treat multiple values as an IN condition.
if (is_array($value))
{
$data = $key . ' IN (';
foreach ($value as $valElement)
{
$data .= $this->value($valElement) . ', ';
}
// Remove trailing ',' and complete clause.
$data[strlen($data)-2] = ')';
}
else
{
$slashedValue = $this->value($value);
//TODO: Remove the = below so LIKE and other compares can be used
$data = $key . '=';
if ($value === null)
{
$data .= 'null';
}
else
{
$data .= $slashedValue;
}
}
$out[] = $data;
}
return ' WHERE ' . join(' AND ', $out);
@ -776,4 +793,4 @@ class DboSource extends DataSource
}
?>
?>

View file

@ -1,474 +0,0 @@
<?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) 2005, 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) 2005, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.cake.libs.model.dbo
* @since CakePHP v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Enter description here...
*
*/
if(!class_exists('Object'))
{
uses('object');
}
/**
* Purpose: DBO/ADO
*
* Description:
* A SQL functions wrapper. Provides ability to get results as arrays
* and query logging (with execution time).
*
* Example usage:
*
* <code>
* require_once('dbo_mysql.php'); // or 'dbo_postgres.php'
*
* // create and connect the object
* $db = new DBO_MySQL(array( // or 'DBO_Postgres'
* 'host'=>'localhost',
* 'login'=>'username',
* 'password'=>'password',
* 'database'=>'database'));
*
* // read the whole query result array (of rows)
* $all_rows = $db->all("SELECT a,b,c FROM table");
*
* // read the first row with debugging on
* $first_row_only = $db->one("SELECT a,b,c FROM table WHERE a=1", TRUE);
*
* // emulate the usual way of reading query results
* if ($db->query("SELECT a,b,c FROM table"))
* {
* while ( $row = $db->farr() )
* {
* print $row['a'].$row['b'].$row['c'];
* }
* }
*
* // show a log of all queries, sorted by execution time
* $db->showLog(TRUE);
* </code>
*
* @package cake
* @subpackage cake.cake.libs.model.dbo
* @since CakePHP v 0.2.9
*/
class DBO extends Object
{
/**
* Are we connected to the database?
*
* @var boolean
* @access public
*/
var $connected=FALSE;
/**
* Connection configuration.
*
* @var array
* @access public
*/
var $config=FALSE;
/**
* Enter description here...
*
* @var boolean
* @access public
*/
var $debug=FALSE;
/**
* Enter description here...
*
* @var boolean
* @access public
*/
var $fullDebug=FALSE;
/**
* Enter description here...
*
* @var unknown_type
* @access public
*/
var $error=NULL;
/**
* String to hold how many rows were affected by the last SQL operation.
*
* @var unknown_type
* @access public
*/
var $affected=NULL;
/**
* Number of rows in current resultset
*
* @var int
* @access public
*/
var $numRows=NULL;
/**
* Time the last query took
*
* @var unknown_type
* @access public
*/
var $took=NULL;
/**
* Enter description here...
*
* @var unknown_type
* @access private
*/
var $_conn=NULL;
/**
* Enter description here...
*
* @var unknown_type
* @access private
*/
var $_result=NULL;
/**
* Queries count.
*
* @var unknown_type
* @access private
*/
var $_queriesCnt=0;
/**
* Total duration of all queries.
*
* @var unknown_type
* @access private
*/
var $_queriesTime=NULL;
/**
* Enter description here...
*
* @var unknown_type
* @access private
*/
var $_queriesLog=array();
/**
* Maximum number of items in query log, to prevent query log taking over
* too much memory on large amounts of queries -- I we've had problems at
* >6000 queries on one system.
*
* @var int Maximum number of queries in the queries log.
* @access private
*/
var $_queriesLogMax=200;
/**
* Constructor. Sets the level of debug for dbo (fullDebug or debug).
*
* @param array $config
* @return unknown
*/
function __construct($config=NULL)
{
$this->debug = DEBUG > 0;
$this->fullDebug = DEBUG > 1;
parent::__construct();
return $this->connect($config);
}
/**
* Destructor. Closes connection to the database.
*
*/
function __destruct()
{
$this->close();
}
/**
* Returns a string with a USE [databasename] SQL statement.
*
* @param string $db_name Name of database to use
* @return unknown Result of the query
*/
function useDb($db_name)
{
return $this->query("USE {$db_name}");
}
/**
* Disconnects database, kills the connection and says the connection is closed, and if DEBUG is turned on, the log for this object is shown.
*
*/
function close ()
{
if ($this->fullDebug) $this->showLog();
$this->disconnect();
$this->_conn = NULL;
$this->connected = false;
}
/**
* Prepares a value, or an array of values for database queries by quoting and escaping them.
*
* @param mixed $data A value or an array of values to prepare.
* @return mixed Prepared value or array of values.
*/
function prepare ($data)
{
if (is_array($data))
{
$out = null;
foreach ($data as $key=>$item)
{
$out[$key] = $this->value($item);
}
return $out;
}
else
{
return $this->value($data);
}
}
function tables()
{
return array_map('strtolower', $this->tablesList());
}
/**
* Executes given SQL statement.
*
* @param string $sql SQL statement
* @return unknown
*/
function rawQuery ($sql)
{
$this->took = $this->error = $this->numRows = false;
return $this->execute($sql);
}
/**
* Queries the database with given SQL statement, and obtains some metadata about the result
* (rows affected, timing, any errors, number of rows in resultset). The query is also logged.
* If DEBUG is set, the log is shown all the time, else it is only shown on errors.
*
* @param string $sql
* @return unknown
*/
function query($sql)
{
$t = getMicrotime();
$this->_result = $this->execute($sql);
$this->affected = $this->lastAffected();
$this->took = round((getMicrotime()-$t)*1000, 0);
$this->error = $this->lastError();
$this->numRows = $this->lastNumRows($this->_result);
$this->logQuery($sql);
if (($this->debug && $this->error) || ($this->fullDebug))
$this->showQuery($sql);
return $this->error? false: $this->_result;
}
/**
* Returns a single row of results from the _last_ SQL query.
*
* @param resource $res
* @return array A single row of results
*/
function farr ($assoc=false)
{
if ($assoc === false)
{
return $this->fetchRow();
}
else
{
return $this->fetchRow($assoc);
}
}
/**
* Returns a single row of results for a _given_ SQL query.
*
* @param string $sql SQL statement
* @return array A single row of results
*/
function one ($sql)
{
return $this->query($sql)? $this->farr(): false;
}
/**
* Returns an array of all result rows for a given SQL query.
* Returns false if no rows matched.
*
* @param string $sql SQL statement
* @return array Array of resultset rows, or false if no rows matched
*/
function all ($sql)
{
if($this->query($sql))
{
$out=array();
while ($item = $this->farr(null, true))
{
$out[] = $item;
}
return $out;
}
else
{
return false;
}
}
/**
* Returns a single field of the first of query results for a given SQL query, or false if empty.
*
* @param string $name Name of the field
* @param string $sql SQL query
* @return unknown
*/
function field ($name, $sql)
{
$data = $this->one($sql);
return empty($data[$name])? false: $data[$name];
}
/**
* Checks if the specified table contains any record matching specified SQL
*
* @param string $table Name of table to look in
* @param string $sql SQL WHERE clause (condition only, not the "WHERE" part)
* @return boolean True if the table has a matching record, else false
*/
function hasAny($table, $sql)
{
$out = $this->one("SELECT COUNT(*) AS count FROM {$table}".($sql? " WHERE {$sql}":""));
return is_array($out)? $out[0]['count']: false;
}
/**
* Checks if it's connected to the database
*
* @return boolean True if the database is connected, else false
*/
function isConnected()
{
return $this->connected;
}
/**
* Outputs the contents of the log.
*
* @param boolean $sorted
*/
function showLog($sorted=false)
{
$log = $sorted?
sortByKey($this->_queriesLog, 'took', 'desc', SORT_NUMERIC):
$this->_queriesLog;
print("<table border=1>\n<tr><th colspan=7>{$this->_queriesCnt} queries took {$this->_queriesTime} ms</th></tr>\n");
print("<tr><td>Nr</td><td>Query</td><td>Error</td><td>Affected</td><td>Num. rows</td><td>Took (ms)</td></tr>\n");
foreach($log AS $k=>$i)
{
print("<tr><td>".($k+1)."</td><td>{$i['query']}</td><td>{$i['error']}</td><td align='right'>{$i['affected']}</td><td align='right'>{$i['numRows']}</td><td align='right'>{$i['took']}</td></tr>\n");
}
print("</table>\n");
}
/**
* Log given SQL query.
*
* @param string $sql SQL statement
*/
function logQuery($sql)
{
$this->_queriesCnt++;
$this->_queriesTime += $this->took;
$this->_queriesLog[] = array(
'query'=>$sql,
'error'=>$this->error,
'affected'=>$this->affected,
'numRows'=>$this->numRows,
'took'=>$this->took
);
if (count($this->_queriesLog) > $this->_queriesLogMax)
{
array_pop($this->_queriesLog);
}
if ($this->error)
return false; // shouldn't we be logging errors somehow?
}
/**
* Output information about an SQL query. The SQL statement, number of rows in resultset,
* and execution time in microseconds. If the query fails, and error is output instead.
*
* @param string $sql
*/
function showQuery($sql)
{
$error = $this->error;
if (strlen($sql)>200 && !$this->fullDebug)
{
$sql = substr($sql, 0, 200) .'[...]';
}
if ($this->debug || $error)
{
print("<p style=\"text-align:left\"><b>Query:</b> {$sql} <small>[Aff:{$this->affected} Num:{$this->numRows} Took:{$this->took}ms]</small>");
if($error)
{
print("<br /><span style=\"color:Red;text-align:left\"><b>ERROR:</b> {$this->error}</span>");
}
print('</p>');
}
}
}
?>

View file

@ -1,134 +0,0 @@
<?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) 2005, 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) 2005, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.cake.libs.model.dbo
* @since CakePHP v 0.10.0.1076
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Enter description here...
*
*/
if(!class_exists('Object'))
{
uses('object');
}
/**
* Enter description here...
*
*/
if (!class_exists('DATABASE_CONFIG'))
{
config('database');
}
/**
* DbFactory
*
* Creates DBO-descendant objects from a given db connection configuration
*
* @package cake
* @subpackage cake.cake.libs.model.dbo
* @since CakePHP v 0.10.0.1076
*
*/
class DboFactory extends Object
{
/**
* A semi-singelton. Returns actual instance, or creates a new one with given config.
*
* @param string $config Name of key of $dbConfig array to be used.
* @return mixed
*/
function getInstance($config = null)
{
$configName = $config;
static $instance = array();
if ($configName == null && !empty($instance))
{
return $instance["default"];
}
else if ($configName == null && empty($instance))
{
return false;
}
if (!key_exists($configName, $instance))
{
$configs = get_class_vars('DATABASE_CONFIG');
$config = $configs[$configName];
// special case for AdoDB -- driver name in the form of 'adodb-drivername'
if (preg_match('#^adodb[\-_](.*)$#i', $config['driver'], $res))
{
uses('model'.DS.'dbo'.DS.'dbo_adodb');
$config['driver'] = $res[1];
$instance[$configName] =& new DBO_AdoDB($config);
}
// special case for PEAR:DB -- driver name in the form of 'pear-drivername'
elseif (preg_match('#^pear[\-_](.*)$#i', $config['driver'], $res))
{
uses('model'.DS.'dbo'.DS.'dbo_pear');
$config['driver'] = $res[1];
$instance[$configName] =& new DBO_Pear($config);
}
// regular, Cake-native db drivers
else
{
$db_driver_class = 'DBO_'.$config['driver'];
$db_driver_fn = LIBS.strtolower('model'.DS.'dbo'.DS.$db_driver_class.'.php');
if (file_exists($db_driver_fn))
{
uses(strtolower('model'.DS.'dbo'.DS.$db_driver_class));
$instance[$configName] =& new $db_driver_class($config);
}
else
{
return false;
}
}
}
return $instance[$configName];
}
/**
* Sets config to use. If there is already a connection, close it first.
*
* @param string $configName Name of the config array key to use.
* @return mixed
*/
function setConfig($config)
{
$db = DboFactory::getInstance();
if ($db->isConnected() === true)
{
$db->close();
}
return $this->getInstance($config);
}
}
?>

View file

@ -464,6 +464,8 @@ class AjaxHelper extends Helper
function dropRemote($id, $options = array(), $ajaxOptions = array())
{
$options['onDrop'] = "function(element){" . $this->remoteFunction($ajaxOptions) . "}";
$options = $this->_optionsForDroppable($options);
return $this->Javascript->codeBlock("Droppables.add('$id'$options);");
}
/**

View file

@ -0,0 +1,36 @@
<?php
/* SVN FILE: $Id$ */
/**
*
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, 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) 2005, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.cake.libs.view.templates.pages
* @since CakePHP v 0.10.5.1782
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
?>
<div>
<h2>Controller dump:</h2>
<pre>
<?php print_r($this->controller); ?>
</pre>
</div>

View file

@ -60,14 +60,4 @@ in file : <?php echo "app".DS."controllers".DS.Inflector::underscore($controller
<p>
<strong>Error</strong>: Unable to execute action <em><?php echo $action;?></em> in
<em><?php echo $controller;?></em>
</p>
<?php if (DEBUG>1):?>
<h2>Controller dump:</h2>
<pre>
<?php
unset($this->db);
print_r($this);
?>
</pre>
<?php endif;?>
</p>

View file

@ -36,12 +36,4 @@
<p>
<span class="notice"><strong>Notice:</strong> this error is being rendered by the <code>app/views/errors/missing_database.thtml</code>
view file, a user-customizable error page for handling errors within CakePHP.</span>
</p>
<?php if (DEBUG > 1) { ?>
<h2>Controller dump:</h2>
<?php
unset($this->db);
pr($this);
?>
<?php } ?>
</p>

View file

@ -62,14 +62,4 @@ in file : <?php echo "app".DS."views".DS."helpers".DS.$missingFile.".php"; ?>
<p>
<strong>Error</strong>: Unable to load helper class <em><?php echo $missingClass;?></em> in
<em>View::_loadHelpers</em>
</p>
<?php if (DEBUG>1):?>
<h2>Controller dump:</h2>
<pre>
<?php
unset($this->db);
print_r($this);
?>
</pre>
<?php endif;?>
</p>

View file

@ -62,14 +62,4 @@ in file : <?php echo "app".DS."views".DS."helpers".DS.$missingFile.".php"; ?>
<p>
<strong>Error</strong>: Unable to load helper file <em><?php echo $missingFile.".php";?></em> in
<em>View::_loadHelpers</em>
</p>
<?php if (DEBUG>1):?>
<h2>Controller dump:</h2>
<pre>
<?php
unset($this->db);
print_r($this);
?>
</pre>
<?php endif;?>
</p>

View file

@ -36,14 +36,4 @@
<p>
<span class="notice"><strong>Notice:</strong> this error is being rendered by the <code>app/views/errors/missing_database.thtml</code>
view file, a user-customizable error page for handling errors within CakePHP.</span>
</p>
<?php if (DEBUG>1):?>
<h2>Controller dump:</h2>
<pre>
<?php
unset($this->db);
print_r($this);
?>
</pre>
<?php endif;?>
</p>

View file

@ -43,14 +43,4 @@ view file, a user-customizable error page for handling missing/invalid views dur
<p>
<strong>Fatal</strong>: Unable to load view file <em><?php echo $this->missingView;?></em> for
action <em><?php echo $this->missingView;?>::<?php echo $action;?></em>
</p>
<?php if (DEBUG>1):?>
<h2>Controller dump:</h2>
<pre>
<?php
unset($this->db);
print_r($this);
?>
</pre>
<?php endif;?>
</p>

View file

@ -45,6 +45,7 @@
<?php if (isset($this->controller->Session)) $this->controller->Session->flash(); ?>
<?php echo $content_for_layout?>
</div>
<?php echo $cakeDebug;?>
<div id="footer">
<p>CakePHP ::
<a href="http://www.cakefoundation.org/pages/copyright/">&copy; 2005 Cake Software Foundation, Inc.</a>

View file

@ -398,9 +398,18 @@ class View extends Object
{
$layout_fn = $this->_getLayoutFileName();
if(DEBUG > 2)
{
$debug = View::_render(LIBS.'view'.DS.'templates'.DS.'elements'.DS.'dump.thtml', array('controller' => $this->controller), true, false);
}
else
{
$debug = '';
}
$data_for_layout = array_merge($this->_viewVars, array(
'title_for_layout'=>$this->pageTitle !== false? $this->pageTitle: Inflector::humanize($this->viewPath),
'content_for_layout'=>$content_for_layout));
'content_for_layout'=>$content_for_layout,
'cakeDebug' => $debug));
if (is_file($layout_fn))
{