Permalink
Browse files

Merge branch '1.2-merge-in' into 1.3

  • Loading branch information...
2 parents ca6ca39 + d1f5acd commit 38f65bdc245051c5399a06ff6b1203ef74a2c658 @markstory markstory committed Oct 14, 2009
Showing with 237 additions and 90 deletions.
  1. +2 −0 cake/libs/cake_session.php
  2. +1 −0 cake/libs/controller/components/email.php
  3. +2 −2 cake/libs/controller/components/request_handler.php
  4. +6 −3 cake/libs/i18n.php
  5. +3 −1 cake/libs/model/behaviors/containable.php
  6. +1 −1 cake/libs/model/datasources/dbo/dbo_oracle.php
  7. +8 −8 cake/libs/model/datasources/dbo/dbo_sybase.php
  8. +2 −2 cake/libs/model/datasources/dbo_source.php
  9. +37 −27 cake/libs/model/model.php
  10. +9 −5 cake/libs/set.php
  11. +19 −17 cake/libs/view/helpers/cache.php
  12. +16 −5 cake/libs/view/helpers/form.php
  13. +5 −2 cake/libs/view/helpers/html.php
  14. +5 −2 cake/libs/view/helpers/javascript.php
  15. +1 −1 cake/libs/view/helpers/time.php
  16. +1 −1 cake/libs/view/helpers/xml.php
  17. +3 −3 cake/libs/view/pages/home.ctp
  18. +2 −2 cake/libs/xml.php
  19. +6 −2 cake/tests/cases/libs/controller/components/request_handler.test.php
  20. +3 −3 cake/tests/cases/libs/i18n.test.php
  21. +21 −0 cake/tests/cases/libs/model/datasources/dbo_source.test.php
  22. +2 −0 cake/tests/cases/libs/model/model_behavior.test.php
  23. +0 −1 cake/tests/cases/libs/model/model_read.test.php
  24. +28 −0 cake/tests/cases/libs/view/helpers/cache.test.php
  25. +4 −0 cake/tests/cases/libs/view/helpers/html.test.php
  26. +8 −0 cake/tests/cases/libs/view/helpers/javascript.test.php
  27. +10 −2 cake/tests/cases/libs/view/helpers/session.test.php
  28. +4 −0 cake/tests/cases/libs/view/helpers/xml.test.php
  29. +13 −0 cake/tests/cases/libs/xml.test.php
  30. +15 −0 cake/tests/test_app/views/posts/multiple_nocache.ctp
