* for details about HTTP status code
- * @param bool $checkAjax whether to specially handle AJAX (and PJAX) requests. Defaults to true,
- * meaning if the current request is an AJAX or PJAX request, then calling this method will cause the browser
+ * @param bool $checkAjax whether to specially handle AJAX requests. Defaults to true,
+ * meaning if the current request is an AJAX request, then calling this method will cause the browser
* to redirect to the given URL. If this is false, a `Location` header will be sent, which when received as
- * an AJAX/PJAX response, may NOT cause browser redirection.
+ * an AJAX response, may NOT cause browser redirection.
* Takes effect only when request header `X-Ie-Redirect-Compatibility` is absent.
* @return $this the response object itself
*/
@@ -890,11 +890,7 @@ class Response extends \yii\base\Response implements ResponseInterface
// Ajax 302 redirect in IE does not work. Change status code to 200. See https://github.com/yiisoft/yii2/issues/9670
$statusCode = 200;
}
- if (Yii::$app->getRequest()->getIsPjax()) {
- $this->setHeader('X-Pjax-Url', $url);
- } else {
- $this->setHeader('X-Redirect', $url);
- }
+ $this->setHeader('X-Redirect', $url);
} else {
$this->setHeader('Location', $url);
}
diff --git a/framework/widgets/Pjax.php b/framework/widgets/Pjax.php
deleted file mode 100644
index 898ef00..0000000
--- a/framework/widgets/Pjax.php
+++ /dev/null
@@ -1,216 +0,0 @@
-
- * @since 2.0
- */
-class Pjax extends Widget
-{
- /**
- * @var array the HTML attributes for the widget container tag. The following special options are recognized:
- *
- * - `tag`: string, the tag name for the container. Defaults to `div`
- * This option is available since version 2.0.7.
- * See also [[\yii\helpers\Html::tag()]].
- *
- * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
- */
- public $options = [];
- /**
- * @var string|false the jQuery selector of the links that should trigger pjax requests.
- * If not set, all links within the enclosed content of Pjax will trigger pjax requests.
- * If set to false, no code will be registered to handle links.
- * Note that if the response to the pjax request is a full page, a normal request will be sent again.
- */
- public $linkSelector;
- /**
- * @var string|false the jQuery selector of the forms whose submissions should trigger pjax requests.
- * If not set, all forms with `data-pjax` attribute within the enclosed content of Pjax will trigger pjax requests.
- * If set to false, no code will be registered to handle forms.
- * Note that if the response to the pjax request is a full page, a normal request will be sent again.
- */
- public $formSelector;
- /**
- * @var string The jQuery event that will trigger form handler. Defaults to "submit".
- * @since 2.0.9
- */
- public $submitEvent = 'submit';
- /**
- * @var bool whether to enable push state.
- */
- public $enablePushState = true;
- /**
- * @var bool whether to enable replace state.
- */
- public $enableReplaceState = false;
- /**
- * @var int pjax timeout setting (in milliseconds). This timeout is used when making AJAX requests.
- * Use a bigger number if your server is slow. If the server does not respond within the timeout,
- * a full page load will be triggered.
- */
- public $timeout = 1000;
- /**
- * @var bool|int how to scroll the page when pjax response is received. If false, no page scroll will be made.
- * Use a number if you want to scroll to a particular place.
- */
- public $scrollTo = false;
- /**
- * @var array additional options to be passed to the pjax JS plugin. Please refer to the
- * [pjax project page](https://github.com/yiisoft/jquery-pjax) for available options.
- */
- public $clientOptions;
- /**
- * {@inheritdoc}
- * @internal
- */
- public static $counter = 0;
- /**
- * {@inheritdoc}
- */
- public static $autoIdPrefix = 'p';
-
-
- /**
- * {@inheritdoc}
- */
- public function init()
- {
- parent::init();
- if (!isset($this->options['id'])) {
- $this->options['id'] = $this->getId();
- }
-
- if ($this->requiresPjax()) {
- ob_start();
- ob_implicit_flush(false);
- $view = $this->getView();
- $view->clear();
- $view->beginPage();
- $view->head();
- $view->beginBody();
- if ($view->title !== null) {
- echo Html::tag('title', Html::encode($view->title));
- }
- } else {
- $options = $this->options;
- $tag = ArrayHelper::remove($options, 'tag', 'div');
- echo Html::beginTag($tag, array_merge([
- 'data-pjax-container' => '',
- 'data-pjax-push-state' => $this->enablePushState,
- 'data-pjax-replace-state' => $this->enableReplaceState,
- 'data-pjax-timeout' => $this->timeout,
- 'data-pjax-scrollto' => $this->scrollTo,
- ], $options));
- }
- }
-
- /**
- * {@inheritdoc}
- */
- public function run()
- {
- if (!$this->requiresPjax()) {
- echo Html::endTag(ArrayHelper::remove($this->options, 'tag', 'div'));
- $this->registerClientScript();
-
- return;
- }
-
- $view = $this->getView();
- $view->endBody();
-
- $view->endPage(true);
-
- $content = ob_get_clean();
-
- // only need the content enclosed within this widget
- $response = Yii::$app->getResponse();
- $response->clearOutputBuffers();
- $response->setStatusCode(200);
- $response->format = Response::FORMAT_HTML;
- $response->content = $content;
- $response->headers->setDefault('X-Pjax-Url', Yii::$app->request->url);
- $response->send();
-
- Yii::$app->end();
- }
-
- /**
- * @return bool whether the current request requires pjax response from this widget
- */
- protected function requiresPjax()
- {
- $request = Yii::$app->getRequest();
- return $request->hasHeader('X-Pjax') && explode(' ', $request->getHeader('X-Pjax-Container')[0])[0] === '#' . $this->options['id'];
- }
-
- /**
- * Registers the needed JavaScript.
- */
- public function registerClientScript()
- {
- $id = $this->options['id'];
- $this->clientOptions['push'] = $this->enablePushState;
- $this->clientOptions['replace'] = $this->enableReplaceState;
- $this->clientOptions['timeout'] = $this->timeout;
- $this->clientOptions['scrollTo'] = $this->scrollTo;
- if (!isset($this->clientOptions['container'])) {
- $this->clientOptions['container'] = "#$id";
- }
- $options = Json::htmlEncode($this->clientOptions);
- $js = '';
- if ($this->linkSelector !== false) {
- $linkSelector = Json::htmlEncode($this->linkSelector !== null ? $this->linkSelector : '#' . $id . ' a');
- $js .= "jQuery(document).pjax($linkSelector, $options);";
- }
- if ($this->formSelector !== false) {
- $formSelector = Json::htmlEncode($this->formSelector !== null ? $this->formSelector : '#' . $id . ' form[data-pjax]');
- $submitEvent = Json::htmlEncode($this->submitEvent);
- $js .= "\njQuery(document).on($submitEvent, $formSelector, function (event) {jQuery.pjax.submit(event, $options);});";
- }
- $view = $this->getView();
- PjaxAsset::register($view);
-
- if ($js !== '') {
- $view->registerJs($js);
- }
- }
-}
diff --git a/framework/widgets/PjaxAsset.php b/framework/widgets/PjaxAsset.php
deleted file mode 100644
index fe9de50..0000000
--- a/framework/widgets/PjaxAsset.php
+++ /dev/null
@@ -1,35 +0,0 @@
-
- * @since 2.0
- */
-class PjaxAsset extends AssetBundle
-{
- /**
- * {@inheritdoc}
- */
- public $sourcePath = '@bower/yii2-pjax';
-
- /**
- * {@inheritdoc}
- */
- public $js = ['jquery.pjax.js',];
-
- /**
- * {@inheritdoc}
- */
- public $depends = [YiiAsset::class];
-}
diff --git a/tests/framework/grid/ActionColumnTest.php b/tests/framework/grid/ActionColumnTest.php
index 2713220..cc220bd 100644
--- a/tests/framework/grid/ActionColumnTest.php
+++ b/tests/framework/grid/ActionColumnTest.php
@@ -41,9 +41,9 @@ class ActionColumnTest extends \yiiunit\TestCase
return 'http://test.com';
};
$columnContents = $column->renderDataCell(['id' => 1], 1, 0);
- $viewButton = '';
- $updateButton = '';
- $deleteButton = '';
+ $viewButton = '';
+ $updateButton = '';
+ $deleteButton = '';
$expectedHtml = "$viewButton $updateButton $deleteButton | ";
$this->assertEquals($expectedHtml, $columnContents);
diff --git a/tests/framework/web/RequestTest.php b/tests/framework/web/RequestTest.php
index 5b2922f..f8040fa 100644
--- a/tests/framework/web/RequestTest.php
+++ b/tests/framework/web/RequestTest.php
@@ -599,39 +599,6 @@ class RequestTest extends TestCase
$_SERVER = $original;
}
- public function getIsPjaxDataProvider()
- {
- return [
- [
- [
- ],
- false,
- ],
- [
- [
- 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest',
- 'HTTP_X_PJAX' => 'any value',
- ],
- true,
- ],
- ];
- }
-
- /**
- * @dataProvider getIsPjaxDataProvider
- * @param array $server
- * @param bool $expected
- */
- public function testGetIsPjax($server, $expected)
- {
- $original = $_SERVER;
- $_SERVER = $server;
- $request = new Request();
-
- $this->assertEquals($expected, $request->getIsPjax());
- $_SERVER = $original;
- }
-
public function testGetOrigin()
{
$_SERVER['HTTP_ORIGIN'] = 'https://www.w3.org';
diff --git a/tests/framework/widgets/PjaxTest.php b/tests/framework/widgets/PjaxTest.php
deleted file mode 100644
index 4af4979..0000000
--- a/tests/framework/widgets/PjaxTest.php
+++ /dev/null
@@ -1,59 +0,0 @@
- new ArrayDataProvider()]);
- ob_start();
- $pjax1 = new Pjax();
- ob_end_clean();
- $nonPjaxWidget2 = new ListView(['dataProvider' => new ArrayDataProvider()]);
- ob_start();
- $pjax2 = new Pjax();
- ob_end_clean();
-
- $this->assertEquals('w0', $nonPjaxWidget1->options['id']);
- $this->assertEquals('w1', $nonPjaxWidget2->options['id']);
- $this->assertEquals('p0', $pjax1->options['id']);
- $this->assertEquals('p1', $pjax2->options['id']);
- }
-
- protected function setUp()
- {
- parent::setUp();
- $this->mockWebApplication();
- }
-
- /**
- * @see https://github.com/yiisoft/yii2/issues/15536
- */
- public function testShouldTriggerInitEvent()
- {
- $initTriggered = false;
- ob_start();
- $pjax = new Pjax(
- [
- 'on init' => function () use (&$initTriggered) {
- $initTriggered = true;
- }
- ]
- );
- ob_end_clean();
- $this->assertTrue($initTriggered);
- }
-}