diff --git a/class2.php b/class2.php
index 4bf9be3c2..16b9a4cea 100644
--- a/class2.php
+++ b/class2.php
@@ -522,14 +522,21 @@ if(varset($pref['multilanguage']) && (e_LANGUAGE != $pref['sitelanguage']))
$sql2->mySQLlanguage = e_LANGUAGE;
}
-//TODO do it only once and with the proper function
-e107_include_once(e_LANGUAGEDIR.e_LANGUAGE.'/'.e_LANGUAGE.'.php');
-e107_include_once(e_LANGUAGEDIR.e_LANGUAGE."/".e_LANGUAGE.'_custom.php');
+//do it only once and with the proper function
+// e107_include_once(e_LANGUAGEDIR.e_LANGUAGE.'/'.e_LANGUAGE.'.php');
+// e107_include_once(e_LANGUAGEDIR.e_LANGUAGE.'/'.e_LANGUAGE.'_custom.php');
+include(e_LANGUAGEDIR.e_LANGUAGE.'/'.e_LANGUAGE.'.php'); // FASTEST - ALWAYS load
+$customLan = e_LANGUAGEDIR.e_LANGUAGE.'/'.e_LANGUAGE.'_custom.php';
+if(is_readable($customLan)) // FASTER - if exist, should be done 'once' by the core
+{
+ include($customLan);
+}
+unset($customLan);
e107::getSession()
->challenge() // Create a unique challenge string for CHAP login
->check(); // Token protection
-// echo e_print($_SESSION, e107::getSession()->getSessionId(), e107::getSession()->getSessionName());
+
//
// N: misc setups: online user tracking, cache
//
diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php
index 20d2479c2..006fea863 100644
--- a/e107_handlers/e107_class.php
+++ b/e107_handlers/e107_class.php
@@ -1704,6 +1704,68 @@ class e107
$ret = ($force) ? include($path) : include_once($path);
return (isset($ret)) ? $ret : "";
}
+
+ /**
+ * Simplify importing of core Language files.
+ * All inputs are sanitized.
+ * Core Exceptions as e_LANGUAGE.'.php' and e_LANGUAGE.'_custom.php' are manually loaded. (see class2.php)
+ *
+ * Examples:
+ *
+ * e107::coreLan('comment');
+ *
+ * // import defeinitions from /e107_languages/[CurrentLanguage]/admin/lan_banlist.php
+ * e107::coreLan('banlist', true);
+ *
+ *
+ * @param string $fname filename without the extension part (e.g. 'comment')
+ * @param boolean $admin true if it's an administration language file
+ * @return void
+ */
+ public static function coreLan($fname, $admin = false)
+ {
+ $fname = ($admin ? 'admin/' : '').'lan_'.preg_replace('/[^\w]/', '', $fname).'.php';
+ $path = e_LANGUAGEDIR.e_LANGUAGE.'/'.$fname;
+
+ self::includeLan($path, false);
+ }
+
+ /**
+ * Simplify importing of plugin Language files (following e107 plugin structure standards).
+ * All inputs are sanitized.
+ *
+ * Examples:
+ *
+ * e107::plugLan('forum', 'lan_forum');
+ *
+ * // import defeinitions from /e107_plugins/featurebox/languages/[CurrentLanguage]_admin_featurebox.php
+ * e107::plugLan('featurebox', 'admin_featurebox', true);
+ *
+ * // import defeinitions from /e107_plugins/myplug/languages/[CurrentLanguage].php
+ * e107::plugLan('myplug');
+ *
+ * // import defeinitions from /e107_plugins/myplug/languages/[CurrentLanguage].php
+ * e107::plugLan('myplug', 'admin/common');
+ *
+ *
+ * @param string $plugin plugin name
+ * @param string $fname filename without the extension part (e.g. 'common')
+ * @param boolean $flat false (default, preferred) Language folder structure; true - prepend Language to file name
+ * @return void
+ */
+ public static function plugLan($plugin, $fname = '', $flat = false)
+ {
+ $plugin = preg_replace('/[^\w]/', '', $plugin);
+
+ if($fname) $fname = e_LANGUAGE.($flat ? '_' : '/').preg_replace('#[^\w/]#', '', $fname);
+ else $fname = e_LANGUAGE;
+
+ $path = e_PLUGIN.$plugin.'/languages/'.$fname.'.php';
+
+ self::includeLan($path, false);
+ }
/**
* Routine looks in standard paths for language files associated with a plugin or