summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorgodzilla80@gmx.net <>2009-11-08 07:33:48 +0000
committergodzilla80@gmx.net <>2009-11-08 07:33:48 +0000
commit58498f0d70d8396ef0dc1c9e8bc4f28151771bee (patch)
tree7baade509d22ae30d02446ad3f3ee072b492e921 /framework
parentc1c9ce954290b24b90bb1d9b69bb41380ca697ed (diff)
Add property ClientScriptManagerClass to TPageService and releated changes in TPage.getClientScript() to allow subclassing of TClientScriptManager
Diffstat (limited to 'framework')
-rw-r--r--framework/Exceptions/messages/messages.txt1
-rw-r--r--framework/Web/Services/TPageService.php24
-rw-r--r--framework/Web/UI/TPage.php13
3 files changed, 36 insertions, 2 deletions
diff --git a/framework/Exceptions/messages/messages.txt b/framework/Exceptions/messages/messages.txt
index fc2b63f1..425979a3 100644
--- a/framework/Exceptions/messages/messages.txt
+++ b/framework/Exceptions/messages/messages.txt
@@ -200,6 +200,7 @@ page_control_outofform = {0} '{1}' must be enclosed within TForm.
page_head_duplicated = A page can contain at most one THead.
page_head_required = A THead control is needed in page template in order to render CSS and js in the HTML head section.
page_statepersister_invalid = Page state persister must implement IPageStatePersister interface.
+page_csmanagerclass_invalid = ClientScriptManager class '{0}' must be an instance of TClientScriptManager.
csmanager_pradoscript_invalid = Unknown Prado script library name '{0}'.
csmanager_invalid_packages = Unkownn packages '{1}' for javascript packages defined in '{0}'. Valid packages are '{2}'.
diff --git a/framework/Web/Services/TPageService.php b/framework/Web/Services/TPageService.php
index e35fb0e3..d7506912 100644
--- a/framework/Web/Services/TPageService.php
+++ b/framework/Web/Services/TPageService.php
@@ -100,6 +100,11 @@ class TPageService extends TService
*/
private $_basePageClass='TPage';
/**
+ * @var string clientscript manager class in namespace format
+ * @since 3.1.7
+ */
+ private $_clientScriptManagerClass='System.Web.UI.TClientScriptManager';
+ /**
* @var string default page
*/
private $_defaultPage='Home';
@@ -409,6 +414,25 @@ class TPageService extends TService
}
/**
+ * Sets the clientscript manager class (in namespace format).
+ * @param string class name
+ * @since 3.1.7
+ */
+ public function setClientScriptManagerClass($value)
+ {
+ $this->_clientScriptManagerClass=$value;
+ }
+
+ /**
+ * @return string clientscript manager class in namespace format. Defaults to 'System.Web.UI.TClientScriptManager'.
+ * @since 3.1.7
+ */
+ public function getClientScriptManagerClass()
+ {
+ return $this->_clientScriptManagerClass;
+ }
+
+ /**
* Runs the service.
* This will create the requested page, initializes it with the property values
* specified in the configuration, and executes the page.
diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php
index 4681f876..4a2ea474 100644
--- a/framework/Web/UI/TPage.php
+++ b/framework/Web/UI/TPage.php
@@ -586,8 +586,17 @@ class TPage extends TTemplateControl
*/
public function getClientScript()
{
- if(!$this->_clientScript)
- $this->_clientScript=new TClientScriptManager($this);
+ if(!$this->_clientScript) {
+ $className = $classPath = $this->getService()->getClientScriptManagerClass();
+ Prado::using($className);
+ if(($pos=strrpos($className,'.'))!==false)
+ $className=substr($className,$pos+1);
+
+ if(!class_exists($className,false) || ($className!=='TClientScriptManager' && !is_subclass_of($className,'TClientScriptManager')))
+ throw new THttpException(404,'page_csmanagerclass_invalid',$classPath);
+
+ $this->_clientScript=new $className($this);
+ }
return $this->_clientScript;
}