From c2981557f2112fbf93267058ad7f9c361bf2f180 Mon Sep 17 00:00:00 2001
From: xue <>
Date: Wed, 11 Jan 2006 05:35:34 +0000
Subject: Fixed many issues with DataBoundControls. Added Prado Composer Demo
(not done yet).
---
.gitattributes | 6 +
demos/composer/index.php | 15 ++
demos/composer/protected/pages/Home.page | 75 ++++++++
demos/composer/protected/pages/Home.php | 120 ++++++++++++
demos/composer/protected/pages/Layout.php | 15 ++
demos/composer/protected/pages/Layout.tpl | 24 +++
demos/composer/themes/Simple/style.css | 204 +++++++++++++++++++++
framework/Web/UI/TControl.php | 7 +-
framework/Web/UI/TTemplateManager.php | 5 +-
framework/Web/UI/WebControls/TDataBoundControl.php | 34 ++--
framework/Web/UI/WebControls/TRepeater.php | 2 +-
11 files changed, 487 insertions(+), 20 deletions(-)
create mode 100644 demos/composer/index.php
create mode 100644 demos/composer/protected/pages/Home.page
create mode 100644 demos/composer/protected/pages/Home.php
create mode 100644 demos/composer/protected/pages/Layout.php
create mode 100644 demos/composer/protected/pages/Layout.tpl
create mode 100644 demos/composer/themes/Simple/style.css
diff --git a/.gitattributes b/.gitattributes
index 60de83a6..b0f5bdee 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,4 +1,10 @@
* text=auto !eol
+demos/composer/index.php -text
+demos/composer/protected/pages/Home.page -text
+demos/composer/protected/pages/Home.php -text
+demos/composer/protected/pages/Layout.php -text
+demos/composer/protected/pages/Layout.tpl -text
+demos/composer/themes/Simple/style.css -text
demos/personal/index.php -text
demos/personal/protected/Pages/Home.page -text
demos/personal/protected/Pages/Home.php -text
diff --git a/demos/composer/index.php b/demos/composer/index.php
new file mode 100644
index 00000000..04695b16
--- /dev/null
+++ b/demos/composer/index.php
@@ -0,0 +1,15 @@
+run();
+
+?>
\ No newline at end of file
diff --git a/demos/composer/protected/pages/Home.page b/demos/composer/protected/pages/Home.page
new file mode 100644
index 00000000..648bec21
--- /dev/null
+++ b/demos/composer/protected/pages/Home.page
@@ -0,0 +1,75 @@
+<%@ MasterClass="Application.pages.Layout" Theme="Simple" %>
+
+
+
+class
+extends
+implements
+
+Author Name:
+Author Email:
+
+Comments:
+
+
+
+
+
+ Accessibility |
+ Name |
+ Type |
+ Default Value |
+ Storage Mode |
+ Comments |
+ Actions |
+
+
+
+
+
+ Parent->DataItem->IsProtected %> />
+ Parent->DataItem->ReadOnly %> />
+ |
+
+ Parent->DataItem->Name %> CssClass="slTextBox"/>
+ |
+
+ Parent->DataItem->Type %> >
+
+
+
+
+
+
+ |
+
+ Parent->DataItem->DefaultValue %> CssClass="slTextBox"/>
+ |
+
+ Parent->DataItem->Storage %> >
+
+
+
+
+ |
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+Event Definitions:
+
+
+
+
+
+
+
diff --git a/demos/composer/protected/pages/Home.php b/demos/composer/protected/pages/Home.php
new file mode 100644
index 00000000..a2281828
--- /dev/null
+++ b/demos/composer/protected/pages/Home.php
@@ -0,0 +1,120 @@
+IsPostBack)
+ {
+ $this->Repeater->setDataSource($this->getInitialProperties());
+ $this->Repeater->dataBind();
+ }
+ else
+ $this->Repeater->ensureChildControls();
+ }
+
+ protected function getInitialProperties()
+ {
+ return array(
+ new PropertyDefinition,
+ new PropertyDefinition,
+ new PropertyDefinition,
+ new PropertyDefinition,
+ );
+ }
+
+ public function generateCode($sender,$param)
+ {
+ $code="ClassName->Text." extends ".$this->ParentClass->Text."implements ".$this->Interfaces->Text;
+ $code.="\n";
+ $code.="{\n";
+ $code.="}\n";
+ $code.="?>";
+ $this->SourceCode->Text=htmlentities($code);
+ }
+}
+
+class PropertyDefinition extends TComponent
+{
+ private $_name='';
+ private $_type='string';
+ private $_default='';
+ private $_readOnly=false;
+ private $_protected=false;
+ private $_storage='ViewState';
+ private $_comments='';
+
+ public function getName()
+ {
+ return $this->_name;
+ }
+
+ public function setName($value)
+ {
+ $this->_name=$value;
+ }
+
+ public function getType()
+ {
+ return $this->_type;
+ }
+
+ public function setType($value)
+ {
+ $this->_type=$value;
+ }
+
+ public function getDefaultValue()
+ {
+ return $this->_default;
+ }
+
+ public function setDefaultValue($value)
+ {
+ $this->_default=$value;
+ }
+
+ public function getReadOnly()
+ {
+ return $this->_readOnly;
+ }
+
+ public function setReadOnly($value)
+ {
+ $this->_readOnly=TPropertyValue::ensureBoolean($value);
+ }
+
+ public function getIsProtected()
+ {
+ return $this->_protected;
+ }
+
+ public function setIsProtected($value)
+ {
+ $this->_protected=TPropertyValue::ensureBoolean($value);
+ }
+
+ public function getStorage()
+ {
+ return $this->_storage;
+ }
+
+ public function setStorage($value)
+ {
+ $this->_storage=$value;
+ }
+
+ public function getComments()
+ {
+ return $this->_comments;
+ }
+
+ public function setComments($value)
+ {
+ $this->_comments=$value;
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/demos/composer/protected/pages/Layout.php b/demos/composer/protected/pages/Layout.php
new file mode 100644
index 00000000..a82d2fff
--- /dev/null
+++ b/demos/composer/protected/pages/Layout.php
@@ -0,0 +1,15 @@
+TopicPanel->Visible=!$this->TopicPanel->Visible;
+ if($this->TopicPanel->Visible)
+ $sender->Text="Hide TOC";
+ else
+ $sender->Text="Show TOC";
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/demos/composer/protected/pages/Layout.tpl b/demos/composer/protected/pages/Layout.tpl
new file mode 100644
index 00000000..b72e8959
--- /dev/null
+++ b/demos/composer/protected/pages/Layout.tpl
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/demos/composer/themes/Simple/style.css b/demos/composer/themes/Simple/style.css
new file mode 100644
index 00000000..b036d56d
--- /dev/null
+++ b/demos/composer/themes/Simple/style.css
@@ -0,0 +1,204 @@
+body {
+ font-family: 'Lucida Grande', Verdana, Geneva, Lucida, Helvetica, Arial, sans-serif;
+ font-weight:normal;
+ font-size:10pt;
+ color:black;
+ margin:0px 0px 0px 0px;
+ padding:0px;
+}
+
+h1 {
+ font-size:13pt;
+}
+
+h2 {
+ font-size:12pt;
+}
+
+h3 {
+ font-size:10pt;
+ font-weight:bold;
+}
+
+.slTextBox {
+ border: 0px;
+ border-bottom: 1px solid silver;
+ text-align:center;
+}
+
+#header {
+ font-size:13pt;
+ font-weight:bold;
+ background:#fff;
+ height:40px;
+ padding:5px;
+}
+
+#menu {
+ padding:3px;
+ padding-right:10px;
+ background:#00487D;
+ color:white;
+ text-align:right;
+}
+
+#menu a {
+ color:#BFE4FF;
+ text-decoration:none;
+}
+
+#menu a:hover {
+ color:white;
+}
+
+#toc {
+ background:#BFE4FF;
+ width:200px;
+ padding:5px;
+}
+
+#content {
+ background:#fff;
+ padding:10px;
+}
+
+#footer {
+ clear:both;
+ color: gray;
+ font-size:8pt;
+ text-align:center;
+ margin-top:25px;
+ padding:10px;
+}
+
+.topic {
+ font-size: 10pt;
+ padding: 0px 0px 10px 0px;
+}
+
+.topic span {
+ font-size: 11pt;
+ font-weight:bold;
+ color:#00487D;
+}
+
+.topic a {
+ color:#00487D;
+ padding-left:10px;
+}
+
+.topic a:hover {
+ color:red;
+}
+
+.source {
+ padding: 0.5em;
+ border-style:dotted;
+ border-width:1px;
+ border-color:#cccccc;
+ background-color:#ffffee;
+ font-family: "Courier New", Courier, mono;
+ margin-top: 0.2em;
+ margin-bottom: 0.5em;
+}
+
+.source pre {
+ font-family: "Courier New", Courier, mono;
+ margin: 0;
+}
+
+.runbar a:link, .runbar a:visited {
+ background-color:#BFE4FF;
+ font-size: 12px;
+ font-weight: bold;
+ padding: 3px;
+ padding-left: 6px;
+ padding-right: 6px;
+ border-top: 1px solid white;
+ border-left: 1px solid white;
+ border-bottom: 1px solid #aaaaaa;
+ border-right: 1px solid #aaaaaa;
+ text-decoration: none;
+}
+
+.runbar a:link.active, .runbar a:visited.active, .runbar a:hover {
+ background-color:#BFE4FF;
+ font-size: 12px;
+ font-weight: bold;
+ padding: 3px;
+ padding-left: 6px;
+ padding-right: 6px;
+ border-top: 1px solid #aaaaaa;
+ border-left: 1px solid #aaaaaa;
+ border-bottom: 1px solid white;
+ border-right: 1px solid white;
+}
+
+#sourceList {
+ background-color:#BFE4FF;
+ margin:10px 10px 0px 10px;
+ padding:10px;
+ border:1px solid silver;
+}
+
+#sourceView {
+ font-family: "Courier New", Courier, mono;
+ background-color:#ffffee;
+ margin:5px 10px 10px 10px;
+ border:1px solid silver;
+ padding:10px;
+}
+
+code {
+ font-family: "Courier New", Courier, mono;
+}
+
+tt {
+ font-family: "Courier New", Courier, mono;
+ border-bottom: 1px dotted silver;
+}
+
+.sampleheader {
+ background:#00487D;
+ color:white;
+ padding:3px;
+}
+
+.sampleheader a {
+ color:white;
+}
+
+.samplepanel {
+ margin: 0px;
+ border: 1px solid silver;
+ padding: 10px;
+ margin-bottom:10px;
+}
+
+.sampletitle {
+ width: 100%;
+ border-bottom:1px solid silver;
+ font-weight:bold;
+ margin-bottom:5px;
+}
+
+.sampletable {
+ width: 100%;
+ border-collapse: collapse;
+}
+
+td.samplenote {
+ width: 300px;
+ text-align: right;
+ background: #BFE4FF;
+ border: 1px solid silver;
+ padding: 5px;
+ vertical-align: top;
+}
+
+td.sampleaction {
+ background: #ffffee;
+ border: 1px solid silver;
+ padding: 5px;
+ vertical-align: top;
+}
diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php
index 99af06d1..db0e141b 100644
--- a/framework/Web/UI/TControl.php
+++ b/framework/Web/UI/TControl.php
@@ -958,8 +958,11 @@ class TControl extends TComponent
$control->initRecursive($namingContainer);
if($this->_stage>=self::CS_STATE_LOADED)
{
- if(isset($this->_rf[self::RF_CHILD_STATE]))
- $state=$this->_rf[self::RF_CHILD_STATE]->remove($control->_id);
+ if(isset($this->_rf[self::RF_CHILD_STATE][$control->_id]))
+ {
+ $state=$this->_rf[self::RF_CHILD_STATE][$control->_id];
+ unset($this->_rf[self::RF_CHILD_STATE][$control->_id]);
+ }
else
$state=null;
$control->loadStateRecursive($state,!($this->_flags & self::IS_DISABLE_VIEWSTATE));
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php
index bd838db2..b6a9abd8 100644
--- a/framework/Web/UI/TTemplateManager.php
+++ b/framework/Web/UI/TTemplateManager.php
@@ -231,9 +231,10 @@ class TTemplate extends TComponent implements ITemplate
* @param TControl the parent control
* @throws TTemplateRuntimeException if an error is encountered during the instantiation.
*/
- public function instantiateIn($tplControl)
+ public function instantiateIn($tplControl,$page=null)
{
- $page=$tplControl->getPage();
+ if($page===null)
+ $page=$tplControl->getPage();
$this->_assetManager=$page->getService()->getAssetManager();
$controls=array();
foreach($this->_tpl as $key=>$object)
diff --git a/framework/Web/UI/WebControls/TDataBoundControl.php b/framework/Web/UI/WebControls/TDataBoundControl.php
index d02412e5..7d865e0f 100644
--- a/framework/Web/UI/WebControls/TDataBoundControl.php
+++ b/framework/Web/UI/WebControls/TDataBoundControl.php
@@ -195,10 +195,11 @@ abstract class TDataBoundControl extends TWebControl
// what about property bindings? should they be after data is ready?
$this->setRequiresDataBinding(false);
$this->dataBindProperties();
- $view=$this->getDataSourceView();
- $data=$view->select($this->getSelectParameters());
+ if(($view=$this->getDataSourceView())!==null)
+ $data=$view->select($this->getSelectParameters());
$this->onDataBinding(null);
- $this->performDataBinding($data);
+ if($view!==null)
+ $this->performDataBinding($data);
$this->setIsDataBound(true);
$this->onDataBound(null);
}
@@ -214,13 +215,17 @@ abstract class TDataBoundControl extends TWebControl
if(!$this->_currentViewValid)
{
if($this->_currentView && $this->_currentViewIsFromDataSourceID)
- $handlers=$this->_currentView->detachEventHandler('DataSourceViewChanged',array($this,'dataSourceViewChanged'));
- $dataSource=$this->determineDataSource();
- if(($view=$dataSource->getView($this->getDataMember()))===null)
- throw new TInvalidDataValueException('databoundcontrol_datamember_invalid',$this->getDataMember());
- if($this->_currentViewIsFromDataSourceID=$this->getUsingDataSourceID())
- $view->attachEventHandler('DataSourceViewChanged',array($this,'dataSourceViewChanged'));
- $this->_currentView=$view;
+ $this->_currentView->detachEventHandler('DataSourceViewChanged',array($this,'dataSourceViewChanged'));
+ if(($dataSource=$this->determineDataSource())!==null)
+ {
+ if(($view=$dataSource->getView($this->getDataMember()))===null)
+ throw new TInvalidDataValueException('databoundcontrol_datamember_invalid',$this->getDataMember());
+ if($this->_currentViewIsFromDataSourceID=$this->getUsingDataSourceID())
+ $view->attachEventHandler('DataSourceViewChanged',array($this,'dataSourceViewChanged'));
+ $this->_currentView=$view;
+ }
+ else
+ $this->_currentView=null;
$this->_currentViewValid=true;
}
return $this->_currentView;
@@ -230,8 +235,7 @@ abstract class TDataBoundControl extends TWebControl
{
if(!$this->_currentDataSourceValid)
{
- $dsid=$this->getDataSourceID();
- if($dsid!=='')
+ if(($dsid=$this->getDataSourceID())!=='')
{
if(($dataSource=$this->getNamingContainer()->findControl($dsid))===null)
throw new TInvalidDataValueException('databoundcontrol_datasourceid_inexistent',$dsid);
@@ -240,10 +244,10 @@ abstract class TDataBoundControl extends TWebControl
else
$this->_currentDataSource=$dataSource;
}
+ else if(($dataSource=$this->getDataSource())!==null)
+ $this->_currentDataSource=new TReadOnlyDataSource($dataSource,$this->getDataMember());
else
- {
- $this->_currentDataSource=new TReadOnlyDataSource($this->getDataSource(),$this->getDataMember());
- }
+ $this->_currentDataSource=null;
$this->_currentDataSourceValid=true;
}
return $this->_currentDataSource;
diff --git a/framework/Web/UI/WebControls/TRepeater.php b/framework/Web/UI/WebControls/TRepeater.php
index af82dfe9..5110cc75 100644
--- a/framework/Web/UI/WebControls/TRepeater.php
+++ b/framework/Web/UI/WebControls/TRepeater.php
@@ -227,8 +227,8 @@ class TRepeater extends TDataBoundControl implements INamingContainer
self::$_templates[$key]=$template;
}
}
+ $template->instantiateIn($item,$this->getPage());
$this->getControls()->add($item);
- $template->instantiateIn($item);
}
}
--
cgit v1.2.3