@@ -166,6 +166,8 @@ function __construct($base = null, $start = true) {
if (strpos($this->host, ':') !== false) {
$this->host = substr($this->host, 0, strpos($this->host, ':'));
}
+ }
+ if (isset($_SESSION) || $start === true) {
if (!class_exists('Security')) {
App::import('Core', 'Security');
}
@@ -229,6 +229,7 @@ class EmailComponent extends Object{
* - timeout
* - username
* - password
+ * - client
*
* @var array
* @access public
@@ -617,9 +617,9 @@ function renderAs(&$controller, $type) {
$controller->ext = '.ctp';
if (empty($this->__renderType)) {
- $controller->viewPath .= '/' . $type;
+ $controller->viewPath .= DS . $type;
} else {
- $remove = preg_replace("/(?:\/{$this->__renderType})$/", '/' . $type, $controller->viewPath);
+ $remove = preg_replace("/([\/\\\\]{$this->__renderType})$/", DS . $type, $controller->viewPath);
$controller->viewPath = $remove;
}
$this->__renderType = $type;
View
@@ -278,20 +278,23 @@ function __bindTextDomain($domain) {
$plugin = Inflector::underscore($plugin);
if ($plugin === $domain) {
foreach ($pluginPaths as $pluginPath) {
- $searchPaths[] = $pluginPath . DS . $plugin . DS . 'locale';
+ $searchPaths[] = $pluginPath . $plugin . DS . 'locale' . DS;
}
$searchPaths = array_reverse($searchPaths);
break;
}
}
}
+
foreach ($searchPaths as $directory) {
+
foreach ($this->l10n->languagePath as $lang) {
- $file = $directory . DS . $lang . DS . $this->category . DS . $domain;
+ $file = $directory . $lang . DS . $this->category . DS . $domain;
if ($core) {
- $app = $directory . DS . $lang . DS . $this->category . DS . 'core';
+ $app = $directory . $lang . DS . $this->category . DS . 'core';
+
if (file_exists($fn = "$app.mo")) {
$this->__loadMo($fn, $domain);
$this->__noLocale = false;
@@ -83,8 +83,9 @@ function setup(&$Model, $settings = array()) {
* Runs before a find() operation. Used to allow 'contain' setting
* as part of the find call, like this:
*
- * Model->find('all', array('contain' => array('Model1', 'Model2')));
+ * `Model->find('all', array('contain' => array('Model1', 'Model2')));`
*
+ * {{{
* Model->find('all', array('contain' => array(
* 'Model1' => array('Model11', 'Model12'),
* 'Model2',
@@ -93,6 +94,7 @@ function setup(&$Model, $settings = array()) {
* 'Model32',
* 'Model33' => array('Model331', 'Model332')
* )));
+ * }}}
*
* @param object $Model Model using the behavior
* @param array $query Query parameters as set by cake
@@ -952,7 +952,7 @@ function renderStatement($type, $data) {
switch (strtolower($type)) {
case 'select':
- return "SELECT {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$order} {$limit}";
+ return "SELECT {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order} {$limit}";
break;
case 'create':
return "INSERT INTO {$table} ({$fields}) VALUES ({$values})";
@@ -97,17 +97,17 @@ class DboSybase extends DboSource {
*/
function connect() {
$config = $this->config;
- $this->connected = false;
- if (!$config['persistent']) {
- $this->connection = sybase_connect($config['host'], $config['login'], $config['password'], true);
- } else {
- $this->connection = sybase_pconnect($config['host'], $config['login'], $config['password']);
+ $port = '';
+ if ($config['port'] !== null) {
+ $port = ':' . $config['port'];
}
-
- if (sybase_select_db($config['database'], $this->connection)) {
- $this->connected = true;
+ if ($config['persistent']) {
+ $this->connection = sybase_pconnect($config['host'] . $port, $config['login'], $config['password']);
+ } else {
+ $this->connection = sybase_connect($config['host'] . $port, $config['login'], $config['password'], true);
}
+ $this->connected = sybase_select_db($config['database'], $this->connection);
return $this->connected;
}
@@ -215,9 +215,9 @@ function execute($sql, $options = array()) {
$defaults = array('stats' => true, 'log' => $this->fullDebug);
$options = array_merge($defaults, $options);
+ $t = getMicrotime();
+ $this->_result = $this->_execute($sql);
if ($options['stats']) {
- $t = getMicrotime();
- $this->_result = $this->_execute($sql);
$this->took = round((getMicrotime() - $t) * 1000, 0);
$this->affected = $this->lastAffected();
$this->error = $this->lastError();
@@ -495,7 +495,7 @@ function call__($method, $params) {
*
* @param mixed $model A model or association name (string) or set of binding options (indexed by model name type)
* @param array $options If $model is a string, this is the list of association properties with which $model will
- * be bound
+ * be bound
* @param boolean $permanent Set to true to make the binding permanent
* @return void
* @access public
@@ -807,10 +807,12 @@ function setSource($tableName) {
}
/**
- * This function does two things: 1) it scans the array $one for the primary key,
+ * This function does two things:
+ *
+ * 1. it scans the array $one for the primary key,
* and if that's found, it sets the current id to the value of $one[id].
* For all other keys than 'id' the keys and values of $one are copied to the 'data' property of this object.
- * 2) Returns an array with all of $one's keys and values.
+ * 2. Returns an array with all of $one's keys and values.
* (Alternative indata: two strings, which are mangled to
* a one-item, two-dimensional array using $one for a key and $two as its value.)
*
@@ -1039,11 +1041,11 @@ function hasField($name) {
/**
* Initializes the model for writing a new record, loading the default values
- * for those fields that are not defined in $data. Especially helpful for
- * saving data in loops.
+ * for those fields that are not defined in $data, and clearing previous validation errors.
+ * Especially helpful for saving data in loops.
*
* @param mixed $data Optional data array to assign to the model after it is created. If null or false,
- * schema data defaults are not merged.
+ * schema data defaults are not merged.
* @param boolean $filterKey If true, overwrites any primary key input with an empty value
* @return array The current Model::data; after merging $data and/or defaults from database
* @access public
@@ -1174,8 +1176,8 @@ function saveField($name, $value, $validate = false) {
*
* @param array $data Data to save.
* @param mixed $validate Either a boolean, or an array.
- * If a boolean, indicates whether or not to validate before saving.
- * If an array, allows control of validate, callbacks, and fieldList
+ * If a boolean, indicates whether or not to validate before saving.
+ * If an array, allows control of validate, callbacks, and fieldList
* @param array $fieldList List of fields to allow to be written
* @return mixed On success Model::$data if its not empty or true, false on failure
* @access public
@@ -1439,7 +1441,7 @@ function __saveMulti($joined, $id) {
*
* @param array $keys Optional foreign key data, defaults to the information $this->data
* @param boolean $created True if a new record was created, otherwise only associations with
- * 'counterScope' defined get updated
+ * 'counterScope' defined get updated
* @return void
* @access public
*/
@@ -1523,17 +1525,20 @@ function _prepareUpdateFields($data) {
* Saves multiple individual records for a single model; Also works with a single record, as well as
* all its associated records.
*
+ * #### Options
+ *
+ * - validate: Set to false to disable validation, true to validate each record before
+ * saving, 'first' to validate *all* records before any are saved, or 'only' to only
+ * validate the records, but not save them.
+ * - atomic: If true (default), will attempt to save all records in a single transaction.
+ * Should be set to false if database/table does not support transactions.
+ * If false, we return an array similar to the $data array passed, but values are set to true/false
+ * depending on whether each record saved successfully.
+ * - fieldList: Equivalent to the $fieldList parameter in Model::save()
+ *
* @param array $data Record data to save. This can be either a numerically-indexed array (for saving multiple
- * records of the same type), or an array indexed by association name.
- * @param array $options Options to use when saving record data, which are as follows:
- * - validate: Set to false to disable validation, true to validate each record before
- * saving, 'first' to validate *all* records before any are saved, or 'only' to only
- * validate the records, but not save them.
- * - atomic: If true (default), will attempt to save all records in a single transaction.
- * Should be set to false if database/table does not support transactions.
- * If false, we return an array similar to the $data array passed, but values are set to true/false
- * depending on whether each record saved successfully.
- * - fieldList: Equivalent to the $fieldList parameter in Model::save()
+ * records of the same type), or an array indexed by association name.
+ * @param array $options Options to use when saving record data, See $options above.
* @return mixed True on success, or false on failure
* @access public
* @link http://book.cakephp.org/view/84/Saving-Related-Model-Data-hasOne-hasMany-belongsTo
@@ -1730,7 +1735,7 @@ function __save($data, $options) {
* Updates multiple model records based on a set of conditions.
*
* @param array $fields Set of fields and values, indexed by fields.
- * Fields are treated as SQL snippets, to insert literal values manually escape your data.
+ * Fields are treated as SQL snippets, to insert literal values manually escape your data.
* @param mixed $conditions Conditions to match, true for all records
* @return boolean True on success, false on failure
* @access public
@@ -1987,14 +1992,19 @@ function hasAny($conditions = null) {
* second parameter options for finding ( indexed array, including: 'conditions', 'limit',
* 'recursive', 'page', 'fields', 'offset', 'order')
*
- * Eg: find('all', array(
- * 'conditions' => array('name' => 'Thomas Anderson'),
- * 'fields' => array('name', 'email'),
- * 'order' => 'field3 DESC',
- * 'recursive' => 2,
- * 'group' => 'type'));
+ * Eg:
+ * {{{
+ * find('all', array(
+ * 'conditions' => array('name' => 'Thomas Anderson'),
+ * 'fields' => array('name', 'email'),
+ * 'order' => 'field3 DESC',
+ * 'recursive' => 2,
+ * 'group' => 'type'
+ * ));
+ * }}}
*
* Specifying 'fields' for new-notation 'list':
+ *
* - If no fields are specified, then 'id' is used for key and 'model->displayField' is used for value.
* - If a single field is specified, 'id' is used for key and specified field is used for value.
* - If three fields are specified, they are used (in order) for key, value and group.
@@ -2758,7 +2768,7 @@ function setDataSource($dataSource = null) {
$this->tablePrefix = $db->config['prefix'];
}
- if (empty($db) || $db == null || !is_object($db)) {
+ if (empty($db) || !is_object($db)) {
return $this->cakeError('missingConnection', array(array('className' => $this->alias)));
}
}
View
@@ -351,9 +351,11 @@ function format($data, $format, $keys) {
}
/**
- * Implements partial support for XPath 2.0. If $path is an array or $data is empty it the call is delegated to Set::classicExtract.
+ * Implements partial support for XPath 2.0. If $path is an array or $data is empty it the call
+ * is delegated to Set::classicExtract.
+ *
+ * #### Currently implemented selectors:
*
- * Currently implemented selectors:
* - /User/id (similar to the classic {n}.User.id)
* - /User[2]/name (selects the name of the second User)
* - /User[id>2] (selects all Users with an id > 2)
@@ -366,11 +368,13 @@ function format($data, $format, $keys) {
* - /Comment[text=/cakephp/i] (Selects the all comments that have a text matching the regex /cakephp/i)
* - /Comment/@* (Selects the all key names of all comments)
*
- * Other limitations:
+ * #### Other limitations:
+ *
* - Only absolute paths starting with a single '/' are supported right now
*
- * Warning: Even so it has plenty of unit tests the XPath support has not gone through a lot of real-world testing. Please report
- * Bugs as you find them. Suggestions for additional features to imlement are also very welcome!
+ * **Warning**: Even so it has plenty of unit tests the XPath support has not gone through a lot of
+ * real-world testing. Please report Bugs as you find them. Suggestions for additional features to
+ * implement are also very welcome!
*
* @param string $path An absolute XPath 2.0 path
* @param array $data An array of data to extract from
@@ -2,9 +2,7 @@
/* SVN FILE: $Id$ */
/**
- * Short description for file.
- *
- * Long description for file
+ * CacheHelper helps create full page view caching.
*
* PHP versions 4 and 5
*
@@ -27,9 +25,10 @@
*/
/**
- * Short description for file.
+ * CacheHelper helps create full page view caching.
*
- * Long description for file
+ * When using CacheHelper you don't call any of its methods, they are all automatically
+ * called by View, and use the $cacheAction settings set in the controller.
*
* @package cake
* @subpackage cake.cake.libs.view.helpers
@@ -165,27 +164,30 @@ function __parseFile($file, $cache) {
} elseif ($file = fileExistsInPath($file)) {
$file = file_get_contents($file);
}
-
- preg_match_all('/(<cake:nocache>(?<=<cake:nocache>)[\\s\\S]*?(?=<\/cake:nocache>)<\/cake:nocache>)/i', $cache, $oresult, PREG_PATTERN_ORDER);
- preg_match_all('/(?<=<cake:nocache>)([\\s\\S]*?)(?=<\/cake:nocache>)/i', $file, $result, PREG_PATTERN_ORDER);
+ preg_match_all('/(<cake:nocache>(?<=<cake:nocache>)[\\s\\S]*?(?=<\/cake:nocache>)<\/cake:nocache>)/i', $cache, $outputResult, PREG_PATTERN_ORDER);
+ preg_match_all('/(?<=<cake:nocache>)([\\s\\S]*?)(?=<\/cake:nocache>)/i', $file, $fileResult, PREG_PATTERN_ORDER);
+ $fileResult = $fileResult[0];
+ $outputResult = $outputResult[0];
if (!empty($this->__replace)) {
- foreach ($oresult['0'] as $k => $element) {
+ foreach ($outputResult as $i => $element) {
$index = array_search($element, $this->__match);
if ($index !== false) {
- array_splice($oresult[0], $k, 1);
+ unset($outputResult[$i]);
}
}
+ $outputResult = array_values($outputResult);
}
- if (!empty($result['0'])) {
- $count = 0;
- foreach ($result['0'] as $block) {
- if (isset($oresult['0'][$count])) {
- $this->__replace[] = $block;
- $this->__match[] = $oresult['0'][$count];
+
+ if (!empty($fileResult)) {
+ $i = 0;
+ foreach ($fileResult as $cacheBlock) {
+ if (isset($outputResult[$i])) {
+ $this->__replace[] = $cacheBlock;
+ $this->__match[] = $outputResult[$i];
}
- $count++;
+ $i++;
}
}
}
@@ -493,13 +493,24 @@ function label($fieldName = null, $text = null, $attributes = array()) {
}
/**
- * Will display all the fields passed in an array expects fieldName as an array key
- * replaces generateFields
+ * Generate a set of inputs for `$fields`. If $fields is null the current model
+ * will be used.
*
+ * In addition to controller fields output, `$fields` can be used to control legend
+ * and fieldset rendering with the `fieldset` and `legend` keys.
+ * `$form->inputs(array('legend' => 'My legend'));` Would generate an input set with
+ * a custom legend. You can customize individual inputs through `$fields` as well.
+ *
+ * {{{
+ * $form->inputs(array(
+ * 'name' => array('label' => 'custom label')
+ * ));
+ * }}}
+ *
+ * @param mixed $fields An array of fields to generate inputs for, or null.
+ * @param array $blacklist a simple array of fields to skip.
+ * @return string Completed form inputs.
* @access public
- * @param array $fields works well with Controller::generateFields() or on its own;
- * @param array $blacklist a simple array of fields to skip
- * @return output
*/
function inputs($fields = null, $blacklist = null) {
$fieldset = $legend = true;
Oops, something went wrong. Retry.

0 comments on commit 38f65bd

Please sign in to comment.