Permalink
Browse files

Merge branch '1.3' of git://github.com/cakephp/cakephp into 1.3

  • Loading branch information...
2 parents 5e27561 + d9c7f4d commit 1f473f5bcdf4bda8630af724dcae4fe8befad239 @ceeram ceeram committed May 2, 2011
@@ -504,6 +504,7 @@ function help() {
parameter will only update one table.
To use a snapshot pass the `-s` param with the snapshot number.
To preview the changes that will be done use `-dry`.
+ To force update of all tables into the schema, use the -f param.
TEXT;
$this->out($help);
$this->_stop();
View
@@ -627,7 +627,7 @@ function _deliverAsset($assetFile, $ext) {
ob_start('ob_gzhandler');
}
- App::import('View', 'Media', false);
+ App::import('View', 'Media');
$controller = null;
$Media = new MediaView($controller);
if (isset($Media->mimeType[$ext])) {
View
@@ -212,8 +212,14 @@ function write($data) {
return false;
}
}
-
- return fwrite($this->connection, $data, strlen($data));
+ $totalBytes = strlen($data);
+ for ($written = 0, $rv = 0; $written < $totalBytes; $written += $rv) {
+ $rv = fwrite($this->connection, substr($data, $written));
+ if ($rv === false || $rv === 0) {
+ return $written;
+ }
+ }
+ return $written;
}
/**
@@ -281,8 +281,14 @@ function delete($key) {
$this->read();
}
if (strpos($key, '.') === false) {
+ if (isset($this->__values[$key]) && is_array($this->__values[$key])) {
+ foreach ($this->__values[$key] as $idx => $val) {
+ $this->__delete("[$key][$idx]");
+ }
+ } else {
+ $this->__delete("[$key]");
+ }
unset($this->__values[$key]);
- $this->__delete("[$key]");
return;
}
$names = explode('.', $key, 2);
@@ -945,7 +945,7 @@ function _parseHeader($header) {
* Parses cookies in response headers.
*
* @param array $header Header array containing one ore more 'Set-Cookie' headers.
- * @return mixed Either false on no cookies, or an array of cookies recieved.
+ * @return mixed Either false on no cookies, or an array of cookies received.
* @access public
* @todo Make this 100% RFC 2965 confirm
*/
@@ -437,7 +437,7 @@ function getpath(&$Model, $id = null, $fields = null, $recursive = null) {
*
* @param AppModel $Model Model instance
* @param mixed $id The ID of the record to move
- * @param mixed $number how many places to move the node or true to move to last position
+ * @param int|bool $number how many places to move the node or true to move to last position
* @return boolean true on success, false on failure
* @access public
* @link http://book.cakephp.org/view/1352/moveDown
@@ -496,7 +496,7 @@ function movedown(&$Model, $id = null, $number = 1) {
*
* @param AppModel $Model Model instance
* @param mixed $id The ID of the record to move
- * @param mixed $number how many places to move the node, or true to move to first position
+ * @param int|bool $number how many places to move the node, or true to move to first position
* @return boolean true on success, false on failure
* @access public
* @link http://book.cakephp.org/view/1353/moveUp
View
@@ -431,6 +431,13 @@ function extract($path, $data = null, $options = array()) {
'key' => $key,
'item' => array_keys($context['item']),
);
+ } elseif (($key === $token || (ctype_digit($token) && $key == $token) || $token === '.')) {
+ $context['trace'][] = $key;
+ $matches[] = array(
+ 'trace' => $context['trace'],
+ 'key' => $key,
+ 'item' => $context['item'],
+ );
} elseif (is_array($context['item']) && array_key_exists($token, $context['item'])) {
$items = $context['item'][$token];
if (!is_array($items)) {
@@ -470,13 +477,6 @@ function extract($path, $data = null, $options = array()) {
'item' => $item,
);
}
- } elseif (($key === $token || (ctype_digit($token) && $key == $token) || $token === '.')) {
- $context['trace'][] = $key;
- $matches[] = array(
- 'trace' => $context['trace'],
- 'key' => $key,
- 'item' => $context['item'],
- );
}
}
if ($conditions) {
@@ -678,7 +678,9 @@ function inputs($fields = null, $blacklist = null) {
* ### Options
*
* See each field type method for more information. Any options that are part of
- * $attributes or $options for the different **type** methods can be included in `$options` for input().
+ * $attributes or $options for the different **type** methods can be included in `$options` for input().i
+ * Additionally, any unknown keys that are not in the list below, or part of the selected type's options
+ * will be treated as a regular html attribute for the generated input.
*
* - `type` - Force the type of widget you want. e.g. `type => 'select'`
* - `label` - Either a string label, or an array of options for the label. See FormHelper::label()
@@ -1454,7 +1456,7 @@ function select($fieldName, $options = array(), $selected = null, $attributes =
$selected = $attributes['value'];
}
- if (isset($attributes) && array_key_exists('multiple', $attributes)) {
+ if (!empty($attributes['multiple'])) {
$style = ($attributes['multiple'] === 'checkbox') ? 'checkbox' : null;
$template = ($style) ? 'checkboxmultiplestart' : 'selectmultiplestart';
$tag = $this->Html->tags[$template];
@@ -33,7 +33,7 @@ class TimeHelper extends AppHelper {
* Converts a string representing the format for the function strftime and returns a
* windows safe and i18n aware format.
*
- * @param string $format Format with specifiers for strftime function.
+ * @param string $format Format with specifiers for strftime function.
* Accepts the special specifier %S which mimics th modifier S for date()
* @param string UNIX timestamp
* @return string windows safe and date() function compatible format for strftime
@@ -343,7 +343,7 @@ function isThisYear($dateString, $userOffset = null) {
* @return boolean True if datetime string was yesterday
* @access public
* @link http://book.cakephp.org/view/1472/Testing-Time
- *
+ *
*/
function wasYesterday($dateString, $userOffset = null) {
$date = $this->fromString($dateString, $userOffset);
@@ -589,33 +589,33 @@ function timeAgoInWords($dateTime, $options = array()) {
} else {
if ($years > 0) {
// years and months and days
- $relativeDate .= ($relativeDate ? ', ' : '') . $years . ' ' . __n('year', 'years', $years, true);
- $relativeDate .= $months > 0 ? ($relativeDate ? ', ' : '') . $months . ' ' . __n('month', 'months', $months, true) : '';
- $relativeDate .= $weeks > 0 ? ($relativeDate ? ', ' : '') . $weeks . ' ' . __n('week', 'weeks', $weeks, true) : '';
- $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' ' . __n('day', 'days', $days, true) : '';
+ $relativeDate .= ($relativeDate ? ', ' : '') . sprintf(__n('%d year', '%d years', $years, true), $years);
+ $relativeDate .= $months > 0 ? ($relativeDate ? ', ' : '') . sprintf(__n('%d month', '%d months', $months, true), $months) : '';
+ $relativeDate .= $weeks > 0 ? ($relativeDate ? ', ' : '') . sprintf(__n('%d week', '%d weeks', $weeks, true), $weeks) : '';
+ $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . sprintf(__n('%d day', '%d days', $days, true), $days) : '';
} elseif (abs($months) > 0) {
// months, weeks and days
- $relativeDate .= ($relativeDate ? ', ' : '') . $months . ' ' . __n('month', 'months', $months, true);
- $relativeDate .= $weeks > 0 ? ($relativeDate ? ', ' : '') . $weeks . ' ' . __n('week', 'weeks', $weeks, true) : '';
- $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' ' . __n('day', 'days', $days, true) : '';
+ $relativeDate .= ($relativeDate ? ', ' : '') . sprintf(__n('%d month', '%d months', $months, true), $months);
+ $relativeDate .= $weeks > 0 ? ($relativeDate ? ', ' : '') . sprintf(__n('%d week', '%d weeks', $weeks, true), $weeks) : '';
+ $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . sprintf(__n('%d day', '%d days', $days, true), $days) : '';
} elseif (abs($weeks) > 0) {
// weeks and days
- $relativeDate .= ($relativeDate ? ', ' : '') . $weeks . ' ' . __n('week', 'weeks', $weeks, true);
- $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' ' . __n('day', 'days', $days, true) : '';
+ $relativeDate .= ($relativeDate ? ', ' : '') . sprintf(__n('%d week', '%d weeks', $weeks, true), $weeks);
+ $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . sprintf(__n('%d day', '%d days', $days, true), $days) : '';
} elseif (abs($days) > 0) {
// days and hours
- $relativeDate .= ($relativeDate ? ', ' : '') . $days . ' ' . __n('day', 'days', $days, true);
- $relativeDate .= $hours > 0 ? ($relativeDate ? ', ' : '') . $hours . ' ' . __n('hour', 'hours', $hours, true) : '';
+ $relativeDate .= ($relativeDate ? ', ' : '') . sprintf(__n('%d day', '%d days', $days, true), $days);
+ $relativeDate .= $hours > 0 ? ($relativeDate ? ', ' : '') . sprintf(__n('%d hour', '%d hours', $hours, true), $hours) : '';
} elseif (abs($hours) > 0) {
// hours and minutes
- $relativeDate .= ($relativeDate ? ', ' : '') . $hours . ' ' . __n('hour', 'hours', $hours, true);
- $relativeDate .= $minutes > 0 ? ($relativeDate ? ', ' : '') . $minutes . ' ' . __n('minute', 'minutes', $minutes, true) : '';
+ $relativeDate .= ($relativeDate ? ', ' : '') . sprintf(__n('%d hour', '%d hours', $hours, true), $hours);
+ $relativeDate .= $minutes > 0 ? ($relativeDate ? ', ' : '') . sprintf(__n('%d minute', '%d minutes', $minutes, true), $minutes) : '';
} elseif (abs($minutes) > 0) {
// minutes only
- $relativeDate .= ($relativeDate ? ', ' : '') . $minutes . ' ' . __n('minute', 'minutes', $minutes, true);
+ $relativeDate .= ($relativeDate ? ', ' : '') . sprintf(__n('%d minute', '%d minutes', $minutes, true), $minutes);
} else {
// seconds only
- $relativeDate .= ($relativeDate ? ', ' : '') . $seconds . ' ' . __n('second', 'seconds', $seconds, true);
+ $relativeDate .= ($relativeDate ? ', ' : '') . sprintf(__n('%d second', '%d seconds', $seconds, true), $seconds);
}
if (!$backwards) {
@@ -644,7 +644,7 @@ function relativeTime($dateTime, $options = array()) {
/**
* Returns true if specified datetime was within the interval specified, else false.
*
- * @param mixed $timeInterval the numeric value with space then time type.
+ * @param mixed $timeInterval the numeric value with space then time type.
* Example of valid types: 6 hours, 2 days, 1 minute.
* @param mixed $dateString the datestring or unix timestamp to compare
* @param int $userOffset User's offset from GMT (in hours)
@@ -38,6 +38,8 @@ class XmlHelper extends AppHelper {
*/
var $encoding = 'UTF-8';
+ var $Xml;
+ var $XmlElement;
/**
* Constructor
*
@@ -136,7 +138,7 @@ function elem($name, $attrib = array(), $content = null, $endTag = true) {
$out = $elem->toString(array('cdata' => $cdata, 'leaveOpen' => !$endTag));
if (!$endTag) {
- $this->Xml =& $elem;
+ $this->XmlElement =& $elem;
}
return $out;
}
@@ -148,9 +150,10 @@ function elem($name, $attrib = array(), $content = null, $endTag = true) {
* @access public
*/
function closeElem() {
- $name = $this->Xml->name();
- if ($parent =& $this->Xml->parent()) {
- $this->Xml =& $parent;
+ $elem = (empty($this->XmlElement)) ? $this->Xml : $this->XmlElement;
+ $name = $elem->name();
+ if ($parent =& $elem->parent()) {
+ $this->XmlElement =& $parent;
}
return '</' . $name . '>';
}
View
@@ -687,11 +687,11 @@ function toString($options = array(), $depth = 0) {
*/
function toArray($camelize = true) {
$out = $this->attributes;
- $multi = null;
foreach ($this->children as $child) {
$key = $camelize ? Inflector::camelize($child->name) : $child->name;
+ $leaf = false;
if (is_a($child, 'XmlTextNode')) {
$out['value'] = $child->value;
continue;
@@ -700,47 +700,34 @@ function toArray($camelize = true) {
if ($child->attributes) {
$value = array_merge(array('value' => $value), $child->attributes);
}
- if (isset($out[$child->name]) || isset($multi[$key])) {
- if (!isset($multi[$key])) {
- $multi[$key] = array($out[$child->name]);
- unset($out[$child->name]);
- }
- $multi[$key][] = $value;
- } else {
- $out[$child->name] = $value;
+ if (count($child->children) == 1) {
+ $leaf = true;
}
- continue;
} elseif (count($child->children) === 0 && $child->value == '') {
$value = $child->attributes;
- if (isset($out[$key]) || isset($multi[$key])) {
- if (!isset($multi[$key])) {
- $multi[$key] = array($out[$key]);
- //unset($out[$key]);
- }
- $multi[$key][] = $value;
- } elseif (!empty($value)) {
- $out[$key] = $value;
- } else {
- $out[$child->name] = $value;
+ if (empty($value)) {
+ $leaf = true;
}
- continue;
} else {
$value = $child->toArray($camelize);
}
- if (!isset($out[$key])) {
- $out[$key] = $value;
- } else {
- if (!is_array($out[$key]) || !isset($out[$key][0])) {
+ if (isset($out[$key])) {
+ if(!isset($out[$key][0]) || !is_array($out[$key]) || !is_int(key($out[$key]))) {
$out[$key] = array($out[$key]);
- }
+ }
$out[$key][] = $value;
+ } elseif (isset($out[$child->name])) {
+ $t = $out[$child->name];
+ unset($out[$child->name]);
+ $out[$key] = array($t);
+ $out[$key][] = $value;
+ } elseif ($leaf) {
+ $out[$child->name] = $value;
+ } else {
+ $out[$key] = $value;
}
}
-
- if (isset($multi)) {
- $out = array_merge($out, $multi);
- }
return $out;
}
@@ -227,7 +227,7 @@ function testConfigured() {
* @return void
*/
function testInitSettings() {
- Cache::config('default', array('engine' => 'File', 'path' => TMP . 'tests'));
+ Cache::config('for_test', array('engine' => 'File', 'path' => TMP . 'tests'));
$settings = Cache::settings();
$expecting = array(
Oops, something went wrong.

0 comments on commit 1f473f5

Please sign in to comment.