/**
  * Setup for the languageConf class.
  * tell Translation2 about our db-tables structure,
  * setup primary language
  * setup the group of module strings we want to fetch from
  * add a Lang decorator to provide a fallback language
  * add another Lang decorator to provide another fallback language,
  * in case some strings are not translated in all languages that exist in KINKY
  *
  * @param void
  * @return void
  * @access public
  */
 public function setup()
 {
     try {
         $otherLangs = $this->dblangAvail->getLanguageList();
         $entries = array();
         $entries['en'] = TABLE_PREFIX . 'en';
         foreach ($otherLangs as $lang) {
             $id = $lang['id'];
             $entries[$id] = TABLE_PREFIX . $id;
         }
         //Define table properties so that MDB2 knows about them
         $params = array('langs_avail_table' => TABLE_PREFIX . 'langs_avail', 'lang_id_col' => 'id', 'lang_name_col' => 'name', 'lang_meta_col' => 'meta', 'lang_errmsg_col' => 'error_text', 'strings_tables' => $entries, 'string_id_col' => 'id', 'string_page_id_col' => 'pageID', 'string_text_col' => '%s');
         $driver = 'MDB2';
         //instantiate class
         $this->_siteConf = $this->getObject('altconfig', 'config');
         $langcache = $this->_siteConf->getlangcache();
         if (strtolower($langcache) === 'true') {
             $langcache = true;
         } else {
             $langcache = false;
         }
         //$dsn = $this->_parseDSN(KEWL_DB_DSN);
         $dsn = engine::parseDSN_(KEWL_DB_DSN);
         $this->lang =& Translation2::factory($driver, $dsn, $params);
         if (PEAR::isError($this->lang)) {
             echo '!';
             throw new customException($this->lang->getMessage());
         }
         $this->langAdmin =& Translation2_Admin::factory($driver, $dsn, $params);
         // caching
         $this->lang =& $this->lang->getDecorator('CacheMemory');
         $this->lang->setOption('prefetch', true);
         //$this->lang =& $this->lang->getDecorator('CacheLiteFunction');
         // TODO: make the caching configuration options for language items configurable
         $cacheLiteOptions = array('memoryCaching' => false, 'cacheDir' => '/tmp/', 'caching' => $langcache, 'lifeTime' => 3600, 'cleaningFrequency' => 0);
         //$this->lang->setOptions($cacheLiteOptions);
         // charsets
         $this->lang =& $this->lang->getDecorator('SpecialChars');
         // control the charset to use
         $this->lang->setOption('charset', 'UTF-8');
         // add a UTF-8 decorator to automatically decode UTF-8 strings
         $this->lang =& $this->lang->getDecorator('UTF8');
         // add a default text decorator to deal with empty strings
         $this->lang =& $this->lang->getDecorator('DefaultText');
         //default value is true
         if (PEAR::isError($this->lang)) {
             throw new customException($this->lang->getMessage());
         }
         if (!is_object($this->lang)) {
             throw new customException('Translation class not loaded');
         }
         // set primary language
         $this->lang->setLang("en");
         // set the group of strings you want to fetch from
         $this->caller = $this->getParam('module');
         if ($this->caller == '') {
             $page = 'system';
         } else {
             $page = $this->caller;
         }
         // This needs to be dynamic, coming from the module that we are using currently
         $this->lang->setPageID($page);
         // add a Lang decorator to provide a fallback language
         $this->lang =& $this->lang->getDecorator('Lang');
         $this->lang->setOption('fallbackLang', 'en');
         /* $this->lang->setOption('cacheDir', '/var/www/cache/');
            $this->lang->setOption('lifeTime', 86400);
            $this->lang->setOption('cleaningFrequency', 0); */
         // replace the empty string with its stringID
         return $this->lang;
         //}
     } catch (Exception $e) {
         // Alterations by jsc on advice from paulscott
         //$this->errorCallback ('Caught exception: '.$e->getMessage());
         echo $e->getMessage();
         exit;
     }
 }