mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch '1.3-misc' of dev@code.cakephp.org:cakephp into 1.3-misc
This commit is contained in:
commit
20fa1c9693
18 changed files with 346 additions and 110 deletions
|
@ -24,6 +24,7 @@
|
|||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
|
||||
/**
|
||||
* CakePHP Debug Level:
|
||||
*
|
||||
|
@ -39,10 +40,27 @@
|
|||
* In development mode, you need to click the flash message to continue.
|
||||
*/
|
||||
Configure::write('debug', 2);
|
||||
|
||||
/**
|
||||
* CakePHP Log Level:
|
||||
*
|
||||
* In case of Production Mode CakePHP gives you the possibility to continue logging errors.
|
||||
*
|
||||
* The following parameters can be used:
|
||||
* Boolean: Set true/false to activate/deactivate logging
|
||||
* Configure::write('log', true);
|
||||
*
|
||||
* Integer: Use built-in PHP constants to set the error level (see error_reporting)
|
||||
* Configure::write('log', E_ERROR | E_WARNING);
|
||||
* Configure::write('log', E_ALL ^ E_NOTICE);
|
||||
*/
|
||||
Configure::write('log', true);
|
||||
|
||||
/**
|
||||
* Application wide charset encoding
|
||||
*/
|
||||
Configure::write('App.encoding', 'UTF-8');
|
||||
|
||||
/**
|
||||
* To configure CakePHP *not* to use mod_rewrite and to
|
||||
* use CakePHP pretty URLs, remove these .htaccess
|
||||
|
@ -55,6 +73,7 @@
|
|||
* And uncomment the App.baseUrl below:
|
||||
*/
|
||||
//Configure::write('App.baseUrl', env('SCRIPT_NAME'));
|
||||
|
||||
/**
|
||||
* Uncomment the define below to use CakePHP admin routes.
|
||||
*
|
||||
|
@ -71,6 +90,7 @@
|
|||
*
|
||||
*/
|
||||
//Configure::write('Cache.disable', true);
|
||||
|
||||
/**
|
||||
* Enable cache checking.
|
||||
*
|
||||
|
@ -81,11 +101,13 @@
|
|||
*
|
||||
*/
|
||||
//Configure::write('Cache.check', true);
|
||||
|
||||
/**
|
||||
* Defines the default error type when using the log() function. Used for
|
||||
* differentiating error logging and debugging. Currently PHP supports LOG_DEBUG.
|
||||
*/
|
||||
define('LOG_ERROR', 2);
|
||||
|
||||
/**
|
||||
* The preferred session handling method. Valid values:
|
||||
*
|
||||
|
@ -101,6 +123,7 @@
|
|||
*
|
||||
*/
|
||||
Configure::write('Session.save', 'php');
|
||||
|
||||
/**
|
||||
* The model name to be used for the session model.
|
||||
*
|
||||
|
@ -109,6 +132,7 @@
|
|||
* The model name set here should *not* be used elsewhere in your application.
|
||||
*/
|
||||
//Configure::write('Session.model', 'Session');
|
||||
|
||||
/**
|
||||
* The name of the table used to store CakePHP database sessions.
|
||||
*
|
||||
|
@ -122,30 +146,36 @@
|
|||
* [Note: Session.table is deprecated as of CakePHP 1.3]
|
||||
*/
|
||||
//Configure::write('Session.table', 'cake_sessions');
|
||||
|
||||
/**
|
||||
* The DATABASE_CONFIG::$var to use for database session handling.
|
||||
*
|
||||
* 'Session.save' must be set to 'database' in order to utilize this constant.
|
||||
*/
|
||||
//Configure::write('Session.database', 'default');
|
||||
|
||||
/**
|
||||
* The name of CakePHP's session cookie.
|
||||
*/
|
||||
Configure::write('Session.cookie', 'CAKEPHP');
|
||||
|
||||
/**
|
||||
* Session time out time (in seconds).
|
||||
* Actual value depends on 'Security.level' setting.
|
||||
*/
|
||||
Configure::write('Session.timeout', '120');
|
||||
|
||||
/**
|
||||
* If set to false, sessions are not automatically started.
|
||||
*/
|
||||
Configure::write('Session.start', true);
|
||||
|
||||
/**
|
||||
* When set to false, HTTP_USER_AGENT will not be checked
|
||||
* in the session
|
||||
*/
|
||||
Configure::write('Session.checkAgent', true);
|
||||
|
||||
/**
|
||||
* The level of CakePHP security. The session timeout time defined
|
||||
* in 'Session.timeout' is multiplied according to the settings here.
|
||||
|
@ -159,10 +189,12 @@
|
|||
* 'Security.level' is set to 'high'.
|
||||
*/
|
||||
Configure::write('Security.level', 'high');
|
||||
|
||||
/**
|
||||
* A random string used in security hashing methods.
|
||||
*/
|
||||
Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');
|
||||
|
||||
/**
|
||||
* Compress CSS output by removing comments, whitespace, repeating tags, etc.
|
||||
* This requires a/var/cache directory to be writable by the web server for caching.
|
||||
|
@ -171,6 +203,7 @@
|
|||
* To use, prefix the CSS link URL with '/ccss/' instead of '/css/' or use HtmlHelper::css().
|
||||
*/
|
||||
//Configure::write('Asset.filter.css', 'css.php');
|
||||
|
||||
/**
|
||||
* Plug in your own custom JavaScript compressor by dropping a script in your webroot to handle the
|
||||
* output, and setting the config below to the name of the script.
|
||||
|
@ -178,17 +211,20 @@
|
|||
* To use, prefix your JavaScript link URLs with '/cjs/' instead of '/js/' or use JavaScriptHelper::link().
|
||||
*/
|
||||
//Configure::write('Asset.filter.js', 'custom_javascript_output_filter.php');
|
||||
|
||||
/**
|
||||
* The classname and database used in CakePHP's
|
||||
* access control lists.
|
||||
*/
|
||||
Configure::write('Acl.classname', 'DbAcl');
|
||||
Configure::write('Acl.database', 'default');
|
||||
|
||||
/**
|
||||
* If you are on PHP 5.3 uncomment this line and correct your server timezone
|
||||
* to fix the date & time related errors.
|
||||
*/
|
||||
//date_default_timezone_set('UTC');
|
||||
|
||||
/**
|
||||
*
|
||||
* Cache Engine Configuration
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
|
||||
/**
|
||||
* This is core configuration file.
|
||||
*
|
||||
|
@ -42,6 +41,21 @@
|
|||
*/
|
||||
Configure::write('debug', 2);
|
||||
|
||||
/**
|
||||
* CakePHP Log Level:
|
||||
*
|
||||
* In case of Production Mode CakePHP gives you the possibility to continue logging errors.
|
||||
*
|
||||
* The following parameters can be used:
|
||||
* Boolean: Set true/false to activate/deactivate logging
|
||||
* Configure::write('log', true);
|
||||
*
|
||||
* Integer: Use built-in PHP constants to set the error level (see error_reporting)
|
||||
* Configure::write('log', E_ERROR | E_WARNING);
|
||||
* Configure::write('log', E_ALL ^ E_NOTICE);
|
||||
*/
|
||||
Configure::write('log', true);
|
||||
|
||||
/**
|
||||
* Application wide charset encoding
|
||||
*/
|
||||
|
@ -104,17 +118,32 @@
|
|||
* To define a custom session handler, save it at /app/config/<name>.php.
|
||||
* Set the value of 'Session.save' to <name> to utilize it in CakePHP.
|
||||
*
|
||||
* To use database sessions, execute the SQL file found at /app/config/sql/sessions.sql.
|
||||
* To use database sessions, run the app/config/schema/sessions.php schema using
|
||||
* the cake shell command: cake schema run create Sessions
|
||||
*
|
||||
*/
|
||||
Configure::write('Session.save', 'php');
|
||||
|
||||
/**
|
||||
* The model name to be used for the session model.
|
||||
*
|
||||
* 'Session.save' must be set to 'database' in order to utilize this constant.
|
||||
*
|
||||
* The model name set here should *not* be used elsewhere in your application.
|
||||
*/
|
||||
//Configure::write('Session.model', 'Session');
|
||||
|
||||
/**
|
||||
* The name of the table used to store CakePHP database sessions.
|
||||
*
|
||||
* 'Session.save' must be set to 'database' in order to utilize this constant.
|
||||
*
|
||||
* The table name set here should *not* include any table prefix defined elsewhere.
|
||||
*
|
||||
* Please note that if you set a value for Session.model (above), any value set for
|
||||
* Session.table will be ignored.
|
||||
*
|
||||
* [Note: Session.table is deprecated as of CakePHP 1.3]
|
||||
*/
|
||||
//Configure::write('Session.table', 'cake_sessions');
|
||||
|
||||
|
@ -195,6 +224,7 @@
|
|||
* to fix the date & time related errors.
|
||||
*/
|
||||
//date_default_timezone_set('UTC');
|
||||
|
||||
/**
|
||||
*
|
||||
* Cache Engine Configuration
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
|
||||
/**
|
||||
* Logging.
|
||||
*
|
||||
|
@ -9,20 +7,17 @@
|
|||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
|
||||
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
|
||||
|
@ -102,5 +97,52 @@ class CakeLog {
|
|||
return $log->append($output);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An error_handler that will log errors to file using CakeLog::write();
|
||||
*
|
||||
* @param integer $code Code of error
|
||||
* @param string $description Error description
|
||||
* @param string $file File on which error occurred
|
||||
* @param integer $line Line that triggered the error
|
||||
* @param array $context Context
|
||||
* @return void
|
||||
**/
|
||||
function handleError($code, $description, $file = null, $line = null, $context = null) {
|
||||
if ($code === 2048 || $code === 8192) {
|
||||
return;
|
||||
}
|
||||
switch ($code) {
|
||||
case E_PARSE:
|
||||
case E_ERROR:
|
||||
case E_CORE_ERROR:
|
||||
case E_COMPILE_ERROR:
|
||||
case E_USER_ERROR:
|
||||
$error = 'Fatal Error';
|
||||
$level = LOG_ERROR;
|
||||
break;
|
||||
case E_WARNING:
|
||||
case E_USER_WARNING:
|
||||
case E_COMPILE_WARNING:
|
||||
case E_RECOVERABLE_ERROR:
|
||||
$error = 'Warning';
|
||||
$level = LOG_WARNING;
|
||||
break;
|
||||
case E_NOTICE:
|
||||
case E_USER_NOTICE:
|
||||
$error = 'Notice';
|
||||
$level = LOG_NOTICE;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
$message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']';
|
||||
CakeLog::write($level, $message);
|
||||
}
|
||||
}
|
||||
|
||||
if (!defined('DISABLE_DEFAULT_ERROR_HANDLING')) {
|
||||
set_error_handler(array('CakeLog', 'handleError'));
|
||||
}
|
||||
?>
|
|
@ -510,12 +510,14 @@ class CakeSession extends Object {
|
|||
ini_set('session.auto_start', 0);
|
||||
}
|
||||
}
|
||||
session_set_save_handler(array('CakeSession','__open'),
|
||||
array('CakeSession', '__close'),
|
||||
array('CakeSession', '__read'),
|
||||
array('CakeSession', '__write'),
|
||||
array('CakeSession', '__destroy'),
|
||||
array('CakeSession', '__gc'));
|
||||
session_set_save_handler(
|
||||
array('CakeSession','__open'),
|
||||
array('CakeSession', '__close'),
|
||||
array('CakeSession', '__read'),
|
||||
array('CakeSession', '__write'),
|
||||
array('CakeSession', '__destroy'),
|
||||
array('CakeSession', '__gc')
|
||||
);
|
||||
break;
|
||||
case 'php':
|
||||
if (empty($_SESSION)) {
|
||||
|
@ -542,12 +544,14 @@ class CakeSession extends Object {
|
|||
ini_set('session.cookie_path', $this->path);
|
||||
}
|
||||
}
|
||||
session_set_save_handler(array('CakeSession','__open'),
|
||||
array('CakeSession', '__close'),
|
||||
array('Cache', 'read'),
|
||||
array('Cache', 'write'),
|
||||
array('Cache', 'delete'),
|
||||
array('Cache', 'gc'));
|
||||
session_set_save_handler(
|
||||
array('CakeSession','__open'),
|
||||
array('CakeSession', '__close'),
|
||||
array('Cache', 'read'),
|
||||
array('Cache', 'write'),
|
||||
array('Cache', 'delete'),
|
||||
array('Cache', 'gc')
|
||||
);
|
||||
break;
|
||||
default:
|
||||
if (empty($_SESSION)) {
|
||||
|
|
|
@ -42,7 +42,7 @@ class Configure extends Object {
|
|||
* @var integer
|
||||
* @access public
|
||||
*/
|
||||
var $debug = null;
|
||||
var $debug = 0;
|
||||
|
||||
/**
|
||||
* Returns a singleton instance of the Configure class.
|
||||
|
@ -106,24 +106,30 @@ class Configure extends Object {
|
|||
}
|
||||
|
||||
if (isset($config['debug'])) {
|
||||
$reporting = 0;
|
||||
if ($_this->debug) {
|
||||
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||
|
||||
if (function_exists('ini_set')) {
|
||||
ini_set('display_errors', 1);
|
||||
}
|
||||
|
||||
if (!class_exists('Debugger')) {
|
||||
require LIBS . 'debugger.php';
|
||||
}
|
||||
$reporting = E_ALL & ~E_DEPRECATED;
|
||||
if (function_exists('ini_set')) {
|
||||
ini_set('display_errors', 1);
|
||||
}
|
||||
} elseif (function_exists('ini_set')) {
|
||||
ini_set('display_errors', 0);
|
||||
}
|
||||
|
||||
if (isset($_this->log) && $_this->log) {
|
||||
if (!class_exists('CakeLog')) {
|
||||
require LIBS . 'cake_log.php';
|
||||
}
|
||||
Configure::write('log', LOG_NOTICE);
|
||||
} else {
|
||||
error_reporting(0);
|
||||
Configure::write('log', LOG_NOTICE);
|
||||
if (is_integer($_this->log) && !$_this->debug) {
|
||||
$reporting = $_this->log;
|
||||
} else {
|
||||
$reporting = E_ALL & ~E_DEPRECATED;
|
||||
}
|
||||
}
|
||||
error_reporting($reporting);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,13 +149,6 @@ class Configure extends Object {
|
|||
$_this =& Configure::getInstance();
|
||||
|
||||
if ($var === 'debug') {
|
||||
if (!isset($_this->debug)) {
|
||||
if (defined('DEBUG')) {
|
||||
$_this->debug = DEBUG;
|
||||
} else {
|
||||
$_this->debug = 0;
|
||||
}
|
||||
}
|
||||
return $_this->debug;
|
||||
}
|
||||
|
||||
|
|
|
@ -274,7 +274,6 @@ class Debugger extends Object {
|
|||
return;
|
||||
}
|
||||
|
||||
$level = LOG_DEBUG;
|
||||
switch ($code) {
|
||||
case E_PARSE:
|
||||
case E_ERROR:
|
||||
|
@ -297,7 +296,7 @@ class Debugger extends Object {
|
|||
$level = LOG_NOTICE;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -476,16 +476,27 @@ class DboSource extends DataSource {
|
|||
}
|
||||
|
||||
/**
|
||||
* Outputs the contents of the queries log.
|
||||
* Get the query log as an array.
|
||||
*
|
||||
* @param boolean $sorted
|
||||
*/
|
||||
function showLog($sorted = false) {
|
||||
* @param boolean $sorted Get the queries sorted by time taken, defaults to false.
|
||||
* @return array Array of queries run as an array
|
||||
**/
|
||||
function getLog($sorted = false) {
|
||||
if ($sorted) {
|
||||
$log = sortByKey($this->_queriesLog, 'took', 'desc', SORT_NUMERIC);
|
||||
} else {
|
||||
$log = $this->_queriesLog;
|
||||
}
|
||||
return $log;
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the contents of the queries log.
|
||||
*
|
||||
* @param boolean $sorted Get the queries sorted by time taken, defaults to false
|
||||
*/
|
||||
function showLog($sorted = false) {
|
||||
$log = $this->getLog($sorted);
|
||||
|
||||
if ($this->_queriesCnt > 1) {
|
||||
$text = 'queries';
|
||||
|
|
|
@ -2020,7 +2020,6 @@ class Model extends Overloadable {
|
|||
list($type, $query) = array($conditions, $fields);
|
||||
}
|
||||
|
||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||
$this->findQueryType = $type;
|
||||
$this->id = $this->getID();
|
||||
|
||||
|
@ -2067,6 +2066,9 @@ class Model extends Overloadable {
|
|||
}
|
||||
}
|
||||
|
||||
if (!$db =& ConnectionManager::getDataSource($this->useDbConfig)) {
|
||||
return false;
|
||||
}
|
||||
$results = $db->read($this, $query);
|
||||
$this->resetAssociations();
|
||||
$this->findQueryType = null;
|
||||
|
|
|
@ -1,25 +1,21 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Html Helper class file.
|
||||
*
|
||||
* Simplifies the construction of HTML elements.
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
|
||||
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.view.helpers
|
||||
* @since CakePHP(tm) v 0.9.1
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
/**
|
||||
|
@ -90,9 +86,9 @@ class HtmlHelper extends AppHelper {
|
|||
'ol' => '<ol%s>%s</ol>',
|
||||
'li' => '<li%s>%s</li>',
|
||||
'error' => '<div%s>%s</div>',
|
||||
'javascriptblock' => '<script type="text/javascript">%s</script>',
|
||||
'javascriptblock' => '<script type="text/javascript"%s>%s</script>',
|
||||
'javascriptstart' => '<script type="text/javascript">',
|
||||
'javascriptlink' => '<script type="text/javascript" src="%s"></script>',
|
||||
'javascriptlink' => '<script type="text/javascript" src="%s"%s></script>',
|
||||
'javascriptend' => '</script>'
|
||||
);
|
||||
|
||||
|
@ -420,26 +416,34 @@ class HtmlHelper extends AppHelper {
|
|||
*
|
||||
* Can include one or many Javascript files.
|
||||
*
|
||||
* @param mixed $url String or array of javascript files to include
|
||||
* @param boolean $inline Whether script should be output inline or into scripts_for_layout.
|
||||
* @param boolean $once Whether or not the script should be checked for uniqueness. If true scripts will only be
|
||||
* #### Options
|
||||
*
|
||||
* - `inline` - Whether script should be output inline or into scripts_for_layout.
|
||||
* - `once` - Whether or not the script should be checked for uniqueness. If true scripts will only be
|
||||
* included once, use false to allow the same script to be included more than once per request.
|
||||
*
|
||||
* @param mixed $url String or array of javascript files to include
|
||||
* @param mixed $options Array of options, and html attributes see above. If boolean sets $options['inline'] = value
|
||||
* @return mixed String of <script /> tags or null if $inline is false or if $once is true and the file has been
|
||||
* included before.
|
||||
**/
|
||||
function script($url, $inline = true, $once = true) {
|
||||
function script($url, $options = array()) {
|
||||
if (is_bool($options)) {
|
||||
list($inline, $options) = array($options, array());
|
||||
$options['inline'] = $inline;
|
||||
}
|
||||
$options = array_merge(array('inline' => true, 'once' => true), $options);
|
||||
if (is_array($url)) {
|
||||
$out = '';
|
||||
foreach ($url as $i) {
|
||||
$out .= "\n\t" . $this->script($i, $inline, $once);
|
||||
$out .= "\n\t" . $this->script($i, $options);
|
||||
}
|
||||
if ($inline) {
|
||||
if ($options['inline']) {
|
||||
return $out . "\n";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($once && isset($this->__includedScripts[$url])) {
|
||||
if ($options['once'] && isset($this->__includedScripts[$url])) {
|
||||
return null;
|
||||
}
|
||||
$this->__includedScripts[$url] = true;
|
||||
|
@ -468,7 +472,10 @@ class HtmlHelper extends AppHelper {
|
|||
$url = str_replace(JS_URL, 'cjs/', $url);
|
||||
}
|
||||
}
|
||||
$out = $this->output(sprintf($this->tags['javascriptlink'], $url));
|
||||
$inline = $options['inline'];
|
||||
unset($options['inline'], $options['once']);
|
||||
$attributes = $this->_parseAttributes($options, ' ', ' ');
|
||||
$out = $this->output(sprintf($this->tags['javascriptlink'], $url, $attributes));
|
||||
|
||||
if ($inline) {
|
||||
return $out;
|
||||
|
@ -495,11 +502,14 @@ class HtmlHelper extends AppHelper {
|
|||
if ($options['safe']) {
|
||||
$script = "\n" . '//<![CDATA[' . "\n" . $script . "\n" . '//]]>' . "\n";
|
||||
}
|
||||
if ($options['inline']) {
|
||||
return sprintf($this->tags['javascriptblock'], $script);
|
||||
$inline = $options['inline'];
|
||||
unset($options['inline'], $options['safe']);
|
||||
$attributes = $this->_parseAttributes($options, ' ', ' ');
|
||||
if ($inline) {
|
||||
return sprintf($this->tags['javascriptblock'], $attributes, $script);
|
||||
} else {
|
||||
$view =& ClassRegistry::getObject('view');
|
||||
$view->addScript(sprintf($this->tags['javascriptblock'], $script));
|
||||
$view->addScript(sprintf($this->tags['javascriptblock'], $attributes, $script));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,26 +1,21 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
|
||||
/**
|
||||
* Methods for displaying presentation data in the view.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
|
||||
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.view
|
||||
* @since CakePHP(tm) v 0.10.0.1076
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
|
||||
|
@ -696,8 +691,11 @@ class View extends Object {
|
|||
$helperNames = array_map(array('Inflector', 'variable'), $helpers);
|
||||
|
||||
for ($i = count($helpers) - 1; $i >= 0; $i--) {
|
||||
${$helperNames[$i]} =& $loadedHelpers[$helpers[$i]];
|
||||
$this->loaded[$helperNames[$i]] =& ${$helperNames[$i]};
|
||||
$name = $helperNames[$i];
|
||||
|
||||
${$name} =& $loadedHelpers[$helpers[$i]];
|
||||
$this->loaded[$helperNames[$i]] =& ${$name};
|
||||
$this->{$helpers[$i]} =& ${$name};
|
||||
}
|
||||
$this->_triggerHelpers('beforeRender');
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
|
||||
/**
|
||||
* CakeLogTest file
|
||||
*
|
||||
|
@ -9,20 +7,17 @@
|
|||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs
|
||||
* @since CakePHP(tm) v 1.2.0.5432
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
App::import('Core', 'Log');
|
||||
|
@ -54,5 +49,27 @@ class CakeLogTest extends CakeTestCase {
|
|||
$this->assertPattern('/2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Warning: Test warning 2$/', $result);
|
||||
unlink(LOGS . 'error.log');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test logging with the error handler.
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testLoggingWithErrorHandling() {
|
||||
@unlink(LOGS . 'debug.log');
|
||||
Configure::write('log', E_ALL & ~E_DEPRECATED);
|
||||
Configure::write('debug', 0);
|
||||
|
||||
set_error_handler(array('CakeLog', 'handleError'));
|
||||
$out .= '';
|
||||
|
||||
$result = file(LOGS . 'debug.log');
|
||||
$this->assertEqual(count($result), 1);
|
||||
$this->assertPattern(
|
||||
'/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} Debug: Notice \(8\): Undefined variable: out in \[.+ line \d{2}\]$/',
|
||||
$result[0]
|
||||
);
|
||||
@unlink(LOGS . 'debug.log');
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -144,13 +144,15 @@ class ConfigureTest extends CakeTestCase {
|
|||
* @return void
|
||||
**/
|
||||
function testSetErrorReportingLevel() {
|
||||
Configure::write('log', false);
|
||||
|
||||
Configure::write('debug', 0);
|
||||
$result = ini_get('error_reporting');
|
||||
$this->assertEqual($result, 0);
|
||||
|
||||
Configure::write('debug', 2);
|
||||
$result = ini_get('error_reporting');
|
||||
$this->assertEqual($result, E_ALL);
|
||||
$this->assertEqual($result, E_ALL & ~E_DEPRECATED);
|
||||
|
||||
$result = ini_get('display_errors');
|
||||
$this->assertEqual($result, 1);
|
||||
|
@ -160,6 +162,28 @@ class ConfigureTest extends CakeTestCase {
|
|||
$this->assertEqual($result, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that log and debug configure values interact well.
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testInteractionOfDebugAndLog() {
|
||||
Configure::write('log', false);
|
||||
|
||||
Configure::write('debug', 0);
|
||||
$this->assertEqual(ini_get('error_reporting'), 0);
|
||||
$this->assertEqual(ini_get('display_errors'), 0);
|
||||
|
||||
Configure::write('log', E_WARNING);
|
||||
Configure::write('debug', 0);
|
||||
$this->assertEqual(ini_get('error_reporting'), E_WARNING);
|
||||
$this->assertEqual(ini_get('display_errors'), 0);
|
||||
|
||||
Configure::write('debug', 2);
|
||||
$this->assertEqual(ini_get('error_reporting'), E_ALL & ~E_DEPRECATED);
|
||||
$this->assertEqual(ini_get('display_errors'), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* testDelete method
|
||||
*
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||
}
|
||||
App::import('Core', array('Model', 'DataSource', 'DboSource', 'DboMysql'));
|
||||
App::import('Model', 'App');
|
||||
App::import('Model', array('Model', 'DataSource', 'DboSource', 'DboMysql', 'App'));
|
||||
require_once dirname(dirname(__FILE__)) . DS . 'models.php';
|
||||
|
||||
/**
|
||||
|
@ -3620,11 +3619,11 @@ class DboSourceTest extends CakeTestCase {
|
|||
function testHasAny() {
|
||||
$this->testDb->hasAny($this->Model, array());
|
||||
$expected = 'SELECT COUNT(`TestModel`.`id`) AS count FROM `test_models` AS `TestModel` WHERE 1 = 1';
|
||||
$this->assertEqual($this->testDb->simulated[0], $expected);
|
||||
$this->assertEqual($this->testDb->simulated[1], $expected);
|
||||
|
||||
$this->testDb->hasAny($this->Model, array('TestModel.name' => 'harry'));
|
||||
$expected = "SELECT COUNT(`TestModel`.`id`) AS count FROM `test_models` AS `TestModel` WHERE `TestModel`.`name` = 'harry'";
|
||||
$this->assertEqual($this->testDb->simulated[1], $expected);
|
||||
$this->assertEqual($this->testDb->simulated[2], $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3969,6 +3968,30 @@ class DboSourceTest extends CakeTestCase {
|
|||
Configure::write('debug', $oldDebug);
|
||||
}
|
||||
|
||||
/**
|
||||
* test getting the query log as an array.
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testGetLog() {
|
||||
$this->testDb->logQuery('Query 1');
|
||||
$this->testDb->logQuery('Query 2');
|
||||
|
||||
$oldError = $this->testDb->error;
|
||||
$this->testDb->error = true;
|
||||
$result = $this->testDb->logQuery('Error 1');
|
||||
$this->assertFalse($result);
|
||||
$this->testDb->error = $oldError;
|
||||
|
||||
$log = $this->testDb->getLog();
|
||||
$expected = array('query' => 'Query 1', 'error' => '', 'affected' => '', 'numRows' => '', 'took' => '');
|
||||
$this->assertEqual($log[0], $expected);
|
||||
$expected = array('query' => 'Query 2', 'error' => '', 'affected' => '', 'numRows' => '', 'took' => '');
|
||||
$this->assertEqual($log[1], $expected);
|
||||
$expected = array('query' => 'Error 1', 'error' => true, 'affected' => '', 'numRows' => '', 'took' => '');
|
||||
$this->assertEqual($log[2], $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* test ShowQuery generation of regular and error messages
|
||||
*
|
||||
|
|
|
@ -4877,6 +4877,22 @@ class ModelReadTest extends BaseModelTest {
|
|||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the database configuration assigned to the model can be changed using
|
||||
* (before|after)Find callbacks
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testCallbackSourceChange() {
|
||||
$this->loadFixtures('Post');
|
||||
$TestModel = new Post();
|
||||
$this->assertEqual(3, count($TestModel->find('all')));
|
||||
|
||||
$this->expectError(new PatternExpectation('/Non-existent data source foo/i'));
|
||||
$this->expectError(new PatternExpectation('/Only variable references/i'));
|
||||
$this->assertFalse($TestModel->find('all', array('connection' => 'foo')));
|
||||
}
|
||||
|
||||
/**
|
||||
* testMultipleBelongsToWithSameClass method
|
||||
*
|
||||
|
|
|
@ -857,6 +857,18 @@ class Post extends CakeTestModel {
|
|||
* @access public
|
||||
*/
|
||||
var $belongsTo = array('Author');
|
||||
|
||||
function beforeFind($queryData) {
|
||||
if (isset($queryData['connection'])) {
|
||||
$this->useDbConfig = $queryData['connection'];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function afterFind($results) {
|
||||
$this->useDbConfig = 'test_suite';
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
|
||||
/**
|
||||
* HtmlHelperTest file
|
||||
*
|
||||
|
@ -9,20 +7,17 @@
|
|||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* Copyright 2006-2009, Cake Software Foundation, Inc.
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* @copyright Copyright 2006-2009, Cake Software Foundation, Inc.
|
||||
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.view.helpers
|
||||
* @since CakePHP(tm) v 1.2.0.4206
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
App::import('Core', array('Helper', 'AppHelper', 'ClassRegistry', 'Controller', 'Model'));
|
||||
|
@ -396,7 +391,7 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
$expected['link']['href'] = 'preg:/.*css\/vendor\.generic\.css/';
|
||||
$this->assertTags($result[1], $expected);
|
||||
$this->assertEqual(count($result), 2);
|
||||
|
||||
|
||||
Configure::write('debug', 2);
|
||||
Configure::write('Asset.timestamp', true);
|
||||
|
||||
|
@ -453,16 +448,17 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
touch(WWW_ROOT . 'js' . DS. '__cake_js_test.js');
|
||||
$timestamp = substr(strtotime('now'), 0, 8);
|
||||
|
||||
$result = $this->Html->script('__cake_js_test', true, false);
|
||||
$result = $this->Html->script('__cake_js_test', array('inline' => true, 'once' => false));
|
||||
$this->assertPattern('/__cake_js_test.js\?' . $timestamp . '[0-9]{2}"/', $result, 'Timestamp value not found %s');
|
||||
|
||||
Configure::write('debug', 0);
|
||||
Configure::write('Asset.timestamp', 'force');
|
||||
$result = $this->Html->script('__cake_js_test', true, false);
|
||||
$result = $this->Html->script('__cake_js_test', array('inline' => true, 'once' => false));
|
||||
$this->assertPattern('/__cake_js_test.js\?' . $timestamp . '[0-9]{2}"/', $result, 'Timestamp value not found %s');
|
||||
unlink(WWW_ROOT . 'js' . DS. '__cake_js_test.js');
|
||||
Configure::write('Asset.timestamp', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that scripts added with uses() are only ever included once.
|
||||
* test script tag generation
|
||||
|
@ -496,15 +492,21 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
'script' => array('type' => 'text/javascript', 'src' => '/plugin/js/jquery-1.3.2.js?someparam=foo')
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
|
||||
$result = $this->Html->script('foo');
|
||||
$this->assertNull($result, 'Script returned upon duplicate inclusion %s');
|
||||
|
||||
$result = $this->Html->script(array('foo', 'bar', 'baz'));
|
||||
$this->assertNoPattern('/foo.js/', $result);
|
||||
|
||||
$result = $this->Html->script('foo', true, false);
|
||||
$result = $this->Html->script('foo', array('inline' => true, 'once' => false));
|
||||
$this->assertNotNull($result);
|
||||
|
||||
$result = $this->Html->script('jquery-1.3.2', array('defer' => true, 'encoding' => 'utf-8'));
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript', 'src' => 'js/jquery-1.3.2.js', 'defer' => 'defer', 'encoding' => 'utf-8')
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
/**
|
||||
* test Script block generation
|
||||
|
@ -521,7 +523,7 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
'/script',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
|
||||
$result = $this->Html->scriptBlock('window.foo = 2;', array('safe' => false));
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
|
@ -539,13 +541,21 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
'/script',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
|
||||
$view =& ClassRegistry::getObject('view');
|
||||
$view =& new HtmlHelperMockView();
|
||||
$view->expectAt(0, 'addScript', array(new PatternExpectation('/window\.foo\s\=\s2;/')));
|
||||
|
||||
|
||||
$result = $this->Html->scriptBlock('window.foo = 2;', array('inline' => false));
|
||||
$this->assertNull($result);
|
||||
|
||||
$result = $this->Html->scriptBlock('window.foo = 2;', array('safe' => false, 'encoding' => 'utf-8'));
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript', 'encoding' => 'utf-8'),
|
||||
'window.foo = 2;',
|
||||
'/script',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
/**
|
||||
* test script tag output buffering when using scriptStart() and scriptEnd();
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
|
||||
/**
|
||||
* ViewTest file
|
||||
*
|
||||
|
@ -9,20 +7,17 @@
|
|||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs
|
||||
* @since CakePHP(tm) v 1.2.0.4206
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
App::import('Core', array('View', 'Controller'));
|
||||
|
@ -653,6 +648,14 @@ class ViewTest extends CakeTestCase {
|
|||
$this->assertTrue(is_object($helpers['form']->Html));
|
||||
$this->assertTrue(is_object($helpers['ajax']->Html));
|
||||
$this->assertTrue(is_object($helpers['pluggedHelper']->OtherHelper));
|
||||
|
||||
$this->assertTrue(is_object($View->Html));
|
||||
$this->assertTrue(is_object($View->Form));
|
||||
$this->assertTrue(is_object($View->Form->Html));
|
||||
$this->assertTrue(is_object($View->PluggedHelper->OtherHelper));
|
||||
$this->assertReference($View->Form, $View->loaded['form']);
|
||||
$this->assertReference($View->Html, $View->loaded['html']);
|
||||
$this->assertReference($View->PluggedHelper->OtherHelper, $View->loaded['otherHelper']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -498,7 +498,7 @@ class CodeCoverageManager {
|
|||
|
||||
$folder =& new Folder();
|
||||
$folder->cd(ROOT . DS . CAKE_TESTS_LIB);
|
||||
$contents = $folder->ls();
|
||||
$contents = $folder->read();
|
||||
|
||||
if (in_array(basename($testFile), $contents[1])) {
|
||||
$testFile = basename($testFile);
|
||||
|
|
Loading…
Reference in a new issue