Class implemented by a page scroll bar
Usage example:
<? Php
Class_Scroll: _ Print ($ _ SERVER ['php _ self-service '], 1234, $ _ GET ['page'], 10, $ _ SERVER ['query _ string'], "Page", 9, true );
?>
<? Php
/**
* Implement the scroll bar class
*
* Generate a page scroll bar for display/Control Based on the page content and data volume.
* <Code>
* Class_Scroll: _ Print ($ _ SERVER ['php _ SELF '], 1234, $ _ GET ['page'], 10, $ _ SERVER ['query _ string'], "Page", 9, true );
* </Code>
*
* @ Author Zhou Beichen 2006-7-16
* @ Version 2.1
*
* @ Todo generate a page content scroll bar
*/
Class Class_Scroll {
/**
* Scroll bar of the output page
*
* @ Param string $ AScriptName the page to be rolled
* @ Param integer $ ATotalCount the total number of scrolling Information
* @ Param integer $ ANowPageID current page number
* @ Param integer $ AInnerCount the number of messages on each page
* @ Param string $ other variables to be included with AVar and their values
* @ Param string $ APageKey is used to specify the variable name of the page number.
* @ Param integer $ APageBundle indicates the maximum number of pages displayed in the scroll bar.
* @ Param boolean $ IncJump whether the page Jump drop-down list is displayed (default: true)
* @ Return string HTML code in the scroll bar of the page
*/
Function _ Print ($ AScriptName, $ ATotalCount, $ ANowPageID, $ AInnerCount, $ AVar, $ APageKey = "Page", $ APageBundle = 9, $ IncJump = true ){
// No project
If ($ ATotalCount = 0 or $ ATotalCount = "") return "No related content."; // "No Item Here .";
// Calculate the total number of pages
$ PageCount = ceil ($ ATotalCount/$ AInnerCount );
// Check and control the current page number
If ($ ANowPageID <1) $ ANowPageID = 1;
If ($ ANowPageID> $ PageCount) $ ANowPageID = $ PageCount;
// Determine the digital link value to be displayed.
$ StartNum = ($ ANowPageID-floor ($ APageBundle/2)> 0? ($ ANowPageID-floor ($ APageBundle/2): 1;
$ EndNum = ($ PageCount-$ StartNum) <$ APageBundle? $ PageCount: ($ StartNum + $ APageBundle-1 );
If ($ EndNum-$ StartNum) <$ APageBundle) & ($ PageCount> $ APageBundle) $ StartNum = $ EndNum-$ APageBundle + 1;
// Obtain the variable
If (strlen ($ AVar)> 0) $ Vars = explode ("&", $ AVar );
If (count ($ Vars)> 0 ){
For ($ I = 0; $ I <count ($ Vars); $ I ++ ){
$ V = explode ("=", $ Vars [$ I]);
If ($ v [0]! = $ APageKey) $ VarString. = sprintf ("% s = % s &", $ v [0], $ v [1]);
}
}
// Home Page
$ OutStringr = sprintf ('<a href = "% s? % S = % s "> % s </a> % s ', $ AScriptName, $ VarString, $ APageKey," 1 "," Homepage ", "r ");
// Previous Page Link
$ OutStringr. = ($ ANowPageID = 1 )? "": Sprintf ('<a href = "% s? % S = % s "> % s </a> % s ', $ AScriptName, $ VarString, $ APageKey, $ ANowPageID-1," Previous Page "," r ");
// Link to the intermediate page
For ($ I = $ StartNum; $ I <= $ EndNum; $ I ++)
$ OutStringr. = ($ I = $ ANowPageID )? Sprintf ("<span class =" Currpage "> % s </span> % s", $ I, "r"): sprintf ('<a href = "% s? % S = % s "> % s </a> % s ', $ AScriptName, $ VarString, $ APageKey, $ I, $ I," r ");
// Next page
$ OutStringr. = ($ ANowPageID = $ PageCount )? "": Sprintf ('<a href = "% s? % S = % s "> % s </a> % s ', $ AScriptName, $ VarString, $ APageKey, $ ANowPageID + 1," Next page ", "r ");
// Link to the last page
$ OutStringr. = sprintf ('<a href = "% s? % S = % s "> % s </a> % s Page % s ', $ AScriptName, $ VarString, $ APageKey, $ PageCount, "Last page", $ PageCount, $ ATotalCount, "r ");
// Jump Link
If ($ IncJump ){
$ OutStringr. = sprintf ("<label> jump to (J): <select name =" ScrollJump "accesskey =" j "onChange =" javascript: if (this. value! = 0) document. location = '% s? % S = '+ this. value; "id =" ScrollJump "> % s", $ AScriptName, $ VarString, $ APageKey, "r ");
For ($ I = 1; $ I <= $ PageCount; $ I ++ ){
$ SelectedStr = ($ I = $ ANowPageID )? "Selected =" selected "":"";
$ OutStringr. = sprintf ("<option value =" % d "% s> Page % d </option> % s", $ I, $ SelectedStr, $ I, "r ");
}
$ OutStringr. = "</select> </label> ";
}
// Output
Return $ OutStringr;
}
}
?>