Conditions | 13 |
Paths | 57 |
Total Lines | 103 |
Code Lines | 90 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
182 | function languageList(LanguageHandler $languageHandler) |
||
183 | { |
||
184 | // global $languageHandler, $xoopsModule; |
||
185 | |||
186 | global $pathIcon16; |
||
187 | |||
188 | $lang_list = $languageHandler->getAllList(); |
||
189 | |||
190 | if ($lang_list && is_array($lang_list)) { |
||
191 | echo "<table width='100%' border='0' cellspacing='1' class='outer'><tr><td class=\"odd\">"; |
||
192 | echo "<div style='text-align: center;'><b><h4>" . _AM_XLANGUAGE_LANGLIST . '</h4></b><br>'; |
||
193 | echo "<table class='outer' width='100%' border='0' cellpadding='0' cellspacing='0' ><tr class='bg2'><th align='center'>" |
||
194 | . _AM_XLANGUAGE_DESC |
||
195 | . "</th><th align='center'>" |
||
196 | . _AM_XLANGUAGE_NAME |
||
197 | . "</th><th align='center'>" |
||
198 | . _AM_XLANGUAGE_CHARSET |
||
199 | . "</th><th align='center'>" |
||
200 | . _AM_XLANGUAGE_CODE |
||
201 | . "</th><th align='center'>" |
||
202 | . _AM_XLANGUAGE_IMAGE |
||
203 | . "</th><th align='center'>" |
||
204 | . _AM_XLANGUAGE_WEIGHT |
||
205 | . "</th><th align='center'>" |
||
206 | . _AM_XLANGUAGE_BASE |
||
207 | . "</th><th align='center'>" |
||
208 | . _AM_XLANGUAGE_ACTION |
||
209 | . "</th></tr>\n"; |
||
210 | $class = 'even'; |
||
211 | foreach (array_keys($lang_list) as $lang_name) { |
||
212 | $lang = &$lang_list[$lang_name]; |
||
213 | $isOrphan = true; |
||
214 | if (isset($lang['base'])) { |
||
215 | echo "<tr>\n"; |
||
216 | echo "<td class='$class' >" . $lang['base']->getVar('lang_desc') . "</td>\n"; |
||
217 | echo "<td class='$class' ><b>" . $lang['base']->getVar('lang_name') . "</b></td>\n"; |
||
218 | echo "<td class='$class' ><b>" . $lang['base']->getVar('lang_charset') . "</b></td>\n"; |
||
219 | echo "<td class='$class' >" . $lang['base']->getVar('lang_code') . "</td>\n"; |
||
220 | $lang_image = 'noflag.gif'; |
||
221 | if (is_readable(XOOPS_ROOT_PATH . '/modules/xlanguage/assets/images/' . $lang['base']->getVar('lang_image'))) { |
||
222 | $lang_image = $lang['base']->getVar('lang_image'); |
||
223 | } |
||
224 | echo "<td class='$class' ><img src='" . XOOPS_URL . '/modules/xlanguage/assets/images/' . $lang_image . "' alt='" . $lang['base']->getVar('lang_desc') . "'></td>\n"; |
||
225 | echo "<td class='$class' >" . $lang['base']->getVar('weight') . "</td>\n"; |
||
226 | echo "<td class='$class' >Ø</td>\n"; |
||
227 | echo "<td class='$class' ><a href='main.php?op=edit&type=base&lang_id=" |
||
228 | . $lang['base']->getVar('lang_id') |
||
229 | . "'><img src=" |
||
230 | . $pathIcon16 |
||
231 | . '/edit.png title=' |
||
232 | . _EDIT |
||
233 | . "></a>\n" |
||
234 | . "<a href='main.php?op=del&type=base&lang_id=" |
||
235 | . $lang['base']->getVar('lang_id') |
||
236 | . "'><img src=" |
||
237 | . $pathIcon16 |
||
238 | . '/delete.png title=' |
||
239 | . _DELETE |
||
240 | . "></td>\n"; |
||
241 | echo "</tr>\n"; |
||
242 | $isOrphan = false; |
||
243 | $class = ('odd' === $class) ? 'even' : 'odd'; |
||
244 | } |
||
245 | if (!isset($lang['ext']) || count($lang['ext']) < 1) { |
||
246 | continue; |
||
247 | } |
||
248 | foreach ($lang['ext'] as $ext) { |
||
249 | echo "<tr>\n"; |
||
250 | echo "<td class='$class' >" . $ext->getVar('lang_desc') . "</td>\n"; |
||
251 | echo "<td class='$class' >" . $ext->getVar('lang_name') . "</td>\n"; |
||
252 | echo "<td class='$class' ><b>" . $ext->getVar('lang_charset') . "</b></td>\n"; |
||
253 | echo "<td class='$class' >" . $ext->getVar('lang_code') . "</td>\n"; |
||
254 | $lang_image = 'noflag.gif'; |
||
255 | if (is_readable(XOOPS_ROOT_PATH . '/modules/xlanguage/assets/images/' . $ext->getVar('lang_image'))) { |
||
256 | $lang_image = $ext->getVar('lang_image'); |
||
257 | } |
||
258 | echo "<td class='$class' ><img src='" . XOOPS_URL . '/modules/xlanguage/assets/images/' . $lang_image . "' alt='" . $ext->getVar('lang_desc') . "'></td>\n"; |
||
259 | echo "<td class='$class' >" . $ext->getVar('weight') . "</td>\n"; |
||
260 | $lang_base = $isOrphan ? "<span style='color:#ff0000'>" . $ext->getVar('lang_base') . '</span>' : $ext->getVar('lang_base'); |
||
261 | echo "<td class='$class' ><b>" . $lang_base . "</b></td>\n"; |
||
262 | echo "<td class='$class' ><a href='main.php?op=edit&type=ext&lang_id=" |
||
263 | . $ext->getVar('lang_id') |
||
264 | . "'><img src=" |
||
265 | . $pathIcon16 |
||
266 | . '/edit.png title=' |
||
267 | . _EDIT |
||
268 | . "></a>\n" |
||
269 | . "<a href='main.php?op=del&type=ext&lang_id=" |
||
270 | . $ext->getVar('lang_id') |
||
271 | . "'><img src=" |
||
272 | . $pathIcon16 |
||
273 | . '/delete.png title=' |
||
274 | . _DELETE |
||
275 | . "></td>\n"; |
||
276 | echo "</tr>\n"; |
||
277 | } |
||
278 | echo "<tr><td colspan='9' ></td></tr>\n"; |
||
279 | $class = ('odd' === $class) ? 'even' : 'odd'; |
||
280 | } |
||
281 | |||
282 | echo "</table></div>\n"; |
||
283 | echo '</td></tr></table>'; |
||
284 | echo '<br>'; |
||
285 | } |
||
287 |