Skip to content

Commit

Permalink
Merge branch '1.2' into 1.2-merger
Browse files Browse the repository at this point in the history
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
markstory committed Dec 7, 2009
2 parents 4cefb5f + cc750d1 commit 7259a1b
Show file tree
Hide file tree
Showing 16 changed files with 126 additions and 131 deletions.
2 changes: 1 addition & 1 deletion app/webroot/css/cake.generic.css
Expand Up @@ -189,7 +189,7 @@ dl {
margin: 0em 0em;
width: 60%;
}
dl.altrow {
dl .altrow {
background: #f4f4f4;
}
dt {
Expand Down
2 changes: 1 addition & 1 deletion cake/console/templates/skel/webroot/css/cake.generic.css
Expand Up @@ -190,7 +190,7 @@ dl {
margin: 0em 0em;
width: 60%;
}
dl.altrow {
dl .altrow {
background: #f4f4f4;
}
dt {
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/class_registry.php
Expand Up @@ -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
*/
Expand Down
3 changes: 2 additions & 1 deletion cake/libs/controller/controller.php
Expand Up @@ -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)) {
Expand Down
9 changes: 0 additions & 9 deletions cake/libs/model/behaviors/tree.php
Expand Up @@ -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]) {
Expand Down
95 changes: 47 additions & 48 deletions cake/libs/model/datasources/dbo/dbo_mysql.php
Expand Up @@ -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';
}
}

/**
Expand Down Expand Up @@ -682,54 +729,6 @@ function lastInsertId($source = null) {
return 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...
*
Expand Down
48 changes: 0 additions & 48 deletions cake/libs/model/datasources/dbo/dbo_mysqli.php
Expand Up @@ -260,54 +260,6 @@ function lastInsertId($source = null) {
return 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...
*
Expand Down
3 changes: 3 additions & 0 deletions cake/libs/model/model.php
Expand Up @@ -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
Expand All @@ -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
*/
Expand Down
3 changes: 2 additions & 1 deletion cake/libs/router.php
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/javascript.php
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions cake/libs/view/helpers/text.php
Expand Up @@ -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;
}
}
?>
10 changes: 5 additions & 5 deletions cake/libs/xml.php
Expand Up @@ -114,7 +114,6 @@ function __construct($name = null, $value = null, $namespace = null) {
$this->createTextNode($value);
}
}

/**
* Adds a namespace to the current node
*
Expand Down Expand Up @@ -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_']);
}
Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -1135,6 +1134,7 @@ function __destruct() {
if (is_resource($this->__parser)) {
xml_parser_free($this->__parser);
}
$this->_killParent(true);
}

/**
Expand Down
13 changes: 13 additions & 0 deletions cake/tests/cases/libs/model/model_write.test.php
Expand Up @@ -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')));
}

/**
Expand Down
3 changes: 3 additions & 0 deletions cake/tests/cases/libs/view/helpers/text.test.php
Expand Up @@ -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');
}
}
?>
19 changes: 16 additions & 3 deletions cake/tests/cases/libs/view/theme.test.php
Expand Up @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand Down

0 comments on commit 7259a1b

Please sign in to comment.