Esempio n. 1
0
 protected function renderScriptFiles($writer, array $scripts)
 {
     foreach ($scripts as $script) {
         $writer->write(TJavaScript::renderScriptFile($script));
         $this->markScriptFileAsRendered($script);
     }
 }
 /**
  * Renders the HTML tags for PRADO js files
  * @param THtmlWriter writer
  */
 protected function renderPradoScripts($writer)
 {
     if (($packages = array_keys($this->_registeredPradoScripts)) !== array()) {
         if (Prado::getApplication()->getMode() !== TApplicationMode::Debug) {
             $base = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::SCRIPT_PATH;
             $url = $this->registerJavascriptPackages($base, $packages);
             $writer->write(TJavaScript::renderScriptFile($url));
         } else {
             // In debug mode, we add 1 <script> line by file
             $base = Prado::getFrameworkPath() . DIRECTORY_SEPARATOR . self::SCRIPT_PATH;
             list($path, $baseUrl) = $this->getPackagePathUrl($base);
             $packagesUrl = array();
             foreach ($packages as $p) {
                 foreach (self::$_pradoScripts[$p] as $dep) {
                     foreach (self::$_pradoPackages[$dep] as $script) {
                         if (!in_array($url = $baseUrl . '/' . $script, $packagesUrl)) {
                             $packagesUrl[] = $url;
                         }
                     }
                 }
             }
             $writer->write(TJavaScript::renderScriptFiles($packagesUrl));
         }
     }
 }