diff options
author | emkael <emkael@tlen.pl> | 2016-04-29 11:24:11 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-04-29 11:24:11 +0200 |
commit | 7a2a894fab8414200b53da9d2d6959c80271cad8 (patch) | |
tree | 9d0d222dcb580b8d2fc981a55f7bbf58dd19469d | |
parent | 7a728e107ca20c98cacea406ab555d3d12605caf (diff) |
* JS libraries as control dependencies
-rw-r--r-- | app/php/web/TemplateControl.php | 29 | ||||
-rw-r--r-- | http/index.php | 4 |
2 files changed, 27 insertions, 6 deletions
diff --git a/app/php/web/TemplateControl.php b/app/php/web/TemplateControl.php index e3c9e26..a397f6f 100644 --- a/app/php/web/TemplateControl.php +++ b/app/php/web/TemplateControl.php @@ -9,10 +9,30 @@ class TemplateControl extends TTemplateControl { . '.js'; } + private function _getLibScriptPath($identifier) { + return Prado::getPathOfNamespace('Lib') + . DIRECTORY_SEPARATOR + . $identifier + . '.js'; + } + public function onPreRender($param) { parent::onPreRender($param); $scriptFile = $this->_getControlScriptPath(get_class($this)); if (file_exists($scriptFile)) { + foreach ($this->getExternalScriptDependencies() as $dependency) { + $this->Page->ClientScript->registerHeadScriptFile( + $dependency, $dependency + ); + } + foreach ($this->getLibScriptDependencies() as $dependency) { + $this->Page->ClientScript->registerScriptFile( + 'LibScript.' . $dependency, + $this->Application->AssetManager->publishFilePath( + $this->_getLibScriptPath($dependency) + ) + ); + } foreach ($this->getPradoScriptDependencies() as $dependency) { $this->Page->ClientScript->registerPradoScript($dependency); } @@ -24,11 +44,6 @@ class TemplateControl extends TTemplateControl { ) ); } - foreach ($this->getExternalScriptDependencies() as $dependency) { - $this->Page->ClientScript->registerHeadScriptFile( - $dependency, $dependency - ); - } $this->Page->ClientScript->registerScriptFile( 'TemplateControl.' . get_class($this), $this->Application->AssetManager->publishFilePath($scriptFile) @@ -44,6 +59,10 @@ class TemplateControl extends TTemplateControl { return []; } + protected function getLibScriptDependencies() { + return []; + } + protected function getExternalScriptDependencies() { return []; } diff --git a/http/index.php b/http/index.php index f5e04d6..5519aa6 100644 --- a/http/index.php +++ b/http/index.php @@ -1,12 +1,14 @@ <?php $basePath = dirname(__FILE__); -$frameworkPath = $basePath . '/../lib/prado/framework/prado.php'; $applicationPath = $basePath . '/../app/php/'; +$libPath = $basePath . '/../lib/'; +$frameworkPath = $libPath . 'prado/framework/prado.php'; require_once($frameworkPath); Prado::setPathOfAlias('Web', $basePath); +Prado::setPathOfAlias('Lib', $libPath); $application = new TApplication($applicationPath); $application->run(); |