summaryrefslogtreecommitdiff
path: root/framework/Web/UI
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/UI')
-rw-r--r--framework/Web/UI/TCompositeControl.php39
-rw-r--r--framework/Web/UI/TPage.php1
-rw-r--r--framework/Web/UI/TTemplateControl.php7
-rw-r--r--framework/Web/UI/WebControls/TDataGrid.php93
-rw-r--r--framework/Web/UI/WebControls/TRepeatInfo.php8
-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
9 files changed, 309 insertions, 11 deletions
diff --git a/framework/Web/UI/TCompositeControl.php b/framework/Web/UI/TCompositeControl.php
new file mode 100644
index 00000000..4e33bb83
--- /dev/null
+++ b/framework/Web/UI/TCompositeControl.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * TCompositeControl 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
+ */
+
+/**
+ * TCompositeControl class.
+ * TCompositeControl is the base class for controls that are composed
+ * by other controls.
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @version $Revision: $ $Date: $
+ * @package System.Web.UI
+ * @since 3.0
+ */
+class TCompositeControl extends TControl implements INamingContainer
+{
+ /**
+ * Performs the OnInit step for the control and all its child controls.
+ * This method overrides the parent implementation
+ * by ensuring child controls are created first.
+ * Only framework developers should use this method.
+ * @param TControl the naming container control
+ */
+ protected function initRecursive($namingContainer=null)
+ {
+ $this->ensureChildControls();
+ parent::initRecursive($namingContainer);
+ }
+}
+
+?> \ No newline at end of file
diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php
index 598fb9dc..94f1f475 100644
--- a/framework/Web/UI/TPage.php
+++ b/framework/Web/UI/TPage.php
@@ -13,6 +13,7 @@
Prado::using('System.Web.UI.WebControls.*');
Prado::using('System.Web.UI.TControl');
Prado::using('System.Web.UI.WebControls.TWebControl');
+Prado::using('System.Web.UI.TCompositeControl');
Prado::using('System.Web.UI.TTemplateControl');
Prado::using('System.Web.UI.TForm');
Prado::using('System.Web.UI.TClientScriptManager');
diff --git a/framework/Web/UI/TTemplateControl.php b/framework/Web/UI/TTemplateControl.php
index f18678f1..0595a9e5 100644
--- a/framework/Web/UI/TTemplateControl.php
+++ b/framework/Web/UI/TTemplateControl.php
@@ -11,6 +11,11 @@
*/
/**
+ * Includes TCompositeControl class
+ */
+Prado::using('System.Web.UI.TCompositeControl');
+
+/**
* TTemplateControl class.
* TTemplateControl is the base class for all controls that use templates.
* By default, a control template is assumed to be in a file under the same
@@ -22,7 +27,7 @@
* @package System.Web.UI
* @since 3.0
*/
-class TTemplateControl extends TControl implements INamingContainer
+class TTemplateControl extends TCompositeControl
{
/**
* template file extension.
diff --git a/framework/Web/UI/WebControls/TDataGrid.php b/framework/Web/UI/WebControls/TDataGrid.php
index 55b12ebc..6ff6faba 100644
--- a/framework/Web/UI/WebControls/TDataGrid.php
+++ b/framework/Web/UI/WebControls/TDataGrid.php
@@ -357,6 +357,39 @@ class TDataGrid extends TBaseDataList implements INamingContainer
}
/**
+ * @return string caption for the datagrid
+ */
+ public function getCaption()
+ {
+ return $this->getViewState('Caption','');
+ }
+
+ /**
+ * @param string caption for the datagrid
+ */
+ public function setCaption($value)
+ {
+ $this->setViewState('Caption',$value,'');
+ }
+
+ /**
+ * @return string datagrid caption alignment. Defaults to 'NotSet'.
+ */
+ public function getCaptionAlign()
+ {
+ return $this->getViewState('CaptionAlign','NotSet');
+ }
+
+ /**
+ * @param string datagrid caption alignment. Valid values include
+ * 'NotSet','Top','Bottom','Left','Right'.
+ */
+ public function setCaptionAlign($value)
+ {
+ $this->setViewState('CaptionAlign',TPropertyValue::ensureEnum($value,'NotSet','Top','Bottom','Left','Right'),'NotSet');
+ }
+
+ /**
* @return TDataGridItem the header item
*/
public function getHeader()
@@ -1444,6 +1477,23 @@ class TDataGrid extends TBaseDataList implements INamingContainer
}
/**
+ * Renders the openning tag for the datagrid control which will render table caption if present.
+ * @param THtmlWriter the writer used for the rendering purpose
+ */
+ public function renderBeginTag($writer)
+ {
+ parent::renderBeginTag($writer);
+ if(($caption=$this->getCaption())!=='')
+ {
+ if(($align=$this->getCaptionAlign())!=='NotSet')
+ $writer->addAttribute('align',strtolower($align));
+ $writer->renderBeginTag('caption');
+ $writer->write($caption);
+ $writer->renderEndTag();
+ }
+ }
+
+ /**
* Renders the datagrid.
* @param THtmlWriter writer for the rendering purpose
*/
@@ -1457,12 +1507,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer
$this->_topPager->renderControl($writer);
$writer->writeLine();
}
- $this->renderBeginTag($writer);
- $this->_header->renderControl($writer);
- foreach($this->getItems() as $item)
- $item->renderControl($writer);
- $this->_footer->renderControl($writer);
- $this->renderEndTag($writer);
+ $this->renderTable($writer);
if($this->_bottomPager)
{
$writer->writeLine();
@@ -1470,6 +1515,38 @@ class TDataGrid extends TBaseDataList implements INamingContainer
}
}
}
+
+ /**
+ * Renders the tabular data.
+ * @param THtmlWriter writer
+ */
+ protected function renderTable($writer)
+ {
+ $this->renderBeginTag($writer);
+ if($this->_header->getVisible())
+ {
+ $writer->writeLine();
+ $writer->renderBeginTag('thead');
+ $this->_header->render($writer);
+ $writer->renderEndTag();
+ }
+ $writer->writeLine();
+ $writer->renderBeginTag('tbody');
+ foreach($this->getItems() as $item)
+ $item->renderControl($writer);
+ $writer->renderEndTag();
+
+ if($this->_footer->getVisible())
+ {
+ $writer->writeLine();
+ $writer->renderBeginTag('tfoot');
+ $this->_footer->render($writer);
+ $writer->renderEndTag();
+ }
+
+ $writer->writeLine();
+ $this->renderEndTag($writer);
+ }
}
/**
@@ -1758,6 +1835,10 @@ class TDataGridItem extends TTableRow implements INamingContainer
$this->_itemIndex=$itemIndex;
$this->_dataSourceIndex=$dataSourceIndex;
$this->setItemType($itemType);
+ if($itemType===TDataGrid::IT_HEADER)
+ $this->setTableSection('Header');
+ else if($itemType===TDataGrid::IT_FOOTER)
+ $this->setTableSection('Footer');
}
/**
diff --git a/framework/Web/UI/WebControls/TRepeatInfo.php b/framework/Web/UI/WebControls/TRepeatInfo.php
index 10c49691..81b82c33 100644
--- a/framework/Web/UI/WebControls/TRepeatInfo.php
+++ b/framework/Web/UI/WebControls/TRepeatInfo.php
@@ -261,6 +261,7 @@ class TRepeatInfo extends TComponent
// render items
if($tableLayout)
{
+ $writer->renderBeginTag('tbody');
$column=0;
for($i=0;$i<$itemCount;++$i)
{
@@ -297,6 +298,7 @@ class TRepeatInfo extends TComponent
$column=0;
}
}
+ $writer->renderEndTag();
}
else
{
@@ -353,6 +355,7 @@ class TRepeatInfo extends TComponent
if($tableLayout)
{
+ $writer->renderBeginTag('tbody');
$renderedItems=0;
for($row=0;$row<$rows;++$row)
{
@@ -407,6 +410,7 @@ class TRepeatInfo extends TComponent
$writer->renderEndTag();
$writer->writeLine();
}
+ $writer->renderEndTag();
}
else
{
@@ -461,6 +465,7 @@ class TRepeatInfo extends TComponent
{
if($tableLayout)
{
+ $writer->renderBeginTag('thead');
$writer->renderBeginTag('tr');
if($columns>1)
$writer->addAttribute('colspan',"$columns");
@@ -471,6 +476,7 @@ class TRepeatInfo extends TComponent
$user->renderItem($writer,$this,'Header',-1);
$writer->renderEndTag();
$writer->renderEndTag();
+ $writer->renderEndTag();
}
else
{
@@ -492,6 +498,7 @@ class TRepeatInfo extends TComponent
{
if($tableLayout)
{
+ $writer->renderBeginTag('tfoot');
$writer->renderBeginTag('tr');
if($columns>1)
$writer->addAttribute('colspan',"$columns");
@@ -501,6 +508,7 @@ class TRepeatInfo extends TComponent
$user->renderItem($writer,$this,'Footer',-1);
$writer->renderEndTag();
$writer->renderEndTag();
+ $writer->renderEndTag();
}
else
$user->renderItem($writer,$this,'Footer',-1);
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
*/