summaryrefslogtreecommitdiff
path: root/app/php/components/TemplateControl.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/php/components/TemplateControl.php')
-rw-r--r--app/php/components/TemplateControl.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/app/php/components/TemplateControl.php b/app/php/components/TemplateControl.php
new file mode 100644
index 0000000..e3c9e26
--- /dev/null
+++ b/app/php/components/TemplateControl.php
@@ -0,0 +1,53 @@
+<?php
+
+class TemplateControl extends TTemplateControl {
+
+ private function _getControlScriptPath($className) {
+ return Prado::getPathOfNamespace('Application.controls.scripts')
+ . DIRECTORY_SEPARATOR
+ . $className
+ . '.js';
+ }
+
+ public function onPreRender($param) {
+ parent::onPreRender($param);
+ $scriptFile = $this->_getControlScriptPath(get_class($this));
+ if (file_exists($scriptFile)) {
+ foreach ($this->getPradoScriptDependencies() as $dependency) {
+ $this->Page->ClientScript->registerPradoScript($dependency);
+ }
+ foreach ($this->getControlScriptDependencies() as $dependency) {
+ $this->Page->ClientScript->registerScriptFile(
+ 'TemplateControl.' . $dependency,
+ $this->Application->AssetManager->publishFilePath(
+ $this->_getControlScriptPath($dependency)
+ )
+ );
+ }
+ foreach ($this->getExternalScriptDependencies() as $dependency) {
+ $this->Page->ClientScript->registerHeadScriptFile(
+ $dependency, $dependency
+ );
+ }
+ $this->Page->ClientScript->registerScriptFile(
+ 'TemplateControl.' . get_class($this),
+ $this->Application->AssetManager->publishFilePath($scriptFile)
+ );
+ }
+ }
+
+ protected function getPradoScriptDependencies() {
+ return [];
+ }
+
+ protected function getControlScriptDependencies() {
+ return [];
+ }
+
+ protected function getExternalScriptDependencies() {
+ return [];
+ }
+
+}
+
+?>