diff options
author | xue <> | 2006-05-04 03:02:44 +0000 |
---|---|---|
committer | xue <> | 2006-05-04 03:02:44 +0000 |
commit | 27478826035da62e1cba07833101b162558f895a (patch) | |
tree | f202993add7c7b5f9992407234dd5272d2267cff /framework | |
parent | bdae204aaf0d47a284dd19fad52cacef4a4afa46 (diff) |
Merge from 3.0 branch till 1016.
Diffstat (limited to 'framework')
-rw-r--r-- | framework/TComponent.php | 5 | ||||
-rw-r--r-- | framework/Web/TAssetManager.php | 3 | ||||
-rw-r--r-- | framework/Web/THttpRequest.php | 14 | ||||
-rw-r--r-- | framework/Web/UI/TTemplateManager.php | 64 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TTable.php | 56 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TTableRow.php | 62 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TWizard.php | 58 |
7 files changed, 146 insertions, 116 deletions
diff --git a/framework/TComponent.php b/framework/TComponent.php index 99907e4d..64854692 100644 --- a/framework/TComponent.php +++ b/framework/TComponent.php @@ -360,7 +360,10 @@ class TComponent $object=$this->getSubProperty(substr($method,0,$pos));
$method=substr($method,$pos+1);
}
- $object->$method($sender,$param);
+ if(method_exists($object,$method))
+ $object->$method($sender,$param);
+ else
+ throw new TInvalidDataValueException('component_eventhandler_invalid',get_class($this),$name);
}
}
else
diff --git a/framework/Web/TAssetManager.php b/framework/Web/TAssetManager.php index 5600c4ab..f3ebe7c3 100644 --- a/framework/Web/TAssetManager.php +++ b/framework/Web/TAssetManager.php @@ -213,6 +213,7 @@ class TAssetManager extends TModule * File modification time is used to ensure the copied files are latest.
* @param string the source directory
* @param string the destination directory
+ * @todo a generic solution to ignore certain directories and files
*/
protected function copyDirectory($src,$dst)
{
@@ -221,7 +222,7 @@ class TAssetManager extends TModule $folder=@opendir($src);
while($file=@readdir($folder))
{
- if($file==='.' || $file==='..')
+ if($file==='.' || $file==='..' || $file==='.svn')
continue;
else if(is_file($src.'/'.$file))
{
diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php index 71237fa1..9b06076e 100644 --- a/framework/Web/THttpRequest.php +++ b/framework/Web/THttpRequest.php @@ -460,9 +460,12 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar {
$name=urlencode($name.'[]');
foreach($value as $v)
- $url.=$amp.$name.'='.$v;
+ {
+ if(($v=trim($v))!=='')
+ $url.=$amp.$name.'='.$v;
+ }
}
- else
+ else if(($value=trim($value))!=='')
$url.=$amp.urlencode($name).'='.urlencode($value);
}
}
@@ -473,9 +476,12 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar if(is_array($value))
{
foreach($value as $v)
- $url.=$amp.$name.'[]='.$v;
+ {
+ if(($v=trim($v))!=='')
+ $url.=$amp.$name.'[]='.$v;
+ }
}
- else
+ else if(($value=trim($value))!=='')
$url.=$amp.$name.'='.$value;
}
}
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php index eac7c157..b29466ad 100644 --- a/framework/Web/UI/TTemplateManager.php +++ b/framework/Web/UI/TTemplateManager.php @@ -132,9 +132,7 @@ class TTemplateManager extends TModule * - directive: directive specifies the property values for the template owner.
* It is in the format of <% property name-value pairs %>
* - expressions: They are in the formate of <= PHP expression > and <% PHP statements >
- * - comments: There are two kinds of comments, regular HTML comments and special template comments.
- * The former is in the format of <!-- comments -->, which will be treated as text strings.
- * The latter is in the format of <%* comments %>, which will be stripped out.
+ * - comments: Special template comments enclosed within <!-- comments --!> will be stripped out.
*
* Tags other than the above are not required to be well-formed.
*
@@ -152,13 +150,12 @@ class TTemplate extends TApplicationComponent implements ITemplate {
/**
* '<!--.*?--!>' - template comments
- * '<!--.*?-->' - HTML comments
* '<\/?com:([\w\.]+)((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?"|\s*[\w\.]+=<%.*?%>)*)\s*\/?>' - component tags
* '<\/?prop:([\w\.]+)\s*>' - property tags
* '<%@\s*((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?")*)\s*%>' - directives
* '<%[%#~\\$=\\[](.*?)%>' - expressions
*/
- const REGEX_RULES='/<!--.*?--!>|<!--.*?-->|<\/?com:([\w\.]+)((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?"|\s*[\w\.]+=<%.*?%>)*)\s*\/?>|<\/?prop:([\w\.]+)\s*>|<%@\s*((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?")*)\s*%>|<%[%#~\\$=\\[](.*?)%>/msS';
+ const REGEX_RULES='/<!--.*?--!>|<\/?com:([\w\.]+)((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?"|\s*[\w\.]+=<%.*?%>)*)\s*\/?>|<\/?prop:([\w\.]+)\s*>|<%@\s*((?:\s*[\w\.]+=\'.*?\'|\s*[\w\.]+=".*?")*)\s*%>|<%[%#~\\$=\\[](.*?)%>/msS';
/**
* Different configurations of component property/event/attribute
@@ -280,6 +277,7 @@ class TTemplate extends TApplicationComponent implements ITemplate if(($page=$tplControl->getPage())===null)
$page=$this->getService()->getRequestedPage();
$controls=array();
+ $directChildren=array();
foreach($this->_tpl as $key=>$object)
{
if($object[0]===-1)
@@ -315,7 +313,10 @@ class TTemplate extends TApplicationComponent implements ITemplate // apply attributes
foreach($properties as $name=>$value)
$this->configureControl($component,$name,$value);
- $component->createdOnTemplate($parent);
+ if($parent===$tplControl)
+ $directChildren[]=$component;
+ else
+ $component->createdOnTemplate($parent);
if($component->getAllowChildControls())
$controls[$key]=$component;
}
@@ -331,20 +332,45 @@ class TTemplate extends TApplicationComponent implements ITemplate }
foreach($properties as $name=>$value)
$this->configureComponent($component,$name,$value);
- $parent->addParsedObject($component);
+ if($parent===$tplControl)
+ $directChildren[]=$component;
+ else
+ $parent->addParsedObject($component);
}
}
- else if(is_string($object[1]))
- $parent->addParsedObject($object[1]);
else if($object[1] instanceof TCompositeLiteral)
{
- $o=clone $object[1];
- $o->setContainer($tplControl);
- $parent->addParsedObject($o);
+ if($object[1] instanceof TCompositeLiteral)
+ {
+ // need to clone a new object because the one in template is reused
+ $o=clone $object[1];
+ $o->setContainer($tplControl);
+ if($parent===$tplControl)
+ $directChildren[]=$o;
+ else
+ $parent->addParsedObject($o);
+ }
+ else
+ {
+ if($parent===$tplControl)
+ $directChildren[]=$object[1];
+ else
+ $parent->addParsedObject($object[1]);
+ }
}
else
throw new TConfigurationException('template_content_unexpected',(string)$object[1]);
}
+ // delay setting parent till now because the parent may cause
+ // the child to do lifecycle catchup which may cause problem
+ // if the child needs its own child controls.
+ foreach($directChildren as $control)
+ {
+ if($control instanceof TControl)
+ $control->createdOnTemplate($tplControl);
+ else
+ $tplControl->addParsedObject($control);
+ }
}
/**
@@ -640,15 +666,11 @@ class TTemplate extends TApplicationComponent implements ITemplate }
else if(strpos($str,'<!--')===0) // comments
{
- if(strrpos($str,'--!>')===strlen($str)-4) // template comments
- {
- if($expectPropEnd)
- throw new TConfigurationException('template_comments_forbidden');
- if($matchStart>$textStart)
- $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
- $textStart=$matchEnd+1;
- }
- // else, HTML comments and we do nothing
+ if($expectPropEnd)
+ throw new TConfigurationException('template_comments_forbidden');
+ if($matchStart>$textStart)
+ $tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
+ $textStart=$matchEnd+1;
}
else
throw new TConfigurationException('template_matching_unexpected',$match);
diff --git a/framework/Web/UI/WebControls/TTable.php b/framework/Web/UI/WebControls/TTable.php index 4fcbb6fb..e7baca02 100644 --- a/framework/Web/UI/WebControls/TTable.php +++ b/framework/Web/UI/WebControls/TTable.php @@ -124,13 +124,21 @@ class TTable extends TWebControl }
/**
- * @return TTableRowCollection list of {@link TTableRow} controls
+ * Creates a control collection object that is to be used to hold child controls
+ * @return TTableRowCollection control collection
+ * @see getControls
+ */
+ protected function createControlCollection()
+ {
+ return new TTableRowCollection($this);
+ }
+
+ /**
+ * @return TTableCellCollection list of {@link TTableCell} controls
*/
public function getRows()
{
- if(!$this->_rows)
- $this->_rows=new TTableRowCollection($this);
- return $this->_rows;
+ return $this->getControls();
}
/**
@@ -288,10 +296,10 @@ class TTable extends TWebControl */
public function renderContents($writer)
{
- if($this->_rows)
+ if($this->getHasControls())
{
$writer->writeLine();
- foreach($this->_rows as $row)
+ foreach($this->getControls() as $row)
{
$row->renderControl($writer);
$writer->writeLine();
@@ -300,6 +308,7 @@ class TTable extends TWebControl }
}
+
/**
* TTableRowCollection class.
*
@@ -310,23 +319,9 @@ class TTable extends TWebControl * @package System.Web.UI.WebControls
* @since 3.0
*/
-class TTableRowCollection extends TList
+class TTableRowCollection extends TControlCollection
{
/**
- * @var mixed row collection owner
- */
- private $_owner=null;
-
- /**
- * Constructor.
- * @param mixed row collection owner
- */
- public function __construct($owner=null)
- {
- $this->_owner=$owner;
- }
-
- /**
* Inserts an item at the specified position.
* This overrides the parent implementation by performing additional
* operations for each newly added table row.
@@ -337,29 +332,10 @@ class TTableRowCollection extends TList public function insertAt($index,$item)
{
if($item instanceof TTableRow)
- {
parent::insertAt($index,$item);
- if($this->_owner)
- $this->_owner->getControls()->insertAt($index,$item);
- }
else
throw new TInvalidDataTypeException('tablerowcollection_tablerow_required');
}
-
- /**
- * Removes an item at the specified position.
- * This overrides the parent implementation by performing additional
- * cleanup work when removing a table row.
- * @param integer the index of the item to be removed.
- * @return mixed the removed item.
- */
- public function removeAt($index)
- {
- $item=parent::removeAt($index);
- if($item instanceof TTableRow)
- $this->_owner->getControls()->remove($item);
- return $item;
- }
}
?>
\ No newline at end of file diff --git a/framework/Web/UI/WebControls/TTableRow.php b/framework/Web/UI/WebControls/TTableRow.php index 6a3f196a..daf921ce 100644 --- a/framework/Web/UI/WebControls/TTableRow.php +++ b/framework/Web/UI/WebControls/TTableRow.php @@ -32,11 +32,6 @@ Prado::using('System.Web.UI.WebControls.TTableHeaderCell'); class TTableRow extends TWebControl
{
/**
- * @var TTableCellCollection cell collection
- */
- private $_cells=null;
-
- /**
* @return string tag name for the table
*/
protected function getTagName()
@@ -67,13 +62,21 @@ class TTableRow extends TWebControl }
/**
+ * Creates a control collection object that is to be used to hold child controls
+ * @return TTableCellCollection control collection
+ * @see getControls
+ */
+ protected function createControlCollection()
+ {
+ return new TTableCellCollection($this);
+ }
+
+ /**
* @return TTableCellCollection list of {@link TTableCell} controls
*/
public function getCells()
{
- if(!$this->_cells)
- $this->_cells=new TTableCellCollection($this);
- return $this->_cells;
+ return $this->getControls();
}
/**
@@ -124,10 +127,10 @@ class TTableRow extends TWebControl */
public function renderContents($writer)
{
- if($this->_cells)
+ if($this->getHasControls())
{
$writer->writeLine();
- foreach($this->_cells as $cell)
+ foreach($this->getControls() as $cell)
{
$cell->renderControl($writer);
$writer->writeLine();
@@ -136,8 +139,6 @@ class TTableRow extends TWebControl }
}
-
-
/**
* TTableCellCollection class.
*
@@ -148,24 +149,9 @@ class TTableRow extends TWebControl * @package System.Web.UI.WebControls
* @since 3.0
*/
-class TTableCellCollection extends TList
+class TTableCellCollection extends TControlCollection
{
/**
- * @var mixed cell collection owner
- */
- private $_owner=null;
-
- /**
- * Constructor.
- * @param mixed cell collection owner
- */
- public function __construct($owner=null)
- {
- $this->_owner=$owner;
- }
-
-
- /**
* Inserts an item at the specified position.
* This overrides the parent implementation by performing additional
* operations for each newly added table cell.
@@ -176,28 +162,10 @@ class TTableCellCollection extends TList public function insertAt($index,$item)
{
if($item instanceof TTableCell)
- {
parent::insertAt($index,$item);
- if($this->_owner)
- $this->_owner->getControls()->insertAt($index,$item);
- }
else
throw new TInvalidDataTypeException('tablecellcollection_tablecell_required');
}
-
- /**
- * Removes an item at the specified position.
- * This overrides the parent implementation by performing additional
- * cleanup work when removing a table cell.
- * @param integer the index of the item to be removed.
- * @return mixed the removed item.
- */
- public function removeAt($index)
- {
- $item=parent::removeAt($index);
- if($item instanceof TTableCell)
- $this->_owner->getControls()->remove($item);
- return $item;
- }
}
+
?>
\ No newline at end of file diff --git a/framework/Web/UI/WebControls/TWizard.php b/framework/Web/UI/WebControls/TWizard.php index 20e27f2b..2d2815ba 100644 --- a/framework/Web/UI/WebControls/TWizard.php +++ b/framework/Web/UI/WebControls/TWizard.php @@ -598,6 +598,54 @@ class TWizard extends TWebControl implements INamingContainer }
/**
+ * @return TPanel container of the wizard header
+ */
+ public function getHeader()
+ {
+ return $this->_header;
+ }
+
+ /**
+ * @return TPanel container of the wizard step content
+ */
+ public function getStepContent()
+ {
+ return $this->_stepContent;
+ }
+
+ /**
+ * @return TPanel container of the wizard side bar
+ */
+ public function getSideBar()
+ {
+ return $this->_sideBar;
+ }
+
+ /**
+ * @var TWizardNavigationContainer container of the start navigation
+ */
+ public function getStartNavigation()
+ {
+ return $this->_startNavigation;
+ }
+
+ /**
+ * @var TWizardNavigationContainer container of the step navigation
+ */
+ public function getStepNavigation()
+ {
+ return $this->_stepNavigation;
+ }
+
+ /**
+ * @var TWizardNavigationContainer container of the finish navigation
+ */
+ public function getFinishNavigation()
+ {
+ return $this->_finishNavigation;
+ }
+
+ /**
* Raises <b>OnActiveStepChanged</b> event.
* This event is raised when the current visible step is changed in the
* wizard.
@@ -845,8 +893,13 @@ class TWizard extends TWebControl implements INamingContainer $activeStep=$this->getActiveStep();
$activeStepIndex=$this->getActiveStepIndex();
- if(!$this->_navigation || $activeStepIndex<0 || $activeStepIndex>=$wizardSteps->getCount())
+ if(!$this->_navigation)
+ return;
+ else if($activeStepIndex<0 || $activeStepIndex>=$wizardSteps->getCount())
+ {
+ $this->_navigation->setVisible(false);
return;
+ }
// set visibility of different types of navigation panel
$showStandard=true;
@@ -1135,7 +1188,8 @@ class TWizard extends TWebControl implements INamingContainer $this->_stepContent=new TPanel;
$this->_stepContent->getControls()->add($multiView);
$this->getControls()->add($this->_stepContent);
- $multiView->setActiveViewIndex(0);
+ if($multiView->getViews()->getCount())
+ $multiView->setActiveViewIndex(0);
}
/**
|