Class page {// The number of pages displayed on each page in the pagination bar public $ rollpage = 6; // The parameter public $ parameter to be included in the page Jump; // The default list shows the number of rows per page. Public $ listrows = 20; // The Starting number of rows is public $ firstrow; // the total number of pages protected $ totalpages; // The total number of rows protected $ totalrows; // The current page number protected $ nowpage; // The total page number in the pagination bar protected $ coolpages; // custom page display protected $ Config = array ('redirect' => false, 'header' => 'record ', 'prev' => 'previous page', 'next' => 'Next page', 'First '=> '1 ', 'last' => 'most Next page ', 'Theme '=>' <Div class = "Part1"> % uppage % first % prepage % linkpage % nextpage % downpage % </div> <Div class = "Part2"> % totalpage % PAGE '); // default paging variable name protected $ varpage;/** + -------------------------------------------------------------- * Architecture Function + functions * @ access public + parameters * @ Param array $ total Total rows record count * @ Param array $ listrows number of records per page * @ Param array $ parameter paging jump parameter + response */public function _ construct ($ totalrows, $ listrows = '', $ parameter ='') {$ this-> totalrows = $ totalrows; $ this-> parameter = $ parameter; $ this-> varpage = C ('var _ page ')? C ('var _ page'): 'P'; If (! Empty ($ listrows) {$ this-> listrows = intval ($ listrows );} $ this-> totalpages = Ceil ($ this-> totalrows/$ this-> listrows ); // total number of pages $ this-> coolpages = Ceil ($ this-> totalpages/$ this-> rollpage ); // $ _ get verification $ this-> nowpage = intval ($ _ Get [$ this-> varpage]); $ this-> nowpage = $ this-> nowpage> 0? $ This-> nowpage: 1; if (! Empty ($ this-> totalpages) & $ this-> nowpage> $ this-> totalpages) {$ this-> nowpage = $ this-> totalpages ;} $ this-> firstrow = $ this-> listrows * ($ this-> nowPage-1);} public function setconfig ($ name, $ value) {If (isset ($ this-> config [$ name]) {$ this-> config [$ name] = $ value ;}} /** + ---------------------------------------------------------- * display by PAGE + ---------------------------------------------------------- * @ Access public + -------------------------------------------------------- */Public Function show () {If (0 = $ this-> totalrows) return ''; // processing parameter $ P = $ this-> varpage; $ url = $ _ server ['request _ URI ']. (strpos ($ _ server ['request _ URI '],'? ')? '':"? "). $ This-> parameter; $ parse = parse_url ($ URL); If (isset ($ parse ['query']) {parse_str ($ parse ['query'], $ Params); unset ($ Params [$ p]); $ url = $ parse ['path']. '? '. Http_build_query ($ Params);}/* Paging logic * // if the total number is smaller than the displayed page number, if ($ this-> totalpages <= $ this-> rollpage) {$ start = 1; $ end = $ this-> totalpages;} else {// if ($ this-> nowpage <= $ this-> rollpage-1) {$ start = 1; $ end = $ this-> rollpage; $ islast = true ;} else if ($ this-> nowpage> $ this-> totalpages-$ this-> rollpage + 1) {$ start = $ this-> totalpages-($ this-> rollpage-1); $ end = $ this-> totalpages; $ isfir St = true;} else {// floating number $ size = floor ($ this-> rollpage/2); $ start = $ this-> nowpage-$ size; $ end = $ this-> nowpage + $ size; $ isfirst = true; $ islast = true ;}// flip string $ uprow = $ this-> nowpage-1; $ downrow = $ this-> nowpage + 1;/* assemble HTML * // <1 ...... last> if ($ isfirst) {$ thefirst = "<a class = 'firstpage' href = '". $ URL. "&". $ p. "= 1'> ". $ this-> config ['first']. "</a>";} if ($ islast) {$ theend = "< A class = 'lastpage' href = '". $ URL. "&". $ p. "= $ this-> totalpages '> ". $ this-> config ['last']. "</a>";} if ($ uprow> 0) {$ uppage = "<a class = 'uppage' href = '". $ URL. "&". $ p. "= $ uprow '> ". $ this-> config ['prev']. "</a>";} if ($ downrow <= $ this-> totalpages) {$ downpage = "<a class = 'Download' href = '". $ URL. "&". $ p. "= $ downrow '> ". $ this-> config ['Next']. "</a>";} if ($ start = 3) {$ linkpage. = "<a href = '". $ URL. "&". $ p. "= 2'> 2 </ A> ";}if ($ start >=4) {$ linkpage. = "<a href = '". $ URL. "&". $ p. "= 2'> 2 </a> <SPAN class = 'noendclass'>... </span> ";}// 1 2 3 4 5 for ($ I = $ start; $ I <=$ end; $ I ++) {if ($ I! = $ This-> nowpage) {$ linkpage. = "<a href = '". $ URL. "&". $ p. "= $ I '> ". $ I. "</a>";} else {$ linkpage. = "<SPAN class = 'current'> ". $ I. "</span>" ;}if ($ I ==$ end) {if ($ I <$ this-> totalrows) {$ linkpage. = "<SPAN class = 'noendclass'>... </span> ";}}$ pagestr = str_replace (Array ('% header %', '% nowpage %', '% totalrow %', '% totalpage % ', '% uppage %', '% first %', '% prepage %', '% linkpage %', '% nextpage %', '% downpage % ', '% end %'), ar Ray ($ this-> config ['head'], $ this-> nowpage, $ this-> totalrows, $ this-> totalpages, $ uppage, $ thefirst, $ prepage, $ linkpage, $ nextpage, $ downpage, $ theend), $ this-> config ['Theme ']); // display mode normal false with jump true if (! Empty ($ this-> config ['redirect']) {$ html = $ pagestr;} else {// pass the parameter if ($ this-> totalpages> 1) {$ redirect = "to the <form method = 'get' action =''> <input name = ". $ p. "type = 'text' class = 'page _ text' size = '3' maxlength = '3' value = '". $ this-> nowpage. "'/> page <input type = 'submit' class = 'page _ BTN 'value = 'confirmed'/>"; if ($ Params) {foreach ($ Params as $ k => $ v) {$ string. = "<input type = 'did' name = '". $ K. "'value = '". $ v. "'/>";} $ redirect = $ redirect. $ string. '</form> </div>';} else {$ redirect = $ redirect. '</form> </div>'; }}// generate an HTML string $ html = $ pagestr. $ redirect;} return $ HTML ;}}