_getControlScriptPath(get_class($this)); if (file_exists($scriptFile)) { $this->_registerScriptFile($scriptFile); } $styleFile = $this->_getControlStylePath(get_class($this)); if (file_exists($styleFile)) { $this->_registerStyleFile($styleFile); } } protected function getExternalScriptDependencies() { return []; } protected function getLibScriptDependencies() { return []; } protected function getPradoScriptDependencies() { return []; } protected function getControlScriptDependencies() { return []; } protected function getExternalStyleDependencies() { return []; } protected function getLibStyleDependencies() { return []; } protected function getControlStyleDependencies() { return []; } private function _getControlScriptPath(string $className) { return Prado::getPathOfNamespace('Application.controls.scripts') . DIRECTORY_SEPARATOR . $className . '.js'; } private function _getControlStylePath(string $className) { return Prado::getPathOfNamespace('Application.controls.styles') . DIRECTORY_SEPARATOR . $className . '.css'; } private function _getLibPath(string $identifier, string $extension = '') { return Prado::getPathOfNamespace('Lib') . DIRECTORY_SEPARATOR . $identifier . $extension; } private function _registerScriptFile(string $scriptFile) { $this->_registerExternalScriptDependencies( $this->getExternalScriptDependencies() ); $this->_registerLibScriptDependencies( $this->getLibScriptDependencies() ); $this->_registerPradoScriptDependencies( $this->getPradoScriptDependencies() ); $this->_registerControlScriptDependencies( $this->getControlScriptDependencies() ); $this->Page->ClientScript->registerScriptFile( 'TemplateControl.' . get_class($this), $this->Application->AssetManager->publishFilePath($scriptFile) ); } private function _registerExternalScriptDependencies(array $dependencies) { foreach ($dependencies as $dependency) { $this->Page->ClientScript->registerHeadScriptFile( $dependency, $dependency ); } } private function _registerLibScriptDependencies(array $dependencies) { foreach ($dependencies as $dependency) { $this->Page->ClientScript->registerScriptFile( 'LibScript.' . $dependency, $this->Application->AssetManager->publishFilePath( $this->_getLibPath($dependency, '.js') ) ); } } private function _registerPradoScriptDependencies(array $dependencies) { foreach ($dependencies as $dependency) { $this->Page->ClientScript->registerPradoScript($dependency); } } private function _registerControlScriptDependencies(array $dependencies) { foreach ($dependencies as $dependency) { $this->Page->ClientScript->registerScriptFile( 'TemplateControl.' . $dependency, $this->Application->AssetManager->publishFilePath( $this->_getControlScriptPath($dependency) ) ); } } private function _registerStyleFile(string $styleFile) { $this->_registerExternalStyleDependencies( $this->getExternalStyleDependencies() ); $this->_registerLibStyleDependencies( $this->getLibStyleDependencies() ); $this->_registerControlStyleDependencies( $this->getControlStyleDependencies() ); if (method_exists($this->Page->ClientScript, 'registerThemeStyleSheetFile')) { $this->Page->ClientScript->registerThemeStyleSheetFile( 'TemplateControl.' . get_class($this), $this->Application->AssetManager->publishFilePath($styleFile) ); } else { $this->Page->ClientScript->registerStyleSheetFile( 'TemplateControl.' . get_class($this), $this->Application->AssetManager->publishFilePath($styleFile) ); } } private function _registerExternalStyleDependencies(array $dependencies) { foreach ($dependencies as $dependency) { $this->Page->ClientScript->registerStyleSheetFile( $dependency, $dependency ); } } private function _registerLibStyleDependencies(array $dependencies) { foreach ($dependencies as $dependency) { $this->Page->ClientScript->registerStyleSheetFile( 'LibStyle.' . $dependency, $this->Application->AssetManager->publishFilePath( $this->_getLibPath($dependency, '.css') ) ); } } private function _registerControlStyleDependencies(array $dependencies) { foreach ($dependencies as $dependency) { $this->Page->ClientScript->registerStyleSheetFile( 'TemplateControl.' . $dependency, $this->Application->AssetManager->publishFilePath( $this->_getControlStylePath($dependency) ) ); } } } ?>