Merge branch 'master' into 2.4

This commit is contained in:
mark_story 2013-08-23 12:56:43 -04:00
commit 53d265cfba
20 changed files with 289 additions and 102 deletions

View file

@ -109,6 +109,9 @@ p {
padding: 6px 10px;
text-align: right;
}
#header a, #footer a {
color: #fff;
}
/** containers **/
div.form,

View file

@ -1,7 +1,5 @@
<?php
/**
* Default routes that CakePHP provides as catch all routes.
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
@ -26,7 +24,6 @@
* created when your application has one or more plugins.
*
* - `/:prefix/:plugin` a plugin shortcut route.
* - `/:prefix/:plugin/:action/*` a plugin shortcut route.
* - `/:prefix/:plugin/:controller`
* - `/:prefix/:plugin/:controller/:action/*`
* - `/:prefix/:controller`
@ -35,7 +32,6 @@
* If plugins are found in your application the following routes are created:
*
* - `/:plugin` a plugin shortcut route.
* - `/:plugin/:action/*` a plugin shortcut route.
* - `/:plugin/:controller`
* - `/:plugin/:controller/:action/*`
*

View file

@ -55,15 +55,14 @@
$this-><?php echo $currentModelName; ?>->create();
if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) {
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved'));
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
<?php else: ?>
return $this->flash(__('<?php echo ucfirst(strtolower($currentModelName)); ?> saved.'), array('action' => 'index'));
return $this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'), array('action' => 'index'));
<?php endif; ?>
}
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
<?php endif; ?>
}
<?php
foreach (array('belongsTo', 'hasAndBelongsToMany') as $assoc):
@ -97,15 +96,14 @@
if ($this->request->is('post') || $this->request->is('put')) {
if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) {
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved'));
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
<?php else: ?>
return $this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'), array('action' => 'index'));
<?php endif; ?>
}
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
<?php endif; ?>
} else {
$options = array('conditions' => array('<?php echo $currentModelName; ?>.' . $this-><?php echo $currentModelName; ?>->primaryKey => $id));
$this->request->data = $this-><?php echo $currentModelName; ?>->find('first', $options);
@ -142,16 +140,15 @@
$this->request->onlyAllow('post', 'delete');
if ($this-><?php echo $currentModelName; ?>->delete()) {
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'));
return $this->redirect(array('action' => 'index'));
<?php else: ?>
return $this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'), array('action' => 'index'));
<?php endif; ?>
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been deleted.'));
} else {
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be deleted. Please, try again.'));
}
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> was not deleted'));
<?php else: ?>
return $this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> was not deleted'), array('action' => 'index'));
<?php endif; ?>
return $this->redirect(array('action' => 'index'));
<?php else: ?>
return $this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been deleted.'), array('action' => 'index'));
} else {
return $this->flash(__('The <?php echo strtolower($singularHumanName); ?> could not be deleted. Please, try again.'), array('action' => 'index'));
}
<?php endif; ?>
}

View file

@ -76,7 +76,7 @@ class <?php echo $controllerName; ?>Controller extends <?php echo $plugin; ?>App
echo ");\n\n";
endif;
echo trim($actions) . "\n";
echo trim($actions);
endif; ?>
}

View file

@ -13,7 +13,6 @@
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.webroot.css
* @since CakePHP(tm)
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
@ -110,6 +109,9 @@ p {
padding: 6px 10px;
text-align: right;
}
#header a, #footer a {
color: #fff;
}
/** containers **/
div.form,

View file

