includes/template.php
changeset 1196 704ba4b9819b
parent 1192 5882f0eebb34
child 1203 c6587072e4c4
equal deleted inserted replaced
1195:449fdd113eb0 1196:704ba4b9819b
   512       $asa = '';
   512       $asa = '';
   513       $as2 = '';
   513       $as2 = '';
   514       $ash = '';
   514       $ash = '';
   515     }
   515     }
   516     
   516     
       
   517     // Append the Enano version to URLs to break the cache on upgrades
       
   518     $enano_version = enano_version();
       
   519     
   517     // Set up javascript includes
   520     // Set up javascript includes
   518     // these depend heavily on whether we have a CDN to work with or not
   521     // these depend heavily on whether we have a CDN to work with or not
   519     if ( getConfig('cdn_path') )
   522     if ( getConfig('cdn_path') )
   520     {
   523     {
   521       // we're on a CDN, point to static includes
   524       // we're on a CDN, point to static includes
   522       // CLI javascript compression script: includes/clientside/jscompress.php
   525       // CLI javascript compression script: includes/clientside/jscompress.php
   523       $js_head = '<script type="text/javascript" src="' . cdnPath . '/includes/clientside/static/enano-lib-basic.js"></script>';
   526       $js_head = '<script type="text/javascript" src="' . cdnPath . '/includes/clientside/static/enano-lib-basic.js?' . $enano_version . '"></script>';
   524       
   527       
   525       if ( !empty($this->js_preload) )
   528       if ( !empty($this->js_preload) )
   526       {
   529       {
   527         $loadlines = array();
   530         $loadlines = array();
   528         
   531         
   534         unset($script);
   537         unset($script);
   535         $this->js_preload = array_unique($this->js_preload);
   538         $this->js_preload = array_unique($this->js_preload);
   536         
   539         
   537         foreach ( $this->js_preload as $script )
   540         foreach ( $this->js_preload as $script )
   538         {
   541         {
   539           $js_head .= "\n    <script type=\"text/javascript\" src=\"" . cdnPath . "/includes/clientside/static/$script\"></script>";
   542           $js_head .= "\n    <script type=\"text/javascript\" src=\"" . cdnPath . "/includes/clientside/static/$script?$enano_version\"></script>";
   540           // special case for l10n: also load strings
   543           // special case for l10n: also load strings
   541           if ( $script == 'l10n.js' )
   544           if ( $script == 'l10n.js' )
   542           {
   545           {
   543             global $lang;
   546             global $lang;
   544             $js_head .= "\n    <script type=\"text/javascript\" src=\"" . makeUrlNS("Special", "LangExportJSON/$lang->lang_id") . "\"></script>";
   547             $js_head .= "\n    <script type=\"text/javascript\" src=\"" . makeUrlNS("Special", "LangExportJSON/$lang->lang_id", "$enano_version") . "\"></script>";
   545           }
   548           }
   546           $loadlines[] = "loaded_components['$script'] = true;";
   549           $loadlines[] = "loaded_components['$script'] = true;";
   547         }
   550         }
   548         
   551         
   549         // tell the system that this stuff is already loaded
   552         // tell the system that this stuff is already loaded
   576       $js_head = '';
   579       $js_head = '';
   577       
   580       
   578       // point to jsres compressor
   581       // point to jsres compressor
   579       $js_head .= <<<JSEOF
   582       $js_head .= <<<JSEOF
   580       <!-- Only load a basic set of functions for now. Let the rest of the API load when the page is finished. -->
   583       <!-- Only load a basic set of functions for now. Let the rest of the API load when the page is finished. -->
   581       <script type="text/javascript" src="$cdnpath/includes/clientside/jsres.php?early"></script>
   584       <script type="text/javascript" src="$cdnpath/includes/clientside/jsres.php?early&$enano_version"></script>
   582 JSEOF;
   585 JSEOF;
   583       $js_foot = '';
   586       $js_foot = '';
   584       
   587       
   585       if ( !empty($this->js_preload) )
   588       if ( !empty($this->js_preload) )
   586       {
   589       {
   591         $this->js_preload = array_unique($this->js_preload);
   594         $this->js_preload = array_unique($this->js_preload);
   592         if ( in_array('l10n.js', $this->js_preload) )
   595         if ( in_array('l10n.js', $this->js_preload) )
   593         {
   596         {
   594           // special case for l10n: also load strings
   597           // special case for l10n: also load strings
   595           global $lang;
   598           global $lang;
   596           $js_foot .= "\n    <script type=\"text/javascript\" src=\"" . makeUrlNS("Special", "LangExportJSON/$lang->lang_id") . "\"></script>";
   599           $js_foot .= "\n    <script type=\"text/javascript\" src=\"" . makeUrlNS("Special", "LangExportJSON/$lang->lang_id", $enano_version) . "\"></script>";
   597         }
   600         }
   598         $scripts = implode(',', $this->js_preload);
   601         $scripts = implode(',', $this->js_preload);
   599         $js_foot .= "\n    <script type=\"text/javascript\" src=\"" . cdnPath . "/includes/clientside/jsres.php?f=$scripts\"></script>";
   602         $js_foot .= "\n    <script type=\"text/javascript\" src=\"" . cdnPath . "/includes/clientside/jsres.php?f=$scripts&$enano_version\"></script>";
   600         
   603         
   601       }
   604       }
   602       
   605       
   603       $js_foot .= <<<JSEOF
   606       $js_foot .= <<<JSEOF
   604     <!-- jsres.php is a wrapper script that compresses and caches single JS files to minimize requests -->
   607     <!-- jsres.php is a wrapper script that compresses and caches single JS files to minimize requests -->
   605     <script type="text/javascript" src="$cdnpath/includes/clientside/jsres.php"></script>
   608     <script type="text/javascript" src="$cdnpath/includes/clientside/jsres.php?$enano_version"></script>
   606     <script type="text/javascript">//<![CDATA[
   609     <script type="text/javascript">//<![CDATA[
   607       // This initializes the Javascript runtime when the DOM is ready - not when the page is
   610       // This initializes the Javascript runtime when the DOM is ready - not when the page is
   608       // done loading, because enano-lib-basic still has to load some 15 other script files
   611       // done loading, because enano-lib-basic still has to load some 15 other script files
   609       // check for the init function - this is a KHTML fix
   612       // check for the init function - this is a KHTML fix
   610       // This doesn't seem to work properly in IE in 1.1.x - there are some problems with
   613       // This doesn't seem to work properly in IE in 1.1.x - there are some problems with
   653         'MAIN_PAGE' => get_main_page(),
   656         'MAIN_PAGE' => get_main_page(),
   654         'UNREAD_PMS' => $session->unread_pms,
   657         'UNREAD_PMS' => $session->unread_pms,
   655         'JS_HEADER' => $js_head,
   658         'JS_HEADER' => $js_head,
   656         'JS_FOOTER' => $js_foot,
   659         'JS_FOOTER' => $js_foot,
   657         'URL_ABOUT_ENANO' => makeUrlNS('Special', 'About_Enano', '', true),
   660         'URL_ABOUT_ENANO' => makeUrlNS('Special', 'About_Enano', '', true),
       
   661         'ENANO_VERSION' => enano_version()
   658       ), true);
   662       ), true);
   659     
   663     
   660     $tpl_strings = array();
   664     $tpl_strings = array();
   661     foreach ( $paths->nslist as $ns_id => $ns_prefix )
   665     foreach ( $paths->nslist as $ns_id => $ns_prefix )
   662     {
   666     {
  1245       var msg_loading_component = \'' . addslashes($lang->get('ajax_msg_loading_component')) . '\';
  1249       var msg_loading_component = \'' . addslashes($lang->get('ajax_msg_loading_component')) . '\';
  1246       var AES_BITS = '.AES_BITS.';
  1250       var AES_BITS = '.AES_BITS.';
  1247       var AES_BLOCKSIZE = '.AES_BLOCKSIZE.';
  1251       var AES_BLOCKSIZE = '.AES_BLOCKSIZE.';
  1248       var pagepass = \''. ( ( isset($_REQUEST['pagepass']) ) ? sha1($_REQUEST['pagepass']) : '' ) .'\';
  1252       var pagepass = \''. ( ( isset($_REQUEST['pagepass']) ) ? sha1($_REQUEST['pagepass']) : '' ) .'\';
  1249       var ENANO_LANG_ID = ' . $lang->lang_id . ';
  1253       var ENANO_LANG_ID = ' . $lang->lang_id . ';
  1250       var ENANO_PAGE_TYPE = "' . addslashes($this->namespace_string) . '";';
  1254       var ENANO_PAGE_TYPE = "' . addslashes($this->namespace_string) . '";
       
  1255       var enano_version = "' . enano_version() . '";';
  1251     
  1256     
  1252     foreach ( $paths->nslist as $k => $c )
  1257     foreach ( $paths->nslist as $k => $c )
  1253     {
  1258     {
  1254       $js_dynamic .= "namespace_list['{$k}'] = '" . addslashes($c) . "';";
  1259       $js_dynamic .= "namespace_list['{$k}'] = '" . addslashes($c) . "';";
  1255     }
  1260     }