Skip to content

Commit

Permalink
Merge branch '1.3-misc' of dev@code.cakephp.org:cakephp into 1.3-misc
Browse files Browse the repository at this point in the history
  • Loading branch information
Niles committed Sep 1, 2009
2 parents dfc3cd2 + 4d458e9 commit 0614580
Show file tree
Hide file tree
Showing 16 changed files with 256 additions and 203 deletions.
19 changes: 11 additions & 8 deletions cake/libs/controller/components/cookie.php
@@ -1,6 +1,4 @@
<?php
/* SVN FILE: $Id$ */

/**
* Short description for file.
*
Expand All @@ -9,20 +7,17 @@
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
* @package cake
* @subpackage cake.cake.libs.controller.components
* @since CakePHP(tm) v 1.2.0.4213
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/

Expand Down Expand Up @@ -276,6 +271,14 @@ function read($key = null) {
}
}

/**
* @deprecated use delete()
**/
function del($key) {
trigger_error('Deprecated method, use CookieComponent::delete instead', E_USER_WARNING);
return $this->delete($key);
}

/**
* Delete a cookie value
*
Expand All @@ -289,7 +292,7 @@ function read($key = null) {
* @return void
* @access public
*/
function del($key) {
function delete($key) {
if (empty($this->__values)) {
$this->read();
}
Expand Down
30 changes: 9 additions & 21 deletions cake/libs/controller/components/session.php
@@ -1,28 +1,21 @@
<?php
/* SVN FILE: $Id$ */

/**
* Short description for file.
*
* Long description for file
* SessionComponent. Provides access to Sessions from the Controller layer
*
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
* @package cake
* @subpackage cake.cake.libs.controller.components
* @since CakePHP(tm) v 0.10.0.1232
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
if (!class_exists('cakesession')) {
Expand Down Expand Up @@ -167,15 +160,10 @@ function read($name = null) {
}

/**
* Used to delete a session variable.
*
* In your controller: $this->Session->del('Controller.sessKey');
*
* @param string $name the name of the session key you want to delete
* @return boolean true is session variable is set and can be deleted, false is variable was not set.
* @access public
* @deprecated use delete
*/
function del($name) {
trigger_error('Deprecated method, use SessionComponent::delete instead', E_USER_WARNING);
if ($this->__active === true) {
$this->__start();
return parent::del($name);
Expand All @@ -195,7 +183,7 @@ function del($name) {
function delete($name) {
if ($this->__active === true) {
$this->__start();
return $this->del($name);
return parent::del($name);
}
return false;
}
Expand Down Expand Up @@ -241,15 +229,15 @@ function error() {
* Additional params below can be passed to customize the output, or the Message.[key]
*
* @param string $message Message to be flashed
* @param string $layout Layout to wrap flash message in
* @param string $element Element to wrap flash message in.
* @param array $params Parameters to be sent to layout as view variables
* @param string $key Message key, default is 'flash'
* @access public
*/
function setFlash($message, $layout = 'default', $params = array(), $key = 'flash') {
function setFlash($message, $element = 'default', $params = array(), $key = 'flash') {
if ($this->__active === true) {
$this->__start();
$this->write('Message.' . $key, compact('message', 'layout', 'params'));
$this->write('Message.' . $key, compact('message', 'element', 'params'));
}
}

Expand Down
86 changes: 38 additions & 48 deletions cake/libs/controller/scaffold.php
Expand Up @@ -197,10 +197,10 @@ function __construct(&$controller, $params) {
if ($this->controller->view && $this->controller->view !== 'Theme') {
$this->controller->view = 'scaffold';
}
$this->__scaffold($params);
$this->_validSession = (
isset($this->controller->Session) && $this->controller->Session->valid() != false
);
$this->__scaffold($params);
}

/**
Expand All @@ -223,20 +223,15 @@ function _output() {
*/
function __scaffoldView($params) {
if ($this->controller->_beforeScaffold('view')) {


$message = sprintf(__("No id set for %s::view()", true), Inflector::humanize($this->modelKey));
if (isset($params['pass'][0])) {
$this->ScaffoldModel->id = $params['pass'][0];
} elseif ($this->_validSession) {
$this->controller->Session->setFlash(sprintf(
__("No id set for %s::view()", true),
Inflector::humanize($this->modelKey
)));
$this->controller->Session->setFlash($message);
$this->controller->redirect($this->redirect);
} else {
return $this->controller->flash(sprintf(
__("No id set for %s::view()", true), Inflector::humanize($this->modelKey)),
'/' . Inflector::underscore($this->controller->viewPath
));
return $this->controller->flash($message, '/' . Inflector::underscore($this->controller->viewPath));
}
$this->ScaffoldModel->recursive = 1;
$this->controller->data = $this->ScaffoldModel->read();
Expand Down Expand Up @@ -278,6 +273,10 @@ function __scaffoldIndex($params) {
* @access private
*/
function __scaffoldForm($action = 'edit') {
$this->controller->viewVars['scaffoldFields'] = array_merge(
$this->controller->viewVars['scaffoldFields'],
array_keys($this->ScaffoldModel->hasAndBelongsToMany)
);
$this->controller->render($action, $this->layout);
$this->_output();
}
Expand Down Expand Up @@ -305,17 +304,13 @@ function __scaffoldSave($params = array(), $action = 'edit') {
}

if (!$this->ScaffoldModel->exists()) {
$message = sprintf(__("Invalid id for %s::edit()", true), Inflector::humanize($this->modelKey));
if ($this->_validSession) {
$this->controller->Session->setFlash(sprintf(
__("Invalid id for %s::edit()", true),
Inflector::humanize($this->modelKey)
));
$this->controller->Session->setFlash($message);
$this->controller->redirect($this->redirect);
} else {
return $this->controller->flash(sprintf(
__("Invalid id for %s::edit()", true),
Inflector::humanize($this->modelKey)
), $this->redirect);
$this->controller->flash($message, $this->redirect);
$this->_output();
}
}
}
Expand All @@ -327,17 +322,16 @@ function __scaffoldSave($params = array(), $action = 'edit') {

if ($this->ScaffoldModel->save($this->controller->data)) {
if ($this->controller->_afterScaffoldSave($action)) {
$message = sprintf(__('The %1$s has been %2$s', true),
Inflector::humanize($this->modelKey),
$success
);
if ($this->_validSession) {
$this->controller->Session->setFlash(sprintf(
__('The %1$s has been %2$s', true),
Inflector::humanize($this->modelClass), $success
));
$this->controller->Session->setFlash($message);
$this->controller->redirect($this->redirect);
} else {
return $this->controller->flash(sprintf(
__('The %1$s has been %2$s', true),
Inflector::humanize($this->modelClass), $success
), $this->redirect);
$this->controller->flash($message, $this->redirect);
return $this->_output();
}
} else {
return $this->controller->_afterScaffoldSaveError($action);
Expand Down Expand Up @@ -385,44 +379,40 @@ function __scaffoldSave($params = array(), $action = 'edit') {
*/
function __scaffoldDelete($params = array()) {
if ($this->controller->_beforeScaffold('delete')) {
$message = sprintf(__("No id set for %s::delete()", true), Inflector::humanize($this->modelKey));
if (isset($params['pass'][0])) {
$id = $params['pass'][0];
} elseif ($this->_validSession) {
$this->controller->Session->setFlash(sprintf(
__("No id set for %s::delete()", true), Inflector::humanize($this->modelKey)
));
$this->controller->Session->setFlash($message);
$this->controller->redirect($this->redirect);
} else {
return $this->controller->flash(sprintf(
__("No id set for %s::delete()", true), Inflector::humanize($this->modelKey)
), '/' . Inflector::underscore($this->controller->viewPath));
$this->controller->flash($message, '/' . Inflector::underscore($this->controller->viewPath));
return $this->_output();
}

if ($this->ScaffoldModel->delete($id)) {
$message = sprintf(
__('The %1$s with id: %2$d has been deleted.', true),
Inflector::humanize($this->modelClass), $id
);
if ($this->_validSession) {
$this->controller->Session->setFlash(sprintf(
__('The %1$s with id: %2$d has been deleted.', true),
Inflector::humanize($this->modelClass), $id
));
$this->controller->Session->setFlash($message);
$this->controller->redirect($this->redirect);
} else {
return $this->controller->flash(sprintf(
__('The %1$s with id: %2$d has been deleted.', true),
Inflector::humanize($this->modelClass), $id
), '/' . $this->viewPath);
$this->controller->flash($message, '/' . $this->viewPath);
return $this->_output();
}
} else {
$message = sprintf(
__('There was an error deleting the %1$s with id: %2$d', true),
Inflector::humanize($this->modelClass), $id
);
if ($this->_validSession) {
$this->controller->Session->setFlash(sprintf(
__('There was an error deleting the %1$s with id: %2$d', true),
Inflector::humanize($this->modelClass), $id
));
$this->controller->Session->setFlash($message);
$this->controller->redirect($this->redirect);
} else {
return $this->controller->flash(sprintf(
__('There was an error deleting the %1$s with id: %2$d', true),
Inflector::humanize($this->modelClass), $id
), '/' . $this->viewPath);
$this->controller->flash($message, '/' . $this->viewPath);
return $this->_output();
}
}
} elseif ($this->controller->_scaffoldError('delete') === false) {
Expand Down
21 changes: 13 additions & 8 deletions cake/libs/folder.php
@@ -1,26 +1,21 @@
<?php
/* SVN FILE: $Id$ */

/**
* Convenience class for handling directories.
*
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
* @package cake
* @subpackage cake.cake.libs
* @since CakePHP(tm) v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/

Expand Down Expand Up @@ -627,7 +622,7 @@ function copy($options = array()) {
}

if (!is_dir($toDir)) {
$this->mkdir($toDir, $mode);
$this->create($toDir, $mode);
}

if (!is_writable($toDir)) {
Expand Down Expand Up @@ -725,49 +720,59 @@ function errors() {
* nix flavored alias
*
* @see read
* @deprecated use read
* @access public
*/
function ls($sort = true, $exceptions = false) {
trigger_error('Deprecated method, use Folder::read instead', E_USER_WARNING);
return $this->read($sort, $exceptions);
}

/**
* nix flavored alias
*
* @see create
* @deprecated use create
* @access public
*/
function mkdir($pathname, $mode = 0755) {
trigger_error('Deprecated method, use Folder::create instead', E_USER_WARNING);
return $this->create($pathname, $mode);
}

/**
* nix flavored alias
*
* @see copy
* @deprecated use copy
* @access public
*/
function cp($options) {
trigger_error('Deprecated method, use Folder::copy instead', E_USER_WARNING);
return $this->copy($options);
}

/**
* nix flavored alias
*
* @see move
* @deprecated use move
* @access public
*/
function mv($options) {
trigger_error('Deprecated method, use Folder::move instead', E_USER_WARNING);
return $this->move($options);
}

/**
* nix flavored alias
*
* @see delete
* @deprecated use delete
* @access public
*/
function rm($path) {
trigger_error('Deprecated method, use Folder::delete instead', E_USER_WARNING);
return $this->delete($path);
}

Expand Down

0 comments on commit 0614580

Please sign in to comment.