mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fixing regression cased by commit d5ffdc288d
causing ajax layout to be not auto set for ajax request for html pages. Refs #1099
This commit is contained in:
parent
b648b61422
commit
b9a7b27ba1
2 changed files with 30 additions and 7 deletions
|
@ -230,15 +230,17 @@ class RequestHandlerComponent extends Object {
|
|||
|
||||
$this->__initializeTypes();
|
||||
$controller->params['isAjax'] = $this->isAjax();
|
||||
$isRecognized = (
|
||||
!in_array($this->ext, array('html', 'htm')) &&
|
||||
in_array($this->ext, array_keys($this->__requestContent))
|
||||
);
|
||||
|
||||
if (!empty($this->ext)) {
|
||||
if (in_array($this->ext, array('html', 'htm'))) {
|
||||
$this->respondAs('html', array('charset' => Configure::read('App.encoding')));
|
||||
} elseif (in_array($this->ext, array_keys($this->__requestContent))) {
|
||||
if (!empty($this->ext) && $isRecognized) {
|
||||
$this->renderAs($controller, $this->ext);
|
||||
}
|
||||
} elseif ($this->isAjax()) {
|
||||
$this->renderAs($controller, 'ajax');
|
||||
} elseif (empty($this->ext) || in_array($this->ext, array('html', 'htm'))) {
|
||||
$this->respondAs('html', array('charset' => Configure::read('App.encoding')));
|
||||
}
|
||||
|
||||
if ($this->requestedWith('xml')) {
|
||||
|
|
|
@ -253,6 +253,27 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
|||
$this->assertEqual($this->Controller->ext, '.ctp');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testAutoAjaxLayout method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testAutoAjaxLayout() {
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
|
||||
$this->RequestHandler->startup($this->Controller);
|
||||
$this->assertTrue($this->Controller->layout, $this->RequestHandler->ajaxLayout);
|
||||
|
||||
$this->_init();
|
||||
$this->Controller->params['url']['ext'] = 'js';
|
||||
$this->RequestHandler->initialize($this->Controller);
|
||||
$this->RequestHandler->startup($this->Controller);
|
||||
$this->assertNotEqual($this->Controller->layout, 'ajax');
|
||||
|
||||
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
|
||||
}
|
||||
|
||||
/**
|
||||
* testStartupCallback method
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue