📄 table.php
字号:
<?php/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: *//** * PEAR::HTML_Table makes the design of HTML tables easy, flexible, reusable and efficient. * * The PEAR::HTML_Table package provides methods for easy and efficient design of HTML tables. * - Lots of customization options. * - Tables can be modified at any time. * - The logic is the same as standard HTML editors. * - Handles col and rowspans. * - PHP code is shorter, easier to read and to maintain. * - Tables options can be reused. * * For auto filling of data and such then check out http://pear.php.net/package/HTML_Table_Matrix * * PHP versions 4 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category HTML * @package HTML_Table * @author Adam Daniel <adaniel1@eesus.jnj.com> * @author Bertrand Mansion <bmansion@mamasam.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Table.php 9611 2006-10-20 11:47:56Z bmol $ * @link http://pear.php.net/package/HTML_Table *//*** Requires PEAR, HTML_Common and HTML_Table_Storage*/require_once 'PEAR.php';require_once 'HTML/Common.php';require_once 'HTML/Table/Storage.php';/** * PEAR::HTML_Table makes the design of HTML tables easy, flexible, reusable and efficient. * * The PEAR::HTML_Table package provides methods for easy and efficient design of HTML tables. * - Lots of customization options. * - Tables can be modified at any time. * - The logic is the same as standard HTML editors. * - Handles col and rowspans. * - PHP code is shorter, easier to read and to maintain. * - Tables options can be reused. * * For auto filling of data and such then check out http://pear.php.net/package/HTML_Table_Matrix * * @category HTML * @package HTML_Table * @author Adam Daniel <adaniel1@eesus.jnj.com> * @author Bertrand Mansion <bmansion@mamasam.com> * @copyright 2005 The PHP Group * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version Release: @package_version@ * @link http://pear.php.net/package/HTML_Table */class HTML_Table extends HTML_Common { /** * Value to insert into empty cells * @var string * @access private */ var $_autoFill = ' '; /** * Array containing the table caption * @var array * @access private */ var $_caption = array(); /** * Array containing the table column group specifications * * @var array * @author Laurent Laville (pear at laurent-laville dot org) * @access private */ var $_colgroup = array(); /** * HTML_Table_Storage object for the (t)head of the table * @var object * @access private */ var $_thead = null; /** * HTML_Table_Storage object for the (t)foot of the table * @var object * @access private */ var $_tfoot = null; /** * HTML_Table_Storage object for the (t)body of the table * @var object * @access private */ var $_tbody = null; /** * Whether to use <thead>, <tfoot> and <tbody> or not * @var bool * @access private */ var $_useTGroups = false; /** * Class constructor * @param array $attributes Associative array of table tag attributes * @param int $tabOffset Tab offset of the table * @param bool $useTGroups Whether to use <thead>, <tfoot> and * <tbody> or not * @access public */ function HTML_Table($attributes = null, $tabOffset = 0, $useTGroups = false) { $commonVersion = 1.7; if (HTML_Common::apiVersion() < $commonVersion) { return PEAR::raiseError('HTML_Table version ' . $this->apiVersion() . ' requires ' . "HTML_Common version $commonVersion or greater.", 0, PEAR_ERROR_TRIGGER); } HTML_Common::HTML_Common($attributes, (int)$tabOffset); $this->_useTGroups = (boolean)$useTGroups; $this->_tbody =& new HTML_Table_Storage($attributes, $tabOffset, $this->_useTGroups); if ($this->_useTGroups) { $this->_thead =& new HTML_Table_Storage($attributes, $tabOffset, $this->_useTGroups); $this->_tfoot =& new HTML_Table_Storage($attributes, $tabOffset, $this->_useTGroups); } } /** * Returns the API version * @access public * @return double */ function apiVersion() { return 1.7; } /** * Returns the HTML_Table_Storage object for <thead> * @access public * @return object */ function &getHeader() { if (is_null($this->_thead)) { $this->_useTGroups = true; $this->_thead =& new HTML_Table_Storage($this->_attributes, $this->_tabOffset, $this->_useTGroups); $this->_tbody->setUseTGroups(true); } return $this->_thead; } /** * Returns the HTML_Table_Storage object for <tfoot> * @access public * @return object */ function &getFooter() { if (is_null($this->_tfoot)) { $this->_useTGroups = true; $this->_tfoot =& new HTML_Table_Storage($this->_attributes, $this->_tabOffset, $this->_useTGroups); $this->_tbody->setUseTGroups(true); } return $this->_tfoot; } /** * Returns the HTML_Table_Storage object for <tbody> * (or the whole table if <t{head|foot|body> is not used) * @access public * @return object */ function &getBody() { return $this->_tbody; } /** * Sets the table caption * @param string $caption * @param mixed $attributes Associative array or string of table row attributes * @access public */ function setCaption($caption, $attributes = null) { $attributes = $this->_parseAttributes($attributes); $this->_caption = array('attr' => $attributes, 'contents' => $caption); } /** * Sets the table columns group specifications, or removes existing ones. * * @param mixed $colgroup (optional) Columns attributes * @param mixed $attributes (optional) Associative array or string * of table row attributes * @author Laurent Laville (pear at laurent-laville dot org) * @access public */ function setColGroup($colgroup = null, $attributes = null) { if (isset($colgroup)) { $attributes = $this->_parseAttributes($attributes); $this->_colgroup[] = array('attr' => $attributes, 'contents' => $colgroup); } else { $this->_colgroup = array(); } } /** * Sets the autoFill value * @param mixed $fill * @access public */ function setAutoFill($fill) { $this->_tbody->setAutoFill($fill); } /** * Returns the autoFill value * @access public * @return mixed */ function getAutoFill() { return $this->_tbody->getAutoFill(); } /** * Sets the autoGrow value * @param bool $fill * @access public */ function setAutoGrow($grow) { $this->_tbody->setAutoGrow($grow); } /** * Returns the autoGrow value * @access public * @return mixed */ function getAutoGrow() { return $this->_tbody->getAutoGrow(); } /** * Sets the number of rows in the table * @param int $rows * @access public */ function setRowCount($rows) { $this->_tbody->setRowCount($rows); } /** * Sets the number of columns in the table * @param int $cols * @access public */ function setColCount($cols) { $this->_tbody->setColCount($cols); } /** * Returns the number of rows in the table * @access public * @return int */ function getRowCount() { return $this->_tbody->getRowCount(); } /** * Gets the number of columns in the table * * If a row index is specified, the count will not take * the spanned cells into account in the return value. * * @param int Row index to serve for cols count * @access public * @return int */ function getColCount($row = null) { return $this->_tbody->getColCount($row); } /** * Sets a rows type 'TH' or 'TD' * @param int $row Row index * @param string $type 'TH' or 'TD' * @access public */ function setRowType($row, $type) { $this->_tbody->setRowType($row, $type); } /** * Sets a columns type 'TH' or 'TD' * @param int $col Column index * @param string $type 'TH' or 'TD' * @access public
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -