diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/php/web/TemplateControl.php | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/app/php/web/TemplateControl.php b/app/php/web/TemplateControl.php index 952bd4f..213a680 100644 --- a/app/php/web/TemplateControl.php +++ b/app/php/web/TemplateControl.php @@ -8,6 +8,10 @@ class TemplateControl extends TTemplateControl { if (file_exists($scriptFile)) { $this->_registerScriptFile($scriptFile); } + $styleFile = $this->_getControlStylePath(get_class($this)); + if (file_exists($styleFile)) { + $this->_registerStyleFile($styleFile); + } } protected function getExternalScriptDependencies() { @@ -26,6 +30,18 @@ class TemplateControl extends TTemplateControl { return []; } + protected function getExternalStyleDependencies() { + return []; + } + + protected function getLibStyleDependencies() { + return []; + } + + protected function getControlStyleDependencies() { + return []; + } + private function _getControlScriptPath($className) { return Prado::getPathOfNamespace('Application.controls.scripts') . DIRECTORY_SEPARATOR @@ -33,6 +49,13 @@ class TemplateControl extends TTemplateControl { . '.js'; } + private function _getControlStylePath($className) { + return Prado::getPathOfNamespace('Application.controls.styles') + . DIRECTORY_SEPARATOR + . $className + . '.css'; + } + private function _getLibPath($identifier, $extension = '') { return Prado::getPathOfNamespace('Lib') . DIRECTORY_SEPARATOR @@ -95,6 +118,52 @@ class TemplateControl extends TTemplateControl { } } + private function _registerStyleFile($styleFile) { + $this->_registerExternalStyleDependencies( + $this->getExternalStyleDependencies() + ); + $this->_registerLibStyleDependencies( + $this->getLibStyleDependencies() + ); + $this->_registerControlStyleDependencies( + $this->getControlStyleDependencies() + ); + $this->Page->ClientScript->registerStyleSheetFile( + 'TemplateControl.' . get_class($this), + $this->Application->AssetManager->publishFilePath($styleFile) + ); + } + + private function _registerExternalStyleDependencies($dependencies) { + foreach ($dependencies as $dependency) { + $this->Page->ClientScript->registerStyleSheetFile( + $dependency, $dependency + ); + } + } + + private function _registerLibStyleDependencies($dependencies) { + foreach ($dependencies as $dependency) { + $this->Page->ClientScript->registerStyleSheetFile( + 'LibStyle.' . $dependency, + $this->Application->AssetManager->publishFilePath( + $this->_getLibPath($dependency, '.css') + ) + ); + } + } + + private function _registerControlStyleDependencies($dependencies) { + foreach ($dependencies as $dependency) { + $this->Page->ClientScript->registerStyleSheetFile( + 'TemplateControl.' . $dependency, + $this->Application->AssetManager->publishFilePath( + $this->_getControlStylePath($dependency) + ) + ); + } + } + } ?> |