/**
  * Sets JS files
  */
 private function setJsFiles()
 {
     global $disable_js_and_css_files, $htmlHeadXtra;
     $jsFolder = api_get_path(WEB_LIBRARY_PATH) . 'javascript/';
     if ($this->app['assetic.enabled']) {
         $js_files = array(api_get_path(WEB_PATH) . 'web/js/script.js', $jsFolder . 'chosen/chosen.jquery.min.js', $jsFolder . 'thickbox.js', $jsFolder . 'ckeditor/ckeditor.js');
     } else {
         //JS files
         $js_files = array($jsFolder . 'modernizr.js', $jsFolder . 'jquery.js', $jsFolder . 'chosen/chosen.jquery.min.js', $jsFolder . 'jquery-ui/js/jquery-ui.custom.js', $jsFolder . 'thickbox.js', $jsFolder . 'bootstrap/js/bootstrap.js');
     }
     $this->app['html_editor']->getJavascriptToInclude($js_files);
     if (api_is_global_chat_enabled()) {
         //Do not include the global chat in LP
         if ($this->show_learnpath == false && $this->show_footer == true && $this->app['template.hide_global_chat'] == false) {
             $js_files[] = $jsFolder . 'chat/js/chat.js';
         }
     }
     if (api_get_setting('accessibility_font_resize') == 'true') {
         $js_files[] = $jsFolder . 'fontresize.js';
     }
     if (api_get_setting('include_asciimathml_script') == 'true') {
         $js_files[] = $jsFolder . 'asciimath/ASCIIMathML.js';
     }
     if (api_get_setting('disable_copy_paste') == 'true') {
         $js_files[] = $jsFolder . 'jquery.nocutcopypaste.js';
     }
     $js_file_to_string = null;
     foreach ($js_files as $js_file) {
         $js_file_to_string .= api_get_js_simple($js_file);
     }
     // Loading email_editor js.
     if (!api_is_anonymous() && api_get_setting('allow_email_editor') == 'true') {
         $js_file_to_string .= $this->fetch($this->app['template_style'] . '/mail_editor/email_link.js.tpl');
     }
     if (!$disable_js_and_css_files) {
         $this->assign('js_file_to_string', $js_file_to_string);
         $extra_headers = null;
         if (isset($htmlHeadXtra) && $htmlHeadXtra) {
             foreach ($htmlHeadXtra as $this_html_head) {
                 $extra_headers .= $this_html_head . "\n";
             }
         }
         if (isset($this->app['extraJS'])) {
             foreach ($this->app['extraJS'] as $this_html_head) {
                 $extra_headers .= $this_html_head . "\n";
             }
         }
         $this->assign('extra_headers', $extra_headers);
     }
 }
Beispiel #2
0
 /**
  * @return string
  */
 public function parseResources()
 {
     $resourceToString = null;
     foreach ($this->resources as $type => $resources) {
         switch ($type) {
             case 'js':
                 if ($this->disableJsAndCss == false) {
                     foreach ($resources as $resource) {
                         $resourceToString .= api_get_js_simple($resource);
                     }
                 }
                 break;
             case 'css':
                 if ($this->disableJsAndCss == false) {
                     foreach ($resources as $resource) {
                         $resourceToString .= api_get_css($resource);
                     }
                 }
                 break;
             case 'string':
                 if ($this->disableJsAndCss == false) {
                     foreach ($resources as $resource) {
                         $resourceToString .= $resource;
                     }
                 }
                 break;
             case 'no_js_css':
                 foreach ($resources as $resource) {
                     $resourceToString .= $resource;
                 }
                 break;
         }
     }
     $this->assign('resources', $resourceToString);
 }