| 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 |
||
| 174 | function languageList(Xlanguage\LanguageHandler $xlanguageHandler) |
||
| 175 | { |
||
| 176 | // global $xlanguageHandler, $xoopsModule; |
||
| 177 | |||
| 178 | global $pathIcon16; |
||
| 179 | |||
| 180 | $lang_list = $xlanguageHandler->getAllList(); |
||
| 181 | |||
| 182 | if ($lang_list && is_array($lang_list)) { |
||
| 183 | echo "<table width='100%' border='0' cellspacing='1' class='outer'><tr><td class=\"odd\">"; |
||
| 184 | echo "<div style='text-align: center;'><b><h4>" . _AM_XLANGUAGE_LANGLIST . '</h4></b><br>'; |
||
| 185 | echo "<table class='outer' width='100%' border='0' cellpadding='0' cellspacing='0' ><tr class='bg2'><th align='center'>" |
||
| 186 | . _AM_XLANGUAGE_DESC |
||
| 187 | . "</th><th align='center'>" |
||
| 188 | . _AM_XLANGUAGE_NAME |
||
| 189 | . "</th><th align='center'>" |
||
| 190 | . _AM_XLANGUAGE_CHARSET |
||
| 191 | . "</th><th align='center'>" |
||
| 192 | . _AM_XLANGUAGE_CODE |
||
| 193 | . "</th><th align='center'>" |
||
| 194 | . _AM_XLANGUAGE_IMAGE |
||
| 195 | . "</th><th align='center'>" |
||
| 196 | . _AM_XLANGUAGE_WEIGHT |
||
| 197 | . "</th><th align='center'>" |
||
| 198 | . _AM_XLANGUAGE_BASE |
||
| 199 | . "</th><th align='center'>" |
||
| 200 | . _AM_XLANGUAGE_ACTION |
||
| 201 | . "</th></tr>\n"; |
||
| 202 | $class = 'even'; |
||
| 203 | foreach (array_keys($lang_list) as $lang_name) { |
||
| 204 | $lang = &$lang_list[$lang_name]; |
||
| 205 | $isOrphan = true; |
||
| 206 | if (isset($lang['base'])) { |
||
| 207 | echo "<tr>\n"; |
||
| 208 | echo "<td class='$class' >" . $lang['base']->getVar('lang_desc') . "</td>\n"; |
||
| 209 | echo "<td class='$class' ><b>" . $lang['base']->getVar('lang_name') . "</b></td>\n"; |
||
| 210 | echo "<td class='$class' ><b>" . $lang['base']->getVar('lang_charset') . "</b></td>\n"; |
||
| 211 | echo "<td class='$class' >" . $lang['base']->getVar('lang_code') . "</td>\n"; |
||
| 212 | $lang_image = 'noflag.gif'; |
||
| 213 | if (is_readable(XOOPS_ROOT_PATH . '/modules/xlanguage/assets/images/' . $lang['base']->getVar('lang_image'))) { |
||
| 214 | $lang_image = $lang['base']->getVar('lang_image'); |
||
| 215 | } |
||
| 216 | echo "<td class='$class' ><img src='" . XOOPS_URL . '/modules/xlanguage/assets/images/' . $lang_image . "' alt='" . $lang['base']->getVar('lang_desc') . "'></td>\n"; |
||
| 217 | echo "<td class='$class' >" . $lang['base']->getVar('weight') . "</td>\n"; |
||
| 218 | echo "<td class='$class' >Ø</td>\n"; |
||
| 219 | echo "<td class='$class' ><a href='main.php?op=edit&type=base&lang_id=" |
||
| 220 | . $lang['base']->getVar('lang_id') |
||
| 221 | . "'><img src=" |
||
| 222 | . $pathIcon16 |
||
| 223 | . '/edit.png title=' |
||
| 224 | . _EDIT |
||
| 225 | . "></a>\n" |
||
| 226 | . "<a href='main.php?op=del&type=base&lang_id=" |
||
| 227 | . $lang['base']->getVar('lang_id') |
||
| 228 | . "'><img src=" |
||
| 229 | . $pathIcon16 |
||
| 230 | . '/delete.png title=' |
||
| 231 | . _DELETE |
||
| 232 | . "></td>\n"; |
||
| 233 | echo "</tr>\n"; |
||
| 234 | $isOrphan = false; |
||
| 235 | $class = ('odd' === $class) ? 'even' : 'odd'; |
||
| 236 | } |
||
| 237 | if (!isset($lang['ext']) || count($lang['ext']) < 1) { |
||
| 238 | continue; |
||
| 239 | } |
||
| 240 | foreach ($lang['ext'] as $ext) { |
||
| 241 | echo "<tr>\n"; |
||
| 242 | echo "<td class='$class' >" . $ext->getVar('lang_desc') . "</td>\n"; |
||
| 243 | echo "<td class='$class' >" . $ext->getVar('lang_name') . "</td>\n"; |
||
| 244 | echo "<td class='$class' ><b>" . $ext->getVar('lang_charset') . "</b></td>\n"; |
||
| 245 | echo "<td class='$class' >" . $ext->getVar('lang_code') . "</td>\n"; |
||
| 246 | $lang_image = 'noflag.gif'; |
||
| 247 | if (is_readable(XOOPS_ROOT_PATH . '/modules/xlanguage/assets/images/' . $ext->getVar('lang_image'))) { |
||
| 248 | $lang_image = $ext->getVar('lang_image'); |
||
| 249 | } |
||
| 250 | echo "<td class='$class' ><img src='" . XOOPS_URL . '/modules/xlanguage/assets/images/' . $lang_image . "' alt='" . $ext->getVar('lang_desc') . "'></td>\n"; |
||
| 251 | echo "<td class='$class' >" . $ext->getVar('weight') . "</td>\n"; |
||
| 252 | $lang_base = $isOrphan ? "<span style='color:#ff0000'>" . $ext->getVar('lang_base') . '</span>' : $ext->getVar('lang_base'); |
||
| 253 | echo "<td class='$class' ><b>" . $lang_base . "</b></td>\n"; |
||
| 254 | echo "<td class='$class' ><a href='main.php?op=edit&type=ext&lang_id=" |
||
| 255 | . $ext->getVar('lang_id') |
||
| 256 | . "'><img src=" |
||
| 257 | . $pathIcon16 |
||
| 258 | . '/edit.png title=' |
||
| 259 | . _EDIT |
||
| 260 | . "></a>\n" |
||
| 261 | . "<a href='main.php?op=del&type=ext&lang_id=" |
||
| 262 | . $ext->getVar('lang_id') |
||
| 263 | . "'><img src=" |
||
| 264 | . $pathIcon16 |
||
| 265 | . '/delete.png title=' |
||
| 266 | . _DELETE |
||
| 267 | . "></td>\n"; |
||
| 268 | echo "</tr>\n"; |
||
| 269 | } |
||
| 270 | echo "<tr><td colspan='9' ></td></tr>\n"; |
||
| 271 | $class = ('odd' === $class) ? 'even' : 'odd'; |
||
| 272 | } |
||
| 273 | |||
| 274 | echo "</table></div>\n"; |
||
| 275 | echo '</td></tr></table>'; |
||
| 276 | echo '<br>'; |
||
| 277 | } |
||
| 279 |