home/includes/pagination.php
/**
	 * Function: page_links
	 * Purpose: create the html links for navigating through the dataset
	 *
	 * @var sting $path optionally set the path for the link
	 * @var sting $ext optionally pass in extra parameters to the GET
	 * @return string returns the html menu
	*/
page_links
Purpose: create the html links for navigating through the dataset

@var sting $path optionally set the path for the link
@var sting $ext optionally pass in extra parameters to the GET
@return string returns the html menu
page_links Purpose : create the html links for navigating through the dataset @var sting $path optionally set the path for the link @var sting $ext optionally pass in extra parameters to the GET @return string returns the html menu
public function page_links($path='&', $ext=null) {
		$adjacents = "2";
		$prev = $this->_page - 1;
		$next = $this->_page + 1;
		$lastpage = ceil($this->_totalRows/$this->_perPage);
		$lpm1 = $lastpage - 1;
		global $previousLink;
		global $nextLink;
		$pagination = "";
		if($lastpage > 1) {
			$pagination .= "<div class='pagination'>";
		}
		if ($this->_page > 1) {
			$pagination.= "<a href='index.php?page=".$_GET['page'].$path."$this->_instance=$prev"."$ext'><i class='fa fa-angle-double-left'></i> ".$previousLink."</a>";
		} else {
			$pagination.= "<span class='disabled'><i class='fa fa-angle-double-left'></i>  ".$previousLink."</span>";
		}
		if ($lastpage < 7 + ($adjacents * 2)) {
			for ($counter = 1; $counter <= $lastpage; $counter++) {
				if ($counter == $this->_page) {
					$pagination.= "<span class='current'>$counter</span>";
				} else {
					$pagination.= "<a href='index.php?page=".$_GET['page'].$path."$this->_instance=$counter"."$ext'>$counter</a>";
				}
			}
		} else if ($lastpage > 5 + ($adjacents * 2)) {
			if ($this->_page < 1 + ($adjacents * 2)) {
				for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) {
					if ($counter == $this->_page) {
						$pagination.= "<span class='current'>$counter</span>";
					} else {
						$pagination.= "<a href='index.php?page=".$_GET['page'].$path."$this->_instance=$counter"."$ext'>$counter</a>";
					}
				}
				$pagination.= "&hellip;";
				$pagination.= "<a href='index.php?page=".$_GET['page'].$path."$this->_instance=$lpm1"."$ext'>$lpm1</a>";
				$pagination.= "<a href='index.php?page=".$_GET['page'].$path."$this->_instance=$lastpage"."$ext'>$lastpage</a>";
			} else if ($lastpage - ($adjacents * 2) > $this->_page && $this->_page > ($adjacents * 2)) {
				$pagination.= "<a href='index.php?page=".$_GET['page'].$path."$this->_instance=1"."$ext'>1</a>";
				$pagination.= "<a href='index.php?page=".$_GET['page'].$path."$this->_instance=2"."$ext'>2</a>";
				$pagination.= "&hellip;";
				for ($counter = $this->_page - $adjacents; $counter <= $this->_page + $adjacents; $counter++) {
					if ($counter == $this->_page) {
						$pagination.= "<span class='current'>$counter</span>";
					} else {
						$pagination.= "<a href='index.php?page=".$_GET['page'].$path."$this->_instance=$counter"."$ext'>$counter</a>";
					}
				}
				$pagination.= "&hellip;";
				$pagination.= "<a href='index.php?page=".$_GET['page'].$path."$this->_instance=$lpm1"."$ext'>$lpm1</a>";
				$pagination.= "<a href='index.php?page=".$_GET['page'].$path."$this->_instance=$lastpage"."$ext'>$lastpage</a>";
			} else {
				$pagination.= "<a href='index.php?page=".$_GET['page'].$path."$this->_instance=1"."$ext'>1</a>";
				$pagination.= "<a href='index.php?page=".$_GET['page'].$path."$this->_instance=2"."$ext'>2</a>";
				$pagination.= "&hellip;";
				for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) {
					if ($counter == $this->_page) {
						$pagination.= "<span class='current'>$counter</span>";
					} else {
						$pagination.= "<a href='index.php?page=".$_GET['page'].$path."$this->_instance=$counter"."$ext'>$counter</a>";
					}
				}
			}
		}
		if ($this->_page < $counter - 1) {
			$pagination.= "<a href='index.php?page=".$_GET['page'].$path."$this->_instance=$next"."$ext'>".$nextLink." <i class='fa fa-angle-double-right'></i></a>";
			$pagination.= "</div>\n";
		} else {
			$pagination.= "<span class='disabled'>".$nextLink." <i class='fa fa-angle-double-right'></i></span>";
			$pagination.= "</div>\n";
		}
		return $pagination;
	}
