Commit 0e0d2f6b authored by alexpott's avatar alexpott

Issue #2010060 by olli, dawehner: Fixed More link is rendered when set to 'No'.

parent 161f2c28
......@@ -2436,7 +2436,7 @@ public function renderPager() {
* Render the 'more' link
*/
public function renderMoreLink() {
if ($this->usesMore() && ($this->useMoreAlways() || (!empty($this->view->pager) && $this->view->pager->hasMoreRecords()))) {
if ($this->isMoreEnabled() && ($this->useMoreAlways() || (!empty($this->view->pager) && $this->view->pager->hasMoreRecords()))) {
$path = $this->getPath();
if ($this->getOption('link_display') == 'custom_url' && $override_path = $this->getOption('link_url')) {
......@@ -2539,7 +2539,7 @@ public function access($account = NULL) {
*/
public function preExecute() {
$this->view->setAjaxEnabled($this->ajaxEnabled());
if ($this->usesMore() && !$this->useMoreAlways()) {
if ($this->isMoreEnabled() && !$this->useMoreAlways()) {
$this->view->get_total_rows = TRUE;
}
$this->view->initHandlers();
......
......@@ -84,8 +84,12 @@ public function postExecute(&$result) {
// Make sure the pager shows the next link by setting the total items to
// the biggest possible number but prevent failing calculations like
// ceil(PHP_INT_MAX) we take PHP_INT_MAX / 2.
pager_default_initialize(PHP_INT_MAX / 2, $this->getItemsPerPage(), $this->options['id']);
$total = PHP_INT_MAX / 2;
}
else {
$total = $this->getCurrentPage() * $this->getItemsPerPage() + count($result);
}
pager_default_initialize($total, $this->getItemsPerPage(), $this->options['id']);
}
/**
......
......@@ -2,7 +2,7 @@
/**
* @file
* Definition of Drupal\views\Tests\Plugin\DisplayTest.
* Contains \Drupal\views\Tests\Plugin\DisplayTest.
*/
namespace Drupal\views\Tests\Plugin;
......@@ -55,7 +55,7 @@ public function setUp() {
*
* @see Drupal\views_test_data\Plugin\views\display\DisplayTest
*/
function testDisplayPlugin() {
public function testDisplayPlugin() {
$view = views_get_view('test_view');
// Add a new 'display_test' display and test it's there.
......@@ -195,6 +195,34 @@ public function testReadMore() {
// tested.
$more_text = $view->display_handler->useMoreText();
$this->assertEqual($more_text, $expected_more_text, 'The right more text is chosen.');
$view = views_get_view('test_display_more');
$view->setDisplay();
$view->display_handler->setOption('use_more', 0);
$this->executeView($view);
$output = $view->preview();
$output = drupal_render($output);
$this->drupalSetContent($output);
$result = $this->xpath('//div[@class=:class]/a', array(':class' => 'more-link'));
$this->assertTrue(empty($result), 'The more link is not shown.');
$view = views_get_view('test_display_more');
$view->setDisplay();
$view->display_handler->setOption('use_more', 0);
$view->display_handler->setOption('use_more_always', 0);
$view->display_handler->setOption('pager', array(
'type' => 'some',
'options' => array(
'items_per_page' => 1,
'offset' => 0,
),
));
$this->executeView($view);
$output = $view->preview();
$output = drupal_render($output);
$this->drupalSetContent($output);
$result = $this->xpath('//div[@class=:class]/a', array(':class' => 'more-link'));
$this->assertTrue(empty($result), 'The more link is not shown when view has more records.');
}
/**
......
......@@ -101,6 +101,11 @@ public function testMiniPagerRender() {
$this->assertText('Page 1', 'The current page info shows the only page.');
$this->assertNoText('‹‹ test', 'The previous link does not appear on the page.');
$this->assertText($this->nodes[19]->label());
$view = views_get_view('test_mini_pager');
$this->executeView($view);
$this->assertIdentical($view->get_total_rows, NULL, 'The query was not forced to calculate the total number of results.');
$this->assertIdentical($view->total_rows, NULL, 'The query did not return the total number of rows.');
}
}
......@@ -105,7 +105,7 @@ class ViewExecutable {
/**
* The total number of rows returned from the query.
*
* @var array
* @var int
*/
public $total_rows = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment