Commit 52befbe4 authored by alexpott's avatar alexpott

Issue #2002920 by sillygwailo, Psikik, jibran, Maxis: Rename Views method...

Issue #2002920 by sillygwailo, Psikik, jibran, Maxis: Rename Views method get_items_per_page() to getItemsPerPage().
parent cad23a5e
......@@ -50,7 +50,7 @@ public function getValue($values, $field = NULL) {
$pager = $this->view->pager;
// Get the base count of the pager.
if ($pager->usePager()) {
$count += ($pager->get_items_per_page() * $pager->getCurrentPage() + $pager->setOffset());
$count += ($pager->getItemsPerPage() * $pager->getCurrentPage() + $pager->setOffset());
}
// Add the counter for the current site.
$count += $this->view->row_index + 1;
......
......@@ -79,12 +79,12 @@ public function useCountQuery() {
public function postExecute(&$result) {
// In query() one more item might have been retrieved than necessary. If so,
// the next link needs to be displayed and the item removed.
if (count($result) > $this->get_items_per_page()) {
if (count($result) > $this->getItemsPerPage()) {
array_pop($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->get_items_per_page(), $this->options['id']);
pager_default_initialize(PHP_INT_MAX / 2, $this->getItemsPerPage(), $this->options['id']);
}
}
......
......@@ -71,7 +71,7 @@ public function useCountQuery() {
return FALSE;
}
function get_items_per_page() {
public function getItemsPerPage() {
return 0;
}
......
......@@ -68,7 +68,7 @@
* All but the leanest pagers should probably return a value here, so
* most pagers will not need to override this method.
*/
function get_items_per_page() {
public function getItemsPerPage() {
return isset($this->options['items_per_page']) ? $this->options['items_per_page'] : 0;
}
......@@ -235,8 +235,8 @@ function render($input) { }
* This is primarily used to control the display of a more link.
*/
public function hasMoreRecords() {
return $this->get_items_per_page()
&& $this->total_items > (intval($this->current_page) + 1) * $this->get_items_per_page();
return $this->getItemsPerPage()
&& $this->total_items > (intval($this->current_page) + 1) * $this->getItemsPerPage();
}
public function exposedFormAlter(&$form, &$form_state) { }
......
......@@ -277,7 +277,7 @@ public function setCurrentPage($number = NULL) {
}
public function getPagerTotal() {
if ($items_per_page = intval($this->get_items_per_page())) {
if ($items_per_page = intval($this->getItemsPerPage())) {
return ceil($this->total_items / $items_per_page);
}
else {
......@@ -300,7 +300,7 @@ public function updatePageInfo() {
}
// Don't set pager settings for items per page = 0.
$items_per_page = $this->get_items_per_page();
$items_per_page = $this->getItemsPerPage();
if (!empty($items_per_page)) {
// Dump information about what we already know into the globals.
global $pager_page_array, $pager_total, $pager_total_items, $pager_limits;
......@@ -350,7 +350,7 @@ public function exposedFormAlter(&$form, &$form_state) {
'#type' => 'select',
'#title' => $this->options['expose']['items_per_page_label'],
'#options' => $sanitized_options,
'#default_value' => $this->get_items_per_page(),
'#default_value' => $this->getItemsPerPage(),
);
}
}
......
......@@ -142,7 +142,7 @@ public function testNoLimit() {
// Check some public functions.
$this->assertFalse($view->pager->usePager());
$this->assertFalse($view->pager->useCountQuery());
$this->assertEqual($view->pager->get_items_per_page(), 0);
$this->assertEqual($view->pager->getItemsPerPage(), 0);
}
public function testViewTotalRowsWithoutPager() {
......@@ -240,7 +240,7 @@ public function testNormalPager() {
$view->display_handler->setOption('pager', $pager);
$this->executeView($view);
$this->assertEqual($view->pager->get_items_per_page(), 0);
$this->assertEqual($view->pager->getItemsPerPage(), 0);
$this->assertEqual(count($view->result), 11);
}
......@@ -274,7 +274,7 @@ function testPagerApi() {
$this->assertEqual($view->getItemsPerPage(), NULL, 'If the pager is not initialized and no manual override there is no items per page.');
$rand_number = rand(1, 5);
$view->setItemsPerPage($rand_number);
$this->assertEqual($view->getItemsPerPage(), $rand_number, 'Make sure get_items_per_page uses the settings of set_items_per_page.');
$this->assertEqual($view->getItemsPerPage(), $rand_number, 'Make sure getItemsPerPage uses the settings of set_items_per_page.');
$this->assertEqual($view->getOffset(), NULL, 'If the pager is not initialized and no manual override there is no offset.');
$rand_number = rand(1, 5);
......@@ -298,7 +298,7 @@ function testPagerApi() {
$view->setItemsPerPage($rand_number);
$rand_number = rand(6, 11);
$view->pager->set_items_per_page($rand_number);
$this->assertEqual($view->getItemsPerPage(), $rand_number, 'Make sure get_items_per_page uses the settings of set_items_per_page.');
$this->assertEqual($view->getItemsPerPage(), $rand_number, 'Make sure getItemsPerPage uses the settings of set_items_per_page.');
$this->assertEqual($view->getOffset(), 0, 'Per default a view has a 0 offset.');
$rand_number = rand(1, 5);
......
......@@ -474,7 +474,7 @@ public function getCurrentPage() {
public function getItemsPerPage() {
// If the pager is already initialized, pass it through to the pager.
if (!empty($this->pager)) {
return $this->pager->get_items_per_page();
return $this->pager->getItemsPerPage();
}
if (isset($this->items_per_page)) {
......
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