diff options
Diffstat (limited to 'framework')
-rw-r--r-- | framework/TApplication.php | 49 | ||||
-rw-r--r-- | framework/Web/Services/TPageService.php | 185 | ||||
-rw-r--r-- | framework/Web/UI/TPage.php | 97 |
3 files changed, 26 insertions, 305 deletions
diff --git a/framework/TApplication.php b/framework/TApplication.php index acfb8d2a..ff99d33e 100644 --- a/framework/TApplication.php +++ b/framework/TApplication.php @@ -76,8 +76,7 @@ Prado::using('System.I18N.TGlobalization'); * TApplication maintains a lifecycle with the following stages: * - [construct] : construction of the application instance * - [initApplication] : load application configuration and instantiate modules and the requested service - * - onInitComplete : this event happens right after application initialization and can finish any initialization - * - onBeginRequest : this event happens right before the request starts + * - onBeginRequest : this event happens right after application initialization * - onAuthentication : this event happens when authentication is needed for the current request * - onAuthenticationComplete : this event happens right after the authentication is done for the current request * - onAuthorization : this event happens when authorization is needed for the current request @@ -161,11 +160,6 @@ class TApplication extends TComponent * Global data file */ const GLOBAL_FILE='global.cache'; - - /** - * Defines which step the service is run - */ - const SERVICE_STEP=8; /** * @var array list of events that define application lifecycles @@ -419,15 +413,6 @@ class TApplication extends TComponent } $this->onEndRequest(); } - - - /** - * Tells you whether the application is after the service step - * @return boolean whether it is after the service step - */ - public function getIsAfterService() { - return $this->_step > self::SERVICE_STEP; - } /** * Completes current request processing. @@ -719,21 +704,6 @@ class TApplication extends TComponent } /** - * This loops through all the modules and finds those with a specific type, with/witout strictness - * @param string $type this is the string module type to look for - * @param boolean $strict default false, the module can be an instanceof the type if false, otherwise it must be the exact class - * @return IModule the module with the specified ID, null if not found - */ - public function getModulesByType($type,$strict=false) - { - $modules = array(); - foreach($this->_modules as $module) - if( get_class($module)===$type || (!$strict && ($module instanceof $type)) ) - $modules[] = $module; - return $modules; - } - - /** * @return array list of loaded application modules, indexed by module IDs */ public function getModules() @@ -1075,8 +1045,6 @@ class TApplication extends TComponent $serviceID=$this->getPageServiceID(); $this->startService($serviceID); - - $this->onInitComplete(); } /** @@ -1131,23 +1099,10 @@ class TApplication extends TComponent } /** - * Raises onInitComplete event. - * At the time when this method is invoked, application modules are loaded, - * user request is resolved and the corresponding service - * is loaded and initialized. The application is about to start processing - * the user request. - */ - public function onInitComplete() - { - Prado::trace("Executing onInitComplete()",'System.TApplication'); - $this->raiseEvent('onInitComplete',$this,null); - } - - /** * Raises OnBeginRequest event. * At the time when this method is invoked, application modules are loaded * and initialized, user request is resolved and the corresponding service - * is loaded and initialized. The application is starting to process + * is loaded and initialized. The application is about to start processing * the user request. */ public function onBeginRequest() 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 <qiang.xue@gmail.com>
* @author Carl G. Mathisen <carlgmathisen@gmail.com>
- * @author Brad Anderson <javalizard@gmail.com>
* @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 <javalizard@gmail.com>
- * @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 <qiang.xue@gmail.com>
- * @author Brad Anderson <javalizard@gmail.com>
* @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 <javalizard@gmail.com>
- * @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.
*
|