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