aboutsummaryrefslogtreecommitdiff
path: root/ratatoeskr/sys/translation.php
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2011-09-21 17:00:50 +0200
committerKevin Chabowski <kevin@kch42.de>2011-09-21 17:00:50 +0200
commit8311cba002dfcaf1836530b978f944f7228ac004 (patch)
treed8ff9eac15957194a53e4c6e94d4bd9eb2d89c2d /ratatoeskr/sys/translation.php
parenta85e1fbbfbbaef176141e98a4691273cd06d0a65 (diff)
downloadratatoeskr-cms-8311cba002dfcaf1836530b978f944f7228ac004.tar.gz
ratatoeskr-cms-8311cba002dfcaf1836530b978f944f7228ac004.tar.bz2
ratatoeskr-cms-8311cba002dfcaf1836530b978f944f7228ac004.zip
Replaced Smarty with STE and started the backend.
Diffstat (limited to 'ratatoeskr/sys/translation.php')
-rw-r--r--ratatoeskr/sys/translation.php55
1 files changed, 55 insertions, 0 deletions
diff --git a/ratatoeskr/sys/translation.php b/ratatoeskr/sys/translation.php
new file mode 100644
index 0000000..01f7c6d
--- /dev/null
+++ b/ratatoeskr/sys/translation.php
@@ -0,0 +1,55 @@
+<?php
+/*
+ * File: ratatoeskr/backend/main.php
+ * Load translation.
+ *
+ * License:
+ * This file is part of Ratatöskr.
+ * Ratatöskr is licensed unter the MIT / X11 License.
+ * See "ratatoeskr/licenses/ratatoeskr" for more information.
+ */
+
+require_once(dirname(__FILE__) . "/models.php");
+require_once(dirname(__FILE__) . "/init_ste.php");
+
+if(!defined(TRANSLATION_PLUGIN_LOADED))
+{
+ $ste->register_tag(
+ "get_translation",
+ function($ste, $params, $sub)
+ {
+ global $translation;
+ if((!isset($translation)) or empty($params["for"]) or (!isset($translation[$params["for"]])))
+ return "";
+ return $translation[$params["for"]];
+ }
+ );
+ define(TRANSLATION_PLUGIN_LOADED, True);
+}
+
+/*
+ * Function: load_language
+ * Load a language (i.e. set the global $translation variable).
+ *
+ * Parameters:
+ * $lang - The language (2-Letter code, e.g. "en", "de", "it" ...) to load. NULL for default (from database).
+ */
+function load_language($lang=NULL)
+{
+ global $ratatoeskr_settings;
+ if($lang === NULL)
+ $lang = $ratatoeskr_settings["default_language"];
+
+ /*
+ * Because we will include an file defined by the $lang param, we will
+ * only allow alphabetic characters, so this function should not be
+ * vulnerable to LFI-Exploits...
+ */
+ $lang = implode("", array_filter(str_split($lang, 1), "ctype_alpha"));
+
+ require(dirname(__FILE__) . "/../translations/$lang.php");
+
+ $GLOBALS["translation"] = $translation;
+}
+
+?>