@ -554,7 +554,6 @@ class CakeSession {
'session.serialize_handler' => 'php',
'session.use_cookies' => 1,
'session.cookie_path' => self::$path,
'session.auto_start' => 0,
'session.save_path' => TMP . 'sessions',
'session.save_handler' => 'files'
)
@ -565,7 +564,6 @@ class CakeSession {
'ini' => array(
'session.use_trans_sid' => 0,
'url_rewriter.tags' => '',
'session.auto_start' => 0,
'session.use_cookies' => 1,
'session.cookie_path' => self::$path,
'session.save_handler' => 'user',
@ -581,7 +579,6 @@ class CakeSession {
'ini' => array(
'session.use_trans_sid' => 0,
'url_rewriter.tags' => '',
'session.auto_start' => 0,
'session.use_cookies' => 1,
'session.cookie_path' => self::$path,
'session.save_handler' => 'user',

View file

@ -282,29 +282,17 @@ class ControllerTaskTest extends CakeTestCase {
$components = array('Acl', 'Auth');
$this->Task->expects($this->any())->method('createFile')->will($this->returnValue(true));
$result = $this->Task->bake('Articles', '--actions--', $helpers, $components);
$this->assertContains(' * @property Article $Article', $result);
$this->assertContains(' * @property AclComponent $Acl', $result);
$this->assertContains(' * @property AuthComponent $Auth', $result);
$this->assertContains(' * @property PaginatorComponent $Paginator', $result);
$this->assertContains('class ArticlesController extends AppController', $result);
$this->assertContains("public \$components = array('Acl', 'Auth', 'Paginator')", $result);
$this->assertContains("public \$helpers = array('Js', 'Time')", $result);
$this->assertContains("--actions--", $result);
$result = $this->Task->bake('Articles', null, $helpers, $components);
$expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'Controller' . DS . 'NoActions.ctp');
$this->assertTextEquals($expected, $result);
$result = $this->Task->bake('Articles', null, array(), array());
$expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'Controller' . DS . 'NoHelpersOrComponents.ctp');
$this->assertTextEquals($expected, $result);
$result = $this->Task->bake('Articles', 'scaffold', $helpers, $components);
$this->assertContains("class ArticlesController extends AppController", $result);
$this->assertContains("public \$scaffold", $result);
$this->assertNotContains('@property', $result);
$this->assertNotContains('helpers', $result);
$this->assertNotContains('components', $result);
$result = $this->Task->bake('Articles', '--actions--', array(), array());
$this->assertContains('class ArticlesController extends AppController', $result);
$this->assertSame(substr_count($result, '@property'), 2);
$this->assertContains("public \$components = array('Paginator')", $result);
$this->assertNotContains('helpers', $result);
$this->assertContains('--actions--', $result);
$expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'Controller' . DS . 'Scaffold.ctp');
$this->assertTextEquals($expected, $result);
}
/**
@ -348,30 +336,10 @@ class ControllerTaskTest extends CakeTestCase {
*/
public function testBakeActionsUsingSessions() {
$result = $this->Task->bakeActions('BakeArticles', null, true);
$this->assertContains('function index() {', $result);
$this->assertContains('$this->BakeArticle->recursive = 0;', $result);
$this->assertContains("\$this->set('bakeArticles', \$this->Paginator->paginate());", $result);
$this->assertContains('function view($id = null)', $result);
$this->assertContains("throw new NotFoundException(__('Invalid bake article'));", $result);
$this->assertContains("\$options = array('conditions' => array('BakeArticle.' . \$this->BakeArticle->primaryKey => \$id));", $result);
$this->assertContains("\$this->set('bakeArticle', \$this->BakeArticle->find('first', \$options));", $result);
$this->assertContains('function add()', $result);
$this->assertContains("if (\$this->request->is('post'))", $result);
$this->assertContains('if ($this->BakeArticle->save($this->request->data))', $result);
$this->assertContains("\$this->Session->setFlash(__('The bake article has been saved'));", $result);
$this->assertContains('function edit($id = null)', $result);
$this->assertContains("\$this->Session->setFlash(__('The bake article could not be saved. Please, try again.'));", $result);
$this->assertContains('function delete($id = null)', $result);
$this->assertContains('if ($this->BakeArticle->delete())', $result);
$this->assertContains("\$this->Session->setFlash(__('Bake article deleted'));", $result);
$expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'Controller' . DS . 'ActionsUsingSessions.ctp');
$this->assertTextEquals($expected, $result);
$result = $this->Task->bakeActions('BakeArticles', 'admin_', true);
$this->assertContains('function admin_index() {', $result);
$this->assertContains('function admin_add()', $result);
$this->assertContains('function admin_view($id = null)', $result);
@ -386,29 +354,8 @@ class ControllerTaskTest extends CakeTestCase {
*/
public function testBakeActionsWithNoSessions() {
$result = $this->Task->bakeActions('BakeArticles', null, false);
$this->assertContains('function index() {', $result);
$this->assertContains('$this->BakeArticle->recursive = 0;', $result);
$this->assertContains("\$this->set('bakeArticles', \$this->Paginator->paginate());", $result);
$this->assertContains('function view($id = null)', $result);
$this->assertContains("throw new NotFoundException(__('Invalid bake article'));", $result);
$this->assertContains("\$this->set('bakeArticle', \$this->BakeArticle->find('first', \$options));", $result);
$this->assertContains('function add()', $result);
$this->assertContains("if (\$this->request->is('post'))", $result);
$this->assertContains('if ($this->BakeArticle->save($this->request->data))', $result);
$this->assertContains("\$this->flash(__('The bake article has been saved.'), array('action' => 'index'))", $result);
$this->assertContains('function edit($id = null)', $result);
$this->assertContains("\$this->BakeArticle->BakeTag->find('list')", $result);
$this->assertContains("\$this->set(compact('bakeTags'))", $result);
$this->assertContains('function delete($id = null)', $result);
$this->assertContains("\$this->request->onlyAllow('post', 'delete')", $result);
$this->assertContains('if ($this->BakeArticle->delete())', $result);
$this->assertContains("\$this->flash(__('Bake article deleted'), array('action' => 'index'))", $result);
$expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'Controller' . DS . 'ActionsWithNoSessions.ctp');
$this->assertTextEquals($expected, $result);
}
/**

View file

@ -193,7 +193,6 @@ class SomethingWithEmailComponent extends Component {
public $components = array('Email');
}
/**
* ComponentTest class
*

View file

@ -119,7 +119,6 @@ class MergePostsController extends MergeVarPluginAppController {
public $uses = array();
}
/**
* Test Case for Controller Merging of Vars.
*

View file

@ -50,7 +50,6 @@ class ControllerTestAppController extends Controller {
public $components = array('Cookie');
}
/**
* ControllerPost class
*

View file

@ -131,7 +131,6 @@ class MyCustomExceptionRenderer extends ExceptionRenderer {
class MissingWidgetThingException extends NotFoundException {
}
/**
* ExceptionRendererTest class
*

View file

@ -2517,7 +2517,6 @@ class MyCategoriesMyProduct extends CakeTestModel {
public $name = 'MyCategoriesMyProduct';
}
/**
* NumberTree class
*

View file

@ -111,7 +111,6 @@ class StringsTestFixture extends CakeTestFixture {
);
}
/**
* CakeTestFixtureImportFixture class
*
@ -175,7 +174,6 @@ class FixturePrefixTest extends Model {
public $useDbConfig = 'test';
}
/**
* Test case for CakeTestFixture
*

View file

@ -7078,6 +7078,23 @@ class FormHelperTest extends CakeTestCase {
'Delete',
'/a'
));
$result = $this->Form->postLink(
'',
array('controller' => 'items', 'action' => 'delete', 10),
array('class' => 'btn btn-danger', 'escape' => false),
'Confirm thing'
);
$this->assertTags($result, array(
'form' => array(
'method' => 'post', 'action' => '/items/delete/10',
'name' => 'preg:/post_\w+/', 'id' => 'preg:/post_\w+/', 'style' => 'display:none;'
),
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
'/form',
'a' => array('class' => 'btn btn-danger', 'href' => '#', 'onclick' => 'preg:/if \(confirm\(\'Confirm thing\'\)\) \{ document\.post_\w+\.submit\(\); \} event\.returnValue = false; return false;/'),
'/a'
));
}
/**

View file

@ -219,7 +219,6 @@ class TestAfterHelper extends Helper {
}
/**
* ViewTest class
*

View file

@ -0,0 +1,91 @@
/**
* index method
*
* @return void
*/
public function index() {
$this->BakeArticle->recursive = 0;
$this->set('bakeArticles', $this->Paginator->paginate());
}
/**
* view method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function view($id = null) {
if (!$this->BakeArticle->exists($id)) {
throw new NotFoundException(__('Invalid bake article'));
}
$options = array('conditions' => array('BakeArticle.' . $this->BakeArticle->primaryKey => $id));
$this->set('bakeArticle', $this->BakeArticle->find('first', $options));
}
/**
* add method
*
* @return void
*/
public function add() {
if ($this->request->is('post')) {
$this->BakeArticle->create();
if ($this->BakeArticle->save($this->request->data)) {
$this->Session->setFlash(__('The bake article has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The bake article could not be saved. Please, try again.'));
}
}
$bakeTags = $this->BakeArticle->BakeTag->find('list');
$this->set(compact('bakeTags'));
}
/**
* edit method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function edit($id = null) {
if (!$this->BakeArticle->exists($id)) {
throw new NotFoundException(__('Invalid bake article'));
}
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->BakeArticle->save($this->request->data)) {
$this->Session->setFlash(__('The bake article has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The bake article could not be saved. Please, try again.'));
}
} else {
$options = array('conditions' => array('BakeArticle.' . $this->BakeArticle->primaryKey => $id));
$this->request->data = $this->BakeArticle->find('first', $options);
}
$bakeTags = $this->BakeArticle->BakeTag->find('list');
$this->set(compact('bakeTags'));
}
/**
* delete method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function delete($id = null) {
$this->BakeArticle->id = $id;
if (!$this->BakeArticle->exists()) {
throw new NotFoundException(__('Invalid bake article'));
}
$this->request->onlyAllow('post', 'delete');
if ($this->BakeArticle->delete()) {
$this->Session->setFlash(__('The bake article has been deleted.'));
} else {
$this->Session->setFlash(__('The bake article could not be deleted. Please, try again.'));
}
return $this->redirect(array('action' => 'index'));
}

View file

@ -0,0 +1,84 @@
/**
* index method
*
* @return void
*/
public function index() {
$this->BakeArticle->recursive = 0;
$this->set('bakeArticles', $this->Paginator->paginate());
}
/**
* view method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function view($id = null) {
if (!$this->BakeArticle->exists($id)) {
throw new NotFoundException(__('Invalid bake article'));
}
$options = array('conditions' => array('BakeArticle.' . $this->BakeArticle->primaryKey => $id));
$this->set('bakeArticle', $this->BakeArticle->find('first', $options));
}
/**
* add method
*
* @return void
*/
public function add() {
if ($this->request->is('post')) {
$this->BakeArticle->create();
if ($this->BakeArticle->save($this->request->data)) {
return $this->flash(__('The bake article has been saved.'), array('action' => 'index'));
}
}
$bakeTags = $this->BakeArticle->BakeTag->find('list');
$this->set(compact('bakeTags'));
}
/**
* edit method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function edit($id = null) {
if (!$this->BakeArticle->exists($id)) {
throw new NotFoundException(__('Invalid bake article'));
}
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->BakeArticle->save($this->request->data)) {
return $this->flash(__('The bake article has been saved.'), array('action' => 'index'));
}
} else {
$options = array('conditions' => array('BakeArticle.' . $this->BakeArticle->primaryKey => $id));
$this->request->data = $this->BakeArticle->find('first', $options);
}
$bakeTags = $this->BakeArticle->BakeTag->find('list');
$this->set(compact('bakeTags'));
}
/**
* delete method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function delete($id = null) {
$this->BakeArticle->id = $id;
if (!$this->BakeArticle->exists()) {
throw new NotFoundException(__('Invalid bake article'));
}
$this->request->onlyAllow('post', 'delete');
if ($this->BakeArticle->delete()) {
return $this->flash(__('The bake article has been deleted.'), array('action' => 'index'));
} else {
return $this->flash(__('The bake article could not be deleted. Please, try again.'), array('action' => 'index'));
}
}

View file

@ -0,0 +1,27 @@
<?php
App::uses('AppController', 'Controller');
/**
* Articles Controller
*
* @property Article $Article
* @property AclComponent $Acl
* @property AuthComponent $Auth
* @property PaginatorComponent $Paginator
*/
class ArticlesController extends AppController {
/**
* Helpers
*
* @var array
*/
public $helpers = array('Js', 'Time');
/**
* Components
*
* @var array
*/
public $components = array('Acl', 'Auth', 'Paginator');
}

View file

@ -0,0 +1,18 @@
<?php
App::uses('AppController', 'Controller');
/**
* Articles Controller
*
* @property Article $Article
* @property PaginatorComponent $Paginator
*/
class ArticlesController extends AppController {
/**
* Components
*
* @var array
*/
public $components = array('Paginator');
}

View file

@ -0,0 +1,16 @@
<?php
App::uses('AppController', 'Controller');
/**
* Articles Controller
*
*/
class ArticlesController extends AppController {
/**
* Scaffold
*
* @var mixed
*/
public $scaffold;
}