From c53ef254ccc2959f5f6d9bf6fff26071fc57368e Mon Sep 17 00:00:00 2001 From: "ctrlaltca@gmail.com" <> Date: Mon, 5 Dec 2011 16:30:49 +0000 Subject: reverted r2801, r2803, r2829's madness. --- framework/Web/Services/TPageService.php | 185 +------------------------------- framework/Web/UI/TPage.php | 97 ++++------------- 2 files changed, 24 insertions(+), 258 deletions(-) (limited to 'framework/Web') diff --git a/framework/Web/Services/TPageService.php b/framework/Web/Services/TPageService.php index a9b74724..d9467864 100644 --- a/framework/Web/Services/TPageService.php +++ b/framework/Web/Services/TPageService.php @@ -68,18 +68,13 @@ Prado::using('System.Web.UI.TThemeManager'); * The first matching rule will be used. The last rule always allows all users * accessing to any resources. * - * The TPageService replicates the {@link TPage} events through {@link IPageEvents}. - * When the TPage is run, the TPageService events attach to all the corresponding TPage - * events. This allows modules to handle page events. - * * @author Qiang Xue * @author Carl G. Mathisen - * @author Brad Anderson * @version $Id$ * @package System.Web.Services * @since 3.0 */ -class TPageService extends TService implements IPageEvents +class TPageService extends TService { /** * Configuration file name @@ -146,11 +141,7 @@ class TPageService extends TService implements IPageEvents * @var TTemplateManager template manager */ private $_templateManager=null; - /** - * @var boolean if the onPageNotFound event is specifically blocked - */ - private $_blockOnPageNotFound = false; - + /** * Initializes the service. * This method is required by IService interface and is invoked by application. @@ -397,29 +388,6 @@ class TPageService extends TService implements IPageEvents { return $this->constructUrl($this->getDefaultPage()); } - - /** - * This event is triggered when a 404 in the normal page tree hierarchy is generated - * @param mixed $sender - * @param mixed $param - */ - public function onPageNotFound($sender, $param) { - } - - /** - * @return boolean whether the onPageNotFound event is blocked - */ - public function getBlockOnPageNotFoundEvent() { return $this->_blockOnPageNotFound; } - - /** - * For security reasons, you may want to turn off the onPageNotFound event. For instance, - * if your website has a "maintenence mode" where the website is offline and want to ensure - * that modules cannot use this event and provide content when they shouldn't be. - * @param boolean whether the onPageNotFound event is blocked - */ - public function setBlockOnPageNotFoundEvent($v) { - $this->_blockOnPageNotFound = TPropertyValue::ensureBoolean($v); - } /** * @return string the root directory for storing pages. Defaults to the 'pages' directory under the application base path. @@ -505,25 +473,18 @@ class TPageService extends TService implements IPageEvents /** * Creates a page instance based on requested page path. * @param string requested page path - * @param (boolean|null) can specify if this is allowed to call onPageNotFound if no page is found; defaults to true. * @return TPage the requested page instance * @throws THttpException if requested page path is invalid * @throws TConfigurationException if the page class cannot be found */ - protected function createPage($pagePath, $doOnPageNotFound = true) + protected function createPage($pagePath) { $path=$this->getBasePath().DIRECTORY_SEPARATOR.strtr($pagePath,'.',DIRECTORY_SEPARATOR); $hasTemplateFile=is_file($path.self::PAGE_FILE_EXT); $hasClassFile=is_file($path.Prado::CLASS_FILE_EXT); - if(!$hasTemplateFile && !$hasClassFile) { - $param = new TPageNotFoundEventParameter($pagePath); - if(!$this->BlockOnPageNotFoundEvent && $doOnPageNotFound) - $this->raiseEvent('onPageNotFound', $this, $param); - if(!$param->FoundPage) - throw new THttpException(404,'pageservice_page_unknown',$pagePath); - return $param->FoundPage; - } + if(!$hasTemplateFile && !$hasClassFile) + throw new THttpException(404,'pageservice_page_unknown',$pagePath); if($hasClassFile) { @@ -560,19 +521,6 @@ class TPageService extends TService implements IPageEvents { foreach($properties as $name=>$value) $page->setSubProperty($name,$value); - - $page->OnDataBinding[] = array($this, 'OnDataBinding'); - $page->OnPreInit[] = array($this, 'OnPreInit'); - $page->OnInit[] = array($this, 'OnInit'); - $page->OnInitComplete[] = array($this, 'OnInitComplete'); - $page->OnPreLoad[] = array($this, 'OnPreLoad'); - $page->OnLoad[] = array($this, 'OnLoad'); - $page->OnLoadComplete[] = array($this, 'OnLoadComplete'); - $page->OnPreRender[] = array($this, 'OnPreRender'); - $page->OnPreRenderComplete[] = array($this, 'OnPreRenderComplete'); - $page->OnSaveStateComplete[] = array($this, 'OnSaveStateComplete'); - $page->OnUnload[] = array($this, 'OnUnload'); - $page->run($this->getResponse()->createHtmlWriter()); } @@ -588,129 +536,6 @@ class TPageService extends TService implements IPageEvents { return $this->getRequest()->constructUrl($this->getID(),$pagePath,$getParams,$encodeAmpersand,$encodeGetItems); } - - - /** - * Raises 'OnDataBinding' event. (inherited from TControl) - */ - public function onDataBinding($param) { - Prado::trace("onDataBinding",'System.Web.Services.TPageService'); - $this->raiseEvent('OnDataBinding',$this,$param); - } - /** - * This method is invoked when the control enters 'OnInit' stage. (inherited from TControl) - */ - public function onInit($param) { - Prado::trace("onInit",'System.Web.Services.TPageService'); - $this->raiseEvent('OnInit',$this,$param); - } - /** - * Raises OnInitComplete event. - */ - public function onInitComplete($param) { - Prado::trace("onInitComplete",'System.Web.Services.TPageService'); - $this->raiseEvent('OnInitComplete',$this,$param); - } - /** - * This method is invoked when the control enters 'OnLoad' stage. (inherited from TControl) - */ - public function onLoad($param) { - Prado::trace("OnLoad",'System.Web.Services.TPageService'); - $this->raiseEvent('OnLoad',$this,$param); - } - /** - * Raises OnLoadComplete event. - */ - public function onLoadComplete($param) { - Prado::trace("OnLoadComplete",'System.Web.Services.TPageService'); - $this->raiseEvent('OnLoadComplete',$this,$param); - } - /** - * Raises OnPreInit event. - */ - public function onPreInit($param) { - Prado::trace("OnPreInit",'System.Web.Services.TPageService'); - $this->raiseEvent('OnPreInit',$this,$param); - } - /** - * Raises OnPreLoad event. - */ - public function onPreLoad($param) { - Prado::trace("OnPreLoad",'System.Web.Services.TPageService'); - $this->raiseEvent('OnPreLoad',$this,$param); - } - /** - * This method is invoked when the control enters 'OnPreRender' stage. (inherited from TControl) - */ - public function onPreRender($param) { - Prado::trace("OnPreRender",'System.Web.Services.TPageService'); - $this->raiseEvent('OnPreRender',$this,$param); - } - /** - * Raises OnPreRenderComplete event. - */ - public function onPreRenderComplete($param) { - Prado::trace("OnPreRenderComplete",'System.Web.Services.TPageService'); - $this->raiseEvent('OnPreRenderComplete',$this,$param); - } - /** - * Raises OnSaveStateComplete event. - */ - public function onSaveStateComplete($param) { - Prado::trace("OnSaveStateComplete",'System.Web.Services.TPageService'); - $this->raiseEvent('OnSaveStateComplete',$this,$param); - } - /** - * This method is invoked when the control enters 'OnUnload' stage. (inherited from TControl) - */ - public function onUnload($param) { - Prado::trace("OnUnload",'System.Web.Services.TPageService'); - $this->raiseEvent('OnUnload',$this,$param); - } -} - - - -/** - * TPageNotFoundEventParameter class. - * TPageNotFoundEventParameter is the parameter sent when no page is found and the code is allowed to call the onPageNotFound. - * - * @author Brad Anderson - * @version $Id$ - * @package System.Web.Services - * @since 3.2a - */ -class TPageNotFoundEventParameter extends TEventParameter { - - private $_foundpage; - private $_path; - - /** - * Holds the parameters for the Class Behavior Events - * @param string $class this is the class to get the behavior - * @param string $name the name of the behavior - * @param object $behavior this is the behavior to implement the class behavior - */ - public function __construct($path) { - $this->_path = $path; - } - - /** - * This is the path of the page to be found - * @return string the page path to find - */ - public function getPath() { return $this->_path; } - - /** - * the found TPage, if found - * @return string the name to get the behavior - */ - public function getFoundPage() { return $this->_foundpage; } - - /** - * This sets the found page - */ - public function setFoundPage($value) { $this->_foundpage = $value; } } diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php index 6b49b99c..a681667d 100644 --- a/framework/Web/UI/TPage.php +++ b/framework/Web/UI/TPage.php @@ -22,12 +22,11 @@ Prado::using('System.Web.UI.TClientScriptManager'); * TPage class * * @author Qiang Xue - * @author Brad Anderson * @version $Id$ * @package System.Web.UI * @since 3.0 */ -class TPage extends TTemplateControl implements IPageEvents +class TPage extends TTemplateControl { /** * system post fields @@ -209,30 +208,30 @@ class TPage extends TTemplateControl implements IPageEvents protected function processNormalRequest($writer) { Prado::trace("Page onPreInit()",'System.Web.UI.TPage'); - $this->onPreInit($this); + $this->onPreInit(null); Prado::trace("Page initRecursive()",'System.Web.UI.TPage'); $this->initRecursive(); Prado::trace("Page onInitComplete()",'System.Web.UI.TPage'); - $this->onInitComplete($this); + $this->onInitComplete(null); Prado::trace("Page onPreLoad()",'System.Web.UI.TPage'); - $this->onPreLoad($this); + $this->onPreLoad(null); Prado::trace("Page loadRecursive()",'System.Web.UI.TPage'); $this->loadRecursive(); Prado::trace("Page onLoadComplete()",'System.Web.UI.TPage'); - $this->onLoadComplete($this); + $this->onLoadComplete(null); Prado::trace("Page preRenderRecursive()",'System.Web.UI.TPage'); $this->preRenderRecursive(); Prado::trace("Page onPreRenderComplete()",'System.Web.UI.TPage'); - $this->onPreRenderComplete($this); + $this->onPreRenderComplete(null); Prado::trace("Page savePageState()",'System.Web.UI.TPage'); $this->savePageState(); Prado::trace("Page onSaveStateComplete()",'System.Web.UI.TPage'); - $this->onSaveStateComplete($this); + $this->onSaveStateComplete(null); Prado::trace("Page renderControl()",'System.Web.UI.TPage'); $this->renderControl($writer); @@ -243,13 +242,13 @@ class TPage extends TTemplateControl implements IPageEvents protected function processPostBackRequest($writer) { Prado::trace("Page onPreInit()",'System.Web.UI.TPage'); - $this->onPreInit($this); + $this->onPreInit(null); Prado::trace("Page initRecursive()",'System.Web.UI.TPage'); $this->initRecursive(); Prado::trace("Page onInitComplete()",'System.Web.UI.TPage'); - $this->onInitComplete($this); + $this->onInitComplete(null); $this->_restPostData=new TMap; Prado::trace("Page loadPageState()",'System.Web.UI.TPage'); @@ -257,7 +256,7 @@ class TPage extends TTemplateControl implements IPageEvents Prado::trace("Page processPostData()",'System.Web.UI.TPage'); $this->processPostData($this->_postData,true); Prado::trace("Page onPreLoad()",'System.Web.UI.TPage'); - $this->onPreLoad($this); + $this->onPreLoad(null); Prado::trace("Page loadRecursive()",'System.Web.UI.TPage'); $this->loadRecursive(); Prado::trace("Page processPostData()",'System.Web.UI.TPage'); @@ -267,17 +266,17 @@ class TPage extends TTemplateControl implements IPageEvents Prado::trace("Page raisePostBackEvent()",'System.Web.UI.TPage'); $this->raisePostBackEvent(); Prado::trace("Page onLoadComplete()",'System.Web.UI.TPage'); - $this->onLoadComplete($this); + $this->onLoadComplete(null); Prado::trace("Page preRenderRecursive()",'System.Web.UI.TPage'); $this->preRenderRecursive(); Prado::trace("Page onPreRenderComplete()",'System.Web.UI.TPage'); - $this->onPreRenderComplete($this); + $this->onPreRenderComplete(null); Prado::trace("Page savePageState()",'System.Web.UI.TPage'); $this->savePageState(); Prado::trace("Page onSaveStateComplete()",'System.Web.UI.TPage'); - $this->onSaveStateComplete($this); + $this->onSaveStateComplete(null); Prado::trace("Page renderControl()",'System.Web.UI.TPage'); $this->renderControl($writer); @@ -302,13 +301,13 @@ class TPage extends TTemplateControl implements IPageEvents $this->_postData[$k]=iconv('UTF-8',$enc.'//IGNORE',$v); Prado::trace("Page onPreInit()",'System.Web.UI.TPage'); - $this->onPreInit($this); + $this->onPreInit(null); Prado::trace("Page initRecursive()",'System.Web.UI.TPage'); $this->initRecursive(); Prado::trace("Page onInitComplete()",'System.Web.UI.TPage'); - $this->onInitComplete($this); + $this->onInitComplete(null); $this->_restPostData=new TMap; Prado::trace("Page loadPageState()",'System.Web.UI.TPage'); @@ -316,7 +315,7 @@ class TPage extends TTemplateControl implements IPageEvents Prado::trace("Page processPostData()",'System.Web.UI.TPage'); $this->processPostData($this->_postData,true); Prado::trace("Page onPreLoad()",'System.Web.UI.TPage'); - $this->onPreLoad($this); + $this->onPreLoad(null); Prado::trace("Page loadRecursive()",'System.Web.UI.TPage'); $this->loadRecursive(); @@ -334,17 +333,17 @@ class TPage extends TTemplateControl implements IPageEvents $this->raisePostBackEvent(); */ Prado::trace("Page onLoadComplete()",'System.Web.UI.TPage'); - $this->onLoadComplete($this); + $this->onLoadComplete(null); Prado::trace("Page preRenderRecursive()",'System.Web.UI.TPage'); $this->preRenderRecursive(); Prado::trace("Page onPreRenderComplete()",'System.Web.UI.TPage'); - $this->onPreRenderComplete($this); + $this->onPreRenderComplete(null); Prado::trace("Page savePageState()",'System.Web.UI.TPage'); $this->savePageState(); Prado::trace("Page onSaveStateComplete()",'System.Web.UI.TPage'); - $this->onSaveStateComplete($this); + $this->onSaveStateComplete(null); /* Prado::trace("Page renderControl()",'System.Web.UI.TPage'); @@ -1225,64 +1224,6 @@ class TPage extends TTemplateControl implements IPageEvents } } - -/** - * IPageEvents interface. - * - * IPageEvents interface has all the events a page uses during its life cycle. - * - * @author Brad Anderson - * @version $Id$ - * @package System.Web.UI - * @since 3.2 - */ -interface IPageEvents { - /** - * Raises 'OnDataBinding' event. (inherited from TControl) - */ - public function onDataBinding($param); - /** - * This method is invoked when the control enters 'OnInit' stage. (inherited from TControl) - */ - public function onInit($param); - /** - * Raises OnInitComplete event. - */ - public function onInitComplete($param); - /** - * This method is invoked when the control enters 'OnLoad' stage. (inherited from TControl) - */ - public function onLoad($param); - /** - * Raises OnLoadComplete event. - */ - public function onLoadComplete($param); - /** - * Raises OnPreInit event. - */ - public function onPreInit($param); - /** - * Raises OnPreLoad event. - */ - public function onPreLoad($param); - /** - * This method is invoked when the control enters 'OnPreRender' stage. (inherited from TControl) - */ - public function onPreRender($param); - /** - * Raises OnPreRenderComplete event. - */ - public function onPreRenderComplete($param); - /** - * Raises OnSaveStateComplete event. - */ - public function onSaveStateComplete($param); - /** - * This method is invoked when the control enters 'OnUnload' stage. (inherited from TControl) - */ - public function onUnload($param); -} - /** * IPageStatePersister interface. * -- cgit v1.2.3