protected function registerPradoScriptInternal($name) { if (!isset($this->_registeredPradoScripts[$name])) { if (self::$_pradoScripts === null) { $packageFile = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::PACKAGES_FILE; list($packages, $deps) = (include $packageFile); self::$_pradoScripts = $deps; self::$_pradoPackages = $packages; } if (isset(self::$_pradoScripts[$name])) { $this->_registeredPradoScripts[$name] = true; } else { throw new TInvalidOperationException('csmanager_pradoscript_invalid', $name); } if (($packages = array_keys($this->_registeredPradoScripts)) !== array()) { $base = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::SCRIPT_PATH; list($path, $baseUrl) = $this->getPackagePathUrl($base); $packagesUrl = array(); $isDebug = $this->getApplication()->getMode() === TApplicationMode::Debug; foreach ($packages as $p) { foreach (self::$_pradoScripts[$p] as $dep) { foreach (self::$_pradoPackages[$dep] as $script) { if (!isset($this->_expandedPradoScripts[$script])) { $this->_expandedPradoScripts[$script] = true; if ($isDebug) { if (!in_array($url = $baseUrl . '/' . $script, $packagesUrl)) { $packagesUrl[] = $url; } } else { if (!in_array($url = $baseUrl . '/min/' . $script, $packagesUrl)) { if (!is_file($filePath = $path . '/min/' . $script)) { $dirPath = dirname($filePath); if (!is_dir($dirPath)) { mkdir($dirPath, PRADO_CHMOD, true); } file_put_contents($filePath, TJavaScript::JSMin(file_get_contents($base . '/' . $script))); chmod($filePath, PRADO_CHMOD); } $packagesUrl[] = $url; } } } } } } foreach ($packagesUrl as $url) { $this->registerScriptFile($url, $url); } } } }