whoami7 - Manager
:
/
home
/
techyfnq
/
mailer.techinfrareviews.com
/
mailer.segnant.com
/
classes
/
Upload File:
files >> //home/techyfnq/mailer.techinfrareviews.com/mailer.segnant.com/classes/paging.class.php
<?php /* ------------------------------------------------------------------------------------ Sample code for cut and paste ------------------------------------------------------------------------------------ To make "Total : 4 Displaying: 1-5 " ************************************** $pageObj->showPageInfo(); To make "Pages: 1 2 3 4 " ************************************** $pageObj->show("http://chd-wrkstn-010/public/Ingenuity/documentation/dhatt/index.php?option=com_traverse_cat&Itemid=$itemid&id=$catID"); ------------------------------------------------------------------------------------ */ class Paging { var $ERROR = ''; var $start = null; var $limit = null; var $totalRecords = null; var $displayPages = null; //***************** Start of constructor() ******************************* function Paging( $totalRecords, $start, $limit, $displayPages=10 ) { $this->totalRecords = intval( $totalRecords ); $this->start = intval( $start ); $this->limit = intval( $limit ); $this->displayPages = intval( $displayPages ); return $this; } //***************** End of constructor() *********************************** //***************** Start of show() *********************************** function Show($link) { $txt =''; if(!empty($this->totalRecords)) { $txt = '<div class="pagingDiv"><strong>Pages: </strong>'; $displayPages =$this->displayPages; $totalPages = ceil( $this->totalRecords / $this->limit ); $currentPage = ceil( ($this->start+1) / $this->limit ); $temp = floor($displayPages/2); $start_loop = $currentPage - $temp; if($start_loop > $totalPages - $displayPages) $start_loop = $totalPages - $displayPages; if($start_loop == $totalPages - $displayPages) $start_loop = $totalPages - $displayPages + 1; if($start_loop < 1) $start_loop = 1; //$start_loop = (floor(($currentPage-1)/$displayPages))*$displayPages+1; if($start_loop + $displayPages - 1 < $totalPages) $stop_loop = $start_loop + $displayPages - 1; else $stop_loop = $totalPages; //$link .= '&limit='. $this->limit; if(strpos($link, 'start=')) $link = substr($link, 0,strrpos($link, '&start')); if($totalPages > 1) { for ($i=$start_loop; $i <= $stop_loop; $i++) { $page = ($i - 1) * $this->limit; if ($i == $currentPage) $txt .= '<span class="currentPage">'. $i .'</span>'; else $txt .= '<span class="pages"><a href="'. ( $link .'&start='. $page ) .'" class="pagenav">'. $i .'</a></span>'; } } else $txt = ''; } if ($txt != "") return $txt . ' </div>'; else return $txt . ''; } //***************** End of show() ************************************* //***************** Start of showPageInfo() *********************************** function ShowPageInfo() { $txt = ' <strong>Total: ' . $this->totalRecords.'</strong>'; if($this->totalRecords < $this->limit) $txt .= '<strong> | Displaying: ' . ($this->start+1) . '-' . ($this->start+$this->totalRecords) . '</strong> '; elseif(($this->totalRecords - $this->limit) < $this->start) $txt .= '<strong> | Displaying: ' . ($this->start+1) . '-' . $this->totalRecords . '</strong> '; else $txt .= '<strong> | Displaying: ' . ($this->start+1) . '-' . ($this->start+$this->limit) . '</strong> '; return $txt; } //***************** End of showPageInfo() ************************************* }// End of class paging ?>
Copyright ©2021 || Defacer Indonesia