?
Path : /home/admin/public_html/libs-bak/ |
Current File : /home/admin/public_html/libs-bak/backoff_ajax.php |
<? class backoff_ajax extends MySql { var $_ModName; var $_Limit; var $_total; var $_Next_Page; var $_Start; var $_a; var $_z; var $_az; var $_link; var $_first_page_link; var $_previous_page_link; var $_last_page_link; var $_next_page_link; var $_Page; var $_total_links; function setModName($name){ global $backoff; $backoff['mod']=$name; } function setOrderMin2Max(){ if($this->_Page==1){$count=1; return $count;}else{ $count=(($this->_Page-1)*$this->_Limit)+1; return $count; } } function setOrder(){ if($this->_Page==1){$count=$this->_total;}else{ $cal_page=$this->_Page-1; $perpage=$cal_page*$this->_Limit; $count=$this->_total-$perpage; return $count; } return $count; } function setPage(){ global $backoff; if(isset($backoff[$backoff['mod']]['page'])){$this->_Page = $backoff[$backoff['mod']]['page'];}else{$this->_Page = 1;} return $this->_Page; } function MakeLinkNavigator($MLlink, $MLget, $MLvalue, $what){ $getQueryString = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, $MLget) == false) { array_push($newParams, $param); } }//end foreach $params as $param if (count($newParams) != 0) { $getQueryString = "&" . implode("&", $newParams); } }//end if empty($_SERVER['..... $getQueryString = sprintf("%s=%s%s",$MLget , $MLvalue, $getQueryString); $this->_link = $MLlink."?".$getQueryString; // $this->_link=$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']; if($what == 1){return $this->_link;} if($what == 0){return $newParams;} }//end function MakeLinkNavigato function total_links($total_link){ if($total_link==""){ $this->_total_links = 9; }else{ $this->_total_links=$total_link;} return $this->_total_links; } function PageNavigator(){ //Total links / navigator if($this->_total_links>$this->_Next_Page ){$this->_total_links=$this->_Next_Page;} $Ceil2total_links = ceil($this->_total_links/2); $Floor2total_links = floor($this->_total_links/2); $this->_first_page_link = 1;//$this->MakeLinkNavigator($_SERVER['PHP_SELF'], "page", 1, 1); $this->_previous_page_link = $this->_Page-1;//$this->MakeLinkNavigator($_SERVER['PHP_SELF'], "page", $this->_Page-1, 1); $this->_last_page_link = $this->_Next_Page;//$this->MakeLinkNavigator($_SERVER['PHP_SELF'], "page", $this->_Next_Page , 1); $this->_next_page_link = $this->_Page+1;//$this->MakeLinkNavigator($_SERVER['PHP_SELF'], "page", $this->_Page+1, 1); $this->_a = 1; $this->_z = $this->_total_links; if( $this->_Next_Page<=$this->_total_links){ $this->_z = $this->_Next_Page; }else{ if(isset($this->_Page) && ($this->_Page > $Ceil2total_links)){ $this->_a = $this->_Page-$Floor2total_links; $this->_z = $this->_Page+$Floor2total_links; } if(isset($this->_Page) && ($this->_Page > ($this->_Limit-$Ceil2total_links))){ $this->_a = $this->_Next_Page-$this->_total_links+1; $this->_z = $this->_Next_Page; } } }//end function function PageLink(){ global $backoff; $output.="หน้า| "; for($i=$this->_a; $i<=$this->_z; $i++){ if($this->_Page == $i){ $output.= "<span id='this_page'>{$i}</span> "; }else{ $output.= " <a href=\"javascript:void(0)\" onClick=\"javascript:xajax_get_Page($i);\">$i</a> "; } } return $output; }//end function total_record(){ $output.="มีทั้งหมด <font color=red>".$this->_total."</font> Items "; $output.="แสดงหน้า {$this->_Page} / ".$this->_Next_Page.""; return $output; }//end function jum2page function PreNext(){ global $backoff; if( $this->_Next_Page > 1){ if($this->_Page>1){ $output.= "<a href=\"javascript:void(0)\" onClick=\"javascript:xajax_get_Page('".$this->_first_page_link."')\">หน้าแรก </a>"; $output.= "<a href=\"javascript:void(0)\" onClick=\"javascript:xajax_get_Page('".$this->_previous_page_link."')\">ก่อน </a>"; }else{ $output.= "หน้าแรก "; $output.= "ก่อน "; } if($this->_Page< $this->_Next_Page){ $output.= "<a href=\"javascript:void(0)\" onClick=\"javascript:xajax_get_Page('".$this->_next_page_link."')\">ถัดไป </a>"; $output.= "<a href=\"javascript:void(0)\" onClick=\"javascript:xajax_get_Page('".$this->_last_page_link."')\">หน้าสุดท้าย</a>"; }else{ $output.= "ถัดไป "; $output.= "Last"; } }else{$output.= "หน้าแรก "; $output.= "ก่อน "; $output.= "ถัดไป "; $output.= "หน้าสุดท้าย"; }//end if $this->_Next_Page>1 return $output; } function setLimit($limit){ global $backoff; $this->_Limit=$backoff[$backoff['mod']]['Limit']; if($this->_Limit==""){$this->_Limit=$limit;} return $this->_Limit; } }//end class ?>