fix renderLayout and update deprecated and outdated code

This commit is contained in:
euromark 2013-09-13 00:09:31 +02:00
parent a980fd92b9
commit a796b26f13
35 changed files with 42 additions and 59 deletions

View file

@ -93,7 +93,7 @@
if (!$this-><?php echo $currentModelName; ?>->exists($id)) {
throw new NotFoundException(__('Invalid <?php echo strtolower($singularHumanName); ?>'));
}
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->request->is(array('post', 'put'))) {
if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) {
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'));

View file

@ -226,7 +226,7 @@ class SecurityComponent extends Component {
$this->_secureRequired($controller);
$this->_authRequired($controller);
$isPost = ($this->request->is('post') || $this->request->is('put'));
$isPost = $this->request->is(array('post', 'put'));
$isNotRequestAction = (
!isset($controller->request->params['requested']) ||
$controller->request->params['requested'] != 1

View file

@ -1188,7 +1188,7 @@ class SecurityComponentTest extends CakeTestCase {
$this->Controller->request = $this->getMock('CakeRequest', array('is'));
$this->Controller->request->expects($this->once())->method('is')
->with('post')
->with(array('post', 'put'))
->will($this->returnValue(true));
$this->Controller->request->params['action'] = 'index';
@ -1240,7 +1240,7 @@ class SecurityComponentTest extends CakeTestCase {
$this->Controller->request = $this->getMock('CakeRequest', array('is'));
$this->Controller->request->expects($this->once())->method('is')
->with('post')
->with(array('post', 'put'))
->will($this->returnValue(true));
$this->Controller->request->params['action'] = 'index';
@ -1270,7 +1270,7 @@ class SecurityComponentTest extends CakeTestCase {
$this->Controller->request = $this->getMock('CakeRequest', array('is'));
$this->Controller->request->expects($this->once())->method('is')
->with('post')
->with(array('post', 'put'))
->will($this->returnValue(true));
$this->Controller->request->params['action'] = 'index';
@ -1326,7 +1326,7 @@ class SecurityComponentTest extends CakeTestCase {
$this->Controller->request = $this->getMock('CakeRequest', array('is'));
$this->Controller->request->expects($this->once())->method('is')
->with('post')
->with(array('post', 'put'))
->will($this->returnValue(true));
$this->Controller->request->params['action'] = 'index';

View file

@ -184,11 +184,11 @@ class TestView extends View {
}
/**
* TestAfterHelper class
* TestBeforeAfterHelper class
*
* @package Cake.Test.Case.View
*/
class TestAfterHelper extends Helper {
class TestBeforeAfterHelper extends Helper {
/**
* property property
@ -949,10 +949,10 @@ class ViewTest extends CakeTestCase {
* @return void
*/
public function testBeforeLayout() {
$this->PostsController->helpers = array('Session', 'TestAfter', 'Html');
$this->PostsController->helpers = array('Session', 'TestBeforeAfter', 'Html');
$View = new View($this->PostsController);
$View->render('index');
$this->assertEquals('Valuation', $View->Helpers->TestAfter->property);
$this->assertEquals('Valuation', $View->Helpers->TestBeforeAfter->property);
}
/**
@ -961,7 +961,7 @@ class ViewTest extends CakeTestCase {
* @return void
*/
public function testAfterLayout() {
$this->PostsController->helpers = array('Session', 'TestAfter', 'Html');
$this->PostsController->helpers = array('Session', 'TestBeforeAfter', 'Html');
$this->PostsController->set('variable', 'values');
$View = new View($this->PostsController);

View file

@ -54,7 +54,7 @@
if (!$this->BakeArticle->exists($id)) {
throw new NotFoundException(__('Invalid bake article'));
}
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->request->is(array('post', 'put'))) {
if ($this->BakeArticle->save($this->request->data)) {
$this->Session->setFlash(__('The bake article has been saved.'));
return $this->redirect(array('action' => 'index'));

View file

@ -51,7 +51,7 @@
if (!$this->BakeArticle->exists($id)) {
throw new NotFoundException(__('Invalid bake article'));
}
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->request->is(array('post', 'put'))) {
if ($this->BakeArticle->save($this->request->data)) {
return $this->flash(__('The bake article has been saved.'), array('action' => 'index'));
}

View file

@ -25,8 +25,6 @@
*/
class TestsAppsController extends AppController {
public $name = 'TestsApps';
public $uses = array();
public $components = array('RequestHandler');

View file

@ -25,8 +25,6 @@
*/
class TestsAppsPostsController extends AppController {
public $name = 'TestsAppsPosts';
public $uses = array('Post');
public $viewPath = 'TestsApps';

View file

@ -34,11 +34,4 @@ class Comment extends AppModel {
*/
public $useTable = 'comments';
/**
* Model name
*
* @var string
*/
public $name = 'Comment';
}

View file

@ -29,8 +29,6 @@ class PersisterOne extends AppModel {
public $useTable = 'posts';
public $name = 'PersisterOne';
public $actsAs = array('PersisterOneBehavior', 'TestPlugin.TestPluginPersisterOne');
public $hasMany = array('Comment', 'TestPlugin.TestPluginComment');

View file

@ -29,8 +29,6 @@ class PersisterTwo extends AppModel {
public $useTable = 'posts';
public $name = 'PersisterTwo';
public $actsAs = array('PersisterOneBehavior', 'TestPlugin.TestPluginPersisterOne');
public $hasMany = array('Comment', 'TestPlugin.TestPluginComment');

View file

@ -29,6 +29,4 @@ class Post extends AppModel {
public $useTable = 'posts';
public $name = 'Post';
}

View file

@ -23,5 +23,5 @@
*
* @package Cake.Test.TestApp.Plugin.TestPlugin.Controller.Component
*/
class OtherComponent extends Object {
class OtherComponent extends Component {
}

View file

@ -19,12 +19,12 @@
*/
/**
* Class TestPluginComponentComponent
* Class TestPluginComponent
*
* @package Cake.Test.TestApp.Plugin.TestPlugin.Controller.Component
*/
class TestPluginComponentComponent extends Object {
class TestPluginComponent extends Component {
public $components = array('TestPlugin.TestPluginOtherComponent');
public $components = array('TestPlugin.TestPluginOther');
}

View file

@ -19,9 +19,9 @@
*/
/**
* Class TestPluginOtherComponentComponent
* Class TestPluginOtherComponent
*
* @package Cake.Test.TestApp.Plugin.TestPlugin.Controller.Component
*/
class TestPluginOtherComponentComponent extends Object {
class TestPluginOtherComponent extends Component {
}

View file

@ -25,8 +25,6 @@
*/
class TestsController extends TestPluginAppController {
public $name = 'Tests';
public $uses = array();
public $helpers = array('TestPlugin.OtherHelper', 'Html');

View file

@ -1 +1 @@
<?php __('This is a translatable string'); ?>
<?php echo __('This is a translatable string'); ?>

View file

@ -1,4 +1,4 @@
<?php echo $content_for_layout; ?>
<?php echo $this->fetch('content'); ?>
This email was sent using the TestPlugin.

View file

@ -6,7 +6,7 @@
</head>
<body>
<?php echo $content_for_layout; ?>
<?php echo $this->fetch('content'); ?>
<p>This email was sent using the <a href="http://cakephp.org">CakePHP Framework</a></p>
</body>

View file

@ -6,7 +6,7 @@
</head>
<body>
<?php echo $content_for_layout; ?>
<?php echo $this->fetch('content'); ?>
<p>このメールは <a href="http://cakephp.org">CakePHP Framework</a> を利用して送信しました。</p>
</body>

View file

@ -6,7 +6,7 @@
</head>
<body>
<?php echo $content_for_layout; ?>
<?php echo $this->fetch('content'); ?>
<p>This email was sent using the CakePHP Framework</p>
</body>

View file

@ -1,4 +1,4 @@
<?php echo $content_for_layout; ?>
<?php echo $this->fetch('content'); ?>
This email was sent using the CakePHP Framework, http://cakephp.org.

View file

@ -1,4 +1,4 @@
<?php echo $content_for_layout; ?>
<?php echo $this->fetch('content'); ?>
CakePHP Framework を使って送信したメールです。 http://cakephp.org.

View file

@ -1 +1 @@
<?php echo $content_for_layout; ?>
<?php echo $this->fetch('content'); ?>

View file

@ -1,2 +1,2 @@
Ajax!
<?php echo $content_for_layout; ?>
<?php echo $this->fetch('content'); ?>

View file

@ -7,7 +7,7 @@
<body>
<!--nocache--><?php $x++; ?><!--/nocache-->
<!--nocache--><?php $x++; ?><!--/nocache-->
<?php echo $content_for_layout; ?>
<?php echo $this->fetch('content'); ?>
<!--nocache--><?php echo 'cached count is: ' . $x; ?><!--/nocache-->
</body>
</html>

View file

@ -3,7 +3,7 @@
<?php echo microtime(); ?>
<!--/nocache-->
<?php echo $content_for_layout; ?>
<?php echo $this->fetch('content'); ?>
<?php echo $superman; ?>

View file

@ -27,7 +27,7 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework
</div>
<div id="content">
<?php echo $content_for_layout; ?>
<?php echo $this->fetch('content'); ?>
</div>
<div id="footer">

View file

@ -1,2 +1,2 @@
<?php echo $scripts_for_layout; ?>
<script type="text/javascript"><?php echo $content_for_layout; ?></script>
<script type="text/javascript"><?php echo $this->fetch('content'); ?></script>

View file

@ -1 +1 @@
<?php echo $content_for_layout; ?>
<?php echo $this->fetch('content'); ?>

View file

@ -8,7 +8,7 @@
<p>C. Layout After Test Element But Before Content</p>
<?php $this->log('3. layout after test element but before content') ?>
<!--/nocache-->
<?php echo $content_for_layout; ?>
<?php echo $this->fetch('content'); ?>
<!--nocache-->
<p>E. Layout After Content</p>
<?php $this->log('5. layout after content') ?>

View file

@ -1,5 +1,5 @@
<?php
echo $rss->header();
echo $this->Rss->header();
if (!isset($channel)) {
$channel = array();
@ -8,9 +8,9 @@ if (!isset($channel['title'])) {
$channel['title'] = $title_for_layout;
}
echo $rss->document(
$rss->channel(
array(), $channel, $content_for_layout
echo $this->Rss->document(
$this->Rss->channel(
array(), $channel, $this->fetch('content')
)
);

View file

@ -1,2 +1,2 @@
<?php echo '<?xml version="1.0" encoding="' . Configure::read('App.encoding') . '"?>'; ?>
<?php echo $content_for_layout; ?>
<?php echo $this->fetch('content'); ?>

View file

@ -1,2 +1,2 @@
default test_theme layout
<?php echo $content_for_layout ?>
<?php echo $this->fetch('content') ?>

View file

@ -504,6 +504,8 @@ class View extends Object {
if (empty($content)) {
$content = $this->Blocks->get('content');
} else {
$this->Blocks->set('content', $content);
}
$this->getEventManager()->dispatch(new CakeEvent('View.beforeLayout', $this, array($layoutFileName)));