diff options
| -rw-r--r-- | .gitattributes | 6 | ||||
| -rw-r--r-- | demos/composer/index.php | 15 | ||||
| -rw-r--r-- | demos/composer/protected/pages/Home.page | 75 | ||||
| -rw-r--r-- | demos/composer/protected/pages/Home.php | 120 | ||||
| -rw-r--r-- | demos/composer/protected/pages/Layout.php | 15 | ||||
| -rw-r--r-- | demos/composer/protected/pages/Layout.tpl | 24 | ||||
| -rw-r--r-- | demos/composer/themes/Simple/style.css | 204 | ||||
| -rw-r--r-- | framework/Web/UI/TControl.php | 7 | ||||
| -rw-r--r-- | framework/Web/UI/TTemplateManager.php | 5 | ||||
| -rw-r--r-- | framework/Web/UI/WebControls/TDataBoundControl.php | 34 | ||||
| -rw-r--r-- | framework/Web/UI/WebControls/TRepeater.php | 2 | 
11 files changed, 487 insertions, 20 deletions
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 @@ +<?php
 +
 +$basePath=dirname(__FILE__);
 +$frameworkPath=$basePath.'/../../framework/prado.php';
 +$assetsPath=$basePath.'/assets';
 +
 +if(!is_writable($assetsPath))
 +	die("Please make sure that the directory $assetsPath is writable by Web server process.");
 +
 +require_once($frameworkPath);
 +
 +$application=new TApplication;
 +$application->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" %>
 +<com:TContent ID="body" >
 +
 +<com:TPanel GroupingText="Class Information">
 +class <com:TTextBox ID="ClassName" CssClass="slTextBox"/>
 +extends <com:TTextBox ID="ParentClass" CssClass="slTextBox"/>
 +implements <com:TTextBox ID="Interfaces" CssClass="slTextBox"/>
 +<br/>
 +Author Name: <com:TTextBox ID="AuthorName" CssClass="slTextBox"/>
 +Author Email: <com:TTextBox ID="AuthorEmail" CssClass="slTextBox"/>
 +<br/>
 +Comments: <com:TTextBox ID="Comments" TextMode="MultiLine"/>
 +</com:TPanel>
 +
 +<com:TPanel GroupingText="Property Definitions">
 +<table>
 +<tr>
 +  <th>Accessibility</th>
 +  <th>Name</th>
 +  <th>Type</th>
 +  <th>Default Value</th>
 +  <th>Storage Mode</th>
 +  <th>Comments</th>
 +  <th>Actions</th>
 +</tr>
 +<com:TRepeater ID="Repeater">
 +<prop:ItemTemplate>
 +<tr>
 +  <td>
 +  <com:TCheckBox ID="IsProtected" Text="protected" Checked=<%# $this->Parent->DataItem->IsProtected %> />
 +  <com:TCheckBox ID="ReadOnly" Text="read-only" Checked=<%# $this->Parent->DataItem->ReadOnly %> />
 +  </td>
 +  <td>
 +  <com:TTextBox ID="PropertyName" Text=<%# $this->Parent->DataItem->Name %> CssClass="slTextBox"/>
 +  </td>
 +  <td>
 +  <com:TDropDownList ID="PropertyType" SelectedValue=<%# $this->Parent->DataItem->Type %> >
 +    <com:TListItem Text="string" />
 +    <com:TListItem Text="integer" />
 +    <com:TListItem Text="boolean" />
 +    <com:TListItem Text="enumerable" />
 +    <com:TListItem Text="mixed" />
 +  </com:TDropDownList>
 +  </td>
 +  <td>
 +  <com:TTextBox ID="DefaultValue" Text=<%# $this->Parent->DataItem->DefaultValue %> CssClass="slTextBox"/>
 +  </td>
 +  <td>
 +  <com:TDropDownList ID="Storage" SelectedValue=<%# $this->Parent->DataItem->Storage %> >
 +    <com:TListItem Text="ViewState" />
 +    <com:TListItem Text="ControlState" />
 +    <com:TListItem Text="Memory" />
 +  </com:TDropDownList>
 +  </td>
 +  <td>
 +  <com:TTextBox ID="Comments" Text=<%# $this->Parent->DataItem->Comments %> CssClass="slTextBox"/>
 +  </td>
 +  <td>
 +  <com:TButton Text="Add" />
 +  <com:TButton Text="Remove" />
 +  </td>
 +</tr>
 +</prop:ItemTemplate>
 +</com:TRepeater>
 +</table>
 +</com:TPanel>
 +<com:TPanel GroupingText="Event Definitions">
 +Event Definitions:
 +</com:TPanel>
 +<com:TButton Text="Generate Code" Click="generateCode" />
 +<pre>
 +<com:TLiteral ID="SourceCode" />
 +</pre>
 +
 +</com:TContent>
 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 @@ +<?php
 +
 +class Home extends TPage
 +{
 +	public function onLoad($param)
 +	{
 +		parent::onLoad($param);
 +		if(!$this->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="<?php\n\n";
 +		$code.="class ".$this->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 @@ +<?php
 +
 +class Layout extends TTemplateControl
 +{
 +	public function toggleTopicPanel($sender,$param)
 +	{
 +		$this->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 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
 +
 +<com:THead Title="PRADO Composer">
 +<meta http-equiv="content-language" content="en"/>
 +</com:THead>
 +
 +<body>
 +<com:TForm>
 +<div id="header">
 +Prado Composer (Component Writer)
 +</div>
 +
 +<div id="content" width="100%">
 +<com:TContentPlaceHolder ID="body" />
 +</div>
 +
 +<div id="footer">
 +Copyright © 2006 <a href="http://www.pradosoft.com">PradoSoft</a>.
 +</div>
 +
 +</com:TForm>
 +</body>
 +</html>
\ 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);
  		}
  	}
  | 
