Commit 5f3770a1e9a3d64246c3ef70a28cca74a8baeb94

Authored by kevin_fourie
1 parent 53ee0eb2

Merged in from 3.5 DEV trunk...

KTS-2356
"i8nJavascript.php runs very slowly"
Fixed. Implemented 'caching' of the javascript in the session.

Committed By: Conrad Vermeulen
Reviewed By: Kevin Fourie

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/branches/3.4.4-Release-Branch@7596 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 16 additions and 4 deletions
presentation/i18nJavascript.php
@@ -27,6 +27,13 @@ @@ -27,6 +27,13 @@
27 * 27 *
28 */ 28 */
29 29
  30 +session_start();
  31 +if (isset($_SESSION['_JS_VAR']))
  32 +{
  33 + print $_SESSION['_JS_VAR'];
  34 + exit;
  35 +}
  36 +
30 require_once('../config/dmsDefaults.php'); 37 require_once('../config/dmsDefaults.php');
31 require_once(KT_LIB_DIR . '/dispatcher.inc.php'); 38 require_once(KT_LIB_DIR . '/dispatcher.inc.php');
32 require_once(KT_LIB_DIR . '/templating/templating.inc.php'); 39 require_once(KT_LIB_DIR . '/templating/templating.inc.php');
@@ -35,21 +42,26 @@ class JavascriptTranslationDispatcher extends KTDispatcher { @@ -35,21 +42,26 @@ class JavascriptTranslationDispatcher extends KTDispatcher {
35 42
36 function check() { 43 function check() {
37 if (!parent::check()) { return false; } 44 if (!parent::check()) { return false; }
38 - 45 +
39 return true; 46 return true;
40 } 47 }
41 48
42 function do_main() { 49 function do_main() {
43 - header('Content-Type: application/javascript; charset=UTF-8');  
44 - 50 + header('Content-Type: application/javascript; charset=UTF-8');
  51 +
45 $oTemplating =& KTTemplating::getSingleton(); 52 $oTemplating =& KTTemplating::getSingleton();
46 $oTemplate = $oTemplating->loadTemplate("ktcore/javascript_i18n"); 53 $oTemplate = $oTemplating->loadTemplate("ktcore/javascript_i18n");
47 54
48 - return $oTemplate->render(); 55 + return $oTemplate->render();
49 } 56 }
50 } 57 }
51 58
  59 +ob_start();
  60 +
52 $oD =& new JavascriptTranslationDispatcher(); 61 $oD =& new JavascriptTranslationDispatcher();
53 $oD->dispatch(); 62 $oD->dispatch();
54 63
  64 +$jsVar = ob_get_flush();
  65 +$_SESSION['_JS_VAR'] = $jsVar;
  66 +
55 ?> 67 ?>
56 \ No newline at end of file 68 \ No newline at end of file