Index: branches/2.8.x/Klasse_Translate_de.pdf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: branches/2.8.x/Klasse_Translate_de.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: branches/2.8.x/CHANGELOG
===================================================================
--- branches/2.8.x/CHANGELOG	(revision 1863)
+++ branches/2.8.x/CHANGELOG	(revision 1864)
@@ -11,6 +11,14 @@
 ! = Update/Change
 ===============================================================================
 
+19 Feb-2013 Build 1864 Werner v.d.Decken(DarkViper)
+! update classes Translate, TranslateTable, TranslateAdaptorWbOldStyle
++ added interface TranslateAdaptorInterface
++ added Klasse_Translate_de.pdf
+! update class WbAdaptor
+! update /framework/initialize.php
+19 Feb-2013 Build 1863 Werner v.d.Decken(DarkViper)
+! updated Twig template engine to stable version 1.12.2
 19 Feb-2013 Build 1862 Werner v.d.Decken(DarkViper)
 ! updated Twig template engine to stable version 1.12.2
 18 Feb-2013 Build 1861 Werner v.d.Decken(DarkViper)
Index: branches/2.8.x/wb/admin/interface/version.php
===================================================================
--- branches/2.8.x/wb/admin/interface/version.php	(revision 1863)
+++ branches/2.8.x/wb/admin/interface/version.php	(revision 1864)
@@ -51,5 +51,5 @@
 
 // check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
 if(!defined('VERSION')) define('VERSION', '2.8.3');
-if(!defined('REVISION')) define('REVISION', '1862');
+if(!defined('REVISION')) define('REVISION', '1864');
 if(!defined('SP')) define('SP', '');
Index: branches/2.8.x/wb/framework/TranslateAdaptorInterface.php
===================================================================
--- branches/2.8.x/wb/framework/TranslateAdaptorInterface.php	(nonexistent)
+++ branches/2.8.x/wb/framework/TranslateAdaptorInterface.php	(revision 1864)
@@ -0,0 +1,42 @@
+<?php
+
+/**
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * TranslateAdaptorInterface.php
+ *
+ * @category     Core
+ * @package      Core_Translation
+ * @author       Werner v.d.Decken <wkl@isteam.de>
+ * @copyright    Werner v.d.Decken <wkl@isteam.de>
+ * @license      http://www.gnu.org/licenses/gpl.html   GPL License
+ * @version      0.0.1
+ * @revision     $Revision$
+ * @link         $HeadURL$
+ * @lastmodified $Date$
+ * @since        File available since 06.02.2013
+ * @description  definitions for all TranslateAdaptorXxxxx
+ */
+interface TranslateAdaptorInterface {
+	
+	public function __construct($sAddon = '');
+	public function loadLanguage($sLangCode);
+	public function findFirstLanguage();
+	
+} // end of interface TranslateAdaptorInterface
+

