summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorxue <>2006-05-04 13:45:09 +0000
committerxue <>2006-05-04 13:45:09 +0000
commitad005a0cfb526a41d04dd5260df654845ef68f5b (patch)
tree393ebcc8313e9bffef64c06406553c12348f80ff /framework
parent49ccf41324a2c87b20b84f72355b79d92d6f3d0c (diff)
Added table section support.
Diffstat (limited to 'framework')
-rw-r--r--framework/Exceptions/messages.txt2
-rw-r--r--framework/Web/UI/WebControls/TTable.php56
-rw-r--r--framework/Web/UI/WebControls/TTableFooterRow.php48
-rw-r--r--framework/Web/UI/WebControls/TTableHeaderRow.php48
-rw-r--r--framework/Web/UI/WebControls/TTableRow.php20
5 files changed, 170 insertions, 4 deletions
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 @@
+<?php
+/**
+ * TTableFooterRow class file
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 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 <qiang.xue@gmail.com>
+ * @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 @@
+<?php
+/**
+ * TTableHeaderRow class file
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 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 <qiang.xue@gmail.com>
+ * @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.
@@ -122,6 +121,23 @@ class TTableRow extends TWebControl
}
/**
+ * @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
*/