📄 common.php
字号:
<?php/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: *//** * Contains the Pager_Common class * * PHP versions 4 and 5 * * LICENSE: Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @category HTML * @package Pager * @author Lorenzo Alberton <l dot alberton at quipo dot it> * @author Richard Heyes <richard@phpguru.org> * @copyright 2003-2006 Lorenzo Alberton, Richard Heyes * @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) * @version CVS: $Id: Common.php 12273 2007-05-03 14:49:21Z elixir_julian $ * @link http://pear.php.net/package/Pager *//** * Two constants used to guess the path- and file-name of the page * when the user doesn't set any other value */if (substr(api_get_self(), -1) == '/') { define('CURRENT_FILENAME', ''); define('CURRENT_PATHNAME', 'http://'.$_SERVER['HTTP_HOST'].str_replace('\\', '/', api_get_self()));} else { define('CURRENT_FILENAME', preg_replace('/(.*)\?.*/', '\\1', basename(api_get_self()))); define('CURRENT_PATHNAME', str_replace('\\', '/', dirname(api_get_self())));}/** * Error codes */define('PAGER_OK', 0);define('ERROR_PAGER', -1);define('ERROR_PAGER_INVALID', -2);define('ERROR_PAGER_INVALID_PLACEHOLDER', -3);define('ERROR_PAGER_INVALID_USAGE', -4);define('ERROR_PAGER_NOT_IMPLEMENTED', -5);/** * Pager_Common - Common base class for [Sliding|Jumping] Window Pager * Extend this class to write a custom paging class * * @category HTML * @package Pager * @author Lorenzo Alberton <l dot alberton at quipo dot it> * @author Richard Heyes <richard@phpguru.org> * @copyright 2003-2005 Lorenzo Alberton, Richard Heyes * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @link http://pear.php.net/package/Pager */class Pager_Common{ // {{{ class vars /** * @var integer number of items * @access private */ var $_totalItems; /** * @var integer number of items per page * @access private */ var $_perPage = 10; /** * @var integer number of page links for each window * @access private */ var $_delta = 10; /** * @var integer current page number * @access private */ var $_currentPage = 1; /** * @var integer total pages number * @access private */ var $_totalPages = 1; /** * @var string CSS class for links * @access private */ var $_linkClass = ''; /** * @var string wrapper for CSS class name * @access private */ var $_classString = ''; /** * @var string path name * @access private */ var $_path = CURRENT_PATHNAME; /** * @var string file name * @access private */ var $_fileName = CURRENT_FILENAME; /** * @var boolean If false, don't override the fileName option. Use at your own risk. * @access private */ var $_fixFileName = true; /** * @var boolean you have to use FALSE with mod_rewrite * @access private */ var $_append = true; /** * @var string specifies which HTTP method to use * @access private */ var $_httpMethod = 'GET'; /** * @var string specifies which HTML form to use * @access private */ var $_formID = ''; /** * @var boolean whether or not to import submitted data * @access private */ var $_importQuery = true; /** * @var string name of the querystring var for pageID * @access private */ var $_urlVar = 'pageID'; /** * @var array data to pass through the link * @access private */ var $_linkData = array(); /** * @var array additional URL vars * @access private */ var $_extraVars = array(); /** * @var array URL vars to ignore * @access private */ var $_excludeVars = array(); /** * @var boolean TRUE => expanded mode (for Pager_Sliding) * @access private */ var $_expanded = true; /** * @var boolean TRUE => show accesskey attribute on <a> tags * @access private */ var $_accesskey = false; /** * @var string extra attributes for the <a> tag * @access private */ var $_attributes = ''; /** * @var string alt text for "first page" (use "%d" placeholder for page number) * @access private */ var $_altFirst = 'first page'; /** * @var string alt text for "previous page" * @access private */ var $_altPrev = 'previous page'; /** * @var string alt text for "next page" * @access private */ var $_altNext = 'next page'; /** * @var string alt text for "last page" (use "%d" placeholder for page number) * @access private */ var $_altLast = 'last page'; /** * @var string alt text for "page" * @access private */ var $_altPage = 'page'; /** * @var string image/text to use as "prev" link * @access private */ var $_prevImg = '<< Back'; /** * @var string image/text to use as "next" link * @access private */ var $_nextImg = 'Next >>'; /** * @var string link separator * @access private */ var $_separator = ''; /** * @var integer number of spaces before separator * @access private */ var $_spacesBeforeSeparator = 0; /** * @var integer number of spaces after separator * @access private */ var $_spacesAfterSeparator = 1; /** * @var string CSS class name for current page link * @access private */ var $_curPageLinkClassName = ''; /** * @var string Text before current page link * @access private */ var $_curPageSpanPre = ''; /** * @var string Text after current page link * @access private */ var $_curPageSpanPost = ''; /** * @var string Text before first page link * @access private */ var $_firstPagePre = '['; /** * @var string Text to be used for first page link * @access private */ var $_firstPageText = ''; /** * @var string Text after first page link * @access private */ var $_firstPagePost = ']'; /** * @var string Text before last page link * @access private */ var $_lastPagePre = '['; /** * @var string Text to be used for last page link * @access private */ var $_lastPageText = ''; /** * @var string Text after last page link * @access private */ var $_lastPagePost = ']'; /** * @var string Will contain the HTML code for the spaces * @access private */ var $_spacesBefore = ''; /** * @var string Will contain the HTML code for the spaces * @access private */ var $_spacesAfter = ''; /** * @var string $_firstLinkTitle * @access private */ var $_firstLinkTitle = 'first page'; /** * @var string $_nextLinkTitle * @access private */ var $_nextLinkTitle = 'next page'; /** * @var string $_prevLinkTitle * @access private */ var $_prevLinkTitle = 'previous page'; /** * @var string $_lastLinkTitle * @access private */ var $_lastLinkTitle = 'last page'; /** * @var string Text to be used for the 'show all' option in the select box * @access private */ var $_showAllText = ''; /** * @var array data to be paged * @access private */ var $_itemData = null; /** * @var boolean If TRUE and there's only one page, links aren't shown * @access private */ var $_clearIfVoid = true; /** * @var boolean Use session for storing the number of items per page * @access private */ var $_useSessions = false; /** * @var boolean Close the session when finished reading/writing data * @access private */ var $_closeSession = false; /** * @var string name of the session var for number of items per page * @access private */ var $_sessionVar = 'setPerPage'; /** * Pear error mode (when raiseError is called) * (see PEAR doc) * * @var int $_pearErrorMode * @access private */ var $_pearErrorMode = null; // }}} // {{{ public vars /** * @var string Complete set of links * @access public */ var $links = ''; /** * @var string Complete set of link tags * @access public */ var $linkTags = ''; /** * @var array Array with a key => value pair representing * page# => bool value (true if key==currentPageNumber). * can be used for extreme customization. * @access public */ var $range = array(); /** * @var array list of available options (safety check) * @access private */ var $_allowed_options = array( 'totalItems', 'perPage', 'delta', 'linkClass', 'path', 'fileName', 'fixFileName', 'append', 'httpMethod', 'formID', 'importQuery', 'urlVar', 'altFirst', 'altPrev', 'altNext', 'altLast', 'altPage', 'prevImg', 'nextImg', 'expanded', 'accesskey', 'attributes', 'separator', 'spacesBeforeSeparator', 'spacesAfterSeparator', 'curPageLinkClassName', 'curPageSpanPre', 'curPageSpanPost', 'firstPagePre', 'firstPageText', 'firstPagePost', 'lastPagePre', 'lastPageText', 'lastPagePost', 'firstLinkTitle', 'nextLinkTitle', 'prevLinkTitle', 'lastLinkTitle', 'showAllText', 'itemData', 'clearIfVoid', 'useSessions', 'closeSession', 'sessionVar', 'pearErrorMode', 'extraVars', 'excludeVars', 'currentPage', ); // }}} // {{{ build() /** * Generate or refresh the links and paged data after a call to setOptions() * * @access public */ function build() { $msg = '<b>PEAR::Pager Error:</b>' .' function "build()" not implemented.'; return $this->raiseError($msg, ERROR_PAGER_NOT_IMPLEMENTED); } // }}} // {{{ getPageData() /** * Returns an array of current pages data * * @param $pageID Desired page ID (optional) * @return array Page data * @access public */ function getPageData($pageID = null) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -