XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
SetupAltsysLangMgr.class.php
1<?php
2
3if (! defined('XOOPS_ROOT_PATH')) {
4 exit ;
5}
6
7if (! defined('XOOPS_TRUST_PATH') || XOOPS_TRUST_PATH == '') {
8 header('Location: '.XOOPS_URL.'/modules/altsys/setup_xoops_trust_path.php') ;
9 exit ;
10}
11
12const ALTSYS_MYLANGUAGE_ROOT_PATH = XOOPS_ROOT_PATH . '/my_language';
13
14
16{
17 public function preFilter()
18 {
19 $this->mController->mCreateLanguageManager->add('SetupAltsysLangMgr::createLanguageManager');
20 }
21
22
23 public static function createLanguageManager(&$langManager, $languageName)
24
25 {
26 $langManager = new AltsysLangMgr_LanguageManager();
27 }
28}
29
30
31require_once XOOPS_ROOT_PATH . '/core/XCube_LanguageManager.class.php';
32require_once XOOPS_ROOT_PATH . '/modules/legacy/kernel/Legacy_LanguageManager.class.php';
33
35{
36 public $langman = null ;
37 public $theme_lang_checked = false ;
38
39 public function prepare()
40 {
41 $langmanpath = XOOPS_TRUST_PATH.'/libs/altsys/class/D3LanguageManager.class.php' ;
42 if (! file_exists($langmanpath)) {
43 die('install the latest altsys') ;
44 }
45 require_once($langmanpath) ;
46 $this->langman = D3LanguageManager::getInstance() ;
47 $this->langman->language = $this->mLanguageName ;
48
49 parent::prepare();
50 }
51
52 public function _loadLanguage($dirname, $fileBodyName)
53 {
54 // read/check once (selected_theme)/language/(lang).php
55 if (! $this->theme_lang_checked) {
56 $root =& XCube_Root::getSingleton() ;
57 if (! empty($root->mContext->mXoopsConfig['theme_set'])) {
58 $langdir = XOOPS_THEME_PATH.'/'.$root->mContext->mXoopsConfig['theme_set'].'/language' ;
59 if (file_exists($langdir)) {
60 $langfile = $langdir.'/'.$this->mLanguageName.'.php' ;
61 $engfile = $langdir.'/english.php' ;
62 if (file_exists($langfile)) {
63 require_once $langfile ;
64 } elseif (file_exists($engfile)) {
65 require_once $engfile ;
66 }
67 }
68 $this->theme_lang_checked = true ;
69 }
70 }
71
72 // read normal
73 $this->langman->read($fileBodyName.'.php', $dirname) ;
74 }
75
76 public function loadPageTypeMessageCatalog( $type)
77 {
78 // I dare not to use langman...
79 if (strpos($type, '.') === false && $this->langman->my_language) {
80 $mylang_file = $this->langman->my_language.'/'.$this->mLanguageName.'/'.$type.'.php' ;
81 if (file_exists($mylang_file)) {
82 require_once $mylang_file ;
83 }
84 }
85 $original_error_level = error_reporting() ;
86 error_reporting($original_error_level & ~ E_NOTICE) ;
87 parent::loadPageTypeMessageCatalog($type);
88 error_reporting($original_error_level) ;
89 }
90
91 public function loadGlobalMessageCatalog()
92 {
93 /* if (!$this->_loadFile(XOOPS_ROOT_PATH . "/modules/legacy/language/" . $this->mLanguageName . "/global.php")) {
94 $this->_loadFile(XOOPS_ROOT_PATH . "/modules/legacy/language/english/global.php");
95 } */
96 $this->_loadLanguage('legacy', 'global') ;
97 $this->_loadLanguage('legacy', 'setting') ;
98
99 //
100 // Now, if XOOPS_USE_MULTIBYTES isn't defined, set zero to it.
101 //
102 if (!defined('XOOPS_USE_MULTIBYTES')) {
103 define('XOOPS_USE_MULTIBYTES', 0);
104 }
105 }
106}
preFilter()
[Abstract] Executes the logic, when the controller executes preFilter().