From 6808797813167ac3ea343dfc794c036d95c6d8af Mon Sep 17 00:00:00 2001 From: javalizard <> Date: Sun, 18 Apr 2010 03:32:22 +0000 Subject: ensured that the UI are calling their parent __construct methods --- .../Web/UI/ActiveControls/TActiveRatingList.php | 2 +- framework/Web/UI/ActiveControls/TAutoComplete.php | 1 + .../Web/UI/ActiveControls/TBaseActiveControl.php | 3 +- .../UI/ActiveControls/TCallbackClientScript.php | 1 + .../UI/ActiveControls/TCallbackEventParameter.php | 3 +- .../UI/ActiveControls/TCallbackResponseAdapter.php | 1 + framework/Web/UI/ActiveControls/TDropContainer.php | 1 + framework/Web/UI/TClientScriptManager.php | 2 + framework/Web/UI/TControlAdapter.php | 3 +- framework/Web/UI/THtmlWriter.php | 3 +- framework/Web/UI/TPage.php | 136 ++++++++++++++++++++- framework/Web/UI/TTemplateManager.php | 1 + framework/Web/UI/TThemeManager.php | 1 + 13 files changed, 149 insertions(+), 9 deletions(-) (limited to 'framework/Web') diff --git a/framework/Web/UI/ActiveControls/TActiveRatingList.php b/framework/Web/UI/ActiveControls/TActiveRatingList.php index 473ca06a..cee1bcd4 100644 --- a/framework/Web/UI/ActiveControls/TActiveRatingList.php +++ b/framework/Web/UI/ActiveControls/TActiveRatingList.php @@ -31,9 +31,9 @@ class TActiveRatingList extends TRatingList implements IActiveControl, ICallback */ public function __construct() { + parent::__construct(); $this->setAdapter(new TActiveListControlAdapter($this)); $this->setAutoPostBack(true); - parent::__construct(); } /** diff --git a/framework/Web/UI/ActiveControls/TAutoComplete.php b/framework/Web/UI/ActiveControls/TAutoComplete.php index 2ae01d2b..f5977a01 100644 --- a/framework/Web/UI/ActiveControls/TAutoComplete.php +++ b/framework/Web/UI/ActiveControls/TAutoComplete.php @@ -425,6 +425,7 @@ class TAutoCompleteTemplate extends TComponent implements ITemplate public function __construct($template) { + parent::__construct(); $this->_template = $template; } /** diff --git a/framework/Web/UI/ActiveControls/TBaseActiveControl.php b/framework/Web/UI/ActiveControls/TBaseActiveControl.php index 92dd3194..2afec4d1 100644 --- a/framework/Web/UI/ActiveControls/TBaseActiveControl.php +++ b/framework/Web/UI/ActiveControls/TBaseActiveControl.php @@ -4,7 +4,7 @@ * * @author Wei Zhuo * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2010 PradoSoft * @license http://www.pradosoft.com/license/ * @version $Id$ * @package System.Web.UI.ActiveControls @@ -44,6 +44,7 @@ class TBaseActiveControl extends TComponent */ public function __construct($control) { + parent::__construct(); $this->_control = $control; $this->_options = new TMap; } diff --git a/framework/Web/UI/ActiveControls/TCallbackClientScript.php b/framework/Web/UI/ActiveControls/TCallbackClientScript.php index d35e89a0..220b5323 100644 --- a/framework/Web/UI/ActiveControls/TCallbackClientScript.php +++ b/framework/Web/UI/ActiveControls/TCallbackClientScript.php @@ -44,6 +44,7 @@ class TCallbackClientScript extends TApplicationComponent */ public function __construct() { + parent::__construct(); $this->_actions = new TList; } diff --git a/framework/Web/UI/ActiveControls/TCallbackEventParameter.php b/framework/Web/UI/ActiveControls/TCallbackEventParameter.php index f08d40a9..060c4431 100644 --- a/framework/Web/UI/ActiveControls/TCallbackEventParameter.php +++ b/framework/Web/UI/ActiveControls/TCallbackEventParameter.php @@ -4,7 +4,7 @@ * * @author Wei Zhuo * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2010 PradoSoft * @license http://www.pradosoft.com/license/ * @version $Id$ * @package System.Web.UI.ActiveControls @@ -48,6 +48,7 @@ class TCallbackEventParameter extends TEventParameter */ public function __construct($response, $parameter) { + parent::__construct(); $this->_response = $response; $this->_parameter = $parameter; } diff --git a/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php b/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php index 6425b123..32e93a86 100755 --- a/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php +++ b/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php @@ -126,6 +126,7 @@ class TCallbackResponseWriter extends TTextWriter */ public function __construct() { + parent::__construct(); $this->_boundary = sprintf('%x',crc32(microtime())); } diff --git a/framework/Web/UI/ActiveControls/TDropContainer.php b/framework/Web/UI/ActiveControls/TDropContainer.php index cb0c4cc1..b9981033 100755 --- a/framework/Web/UI/ActiveControls/TDropContainer.php +++ b/framework/Web/UI/ActiveControls/TDropContainer.php @@ -265,6 +265,7 @@ class TDropContainerEventParameter extends TEventParameter public function __construct($dropParams) { + parent::__construct(); $this->_dragElementId = $dropParams->DragElementID; $this->_screenX = $dropParams->ScreenX; $this->_screenY = $dropParams->ScreenY; diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php index 200bcba5..f6be8217 100644 --- a/framework/Web/UI/TClientScriptManager.php +++ b/framework/Web/UI/TClientScriptManager.php @@ -88,6 +88,7 @@ class TClientScriptManager extends TApplicationComponent */ public function __construct(TPage $owner) { + parent::__construct(); $this->_page=$owner; } @@ -695,6 +696,7 @@ abstract class TClientSideOptions extends TComponent */ public function __construct() { + parent::__construct(); $this->_options = Prado::createComponent('System.Collections.TMap'); } diff --git a/framework/Web/UI/TControlAdapter.php b/framework/Web/UI/TControlAdapter.php index 16a8c839..b59da59c 100644 --- a/framework/Web/UI/TControlAdapter.php +++ b/framework/Web/UI/TControlAdapter.php @@ -4,7 +4,7 @@ * * @author Qiang Xue * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2010 PradoSoft * @license http://www.pradosoft.com/license/ * @version $Id$ * @package System.Web.UI @@ -34,6 +34,7 @@ class TControlAdapter extends TApplicationComponent */ public function __construct($control) { + parent::__construct(); $this->_control=$control; } diff --git a/framework/Web/UI/THtmlWriter.php b/framework/Web/UI/THtmlWriter.php index 9713d941..a8ac08a0 100644 --- a/framework/Web/UI/THtmlWriter.php +++ b/framework/Web/UI/THtmlWriter.php @@ -4,7 +4,7 @@ * * @author Qiang Xue * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2010 PradoSoft * @license http://www.pradosoft.com/license/ * @version $Id$ * @package System.Web.UI @@ -108,6 +108,7 @@ class THtmlWriter extends TApplicationComponent implements ITextWriter */ public function __construct($writer) { + parent::__construct(); $this->_writer=$writer; } diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php index 51c66b88..05da940e 100644 --- a/framework/Web/UI/TPage.php +++ b/framework/Web/UI/TPage.php @@ -22,7 +22,6 @@ Prado::using('System.Web.UI.TClientScriptManager'); * TPage class * * @author Qiang Xue - * @author Brad Anderson * @version $Id$ * @package System.Web.UI * @since 3.0 @@ -51,13 +50,21 @@ class TPage extends TTemplateControl implements IPageEvents 'PRADO_CALLBACK_PARAMETER'=>true ); /** - * @var TForm form instance + * @var THtml html instance */ - private $_form; + private $_html; /** * @var THead head instance */ private $_head; + /** + * @var TBody body instance + */ + private $_body; + /** + * @var TForm form instance + */ + private $_form; /** * @var array list of registered validators */ @@ -70,6 +77,10 @@ class TPage extends TTemplateControl implements IPageEvents * @var TTheme page theme */ private $_theme; + /** + * @var collection of all the skins + */ + private $_skincontrols = array(); /** * @var string page title set when Head is not in page yet */ @@ -567,8 +578,11 @@ class TPage extends TTemplateControl implements IPageEvents */ public function applyControlSkin($control) { - if(($theme=$this->getTheme())!==null) + if(($theme=$this->getTheme())!==null) { $theme->applySkin($control); + if($control->SkinID) + $this->registerSkin($control); + } } /** @@ -998,6 +1012,48 @@ class TPage extends TTemplateControl implements IPageEvents $this->_enableJavaScript=TPropertyValue::ensureBoolean($value); } + /** + * @return THtml, null if not available + */ + public function getHtml() + { + return $this->_html; + } + + /** + * @param THead page head + * @throws TInvalidOperationException if a head already exists + */ + public function setHtml(THtml $value) + { + if($this->_html===null) + $this->_html = $value; + else + throw new TInvalidOperationException('page_body_duplicated'); + } + + /** + * @return TBody the body on the page + */ + public function getBody() + { + return $this->_body; + } + + /** + * Registers the TBody instance on the page. + * Note, a page can contain at most one TBody instance. + * @param TBody the form on the page + * @throws TInvalidOperationException if this method is invoked more than once. + */ + public function setBody(TBody $body) + { + if($this->_body===null) + $this->_body=$body; + else + throw new TInvalidOperationException('page_body_duplicated'); + } + /** * @return THead page head, null if not available */ @@ -1190,6 +1246,78 @@ class TPage extends TTemplateControl implements IPageEvents } } + /** + * Registers a controls skin id with the page. This function links the control to its skin on the page for access. + * @param TControl the object to register the skinid + */ + protected function registerSkin($control) + { + $id = $control->SkinID; + if(!$id) return; + + if(!is_array($this->_skincontrols)) + $this->_skincontrols = array(); + + if(!isset($this->_skincontrols[$id])) + $this->_skincontrols[$id] = array(); + + $this->_skincontrols[$id][] = $control; + } + + /** + * This gets a control based on its SkinId. If there are multiple controls with the same skin, + * you can give this method the second parameter for an index into all the controls with that + * skin id. This will return the first one if and index is not specifiec + * @param string $skinid the skin to look for within the page + * @param index $index the index of the skin if there are many of the same name, defaults to 0 or the first + */ + public function getSkinControl($skinid, $index = 0) + { + if(isset($this->_skincontrols[$skinid][$index])) + return $this->_skincontrols[$skinid][$index]; + } + + /** + * This gets a control based on its SkinId. If there are multiple controls with the same skin, + * you can give this method the second parameter for an index into all the controls with that + * skin id. This will return the first one if and index is not specifiec + * @param string $skinid the skin to look for within the page + */ + public function getSkinControls($skinid) + { + if(isset($this->_skincontrols[$skinid])) + return $this->_skincontrols[$skinid]; + } + + /** + * Return the count of the skins with that id + * @param integer $skinid the skin to look for within the page + */ + public function getSkinControlCount($skinid) + { + if(isset($this->_skincontrols[$skinid])) + return count($this->_skincontrols[$skinid]); + } + public function getSkinControlsByType($skinid, $type) + { + $result = array(); + if(isset($this->_skincontrols[$skinid])) + foreach($this->_skincontrols[$skinid] as $ctl) + if($ctl instanceof $type) + $result[] = $ctl; + + return $result; + } + + public function getSkinControlByType($skinid, $type, $index = 0) + { + if(isset($this->_skincontrols[$skinid])) + foreach($this->_skincontrols[$skinid] as $ctl) + if(($ctl instanceof $type) && $index--) + return $ctl; + } + + /** * @return TStack stack of {@link TOutputCache} objects */ diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php index 01694300..6994d665 100644 --- a/framework/Web/UI/TTemplateManager.php +++ b/framework/Web/UI/TTemplateManager.php @@ -239,6 +239,7 @@ class TTemplate extends TApplicationComponent implements ITemplate */ public function __construct($template,$contextPath,$tplFile=null,$startingLine=0,$sourceTemplate=true) { + parent::__construct(); $this->_sourceTemplate=$sourceTemplate; $this->_contextPath=$contextPath; $this->_tplFile=$tplFile; diff --git a/framework/Web/UI/TThemeManager.php b/framework/Web/UI/TThemeManager.php index 410976c4..59b794ce 100644 --- a/framework/Web/UI/TThemeManager.php +++ b/framework/Web/UI/TThemeManager.php @@ -229,6 +229,7 @@ class TTheme extends TApplicationComponent implements ITheme */ public function __construct($themePath,$themeUrl) { + parent::__construct(); $this->_themeUrl=$themeUrl; $this->_themePath=realpath($themePath); $this->_name=basename($themePath); -- cgit v1.2.3