Permalink
Browse files

Merge branch '1.3' of code.cakephp.org:cakephp into 1.3

  • Loading branch information...
phpnut committed Nov 4, 2009
2 parents a1ce9e6 + d17c526 commit 2bf630f209ba81ca530e2e2282fd6e442de142c4
Showing with 1,442 additions and 797 deletions.
  1. +2 −0 cake/console/libs/bake.php
  2. +22 −3 cake/console/libs/tasks/extract.php
  3. +4 −3 cake/console/libs/tasks/fixture.php
  4. +2 −0 cake/console/libs/templates/skel/views/layouts/xml/default.ctp
  5. +1 −1 cake/console/templates/skel/views/layouts/default.ctp
  6. +6 −6 cake/libs/cake_session.php
  7. +3 −3 cake/libs/controller/components/auth.php
  8. +3 −0 cake/libs/controller/controller.php
  9. +25 −22 cake/libs/controller/scaffold.php
  10. +2 −10 cake/libs/debugger.php
  11. +1 −1 cake/libs/folder.php
  12. +1 −1 cake/libs/http_socket.php
  13. +4 −1 cake/libs/model/behaviors/tree.php
  14. +31 −13 cake/libs/model/datasources/datasource.php
  15. +11 −1 cake/libs/model/datasources/dbo/dbo_adodb.php
  16. +8 −0 cake/libs/model/datasources/dbo/dbo_db2.php
  17. +9 −0 cake/libs/model/datasources/dbo/dbo_firebird.php
  18. +8 −0 cake/libs/model/datasources/dbo/dbo_mssql.php
  19. +42 −46 cake/libs/model/datasources/dbo/dbo_mysql.php
  20. +8 −58 cake/libs/model/datasources/dbo/dbo_mysqli.php
  21. +8 −0 cake/libs/model/datasources/dbo/dbo_odbc.php
  22. +9 −0 cake/libs/model/datasources/dbo/dbo_postgres.php
  23. +28 −26 cake/libs/model/datasources/dbo/dbo_sqlite.php
  24. +8 −0 cake/libs/model/datasources/dbo/dbo_sybase.php
  25. +26 −17 cake/libs/model/datasources/dbo_source.php
  26. +5 −0 cake/libs/string.php
  27. +0 −20 cake/libs/validation.php
  28. +13 −16 cake/libs/view/helpers/cache.php
  29. +101 −60 cake/libs/view/helpers/form.php
  30. +6 −4 cake/libs/view/helpers/paginator.php
  31. +56 −43 cake/libs/view/helpers/text.php
  32. +1 −1 cake/libs/view/layouts/default.ctp
  33. +1 −1 cake/tests/cases/console/libs/api.test.php
  34. +5 −6 cake/tests/cases/console/libs/tasks/model.test.php
  35. +2 −0 cake/tests/cases/libs/cake_test_case.test.php
  36. +1 −1 cake/tests/cases/libs/code_coverage_manager.test.php
  37. +15 −3 cake/tests/cases/libs/controller/component.test.php
  38. +2 −7 cake/tests/cases/libs/controller/components/email.test.php
  39. +4 −1 cake/tests/cases/libs/controller/components/request_handler.test.php
  40. +1 −0 cake/tests/cases/libs/controller/components/security.test.php
  41. +4 −1 cake/tests/cases/libs/controller/controller.test.php
  42. +8 −1 cake/tests/cases/libs/controller/controller_merge_vars.test.php
  43. +57 −10 cake/tests/cases/libs/controller/scaffold.test.php
  44. +1 −0 cake/tests/cases/libs/debugger.test.php
  45. +12 −0 cake/tests/cases/libs/folder.test.php
  46. +22 −0 cake/tests/cases/libs/http_socket.test.php
  47. +3 −3 cake/tests/cases/libs/i18n.test.php
  48. +19 −0 cake/tests/cases/libs/model/behaviors/tree.test.php
  49. +30 −12 cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
  50. +14 −5 cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php
  51. +5 −2 cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
  52. +72 −0 cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
  53. +53 −6 cake/tests/cases/libs/model/datasources/dbo_source.test.php
  54. +4 −0 cake/tests/cases/libs/multibyte.test.php
  55. +5 −0 cake/tests/cases/libs/string.test.php
  56. +4 −0 cake/tests/cases/libs/validation.test.php
  57. +6 −0 cake/tests/cases/libs/view/helpers/ajax.test.php
  58. +503 −237 cake/tests/cases/libs/view/helpers/form.test.php
  59. +1 −1 cake/tests/cases/libs/view/helpers/javascript.test.php
  60. +29 −29 cake/tests/cases/libs/view/helpers/text.test.php
  61. +17 −50 cake/tests/cases/libs/view/helpers/time.test.php
  62. +18 −1 cake/tests/groups/console.group.php
  63. +6 −3 cake/tests/groups/controller.group.php
  64. +1 −1 cake/tests/groups/lib.group.php
  65. +0 −58 cake/tests/groups/no_database.group.php
  66. +60 −0 cake/tests/lib/cake_text_reporter.php
  67. +1 −1 cake/tests/lib/code_coverage_manager.php
  68. +2 −1 cake/tests/lib/test_manager.php
