From ad005a0cfb526a41d04dd5260df654845ef68f5b Mon Sep 17 00:00:00 2001 From: xue <> Date: Thu, 4 May 2006 13:45:09 +0000 Subject: Added table section support. --- framework/Web/UI/WebControls/TTable.php | 56 +++++++++++++++++++++++- framework/Web/UI/WebControls/TTableFooterRow.php | 48 ++++++++++++++++++++ framework/Web/UI/WebControls/TTableHeaderRow.php | 48 ++++++++++++++++++++ framework/Web/UI/WebControls/TTableRow.php | 20 ++++++++- 4 files changed, 168 insertions(+), 4 deletions(-) create mode 100644 framework/Web/UI/WebControls/TTableFooterRow.php create mode 100644 framework/Web/UI/WebControls/TTableHeaderRow.php (limited to 'framework/Web/UI') diff --git a/framework/Web/UI/WebControls/TTable.php b/framework/Web/UI/WebControls/TTable.php index e7baca02..aaed37df 100644 --- a/framework/Web/UI/WebControls/TTable.php +++ b/framework/Web/UI/WebControls/TTable.php @@ -298,11 +298,63 @@ class TTable extends TWebControl { if($this->getHasControls()) { - $writer->writeLine(); + $renderTableSection=false; foreach($this->getControls() as $row) { - $row->renderControl($writer); + if($row->getTableSection()!=='Body') + { + $renderTableSection=true; + break; + } + } + if($renderTableSection) + { + $currentSection='Header'; + $writer->writeLine(); + foreach($this->getControls() as $index=>$row) + { + if(($section=$row->getTableSection())===$currentSection) + { + if($index===0 && $currentSection==='Header') + $writer->renderBeginTag('thead'); + } + else + { + if($currentSection==='Header') + { + if($index>0) + $writer->renderEndTag(); + if($section==='Body') + $writer->renderBeginTag('tbody'); + else + $writer->renderBeginTag('tfoot'); + $currentSection=$section; + } + else if($currentSection==='Body') + { + $writer->renderEndTag(); + if($section==='Footer') + $writer->renderBeginTag('tfoot'); + else + throw new TConfigurationException('table_tablesection_outoforder'); + $currentSection=$section; + } + else // Footer + throw new TConfigurationException('table_tablesection_outoforder'); + } + $row->renderControl($writer); + $writer->writeLine(); + } + $writer->renderEndTag(); + } + else + { $writer->writeLine(); + foreach($this->getControls() as $row) + { + $row->renderControl($writer); + $writer->writeLine(); + } } } } diff --git a/framework/Web/UI/WebControls/TTableFooterRow.php b/framework/Web/UI/WebControls/TTableFooterRow.php new file mode 100644 index 00000000..3b178d52 --- /dev/null +++ b/framework/Web/UI/WebControls/TTableFooterRow.php @@ -0,0 +1,48 @@ + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + */ + +/** + * Includes TTableRow class. + */ +Prado::using('System.Web.UI.WebControls.TTableRow'); + +/** + * TTableFooterRow class. + * + * TTableFooterRow displays a table footer row. + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.1 + */ +class TTableFooterRow extends TTableRow +{ + /** + * @return string location of a row in a table. Always returns 'Footer'. + */ + public function getTableSection() + { + return 'Footer'; + } + + /** + * @param string location of a row in a table. + * @throws TInvalidOperationException if this method is invoked + */ + public function setTableSection($value) + { + throw new TInvalidOperationException('tablefooterrow_tablesection_readonly'); + } +} + +?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TTableHeaderRow.php b/framework/Web/UI/WebControls/TTableHeaderRow.php new file mode 100644 index 00000000..87e01abd --- /dev/null +++ b/framework/Web/UI/WebControls/TTableHeaderRow.php @@ -0,0 +1,48 @@ + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + */ + +/** + * Includes TTableRow class. + */ +Prado::using('System.Web.UI.WebControls.TTableRow'); + +/** + * TTableHeaderRow class. + * + * TTableHeaderRow displays a table header row. + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0.1 + */ +class TTableHeaderRow extends TTableRow +{ + /** + * @return string location of a row in a table. Always returns 'Header'. + */ + public function getTableSection() + { + return 'Header'; + } + + /** + * @param string location of a row in a table. + * @throws TInvalidOperationException if this method is invoked + */ + public function setTableSection($value) + { + throw new TInvalidOperationException('tableheaderrow_tablesection_readonly'); + } +} + +?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TTableRow.php b/framework/Web/UI/WebControls/TTableRow.php index daf921ce..b0e0bfbe 100644 --- a/framework/Web/UI/WebControls/TTableRow.php +++ b/framework/Web/UI/WebControls/TTableRow.php @@ -11,10 +11,9 @@ */ /** - * Includes TTableCell and TTableHeaderCell classes + * Includes TTableCell class */ Prado::using('System.Web.UI.WebControls.TTableCell'); -Prado::using('System.Web.UI.WebControls.TTableHeaderCell'); /** * TTableRow class. @@ -121,6 +120,23 @@ class TTableRow extends TWebControl $this->getStyle()->setVerticalAlign($value); } + /** + * @return string location of a row in a table. Defaults to 'Body'. + */ + public function getTableSection() + { + return $this->getViewState('TableSection','Body'); + } + + /** + * @param string location of a row in a table. Valid values include 'Header', 'Footer' and 'Body'. + */ + public function setTableSection($value) + { + $value=TPropertyValue::ensureEnum($value,'Header','Body','Footer'); + $this->setViewState('TableSection',$value,'Body'); + } + /** * Renders body contents of the table row * @param THtmlWriter writer for the rendering purpose -- cgit v1.2.3