Пример #1
0
 public function getOutput()
 {
     $output = "";
     $globalInline = $this->getGlobalInlineScripts();
     if (!empty($globalInline)) {
         $output .= N2Html::script($globalInline . "\n");
     }
     foreach ($this->urls as $url) {
         $output .= N2Html::script($url, true) . "\n";
     }
     if (!N2Platform::$isAdmin && N2Settings::get('async', '0')) {
         $jsCombined = new N2CacheCombine('js', N2Settings::get('minify-js', '0') ? 'N2MinifierJS::minify' : false);
         foreach ($this->getFiles() as $file) {
             if (basename($file) == 'n2.js') {
                 $output .= N2Html::script(N2Uri::pathToUri($file) . '?' . filemtime($file), true) . "\n";
             } else {
                 $jsCombined->add($file);
             }
         }
         $combinedFile = $jsCombined->make();
         $scripts = 'nextend.loadScript("' . N2Uri::pathToUri($combinedFile) . '?' . filemtime($combinedFile) . '");';
         $output .= N2Html::script($scripts . "\n");
     } else {
         if (!N2Platform::$isAdmin && N2Settings::get('combine-js', '0')) {
             $jsCombined = new N2CacheCombine('js', N2Settings::get('minify-js', '0') ? 'N2MinifierJS::minify' : false);
             foreach ($this->getFiles() as $file) {
                 $jsCombined->add($file);
             }
             $combinedFile = $jsCombined->make();
             $output .= N2Html::script(N2Uri::pathToUri($combinedFile) . '?' . filemtime($combinedFile), true) . "\n";
         } else {
             foreach ($this->getFiles() as $file) {
                 $output .= N2Html::script(N2Uri::pathToUri($file) . '?' . filemtime($file), true) . "\n";
             }
         }
     }
     $output .= N2Html::script(N2Localization::toJS() . "\n" . $this->getInlineScripts() . "\n");
     return $output;
 }