Property changes on: branches/2.8.x/wb/framework/TranslateAdaptorInterface.php
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Date Author Id Revision HeadURL
\ No newline at end of property
Index: branches/2.8.x/wb/framework/Translate.php
===================================================================
--- branches/2.8.x/wb/framework/Translate.php	(revision 1863)
+++ branches/2.8.x/wb/framework/Translate.php	(revision 1864)
@@ -35,13 +35,20 @@
 class Translate {
 	
 //  @object hold the Singleton instance 
-	private static $_oInstance   = null;
+	private static $_oInstance     = null;
 	
-	protected $_sAdaptor         = 'WbOldStyle';
-	protected $_sDefaultLanguage = 'en';
-	protected $_sUserLanguage    = 'en';
-	protected $_aAddons          = array();
-	protected $_aTranslations    = array();
+	protected $sAdaptor            = 'WbOldStyle';
+	protected $sSystemLanguage     = 'en';
+	protected $sDefaultLanguage    = 'en';
+	protected $sUserLanguage       = 'en';
+	protected $bUseCache           = true;
+/** TranslationTable objects of all loaded addons */
+	protected $aLoadedAddons       = array();
+/** TranslationTable object of the core and additional one activated addon */	
+	protected $aActiveTranslations = array();
+	
+	const CACHE_ENABLED = true;
+	const CACHE_DISABLED = false;
 
 /** prevent class from public instancing and get an object to hold extensions */
 	protected function  __construct() {}
@@ -64,31 +71,46 @@
  * @param string UserLanguage code ('de' || 'de_CH' || 'de_CH_uri')
  * @throws TranslationException
  */
-	public function initialize($sDefaultLanguage, $sUserLanguage = '', $sAdaptor = 'WbOldStyle') 
+	public function initialize($sSystemLanguage, $sDefaultLanguage, $sUserLanguage = '', 
+	                           $sAdaptor = 'WbOldStyle', $bUseCache = self::CACHE_ENABLED) 
 	{
 		if(!class_exists('TranslateAdaptor'.$sAdaptor)) {
 			throw new TranslationException('unable to load adaptor: '.$sAdaptor);
 		}
-		$this->_sAdaptor = $sAdaptor;
-		$this->_sDefaultLanguage = $sDefaultLanguage;
+		$this->bUseCache = $bUseCache;
+		$this->sAdaptor = 'TranslateAdaptor'.$sAdaptor;
+		// if no system language is set then use language 'en'
+		$this->sSystemLanguage = (trim($sSystemLanguage) == '' ? 'en' : $sSystemLanguage);
+		// if no default language is set then use system language
+		$this->sDefaultLanguage = (trim($sDefaultLanguage) == '' 
+		                            ? $this->sSystemLanguage 
+		                            : $sDefaultLanguage);
 		// if no user language is set then use default language
-		$this->_sUserLanguage = ($sUserLanguage == '' ? $sDefaultLanguage : $sUserLanguage);
+		$this->sUserLanguage = (trim($sUserLanguage) == '' 
+		                         ? $this->sDefaultLanguage 
+		                         : $sUserLanguage);
 		$sPattern = '/^[a-z]{2,3}(?:(?:\_[a-z]{2})?(?:\_[a-z0-9]{2,4})?)$/siU';
 		// validate language codes
-		if(preg_match($sPattern, $this->_sDefaultLanguage) &&
-		   preg_match($sPattern, $this->_sUserLanguage))
+		if(preg_match($sPattern, $this->sSystemLanguage) &&
+		   preg_match($sPattern, $this->sDefaultLanguage) &&
+		   preg_match($sPattern, $this->sUserLanguage))
 		{
 		// load core translations and activate it
-			$oTmp = new TranslationTable('', $this->_sDefaultLanguage, $this->_sUserLanguage);
-			$this->_aAddons['core'] = $oTmp->load($this->_sAdaptor);
-			$this->_aTranslations[0] = $this->_aAddons['core'];
-			if(sizeof($this->_aAddons['core']) == 0) {
+			$oTmp = new TranslationTable('', 
+			                             $this->sSystemLanguage, 
+			                             $this->sDefaultLanguage, 
+			                             $this->sUserLanguage,
+			                             $this->bUseCache);
+			$this->aLoadedAddons['core'] = $oTmp->load($this->sAdaptor);
+			$this->aActiveTranslations[0] = $this->aLoadedAddons['core'];
+			if(sizeof($this->aLoadedAddons['core']) == 0) {
 			// throw an exception for missing translations
 				throw new TranslationException('missing core translations');
 			}
 		}else {
 		// throw an exception for invalid or missing language codes
-			$sMsg = 'Invalid language codes: ['.$this->_sDefaultLanguage.'] ['.$this->_sUserLanguage.']';
+			$sMsg = 'Invalid language codes: ['.$this->sSystemLanguage.'] or ['
+			      . $this->sDefaultLanguage.'] or ['.$this->sUserLanguage.']';
 			throw new TranslationException($sMsg);
 		}
 	}
@@ -99,10 +121,14 @@
  */	
 	public function addAddon($sAddon)
 	{
-		if(!(strtolower($sAddon) == 'core' || $sAddon == '' || isset($this->_aAddons[$sAddon]))) {
+		if(!(strtolower($sAddon) == 'core' || $sAddon == '' || isset($this->aLoadedAddons[$sAddon]))) {
 		// load requested addon translations if needed and possible
-			$oTmp = new TranslationTable($sAddon, $this->_sDefaultLanguage, $this->_sUserLanguage);
-			$this->_aAddons[$sAddon] = $oTmp->load($this->_sAdaptor);
+			$oTmp = new TranslationTable($sAddon, 
+			                             $this->sSystemLanguage, 
+			                             $this->sDefaultLanguage, 
+			                             $this->sUserLanguage,
+			                             $this->bUseCache);
+			$this->aLoadedAddons[$sAddon] = $oTmp->load($this->sAdaptor);
 		}
 	}
 /**
@@ -112,18 +138,20 @@
 	public function enableAddon($sAddon)
 	{
 		if(!(strtolower($sAddon) == 'core' || $sAddon == '')) {
-			if(!isset($this->_aAddons[$sAddon])) {
+			if(!isset($this->aLoadedAddons[$sAddon])) {
 				$this->addAddon($sAddon);
 			}
-			$this->_aTranslations[1] = $this->_aAddons[$sAddon];
+			$this->aActiveTranslations[1] = $this->aLoadedAddons[$sAddon];
 		}
 		
 	}
-	
+/**
+ * Dissable active addon
+ */	
 	public function disableAddon()
 	{
-		if(isset($this->_aTranslations[1])) {
-			unset($this->_aTranslations[1]);
+		if(isset($this->aActiveTranslations[1])) {
+			unset($this->aActiveTranslations[1]);
 		}
 	}
 	
@@ -134,7 +162,7 @@
  */
 	public function __isset($sKey)
 	{
-		foreach($this->_aTranslations as $oAddon) {
+		foreach($this->aActiveTranslations as $oAddon) {
 			if(isset($oAddon->$sKey)) {
 			// is true if at least one translation is found
 				return true;
@@ -150,7 +178,7 @@
 	public function __get($sKey)
 	{
 		$sRetval = '';
-		foreach($this->_aTranslations as $oAddon) {
+		foreach($this->aActiveTranslations as $oAddon) {
 			if(isset($oAddon->$sKey)) {
 			// search the last matching translation (Core -> Addon)
 				$sRetval = $oAddon->$sKey;
@@ -165,11 +193,13 @@
  */	
 	public function getLangArray()
 	{
-		$aTranslations = array();
-		foreach($this->_aTranslations as $aTranslation) {
-			$aTranslations = array_merge($aTranslations, $aTranslation);
+		$aSumTranslations = array();
+		foreach($this->aActiveTranslations as $oTranslationTable) {
+			if(get_class($oTranslationTable) == 'TranslationTable') {
+				$aSumTranslations = array_merge($aSumTranslations, $oTranslationTable->getArray());
+			}
 		}
-		return $aTranslations;
+		return $aSumTranslations;
 	}
 	
 } // end of class Translate
Index: branches/2.8.x/wb/framework/initialize.php
===================================================================
--- branches/2.8.x/wb/framework/initialize.php	(revision 1863)
+++ branches/2.8.x/wb/framework/initialize.php	(revision 1864)
@@ -1,26 +1,39 @@
 <?php
 /**
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * @category        framework
- * @package         initialize
- * @author          Ryan Djurovich, WebsiteBaker Project
- * @copyright       2009-2012, WebsiteBaker Org. e.V.
- * @link			http://www.websitebaker2.org/
- * @license         http://www.gnu.org/licenses/gpl.html
- * @platform        WebsiteBaker 2.8.x
- * @requirements    PHP 5.2.2 and higher
- * @version         $Id$
- * @filesource		$HeadURL$
- * @lastmodified    $Date$
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
  *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/* -------------------------------------------------------- */
-// Must include code to stop this file being accessed directly
-require_once(dirname(__FILE__).'/globalExceptionHandler.php');
-if(!defined('WB_URL')) { throw new IllegalFileException(); }
-/* -------------------------------------------------------- */
 /**
+ * initialize.php
+ *
+ * @category     Core
+ * @package      Core_Environment
+ * @author       Werner v.d.Decken <wkl@isteam.de>
+ * @copyright    Werner v.d.Decken <wkl@isteam.de>
+ * @license      http://www.gnu.org/licenses/gpl.html   GPL License
+ * @version      0.0.1
+ * @revision     $Revision$
+ * @link         $HeadURL$
+ * @lastmodified $Date$
+ * @since        File replaced since 05.02.2013
+ * @description  set the basic environment to run WebsiteBaker
+ */
+
+/* *** define some helper functions *** */
+/**
  * sanitize $_SERVER['HTTP_REFERER']
  * @param string $sWbUrl qualified startup URL of current application
  */
@@ -48,9 +61,12 @@
 		}
 		$_SERVER['HTTP_REFERER'] = $sTmpReferer;
 	}
-/* -------------------------------------------------------- */
+/**
+ * Set constants for system/install values
+ * @throws RuntimeException
+ */
 	function SetInstallPathConstants() {
-		if(!defined('DEBUG')){ define('DEBUG', false); }// Include config file
+		if(!defined('DEBUG')){ define('DEBUG', false); } // normaly set in config file
 		if(!defined('ADMIN_DIRECTORY')){ define('ADMIN_DIRECTORY', 'admin'); }
 		if(!preg_match('/xx[a-z0-9_][a-z0-9_\-\.]+/i', 'xx'.ADMIN_DIRECTORY)) {
 			throw new RuntimeException('Invalid admin-directory: ' . ADMIN_DIRECTORY);
@@ -62,135 +78,211 @@
 			$x1 = parse_url(WB_URL);
 			define('WB_REL', (isset($x1['path']) ? $x1['path'] : ''));
 		}
+		define('ADMIN_REL', WB_REL.'/'.ADMIN_DIRECTORY);
 		if(!defined('DOCUMENT_ROOT')) {
+			
 			define('DOCUMENT_ROOT', preg_replace('/'.preg_quote(WB_REL, '/').'$/', '', WB_PATH));
 		}
+		define('TMP_PATH', WB_PATH.'/temp');
 	}
-/* -------------------------------------------------------- */
+/**
+ * Read DB settings from configuration file
+ * @return string
+ * @throws RuntimeException
+ * 
+ */
+	function readConfiguration($sRetvalType = 'url') {
+		$x = debug_backtrace();
+		if(sizeof($x) != 0) { throw new RuntimeException('illegal function request!'); }
+		$aRetval = array();
+		$sSetupFile = dirname(dirname(__FILE__)).'/setup.ini.php';
+		if(is_readable($sSetupFile)) {
+			$aCfg = parse_ini_file($sSetupFile, true);
+			foreach($aCfg['Constants'] as $key=>$value) {
+				if($key == 'debug') { $value = filter_var($value, FILTER_VALIDATE_BOOLEAN); }
+				if(!defined(strtoupper($key))) { define(strtoupper($key), $value); }
+			}
+			$db = $aCfg['DataBase'];
+			$db['type'] = isset($db['type']) ? $db['type'] : 'mysql';
+			$db['user'] = isset($db['user']) ? $db['user'] : 'foo';
+			$db['pass'] = isset($db['pass']) ? $db['pass'] : 'bar';
+			$db['host'] = isset($db['host']) ? $db['host'] : 'localhost';
+			$db['port'] = isset($db['port']) ? $db['port'] : '3306';
+			$db['port'] = ($db['port'] != '3306') ? $db['port'] : '';
+			$db['name'] = isset($db['name']) ? $db['name'] : 'dummy';
+			$db['charset'] = isset($db['charset']) ? $db['charset'] : 'utf8';
+			$db['table_prefix'] = (isset($db['table_prefix']) ? $db['table_prefix'] : '');
+			define('TABLE_PREFIX', $db['table_prefix']);
+			if($sRetvalType == 'dsn') {
+				$aRetval[0] = $db['type'].':dbname='.$db['name'].';host='.$db['host'].';'
+				            . ($db['port'] != '' ? 'port='.(int)$db['port'].';' : '');
+				$aRetval[1] = array('CHARSET' => $db['charset'], 'TABLE_PREFIX' => $db['table_prefix']);
+				$aRetval[2] = array( 'user' => $db['user'], 'pass' => $db['pass']);
+			}else { // $sRetvalType == 'url'
+				$aRetval[0] = $db['type'].'://'.$db['user'].':'.$db['pass'].'@'
+				            . $db['host'].($db['port'] != '' ? ':'.$db['port'] : '').'/'.$db['name'];
+			}
+			unset($db, $aCfg);
+			return $sRetval;
+		}
+		throw new RuntimeException('unable to read setup.ini.php');
+	}
+/* ***************************************************************************************
+ * Start initialization                                                                  *
+ ****************************************************************************************/
+// initialize debug evaluation values ---	
+	$sDbConnectType = 'url'; // depending from class WbDatabase it can be 'url' or 'dsn'
 	$starttime = array_sum(explode(" ",microtime()));
-	$iPhpDeclaredClasses =  sizeof(get_declared_classes());
+	$iPhpDeclaredClasses = sizeof(get_declared_classes());
+// disable all kind of magic_quotes in PHP versions before 5.4 ---
+	if(version_compare(PHP_VERSION, '5.4.0', '<')) {
+		if(get_magic_quotes_gpc() || get_magic_quotes_runtime()) {
+			@ini_set('magic_quotes_sybase', 0);
+			@ini_set('magic_quotes_gpc', 0);
+			@ini_set('magic_quotes_runtime', 0);
+		}
+	}
+// define constant systemenvironment settings ---
 	SetInstallPathConstants();
-	SanitizeHttpReferer(WB_URL); // sanitize $_SERVER['HTTP_REFERER']
-	if(!class_exists('WbAutoloader', false)){ include(dirname(__FILE__).'/WbAutoloader.php'); }
+	date_default_timezone_set('UTC');
+	if(!defined('MAX_TIME')) { define('MAX_TIME', (pow(2, 31)-1)); } // 32-Bit Timestamp of 19 Jan 2038 03:14:07 GMT
+	if(!defined('DO_NOT_TRACK')) { define('DO_NOT_TRACK', (isset($_SERVER['HTTP_DNT']))); }
+// register WB basic autoloader ---
+	$sTmp = dirname(__FILE__).'/WbAutoloader.php';
+	if(!class_exists('WbAutoloader', false)){ include($sTmp); }
 	WbAutoloader::doRegister(array(ADMIN_DIRECTORY=>'a', 'modules'=>'m'));
-	require_once dirname(dirname(__FILE__)).'/include/Twig/Autoloader.php';
+// register TWIG autoloader ---
+//	$sTmp = dirname(dirname(__FILE__)).'/include/Sensio/Twig/lib/Twig/Autoloader.php';
+	$sTmp = dirname(dirname(__FILE__)).'/include/Twig/Autoloader.php';
+	if(!class_exists('Twig_Autoloader', false)){ include($sTmp); }
 	Twig_Autoloader::register();
-	date_default_timezone_set('UTC');
-	// Create database class
-	$sSqlUrl = DB_TYPE.'://'.DB_USERNAME.':'.DB_PASSWORD.'@'.DB_HOST.'/'.DB_NAME;
+// aktivate exceptionhandler ---
+	if(!function_exists('globalExceptionHandler')) {
+		include(dirname(__FILE__).'/globalExceptionHandler.php');
+	}
+// load db configuration ---
+	if(defined('DB_TYPE')) {
+		$aSqlData = array( 0 => DB_TYPE.'://'.DB_USERNAME.':'.DB_PASSWORD.'@'.DB_HOST.'/'.DB_NAME);
+	}else {
+		$aSqlData = readConfiguration($sDbConnectType);
+	}
+// sanitize $_SERVER['HTTP_REFERER'] ---
+	SanitizeHttpReferer(WB_URL); 
+// ---------------------------
+// Create global database instance ---
 	$database = WbDatabase::getInstance();
-	$database->doConnect($sSqlUrl);
-	// disable all kind of magic_quotes
-	if(get_magic_quotes_gpc() || get_magic_quotes_runtime()) {
-		@ini_set('magic_quotes_sybase', 0);
-		@ini_set('magic_quotes_gpc', 0);
-		@ini_set('magic_quotes_runtime', 0);
+	if($sDbConnectType == 'dsn') {
+		$database->doConnect($aSqlData[0], $aSqlData[1]['user'], $aSqlData[1]['pass'], $aSqlData[2]);
+	}else {
+		$database->doConnect($aSqlData[0], TABLE_PREFIX);
 	}
-	// Get website settings (title, keywords, description, header, and footer)
-	$query_settings = "SELECT name,value FROM ".TABLE_PREFIX."settings";
-	$get_settings = $database->query($query_settings);
-	if($database->is_error()) { die($database->get_error()); }
-	if($get_settings->numRows() == 0) { die("Settings not found"); }
-	while($setting = $get_settings->fetchRow()) {
-		$setting_name=strtoupper($setting['name']);
-		$setting_value=$setting['value'];
-//		if ($setting_value=='') {$setting_value=false;}
-		if ($setting_value=='false'){$setting_value=false;}
-		if ($setting_value=='true'){$setting_value=true;}
-		@define($setting_name,$setting_value);
-	}
-	@define('DO_NOT_TRACK', (isset($_SERVER['HTTP_DNT'])));
-	$string_file_mode = STRING_FILE_MODE;
+	unset($aSqlData);
+// load global settings from database and define global consts from ---
+	$sql = 'SELECT `name`, `value` FROM `'.TABLE_PREFIX.'settings`';
+	if(($oSettings = $database->query($sql))) {
+		if(!$oSettings->numRows()) { throw new AppException('no settings found'); }
+		while($aSetting = $oSettings->fetchRow(MYSQL_ASSOC)) {
+			//sanitize true/false values
+			$aSetting['value'] = ($aSetting['value'] == 'true' 
+								  ? true 
+								  : ($aSetting['value'] == 'false' 
+									 ? false 
+									 : $aSetting['value'])
+								 );
+			// make global const from setting
+			@define(strtoupper($aSetting['name']), $aSetting['value']);
+		}
+	}else { throw new AppException($database->get_error()); }
+// get/set users timezone ---
+	define('TIMEZONE',    (isset($_SESSION['TIMEZONE'])    ? $_SESSION['TIMEZONE']    : DEFAULT_TIMEZONE));
+	define('DATE_FORMAT', (isset($_SESSION['DATE_FORMAT']) ? $_SESSION['DATE_FORMAT'] : DEFAULT_DATE_FORMAT));
+	define('TIME_FORMAT', (isset($_SESSION['TIME_FORMAT']) ? $_SESSION['TIME_FORMAT'] : DEFAULT_TIME_FORMAT));
+// set Theme directory --- 
+	define('THEME_URL',  WB_URL.'/templates/'.DEFAULT_THEME);
+	define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);
+	define('THEME_REL',  WB_REL.'/templates/'.DEFAULT_THEME);
+// extended wb editor settings
+	define('EDIT_ONE_SECTION', false);
+	define('EDITOR_WIDTH', 0);
+// define numeric, octal values for chmod operations ---	
+	$string_file_mode = STRING_FILE_MODE; // STRING_FILE_MODE is set deprecated
 	define('OCTAL_FILE_MODE',(int) octdec($string_file_mode));
-	$string_dir_mode = STRING_DIR_MODE;
+	$string_dir_mode = STRING_DIR_MODE; // STRING_DIR_MODE is set deprecated
 	define('OCTAL_DIR_MODE',(int) octdec($string_dir_mode));
+// define form security class and preload it ---
 	$sSecMod = (defined('SECURE_FORM_MODULE') && SECURE_FORM_MODULE != '') ? '.'.SECURE_FORM_MODULE : '';
 	$sSecMod = WB_PATH.'/framework/SecureForm'.$sSecMod.'.php';
 	require_once($sSecMod);
-	if (!defined("WB_INSTALL_PROCESS")) {
-		// get CAPTCHA and ASP settings
-		$table = TABLE_PREFIX.'mod_captcha_control';
-		if( ($get_settings = $database->query("SELECT * FROM $table LIMIT 1")) ) {
-			if($get_settings->numRows() == 0) { die("CAPTCHA-Settings not found"); }
-			$setting = $get_settings->fetchRow();
-			if($setting['enabled_captcha'] == '1') define('ENABLED_CAPTCHA', true);
-			else define('ENABLED_CAPTCHA', false);
-			if($setting['enabled_asp'] == '1') define('ENABLED_ASP', true);
-			else define('ENABLED_ASP', false);
-			define('CAPTCHA_TYPE', $setting['captcha_type']);
-			define('ASP_SESSION_MIN_AGE', (int)$setting['asp_session_min_age']);
-			define('ASP_VIEW_MIN_AGE', (int)$setting['asp_view_min_age']);
-			define('ASP_INPUT_MIN_AGE', (int)$setting['asp_input_min_age']);
-		}
-	}
-
-	// set error-reporting
-	if(intval(ER_LEVEL) > 0 )
-	{
+// set error-reporting from loaded settings ---
+	if(intval(ER_LEVEL) > 0 ) {
 		error_reporting(ER_LEVEL);
-		if( intval(ini_get ( 'display_errors' )) == 0 )
-		{
+		if( intval(ini_get ( 'display_errors' )) == 0 ) {
 			ini_set('display_errors', 1);
 		}
 	}
-	// Start a session
+// Start a session ---
 	if(!defined('SESSION_STARTED')) {
 		session_name(APP_NAME.'_session_id');
 		@session_start();
 		define('SESSION_STARTED', true);
 	}
-	if(defined('ENABLED_ASP') && ENABLED_ASP && !isset($_SESSION['session_started']))
+// *** begin deprecated part *************************************************************
+// load settings for use in Captch and ASP module
+	if (!defined("WB_INSTALL_PROCESS")) {
+		$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_captcha_control`';
+		// request settings from database
+		if(($oSettings = $database->query($sql))) {
+			if(($aSetting = $oSettings->fetchRow(MYSQL_ASSOC))) {
+				define('ENABLED_CAPTCHA', ($aSetting['enabled_captcha'] == '1'));
+				define('ENABLED_ASP', ($aSetting['enabled_asp'] == '1'));
+				define('CAPTCHA_TYPE', $aSetting['captcha_type']);
+				define('ASP_SESSION_MIN_AGE', (int)$aSetting['asp_session_min_age']);
+				define('ASP_VIEW_MIN_AGE', (int)$aSetting['asp_view_min_age']);
+				define('ASP_INPUT_MIN_AGE', (int)$aSetting['asp_input_min_age']);
+			}
+		}
+	}
+	if(defined('ENABLED_ASP') && ENABLED_ASP && !isset($_SESSION['session_started'])) {
 		$_SESSION['session_started'] = time();
-
-
-
-	// Get users language
-	$requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
-	$language = (intval(isset(${$requestMethod}['lang'])) ? ${$requestMethod}['lang'] : null);
-	if(isset($language) AND $language != '' AND !is_numeric($language) AND strlen($language) == 2) {
-		define('LANGUAGE', strtoupper($language));
+	}
+// *** end of deprecated part ************************************************************
+// get user language ---
+	$sRequestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
+	// check if get/post value is available
+	$sTempLanguage = (isset(${$sRequestMethod}['lang']) ? ${$sRequestMethod}['lang'] : '');
+	// validate language code
+	if(preg_match('/^[a-z]{2}$/si', $sTempLanguage)) {
+	// if there's valid get/post
+		define('LANGUAGE', strtoupper($sTempLanguage));
 		$_SESSION['LANGUAGE']=LANGUAGE;
-	} else {
-		if(isset($_SESSION['LANGUAGE']) AND $_SESSION['LANGUAGE'] != '') {
+	}else {
+		if(isset($_SESSION['LANGUAGE']) && $_SESSION['LANGUAGE']) {
+		// if there's valid session value
 			define('LANGUAGE', $_SESSION['LANGUAGE']);
-		} else {
+		}else {
+		// otherwise set to default
 			define('LANGUAGE', DEFAULT_LANGUAGE);
 		}
 	}
-
-	// Load Language file
-	if(!defined('LANGUAGE_LOADED')) {
-		if(!file_exists(WB_PATH.'/languages/'.LANGUAGE.'.php')) {
-			exit('Error loading language file '.LANGUAGE.', please check configuration');
-		} else {
-			require_once(WB_PATH.'/languages/'.LANGUAGE.'.php');
-		}
-	}
-
-	// Get users timezone
-	if(isset($_SESSION['TIMEZONE'])) {
-		define('TIMEZONE', $_SESSION['TIMEZONE']);
+// activate translations / load language definitions
+/** begin of deprecated part || will be replaced by class Translate **/	
+// Load Language file
+	if(!file_exists(WB_PATH.'/languages/'.LANGUAGE.'.php')) {
+		$sMsg = 'Error loading language file '.LANGUAGE.', please check configuration';
+		throw new AppException($sMsg);
 	} else {
-		define('TIMEZONE', DEFAULT_TIMEZONE);
+	// include language file
+		require_once(WB_PATH.'/languages/'.LANGUAGE.'.php');
 	}
-	// Get users date format
-	if(isset($_SESSION['DATE_FORMAT'])) {
-		define('DATE_FORMAT', $_SESSION['DATE_FORMAT']);
-	} else {
-		define('DATE_FORMAT', DEFAULT_DATE_FORMAT);
+/** end of deprecated part **/
+// instantiate and initialize adaptor for temporary registry replacement ---
+	if(class_exists('WbAdaptor')) {
+		WbAdaptor::getInstance()->getWbConstants();
 	}
-	// Get users time format
-	if(isset($_SESSION['TIME_FORMAT'])) {
-		define('TIME_FORMAT', $_SESSION['TIME_FORMAT']);
-	} else {
-		define('TIME_FORMAT', DEFAULT_TIME_FORMAT);
-	}
-
-	// Set Theme dir
-	define('THEME_URL', WB_URL.'/templates/'.DEFAULT_THEME);
-	define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);
-
-	// extended wb_settings
-	define('EDIT_ONE_SECTION', false);
-
-	define('EDITOR_WIDTH', 0);
+// load and activate new global translation table
+	Translate::getInstance()->initialize('en',
+	                                     (defined('DEFAULT_LANGUAGE') ? DEFAULT_LANGUAGE : ''), 
+	                                     (defined('LANGUAGE') ? LANGUAGE : ''), 
+	                                     'WbOldStyle');
+// *** END OF FILE ***********************************************************************
+	
\ No newline at end of file
Index: branches/2.8.x/wb/framework/TranslationTable.php
===================================================================
--- branches/2.8.x/wb/framework/TranslationTable.php	(revision 1863)
+++ branches/2.8.x/wb/framework/TranslationTable.php	(revision 1864)
@@ -33,23 +33,40 @@
  */
 class TranslationTable {
 
-	private $_aTranslations = array();
-	private $_sSystemLang   = 'en';
-	private $_sDefaultLang  = 'en';
-	private $_sUserLang     = 'en';
-	private $_sAddon        = '';
-	
+	protected $aTranslations = array();
+	protected $aLanguages    = array();
+	protected $sSystemLang   = 'en';
+	protected $sDefaultLang  = 'en';
+	protected $sUserLang     = 'en';
+	protected $sAddon        = '';
+	protected $oReg          = null;
+	protected $sTempPath     = '';
+	protected $iDirMode      = 0777;
 /**
  * Constructor
  * @param string relative pathname of the Addon (i.e. '' || 'modules/myAddon/')
- * @param string Default language code ( 2ALPHA[[_2ALPHA]_2*4ALNUM] )
- * @param string User language code ( 2ALPHA[[_2ALPHA]_2*4ALNUM] )
+ * @param string System language code ( 2*3ALPHA[[_2ALPHA]_2*4ALNUM] )
+ * @param string Default language code ( 2*3ALPHA[[_2ALPHA]_2*4ALNUM] )
+ * @param string User language code ( 2*3ALPHA[[_2ALPHA]_2*4ALNUM] )
  */	
-	public function __construct($sAddon, $sDefaultLanguage, $sUserLanguage = '')
+	public function __construct($sAddon, 
+	                            $sSystemLanguage, $sDefaultLanguage, $sUserLanguage,
+	                            $bUseCache = Translate::CACHE_ENABLED)
 	{
-		$this->_sDefaultLang = $sDefaultLanguage;
-		$this->_sUserLang = ($sUserLanguage == '' ? $sDefaultLanguage : $sUserLanguage);
-		$this->_sAddon = $sAddon;
+		$this->bUseCache             = $bUseCache;
+		$this->sSystemLang           = $sSystemLanguage;
+		$this->sDefaultLang          = $sDefaultLanguage;
+		$this->sUserLang             = $sUserLanguage;
+		$this->sAddon                = $sAddon;
+		if(class_exists('WbAdaptor')) {
+			$this->sTempPath         = WbAdaptor::getInstance()->TempPath;
+			$this->iDirMode          = WbAdaptor::getInstance()->OctalDirMode;
+		}else {
+			$this->sTempPath         = dirname(dirname(__FILE__)).'/temp/';
+		}
+		$this->aLanguages['system']  = array();
+		$this->aLanguages['default'] = array();
+		$this->aLanguages['user']    = array();
 	}
 /**
  * Load language definitions
@@ -58,32 +75,77 @@
  */	
 	public function load($sAdaptor)
 	{
-		$c = 'TranslateAdaptor'.$sAdaptor;
-		$oTmp = new $c($this->_sAddon);
-		// load default language first
-		if( ($aResult = $oTmp->loadLanguage($this->_sDefaultLang)) !== false ) {
-			$this->_aTranslations = $aResult;
-		}
-		if($this->_sUserLang != $this->_sDefaultLang) {
-		// load user language if its not equal default language
-			if( ($aResult = $oTmp->loadLanguage($this->_sUserLang)) !== false ) {
-				$this->_aTranslations = array_merge($this->_aTranslations, $aResult);
+		$sCachePath	= $this->getCachePath();
+		$sCacheFile = $sCachePath.md5($this->sAddon.$this->sSystemLang.
+		                              $this->sDefaultLang.$this->sUserLang).'.php';
+		if($this->bUseCache && is_readable($sCacheFile)) {
+			$this->aTranslations = $this->loadCacheFile($sCacheFile);
+		}else {
+			$bLanguageFound = false;
+			$oAdaptor= new $sAdaptor($this->sAddon);
+			if(!$oAdaptor instanceof TranslatorAdaptorInterface) {
+				$sMsg = 'Class ['.$sAdaptor.'] does not implement the '
+				      . 'interface [TranslateAdaptorInterface]';
+				throw new TranslationException($sMsg);
 			}
-		}
-		if(($this->_sSystemLang != $this->_sUserLang) && 
-		   ($this->_sSystemLang != $this->_sDefaultLang)) {
-		// load system language if its not already loaded
-			if( ($aResult = $oTmp->loadLanguage($this->_sSystemLang)) !== false ) {
-				$this->_aTranslations = array_merge($this->_aTranslations, $aResult);
+		// load system language first
+			if(($aResult = $this->loadLanguageSegments($this->sSystemLang, $oAdaptor)) !== false) {
+			// load system language
+				$this->aLanguages['system'] = $aResult;
+				$bLanguageFound = true;
 			}
-		}
-		if(sizeof($this->_aTranslations) == 0) {
-		// if absolutely no requested language found, simply get the first available 
-			$sFirstLanguage = $oTmp->findFirstLanguage();
-		// load first found language if its not already loaded
-			if( ($aResult = $oTmp->loadLanguage($sFirstLanguage)) !== false ) {
-				$this->_aTranslations = array_merge($this->_aTranslations, $aResult);
+			if($this->sDefaultLang != $this->sSystemLang) {
+			// load default language if it's not equal system language
+				if(($aResult = $this->loadLanguageSegments($this->sDefaultLang, $oAdaptor)) !== false) {
+					$this->aLanguages['default'] = $aResult;
+					$bLanguageFound = true;
+				}
+			}else {
+			// copy system language
+				$this->aLanguages['default'] = $this->aLanguages['system'];
 			}
+			if($this->sUserLang != $this->sDefaultLang 
+			   && $this->sUserLang != $this->sSystemLang) {
+			// load user language if it's not equal default language or system language
+				if(($aResult = $this->loadLanguageSegments($this->sUserLang, $oAdaptor)) !== false) {
+					$this->aLanguages['user'] = $aResult;
+					$bLanguageFound = true;
+				}
+			}elseif($this->sUserLang == $this->sDefaultLang) {
+			// copy default language
+				$this->aLanguages['user'] = $this->aLanguages['default'];
+			}elseif($this->sUserLang == $this->sSystemLang) {
+			// copy system language
+				$this->aLanguages['user'] = $this->aLanguages['system'];
+			}
+			if($bLanguageFound) {
+			// copy user into default if default is missing
+				if(sizeof($this->aLanguages['user']) && !sizeof($this->aLanguages['default'])) {
+					$this->aLanguages['default'] = $this->aLanguages['user'];
+				}
+			// copy default into system if system is missing
+				if(sizeof($this->aLanguages['default']) && !sizeof($this->aLanguages['system'])) {
+					$this->aLanguages['system'] = $this->aLanguages['default'];
+				}
+			}
+		// if absolutely no requested language found, simply get the first available language
+			if(!$bLanguageFound) {
+				$sFirstLanguage = $oAdaptor->findFirstLanguage();
+			// load first found language if its not already loaded
+				if(($aResult = $this->loadLanguageSegments($sFirstLanguage, $oAdaptor)) !== false) {
+					$this->aLanguages['system'] = $aResult;
+					$bLanguageFound = true;
+				}
+			}
+			if($bLanguageFound) {
+				$this->aTranslations = array_merge($this->aTranslations,
+				                                    $this->aLanguages['system'],
+				                                    $this->aLanguages['default'],
+				                                    $this->aLanguages['user']);
+				if($this->bUseCache) {
+					$this->writeCacheFile($sCacheFile);
+				}
+			}
 		}
 		return $this;
 	}
@@ -94,7 +156,7 @@
  */
 	public function __isset($sKey)
 	{
-		return isset($this->_aTranslations[$sKey]);
+		return isset($this->aTranslations[$sKey]);
 	}
 /**
  * Get translation text
@@ -103,8 +165,8 @@
  */	
 	public function __get($sKey)
 	{
-		if(isset($this->_aTranslations[$sKey])) {
-			return $this->_aTranslations[$sKey];
+		if(isset($this->aTranslations[$sKey])) {
+			return $this->aTranslations[$sKey];
 		}else {
 			return '';
 		}
@@ -116,6 +178,68 @@
  */	
 	public function getArray()
 	{
-		return $this->_aTranslations;
+		$aRetval = (is_array($this->aTranslations) ? $this->aTranslations : array());
+		return $aRetval;
 	}
+/**
+ * Load Language
+ * @param string Language Code
+ * @param object Adaptor object
+ * @return bool|array
+ */
+	protected function loadLanguageSegments($sLangCode, $oAdaptor)
+	{
+		$aTranslations = array();
+		// sanitize the language code
+		$aLangCode = explode('_', preg_replace('/[^a-z0-9]/i', '_', strtolower($sLangCode)));
+		$sConcatedLang = '';
+		foreach($aLangCode as $sLang)
+		{ // iterate all segments of the language code
+			if( ($aResult = $oAdaptor->loadLanguage($sConcatedLang.$sLang)) !== false ) {
+				$aTranslations = array_merge($aTranslations, $aResult);
+			}
+		}
+		return (sizeof($aTranslations) > 0 ? $aTranslations : false);
+	}
+/**
+ * getCachePath
+ * @return string a valid path for caching or null on error
+ */
+	protected function getCachePath()
+	{
+		$sCachePath = $this->sTempPath.__CLASS__.'/cache/';
+		if(!file_exists($sCachePath) && is_writeable($this->sTempPath)) {
+			$iOldUmask = umask(0); 
+			mkdir($sCachePath, $this->iDirMode, true);
+			umask($iOldUmask); 
+		}
+		if(is_writable($sCachePath)) {
+			return $sCachePath;
+		}else {
+			return null;
+		}
+	}
+/**
+ * load cached translation table
+ * @param string path/name of the cachefile
+ * @return array list of translations
+ */	
+	protected function loadCacheFile($sCacheFile)
+	{
+		$aTranslation = array();
+		include($sCacheFile);
+		return $aTranslation;
+	}
+/**
+ * Write cache from translation
+ * @param string path/name of the cachefile
+ */	
+	protected function writeCacheFile($sCacheFile)
+	{
+		$sOutput = '<?php'."\n".'/* autogenerated cachefile */'."\n";
+		while (list($key, $value) = each($this->aTranslations)) {
+			$sOutput .= '$aTranslation[\''.$key.'\'] = \''.addslashes($value).'\';'."\n";
+		}
+		file_put_contents($sCacheFile, $sOutput, LOCK_EX);
+	}
 } // end of class TranslationTable
\ No newline at end of file
Index: branches/2.8.x/wb/framework/TranslateAdaptorWbOldStyle.php
===================================================================
--- branches/2.8.x/wb/framework/TranslateAdaptorWbOldStyle.php	(revision 1863)
+++ branches/2.8.x/wb/framework/TranslateAdaptorWbOldStyle.php	(revision 1864)
@@ -33,11 +33,9 @@
  * @description  Loads translation table from old languagefiles before WB-2.9.0.
  *               Can handle Languagecodes like 'de_DE_BAY' (2ALPHA_2ALPHA_2-4ALNUM)
  */
-class TranslateAdaptorWbOldStyle {
+class TranslateAdaptorWbOldStyle implements TranslateAdaptorInterface {
 
-	protected $sAppPath   = '';
 	protected $sAddon     = '';
-	protected $aLangTable = array();
 	protected $sFilePath  = '';
 /**
  * Constructor
@@ -46,9 +44,8 @@
 	public function __construct($sAddon = '')
 	{
 		$this->sAddon = $sAddon;
-		$this->sAppPath = dirname(dirname(__FILE__)).'/';
-		$this->sFilePath = $this->sAppPath
-		                 . trim(str_replace('\\', '/', $sAddon), '/').'/languages/';
+		$this->sFilePath = str_replace('\\', '/', dirname(dirname(__FILE__))).'/'.$sAddon;
+		$this->sFilePath = rtrim(str_replace('\\', '/', $this->sFilePath), '/').'/languages/';
 	}
 /**
  * Load languagefile
@@ -58,29 +55,18 @@
 	public function loadLanguage($sLangCode)
 	{
 		$aTranslations = array();
-		// sanitize the language code
-		$aLangCode = explode('_', preg_replace('/[^a-z0-9]/i', '_', strtolower($sLangCode)));
-		$sConcatedLang = '';
-		foreach($aLangCode as $sLang)
-		{ // iterate all segments of the language code
-			$sLangFile = '';
-			$sLang = strtolower($sLang);
-			// seek lowerchars file
-			if(is_readable($this->sFilePath.$sConcatedLang.$sLang.'.php')) {
-				$sLangFile = $this->sFilePath.$sConcatedLang.$sLang.'.php';
-			}else {
-				// seek upperchars file
-				$sLang = strtoupper($sLang);
-				if(is_readable($this->sFilePath.$sConcatedLang.$sLang.'.php')) {
-					$sLangFile = $this->sFilePath.$sConcatedLang.$sLang.'.php';
+		$sLangFile = strtolower($sLangCode.'.php');
+		if( ($aDirContent = scandir($this->sFilePath)) !== false) {
+			foreach($aDirContent as $sFile) {
+				if($sLangFile === strtolower($sFile)) {
+					$sLangFile = $this->sFilePath.$sFile;
+					if(is_readable($sLangFile)) {
+						$aTmp = $this->_importArrays($sLangFile);
+						$aTranslations = array_merge($aTranslations, $aTmp);
+						break;
+					}
 				}
 			}
-			if($sLangFile) {
-			// import the fond file
-				$sConcatedLang .= $sLangFile.'_';
-				$aTmp = $this->_importArrays($sLangFile);
-				$aTranslations = array_merge($aTranslations, $aTmp);
-			}
 		}
 		return (sizeof($aTranslations) > 0 ? $aTranslations : false);
 	}
@@ -128,7 +114,10 @@
 		// walk through all arrays
 			foreach(${$sSection} as $key => $value) {
 			// and import all found translations
-				$aLanguageTable[$sSection.'_'.$key] = $value;
+				if(!is_array($value)) {
+				// skip all multiarray definitions from compatibility mode
+					$aLanguageTable[$sSection.'_'.$key] = $value;
+				}
 			}
 		}
 		return $aLanguageTable;
Index: branches/2.8.x/wb/framework/WbAdaptor.php
===================================================================
--- branches/2.8.x/wb/framework/WbAdaptor.php	(revision 1863)
+++ branches/2.8.x/wb/framework/WbAdaptor.php	(revision 1864)
@@ -41,7 +41,7 @@
 /** constructor */
 	protected function __construct() 
 	{
-		$this->_aSys = array('Sys' => array(), 'Req' => array());
+		$this->_aSys = array('System' => array(), 'Request' => array());
 	}
 /**
  * Get active instance 
@@ -49,7 +49,7 @@
  */
 	public static function getInstance()
 	{
-		if(self::$_oInstance === null) {
+		if(self::$_oInstance == null) {
 			$c = __CLASS__;
 			self::$_oInstance = new $c();
 			
@@ -90,7 +90,7 @@
  */	
 	public function getWbConstants()
 	{
-		$this->_aSys = array('Sys' => array(), 'Req' => array());
+		$this->_aSys = array('System' => array(), 'Request' => array());
 		$aConsts = get_defined_constants(true);
 		foreach($aConsts['user'] as $sKey=>$sVal)
 		{
