Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch '1.2' into 1.2-merger

Conflicts:
	cake/libs/model/datasources/dbo/dbo_mysql.php
	cake/libs/model/datasources/dbo/dbo_mysqli.php
	cake/libs/view/helpers/text.php
	cake/libs/view/theme.php
  • Loading branch information...
commit 7259a1b920e3914b05a8f800747be30dc2b58d76 2 parents 4cefb5f + cc750d1
@markstory markstory authored
View
2  app/webroot/css/cake.generic.css
@@ -189,7 +189,7 @@ dl {
margin: 0em 0em;
width: 60%;
}
-dl.altrow {
+dl .altrow {
background: #f4f4f4;
}
dt {
View
2  cake/console/templates/skel/webroot/css/cake.generic.css
@@ -190,7 +190,7 @@ dl {
margin: 0em 0em;
width: 60%;
}
-dl.altrow {
+dl .altrow {
background: #f4f4f4;
}
dt {
View
2  cake/libs/class_registry.php
@@ -241,7 +241,7 @@ function keys() {
* Return object which corresponds to given key.
*
* @param string $key Key of object to look for
- * @return mixed Object stored in registry
+ * @return mixed Object stored in registry or boolean false if the object does not exist.
* @access public
* @static
*/
View
3  cake/libs/controller/controller.php
@@ -947,11 +947,12 @@ function postConditions($data = array(), $op = null, $bool = 'AND', $exclusive =
$op = '';
}
+ $arrayOp = is_array($op);
foreach ($data as $model => $fields) {
foreach ($fields as $field => $value) {
$key = $model.'.'.$field;
$fieldOp = $op;
- if (is_array($op)) {
+ if ($arrayOp) {
if (array_key_exists($key, $op)) {
$fieldOp = $op[$key];
} elseif (array_key_exists($field, $op)) {
View
9 cake/libs/model/behaviors/tree.php
@@ -140,15 +140,6 @@ function beforeDelete(&$Model) {
function beforeSave(&$Model) {
extract($this->settings[$Model->alias]);
- if (isset($Model->data[$Model->alias][$Model->primaryKey])) {
- if ($Model->data[$Model->alias][$Model->primaryKey]) {
- if (!$Model->id) {
- $Model->id = $Model->data[$Model->alias][$Model->primaryKey];
- }
- }
- unset($Model->data[$Model->alias][$Model->primaryKey]);
- }
-
$this->_addToWhitelist($Model, array($left, $right));
if (!$Model->id) {
if (array_key_exists($parent, $Model->data[$Model->alias]) && $Model->data[$Model->alias][$parent]) {
View
95 cake/libs/model/datasources/dbo/dbo_mysql.php
@@ -464,6 +464,53 @@ function getCharsetName($name) {
}
return false;
}
+/**
+ * Converts database-layer column types to basic types
+ *
+ * @param string $real Real database-layer column type (i.e. "varchar(255)")
+ * @return string Abstract column type (i.e. "string")
+ */
+ function column($real) {
+ if (is_array($real)) {
+ $col = $real['name'];
+ if (isset($real['limit'])) {
+ $col .= '('.$real['limit'].')';
+ }
+ return $col;
+ }
+
+ $col = str_replace(')', '', $real);
+ $limit = $this->length($real);
+ if (strpos($col, '(') !== false) {
+ list($col, $vals) = explode('(', $col);
+ }
+
+ if (in_array($col, array('date', 'time', 'datetime', 'timestamp'))) {
+ return $col;
+ }
+ if (($col == 'tinyint' && $limit == 1) || $col == 'boolean') {
+ return 'boolean';
+ }
+ if (strpos($col, 'int') !== false) {
+ return 'integer';
+ }
+ if (strpos($col, 'char') !== false || $col == 'tinytext') {
+ return 'string';
+ }
+ if (strpos($col, 'text') !== false) {
+ return 'text';
+ }
+ if (strpos($col, 'blob') !== false || $col == 'binary') {
+ return 'binary';
+ }
+ if (strpos($col, 'float') !== false || strpos($col, 'double') !== false || strpos($col, 'decimal') !== false) {
+ return 'float';
+ }
+ if (strpos($col, 'enum') !== false) {
+ return "enum($vals)";
+ }
+ return 'text';
+ }
}
/**
@@ -683,54 +730,6 @@ function lastInsertId($source = null) {
}
/**
- * Converts database-layer column types to basic types
- *
- * @param string $real Real database-layer column type (i.e. "varchar(255)")
- * @return string Abstract column type (i.e. "string")
- */
- function column($real) {
- if (is_array($real)) {
- $col = $real['name'];
- if (isset($real['limit'])) {
- $col .= '('.$real['limit'].')';
- }
- return $col;
- }
-
- $col = str_replace(')', '', $real);
- $limit = $this->length($real);
- if (strpos($col, '(') !== false) {
- list($col, $vals) = explode('(', $col);
- }
-
- if (in_array($col, array('date', 'time', 'datetime', 'timestamp'))) {
- return $col;
- }
- if (($col == 'tinyint' && $limit == 1) || $col == 'boolean') {
- return 'boolean';
- }
- if (strpos($col, 'int') !== false) {
- return 'integer';
- }
- if (strpos($col, 'char') !== false || $col == 'tinytext') {
- return 'string';
- }
- if (strpos($col, 'text') !== false) {
- return 'text';
- }
- if (strpos($col, 'blob') !== false || $col == 'binary') {
- return 'binary';
- }
- if (strpos($col, 'float') !== false || strpos($col, 'double') !== false || strpos($col, 'decimal') !== false) {
- return 'float';
- }
- if (strpos($col, 'enum') !== false) {
- return "enum($vals)";
- }
- return 'text';
- }
-
-/**
* Enter description here...
*
* @param unknown_type $results
View
48 cake/libs/model/datasources/dbo/dbo_mysqli.php
@@ -261,54 +261,6 @@ function lastInsertId($source = null) {
}
/**
- * Converts database-layer column types to basic types
- *
- * @param string $real Real database-layer column type (i.e. "varchar(255)")
- * @return string Abstract column type (i.e. "string")
- */
- function column($real) {
- if (is_array($real)) {
- $col = $real['name'];
- if (isset($real['limit'])) {
- $col .= '('.$real['limit'].')';
- }
- return $col;
- }
-
- $col = str_replace(')', '', $real);
- $limit = $this->length($real);
- if (strpos($col, '(') !== false) {
- list($col, $vals) = explode('(', $col);
- }
-
- if (in_array($col, array('date', 'time', 'datetime', 'timestamp'))) {
- return $col;
- }
- if (($col == 'tinyint' && $limit == 1) || $col == 'boolean') {
- return 'boolean';
- }
- if (strpos($col, 'int') !== false) {
- return 'integer';
- }
- if (strpos($col, 'char') !== false || $col == 'tinytext') {
- return 'string';
- }
- if (strpos($col, 'text') !== false) {
- return 'text';
- }
- if (strpos($col, 'blob') !== false || $col == 'binary') {
- return 'binary';
- }
- if (strpos($col, 'float') !== false || strpos($col, 'double') !== false || strpos($col, 'decimal') !== false) {
- return 'float';
- }
- if (strpos($col, 'enum') !== false) {
- return "enum($vals)";
- }
- return 'text';
- }
-
-/**
* Enter description here...
*
* @param unknown_type $results
View
3  cake/libs/model/model.php
@@ -2419,6 +2419,8 @@ function query() {
/**
* Returns true if all fields pass validation.
*
+ * Will validate the currently set data. Use Model::set() or Model::create() to set the active data.
+ *
* @param string $options An optional array of custom options to be made available in the beforeValidate callback
* @return boolean True if there are no errors
* @access public
@@ -2437,6 +2439,7 @@ function validates($options = array()) {
*
* @param string $options An optional array of custom options to be made available in the beforeValidate callback
* @return array Array of invalid fields
+ * @see Model::validates()
* @access public
* @link http://book.cakephp.org/view/410/Validating-Data-from-the-Controller
*/
View
3  cake/libs/router.php
@@ -282,8 +282,9 @@ function connectNamed($named, $options = array()) {
if ($named === true || $named === false) {
$options = array_merge(array('default' => $named, 'reset' => true, 'greedy' => $named), $options);
$named = array();
+ } else {
+ $options = array_merge(array('default' => false, 'reset' => false, 'greedy' => true), $options);
}
- $options = array_merge(array('default' => false, 'reset' => false, 'greedy' => true), $options);
if ($options['reset'] == true || $_this->named['rules'] === false) {
$_this->named['rules'] = array();
View
2  cake/libs/view/helpers/javascript.php
@@ -593,7 +593,7 @@ function includeScript($script = "", $options = array()) {
* - postfix - Appends the string to the returned data. Default is ''
* - stringKeys - A list of array keys to be treated as a string.
* - quoteKeys - If false treats $stringKeys as a list of keys **not** to be quoted. Default is true.
- * - q - The type of quote to use. Default is "'"
+ * - q - The type of quote to use. Default is '"'. This option only affects the keys, not the values.
*
* @param array $data Data to be converted
* @param array $options Set of options: block, prefix, postfix, stringKeys, quoteKeys, q
View
14 cake/libs/view/helpers/text.php
@@ -332,15 +332,17 @@ function excerpt($text, $phrase, $radius = 100, $ending = '...') {
* @access public
*/
function toList($list, $and = 'and') {
- $r = '';
- $c = count($list) - 1;
+ $return = '';
+ $count = count($list) - 1;
+ $counter = 0;
foreach ($list as $i => $item) {
- $r .= $item;
- if ($c > 0 && $i < $c) {
- $r .= ($i < $c - 1 ? ', ' : " {$and} ");
+ $return .= $item;
+ if ($count > 0 && $counter < $count) {
+ $return .= ($counter < $count - 1 ? ', ' : " {$and} ");
}
+ $counter++;
}
- return $r;
+ return $return;
}
}
?>
View
10 cake/libs/xml.php
@@ -114,7 +114,6 @@ function __construct($name = null, $value = null, $namespace = null) {
$this->createTextNode($value);
}
}
-
/**
* Adds a namespace to the current node
*
@@ -250,7 +249,7 @@ function normalize($object, $keyName = null, $options = array()) {
}
$n = $name;
- if (!empty($chldObjs['_name_'])) {
+ if (isset($chldObjs['_name_'])) {
$n = null;
unset($chldObjs['_name_']);
}
@@ -760,13 +759,13 @@ function __toString() {
* if given the $recursive parameter.
*
* @param boolean $recursive Recursively delete elements.
- * @access private
+ * @access protected
*/
- function __killParent($recursive = true) {
+ function _killParent($recursive = true) {
unset($this->__parent, $this->_log);
if ($recursive && $this->hasChildren()) {
for ($i = 0; $i < count($this->children); $i++) {
- $this->children[$i]->__killParent(true);
+ $this->children[$i]->_killParent(true);
}
}
}
@@ -1135,6 +1134,7 @@ function __destruct() {
if (is_resource($this->__parser)) {
xml_parser_free($this->__parser);
}
+ $this->_killParent(true);
}
/**
View
13 cake/tests/cases/libs/model/model_write.test.php
@@ -3106,6 +3106,19 @@ function testSaveAllHasOne() {
'attachment' => 'some_file.zip'
)));
$this->assertEqual($result, $expected);
+
+
+ $model->Attachment->bindModel(array('belongsTo' => array('Comment')), false);
+ $data = array(
+ 'Comment' => array(
+ 'comment' => 'Comment with attachment',
+ 'article_id' => 1,
+ 'user_id' => 1
+ ),
+ 'Attachment' => array(
+ 'attachment' => 'some_file.zip'
+ ));
+ $this->assertTrue($model->saveAll($data, array('validate' => 'first')));
}
/**
View
3  cake/tests/cases/libs/view/helpers/text.test.php
@@ -362,6 +362,9 @@ function testListGeneration() {
$result = $this->Text->toList(array('Dusty', 'Lucky', 'Ned'), 'y');
$this->assertEqual($result, 'Dusty, Lucky y Ned');
+
+ $result = $this->Text->toList(array( 1 => 'Dusty', 2 => 'Lucky', 3 => 'Ned'), 'y');
+ $this->assertEqual($result, 'Dusty, Lucky y Ned');
}
}
?>
View
19 cake/tests/cases/libs/view/theme.test.php
@@ -149,11 +149,11 @@ class ThemeViewTest extends CakeTestCase {
*/
function setUp() {
Router::reload();
- $this->Controller = new Controller();
- $this->PostsController = new ThemePostsController();
+ $this->Controller =& new Controller();
+ $this->PostsController =& new ThemePostsController();
$this->PostsController->viewPath = 'posts';
$this->PostsController->index();
- $this->ThemeView = new ThemeView($this->PostsController);
+ $this->ThemeView =& new ThemeView($this->PostsController);
}
/**
@@ -166,6 +166,19 @@ function tearDown() {
unset($this->ThemeView);
unset($this->PostsController);
unset($this->Controller);
+ ClassRegistry::flush();
+ }
+/**
+ * test that the theme view can be constructed without going into the registry
+ *
+ * @return void
+ */
+ function testConstructionNoRegister() {
+ ClassRegistry::flush();
+ $controller = null;
+ $Theme =& new ThemeView($controller, false);
+ $ThemeTwo =& ClassRegistry::getObject('view');
+ $this->assertFalse($ThemeTwo);
}
/**
View
29 cake/tests/cases/libs/xml.test.php
@@ -113,7 +113,6 @@ function testSerializeOnMultiDimensionalArray() {
$result =& new Xml($data, array('format' => 'tags'));
$expected = '<statuses><status><id>1</id></status><status><id>2</id></status></statuses>';
$this->assertIdentical($result->toString(), $expected);
-
}
/**
@@ -263,7 +262,7 @@ function testArraySingleSerialization() {
* @access public
* @return void
*/
- function testArraySerialization() {
+ function testSerializationArray() {
$input = array(
array(
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 1, 'industry_id' => 1, 'modified' => null, 'created' => null),
@@ -291,7 +290,7 @@ function testArraySerialization() {
* @access public
* @return void
*/
- function testNestedArraySerialization() {
+ function testSerializationNestedArray() {
$input = array(
array(
'Project' => array('id' => 1, 'title' => null, 'client_id' => 1, 'show' => 1, 'is_spotlight' => null, 'style_id' => 0, 'job_type_id' => 1, 'industry_id' => 1, 'modified' => null, 'created' => null),
@@ -337,9 +336,9 @@ function testNestedArraySerialization() {
*/
function testArraySerializationWithRoot() {
$input = array(
- array('Shirt' => array('id' => 1, 'color' => 'green')),
- array('Shirt' => array('id' => 2, 'color' => 'blue')),
- );
+ array('Shirt' => array('id' => 1, 'color' => 'green')),
+ array('Shirt' => array('id' => 2, 'color' => 'blue')),
+ );
$expected = '<collection><shirt id="1" color="green" />';
$expected .= '<shirt id="2" color="blue" /></collection>';
@@ -715,6 +714,24 @@ function testSetSerialization() {
}
/**
+ * ensure that normalize does not add _name_ elements that come from Set::map sometimes.
+ *
+ * @return void
+ */
+ function testNormalizeNotAdding_name_Element() {
+ $input = array(
+ 'output' => array(
+ 'Vouchers' => array(
+ array('Voucher' => array('id' => 1)),
+ array('Voucher' => array('id' => 2)),
+ ),
+ )
+ );
+ $xml = new Xml($input, array('attributes' => false, 'format' => 'tags'));
+ $this->assertFalse(isset($xml->children[0]->children[0]->children[1]), 'Too many children %s');
+ $this->assertEqual($xml->children[0]->children[0]->children[0]->name, 'voucher');
+ }
+/**
* testSimpleParsing method
*
* @access public
Please sign in to comment.
Something went wrong with that request. Please try again.