PHP Page Header There is a large section of comment description, how to find out where to write, to explain
Source: Internet
Author: User
PHP Page Header There is a large paragraph of comment description, how to find out where to write, to explain?
The contents of the comment are as follows:
* @copyright: Copyright 2006 FEIFENGXLQ * @license: Version 2.0 * @create: 2006-5-31 * @modify: 2006-6-1 * @modify: FEIFENGXLQ 2006-11-4 * Description: Ultra-strong paging class, four paging modes, default to similar baidu,google-like paging style. * 2.0 Add Feature: Support custom style, custom style, support PHP4 and PHP5, * to see Detail,please visit http://www.phpobject.net/blog/read.php? * Example: * Mode four paging mode: require_once (' ... /libs/classes/page.class.php '); $page =new page (Array (' Total ' =>1000, ' perpage ' =>20)); Echo ' Mode:1
'. $page->show (); Echo '
--------------------------------------------
Mode:2
'. $page->show (2); Echo '
--------------------------------------------
Mode:3
'. $page->show (3); Echo '
--------------------------------------------
Mode:4
'. $page->show (4); Open Ajax: $ajaxpage =new page (' Total ' =>1000, ' perpage ' =>20, ' ajax ' = ' ajax_page ', ' page_name ' = ' test ' )); Echo ' Mode:1
'. $ajaxpage->show (); Inherit custom paging display mode: Demo:http://www.phpobject.net/blog */class Page {/** * config, public */var $page _name= "Pb_page";//page label To control the URL page. such as xxx.php? pb_page=2 pb_page var $next _page= ' > ';//Next page var $pre _page= ' < ';//previous page var $first _page= ' first ';//home Var $last _page= ' last ';//end Var $pre _bar= ' << ';//previous page strip Var $next _bar= ' >> ';//Next page strip var $format _left= ' ['; var $format _right= ' ]'; var $is whether _ajax=false;//supports AJAX paging mode/** * Private * */var $pagebarnum =10;//control the number of record bars. var $totalpage =0;//Total pages var $ajax _action_name= ";//ajax action name var $nowindex =1;//current page var $url =" ";//url address header var $offset = 0; /** * Constructor Constructor * * @param array $array [' total '], $array [' Perpage '], $array [' Nowindex '], $array [' url '], $array [' Ajax '] ... */function page ($array) {if (Is_array ($array)) {if (!array_key_exists (' Total ', $array)) $this->error (__ function__, ' need a param of total '); $total =intval ($array [' total ']); $perpage = (array_key_exists (' Perpage ', $array))? intval ($array [' Perpage ']): 10; $nowindex = (Array_keY_exists (' Nowindex ', $array))? intval ($array [' Nowindex ']): '; $url = (array_key_exists (' url ', $array))? $array [' url ']: '; }else{$total = $array; $perpage =10; $nowindex = "; $url =";} if ((!is_int ($total)) | | ($total <0)) $this->error (__function__, $total. ' is not a positive integer! '); if ((!is_int ($perpage)) | | ($perpage <=0)) $this->error (__function__, $perpage. ' is not a positive integer! '); if (!empty ($array [' page_name '])) $this->set (' page_name ', $array [' page_name ']);//set PAGENAME $this->_set_ Nowindex ($nowindex);//Set the current page $this->_set_url ($url);//Set the link address $this->totalpage=ceil ($total/$perpage); $this->offset= ($this->nowindex-1) * $perpage; if (!empty ($array [' Ajax])) $this->open_ajax ($array [' Ajax ']),//Open Ajax mode}/** * Set the value of the variable name specified in the class, if the change amount does not belong to this class, will throw a exception * * @param string $var * @param string $value */function set ($var, $value) {//var_dump (Get_object_vars ( $this)); if (In_array ($var, Get_object_vars ($this))) $this, $var = $value; else {//$this->error (__function__, $var."Does not belong to pb_page!"); }}/** * Open inverted Ajax mode * * @param string $action default Ajax-triggered action. */function Open_ajax ($action) {$this->is_ajax=true; $this->ajax_action_name= $action;}/** * Get the code that shows "next page" * * @par AM String $style * @return String */function next_page ($style = ") {if ($this->nowindex< $this->totalpage) {retur n $this->_get_link ($this->_get_url ($this->nowindex+1), $this->next_page, $style); } return '. $this->next_page. '; }/** * Gets the code that displays "previous page" * * @param string $style * @return String */function pre_page ($style = ") {if ($this->nowindex> 1) {return $this->_get_link ($this->_get_url ($this->nowindex-1), $this->pre_page, $style);} return '. $ This->pre_page. '; }/** * Gets the code that displays "Home page" * @return String */function first_page ($style = ") {if ($this->nowindex==1) {return '. $this First_page. '; } return $this->_get_link ($this->_get_url (1), $this->first_page, $style); /** * Get the code that shows "last" * * @return String */function Last_page($style = ") {if ($this->nowindex== $this->totalpage) {return '. $this->last_page. ';} return $this->_get_link ($this- >_get_url ($this->totalpage), $this->last_page, $style); } function Nowbar ($style = ", $nowindex _style=") {$plus =ceil ($this->pagebarnum/2), if ($this->pagebarnum-$plus + $this->nowindex> $this->totalpage) $plus = ($this->pagebarnum-$this->totalpage+ $this->nowindex) ; $begin = $this->nowindex-$plus +1; $begin = ($begin >=1)? $begin: 1; $return = "; for ($i = $begin; $i < $begin + $this->pagebarnum; $i + +) {if ($i <= $this->totalpage) {if ($i! = $this->nowindex ) $return. = $this->_get_text ($this->_get_link ($this->_get_url ($i), $i, $style)); else $return. = $this->_get_text ('. $i. '); }else{break;} $return. = "\ n"; } unset ($begin); return $return; /** * Gets the code that shows the Jump button * * @return String */function Select () {$return = "; for ($i =1; $i <= $this->totalpage; $i + +) {if ($ i== $this->nowindex) {$return. = '. $i. ';} else{$return. = '. $i. ';}} Unset ($i); $return. = '; return $return; }/** * Gets the value required in the MySQL statement * * @return String */function offset () {return $this->offset;}/** * Controls the pagination display style (you can add the corresponding wind Lattice) * * @param int $mode * @return String */function Show ($mode =1) {switch ($mode) {case ' 1 ': $this->next_page= ' next page '; $this->pre_page= ' previous page '; return $this->pre_page (). $this->nowbar (). $this->next_page (). ' Section '. $this->select (). ' Page '; Break Case ' 2 ': $this->next_page= ' next '; $this->pre_page= ' Previous '; $this->first_page= ' home '; $this->last_page= ' last '; return $this->first_page (). " ". $this->pre_page (). ' [Page '. $this->nowindex. '] '. $this->next_page (). " ". $this->last_page (); Break Case ' 3 ': $this->next_page= ' next page '; $this->pre_page= ' previous page '; $this->first_page= ' home '; $this->last_page= ' last '; return $this->first_page (). $this->pre_page (). $this->next_page (). $this->last_page (); Break Case ' 4 ': $this->next_page= ' next page '; $this->pre_page= ' previous page '; return $this->pre_page (). $tHis->nowbar (). $this->next_page (); Break Case ' 5 ': Return $this->pre_bar (). $this->pre_page (). $this->nowbar (). $this->next_page (). $this->next _bar (); Break }/*----------------Private Function (private method)-----------------------*//** * Set URL header address * @param: String $url * @return bool EAN */function _set_url ($url = "") {if (!empty ($url)) {//Manually set $this->url= $url. (Stristr ($url, '? '))? ' & ': '? '). $this->page_name. " ="; }else{//Auto Get if (empty ($_server[' query_string ')) {//Not present query_string $this->url=$_server[' Request_uri ']. "?". $this->page_name. " ="; }else{//if (Stristr ($_server[' query_string '), $this->page_name. ' = ')) {//Address exists page parameter $this->url=str_replace ($this->page_name. ' = '. $this->nowindex, ' ', $_server[' Request_uri ']); $last = $this->url[strlen ($this->url)-1]; if ($last = = '? ' | | $last = = ' & ') {$this->url.= $this->page_name. " ="; }else{$this->url.= ' & '. $this->page_name. " ="; }}else{//$this->url=$_server[' Request_uri ']. ' & '. $this->page_name. ' ='; }//end if}//end if}//end if}/** * Set Current page * */function _set_nowindex ($nowindex) {if (empty ($nowindex)) {//System gets if (Isse T ($_get[$this->page_name]) {$this->nowindex=intval ($_get[$this->page_name]);}} else{//Manually set $this->nowindex=intval ($nowindex);}} /** * Returns the address value for the specified page * * @param int $pageno * @return string $url */function _get_url ($pageno =1) {return $this->url. $pag Eno }/** * Get pagination display text, for example _get_text (' 1 ') will return by default [1] * * @param string $str * @return string $url */function _get_text ($STR) {R Eturn $this->format_left. $str. $this->format_right; }/** * Get the link address */function _get_link ($url, $text, $style = ") {$style = (empty ($style))? ': ' class= '. $style. '"; if ($this->is_ajax) {//If you are using AJAX mode return '. $text. ';} else{return '. $text. ';}} /** * Error Handling Method */Function error ($function, $errormsg) {die (' Error in file ' __file__ ', function '. $function. ' (): '. $errormsg); }}?>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.