@@ -81,6 +81,8 @@ function main() {
if (!is_dir($this->DbConfig->path)) {
if ($this->Project->execute()) {
$this->DbConfig->path = $this->params['working'] . DS . 'config' . DS;
+ } else {
+ return false;
}
}
@@ -45,6 +45,14 @@ class ExtractTask extends Shell {
*/
var $__files = array();
+/**
+ * Merge all domains string into the default.pot file
+ *
+ * @var boolean
+ * @access public
+ */
+ var $__merge = false;
+
/**
* Current file being processed
*
@@ -137,6 +145,14 @@ function execute() {
}
}
+ if (isset($this->params['merge'])) {
+ $this->__merge = !(strtolower($this->params['merge']) === 'no');
+ } else {
+ $this->out();
+ $response = $this->in(sprintf(__('Would you like to merge all domains strings into the default.pot file?', true)), array('y', 'n'), 'n');
+ $this->__merge = strtolower($response) === 'y';
+ }
+
if (empty($this->__files)) {
$this->__searchFiles();
}
@@ -176,15 +192,18 @@ function help() {
$this->out(__('By default the .pot file(s) will be place in the locale directory of -app', true));
$this->out(__('By default -app is ROOT/app', true));
$this->hr();
- $this->out(__('Usage: cake i18n extract [command] [path...]', true));
+ $this->out(__('Usage: cake i18n extract <command> <param1> <param2>...', true));
$this->out();
- $this->out(__('Commands:', true));
+ $this->out(__('Params:', true));
$this->out(__(' -app [path...]: directory where your application is located', true));
$this->out(__(' -root [path...]: path to install', true));
$this->out(__(' -core [path...]: path to cake directory', true));
$this->out(__(' -paths [comma separated list of paths, full path is needed]', true));
+ $this->out(__(' -merge [yes|no]: Merge all domains strings into the default.pot file', true));
$this->out(__(' -output [path...]: Full path to output directory', true));
$this->out(__(' -files: [comma separated list of files, full path to file is needed]', true));
+ $this->out();
+ $this->out(__('Commands:', true));
$this->out(__(' cake i18n extract help: Shows this help message.', true));
$this->out();
}
@@ -322,7 +341,7 @@ function __buildFiles() {
}
$this->__store($domain, $header, $sentence);
- if ($domain != 'default') {
+ if ($domain != 'default' && $this->__merge) {
$this->__store('default', $header, $sentence);
}
}
@@ -73,9 +73,6 @@ class FixtureTask extends Shell {
function __construct(&$dispatch) {
parent::__construct($dispatch);
$this->path = $this->params['working'] . DS . 'tests' . DS . 'fixtures' . DS;
- if (!class_exists('CakeSchema')) {
- App::import('Model', 'CakeSchema', false);
- }
}
/**
@@ -85,6 +82,10 @@ function __construct(&$dispatch) {
* @access public
*/
function execute() {
+ if (!class_exists('CakeSchema')) {
+ App::import('Model', 'CakeSchema', false);
+ }
+
if (empty($this->args)) {
$this->__interactive();
}
@@ -0,0 +1,2 @@
+<?php echo $xml->header(); ?>
+<?php echo $content_for_layout; ?>
@@ -55,7 +55,7 @@
<?php echo $html->link(
$html->image('cake.power.gif', array('alt'=>__("CakePHP: the rapid development php framework", true), 'border'=>"0")),
'http://www.cakephp.org/',
- array('target'=>'_blank', 'escape'=>false), null
+ array('target' => '_blank', 'escape' => false)
);
?>
</div>
View
@@ -641,15 +641,15 @@ function _checkValid() {
function __regenerateId() {
$oldSessionId = session_id();
if ($oldSessionId) {
- $sessionpath = session_save_path();
- if (empty($sessionpath)) {
- $sessionpath = "/tmp";
- }
- if (session_id() != "" || isset($_COOKIE[session_name()])) {
+ if (session_id() != ''|| isset($_COOKIE[session_name()])) {
setcookie(Configure::read('Session.cookie'), '', time() - 42000, $this->path);
}
session_regenerate_id(true);
if (PHP_VERSION < 5.1) {
+ $sessionPath = session_save_path();
+ if (empty($sessionPath)) {
+ $sessionPath = '/tmp';
+ }
$newSessid = session_id();
if (function_exists('session_write_close')) {
@@ -659,7 +659,7 @@ function __regenerateId() {
session_id($oldSessionId);
session_start();
session_destroy();
- $file = $sessionpath . DS . "sess_$oldSessionId";
+ $file = $sessionPath . DS . 'sess_' . $oldSessionId;
@unlink($file);
$this->__initSession();
session_id($newSessid);
@@ -450,10 +450,10 @@ function __setDefaults() {
return false;
}
$defaults = array(
- 'loginAction' => Router::normalize(array(
- 'controller'=> Inflector::underscore(Inflector::pluralize($this->userModel)),
+ 'loginAction' => array(
+ 'controller' => Inflector::underscore(Inflector::pluralize($this->userModel)),
'action' => 'login'
- )),
+ ),
'sessionKey' => 'Auth.' . $this->userModel,
'logoutRedirect' => $this->loginAction,
'loginError' => __('Login failed. Invalid username or password.', true),
@@ -74,6 +74,9 @@ class Controller extends Object {
*
* Example: var $uses = array('Product', 'Post', 'Comment');
*
+ * Can be set to array() to use no models. Can be set to false to
+ * use no models and prevent the merging of $uses with AppController
+ *
* @var mixed A single name as a string or a list of names as an array.
* @access protected
* @link http://book.cakephp.org/view/53/components-helpers-and-uses
@@ -434,54 +434,52 @@ function __scaffoldError() {
/**
* When methods are now present in a controller
* scaffoldView is used to call default Scaffold methods if:
- * <code>
- * var $scaffold;
- * </code>
- * is placed in the controller's class definition.
+ * `var $scaffold;` is placed in the controller's class definition.
*
* @param array $params Parameters for scaffolding
* @return mixed A rendered view of scaffold action, or showing the error
* @access private
*/
function __scaffold($params) {
$db = &ConnectionManager::getDataSource($this->ScaffoldModel->useDbConfig);
- $admin = Configure::read('Routing.admin');
-
+ $prefixes = Configure::read('Routing.prefixes');
+ $scaffoldPrefix = $this->scaffoldActions;
+
if (isset($db)) {
if (empty($this->scaffoldActions)) {
$this->scaffoldActions = array(
'index', 'list', 'view', 'add', 'create', 'edit', 'update', 'delete'
);
- } elseif (!empty($admin) && $this->scaffoldActions === $admin) {
+ } elseif (!empty($prefixes) && in_array($scaffoldPrefix, $prefixes)) {
$this->scaffoldActions = array(
- $admin .'_index', $admin .'_list', $admin .'_view', $admin .'_add',
- $admin .'_create', $admin .'_edit', $admin .'_update', $admin .'_delete'
+ $scaffoldPrefix . '_index',
+ $scaffoldPrefix . '_list',
+ $scaffoldPrefix . '_view',
+ $scaffoldPrefix . '_add',
+ $scaffoldPrefix . '_create',
+ $scaffoldPrefix . '_edit',
+ $scaffoldPrefix . '_update',
+ $scaffoldPrefix . '_delete'
);
}
if (in_array($params['action'], $this->scaffoldActions)) {
- if (!empty($admin)) {
- $params['action'] = str_replace($admin . '_', '', $params['action']);
+ if (!empty($prefixes)) {
+ $params['action'] = str_replace($scaffoldPrefix . '_', '', $params['action']);
}
switch ($params['action']) {
case 'index':
+ case 'list':
$this->__scaffoldIndex($params);
break;
case 'view':
$this->__scaffoldView($params);
break;
- case 'list':
- $this->__scaffoldIndex($params);
- break;
case 'add':
- $this->__scaffoldSave($params, 'add');
- break;
- case 'edit':
- $this->__scaffoldSave($params, 'edit');
- break;
case 'create':
$this->__scaffoldSave($params, 'add');
break;
+ case 'edit':
case 'update':
$this->__scaffoldSave($params, 'edit');
break;
@@ -556,10 +554,15 @@ function _getViewFileName($name = null) {
$name = $this->action;
}
$name = Inflector::underscore($name);
- $admin = Configure::read('Routing.admin');
+ $prefixes = Configure::read('Routing.prefixes');
- if (!empty($admin) && strpos($name, $admin . '_') !== false) {
- $name = substr($name, strlen($admin) + 1);
+ if (!empty($prefixes)) {
+ foreach ($prefixes as $prefix) {
+ if (strpos($name, $prefix . '_') !== false) {
+ $name = substr($name, strlen($prefix) + 1);
+ break;
+ }
+ }
}
if ($name === 'add') {
View
@@ -229,16 +229,8 @@ function dump($var) {
*/
function log($var, $level = LOG_DEBUG) {
$_this = Debugger::getInstance();
- $trace = $_this->trace(array('start' => 1, 'depth' => 2, 'format' => 'array'));
- $source = null;
-
- if (is_object($trace[0]['object']) && isset($trace[0]['object']->_reporter->_test_stack)) {
- $stack = $trace[0]['object']->_reporter->_test_stack;
- $source = sprintf('[%1$s, %3$s::%2$s()]' . "\n",
- array_shift($stack), array_pop($stack), array_pop($stack));
- }
-
- CakeLog::write($level, $source . $_this->exportVar($var));
+ $source = $_this->trace(array('start' => 1)) . "\n";
+ CakeLog::write($level, "\n" . $source . $_this->exportVar($var));
}
/**
View
@@ -326,7 +326,7 @@ function slashTerm($path) {
* @static
*/
function addPathElement($path, $element) {
- return Folder::slashTerm($path) . $element;
+ return rtrim($path, DS) . DS . $element;
}
/**
@@ -693,7 +693,7 @@ function _parseQuery($query) {
foreach ($items as $item) {
if (strpos($item, '=') !== false) {
- list($key, $value) = explode('=', $item);
+ list($key, $value) = explode('=', $item, 2);
} else {
$key = $item;
$value = null;
@@ -474,7 +474,7 @@ function movedown(&$Model, $id = null, $number = 1) {
'fields' => array($Model->primaryKey, $left, $right), 'recursive' => $recursive)
);
if ($nextNode) {
- list($nextNode)= array_values($nextNode);
+ list($nextNode) = array_values($nextNode);
} else {
return false;
}
@@ -657,6 +657,8 @@ function reorder(&$Model, $options = array()) {
$sort = $field . ' ' . $order;
$nodes = $this->children($Model, $id, true, $fields, $sort, null, null, $recursive);
+ $cacheQueries = $Model->cacheQueries;
+ $Model->cacheQueries = false;
if ($nodes) {
foreach ($nodes as $node) {
$id = $node[$Model->alias][$Model->primaryKey];
@@ -666,6 +668,7 @@ function reorder(&$Model, $options = array()) {
}
}
}
+ $Model->cacheQueries = $cacheQueries;
return true;
}
@@ -320,45 +320,53 @@ function column($real) {
}
/**
+ * Used to create new records. The "C" CRUD.
+ *
* To-be-overridden in subclasses.
*
- * @param unknown_type $model
- * @param unknown_type $fields
- * @param unknown_type $values
- * @return unknown
+ * @param Model $model The Model to be created.
+ * @param array $fields An Array of fields to be saved.
+ * @param array $values An Array of values to save.
+ * @return boolean success
*/
function create(&$model, $fields = null, $values = null) {
return false;
}
/**
+ * Used to read records from the Datasource. The "R" in CRUD
+ *
* To-be-overridden in subclasses.
*
- * @param unknown_type $model
- * @param unknown_type $queryData
- * @return unknown
+ * @param Model $model The model being read.
+ * @param array $queryData An array of query data used to find the data you want
+ * @return mixed
*/
function read(&$model, $queryData = array()) {
return false;
}
/**
+ * Update a record(s) in the datasource.
+ *
* To-be-overridden in subclasses.
*
- * @param unknown_type $model
- * @param unknown_type $fields
- * @param unknown_type $values
- * @return unknown
+ * @param Model $model Instance of the model class being updated
+ * @param array $fields Array of fields to be updated
+ * @param array $values Array of values to be update $fields to.
+ * @return boolean Success
*/
function update(&$model, $fields = null, $values = null) {
return false;
}
/**
+ * Delete a record(s) in the datasource.
+ *
* To-be-overridden in subclasses.
*
- * @param unknown_type $model
- * @param unknown_type $id
+ * @param Model $model The model class having record(s) deleted
+ * @param mixed $id Primary key of the model
*/
function delete(&$model, $id = null) {
if ($id == null) {
@@ -396,6 +404,16 @@ function lastAffected($source = null) {
return false;
}
+/**
+ * Check whether the conditions for the Datasource being available
+ * are satisfied. Often used from connect() to check for support
+ * before establishing a connection.
+ *
+ * @return boolean Whether or not the Datasources conditions for use are met.
+ **/
+ function enabled() {
+ return true;
+ }
/**
* Returns true if the DataSource supports the given interface (method)
*
Oops, something went wrong.

0 comments on commit 2bf630f

Please sign in to comment.