Merge branch '2.0' of github.com:cakephp/cakephp into 2.0

This commit is contained in:
Jose Lorenzo Rodriguez 2011-11-28 00:54:16 -04:30
commit 8f1125ed4d
29 changed files with 125 additions and 26 deletions

View file

@ -15,6 +15,8 @@
* @since CakePHP(tm) v 1.2.0.5012
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('ComponentCollection', 'Controller');
App::uses('AclComponent', 'Controller/Component');
App::uses('DbAcl', 'Model');
@ -25,7 +27,7 @@ App::uses('DbAcl', 'Model');
*
* @package Cake.Console.Command
*/
class AclShell extends Shell {
class AclShell extends AppShell {
/**
* Contains instance of AclComponent

View file

@ -17,6 +17,8 @@
* @since CakePHP(tm) v 1.2.0.5012
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('File', 'Utility');
/**
@ -24,7 +26,7 @@ App::uses('File', 'Utility');
*
* @package Cake.Console.Command
*/
class ApiShell extends Shell {
class ApiShell extends AppShell {
/**
* Map between short name for paths and real paths.

View file

@ -16,6 +16,8 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Shell', 'Console');
/**
* This is a placeholder class.
* Create the same file in app/Console/Command/AppShell.php

View file

@ -20,6 +20,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('Model', 'Model');
/**
@ -28,7 +29,7 @@ App::uses('Model', 'Model');
* @package Cake.Console.Command
* @link http://book.cakephp.org/2.0/en/console-and-shells/code-generation-with-bake.html
*/
class BakeShell extends Shell {
class BakeShell extends AppShell {
/**
* Contains tasks to load and instantiate

View file

@ -17,6 +17,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('Inflector', 'Utility');
/**
@ -24,7 +25,7 @@ App::uses('Inflector', 'Utility');
*
* @package Cake.Console.Command
*/
class CommandListShell extends Shell {
class CommandListShell extends AppShell {
/**
* startup
@ -80,13 +81,15 @@ class CommandListShell extends Shell {
*/
protected function _getShellList() {
$shellList = array();
$skipFiles = array('AppShell');
$corePath = App::core('Console/Command');
$shells = App::objects('file', $corePath[0]);
$shells = array_diff($shells, $skipFiles);
$shellList = $this->_appendShells('CORE', $shells, $shellList);
$appShells = App::objects('Console/Command', null, false);
$appShells = array_diff($appShells, $shells);
$appShells = array_diff($appShells, $shells, $skipFiles);
$shellList = $this->_appendShells('app', $appShells, $shellList);
$plugins = CakePlugin::loaded();

View file

@ -16,12 +16,14 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
/**
* Provides a very basic 'interactive' console for CakePHP apps.
*
* @package Cake.Console.Command
*/
class ConsoleShell extends Shell {
class ConsoleShell extends AppShell {
/**
* Available binding types

View file

@ -16,12 +16,14 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
/**
* Shell for I18N management.
*
* @package Cake.Console.Command
*/
class I18nShell extends Shell {
class I18nShell extends AppShell {
/**
* Contains database source to use

View file

@ -18,6 +18,8 @@
* @since CakePHP(tm) v 1.2.0.5550
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('File', 'Utility');
App::uses('Folder', 'Utility');
App::uses('CakeSchema', 'Model');
@ -28,7 +30,7 @@ App::uses('CakeSchema', 'Model');
* @package Cake.Console.Command
* @link http://book.cakephp.org/2.0/en/console-and-shells/schema-management-and-migrations.html
*/
class SchemaShell extends Shell {
class SchemaShell extends AppShell {
/**
* Schema class being used.
@ -166,7 +168,7 @@ class SchemaShell extends Shell {
if (isset($this->params['snapshot'])) {
$numToUse = $this->params['snapshot'];
}
$count = 0;
if (!empty($result[1])) {
foreach ($result[1] as $file) {
@ -181,7 +183,7 @@ class SchemaShell extends Shell {
$count = $numToUse;
}
}
$content['file'] = $fileName . '_' . $count . '.php';
}

View file

@ -16,13 +16,14 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Shell', 'Console');
App::uses('AppShell', 'Console/Command');
/**
* Base class for Bake Tasks.
*
* @package Cake.Console.Command.Task
*/
class BakeTask extends Shell {
class BakeTask extends AppShell {
/**
* Name of plugin

View file

@ -16,6 +16,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('BakeTask', 'Console/Command/Task');
App::uses('AppModel', 'Model');

View file

@ -16,12 +16,14 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
/**
* Task class for creating and updating the database configuration file.
*
* @package Cake.Console.Command.Task
*/
class DbConfigTask extends Shell {
class DbConfigTask extends AppShell {
/**
* path to CONFIG directory

View file

@ -15,6 +15,8 @@
* @since CakePHP(tm) v 1.2.0.5012
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('File', 'Utility');
App::uses('Folder', 'Utility');
@ -23,7 +25,7 @@ App::uses('Folder', 'Utility');
*
* @package Cake.Console.Command.Task
*/
class ExtractTask extends Shell {
class ExtractTask extends AppShell {
/**
* Paths to use when looking for strings

View file

@ -16,6 +16,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('BakeTask', 'Console/Command/Task');
App::uses('Model', 'Model');

View file

@ -16,6 +16,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('BakeTask', 'Console/Command/Task');
App::uses('ConnectionManager', 'Model');
App::uses('Model', 'Model');

View file

@ -16,6 +16,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('File', 'Utility');
App::uses('Folder', 'Utility');
@ -24,7 +25,7 @@ App::uses('Folder', 'Utility');
*
* @package Cake.Console.Command.Task
*/
class PluginTask extends Shell {
class PluginTask extends AppShell {
/**
* path to plugins directory

View file

@ -17,6 +17,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('File', 'Utility');
App::uses('Folder', 'Utility');
App::uses('String', 'Utility');
@ -27,7 +28,7 @@ App::uses('Security', 'Utility');
*
* @package Cake.Console.Command.Task
*/
class ProjectTask extends Shell {
class ProjectTask extends AppShell {
/**
* configs path (used in testing).

View file

@ -16,14 +16,16 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('Folder', 'Utility');
/**
* Template Task can generate templated output Used in other Tasks.
* Acts like a simplified View class.
*
* @package Cake.Console.Command.Task
*/
class TemplateTask extends Shell {
class TemplateTask extends AppShell {
/**
* variables to add to template scope

View file

@ -16,6 +16,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('BakeTask', 'Console/Command/Task');
App::uses('ClassRegistry', 'Utility');
@ -472,7 +473,7 @@ class TestTask extends BakeTask {
->addArgument('type', array(
'help' => __d('cake_console', 'Type of class to bake, can be any of the following: controller, model, helper, component or behavior.'),
'choices' => array(
'Controller', 'controller',
'Controller', 'controller',
'Model', 'model',
'Helper', 'helper',
'Component', 'component',

View file

@ -16,6 +16,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('Controller', 'Controller');
App::uses('BakeTask', 'Console/Command/Task');

View file

@ -18,7 +18,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Shell', 'Console');
App::uses('AppShell', 'Console/Command');
App::uses('CakeTestSuiteDispatcher', 'TestSuite');
App::uses('CakeTestSuiteCommand', 'TestSuite');
App::uses('CakeTestLoader', 'TestSuite');
@ -29,7 +29,7 @@ App::uses('CakeTestLoader', 'TestSuite');
*
* @package Cake.Console.Command
*/
class TestsuiteShell extends Shell {
class TestsuiteShell extends AppShell {
/**
* Dispatcher object for the run.

View file

@ -17,6 +17,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('AppShell', 'Console/Command');
App::uses('Folder', 'Utility');
/**
@ -24,7 +25,7 @@ App::uses('Folder', 'Utility');
*
* @package Cake.Console.Command
*/
class UpgradeShell extends Shell {
class UpgradeShell extends AppShell {
/**
* Files

View file

@ -210,7 +210,7 @@ class ShellDispatcher {
$class = Inflector::camelize($shell) . 'Shell';
App::uses('Shell', 'Console');
App::uses('AppShell', 'Console');
App::uses('AppShell', 'Console/Command');
App::uses($class, $plugin . 'Console/Command');
if (!class_exists($class)) {

View file

@ -99,7 +99,7 @@ class App {
'view' => array('suffix' => 'View', 'extends' => null, 'core' => true),
'helper' => array('suffix' => 'Helper', 'extends' => 'AppHelper', 'core' => true),
'vendor' => array('extends' => null, 'core' => true),
'shell' => array('suffix' => 'Shell', 'extends' => 'Shell', 'core' => true),
'shell' => array('suffix' => 'Shell', 'extends' => 'AppShell', 'core' => true),
'plugin' => array('extends' => null, 'core' => true)
);
@ -794,7 +794,7 @@ class App {
/**
* Sets then returns the templates for each customizable package path
*
*
* @return array templates for each customizable package path
*/
protected static function _packageFormat() {

View file

@ -184,7 +184,7 @@ class CakeRequest implements ArrayAccess {
$query = $_GET;
}
unset($query['/' . $this->url]);
unset($query['/' . str_replace('.', '_', $this->url)]);
if (strpos($this->url, '?') !== false) {
list(, $querystr) = explode('?', $this->url);
parse_str($querystr, $queryArgs);

View file

@ -1056,6 +1056,21 @@ class CakeRequestTest extends CakeTestCase {
$this->assertEquals('/', $request->webroot);
}
/**
* Test that a request with a . in the main GET parameter is filtered out.
* PHP changes GET parameter keys containing dots to _.
*
* @return void
*/
public function testGetParamsWithDot() {
$_GET['/posts/index/add_add'] = '';
$_SERVER['SCRIPT_NAME'] = '/cake_dev/app/webroot/index.php';
$_SERVER['REQUEST_URI'] = '/cake_dev/posts/index/add.add';
$request = new CakeRequest();
$this->assertEquals(array(), $request->query);
}
/**
* generator for environment configurations
*

View file

@ -865,6 +865,40 @@ class XmlTest extends CakeTestCase {
$expected .= '<published>Y</published><created>2007-03-18 10:43:23</created><updated>2007-03-18 10:45:31</updated></Article>';
$expected .= '</data>';
$this->assertEquals(str_replace(array("\r", "\n"), '', $obj->asXML()), $expected);
//multiple model results - without a records key it would fatal error
$data = $user->find('all', array('limit'=>2));
$data = array('records'=>$data);
$obj = Xml::build(compact('data'));
$expected = '<' . '?xml version="1.0" encoding="UTF-8"?><data>';
$expected .= '<records>';
$expected .= '<User><id>1</id><user>mariano</user><password>5f4dcc3b5aa765d61d8327deb882cf99</password>';
$expected .= '<created>2007-03-17 01:16:23</created><updated>2007-03-17 01:18:31</updated></User>';
$expected .= '<Article><id>1</id><user_id>1</user_id><title>First Article</title><body>First Article Body</body>';
$expected .= '<published>Y</published><created>2007-03-18 10:39:23</created><updated>2007-03-18 10:41:31</updated></Article>';
$expected .= '<Article><id>3</id><user_id>1</user_id><title>Third Article</title><body>Third Article Body</body>';
$expected .= '<published>Y</published><created>2007-03-18 10:43:23</created><updated>2007-03-18 10:45:31</updated></Article>';
$expected .= '</records><records><User><id>2</id><user>nate</user><password>5f4dcc3b5aa765d61d8327deb882cf99</password>';
$expected .= '<created>2007-03-17 01:18:23</created><updated>2007-03-17 01:20:31</updated></User><Article/>';
$expected .= '</records>';
$expected .= '</data>';
$result = $obj->asXML();
$this->assertEquals(str_replace(array("\r", "\n"), '', $obj->asXML()), $expected);
}
/**
* Test ampersand in text elements.
*
* @return void
*/
public function testAmpInText() {
$data = array(
'outer' => array(
'inner' => array('name' => 'mark & mark')
)
);
$obj = Xml::build($data);
$result = $obj->asXml();
$this->assertContains('mark &amp; mark', $result);
}
}

View file

@ -200,7 +200,16 @@ class Xml {
continue;
}
if ($key[0] !== '@' && $format === 'tags') {
$child = $dom->createElement($key, $value);
$child = null;
if (!is_numeric($value)) {
// Escape special characters
// http://www.w3.org/TR/REC-xml/#syntax
// https://bugs.php.net/bug.php?id=36795
$child = $dom->createElement($key, '');
$child->appendChild(new DOMText($value));
} else {
$child = $dom->createElement($key, $value);
}
$node->appendChild($child);
} else {
if ($key[0] === '@') {

View file

@ -126,6 +126,7 @@ if (!function_exists('sortByKey')) {
* @param string $order Sort order asc/desc (ascending or descending).
* @param integer $type Type of sorting to perform
* @return mixed Sorted array
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#sortByKey
*/
function sortByKey(&$array, $sortby, $order = 'asc', $type = SORT_NUMERIC) {
if (!is_array($array)) {
@ -198,6 +199,7 @@ function h($text, $double = true, $charset = null) {
* @param boolean $dotAppend Set to true if you want the plugin to have a '.' appended to it.
* @param string $plugin Optional default plugin to use if no plugin is found. Defaults to null.
* @return array Array with 2 indexes. 0 => plugin name, 1 => classname
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#pluginSplit
*/
function pluginSplit($name, $dotAppend = false, $plugin = null) {
if (strpos($name, '.') !== false) {
@ -521,6 +523,7 @@ function __($singular, $args = null) {
* @param integer $count Count
* @param mixed $args Array with arguments or multiple arguments in function
* @return mixed plural form of translated string
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__n
*/
function __n($singular, $plural, $count, $args = null) {
if (!$singular) {
@ -544,6 +547,7 @@ function __n($singular, $plural, $count, $args = null) {
* @param string $msg String to translate
* @param mixed $args Array with arguments or multiple arguments in function
* @return translated string
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__d
*/
function __d($domain, $msg, $args = null) {
if (!$msg) {
@ -570,6 +574,7 @@ function __d($domain, $msg, $args = null) {
* @param integer $count Count
* @param mixed $args Array with arguments or multiple arguments in function
* @return plural form of translated string
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dn
*/
function __dn($domain, $singular, $plural, $count, $args = null) {
if (!$singular) {
@ -607,6 +612,7 @@ function __dn($domain, $singular, $plural, $count, $args = null) {
* @param integer $category Category
* @param mixed $args Array with arguments or multiple arguments in function
* @return translated string
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dc
*/
function __dc($domain, $msg, $category, $args = null) {
if (!$msg) {
@ -648,6 +654,7 @@ function __dc($domain, $msg, $category, $args = null) {
* @param integer $category Category
* @param mixed $args Array with arguments or multiple arguments in function
* @return plural form of translated string
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__dcn
*/
function __dcn($domain, $singular, $plural, $count, $category, $args = null) {
if (!$singular) {
@ -681,6 +688,7 @@ function __dcn($domain, $singular, $plural, $count, $category, $args = null) {
* @param integer $category Category
* @param mixed $args Array with arguments or multiple arguments in function
* @return translated string
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#__c
*/
function __c($msg, $category, $args = null) {
if (!$msg) {
@ -700,6 +708,8 @@ function __c($msg, $category, $args = null) {
* Shortcut to Log::write.
*
* @param string $message Message to write to log
* @return void
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#LogError
*/
function LogError($message) {
App::uses('CakeLog', 'Log');