Commit c28e63d11b2b880d61d4c04820bbaa45e99f84b9

Authored by conradverm
1 parent 36e3356e

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/trunk@7163 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 19 additions and 7 deletions
presentation/i18nJavascript.php
... ... @@ -4,7 +4,7 @@
4 4 * License Version 1.1.2 ("License"); You may not use this file except in
5 5 * compliance with the License. You may obtain a copy of the License at
6 6 * http://www.knowledgetree.com/KPL
7   - *
  7 + *
8 8 * Software distributed under the License is distributed on an "AS IS"
9 9 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
10 10 * See the License for the specific language governing rights and
... ... @@ -15,9 +15,9 @@
15 15 * (ii) the KnowledgeTree copyright notice
16 16 * in the same form as they appear in the distribution. See the License for
17 17 * requirements.
18   - *
  18 + *
19 19 * The Original Code is: KnowledgeTree Open Source
20   - *
  20 + *
21 21 * The Initial Developer of the Original Code is The Jam Warehouse Software
22 22 * (Pty) Ltd, trading as KnowledgeTree.
23 23 * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright
... ... @@ -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 37 require_once('../config/dmsDefaults.php');
31 38 require_once(KT_LIB_DIR . '/dispatcher.inc.php');
32 39 require_once(KT_LIB_DIR . '/templating/templating.inc.php');
... ... @@ -35,21 +42,26 @@ class JavascriptTranslationDispatcher extends KTDispatcher {
35 42  
36 43 function check() {
37 44 if (!parent::check()) { return false; }
38   -
  45 +
39 46 return true;
40 47 }
41 48  
42 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 52 $oTemplating =& KTTemplating::getSingleton();
46 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 61 $oD =& new JavascriptTranslationDispatcher();
53 62 $oD->dispatch();
54 63  
  64 +$jsVar = ob_get_flush();
  65 +$_SESSION['_JS_VAR'] = $jsVar;
  66 +
55 67 ?>
56 68 \ No newline at end of file
... ...