rs ) ) { //If there is no RS to return, something is seriously wrong. Check interface.inc.php? //Make sure the ListFactory function is doing a pageselect $this->rs = $arr->rs; $this->count_rows = $arr->db->pageExecuteCountRows; return true; } return false; } /** * @return bool|int */ function getPreviousPage() { if ( is_object( $this->rs ) ) { return (int)( $this->rs->absolutepage() - 1 ); } return false; } /** * @return bool|int */ function getCurrentPage() { if ( is_object( $this->rs ) ) { return (int)$this->rs->absolutepage(); } return false; } /** * @return bool|int */ function getNextPage() { if ( is_object( $this->rs ) ) { return (int)( $this->rs->absolutepage() + 1 ); } return false; } /** * @return bool */ function isFirstPage() { if ( is_object( $this->rs ) ) { return (bool)$this->rs->atfirstpage(); } return true; } /** * @return bool */ function isLastPage() { //If the first page is also the last, return true. if ( $this->isFirstPage() && $this->LastPageNumber() == 1 ) { return true; } if ( is_object( $this->rs ) ) { return (bool)$this->rs->atlastpage(); } return true; } /** * @return bool|int */ function LastPageNumber() { if ( is_object( $this->rs ) ) { if ( $this->count_rows === false ) { if ( $this->getCurrentPage() < 0 ) { //Only one page in result set. return (int)$this->rs->lastpageno(); } else { //More than one page in result set. if ( $this->rs->atlastpage() == true ) { return (int)$this->getCurrentPage(); } else { //Since we don't know what the actual last page is, just add 100 pages to the current one. //The user may need to click this several times if there are more than 100 pages. return (int)( $this->getCurrentPage() + 99 ); } } } else { return (int)$this->rs->lastpageno(); } } return false; } /** * Return maximum rows per page * @return bool|int */ function getRowsPerPage() { if ( is_object( $this->rs ) ) { if ( isset( $this->rs->rowsPerPage ) ) { return (int)$this->rs->rowsPerPage; } else { return (int)$this->rs->recordcount(); } } return false; } /** * Used to dynamically add total rows outside of a record set. * @param $value * @return bool */ function addTotalRows( $value ) { $this->add_total_rows = (int)$value; return true; } /** * @return bool|int */ function getTotalRows() { if ( is_object( $this->rs ) ) { if ( $this->count_rows === false ) { if ( $this->isLastPage() === true ) { return (int)( ( $this->getPreviousPage() * $this->getRowsPerPage() ) + $this->add_total_rows + $this->rs->recordcount() ); } else { return false; } } else { return (int)$this->rs->maxrecordcount(); } } return false; } /** * @return array */ function getPageVariables() { //Make sure the ListFactory function is doing a pageselect $paging_data = [ 'previous_page' => $this->getPreviousPage(), 'current_page' => $this->getCurrentPage(), 'next_page' => $this->getNextPage(), 'is_first_page' => $this->isFirstPage(), 'is_last_page' => $this->isLastPage(), 'last_page_number' => $this->LastPageNumber(), 'rows_per_page' => $this->getRowsPerPage(), 'total_rows' => $this->getTotalRows(), ]; //Debug::Arr($paging_data, ' Paging Data: Count Rows: '. (int)$this->count_rows, __FILE__, __LINE__, __METHOD__, 10); return $paging_data; } } ?>