From 296dc598eb58b38977d87109a06f09cfcf47f384 Mon Sep 17 00:00:00 2001 From: Conrad Vermeulen Date: Thu, 20 Sep 2007 09:42:46 +0000 Subject: [PATCH] KTS-2356 "i8nJavascript.php runs very slowly" Fixed. Implemented 'caching' of the javascript in the session. --- presentation/i18nJavascript.php | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/presentation/i18nJavascript.php b/presentation/i18nJavascript.php index 2d8a485..c401d7e 100644 --- a/presentation/i18nJavascript.php +++ b/presentation/i18nJavascript.php @@ -4,7 +4,7 @@ * License Version 1.1.2 ("License"); You may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.knowledgetree.com/KPL - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. * See the License for the specific language governing rights and @@ -15,9 +15,9 @@ * (ii) the KnowledgeTree copyright notice * in the same form as they appear in the distribution. See the License for * requirements. - * + * * The Original Code is: KnowledgeTree Open Source - * + * * The Initial Developer of the Original Code is The Jam Warehouse Software * (Pty) Ltd, trading as KnowledgeTree. * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright @@ -27,6 +27,13 @@ * */ +session_start(); +if (isset($_SESSION['_JS_VAR'])) +{ + print $_SESSION['_JS_VAR']; + exit; +} + require_once('../config/dmsDefaults.php'); require_once(KT_LIB_DIR . '/dispatcher.inc.php'); require_once(KT_LIB_DIR . '/templating/templating.inc.php'); @@ -35,21 +42,26 @@ class JavascriptTranslationDispatcher extends KTDispatcher { function check() { if (!parent::check()) { return false; } - + return true; } function do_main() { - header('Content-Type: application/javascript; charset=UTF-8'); - + header('Content-Type: application/javascript; charset=UTF-8'); + $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate("ktcore/javascript_i18n"); - return $oTemplate->render(); + return $oTemplate->render(); } } +ob_start(); + $oD =& new JavascriptTranslationDispatcher(); $oD->dispatch(); +$jsVar = ob_get_flush(); +$_SESSION['_JS_VAR'] = $jsVar; + ?> \ No newline at end of file -- libgit2 0.21.4