public function page_links ( $ path = '&' , $ ext = null ) { $ adjacents = " 2 " ; $ prev = $ this -> _page - 1 ; $ next = $ this -> _page + 1 ; $ lastpage = ceil ( $ this -> _totalRows / $ this -> _perPage ) ; $ lpm1 = $ lastpage - 1 ; global $ previousLink ; global $ nextLink ; $ pagination = " " ; if ( $ lastpage > 1 ) { $ pagination .= " <div class='pagination'> " ; } if ( $ this -> _page > 1 ) { $ pagination .= " <a href='index.php?page= " . $ _GET [ 'page' ] . $ path . " $ this -> _instance = $ prev " . " $ ext '><i class='fa fa-angle-double-left'></i>  " . $ previousLink . " </a> " ; } else { $ pagination .= " <span class='disabled'><i class='fa fa-angle-double-left'></i>   " . $ previousLink . " </span> " ; } if ( $ lastpage < 7 + ( $ adjacents * 2 ) ) { for ( $ counter = 1 ; $ counter <= $ lastpage ; $ counter ++ ) { if ( $ counter == $ this -> _page ) { $ pagination .= " <span class='current'> $ counter </span> " ; } else { $ pagination .= " <a href='index.php?page= " . $ _GET [ 'page' ] . $ path . " $ this -> _instance = $ counter " . " $ ext '> $ counter </a> " ; } } } else if ( $ lastpage > 5 + ( $ adjacents * 2 ) ) { if ( $ this -> _page < 1 + ( $ adjacents * 2 ) ) { for ( $ counter = 1 ; $ counter < 4 + ( $ adjacents * 2 ) ; $ counter ++ ) { if ( $ counter == $ this -> _page ) { $ pagination .= " <span class='current'> $ counter </span> " ; } else { $ pagination .= " <a href='index.php?page= " . $ _GET [ 'page' ] . $ path . " $ this -> _instance = $ counter " . " $ ext '> $ counter </a> " ; } } $ pagination .= " &hellip; " ; $ pagination .= " <a href='index.php?page= " . $ _GET [ 'page' ] . $ path . " $ this -> _instance = $ lpm1 " . " $ ext '> $ lpm1 </a> " ; $ pagination .= " <a href='index.php?page= " . $ _GET [ 'page' ] . $ path . " $ this -> _instance = $ lastpage " . " $ ext '> $ lastpage </a> " ; } else if ( $ lastpage - ( $ adjacents * 2 ) > $ this -> _page && $ this -> _page > ( $ adjacents * 2 ) ) { $ pagination .= " <a href='index.php?page= " . $ _GET [ 'page' ] . $ path . " $ this -> _instance =1 " . " $ ext '>1</a> " ; $ pagination .= " <a href='index.php?page= " . $ _GET [ 'page' ] . $ path . " $ this -> _instance =2 " . " $ ext '>2</a> " ; $ pagination .= " &hellip; " ; for ( $ counter = $ this -> _page - $ adjacents ; $ counter <= $ this -> _page + $ adjacents ; $ counter ++ ) { if ( $ counter == $ this -> _page ) { $ pagination .= " <span class='current'> $ counter </span> " ; } else { $ pagination .= " <a href='index.php?page= " . $ _GET [ 'page' ] . $ path . " $ this -> _instance = $ counter " . " $ ext '> $ counter </a> " ; } } $ pagination .= " &hellip; " ; $ pagination .= " <a href='index.php?page= " . $ _GET [ 'page' ] . $ path . " $ this -> _instance = $ lpm1 " . " $ ext '> $ lpm1 </a> " ; $ pagination .= " <a href='index.php?page= " . $ _GET [ 'page' ] . $ path . " $ this -> _instance = $ lastpage " . " $ ext '> $ lastpage </a> " ; } else { $ pagination .= " <a href='index.php?page= " . $ _GET [ 'page' ] . $ path . " $ this -> _instance =1 " . " $ ext '>1</a> " ; $ pagination .= " <a href='index.php?page= " . $ _GET [ 'page' ] . $ path . " $ this -> _instance =2 " . " $ ext '>2</a> " ; $ pagination .= " &hellip; " ; for ( $ counter = $ lastpage - ( 2 + ( $ adjacents * 2 ) ) ; $ counter <= $ lastpage ; $ counter ++ ) { if ( $ counter == $ this -> _page ) { $ pagination .= " <span class='current'> $ counter </span> " ; } else { $ pagination .= " <a href='index.php?page= " . $ _GET [ 'page' ] . $ path . " $ this -> _instance = $ counter " . " $ ext '> $ counter </a> " ; } } } } if ( $ this -> _page < $ counter - 1 ) { $ pagination .= " <a href='index.php?page= " . $ _GET [ 'page' ] . $ path . " $ this -> _instance = $ next " . " $ ext '> " . $ nextLink . "  <i class='fa fa-angle-double-right'></i></a> " ; $ pagination .= " </div> \n " ; } else { $ pagination .= " <span class='disabled'> " . $ nextLink . "  <i class='fa fa-angle-double-right'></i></span> " ; $ pagination .= " </div> \n " ; } return $ pagination ; }
Function: page_links
 Purpose: create the html links for navigating through the dataset
Function : page_links Purpose : create the html links for navigating through the dataset
// Localization Globals