Issue #1866910 by damiankloip: Add an ajaxEnabled() method for ViewExecutable.

8.0.x
catch 2013-02-05 13:03:02 +00:00
parent c962f4f5bc
commit 26253b37f0
7 changed files with 32 additions and 17 deletions

View File

@ -176,7 +176,7 @@ class Block extends DisplayPluginBase {
* Block views use exposed widgets only if AJAX is set.
*/
public function usesExposed() {
if ($this->isAJAXEnabled()) {
if ($this->ajaxEnabled()) {
return parent::usesExposed();
}
return FALSE;

View File

@ -244,7 +244,7 @@ abstract class DisplayPluginBase extends PluginBase {
*
* @return bool
*/
public function isAJAXEnabled() {
public function ajaxEnabled() {
if ($this->usesAJAX()) {
return $this->getOption('use_ajax');
}
@ -2488,7 +2488,7 @@ abstract class DisplayPluginBase extends PluginBase {
* overridden on an individual display.
*/
public function preExecute() {
$this->view->setUseAJAX($this->isAJAXEnabled());
$this->view->setAjaxEnabled($this->ajaxEnabled());
if ($this->usesMore() && !$this->useMoreAlways()) {
$this->view->get_total_rows = TRUE;
}

View File

@ -33,7 +33,7 @@ class Feed extends PathPluginBase {
*
* @var bool
*/
protected $usesAJAX = FALSE;
protected $ajaxEnabled = FALSE;
/**
* Whether the display allows the use of a pager or not.

View File

@ -250,7 +250,8 @@ class PagerTest extends PluginTestBase {
}
$view = views_get_view('test_pager_full');
$this->executeView($view);
$view->use_ajax = TRUE; // force the value again here
// Force the value again here.
$view->setAjaxEnabled(TRUE);
$view->pager = NULL;
$output = $view->render();
$output = drupal_render($output);

View File

@ -57,7 +57,6 @@ class ViewExecutableTest extends ViewUnitTestBase {
'executed',
'args',
'build_info',
'use_ajax',
'result',
'attachment_before',
'attachment_after',
@ -201,10 +200,10 @@ class ViewExecutableTest extends ViewUnitTestBase {
public function testPropertyMethods() {
$view = views_get_view('test_executable_displays');
// Test the setUseAJAX() method.
$this->assertFalse($view->use_ajax);
$view->setUseAJAX(TRUE);
$this->assertTrue($view->use_ajax);
// Test the setAjaxEnabled() method.
$this->assertFalse($view->ajaxEnabled());
$view->setAjaxEnabled(TRUE);
$this->assertTrue($view->ajaxEnabled());
$view->setDisplay();
// There should be no pager set initially.

View File

@ -67,7 +67,7 @@ class ViewExecutable {
*
* @var bool
*/
public $use_ajax = FALSE;
protected $ajaxEnabled = FALSE;
/**
* Where the results of a query will go.
@ -533,12 +533,27 @@ class ViewExecutable {
}
/**
* Whether or not AJAX should be used. If AJAX is used, paging,
* tablesorting and exposed filters will be fetched via an AJAX call
* rather than a page refresh.
* Sets whether or not AJAX should be used.
*
* If AJAX is used, paging, tablesorting and exposed filters will be fetched
* via an AJAX call rather than a page refresh.
*
* @param bool $use_ajax
* TRUE if AJAX should be used, FALSE otherwise.
*/
public function setUseAJAX($use_ajax) {
$this->use_ajax = $use_ajax;
public function setAjaxEnabled($ajax_enabled) {
$this->ajaxEnabled = (bool) $ajax_enabled;
}
/**
* Whether or not AJAX should be used.
*
* @see \Drupal\views\ViewExecutable::setAjaxEnabled().
*
* @return bool
*/
public function ajaxEnabled() {
return $this->ajaxEnabled;
}
/**

View File

@ -130,7 +130,7 @@ function template_preprocess_views_view(&$vars) {
}
// If using AJAX, send identifying data about this view.
if ($view->use_ajax && empty($view->is_attachment) && empty($view->live_preview)) {
if ($view->ajaxEnabled() && empty($view->is_attachment) && empty($view->live_preview)) {
$settings = array(
'views' => array(
'ajax_path' => url('views/ajax'),