Commit c28e63d11b2b880d61d4c04820bbaa45e99f84b9
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,7 +4,7 @@ | ||
| 4 | * License Version 1.1.2 ("License"); You may not use this file except in | 4 | * License Version 1.1.2 ("License"); You may not use this file except in |
| 5 | * compliance with the License. You may obtain a copy of the License at | 5 | * compliance with the License. You may obtain a copy of the License at |
| 6 | * http://www.knowledgetree.com/KPL | 6 | * http://www.knowledgetree.com/KPL |
| 7 | - * | 7 | + * |
| 8 | * Software distributed under the License is distributed on an "AS IS" | 8 | * Software distributed under the License is distributed on an "AS IS" |
| 9 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. | 9 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. |
| 10 | * See the License for the specific language governing rights and | 10 | * See the License for the specific language governing rights and |
| @@ -15,9 +15,9 @@ | @@ -15,9 +15,9 @@ | ||
| 15 | * (ii) the KnowledgeTree copyright notice | 15 | * (ii) the KnowledgeTree copyright notice |
| 16 | * in the same form as they appear in the distribution. See the License for | 16 | * in the same form as they appear in the distribution. See the License for |
| 17 | * requirements. | 17 | * requirements. |
| 18 | - * | 18 | + * |
| 19 | * The Original Code is: KnowledgeTree Open Source | 19 | * The Original Code is: KnowledgeTree Open Source |
| 20 | - * | 20 | + * |
| 21 | * The Initial Developer of the Original Code is The Jam Warehouse Software | 21 | * The Initial Developer of the Original Code is The Jam Warehouse Software |
| 22 | * (Pty) Ltd, trading as KnowledgeTree. | 22 | * (Pty) Ltd, trading as KnowledgeTree. |
| 23 | * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright | 23 | * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright |
| @@ -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 |