Skip to content

Commit

Permalink
Merge commit 'origin/1.2' into 1.2-merge-in
Browse files Browse the repository at this point in the history
Conflicts:
	cake/console/libs/shell.php
	cake/libs/model/connection_manager.php
	cake/libs/view/helpers/html.php
	cake/libs/view/helpers/javascript.php
	cake/tests/cases/libs/i18n.test.php
	cake/tests/cases/libs/model/connection_manager.test.php
	cake/tests/cases/libs/model/model_read.test.php
	cake/tests/cases/libs/view/helpers/html.test.php
	cake/tests/groups/database.group.php
  • Loading branch information
markstory committed Oct 14, 2009
2 parents f2cba2f + a4d09a8 commit d1f5acd
Show file tree
Hide file tree
Showing 30 changed files with 237 additions and 90 deletions.
2 changes: 2 additions & 0 deletions cake/libs/cake_session.php
Expand Up @@ -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');
}
Expand Down
1 change: 1 addition & 0 deletions cake/libs/controller/components/email.php
Expand Up @@ -229,6 +229,7 @@ class EmailComponent extends Object{
* - timeout
* - username
* - password
* - client
*
* @var array
* @access public
Expand Down
4 changes: 2 additions & 2 deletions cake/libs/controller/components/request_handler.php
Expand Up @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions cake/libs/i18n.php
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion cake/libs/model/behaviors/containable.php
Expand Up @@ -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',
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/model/datasources/dbo/dbo_oracle.php
Expand Up @@ -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})";
Expand Down
16 changes: 8 additions & 8 deletions cake/libs/model/datasources/dbo/dbo_sybase.php
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions cake/libs/model/datasources/dbo_source.php
Expand Up @@ -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();
Expand Down
64 changes: 37 additions & 27 deletions cake/libs/model/model.php
Expand Up @@ -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
Expand Down Expand Up @@ -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.)
*
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)));
}
}
Expand Down
14 changes: 9 additions & 5 deletions cake/libs/set.php
Expand Up @@ -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)
Expand All @@ -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
Expand Down
36 changes: 19 additions & 17 deletions cake/libs/view/helpers/cache.php
Expand Up @@ -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
*
Expand All @@ -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
Expand Down Expand Up @@ -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++;
}
}
}
Expand Down
21 changes: 16 additions & 5 deletions cake/libs/view/helpers/form.php
Expand Up @@ -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;
Expand Down

0 comments on commit d1f5acd

Please sign in to comment.