These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * xLanguage module (eXtensible Language Management For XOOPS) |
||
4 | * |
||
5 | * You may not change or alter any portion of this comment or credits |
||
6 | * of supporting developers from this source code or any supporting source code |
||
7 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
8 | * This program is distributed in the hope that it will be useful, |
||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
11 | * |
||
12 | * @copyright XOOPS Project (https://xoops.org) |
||
13 | * @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU Public License} |
||
14 | * @package xlanguage |
||
15 | * @since 2.0 |
||
16 | * @author D.J.(phppp) [email protected] |
||
17 | **/ |
||
18 | |||
19 | require_once __DIR__ . '/../../../include/cp_header.php'; |
||
20 | require_once __DIR__ . '/admin_header.php'; |
||
21 | |||
22 | require_once XOOPS_ROOT_PATH . '/modules/xlanguage/include/vars.php'; |
||
23 | require_once XOOPS_ROOT_PATH . '/modules/xlanguage/include/functions.php'; |
||
24 | |||
25 | $op = ''; |
||
26 | if (isset($_POST)) { |
||
27 | foreach ($_POST as $k => $v) { |
||
28 | ${$k} = $v; |
||
29 | } |
||
30 | } |
||
31 | if (isset($_GET)) { |
||
32 | foreach ($_GET as $k => $v) { |
||
33 | ${$k} = $v; |
||
34 | } |
||
35 | } |
||
36 | |||
37 | define('XLANG_CONFIG_LINK', "<a href='main.php' target='_self'>" . _AM_XLANG_CONFIG . '</a>'); |
||
38 | |||
39 | /** @var \XlanguageLanguageHandler $xlanguageHandler */ |
||
40 | $xlanguageHandler = xoops_getModuleHandler('language', 'xlanguage'); |
||
41 | $xlanguageHandler->loadConfig(); |
||
42 | |||
43 | switch ($op) { |
||
44 | case 'del': |
||
45 | if (!isset($_POST['ok']) || $_POST['ok'] != 1) { |
||
46 | xoops_cp_header(); |
||
47 | $aboutAdmin = \Xmf\Module\Admin::getInstance(); |
||
48 | $adminObject->displayNavigation(basename(__FILE__)); |
||
49 | // echo "<h4>" . XLANG_CONFIG_LINK . "</h4>"; |
||
50 | xoops_confirm(array('op' => 'del', 'type' => $_GET['type'], 'lang_id' => (int)$_GET['lang_id'], 'ok' => 1), 'main.php', _AM_XLANG_DELETE_CFM); |
||
51 | } else { |
||
52 | $isBase = true; |
||
53 | if (isset($type) && $type === 'ext') { |
||
54 | $isBase = false; |
||
55 | } |
||
56 | $lang = $xlanguageHandler->get($lang_id, $isBase); |
||
57 | $xlanguageHandler->delete($lang); |
||
58 | redirect_header('main.php', 2, _AM_XLANG_DELETED); |
||
59 | } |
||
60 | break; |
||
61 | |||
62 | case 'save': |
||
63 | $isBase = true; |
||
64 | if (isset($type) && $type === 'ext') { |
||
65 | $isBase = false; |
||
66 | } |
||
67 | if (isset($lang_id) && $lang_id > 0) { |
||
68 | $lang = $xlanguageHandler->get($lang_id, $isBase); |
||
69 | } else { |
||
70 | $lang = $xlanguageHandler->create(true, $isBase); |
||
71 | } |
||
72 | $lang_name = preg_replace("/[^a-zA-Z0-9\_\-]/", '', $lang_name); |
||
73 | |||
74 | $lang->setVar('lang_name', $lang_name); |
||
75 | $lang->setVar('lang_desc', $lang_desc); |
||
76 | $lang->setVar('lang_code', $lang_code); |
||
77 | $lang->setVar('lang_charset', $lang_charset); |
||
78 | $lang->setVar('lang_image', $lang_image); |
||
79 | if (!$isBase) { |
||
80 | $lang->setVar('lang_base', $lang_base); |
||
81 | } |
||
82 | $lang->setVar('weight', $weight); |
||
83 | $xlanguageHandler->insert($lang); |
||
84 | redirect_header('main.php', 2, _AM_XLANG_SAVED); |
||
85 | break; |
||
86 | |||
87 | case 'edit': |
||
88 | xoops_cp_header(); |
||
89 | $aboutAdmin = \Xmf\Module\Admin::getInstance(); |
||
90 | $adminObject->displayNavigation(basename(__FILE__)); |
||
91 | // echo "<h4>" . XLANG_CONFIG_LINK . "</h4>"; |
||
92 | // echo "<br>"; |
||
93 | echo '<h4>' . _AM_XLANG_EDITLANG . '</h4>'; |
||
94 | $isBase = true; |
||
95 | if (isset($type) && $type === 'ext') { |
||
96 | $isBase = false; |
||
97 | } |
||
98 | if (isset($lang_id) && $lang_id > 0) { |
||
99 | $lang = $xlanguageHandler->get($lang_id, $isBase); |
||
100 | } elseif (isset($lang_name)) { |
||
101 | $lang = $xlanguageHandler->getByName($lang_name, $isBase); |
||
102 | } else { |
||
103 | $lang = $xlanguageHandler->create(true, $isBase); |
||
104 | } |
||
105 | $lang_name = $lang->getVar('lang_name'); |
||
106 | $lang_desc = $lang->getVar('lang_desc'); |
||
107 | $lang_code = $lang->getVar('lang_code'); |
||
108 | $lang_charset = $lang->getVar('lang_charset'); |
||
109 | $lang_image = $lang->getVar('lang_image'); |
||
110 | $weight = $lang->getVar('weight'); |
||
111 | if (!$isBase) { |
||
112 | $lang_base = $lang->getVar('lang_base'); |
||
113 | } |
||
114 | include __DIR__ . '/langform.inc.php'; |
||
115 | break; |
||
116 | |||
117 | case 'add': |
||
118 | xoops_cp_header(); |
||
119 | $aboutAdmin = \Xmf\Module\Admin::getInstance(); |
||
120 | // echo "<h4>" . XLANG_CONFIG_LINK . "</h4>"; |
||
121 | // echo "<br>"; |
||
122 | // echo "<h4>" . _AM_XLANG_ADDLANG . "</h4>"; |
||
123 | if (isset($type) && $type === 'ext') { |
||
124 | $isBase = false; |
||
125 | $adminObject->displayNavigation('main.php?op=add&type=ext'); |
||
126 | } else { |
||
127 | $isBase = true; |
||
128 | $adminObject->displayNavigation('main.php?op=add&type=base'); |
||
129 | } |
||
130 | $lang_name = ''; |
||
131 | $lang_desc = ''; |
||
132 | $lang_code = ''; |
||
133 | $lang_charset = ''; |
||
134 | $lang_image = ''; |
||
135 | $weight = 1; |
||
136 | $lang_base = ''; |
||
137 | include __DIR__ . '/langform.inc.php'; |
||
138 | break; |
||
139 | |||
140 | case 'createconfig': |
||
141 | xlanguage_createConfig(); |
||
142 | redirect_header('main.php', 1, _AM_XLANG_CREATED); |
||
143 | |||
144 | break; |
||
145 | |||
146 | case 'default': |
||
147 | default: |
||
148 | xoops_cp_header(); |
||
149 | $adminObject = \Xmf\Module\Admin::getInstance(); |
||
150 | $adminObject->displayNavigation(basename(__FILE__)); |
||
151 | |||
152 | // if (TDMDownloads_checkModuleAdmin()) { |
||
153 | // $adminObject = \Xmf\Module\Admin::getInstance(); |
||
0 ignored issues
–
show
|
|||
154 | // $adminObject->displayNavigation('downloads.php'); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
75% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them.
Loading history...
|
|||
155 | $adminObject->addItemButton(_MI_XLANGUAGE_ADMENU1, 'main.php?op=add&type=base', 'add'); |
||
156 | $adminObject->addItemButton(_MI_XLANGUAGE_ADMENU2, 'main.php?op=add&type=ext', 'insert_table_row'); |
||
157 | |||
158 | $adminObject->displayButton('left'); |
||
159 | // } |
||
160 | |||
161 | // echo "<h4>" . XLANG_CONFIG_LINK . "</h4>"; |
||
162 | languageList(); |
||
163 | $configfile_status = (@is_readable(XLANGUAGE_CONFIG_FILE)) ? _AM_XLANG_CONFIGOK : _AM_XLANG_CONFIGNOTOK; |
||
164 | echo "<table width='100%' border='0' cellspacing='1' class='outer'><tr><td class=\"odd\"><br>"; |
||
165 | // echo " - <b><a href='index.php?op=add&type=base'>" . _AM_XLANG_ADDBASE . "</a></b><br><br>\n"; |
||
166 | // echo " - <b><a href='index.php?op=add&type=ext'>" . _AM_XLANG_ADDEXT . "</a></b><br><br>\n"; |
||
167 | echo '<b>' . $configfile_status . '</b>: ' . XLANGUAGE_CONFIG_FILE . " (<a href='main.php?op=createconfig' title='" . _AM_XLANG_CREATECONFIG . "'>" . _AM_XLANG_CREATECONFIG . "</a>)<br><br>\n"; |
||
168 | // echo " - <b><a href='about.php'>" . _AM_XLANG_ABOUT . "</a></b>"; |
||
169 | echo '</td></tr></table>'; |
||
170 | break; |
||
171 | } |
||
172 | xoops_cp_footer(); |
||
173 | |||
174 | function languageList() |
||
175 | { |
||
176 | global $xlanguageHandler, $xoopsModule; |
||
177 | |||
178 | global $pathIcon16; |
||
179 | |||
180 | $lang_list = $xlanguageHandler->getAllList(); |
||
181 | if (is_array($lang_list) && count($lang_list) > 0) { |
||
182 | echo "<table width='100%' border='0' cellspacing='1' class='outer'><tr><td class=\"odd\">"; |
||
183 | echo "<div style='text-align: center;'><b><h4>" . _AM_XLANG_LANGLIST . '</h4></b><br>'; |
||
184 | echo "<table class='outer' width='100%' border='0' cellpadding='0' cellspacing='0' ><tr class='bg2'><th align='center'>" |
||
185 | . _AM_XLANG_DESC |
||
186 | . "</th><th align='center'>" |
||
187 | . _AM_XLANG_NAME |
||
188 | . "</th><th align='center'>" |
||
189 | . _AM_XLANG_CHARSET |
||
190 | . "</th><th align='center'>" |
||
191 | . _AM_XLANG_CODE |
||
192 | . "</th><th align='center'>" |
||
193 | . _AM_XLANG_IMAGE |
||
194 | . "</th><th align='center'>" |
||
195 | . _AM_XLANG_WEIGHT |
||
196 | . "</th><th align='center'>" |
||
197 | . _AM_XLANG_BASE |
||
198 | . "</th><th align='center'>" |
||
199 | . _AM_XLANG_ACTION |
||
200 | . "</th></tr>\n"; |
||
201 | $class = 'even'; |
||
202 | foreach (array_keys($lang_list) as $lang_name) { |
||
203 | $lang =& $lang_list[$lang_name]; |
||
204 | $isOrphan = true; |
||
205 | if (isset($lang['base'])) { |
||
206 | echo "<tr>\n"; |
||
207 | echo "<td class='$class' >" . $lang['base']->getVar('lang_desc') . "</td>\n"; |
||
208 | echo "<td class='$class' ><b>" . $lang['base']->getVar('lang_name') . "</b></td>\n"; |
||
209 | echo "<td class='$class' ><b>" . $lang['base']->getVar('lang_charset') . "</b></td>\n"; |
||
210 | echo "<td class='$class' >" . $lang['base']->getVar('lang_code') . "</td>\n"; |
||
211 | $lang_image = 'noflag.gif'; |
||
212 | View Code Duplication | if (is_readable(XOOPS_ROOT_PATH . '/modules/xlanguage/assets/images/' . $lang['base']->getVar('lang_image'))) { |
|
213 | $lang_image = $lang['base']->getVar('lang_image'); |
||
214 | } |
||
215 | echo "<td class='$class' ><img src='" . XOOPS_URL . '/modules/xlanguage/assets/images/' . $lang_image . "' alt='" . $lang['base']->getVar('lang_desc') . "'></td>\n"; |
||
216 | echo "<td class='$class' >" . $lang['base']->getVar('weight') . "</td>\n"; |
||
217 | echo "<td class='$class' >Ø</td>\n"; |
||
218 | echo "<td class='$class' ><a href='main.php?op=edit&type=base&lang_id=" |
||
219 | . $lang['base']->getVar('lang_id') |
||
220 | . "'><img src=" |
||
221 | . $pathIcon16 |
||
222 | . '/edit.png title=' |
||
223 | . _EDIT |
||
224 | . "></a>\n" |
||
225 | . "<a href='main.php?op=del&type=base&lang_id=" |
||
226 | . $lang['base']->getVar('lang_id') |
||
227 | . "'><img src=" |
||
228 | . $pathIcon16 |
||
229 | . '/delete.png title=' |
||
230 | . _DELETE |
||
231 | . "></td>\n"; |
||
232 | echo "</tr>\n"; |
||
233 | $isOrphan = false; |
||
234 | $class = ($class === 'odd') ? 'even' : 'odd'; |
||
235 | } |
||
236 | if (!isset($lang['ext']) || count($lang['ext']) < 1) { |
||
237 | continue; |
||
238 | } |
||
239 | foreach ($lang['ext'] as $ext) { |
||
240 | echo "<tr>\n"; |
||
241 | echo "<td class='$class' >" . $ext->getVar('lang_desc') . "</td>\n"; |
||
242 | echo "<td class='$class' >" . $ext->getVar('lang_name') . "</td>\n"; |
||
243 | echo "<td class='$class' ><b>" . $ext->getVar('lang_charset') . "</b></td>\n"; |
||
244 | echo "<td class='$class' >" . $ext->getVar('lang_code') . "</td>\n"; |
||
245 | $lang_image = 'noflag.gif'; |
||
246 | View Code Duplication | if (is_readable(XOOPS_ROOT_PATH . '/modules/xlanguage/assets/images/' . $ext->getVar('lang_image'))) { |
|
247 | $lang_image = $ext->getVar('lang_image'); |
||
248 | } |
||
249 | echo "<td class='$class' ><img src='" . XOOPS_URL . '/modules/xlanguage/assets/images/' . $lang_image . "' alt='" . $ext->getVar('lang_desc') . "'></td>\n"; |
||
250 | echo "<td class='$class' >" . $ext->getVar('weight') . "</td>\n"; |
||
251 | $lang_base = $isOrphan ? "<font color='red'>" . $ext->getVar('lang_base') . '</font>' : $ext->getVar('lang_base'); |
||
252 | echo "<td class='$class' ><b>" . $lang_base . "</b></td>\n"; |
||
253 | echo "<td class='$class' ><a href='main.php?op=edit&type=ext&lang_id=" |
||
254 | . $ext->getVar('lang_id') |
||
255 | . "'><img src=" |
||
256 | . $pathIcon16 |
||
257 | . '/edit.png title=' |
||
258 | . _EDIT |
||
259 | . "></a>\n" |
||
260 | . "<a href='main.php?op=del&type=ext&lang_id=" |
||
261 | . $ext->getVar('lang_id') |
||
262 | . "'><img src=" |
||
263 | . $pathIcon16 |
||
264 | . '/delete.png title=' |
||
265 | . _DELETE |
||
266 | . "></td>\n"; |
||
267 | echo "</tr>\n"; |
||
268 | } |
||
269 | echo "<tr><td colspan='9' ></td></tr>\n"; |
||
270 | $class = ($class === 'odd') ? 'even' : 'odd'; |
||
271 | } |
||
272 | |||
273 | echo "</table></div>\n"; |
||
274 | echo '</td></tr></table>'; |
||
275 | echo '<br>'; |
||
276 | } |
||
277 | } |
||
278 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.