From d0acd8681d97c863b9b6fec9d286a0aa19abf61e Mon Sep 17 00:00:00 2001 From: emkael Date: Tue, 19 Apr 2016 13:33:29 +0200 Subject: * base class for controls, auto-registering JS scripts --- app/php/components/TemplateControl.php | 53 ++++++++++++++++++++++++++++++++++ app/php/controls/CalendarScaffold.php | 5 +++- app/php/controls/HeaderMenu.php | 4 ++- app/php/controls/LoginBox.php | 4 ++- app/php/controls/PasswordChange.php | 4 ++- app/php/controls/RegistrationForm.php | 4 ++- app/php/controls/TimezoneSelect.php | 4 ++- app/php/controls/UpcomingEvents.php | 4 ++- app/php/controls/UserSelection.php | 4 ++- 9 files changed, 78 insertions(+), 8 deletions(-) create mode 100644 app/php/components/TemplateControl.php (limited to 'app/php') 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 @@ +_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 []; + } + +} + +?> diff --git a/app/php/controls/CalendarScaffold.php b/app/php/controls/CalendarScaffold.php index 70efcaa..dd8a80e 100644 --- a/app/php/controls/CalendarScaffold.php +++ b/app/php/controls/CalendarScaffold.php @@ -1,11 +1,14 @@ setViewState('Facade', $facade); diff --git a/app/php/controls/HeaderMenu.php b/app/php/controls/HeaderMenu.php index bffe4d2..f6b69b9 100644 --- a/app/php/controls/HeaderMenu.php +++ b/app/php/controls/HeaderMenu.php @@ -1,8 +1,10 @@ Application->getModule('auth')->logout(); diff --git a/app/php/controls/LoginBox.php b/app/php/controls/LoginBox.php index 33bbcc1..eb448eb 100644 --- a/app/php/controls/LoginBox.php +++ b/app/php/controls/LoginBox.php @@ -1,6 +1,8 @@ Page->IsValid) { diff --git a/app/php/controls/PasswordChange.php b/app/php/controls/PasswordChange.php index cd901ca..1c05c64 100644 --- a/app/php/controls/PasswordChange.php +++ b/app/php/controls/PasswordChange.php @@ -1,8 +1,10 @@ getControlState('user'); diff --git a/app/php/controls/RegistrationForm.php b/app/php/controls/RegistrationForm.php index 71d4df1..2ffe507 100644 --- a/app/php/controls/RegistrationForm.php +++ b/app/php/controls/RegistrationForm.php @@ -1,8 +1,10 @@ IsValid = !User::finder()->countByLogin($this->Login->SafeText); diff --git a/app/php/controls/TimezoneSelect.php b/app/php/controls/TimezoneSelect.php index 592a9e7..5556f4a 100644 --- a/app/php/controls/TimezoneSelect.php +++ b/app/php/controls/TimezoneSelect.php @@ -1,9 +1,11 @@ getControlState('user'); diff --git a/app/php/controls/UpcomingEvents.php b/app/php/controls/UpcomingEvents.php index 3b0869a..6d0f9d3 100644 --- a/app/php/controls/UpcomingEvents.php +++ b/app/php/controls/UpcomingEvents.php @@ -1,8 +1,10 @@ setViewState('Facade', $facade); diff --git a/app/php/controls/UserSelection.php b/app/php/controls/UserSelection.php index 3e2def1..6f9bc9e 100644 --- a/app/php/controls/UserSelection.php +++ b/app/php/controls/UserSelection.php @@ -1,8 +1,10 @@ setViewState('Facade', $facade); -- cgit v1.2.3