1 | <?php |
||
2 | |||
3 | altsys_set_module_config(); |
||
4 | |||
5 | function altsys_set_module_config() |
||
6 | { |
||
7 | global $altsysModuleConfig, $altsysModuleId; |
||
8 | |||
9 | /** @var \XoopsModuleHandler $module_handler */ |
||
10 | $module_handler = xoops_getHandler('module'); |
||
11 | /** @var \XoopsModule $module */ |
||
12 | $module = $module_handler->getByDirname('altsys'); |
||
13 | if (is_object($module)) { |
||
14 | /** @var \XoopsConfigHandler $config_handler */ |
||
15 | $config_handler = xoops_getHandler('config'); |
||
16 | $altsysModuleConfig = $config_handler->getConfigList($module->getVar('mid')); |
||
17 | $altsysModuleId = $module->getVar('mid'); |
||
18 | } else { |
||
19 | $altsysModuleConfig = []; |
||
20 | $altsysModuleId = 0; |
||
21 | } |
||
22 | } |
||
23 | |||
24 | function altsys_include_mymenu() |
||
25 | { |
||
26 | global $xoopsModule, $xoopsConfig, $mydirname, $mydirpath, $mytrustdirname, $mytrustdirpath, $mymenu_fake_uri; |
||
27 | |||
28 | $mymenu_find_paths = [ |
||
29 | $mydirpath . '/admin/mymenu.php', |
||
30 | $mydirpath . '/mymenu.php', |
||
31 | $mytrustdirpath . '/admin/mymenu.php', |
||
32 | $mytrustdirpath . '/mymenu.php', |
||
33 | ]; |
||
34 | |||
35 | foreach ($mymenu_find_paths as $mymenu_find_path) { |
||
36 | if (file_exists($mymenu_find_path)) { |
||
37 | include $mymenu_find_path; |
||
38 | include_once __DIR__ . '/adminmenu_functions.php'; |
||
39 | altsys_adminmenu_insert_mymenu($xoopsModule); |
||
40 | altsys_adminmenu_hack_ft(); |
||
41 | break; |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @param $type |
||
48 | */ |
||
49 | function altsys_include_language_file($type) |
||
50 | { |
||
51 | $mylang = $GLOBALS['xoopsConfig']['language']; |
||
52 | |||
53 | if (file_exists(XOOPS_ROOT_PATH . '/modules/altsys/language/' . $mylang . '/' . $type . '.php')) { |
||
54 | include_once XOOPS_ROOT_PATH . '/modules/altsys/language/' . $mylang . '/' . $type . '.php'; |
||
55 | } elseif (file_exists(XOOPS_TRUST_PATH . '/libs/altsys/language/' . $mylang . '/' . $type . '.php')) { |
||
56 | include_once XOOPS_TRUST_PATH . '/libs/altsys/language/' . $mylang . '/' . $type . '.php'; |
||
57 | } elseif (file_exists(XOOPS_ROOT_PATH . '/modules/altsys/language/english/' . $type . '.php')) { |
||
58 | include_once XOOPS_ROOT_PATH . '/modules/altsys/language/english/' . $type . '.php'; |
||
59 | } elseif (file_exists(XOOPS_TRUST_PATH . '/libs/altsys/language/english/' . $type . '.php')) { |
||
60 | include_once XOOPS_TRUST_PATH . '/libs/altsys/language/english/' . $type . '.php'; |
||
61 | } |
||
62 | } |
||
63 | |||
64 | define('ALTSYS_CORE_TYPE_X20', 1); // 2.0.0-2.0.13 and 2.0.x-JP |
||
65 | define('ALTSYS_CORE_TYPE_X20S', 2); // 2.0.14- from xoops.org Skalpa's "S" |
||
66 | define('ALTSYS_CORE_TYPE_ORE', 4); // ORETEKI by marijuana |
||
67 | define('ALTSYS_CORE_TYPE_X22', 8); // 2.2 from xoops.org |
||
68 | define('ALTSYS_CORE_TYPE_XC21L', 16); // XOOPS Cube 2.1 Legacy |
||
69 | |||
70 | /** |
||
71 | * @return int |
||
72 | */ |
||
73 | function altsys_get_core_type() |
||
74 | { |
||
75 | if (defined('XOOPS_ORETEKI')) { |
||
76 | return ALTSYS_CORE_TYPE_ORE; |
||
77 | } elseif (defined('XOOPS_CUBE_LEGACY')) { |
||
78 | return ALTSYS_CORE_TYPE_XC21L; |
||
79 | } elseif (strstr(XOOPS_VERSION, 'JP')) { |
||
80 | return ALTSYS_CORE_TYPE_X20; |
||
81 | } else { |
||
82 | $versions = array_map('intval', explode('.', preg_replace('/[^0-9.]/', '', XOOPS_VERSION))); |
||
83 | if ($versions[0] == 2 && $versions[1] == 2) { |
||
84 | return ALTSYS_CORE_TYPE_X22; |
||
85 | } elseif ($versions[0] == 2 && ($versions[1] > 2 || $versions[2] > 13)) { |
||
86 | return ALTSYS_CORE_TYPE_X20S; |
||
87 | } else { |
||
88 | return ALTSYS_CORE_TYPE_X20; |
||
89 | } |
||
90 | } |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * @param $mid |
||
95 | * @param $coretype |
||
96 | * @return null|string |
||
97 | */ |
||
98 | function altsys_get_link2modpreferences($mid, $coretype) |
||
99 | { |
||
100 | switch ($coretype) { |
||
101 | case ALTSYS_CORE_TYPE_X20: |
||
102 | case ALTSYS_CORE_TYPE_X20S: |
||
103 | case ALTSYS_CORE_TYPE_ORE: |
||
104 | case ALTSYS_CORE_TYPE_X22: |
||
105 | return XOOPS_URL . '/modules/system/admin.php?fct=preferences&op=showmod&mod=' . $mid; |
||
106 | case ALTSYS_CORE_TYPE_XC21L: |
||
107 | return XOOPS_URL . '/modules/legacy/admin/index.php?action=PreferenceEdit&confmod_id=' . $mid; |
||
108 | } |
||
109 | |||
110 | return null; |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * @param $tpl_id |
||
115 | */ |
||
116 | function altsys_template_touch($tpl_id) |
||
117 | { |
||
118 | if (altsys_get_core_type() == ALTSYS_CORE_TYPE_X20S) { |
||
119 | // need to delete all files under templates_c/ |
||
120 | altsys_clear_templates_c(); |
||
121 | } else { |
||
122 | // just touch the template |
||
123 | xoops_template_touch($tpl_id); |
||
124 | } |
||
125 | } |
||
126 | |||
127 | function altsys_clear_templates_c() |
||
128 | { |
||
129 | $dh = opendir(XOOPS_COMPILE_PATH); |
||
130 | while ($file = readdir($dh)) { |
||
131 | if (substr($file, 0, 1) === '.') { |
||
132 | continue; |
||
133 | } |
||
134 | if (substr($file, -4) !== '.php') { |
||
135 | continue; |
||
136 | } |
||
137 | @unlink(XOOPS_COMPILE_PATH . '/' . $file); |
||
0 ignored issues
–
show
|
|||
138 | } |
||
139 | closedir($dh); |
||
140 | } |
||
141 |
If you suppress an error, we recommend checking for the error condition explicitly: