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. --- .gitattributes | 2 + HISTORY | 1 + framework/Exceptions/messages.txt | 2 + 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 ++++++++- 7 files changed, 173 insertions(+), 4 deletions(-) create mode 100644 framework/Web/UI/WebControls/TTableFooterRow.php create mode 100644 framework/Web/UI/WebControls/TTableHeaderRow.php diff --git a/.gitattributes b/.gitattributes index ad6aeca0..fefa71e7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -823,7 +823,9 @@ framework/Web/UI/WebControls/TStatements.php -text framework/Web/UI/WebControls/TStyle.php -text framework/Web/UI/WebControls/TTable.php -text framework/Web/UI/WebControls/TTableCell.php -text +framework/Web/UI/WebControls/TTableFooterRow.php -text framework/Web/UI/WebControls/TTableHeaderCell.php -text +framework/Web/UI/WebControls/TTableHeaderRow.php -text framework/Web/UI/WebControls/TTableRow.php -text framework/Web/UI/WebControls/TTemplateColumn.php -text framework/Web/UI/WebControls/TTextBox.php -text diff --git a/HISTORY b/HISTORY index 022aa476..7029455d 100644 --- a/HISTORY +++ b/HISTORY @@ -5,6 +5,7 @@ CHG: Ticket#154 - HTML comments are now parsed as regular template strings (Qian ENH: Ticket#151 - added sanity check GET parameters in constructUrl() (Qiang) ENH: Ticket#152 - constituent parts of TWizard are exposed (Qiang) ENH: added sanity check to calling event handlers (Qiang) +NEW: TTableHeaderRow, TTableFooterRow and table section support (Qiang) Version 3.0.0 May 1, 2006 ========================= diff --git a/framework/Exceptions/messages.txt b/framework/Exceptions/messages.txt index 20bafba2..3df84dde 100644 --- a/framework/Exceptions/messages.txt +++ b/framework/Exceptions/messages.txt @@ -270,6 +270,8 @@ view_visible_readonly = TView.Visible is read-only. Use TView.Active to togg wizard_step_invalid = The step to be activated cannot be found in wizard step collection. wizard_command_invalid = Invalid wizard navigation command '{0}'. +table_tablesection_outoforder = TTable table sections must be in the order of: Header, Body and Footer. + completewizardstep_steptype_readonly = TCompleteWizardStep.StepType is read-only. wizardstepcollection_wizardstep_required = TWizardStepCollection can only accept objects of TWizardStep or its derived classes. 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