Merge branch '1.3' of dev@code.cakephp.org:cakephp into 1.3-misc

This commit is contained in:
mark_story 2009-11-25 22:23:38 -05:00
commit e345b2f788
74 changed files with 395 additions and 295 deletions

View file

@ -198,6 +198,15 @@
*/ */
Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi'); Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');
/**
* Apply timestamps with the last modified time to static assets (js, css, images).
* Will append a querystring parameter containing the time the file was modified. This is
* useful for invalidating browser caches.
*
* Set to `true` to apply timestamps, when debug = 0, or set to 'force' to always enable
* timestamping.
*/
//Configure::write('Asset.timestamp', true);
/** /**
* Compress CSS output by removing comments, whitespace, repeating tags, etc. * 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. * This requires a/var/cache directory to be writable by the web server for caching.

View file

@ -461,7 +461,7 @@ if (!function_exists('file_put_contents')) {
/** /**
* Writes data into file. * Writes data into file.
* *
* If file exists, it will be overwritten. If data is an array, it will be join()ed with an empty string. * If file exists, it will be overwritten. If data is an array, it will be implode()ed with an empty string.
* *
* @param string $fileName File name. * @param string $fileName File name.
* @param mixed $data String or array. * @param mixed $data String or array.
@ -469,7 +469,7 @@ if (!function_exists('file_put_contents')) {
*/ */
function file_put_contents($fileName, $data) { function file_put_contents($fileName, $data) {
if (is_array($data)) { if (is_array($data)) {
$data = join('', $data); $data = implode('', $data);
} }
$res = @fopen($fileName, 'w+b'); $res = @fopen($fileName, 'w+b');

View file

@ -305,7 +305,7 @@ class ConsoleShell extends Shell {
break; break;
case (preg_match("/^routes\s+show/i", $command, $tmp) == true): case (preg_match("/^routes\s+show/i", $command, $tmp) == true):
$router =& Router::getInstance(); $router =& Router::getInstance();
$this->out(join("\n", Set::extract($router->routes, '{n}.0'))); $this->out(implode("\n", Set::extract($router->routes, '{n}.0')));
break; break;
case (preg_match("/^route\s+(\(.*\))$/i", $command, $tmp) == true): case (preg_match("/^route\s+(\(.*\))$/i", $command, $tmp) == true):
if ($url = eval('return array' . $tmp[1] . ';')) { if ($url = eval('return array' . $tmp[1] . ';')) {

View file

@ -164,7 +164,7 @@ class ControllerTask extends Shell {
if (file_exists($this->path . $controllerFile .'_controller.php')) { if (file_exists($this->path . $controllerFile .'_controller.php')) {
$question[] = sprintf(__("Warning: Choosing no will overwrite the %sController.", true), $controllerName); $question[] = sprintf(__("Warning: Choosing no will overwrite the %sController.", true), $controllerName);
} }
$doItInteractive = $this->in(join("\n", $question), array('y', 'n'), 'y'); $doItInteractive = $this->in(implode("\n", $question), array('y','n'), 'y');
if (strtolower($doItInteractive) == 'y') { if (strtolower($doItInteractive) == 'y') {
$this->interactive = true; $this->interactive = true;

View file

@ -232,9 +232,9 @@ class ExtractTask extends Shell {
} }
if (is_array($token)) { if (is_array($token)) {
$lineNumber += count(split("\n", $token[1])) - 1; $lineNumber += count(explode("\n", $token[1])) - 1;
} else { } else {
$lineNumber += count(split("\n", $token)) - 1; $lineNumber += count(explode("\n", $token)) - 1;
} }
} }
unset($allTokens); unset($allTokens);

View file

@ -24,7 +24,7 @@
<?php <?php
echo "\t<?php\n"; echo "\t<?php\n";
foreach ($fields as $field) { foreach ($fields as $field) {
if ($action == 'add' && $field == $primaryKey) { if (substr($action, 'add') !== false && $field == $primaryKey) {
continue; continue;
} elseif (!in_array($field, array('created', 'modified', 'updated'))) { } elseif (!in_array($field, array('created', 'modified', 'updated'))) {
echo "\t\techo \$this->Form->input('{$field}');\n"; echo "\t\techo \$this->Form->input('{$field}');\n";

View file

@ -1,4 +1,4 @@
;<?php die() ?> ;<?php exit() ?>
; SVN FILE: $Id$ ; SVN FILE: $Id$
;/** ;/**
; * Short description for file. ; * Short description for file.

View file

@ -79,7 +79,7 @@ class PagesController extends AppController {
$title = Inflector::humanize($path[$count - 1]); $title = Inflector::humanize($path[$count - 1]);
} }
$this->set(compact('page', 'subpage', 'title')); $this->set(compact('page', 'subpage', 'title'));
$this->render(join('/', $path)); $this->render(implode('/', $path));
} }
} }

View file

@ -64,7 +64,7 @@ if (!class_exists('File')) {
} }
if (preg_match('|\.\.|', $url) || !preg_match('|^ccss/(.+)$|i', $url, $regs)) { if (preg_match('|\.\.|', $url) || !preg_match('|^ccss/(.+)$|i', $url, $regs)) {
die('Wrong file name.'); exit('Wrong file name.');
} }
$filename = 'css/' . $regs[1]; $filename = 'css/' . $regs[1];
@ -72,7 +72,7 @@ if (!class_exists('File')) {
$cachepath = CACHE . 'css' . DS . str_replace(array('/','\\'), '-', $regs[1]); $cachepath = CACHE . 'css' . DS . str_replace(array('/','\\'), '-', $regs[1]);
if (!file_exists($filepath)) { if (!file_exists($filepath)) {
die('Wrong file name.'); exit('Wrong file name.');
} }
if (file_exists($cachepath)) { if (file_exists($cachepath)) {

View file

@ -90,7 +90,7 @@ if (isset($corePath[0])) {
require_once CAKE_TESTS_LIB . 'test_manager.php'; require_once CAKE_TESTS_LIB . 'test_manager.php';
if (Configure::read('debug') < 1) { if (Configure::read('debug') < 1) {
die(__('Debug setting does not allow access to this url.', true)); exit(__('Debug setting does not allow access to this url.', true));
} }
if (!isset($_SERVER['SERVER_NAME'])) { if (!isset($_SERVER['SERVER_NAME'])) {

View file

@ -142,13 +142,13 @@ class Dispatcher extends Object {
))); )));
} }
$privateAction = (bool)(strpos($this->params['action'], '_', 0) === 0); $privateAction = $this->params['action'][0] === '_';
$prefixes = Router::prefixes(); $prefixes = Router::prefixes();
if (!empty($prefixes)) { if (!empty($prefixes)) {
if (isset($this->params['prefix'])) { if (isset($this->params['prefix'])) {
$this->params['action'] = $this->params['prefix'] . '_' . $this->params['action']; $this->params['action'] = $this->params['prefix'] . '_' . $this->params['action'];
} elseif (strpos($this->params['action'], '_') !== false && !$privateAction) { } elseif (strpos($this->params['action'], '_') > 0) {
list($prefix, $action) = explode('_', $this->params['action']); list($prefix, $action) = explode('_', $this->params['action']);
$privateAction = in_array($prefix, $prefixes); $privateAction = in_array($prefix, $prefixes);
} }
@ -377,9 +377,6 @@ class Dispatcher extends Object {
$this->webroot = $base .'/'; $this->webroot = $base .'/';
return $base; return $base;
} }
$file = null;
if ($baseUrl) {
$file = '/' . basename($baseUrl); $file = '/' . basename($baseUrl);
$base = dirname($baseUrl); $base = dirname($baseUrl);
@ -395,8 +392,6 @@ class Dispatcher extends Object {
$this->webroot .= $webroot . '/'; $this->webroot .= $webroot . '/';
} }
return $base . $file; return $base . $file;
}
return false;
} }
/** /**
@ -529,7 +524,7 @@ class Dispatcher extends Object {
if (key($_GET) && strpos(key($_GET), '?') !== false) { if (key($_GET) && strpos(key($_GET), '?') !== false) {
unset($_GET[key($_GET)]); unset($_GET[key($_GET)]);
} }
$uri = preg_split('/\?/', $uri, 2); $uri = explode('?', $uri, 2);
if (isset($uri[1])) { if (isset($uri[1])) {
parse_str($uri[1], $_GET); parse_str($uri[1], $_GET);
@ -605,7 +600,7 @@ class Dispatcher extends Object {
* @access public * @access public
*/ */
function cached($url) { function cached($url) {
if (strpos($url, 'css/') !== false || strpos($url, 'js/') !== false || strpos($url, 'img/') !== false) { if (strpos($url, '..') === false && strpos($url, '.')) {
if (strpos($url, 'ccss/') === 0) { if (strpos($url, 'ccss/') === 0) {
include WWW_ROOT . DS . Configure::read('Asset.filter.css'); include WWW_ROOT . DS . Configure::read('Asset.filter.css');
$this->_stop(); $this->_stop();
@ -613,27 +608,19 @@ class Dispatcher extends Object {
include WWW_ROOT . DS . Configure::read('Asset.filter.js'); include WWW_ROOT . DS . Configure::read('Asset.filter.js');
$this->_stop(); $this->_stop();
} }
$isAsset = false; App::import('View', 'Media', false);
$assets = array( $Media = new MediaView();
'js' => 'text/javascript', 'css' => 'text/css',
'gif' => 'image/gif', 'jpg' => 'image/jpeg', 'png' => 'image/png'
);
$ext = array_pop(explode('.', $url)); $ext = array_pop(explode('.', $url));
foreach ($assets as $type => $contentType) { if (isset($Media->mimeType[$ext])) {
if ($type === $ext) { $parts = explode('/', $url);
$parts = explode('/', $url); if ($parts[0] === 'css' || $parts[0] === 'js' || $parts[0] === 'img') {
if ($parts[0] === 'css' || $parts[0] === 'js' || $parts[0] === 'img') { $pos = 0;
$pos = 0; } elseif ($parts[0] === 'theme') {
} else { $pos = strlen($parts[0] . $parts[1]) + 1;
$pos = strlen($parts[0]); } elseif (count($parts) > 2) {
} $pos = strlen($parts[0]);
$isAsset = true;
break;
} }
}
if ($isAsset === true) {
$ob = @ini_get("zlib.output_compression") !== '1' && extension_loaded("zlib") && (strpos(env('HTTP_ACCEPT_ENCODING'), 'gzip') !== false); $ob = @ini_get("zlib.output_compression") !== '1' && extension_loaded("zlib") && (strpos(env('HTTP_ACCEPT_ENCODING'), 'gzip') !== false);
if ($ob && Configure::read('Asset.compress')) { if ($ob && Configure::read('Asset.compress')) {
@ -642,29 +629,49 @@ class Dispatcher extends Object {
} }
$assetFile = null; $assetFile = null;
$paths = array(); $paths = array();
$matched = false;
if ($pos > 0) { if ($pos > 0) {
$plugin = substr($url, 0, $pos); $plugin = substr($url, 0, $pos);
$url = preg_replace('/^' . preg_quote($plugin, '/') . '\//i', '', $url); $url = preg_replace('/^' . preg_quote($plugin, '/') . '\//i', '', $url);
$paths[] = App::pluginPath($plugin) . 'vendors' . DS;
}
$paths = array_merge($paths, App::path('vendors'));
foreach ($paths as $path) { if (strpos($plugin, '/') !== false) {
if (is_file($path . $url) && file_exists($path . $url)) { list($plugin, $theme) = explode('/', $plugin);
$assetFile = $path . $url; $themePaths = App::path('views');
break;
foreach ($themePaths as $viewPath) {
$path = $viewPath . 'themed' . DS . $theme . DS . 'webroot' . DS;
if ($plugin === 'theme' && (is_file($path . $url) && file_exists($path . $url))) {
$assetFile = $path . $url;
$matched = true;
break;
}
}
}
if ($matched === false) {
$paths[] = App::pluginPath($plugin) . 'webroot' . DS;
}
}
if ($matched === false) {
foreach ($paths as $path) {
if (is_file($path . $url) && file_exists($path . $url)) {
$assetFile = $path . $url;
break;
}
} }
} }
if ($assetFile !== null) { if ($assetFile !== null) {
$fileModified = filemtime($assetFile); $fileModified = filemtime($assetFile);
header("Date: " . date("D, j M Y G:i:s ", $fileModified) . 'GMT'); header("Date: " . date("D, j M Y G:i:s ", $fileModified) . 'GMT');
header('Content-type: ' . $assets[$type]); header('Content-type: ' . $Media->mimeType[$ext]);
header("Expires: " . gmdate("D, j M Y H:i:s", time() + DAY) . " GMT"); header("Expires: " . gmdate("D, j M Y H:i:s", time() + DAY) . " GMT");
header("Cache-Control: cache"); header("Cache-Control: cache");
header("Pragma: cache"); header("Pragma: cache");
if ($type === 'css' || $type === 'js') { if ($ext === 'css' || $ext === 'js') {
include($assetFile); include($assetFile);
} else { } else {
readfile($assetFile); readfile($assetFile);

View file

@ -558,7 +558,7 @@ class CakeSession extends Object {
$config = CONFIGS . Configure::read('Session.save') . '.php'; $config = CONFIGS . Configure::read('Session.save') . '.php';
if (is_file($config)) { if (is_file($config)) {
require_once ($config); require($config);
} }
} }
break; break;

View file

@ -235,22 +235,25 @@ class Configure extends Object {
if ($plugin) { if ($plugin) {
$pluginPath = App::pluginPath($plugin); $pluginPath = App::pluginPath($plugin);
} }
$pos = strpos($fileName, '..');
if ($pluginPath && file_exists($pluginPath . 'config' . DS . $fileName . '.php')) { if ($pos === false) {
include($pluginPath . 'config' . DS . $fileName . '.php'); if ($pluginPath && file_exists($pluginPath . 'config' . DS . $fileName . '.php')) {
$found = true; include($pluginPath . 'config' . DS . $fileName . '.php');
} elseif (file_exists(CONFIGS . $fileName . '.php')) { $found = true;
include(CONFIGS . $fileName . '.php'); } elseif (file_exists(CONFIGS . $fileName . '.php')) {
$found = true; include(CONFIGS . $fileName . '.php');
} elseif (file_exists(CACHE . 'persistent' . DS . $fileName . '.php')) { $found = true;
include(CACHE . 'persistent' . DS . $fileName . '.php'); } elseif (file_exists(CACHE . 'persistent' . DS . $fileName . '.php')) {
$found = true; include(CACHE . 'persistent' . DS . $fileName . '.php');
} else { $found = true;
foreach (App::core('cake') as $key => $path) { } else {
if (file_exists($path . DS . 'config' . DS . $fileName . '.php')) { foreach (App::core('cake') as $key => $path) {
include($path . DS . 'config' . DS . $fileName . '.php'); if (file_exists($path . DS . 'config' . DS . $fileName . '.php')) {
$found = true; include($path . DS . 'config' . DS . $fileName . '.php');
break; $found = true;
break;
}
} }
} }
} }
@ -859,7 +862,6 @@ class App extends Object {
* @access public * @access public
*/ */
function import($type = null, $name = null, $parent = true, $search = array(), $file = null, $return = false) { function import($type = null, $name = null, $parent = true, $search = array(), $file = null, $return = false) {
$_this =& App::getInstance();
$plugin = $directory = null; $plugin = $directory = null;
if (is_array($type)) { if (is_array($type)) {
@ -910,7 +912,7 @@ class App extends Object {
list($plugin, $name) = explode('.', $name); list($plugin, $name) = explode('.', $name);
$plugin = Inflector::camelize($plugin); $plugin = Inflector::camelize($plugin);
} }
$_this =& App::getInstance();
$_this->return = $return; $_this->return = $return;
if (isset($ext)) { if (isset($ext)) {

View file

@ -362,7 +362,7 @@ class DbAcl extends AclBase {
} }
list($save['aro_id'], $save['aco_id']) = array($perms['aro'], $perms['aco']); list($save['aro_id'], $save['aco_id']) = array($perms['aro'], $perms['aco']);
if ($perms['link'] != null && count($perms['link']) > 0) { if ($perms['link'] != null && !empty($perms['link'])) {
$save['id'] = $perms['link'][0][$this->Aro->Permission->alias]['id']; $save['id'] = $perms['link'][0][$this->Aro->Permission->alias]['id'];
} else { } else {
unset($save['id']); unset($save['id']);

View file

@ -349,7 +349,7 @@ class SecurityComponent extends Object {
$out[] = 'opaque="' . md5($options['realm']).'"'; $out[] = 'opaque="' . md5($options['realm']).'"';
} }
return $auth . ' ' . join(',', $out); return $auth . ' ' . implode(',', $out);
} }
/** /**

View file

@ -645,7 +645,7 @@ class Controller extends Object {
504 => 'Gateway Time-out' 504 => 'Gateway Time-out'
); );
if (is_string($status)) { if (is_string($status)) {
$codes = array_combine(array_values($codes), array_keys($codes)); $codes = array_flip($codes);
} }
if (isset($codes[$status])) { if (isset($codes[$status])) {
@ -776,7 +776,7 @@ class Controller extends Object {
function validateErrors() { function validateErrors() {
$objects = func_get_args(); $objects = func_get_args();
if (!count($objects)) { if (empty($objects)) {
return false; return false;
} }
@ -786,7 +786,7 @@ class Controller extends Object {
$errors = array_merge($errors, $this->{$object->alias}->invalidFields()); $errors = array_merge($errors, $this->{$object->alias}->invalidFields());
} }
return $this->validationErrors = (count($errors) ? $errors : false); return $this->validationErrors = (!empty($errors) ? $errors : false);
} }
/** /**
@ -951,12 +951,14 @@ class Controller extends Object {
foreach ($fields as $field => $value) { foreach ($fields as $field => $value) {
$key = $model.'.'.$field; $key = $model.'.'.$field;
$fieldOp = $op; $fieldOp = $op;
if (is_array($op) && array_key_exists($key, $op)) { if (is_array($op)) {
$fieldOp = $op[$key]; if (array_key_exists($key, $op)) {
} elseif (is_array($op) && array_key_exists($field, $op)) { $fieldOp = $op[$key];
$fieldOp = $op[$field]; } elseif (array_key_exists($field, $op)) {
} elseif (is_array($op)) { $fieldOp = $op[$field];
$fieldOp = false; } else {
$fieldOp = false;
}
} }
if ($exclusive && $fieldOp === false) { if ($exclusive && $fieldOp === false) {
continue; continue;

View file

@ -79,7 +79,7 @@ class PagesController extends AppController {
$title = Inflector::humanize($path[$count - 1]); $title = Inflector::humanize($path[$count - 1]);
} }
$this->set(compact('page', 'subpage', 'title')); $this->set(compact('page', 'subpage', 'title'));
$this->render(join('/', $path)); $this->render(implode('/', $path));
} }
} }

View file

@ -312,7 +312,7 @@ class Debugger extends Object {
} }
if ($error == 'Fatal Error') { if ($error == 'Fatal Error') {
die(); exit();
} }
return true; return true;
} }
@ -393,7 +393,7 @@ class Debugger extends Object {
if ($options['format'] == 'array' || $options['format'] == 'points') { if ($options['format'] == 'array' || $options['format'] == 'points') {
return $back; return $back;
} }
return join("\n", $back); return implode("\n", $back);
} }
/** /**
@ -503,10 +503,10 @@ class Debugger extends Object {
} }
} }
$n = null; $n = null;
if (count($vars) > 0) { if (!empty($vars)) {
$n = "\n"; $n = "\n";
} }
return $out . join(",", $vars) . "{$n})"; return $out . implode(",", $vars) . "{$n})";
break; break;
case 'resource': case 'resource':
return strtolower(gettype($var)); return strtolower(gettype($var));
@ -545,7 +545,7 @@ class Debugger extends Object {
$out[] = "$className::$$key = " . $value; $out[] = "$className::$$key = " . $value;
} }
} }
return join("\n", $out); return implode("\n", $out);
} }
/** /**

View file

@ -801,7 +801,7 @@ class Folder extends Object {
continue; continue;
} }
if ($part === '..') { if ($part === '..') {
if (count($newparts) > 0) { if (!empty($newparts)) {
array_pop($newparts); array_pop($newparts);
continue; continue;
} else { } else {

View file

@ -794,7 +794,7 @@ class HttpSocket extends CakeSocket {
$returnHeader = ''; $returnHeader = '';
foreach ($header as $field => $contents) { foreach ($header as $field => $contents) {
if (is_array($contents) && $mode == 'standard') { if (is_array($contents) && $mode == 'standard') {
$contents = join(',', $contents); $contents = implode(',', $contents);
} }
foreach ((array)$contents as $content) { foreach ((array)$contents as $content) {
$contents = preg_replace("/\r\n(?![\t ])/", "\r\n ", $content); $contents = preg_replace("/\r\n(?![\t ])/", "\r\n ", $content);
@ -873,7 +873,7 @@ class HttpSocket extends CakeSocket {
foreach ((array)$header['Set-Cookie'] as $cookie) { foreach ((array)$header['Set-Cookie'] as $cookie) {
if (strpos($cookie, '";"') !== false) { if (strpos($cookie, '";"') !== false) {
$cookie = str_replace('";"', "{__cookie_replace__}", $cookie); $cookie = str_replace('";"', "{__cookie_replace__}", $cookie);
$parts = str_replace("{__cookie_replace__}", '";"', preg_split('/\;/', $cookie)); $parts = str_replace("{__cookie_replace__}", '";"', explode(';', $cookie));
} else { } else {
$parts = preg_split('/\;[ \t]*/', $cookie); $parts = preg_split('/\;[ \t]*/', $cookie);
} }

View file

@ -95,7 +95,7 @@ class MagicDb extends Object {
$lines = explode("\r\n", $data); $lines = explode("\r\n", $data);
$db = array(); $db = array();
$validHeader = count($lines > 3) $validHeader = count($lines) > 3
&& preg_match('/^# Date:([0-9]{4}-[0-9]{2}-[0-9]{2})$/', $lines[1], $date) && preg_match('/^# Date:([0-9]{4}-[0-9]{2}-[0-9]{2})$/', $lines[1], $date)
&& preg_match('/^# Source:(.+)$/', $lines[2], $source) && preg_match('/^# Source:(.+)$/', $lines[2], $source)
&& strlen($lines[3]) == 0; && strlen($lines[3]) == 0;

View file

@ -287,7 +287,7 @@ class ContainableBehavior extends ModelBehavior {
if (strpos($name, '.') !== false) { if (strpos($name, '.') !== false) {
$chain = explode('.', $name); $chain = explode('.', $name);
$name = array_shift($chain); $name = array_shift($chain);
$children = array(join('.', $chain) => $children); $children = array(implode('.', $chain) => $children);
} }
$children = (array)$children; $children = (array)$children;

View file

@ -514,7 +514,7 @@ class CakeSchema extends Object {
if (is_array($values)) { if (is_array($values)) {
foreach ($values as $key => $val) { foreach ($values as $key => $val) {
if (is_array($val)) { if (is_array($val)) {
$vals[] = "'{$key}' => array('" . join("', '", $val) . "')"; $vals[] = "'{$key}' => array('" . implode("', '", $val) . "')";
} else if (!is_numeric($key)) { } else if (!is_numeric($key)) {
$val = var_export($val, true); $val = var_export($val, true);
$vals[] = "'{$key}' => {$val}"; $vals[] = "'{$key}' => {$val}";

View file

@ -225,7 +225,7 @@ class DboAdodb extends DboSource {
function listSources() { function listSources() {
$tables = $this->_adodb->MetaTables('TABLES'); $tables = $this->_adodb->MetaTables('TABLES');
if (!sizeof($tables) > 0) { if (!count($tables) > 0) {
trigger_error(ERROR_NO_TABLE_LIST, E_USER_NOTICE); trigger_error(ERROR_NO_TABLE_LIST, E_USER_NOTICE);
exit; exit;
} }

View file

@ -612,7 +612,7 @@ class DboMssql extends DboSource {
foreach (array('columns', 'indexes') as $var) { foreach (array('columns', 'indexes') as $var) {
if (is_array(${$var})) { if (is_array(${$var})) {
${$var} = "\t" . join(",\n\t", array_filter(${$var})); ${$var} = "\t" . implode(",\n\t", array_filter(${$var}));
} }
} }
return "CREATE TABLE {$table} (\n{$columns});\n{$indexes}"; return "CREATE TABLE {$table} (\n{$columns});\n{$indexes}";
@ -747,7 +747,7 @@ class DboMssql extends DboSource {
$out = "ALTER TABLE {$table} ADD CONSTRAINT {$name} UNIQUE"; $out = "ALTER TABLE {$table} ADD CONSTRAINT {$name} UNIQUE";
if (is_array($value['column'])) { if (is_array($value['column'])) {
$value['column'] = join(', ', array_map(array(&$this, 'name'), $value['column'])); $value['column'] = implode(', ', array_map(array(&$this, 'name'), $value['column']));
} else { } else {
$value['column'] = $this->name($value['column']); $value['column'] = $this->name($value['column']);
} }

View file

@ -168,7 +168,7 @@ class DboMysqlBase extends DboSource {
$alias = $joins = false; $alias = $joins = false;
$fields = $this->_prepareUpdateFields($model, $combined, empty($conditions), !empty($conditions)); $fields = $this->_prepareUpdateFields($model, $combined, empty($conditions), !empty($conditions));
$fields = join(', ', $fields); $fields = implode(', ', $fields);
$table = $this->fullTableName($model); $table = $this->fullTableName($model);
if (!empty($conditions)) { if (!empty($conditions)) {
@ -392,7 +392,7 @@ class DboMysqlBase extends DboSource {
} }
} }
if (is_array($value['column'])) { if (is_array($value['column'])) {
$out .= 'KEY '. $name .' (' . join(', ', array_map(array(&$this, 'name'), $value['column'])) . ')'; $out .= 'KEY '. $name .' (' . implode(', ', array_map(array(&$this, 'name'), $value['column'])) . ')';
} else { } else {
$out .= 'KEY '. $name .' (' . $this->name($value['column']) . ')'; $out .= 'KEY '. $name .' (' . $this->name($value['column']) . ')';
} }
@ -412,7 +412,7 @@ class DboMysqlBase extends DboSource {
function insertMulti($table, $fields, $values) { function insertMulti($table, $fields, $values) {
$table = $this->fullTableName($table); $table = $this->fullTableName($table);
if (is_array($fields)) { if (is_array($fields)) {
$fields = join(', ', array_map(array(&$this, 'name'), $fields)); $fields = implode(', ', array_map(array(&$this, 'name'), $fields));
} }
$values = implode(', ', $values); $values = implode(', ', $values);
$this->query("INSERT INTO {$table} ({$fields}) VALUES {$values}"); $this->query("INSERT INTO {$table} ({$fields}) VALUES {$values}");

View file

@ -95,7 +95,7 @@ class DboOdbc extends DboSource {
$connect = 'odbc_connect'; $connect = 'odbc_connect';
} }
if (!function_exists($connect)) { if (!function_exists($connect)) {
die('no odbc?'); exit('no odbc?');
} }
$this->connected = false; $this->connected = false;
$this->connection = $connect($config['database'], $config['login'], $config['password'], SQL_CUR_USE_ODBC); $this->connection = $connect($config['database'], $config['login'], $config['password'], SQL_CUR_USE_ODBC);

View file

@ -735,7 +735,7 @@ class DboOracle extends DboSource {
break; break;
} }
} }
$out .= "\t" . join(",\n\t", $colList) . ";\n\n"; $out .= "\t" . implode(",\n\t", $colList) . ";\n\n";
} }
} }
return $out; return $out;
@ -966,7 +966,7 @@ class DboOracle extends DboSource {
case 'schema': case 'schema':
foreach (array('columns', 'indexes') as $var) { foreach (array('columns', 'indexes') as $var) {
if (is_array(${$var})) { if (is_array(${$var})) {
${$var} = "\t" . join(",\n\t", array_filter(${$var})); ${$var} = "\t" . implode(",\n\t", array_filter(${$var}));
} }
} }
if (trim($indexes) != '') { if (trim($indexes) != '') {
@ -1019,7 +1019,7 @@ class DboOracle extends DboSource {
$fetch = array(); $fetch = array();
$ins = array_chunk($ins, 1000); $ins = array_chunk($ins, 1000);
foreach ($ins as $i) { foreach ($ins as $i) {
$q = str_replace('{$__cakeID__$}', join(', ', $i), $query); $q = str_replace('{$__cakeID__$}', implode(', ', $i), $query);
$q = str_replace('= (', 'IN (', $q); $q = str_replace('= (', 'IN (', $q);
$res = $this->fetchAll($q, $model->cacheQueries, $model->alias); $res = $this->fetchAll($q, $model->cacheQueries, $model->alias);
$fetch = array_merge($fetch, $res); $fetch = array_merge($fetch, $res);
@ -1063,7 +1063,7 @@ class DboOracle extends DboSource {
$fetch = array(); $fetch = array();
$ins = array_chunk($ins, 1000); $ins = array_chunk($ins, 1000);
foreach ($ins as $i) { foreach ($ins as $i) {
$q = str_replace('{$__cakeID__$}', '(' .join(', ', $i) .')', $query); $q = str_replace('{$__cakeID__$}', '(' .implode(', ', $i) .')', $query);
$q = str_replace('= (', 'IN (', $q); $q = str_replace('= (', 'IN (', $q);
$q = str_replace(' WHERE 1 = 1', '', $q); $q = str_replace(' WHERE 1 = 1', '', $q);

View file

@ -554,11 +554,11 @@ class DboPostgres extends DboSource {
} }
if (!empty($colList)) { if (!empty($colList)) {
$out .= "\t" . join(",\n\t", $colList) . ";\n\n"; $out .= "\t" . implode(",\n\t", $colList) . ";\n\n";
} else { } else {
$out = ''; $out = '';
} }
$out .= join(";\n\t", $this->_alterIndexes($curTable, $indexes)) . ";"; $out .= implode(";\n\t", $this->_alterIndexes($curTable, $indexes)) . ";";
} }
} }
return $out; return $out;
@ -596,7 +596,7 @@ class DboPostgres extends DboSource {
$out .= 'INDEX '; $out .= 'INDEX ';
} }
if (is_array($value['column'])) { if (is_array($value['column'])) {
$out .= $name . ' ON ' . $table . ' (' . join(', ', array_map(array(&$this, 'name'), $value['column'])) . ')'; $out .= $name . ' ON ' . $table . ' (' . implode(', ', array_map(array(&$this, 'name'), $value['column'])) . ')';
} else { } else {
$out .= $name . ' ON ' . $table . ' (' . $this->name($value['column']) . ')'; $out .= $name . ' ON ' . $table . ' (' . $this->name($value['column']) . ')';
} }
@ -855,7 +855,7 @@ class DboPostgres extends DboSource {
$out .= 'UNIQUE '; $out .= 'UNIQUE ';
} }
if (is_array($value['column'])) { if (is_array($value['column'])) {
$value['column'] = join(', ', array_map(array(&$this, 'name'), $value['column'])); $value['column'] = implode(', ', array_map(array(&$this, 'name'), $value['column']));
} else { } else {
$value['column'] = $this->name($value['column']); $value['column'] = $this->name($value['column']);
} }
@ -889,7 +889,7 @@ class DboPostgres extends DboSource {
foreach (array('columns', 'indexes') as $var) { foreach (array('columns', 'indexes') as $var) {
if (is_array(${$var})) { if (is_array(${$var})) {
${$var} = join($join[$var], array_filter(${$var})); ${$var} = implode($join[$var], array_filter(${$var}));
} }
} }
return "CREATE TABLE {$table} (\n\t{$columns}\n);\n{$indexes}"; return "CREATE TABLE {$table} (\n\t{$columns}\n);\n{$indexes}";

View file

@ -547,7 +547,7 @@ class DboSqlite extends DboSource {
$out .= 'UNIQUE '; $out .= 'UNIQUE ';
} }
if (is_array($value['column'])) { if (is_array($value['column'])) {
$value['column'] = join(', ', array_map(array(&$this, 'name'), $value['column'])); $value['column'] = implode(', ', array_map(array(&$this, 'name'), $value['column']));
} else { } else {
$value['column'] = $this->name($value['column']); $value['column'] = $this->name($value['column']);
} }
@ -608,7 +608,7 @@ class DboSqlite extends DboSource {
foreach (array('columns', 'indexes') as $var) { foreach (array('columns', 'indexes') as $var) {
if (is_array(${$var})) { if (is_array(${$var})) {
${$var} = "\t" . join(",\n\t", array_filter(${$var})); ${$var} = "\t" . implode(",\n\t", array_filter(${$var}));
} }
} }
return "CREATE TABLE {$table} (\n{$columns});\n{$indexes}"; return "CREATE TABLE {$table} (\n{$columns});\n{$indexes}";

View file

@ -630,8 +630,8 @@ class DboSource extends DataSource {
} }
$query = array( $query = array(
'table' => $this->fullTableName($model), 'table' => $this->fullTableName($model),
'fields' => join(', ', $fieldInsert), 'fields' => implode(', ', $fieldInsert),
'values' => join(', ', $valueInsert) 'values' => implode(', ', $valueInsert)
); );
if ($this->execute($this->renderStatement('create', $query))) { if ($this->execute($this->renderStatement('create', $query))) {
@ -849,7 +849,7 @@ class DboSource extends DataSource {
} }
if (!empty($ins)) { if (!empty($ins)) {
if (count($ins) > 1) { if (count($ins) > 1) {
$query = str_replace('{$__cakeID__$}', '(' .join(', ', $ins) .')', $query); $query = str_replace('{$__cakeID__$}', '(' .implode(', ', $ins) .')', $query);
$query = str_replace('= (', 'IN (', $query); $query = str_replace('= (', 'IN (', $query);
$query = str_replace('= (', 'IN (', $query); $query = str_replace('= (', 'IN (', $query);
} else { } else {
@ -949,7 +949,7 @@ class DboSource extends DataSource {
* @return array Association results * @return array Association results
*/ */
function fetchAssociated($model, $query, $ids) { function fetchAssociated($model, $query, $ids) {
$query = str_replace('{$__cakeID__$}', join(', ', $ids), $query); $query = str_replace('{$__cakeID__$}', implode(', ', $ids), $query);
if (count($ids) > 1) { if (count($ids) > 1) {
$query = str_replace('= (', 'IN (', $query); $query = str_replace('= (', 'IN (', $query);
$query = str_replace('= (', 'IN (', $query); $query = str_replace('= (', 'IN (', $query);
@ -1332,12 +1332,12 @@ class DboSource extends DataSource {
} }
return $this->renderStatement('select', array( return $this->renderStatement('select', array(
'conditions' => $this->conditions($query['conditions'], true, true, $model), 'conditions' => $this->conditions($query['conditions'], true, true, $model),
'fields' => join(', ', $query['fields']), 'fields' => implode(', ', $query['fields']),
'table' => $query['table'], 'table' => $query['table'],
'alias' => $this->alias . $this->name($query['alias']), 'alias' => $this->alias . $this->name($query['alias']),
'order' => $this->order($query['order']), 'order' => $this->order($query['order']),
'limit' => $this->limit($query['limit'], $query['offset']), 'limit' => $this->limit($query['limit'], $query['offset']),
'joins' => join(' ', $query['joins']), 'joins' => implode(' ', $query['joins']),
'group' => $this->group($query['group']) 'group' => $this->group($query['group'])
)); ));
} }
@ -1444,7 +1444,7 @@ class DboSource extends DataSource {
} else { } else {
$combined = array_combine($fields, $values); $combined = array_combine($fields, $values);
} }
$fields = join(', ', $this->_prepareUpdateFields($model, $combined, empty($conditions))); $fields = implode(', ', $this->_prepareUpdateFields($model, $combined, empty($conditions)));
$alias = $joins = null; $alias = $joins = null;
$table = $this->fullTableName($model); $table = $this->fullTableName($model);
@ -1807,7 +1807,7 @@ class DboSource extends DataSource {
} else { } else {
$field[0] = explode('.', $field[1]); $field[0] = explode('.', $field[1]);
if (!Set::numeric($field[0])) { if (!Set::numeric($field[0])) {
$field[0] = join('.', array_map(array($this, 'name'), $field[0])); $field[0] = implode('.', array_map(array($this, 'name'), $field[0]));
$fields[$i] = preg_replace('/\(' . $field[1] . '\)/', '(' . $field[0] . ')', $fields[$i], 1); $fields[$i] = preg_replace('/\(' . $field[1] . '\)/', '(' . $field[0] . ')', $fields[$i], 1);
} }
} }
@ -1840,7 +1840,7 @@ class DboSource extends DataSource {
if (empty($out)) { if (empty($out)) {
return $clause . ' 1 = 1'; return $clause . ' 1 = 1';
} }
return $clause . join(' AND ', $out); return $clause . implode(' AND ', $out);
} }
if (empty($conditions) || trim($conditions) == '' || $conditions === true) { if (empty($conditions) || trim($conditions) == '' || $conditions === true) {
@ -1910,7 +1910,7 @@ class DboSource extends DataSource {
$out[] = $value[0] ; $out[] = $value[0] ;
} }
} else { } else {
$out[] = '(' . $not . '(' . join(') ' . strtoupper($key) . ' (', $value) . '))'; $out[] = '(' . $not . '(' . implode(') ' . strtoupper($key) . ' (', $value) . '))';
} }
} else { } else {
@ -1937,13 +1937,13 @@ class DboSource extends DataSource {
if (is_object($model)) { if (is_object($model)) {
$columnType = $model->getColumnType($key); $columnType = $model->getColumnType($key);
} }
$data .= join(', ', $this->value($value, $columnType)); $data .= implode(', ', $this->value($value, $columnType));
} }
$data .= ')'; $data .= ')';
} else { } else {
$ret = $this->conditionKeysToString($value, $quoteValues, $model); $ret = $this->conditionKeysToString($value, $quoteValues, $model);
if (count($ret) > 1) { if (count($ret) > 1) {
$data = '(' . join(') AND (', $ret) . ')'; $data = '(' . implode(') AND (', $ret) . ')';
} elseif (isset($ret[0])) { } elseif (isset($ret[0])) {
$data = $ret[0]; $data = $ret[0];
} }
@ -1978,7 +1978,7 @@ class DboSource extends DataSource {
* @access private * @access private
*/ */
function __parseKey($model, $key, $value) { function __parseKey($model, $key, $value) {
$operatorMatch = '/^((' . join(')|(', $this->__sqlOps); $operatorMatch = '/^((' . implode(')|(', $this->__sqlOps);
$operatorMatch .= '\\x20)|<[>=]?(?![^>]+>)\\x20?|[>=!]{1,3}(?!<)\\x20?)/is'; $operatorMatch .= '\\x20)|<[>=]?(?![^>]+>)\\x20?|[>=!]{1,3}(?!<)\\x20?)/is';
$bound = (strpos($key, '?') !== false || (is_array($value) && strpos($key, ':') !== false)); $bound = (strpos($key, '?') !== false || (is_array($value) && strpos($key, ':') !== false));
@ -2024,7 +2024,7 @@ class DboSource extends DataSource {
$operator = trim($operator); $operator = trim($operator);
if (is_array($value)) { if (is_array($value)) {
$value = join(', ', $value); $value = implode(', ', $value);
switch ($operator) { switch ($operator) {
case '=': case '=':
@ -2124,7 +2124,7 @@ class DboSource extends DataSource {
$keys = array_filter($keys); $keys = array_filter($keys);
} }
if (empty($keys) || (is_array($keys) && count($keys) && isset($keys[0]) && empty($keys[0]))) { if (empty($keys) || (is_array($keys) && isset($keys[0]) && empty($keys[0]))) {
return ''; return '';
} }
@ -2154,7 +2154,7 @@ class DboSource extends DataSource {
} }
$order[] = $this->order($key . $value); $order[] = $this->order($key . $value);
} }
return ' ORDER BY ' . trim(str_replace('ORDER BY', '', join(',', $order))); return ' ORDER BY ' . trim(str_replace('ORDER BY', '', implode(',', $order)));
} }
$keys = preg_replace('/ORDER\\x20BY/i', '', $keys); $keys = preg_replace('/ORDER\\x20BY/i', '', $keys);
@ -2186,7 +2186,7 @@ class DboSource extends DataSource {
function group($group) { function group($group) {
if ($group) { if ($group) {
if (is_array($group)) { if (is_array($group)) {
$group = join(', ', $group); $group = implode(', ', $group);
} }
return ' GROUP BY ' . $this->__quoteFields($group); return ' GROUP BY ' . $this->__quoteFields($group);
} }
@ -2315,7 +2315,7 @@ class DboSource extends DataSource {
function insertMulti($table, $fields, $values) { function insertMulti($table, $fields, $values) {
$table = $this->fullTableName($table); $table = $this->fullTableName($table);
if (is_array($fields)) { if (is_array($fields)) {
$fields = join(', ', array_map(array(&$this, 'name'), $fields)); $fields = implode(', ', array_map(array(&$this, 'name'), $fields));
} }
$count = count($values); $count = count($values);
for ($x = 0; $x < $count; $x++) { for ($x = 0; $x < $count; $x++) {
@ -2521,7 +2521,7 @@ class DboSource extends DataSource {
$name = $this->startQuote . $name . $this->endQuote; $name = $this->startQuote . $name . $this->endQuote;
} }
if (is_array($value['column'])) { if (is_array($value['column'])) {
$out .= 'KEY ' . $name . ' (' . join(', ', array_map(array(&$this, 'name'), $value['column'])) . ')'; $out .= 'KEY ' . $name . ' (' . implode(', ', array_map(array(&$this, 'name'), $value['column'])) . ')';
} else { } else {
$out .= 'KEY ' . $name . ' (' . $this->name($value['column']) . ')'; $out .= 'KEY ' . $name . ' (' . $this->name($value['column']) . ')';
} }

View file

@ -748,8 +748,13 @@ class Model extends Overloadable {
if (is_array($joinClass)) { if (is_array($joinClass)) {
$joinClass = key($joinClass); $joinClass = key($joinClass);
} }
list($plugin, $joinClass) = pluginSplit($joinClass, true);
$this->{$type}[$assocKey]['with'] = $joinClass; $plugin = null;
if (strpos($joinClass, '.') !== false) {
list($plugin, $joinClass) = explode('.', $joinClass);
$plugin .= '.';
$this->{$type}[$assocKey]['with'] = $joinClass;
}
if (!ClassRegistry::isKeySet($joinClass) && $dynamicWith === true) { if (!ClassRegistry::isKeySet($joinClass) && $dynamicWith === true) {
$this->{$joinClass} = new AppModel(array( $this->{$joinClass} = new AppModel(array(
@ -1127,7 +1132,7 @@ class Model extends Overloadable {
return $data[$name[0]][$name[1]]; return $data[$name[0]][$name[1]];
} }
} }
if (isset($data[0]) && count($data[0]) > 0) { if (!empty($data[0])) {
$name = key($data[0]); $name = key($data[0]);
return $data[0][$name]; return $data[0][$name];
} }
@ -1353,14 +1358,6 @@ class Model extends Overloadable {
if (isset($this->hasAndBelongsToMany[$assoc])) { if (isset($this->hasAndBelongsToMany[$assoc])) {
list($join) = $this->joinModel($this->hasAndBelongsToMany[$assoc]['with']); list($join) = $this->joinModel($this->hasAndBelongsToMany[$assoc]['with']);
$conditions = array($join . '.' . $this->hasAndBelongsToMany[$assoc]['foreignKey'] => $id);
$links = $this->{$join}->find('all', array(
'conditions' => $conditions,
'recursive' => -1,
'fields' => $this->hasAndBelongsToMany[$assoc]['associationForeignKey']
));
$isUUID = !empty($this->{$join}->primaryKey) && ( $isUUID = !empty($this->{$join}->primaryKey) && (
$this->{$join}->_schema[$this->{$join}->primaryKey]['length'] == 36 && ( $this->{$join}->_schema[$this->{$join}->primaryKey]['length'] == 36 && (
$this->{$join}->_schema[$this->{$join}->primaryKey]['type'] === 'string' || $this->{$join}->_schema[$this->{$join}->primaryKey]['type'] === 'string' ||
@ -1391,7 +1388,7 @@ class Model extends Overloadable {
if ($isUUID && $primaryAdded) { if ($isUUID && $primaryAdded) {
$values[] = $db->value(String::uuid()); $values[] = $db->value(String::uuid());
} }
$values = join(',', $values); $values = implode(',', $values);
$newValues[] = "({$values})"; $newValues[] = "({$values})";
unset($values); unset($values);
} elseif (isset($row[$this->hasAndBelongsToMany[$assoc]['associationForeignKey']])) { } elseif (isset($row[$this->hasAndBelongsToMany[$assoc]['associationForeignKey']])) {
@ -1402,6 +1399,16 @@ class Model extends Overloadable {
} }
if ($this->hasAndBelongsToMany[$assoc]['unique']) { if ($this->hasAndBelongsToMany[$assoc]['unique']) {
$conditions = array_merge(
array($join . '.' . $this->hasAndBelongsToMany[$assoc]['foreignKey'] => $id),
(array)$this->hasAndBelongsToMany[$assoc]['conditions']
);
$links = $this->{$join}->find('all', array(
'conditions' => $conditions,
'recursive' => empty($this->hasAndBelongsToMany[$assoc]['conditions']) ? -1 : 0,
'fields' => $this->hasAndBelongsToMany[$assoc]['associationForeignKey']
));
$associationForeignKey = "{$join}." . $this->hasAndBelongsToMany[$assoc]['associationForeignKey']; $associationForeignKey = "{$join}." . $this->hasAndBelongsToMany[$assoc]['associationForeignKey'];
$oldLinks = Set::extract($links, "{n}.{$associationForeignKey}"); $oldLinks = Set::extract($links, "{n}.{$associationForeignKey}");
if (!empty($oldLinks)) { if (!empty($oldLinks)) {
@ -1419,7 +1426,7 @@ class Model extends Overloadable {
} }
if (!empty($newValues)) { if (!empty($newValues)) {
$fields = join(',', $fields); $fields = implode(',', $fields);
$db->insertMulti($this->{$join}, $fields, $newValues); $db->insertMulti($this->{$join}, $fields, $newValues);
} }
} }

View file

@ -32,7 +32,8 @@ if (function_exists('mb_internal_encoding')) {
* @param string $needle The string to find in $haystack. * @param string $needle The string to find in $haystack.
* @param integer $offset The position in $haystack to start searching. * @param integer $offset The position in $haystack to start searching.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string, or false if $needle is not found. * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string, or false
* if $needle is not found.
*/ */
if (!function_exists('mb_stripos')) { if (!function_exists('mb_stripos')) {
function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) { function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) {
@ -46,8 +47,9 @@ if (!function_exists('mb_stripos')) {
* @param string $haystack The string from which to get the first occurrence of $needle. * @param string $haystack The string from which to get the first occurrence of $needle.
* @param string $needle The string to find in $haystack. * @param string $needle The string to find in $haystack.
* @param boolean $part Determines which portion of $haystack this function returns. * @param boolean $part Determines which portion of $haystack this function returns.
* If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle.
* If set to false, it returns all of $haystack from the first occurrence of $needle to the end, Default value is false. * If set to false, it returns all of $haystack from the first occurrence of $needle to the end,
* Default value is false.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return string|boolean The portion of $haystack, or false if $needle is not found. * @return string|boolean The portion of $haystack, or false if $needle is not found.
*/ */
@ -63,7 +65,7 @@ if (!function_exists('mb_stristr')) {
* @param string $string The string being checked for length. * @param string $string The string being checked for length.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return integer The number of characters in string $string having character encoding encoding. * @return integer The number of characters in string $string having character encoding encoding.
* A multi-byte character is counted as 1. * A multi-byte character is counted as 1.
*/ */
if (!function_exists('mb_strlen')) { if (!function_exists('mb_strlen')) {
function mb_strlen($string, $encoding = null) { function mb_strlen($string, $encoding = null) {
@ -79,7 +81,7 @@ if (!function_exists('mb_strlen')) {
* @param integer $offset The search offset. If it is not specified, 0 is used. * @param integer $offset The search offset. If it is not specified, 0 is used.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string. * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string.
* If $needle is not found, it returns false. * If $needle is not found, it returns false.
*/ */
if (!function_exists('mb_strpos')) { if (!function_exists('mb_strpos')) {
function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) { function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) {
@ -93,8 +95,9 @@ if (!function_exists('mb_strpos')) {
* @param string $haystack The string from which to get the last occurrence of $needle. * @param string $haystack The string from which to get the last occurrence of $needle.
* @param string $needle The string to find in $haystack. * @param string $needle The string to find in $haystack.
* @param boolean $part Determines which portion of $haystack this function returns. * @param boolean $part Determines which portion of $haystack this function returns.
* If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle.
* If set to false, it returns all of $haystack from the last occurrence of $needle to the end, Default value is false. * If set to false, it returns all of $haystack from the last occurrence of $needle to the end,
* Default value is false.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return string|boolean The portion of $haystack. or false if $needle is not found. * @return string|boolean The portion of $haystack. or false if $needle is not found.
*/ */
@ -110,8 +113,9 @@ if (!function_exists('mb_strrchr')) {
* @param string $haystack The string from which to get the last occurrence of $needle. * @param string $haystack The string from which to get the last occurrence of $needle.
* @param string $needle The string to find in $haystack. * @param string $needle The string to find in $haystack.
* @param boolean $part Determines which portion of $haystack this function returns. * @param boolean $part Determines which portion of $haystack this function returns.
* If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle.
* If set to false, it returns all of $haystack from the last occurrence of $needle to the end, Default value is false. * If set to false, it returns all of $haystack from the last occurrence of $needle to the end,
* Default value is false.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return string|boolean The portion of $haystack. or false if $needle is not found. * @return string|boolean The portion of $haystack. or false if $needle is not found.
*/ */
@ -128,7 +132,8 @@ if (!function_exists('mb_strrichr')) {
* @param string $needle The string to find in $haystack. * @param string $needle The string to find in $haystack.
* @param integer $offset The position in $haystack to start searching. * @param integer $offset The position in $haystack to start searching.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string, or false if $needle is not found. * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string,
* or false if $needle is not found.
*/ */
if (!function_exists('mb_strripos')) { if (!function_exists('mb_strripos')) {
function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) { function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) {
@ -142,9 +147,10 @@ if (!function_exists('mb_strripos')) {
* @param string $haystack The string being checked, for the last occurrence of $needle. * @param string $haystack The string being checked, for the last occurrence of $needle.
* @param string $needle The string to find in $haystack. * @param string $needle The string to find in $haystack.
* @param integer $offset May be specified to begin searching an arbitrary number of characters into the string. * @param integer $offset May be specified to begin searching an arbitrary number of characters into the string.
* Negative values will stop searching at an arbitrary point prior to the end of the string. * Negative values will stop searching at an arbitrary point prior to the end of the string.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string. If $needle is not found, it returns false. * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string.
* If $needle is not found, it returns false.
*/ */
if (!function_exists('mb_strrpos')) { if (!function_exists('mb_strrpos')) {
function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) { function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) {
@ -158,8 +164,9 @@ if (!function_exists('mb_strrpos')) {
* @param string $haystack The string from which to get the first occurrence of $needle. * @param string $haystack The string from which to get the first occurrence of $needle.
* @param string $needle The string to find in $haystack * @param string $needle The string to find in $haystack
* @param boolean $part Determines which portion of $haystack this function returns. * @param boolean $part Determines which portion of $haystack this function returns.
* If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle.
* If set to false, it returns all of $haystack from the first occurrence of $needle to the end, Default value is FALSE. * If set to false, it returns all of $haystack from the first occurrence of $needle to the end,
* Default value is FALSE.
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
* @return string|boolean The portion of $haystack, or true if $needle is not found. * @return string|boolean The portion of $haystack, or true if $needle is not found.
*/ */
@ -229,12 +236,13 @@ if (!function_exists('mb_substr')) {
* *
* @param string $str The string being encoded * @param string $str The string being encoded
* @param string $charset specifies the name of the character set in which str is represented in. * @param string $charset specifies the name of the character set in which str is represented in.
* The default value is determined by the current NLS setting (mbstring.language). * The default value is determined by the current NLS setting (mbstring.language).
* @param string $transfer_encoding specifies the scheme of MIME encoding. It should be either "B" (Base64) or "Q" (Quoted-Printable). * @param string $transfer_encoding specifies the scheme of MIME encoding.
* Falls back to "B" if not given. * It should be either "B" (Base64) or "Q" (Quoted-Printable). Falls back to "B" if not given.
* @param string $linefeed specifies the EOL (end-of-line) marker with which mb_encode_mimeheader() performs line-folding * @param string $linefeed specifies the EOL (end-of-line) marker with which
* (a » RFC term, the act of breaking a line longer than a certain length into multiple lines. * mb_encode_mimeheader() performs line-folding
* The length is currently hard-coded to 74 characters). Falls back to "\r\n" (CRLF) if not given. * (a » RFC term, the act of breaking a line longer than a certain length into multiple lines.
* The length is currently hard-coded to 74 characters). Falls back to "\r\n" (CRLF) if not given.
* @param integer $indent [definition unknown and appears to have no affect] * @param integer $indent [definition unknown and appears to have no affect]
* @return string A converted version of the string represented in ASCII. * @return string A converted version of the string represented in ASCII.
*/ */
@ -315,7 +323,7 @@ class Multibyte extends Object {
if ($value < 128) { if ($value < 128) {
$map[] = $value; $map[] = $value;
} else { } else {
if (count($values) == 0) { if (empty($values)) {
$find = ($value < 224) ? 2 : 3; $find = ($value < 224) ? 2 : 3;
} }
$values[] = $value; $values[] = $value;
@ -367,7 +375,8 @@ class Multibyte extends Object {
* @param multi-byte string $haystack The string from which to get the position of the first occurrence of $needle. * @param multi-byte string $haystack The string from which to get the position of the first occurrence of $needle.
* @param multi-byte string $needle The string to find in $haystack. * @param multi-byte string $needle The string to find in $haystack.
* @param integer $offset The position in $haystack to start searching. * @param integer $offset The position in $haystack to start searching.
* @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string, or false if $needle is not found. * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string,
* or false if $needle is not found.
* @access public * @access public
* @static * @static
*/ */
@ -386,8 +395,9 @@ class Multibyte extends Object {
* @param string $haystack The string from which to get the first occurrence of $needle. * @param string $haystack The string from which to get the first occurrence of $needle.
* @param string $needle The string to find in $haystack. * @param string $needle The string to find in $haystack.
* @param boolean $part Determines which portion of $haystack this function returns. * @param boolean $part Determines which portion of $haystack this function returns.
* If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle.
* If set to false, it returns all of $haystack from the first occurrence of $needle to the end, Default value is false. * If set to false, it returns all of $haystack from the first occurrence of $needle to the end,
* Default value is false.
* @return int|boolean The portion of $haystack, or false if $needle is not found. * @return int|boolean The portion of $haystack, or false if $needle is not found.
* @access public * @access public
* @static * @static
@ -465,7 +475,7 @@ class Multibyte extends Object {
* @param string $needle The position counted from the beginning of haystack. * @param string $needle The position counted from the beginning of haystack.
* @param integer $offset The search offset. If it is not specified, 0 is used. * @param integer $offset The search offset. If it is not specified, 0 is used.
* @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string. * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string.
* If $needle is not found, it returns false. * If $needle is not found, it returns false.
* @access public * @access public
* @static * @static
*/ */
@ -509,8 +519,9 @@ class Multibyte extends Object {
* @param string $haystack The string from which to get the last occurrence of $needle. * @param string $haystack The string from which to get the last occurrence of $needle.
* @param string $needle The string to find in $haystack. * @param string $needle The string to find in $haystack.
* @param boolean $part Determines which portion of $haystack this function returns. * @param boolean $part Determines which portion of $haystack this function returns.
* If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle.
* If set to false, it returns all of $haystack from the last occurrence of $needle to the end, Default value is false. * If set to false, it returns all of $haystack from the last occurrence of $needle to the end,
* Default value is false.
* @return string|boolean The portion of $haystack. or false if $needle is not found. * @return string|boolean The portion of $haystack. or false if $needle is not found.
* @access public * @access public
* @static * @static
@ -570,8 +581,9 @@ class Multibyte extends Object {
* @param string $haystack The string from which to get the last occurrence of $needle. * @param string $haystack The string from which to get the last occurrence of $needle.
* @param string $needle The string to find in $haystack. * @param string $needle The string to find in $haystack.
* @param boolean $part Determines which portion of $haystack this function returns. * @param boolean $part Determines which portion of $haystack this function returns.
* If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle.
* If set to false, it returns all of $haystack from the last occurrence of $needle to the end, Default value is false. * If set to false, it returns all of $haystack from the last occurrence of $needle to the end,
* Default value is false.
* @return string|boolean The portion of $haystack. or false if $needle is not found. * @return string|boolean The portion of $haystack. or false if $needle is not found.
* @access public * @access public
* @static * @static
@ -633,7 +645,8 @@ class Multibyte extends Object {
* @param string $haystack The string from which to get the position of the last occurrence of $needle. * @param string $haystack The string from which to get the position of the last occurrence of $needle.
* @param string $needle The string to find in $haystack. * @param string $needle The string to find in $haystack.
* @param integer $offset The position in $haystack to start searching. * @param integer $offset The position in $haystack to start searching.
* @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string, or false if $needle is not found. * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string,
* or false if $needle is not found.
* @access public * @access public
* @static * @static
*/ */
@ -684,8 +697,9 @@ class Multibyte extends Object {
* @param string $haystack The string being checked, for the last occurrence of $needle. * @param string $haystack The string being checked, for the last occurrence of $needle.
* @param string $needle The string to find in $haystack. * @param string $needle The string to find in $haystack.
* @param integer $offset May be specified to begin searching an arbitrary number of characters into the string. * @param integer $offset May be specified to begin searching an arbitrary number of characters into the string.
* Negative values will stop searching at an arbitrary point prior to the end of the string. * Negative values will stop searching at an arbitrary point prior to the end of the string.
* @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string. If $needle is not found, it returns false. * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string.
* If $needle is not found, it returns false.
* @access public * @access public
* @static * @static
*/ */
@ -735,8 +749,9 @@ class Multibyte extends Object {
* @param string $haystack The string from which to get the first occurrence of $needle. * @param string $haystack The string from which to get the first occurrence of $needle.
* @param string $needle The string to find in $haystack * @param string $needle The string to find in $haystack
* @param boolean $part Determines which portion of $haystack this function returns. * @param boolean $part Determines which portion of $haystack this function returns.
* If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle.
* If set to false, it returns all of $haystack from the first occurrence of $needle to the end, Default value is FALSE. * If set to false, it returns all of $haystack from the first occurrence of $needle to the end,
* Default value is FALSE.
* @return string|boolean The portion of $haystack, or true if $needle is not found. * @return string|boolean The portion of $haystack, or true if $needle is not found.
* @access public * @access public
* @static * @static
@ -879,14 +894,14 @@ class Multibyte extends Object {
if ($length > 1 && count($keys[$key]['lower']) > 1) { if ($length > 1 && count($keys[$key]['lower']) > 1) {
$j = 0; $j = 0;
for ($ii = 0; $ii < count($keys[$key]['lower']); $ii++) { for ($ii = 0, $count = count($keys[$key]['lower']); $ii < $count; $ii++) {
$nextChar = $utf8Map[$i + $ii]; $nextChar = $utf8Map[$i + $ii];
if (isset($nextChar) && ($nextChar == $keys[$key]['lower'][$j + $ii])) { if (isset($nextChar) && ($nextChar == $keys[$key]['lower'][$j + $ii])) {
$replace++; $replace++;
} }
} }
if ($replace == count($keys[$key]['lower'])) { if ($replace == $count) {
$upperCase[] = $keys[$key]['upper']; $upperCase[] = $keys[$key]['upper'];
$replaced = array_merge($replaced, array_values($keys[$key]['lower'])); $replaced = array_merge($replaced, array_values($keys[$key]['lower']));
$matched = true; $matched = true;
@ -899,14 +914,14 @@ class Multibyte extends Object {
if (in_array($nextChar, $keys[$ii]['lower'])) { if (in_array($nextChar, $keys[$ii]['lower'])) {
for ($jj = 0; $jj < count($keys[$ii]['lower']); $jj++) { for ($jj = 0, $count = count($keys[$ii]['lower']); $jj < $count; $jj++) {
$nextChar = $utf8Map[$i + $jj]; $nextChar = $utf8Map[$i + $jj];
if (isset($nextChar) && ($nextChar == $keys[$ii]['lower'][$j + $jj])) { if (isset($nextChar) && ($nextChar == $keys[$ii]['lower'][$j + $jj])) {
$replace++; $replace++;
} }
} }
if ($replace == count($keys[$ii]['lower'])) { if ($replace == $count) {
$upperCase[] = $keys[$ii]['upper']; $upperCase[] = $keys[$ii]['upper'];
$replaced = array_merge($replaced, array_values($keys[$ii]['lower'])); $replaced = array_merge($replaced, array_values($keys[$ii]['lower']));
$matched = true; $matched = true;

View file

@ -410,7 +410,7 @@ class Router {
$parsed[] = '/' . $element; $parsed[] = '/' . $element;
} }
} }
return array('#^' . join('', $parsed) . '[\/]*$#', $names); return array('#^' . implode('', $parsed) . '[\/]*$#', $names);
} }
/** /**
@ -941,11 +941,11 @@ class Router {
break; break;
} }
} }
$output = join('/', $urlOut) . '/'; $output = implode('/', $urlOut) . '/';
} }
if (!empty($args)) { if (!empty($args)) {
$args = join('/', $args); $args = implode('/', $args);
if ($output{strlen($output) - 1} != '/') { if ($output{strlen($output) - 1} != '/') {
$args = '/'. $args; $args = '/'. $args;
} }
@ -1132,7 +1132,7 @@ class Router {
for ($i = 0; $i < $count; $i++) { for ($i = 0; $i < $count; $i++) {
$named[] = $keys[$i] . $this->named['separator'] . $params['named'][$keys[$i]]; $named[] = $keys[$i] . $this->named['separator'] . $params['named'][$keys[$i]];
} }
$params['named'] = join('/', $named); $params['named'] = implode('/', $named);
} }
$params['pass'] = str_replace('//', '/', $params['pass'] . '/' . $params['named']); $params['pass'] = str_replace('//', '/', $params['pass'] . '/' . $params['named']);
} }

View file

@ -165,7 +165,7 @@ class Sanitize {
$params = params(func_get_args()); $params = params(func_get_args());
$str = $params[0]; $str = $params[0];
for ($i = 1; $i < count($params); $i++) { for ($i = 1, $count = count($params); $i < $count; $i++) {
$str = preg_replace('/<' . $params[$i] . '\b[^>]*>/i', '', $str); $str = preg_replace('/<' . $params[$i] . '\b[^>]*>/i', '', $str);
$str = preg_replace('/<\/' . $params[$i] . '[^>]*>/i', '', $str); $str = preg_replace('/<\/' . $params[$i] . '[^>]*>/i', '', $str);
} }

View file

@ -418,7 +418,7 @@ class Set {
if (count($context['trace']) == 1) { if (count($context['trace']) == 1) {
$context['trace'][] = $context['key']; $context['trace'][] = $context['key'];
} }
$parent = join('/', $context['trace']) . '/.'; $parent = implode('/', $context['trace']) . '/.';
$context['item'] = Set::extract($parent, $data); $context['item'] = Set::extract($parent, $data);
$context['key'] = array_pop($context['trace']); $context['key'] = array_pop($context['trace']);
if (isset($context['trace'][1]) && $context['trace'][1] > 0) { if (isset($context['trace'][1]) && $context['trace'][1] > 0) {
@ -1098,7 +1098,7 @@ class Set {
if (!is_null($key)) { if (!is_null($key)) {
$id = $key; $id = $key;
} }
if (is_array($r) && count($r)) { if (is_array($r) && !empty($r)) {
$stack = array_merge($stack, Set::__flatten($r, $id)); $stack = array_merge($stack, Set::__flatten($r, $id));
} else { } else {
$stack[] = array('id' => $id, 'value' => $r); $stack[] = array('id' => $id, 'value' => $r);

View file

@ -626,10 +626,10 @@ class Validation extends Object {
if (empty($check)) { if (empty($check)) {
return false; return false;
} }
if ($options['max'] && sizeof($check) > $options['max']) { if ($options['max'] && count($check) > $options['max']) {
return false; return false;
} }
if ($options['min'] && sizeof($check) < $options['min']) { if ($options['min'] && count($check) < $options['min']) {
return false; return false;
} }
if ($options['in'] && is_array($options['in'])) { if ($options['in'] && is_array($options['in'])) {

View file

@ -198,24 +198,27 @@ class Helper extends Overloadable {
* @return string $webPath web path to file. * @return string $webPath web path to file.
*/ */
function webroot($file) { function webroot($file) {
$webPath = "{$this->webroot}" . $file; $asset = explode('?', $file);
if (!empty($this->themeWeb)) { $asset[1] = isset($asset[1]) ? '?' . $asset[1] : null;
$os = env('OS'); $webPath = "{$this->webroot}" . $asset[0];
if (!empty($os) && strpos($os, 'Windows') !== false) {
if (strpos(WWW_ROOT . $this->themeWeb . $file, '\\') !== false) { if (!empty($this->theme)) {
$path = str_replace('/', '\\', WWW_ROOT . $this->themeWeb . $file); $viewPaths = App::path('views');
foreach ($viewPaths as $viewPath) {
$path = $viewPath . 'themed'. DS . $this->theme . DS . 'webroot' . DS . $asset[0];
$theme = $this->theme . '/';
if (file_exists($path)) {
$webPath = "{$this->webroot}theme/" . $theme . $asset[0];
break;
} }
} else {
$path = WWW_ROOT . $this->themeWeb . $file;
}
if (file_exists($path)) {
$webPath = "{$this->webroot}" . $this->themeWeb . $file;
} }
} }
if (strpos($webPath, '//') !== false) { if (strpos($webPath, '//') !== false) {
return str_replace('//', '/', $webPath); return str_replace('//', '/', $webPath);
} }
return $webPath; return $webPath . $asset[1];
} }
/** /**
@ -602,7 +605,7 @@ class Helper extends Overloadable {
$name = $field; $name = $field;
break; break;
default: default:
$name = 'data[' . join('][', $view->entity()) . ']'; $name = 'data[' . implode('][', $view->entity()) . ']';
break; break;
} }

View file

@ -261,7 +261,7 @@ class AjaxHelper extends AppHelper {
$options['requestHeaders'] = array(); $options['requestHeaders'] = array();
} }
if (is_array($options['update'])) { if (is_array($options['update'])) {
$options['update'] = join(' ', $options['update']); $options['update'] = implode(' ', $options['update']);
} }
$options['requestHeaders']['X-Update'] = $options['update']; $options['requestHeaders']['X-Update'] = $options['update'];
} else { } else {
@ -824,7 +824,7 @@ class AjaxHelper extends AppHelper {
$keys[] = "'" . $key . "'"; $keys[] = "'" . $key . "'";
$keys[] = "'" . $val . "'"; $keys[] = "'" . $val . "'";
} }
$jsOptions['requestHeaders'] = '[' . join(', ', $keys) . ']'; $jsOptions['requestHeaders'] = '[' . implode(', ', $keys) . ']';
break; break;
} }
} }
@ -873,7 +873,7 @@ class AjaxHelper extends AppHelper {
} }
} }
$out = join(', ', $out); $out = implode(', ', $out);
$out = '{' . $out . '}'; $out = '{' . $out . '}';
return $out; return $out;
} else { } else {
@ -996,7 +996,7 @@ class AjaxHelper extends AppHelper {
$data[] = $key . ':"' . rawurlencode($val) . '"'; $data[] = $key . ':"' . rawurlencode($val) . '"';
} }
} }
$out = 'var __ajaxUpdater__ = {' . join(", \n", $data) . '};' . "\n"; $out = 'var __ajaxUpdater__ = {' . implode(", \n", $data) . '};' . "\n";
$out .= 'for (n in __ajaxUpdater__) { if (typeof __ajaxUpdater__[n] == "string"'; $out .= 'for (n in __ajaxUpdater__) { if (typeof __ajaxUpdater__[n] == "string"';
$out .= ' && $(n)) Element.update($(n), unescape(decodeURIComponent('; $out .= ' && $(n)) Element.update($(n), unescape(decodeURIComponent(';
$out .= '__ajaxUpdater__[n]))); }'; $out .= '__ajaxUpdater__[n]))); }';

View file

@ -268,7 +268,7 @@ class CacheHelper extends AppHelper {
$controller->params = $this->params = unserialize(stripslashes(\'' . addslashes(serialize($this->params)) . '\')); $controller->params = $this->params = unserialize(stripslashes(\'' . addslashes(serialize($this->params)) . '\'));
$controller->action = $this->action = unserialize(\'' . serialize($this->action) . '\'); $controller->action = $this->action = unserialize(\'' . serialize($this->action) . '\');
$controller->data = $this->data = unserialize(stripslashes(\'' . addslashes(serialize($this->data)) . '\')); $controller->data = $this->data = unserialize(stripslashes(\'' . addslashes(serialize($this->data)) . '\'));
$controller->themeWeb = $this->themeWeb = \'' . $this->themeWeb . '\'; $controller->theme = $this->theme = \'' . $this->theme . '\';
Router::setRequestInfo(array($this->params, array(\'base\' => $this->base, \'webroot\' => $this->webroot)));'; Router::setRequestInfo(array($this->params, array(\'base\' => $this->base, \'webroot\' => $this->webroot)));';
if ($useCallbacks == true) { if ($useCallbacks == true) {

View file

@ -409,7 +409,7 @@ class FormHelper extends AppHelper {
} }
} }
} }
$field = join('.', $field); $field = implode('.', $field);
if (!in_array($field, $this->fields)) { if (!in_array($field, $this->fields)) {
if ($value !== null) { if ($value !== null) {
return $this->fields[$field] = $value; return $this->fields[$field] = $value;
@ -1028,7 +1028,7 @@ class FormHelper extends AppHelper {
)); ));
} }
} }
$out = $hidden . join($inbetween, $out); $out = $hidden . implode($inbetween, $out);
if ($legend) { if ($legend) {
$out = sprintf( $out = sprintf(

View file

@ -559,7 +559,7 @@ class HtmlHelper extends AppHelper {
if ($oneline) { if ($oneline) {
return join(' ', $out); return join(' ', $out);
} }
return join("\n", $out); return implode("\n", $out);
} }
/** /**
@ -571,7 +571,7 @@ class HtmlHelper extends AppHelper {
* @access public * @access public
*/ */
function getCrumbs($separator = '&raquo;', $startText = false) { function getCrumbs($separator = '&raquo;', $startText = false) {
if (count($this->_crumbs)) { if (!empty($this->_crumbs)) {
$out = array(); $out = array();
if ($startText) { if ($startText) {
$out[] = $this->link($startText, '/'); $out[] = $this->link($startText, '/');
@ -694,7 +694,7 @@ class HtmlHelper extends AppHelper {
$cellsOut[] = sprintf($this->tags['tablecell'], $this->_parseAttributes($cellOptions), $cell); $cellsOut[] = sprintf($this->tags['tablecell'], $this->_parseAttributes($cellOptions), $cell);
} }
$options = $this->_parseAttributes($count % 2 ? $oddTrOptions : $evenTrOptions); $options = $this->_parseAttributes($count % 2 ? $oddTrOptions : $evenTrOptions);
$out[] = sprintf($this->tags['tablerow'], $options, join(' ', $cellsOut)); $out[] = sprintf($this->tags['tablerow'], $options, implode(' ', $cellsOut));
} }
return implode("\n", $out); return implode("\n", $out);
} }

View file

@ -655,9 +655,9 @@ class JavascriptHelper extends AppHelper {
} }
if (!$numeric) { if (!$numeric) {
$rt = '{' . join(',', $out) . '}'; $rt = '{' . implode(',', $out) . '}';
} else { } else {
$rt = '[' . join(',', $out) . ']'; $rt = '[' . implode(',', $out) . ']';
} }
} }
$rt = $options['prefix'] . $rt . $options['postfix']; $rt = $options['prefix'] . $rt . $options['postfix'];

View file

@ -217,7 +217,7 @@ class RssHelper extends XmlHelper {
} }
$categories[] = $this->elem($key, $attrib, $category); $categories[] = $this->elem($key, $attrib, $category);
} }
$elements[$key] = join('', $categories); $elements[$key] = implode('', $categories);
continue 2; continue 2;
} else if (is_array($val) && isset($val['domain'])) { } else if (is_array($val) && isset($val['domain'])) {
$attrib['domain'] = $val['domain']; $attrib['domain'] = $val['domain'];
@ -267,7 +267,7 @@ class RssHelper extends XmlHelper {
$elements[$key] = $this->elem($key, $attrib, $val); $elements[$key] = $this->elem($key, $attrib, $val);
} }
if (!empty($elements)) { if (!empty($elements)) {
$content = join('', $elements); $content = implode('', $elements);
} }
return $this->elem('item', $att, $content, !($content === null)); return $this->elem('item', $att, $content, !($content === null));
} }

View file

@ -62,7 +62,7 @@ class TimeHelper extends AppHelper {
if (empty($dateString)) { if (empty($dateString)) {
return false; return false;
} }
if (is_integer($dateString) || is_numeric($dateString)) { if (is_int($dateString) || is_numeric($dateString)) {
$date = intval($dateString); $date = intval($dateString);
} else { } else {
$date = strtotime($dateString); $date = strtotime($dateString);

View file

@ -17,7 +17,7 @@
* @since CakePHP(tm) v 1.2.0.5714 * @since CakePHP(tm) v 1.2.0.5714
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
class MediaView extends View { class MediaView {
/** /**
* Holds known mime type mappings * Holds known mime type mappings
@ -90,8 +90,7 @@ class MediaView extends View {
* *
* @param object $controller * @param object $controller
*/ */
function __construct(&$controller) { function __construct($controller = null) {
parent::__construct($controller);
} }
/** /**

View file

@ -40,12 +40,6 @@ class ThemeView extends View {
function __construct(&$controller) { function __construct(&$controller) {
parent::__construct($controller); parent::__construct($controller);
$this->theme =& $controller->theme; $this->theme =& $controller->theme;
if (!empty($this->theme)) {
if (is_dir(WWW_ROOT . 'themed' . DS . $this->theme)) {
$this->themeWeb = 'themed/'. $this->theme .'/';
}
}
} }
/** /**

View file

@ -167,7 +167,7 @@ class View extends Object {
* *
* @var string * @var string
*/ */
var $themeWeb = null; var $theme = null;
/** /**
* Used to define methods a controller that will be cached. * Used to define methods a controller that will be cached.
@ -454,7 +454,7 @@ class View extends Object {
$dataForLayout = array_merge($this->viewVars, array( $dataForLayout = array_merge($this->viewVars, array(
'content_for_layout' => $content_for_layout, 'content_for_layout' => $content_for_layout,
'scripts_for_layout' => join("\n\t", $this->__scripts), 'scripts_for_layout' => implode("\n\t", $this->__scripts),
'cakeDebug' => $debug 'cakeDebug' => $debug
)); ));
@ -779,9 +779,7 @@ class View extends Object {
} }
} }
$loaded[$helper] =& new $helperCn($options); $loaded[$helper] =& new $helperCn($options);
$vars = array( $vars = array('base', 'webroot', 'here', 'params', 'action', 'data', 'theme', 'plugin');
'base', 'webroot', 'here', 'params', 'action', 'data', 'themeWeb', 'plugin'
);
$c = count($vars); $c = count($vars);
for ($j = 0; $j < $c; $j++) { for ($j = 0; $j < $c; $j++) {
@ -837,7 +835,6 @@ class View extends Object {
$name = $this->viewPath . DS . $subDir . $name; $name = $this->viewPath . DS . $subDir . $name;
} }
} }
$paths = $this->_paths(Inflector::underscore($this->plugin)); $paths = $this->_paths(Inflector::underscore($this->plugin));
$exts = array($this->ext); $exts = array($this->ext);

View file

@ -590,7 +590,7 @@ class XmlNode extends Object {
* @access public * @access public
*/ */
function hasChildren() { function hasChildren() {
if (is_array($this->children) && count($this->children) > 0) { if (is_array($this->children) && !empty($this->children)) {
return true; return true;
} }
return false; return false;
@ -618,7 +618,7 @@ class XmlNode extends Object {
} }
$d .= '<' . $this->name(); $d .= '<' . $this->name();
if (count($this->namespaces) > 0) { if (!empty($this->namespaces) > 0) {
foreach ($this->namespaces as $key => $val) { foreach ($this->namespaces as $key => $val) {
$val = str_replace('"', '\"', $val); $val = str_replace('"', '\"', $val);
$d .= ' xmlns:' . $key . '="' . $val . '"'; $d .= ' xmlns:' . $key . '="' . $val . '"';
@ -626,14 +626,14 @@ class XmlNode extends Object {
} }
$parent =& $this->parent(); $parent =& $this->parent();
if ($parent->name === '#document' && count($parent->namespaces) > 0) { if ($parent->name === '#document' && !empty($parent->namespaces)) {
foreach ($parent->namespaces as $key => $val) { foreach ($parent->namespaces as $key => $val) {
$val = str_replace('"', '\"', $val); $val = str_replace('"', '\"', $val);
$d .= ' xmlns:' . $key . '="' . $val . '"'; $d .= ' xmlns:' . $key . '="' . $val . '"';
} }
} }
if (is_array($this->attributes) && count($this->attributes) > 0) { if (is_array($this->attributes) && !empty($this->attributes)) {
foreach ($this->attributes as $key => $val) { foreach ($this->attributes as $key => $val) {
if (is_bool($val) && $val === false) { if (is_bool($val) && $val === false) {
$val = 0; $val = 0;

View file

@ -1780,60 +1780,84 @@ class DispatcherTest extends CakeTestCase {
App::build(array( App::build(array(
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
'vendors' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors'. DS) 'vendors' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors'. DS),
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
)); ));
$Dispatcher =& new TestDispatcher(); $Dispatcher =& new TestDispatcher();
$debug = Configure::read('debug');
Configure::write('debug', 0); Configure::write('debug', 0);
ob_start(); ob_start();
$Dispatcher->dispatch('img/test.jpg'); $Dispatcher->dispatch('theme/test_theme/../webroot/css/test_asset.css');
$result = ob_get_clean(); $result = ob_get_clean();
$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS . 'img' . DS . 'test.jpg'); $this->assertEqual(null, $result);
ob_start();
$Dispatcher->dispatch('theme/test_theme/flash/theme_test.swf');
$result = ob_get_clean();
$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'flash' . DS . 'theme_test.swf');
$this->assertEqual($file, $result);
$this->assertEqual('this is just a test to load swf file from the theme.', $result);
ob_start();
$Dispatcher->dispatch('theme/test_theme/pdfs/theme_test.pdf');
$result = ob_get_clean();
$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'pdfs' . DS . 'theme_test.pdf');
$this->assertEqual($file, $result);
$this->assertEqual('this is just a test to load pdf file from the theme.', $result);
ob_start();
$Dispatcher->dispatch('theme/test_theme/img/test.jpg');
$result = ob_get_clean();
$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'img' . DS . 'test.jpg');
$this->assertEqual($file, $result); $this->assertEqual($file, $result);
Configure::write('debug', 0); $Dispatcher->params = $Dispatcher->parseParams('theme/test_theme/css/test_asset.css');
$Dispatcher->params = $Dispatcher->parseParams('css/test_asset.css');
ob_start(); ob_start();
$Dispatcher->cached('css/test_asset.css'); $Dispatcher->cached('theme/test_theme/css/test_asset.css');
$result = ob_get_clean(); $result = ob_get_clean();
$this->assertEqual('this is the test asset css file', $result); $this->assertEqual('this is the test asset css file', $result);
ob_start();
$Dispatcher->dispatch('test_plugin/flash/plugin_test.swf');
$result = ob_get_clean();
$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'webroot' . DS . 'flash' . DS . 'plugin_test.swf');
$this->assertEqual($file, $result);
$this->assertEqual('this is just a test to load swf file from the plugin.', $result);
ob_start();
$Dispatcher->dispatch('test_plugin/pdfs/plugin_test.pdf');
$result = ob_get_clean();
$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'webroot' . DS . 'pdfs' . DS . 'plugin_test.pdf');
$this->assertEqual($file, $result);
$this->assertEqual('this is just a test to load pdf file from the plugin.', $result);
ob_start(); ob_start();
$Dispatcher->cached('test_plugin/js/test_plugin/test.js'); $Dispatcher->cached('test_plugin/js/test_plugin/test.js');
$result = ob_get_clean(); $result = ob_get_clean();
$this->assertEqual('alert("Test App");', $result); $this->assertEqual('alert("Test App");', $result);
Configure::write('debug', 0);
$Dispatcher->params = $Dispatcher->parseParams('test_plugin/js/test_plugin/test.js'); $Dispatcher->params = $Dispatcher->parseParams('test_plugin/js/test_plugin/test.js');
ob_start(); ob_start();
$Dispatcher->cached('test_plugin/js/test_plugin/test.js'); $Dispatcher->cached('test_plugin/js/test_plugin/test.js');
$result = ob_get_clean(); $result = ob_get_clean();
$this->assertEqual('alert("Test App");', $result); $this->assertEqual('alert("Test App");', $result);
Configure::write('debug', 0);
$Dispatcher->params = $Dispatcher->parseParams('test_plugin/css/test_plugin_asset.css'); $Dispatcher->params = $Dispatcher->parseParams('test_plugin/css/test_plugin_asset.css');
ob_start(); ob_start();
$Dispatcher->cached('test_plugin/css/test_plugin_asset.css'); $Dispatcher->cached('test_plugin/css/test_plugin_asset.css');
$result = ob_get_clean(); $result = ob_get_clean();
$this->assertEqual('this is the test plugin asset css file', $result); $this->assertEqual('this is the test plugin asset css file', $result);
Configure::write('debug', 0);
$Dispatcher->params = $Dispatcher->parseParams('test_plugin/img/cake.icon.gif'); $Dispatcher->params = $Dispatcher->parseParams('test_plugin/img/cake.icon.gif');
ob_start(); ob_start();
$Dispatcher->cached('test_plugin/img/cake.icon.gif'); $Dispatcher->cached('test_plugin/img/cake.icon.gif');
$result = ob_get_clean(); $result = ob_get_clean();
$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' .DS . 'vendors' . DS . 'img' . DS . 'cake.icon.gif'); $file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' .DS . 'webroot' . DS . 'img' . DS . 'cake.icon.gif');
$this->assertEqual($file, $result); $this->assertEqual($file, $result);
Configure::write('debug', 2); Configure::write('debug', $debug);
$Dispatcher->params = $Dispatcher->parseParams('plugin_js/js/plugin_js.js'); $Dispatcher->params = $Dispatcher->parseParams('plugin_js/js/plugin_js.js');
ob_start(); ob_start();
$Dispatcher->cached('plugin_js/js/plugin_js.js'); $Dispatcher->cached('plugin_js/js/plugin_js.js');

View file

@ -222,6 +222,9 @@ class ConfigureTest extends CakeTestCase {
$result = Configure::load('config'); $result = Configure::load('config');
$this->assertTrue($result === null); $this->assertTrue($result === null);
$result = Configure::load('../../index');
$this->assertFalse($result);
} }
/** /**

View file

@ -240,7 +240,7 @@ class DebuggerTest extends CakeTestCase {
View::$autoLayout = true View::$autoLayout = true
View::$ext = ".ctp" View::$ext = ".ctp"
View::$subDir = NULL View::$subDir = NULL
View::$themeWeb = NULL View::$theme = NULL
View::$cacheAction = false View::$cacheAction = false
View::$validationErrors = array View::$validationErrors = array
View::$hasRendered = false View::$hasRendered = false
@ -256,7 +256,6 @@ class DebuggerTest extends CakeTestCase {
View::$__passedVars = array View::$__passedVars = array
View::$__scripts = array View::$__scripts = array
View::$__paths = array View::$__paths = array
View::$_log = NULL
View::$webroot = NULL'; View::$webroot = NULL';
$result = str_replace(array("\t", "\r\n", "\n"), "", $result); $result = str_replace(array("\t", "\r\n", "\n"), "", $result);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $expected); $expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);

View file

@ -113,6 +113,9 @@ class MagicDbTest extends UnitTestCase {
$r = $this->Db->toArray(array('yeah')); $r = $this->Db->toArray(array('yeah'));
$this->assertTrue($r === array('yeah')); $this->assertTrue($r === array('yeah'));
$r = $this->Db->toArray("# FILE_ID DB\r\n# Date:2009-10-10\r\n# Source:xxx.php");
$this->assertTrue($r === array());
$r = $this->Db->toArray('foo'); $r = $this->Db->toArray('foo');
$this->assertTrue($r === array()); $this->assertTrue($r === array());

View file

@ -305,7 +305,7 @@ class AclBehaviorTestCase extends CakeTestCase {
$this->assertEqual($result['Aro']['parent_id'], 5); $this->assertEqual($result['Aro']['parent_id'], 5);
$node = $Person->node(array('model' => 'AclPerson', 'foreign_key' => 8)); $node = $Person->node(array('model' => 'AclPerson', 'foreign_key' => 8));
$this->assertEqual(sizeof($node), 2); $this->assertEqual(count($node), 2);
$this->assertEqual($node[0]['Aro']['parent_id'], 5); $this->assertEqual($node[0]['Aro']['parent_id'], 5);
$this->assertEqual($node[1]['Aro']['parent_id'], null); $this->assertEqual($node[1]['Aro']['parent_id'], null);
@ -358,7 +358,7 @@ class AclBehaviorTestCase extends CakeTestCase {
$Person->save($data); $Person->save($data);
$id = $Person->id; $id = $Person->id;
$node = $Person->node(); $node = $Person->node();
$this->assertEqual(sizeof($node), 2); $this->assertEqual(count($node), 2);
$this->assertEqual($node[0]['Aro']['parent_id'], 5); $this->assertEqual($node[0]['Aro']['parent_id'], 5);
$this->assertEqual($node[1]['Aro']['parent_id'], null); $this->assertEqual($node[1]['Aro']['parent_id'], null);
@ -406,7 +406,7 @@ class AclBehaviorTestCase extends CakeTestCase {
$Person->id = 2; $Person->id = 2;
$result = $Person->node(); $result = $Person->node();
$this->assertTrue(is_array($result)); $this->assertTrue(is_array($result));
$this->assertEqual(sizeof($result), 1); $this->assertEqual(count($result), 1);
} }
} }
?> ?>

View file

@ -4887,21 +4887,6 @@ class ModelReadTest extends BaseModelTest {
$this->assertFalse($TestModel->find('all', array('connection' => 'foo'))); $this->assertFalse($TestModel->find('all', array('connection' => 'foo')));
} }
/**
* 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 * testMultipleBelongsToWithSameClass method
* *

View file

@ -2015,6 +2015,54 @@ class ModelWriteTest extends BaseModelTest {
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }
/**
* test that saving habtm records respects conditions set in the the 'conditions' key
* for the association.
*
* @return void
*/
function testHabtmSaveWithConditionsInAssociation() {
$this->loadFixtures('JoinThing', 'Something', 'SomethingElse');
$Something =& new Something();
$Something->unbindModel(array('hasAndBelongsToMany' => array('SomethingElse')), false);
$Something->bindModel(array(
'hasAndBelongsToMany' => array(
'DoomedSomethingElse' => array(
'className' => 'SomethingElse',
'joinTable' => 'join_things',
'conditions' => 'JoinThing.doomed = 1',
'unique' => true
),
'NotDoomedSomethingElse' => array(
'className' => 'SomethingElse',
'joinTable' => 'join_things',
'conditions' => array('JoinThing.doomed' => 0),
'unique' => true
)
)
), false);
$result = $Something->read(null, 1);
$this->assertTrue(empty($result['NotDoomedSomethingElse']));
$this->assertEqual(count($result['DoomedSomethingElse']), 1);
$data = array(
'Something' => array('id' => 1),
'NotDoomedSomethingElse' => array(
'NotDoomedSomethingElse' => array(
array('something_else_id' => 2, 'doomed' => 0),
array('something_else_id' => 3, 'doomed' => 0)
)
)
);
$Something->create($data);
$result = $Something->save();
$this->assertTrue($result);
$result = $Something->read(null, 1);
$this->assertEqual(count($result['NotDoomedSomethingElse']), 2);
$this->assertEqual(count($result['DoomedSomethingElse']), 1);
}
/** /**
* testHabtmSaveKeyResolution method * testHabtmSaveKeyResolution method
* *

View file

@ -3090,8 +3090,6 @@ class Uuiditem extends CakeTestModel {
* @var array * @var array
* @access public * @access public
*/ */
//var $hasAndBelongsToMany = array('Uuidportfolio' => array('unique' => true));
// var $hasAndBelongsToMany = array('Uuidportfolio' => array('with' => 'UuiditemsUuidportfolio'));
var $hasAndBelongsToMany = array('Uuidportfolio' => array('with' => 'UuiditemsUuidportfolioNumericid')); var $hasAndBelongsToMany = array('Uuidportfolio' => array('with' => 'UuiditemsUuidportfolioNumericid'));
} }

View file

@ -1806,7 +1806,7 @@ class SetTest extends CakeTestCase {
$model = new Model(array('id' => false, 'name' => 'Model', 'table' => false)); $model = new Model(array('id' => false, 'name' => 'Model', 'table' => false));
$expected = array( $expected = array(
'Behaviors' => array('modelName' => 'Model', '_attached' => array(), '_disabled' => array(), '__methods' => array(), '__mappedMethods' => array(), '_log' => null), 'Behaviors' => array('modelName' => 'Model', '_attached' => array(), '_disabled' => array(), '__methods' => array(), '__mappedMethods' => array()),
'useDbConfig' => 'default', 'useTable' => false, 'displayField' => null, 'id' => false, 'data' => array(), 'table' => 'models', 'primaryKey' => 'id', '_schema' => null, 'validate' => array(), 'useDbConfig' => 'default', 'useTable' => false, 'displayField' => null, 'id' => false, 'data' => array(), 'table' => 'models', 'primaryKey' => 'id', '_schema' => null, 'validate' => array(),
'validationErrors' => array(), 'tablePrefix' => null, 'name' => 'Model', 'alias' => 'Model', 'tableToModel' => array(), 'logTransactions' => false, 'transactional' => false, 'cacheQueries' => false, 'validationErrors' => array(), 'tablePrefix' => null, 'name' => 'Model', 'alias' => 'Model', 'tableToModel' => array(), 'logTransactions' => false, 'transactional' => false, 'cacheQueries' => false,
'belongsTo' => array(), 'hasOne' => array(), 'hasMany' => array(), 'hasAndBelongsToMany' => array(), 'actsAs' => null, 'whitelist' => array(), 'cacheSources' => true, 'belongsTo' => array(), 'hasOne' => array(), 'hasMany' => array(), 'hasAndBelongsToMany' => array(), 'actsAs' => null, 'whitelist' => array(), 'cacheSources' => true,
@ -1817,7 +1817,7 @@ class SetTest extends CakeTestCase {
'hasMany' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'dependent', 'exclusive', 'finderQuery', 'counterQuery'), 'hasMany' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'dependent', 'exclusive', 'finderQuery', 'counterQuery'),
'hasAndBelongsToMany' => array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery', 'deleteQuery', 'insertQuery')), 'hasAndBelongsToMany' => array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery', 'deleteQuery', 'insertQuery')),
'__associations' => array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'), '__backAssociation' => array(), '__insertID' => null, '__numRows' => null, '__affectedRows' => null, '__associations' => array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'), '__backAssociation' => array(), '__insertID' => null, '__numRows' => null, '__affectedRows' => null,
'_findMethods' => array('all' => true, 'first' => true, 'count' => true, 'neighbors' => true, 'list' => true, 'threaded' => true), '_log' => null); '_findMethods' => array('all' => true, 'first' => true, 'count' => true, 'neighbors' => true, 'list' => true, 'threaded' => true));
$result = Set::reverse($model); $result = Set::reverse($model);
ksort($result); ksort($result);

View file

@ -333,27 +333,27 @@ class HtmlHelperTest extends CakeTestCase {
* @link https://trac.cakephp.org/ticket/6490 * @link https://trac.cakephp.org/ticket/6490
*/ */
function testImageTagWithTheme() { function testImageTagWithTheme() {
$file = WWW_ROOT . 'themed' . DS . 'default' . DS . 'img' . DS . 'cake.power.gif'; App::build(array(
$message = "File '{$file}' not present. %s"; 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
$this->skipUnless(file_exists($file), $message); ));
Configure::write('Asset.timestamp', true); Configure::write('Asset.timestamp', true);
Configure::write('debug', 1); Configure::write('debug', 1);
$this->Html->themeWeb = 'themed/default/';
$this->Html->theme = 'test_theme';
$result = $this->Html->image('cake.power.gif'); $result = $this->Html->image('cake.power.gif');
$this->assertTags($result, array( $this->assertTags($result, array(
'img' => array( 'img' => array(
'src' => 'preg:/themed\/default\/img\/cake\.power\.gif\?\d+/', 'src' => 'preg:/theme\/test_theme\/img\/cake\.power\.gif\?\d+/',
'alt' => '' 'alt' => ''
))); )));
$webroot = $this->Html->webroot; $webroot = $this->Html->webroot;
$this->Html->webroot = '/testing/'; $this->Html->webroot = '/testing/';
$result = $this->Html->image('cake.power.gif'); $result = $this->Html->image('cake.power.gif');
$this->assertTags($result, array( $this->assertTags($result, array(
'img' => array( 'img' => array(
'src' => 'preg:/\/testing\/themed\/default\/img\/cake\.power\.gif\?\d+/', 'src' => 'preg:/\/testing\/theme\/test_theme\/img\/cake\.power\.gif\?\d+/',
'alt' => '' 'alt' => ''
))); )));
$this->Html->webroot = $webroot; $this->Html->webroot = $webroot;

View file

@ -179,6 +179,8 @@ class ThemeViewTest extends CakeTestCase {
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
)); ));
$Configure = App::getInstance();
array_shift($Configure->views);
} }
/** /**

View file

@ -656,10 +656,10 @@ class CakeTestCase extends UnitTestCase {
$permutations = $this->__array_permute($attrs); $permutations = $this->__array_permute($attrs);
$permutationTokens = array(); $permutationTokens = array();
foreach ($permutations as $permutation) { foreach ($permutations as $permutation) {
$permutationTokens[] = join('', $permutation); $permutationTokens[] = implode('', $permutation);
} }
$regex[] = array( $regex[] = array(
sprintf('%s', join(', ', $explanations)), sprintf('%s', implode(', ', $explanations)),
$permutationTokens, $permutationTokens,
$i, $i,
); );

View file

@ -602,7 +602,7 @@ class HtmlTestManager extends TestManager {
foreach ($testCases as $testCaseFile => $testCase) { foreach ($testCases as $testCaseFile => $testCase) {
$title = explode(strpos($testCase, '\\') ? '\\' : '/', str_replace('.test.php', '', $testCase)); $title = explode(strpos($testCase, '\\') ? '\\' : '/', str_replace('.test.php', '', $testCase));
$title[count($title) - 1] = Inflector::camelize($title[count($title) - 1]); $title[count($title) - 1] = Inflector::camelize($title[count($title) - 1]);
$title = join(' / ', $title); $title = implode(' / ', $title);
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?case=" . urlencode($testCase) . $urlExtra ."'>" . $title . "</a></li>\n"; $buffer .= "<li><a href='" . $manager->getBaseURL() . "?case=" . urlencode($testCase) . $urlExtra ."'>" . $title . "</a></li>\n";
} }

View file

@ -1,4 +1,4 @@
;<?php die() ?> ;<?php exit() ?>
; SVN FILE: $Id$ ; SVN FILE: $Id$
;/** ;/**
; * Test App Ini Based Acl Config File ; * Test App Ini Based Acl Config File

View file

@ -0,0 +1 @@
this is just a test to load swf file from the plugin.

View file

Before

Width:  |  Height:  |  Size: 233 B

After

Width:  |  Height:  |  Size: 233 B

View file

@ -0,0 +1 @@
this is the test asset css file

View file

@ -0,0 +1 @@
this is just a test to load swf file from the theme.

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB