| Conditions | 12 |
| Paths | 5 |
| Total Lines | 44 |
| Code Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 25 | function langDropdown() |
||
| 26 | { |
||
| 27 | $content = ''; |
||
| 28 | |||
| 29 | $time = time(); |
||
| 30 | if (!isset($_SESSION['XoopsMLcontent']) && (isset($_SESSION['XoopsMLcontent_expire']) && $_SESSION['XoopsMLcontent_expire'] < $time)) { |
||
| 31 | include_once XOOPS_ROOT_PATH . '/kernel/module.php'; |
||
| 32 | $xlanguage = XoopsModule::getByDirname('xlanguage'); |
||
| 33 | if (is_object($xlanguage) && $xlanguage->getVar('isactive')) { |
||
| 34 | include_once(XOOPS_ROOT_PATH . '/modules/xlanguage/include/vars.php'); |
||
| 35 | include_once(XOOPS_ROOT_PATH . '/modules/xlanguage/include/functions.php'); |
||
| 36 | /** @var LanguageHandler $xlanguage_handler */ |
||
| 37 | $xlanguage_handler = xoops_getModuleHandler('language', 'xlanguage'); |
||
| 38 | $xlanguage_handler->loadConfig(); |
||
| 39 | $lang_list =& $xlanguage_handler->getAllList(); |
||
| 40 | |||
| 41 | $content .= '<select name="mlanguages" id="mlanguages">'; |
||
| 42 | $content .= '<option value="">{#xoopsmlcontent_dlg.sellang}</option>'; |
||
| 43 | if (!empty($lang_list) && \is_array($lang_list)) { |
||
| 44 | foreach (array_keys($lang_list) as $lang_name) { |
||
| 45 | $lang =& $lang_list[$lang_name]; |
||
| 46 | $content .= '<option value="' . $lang['base']->getVar('lang_code') . '">' . $lang['base']->getVar('lang_name') . '</option>'; |
||
| 47 | } |
||
| 48 | } |
||
| 49 | $content .= '</select>'; |
||
| 50 | } elseif (defined('EASIESTML_LANGS') && defined('EASIESTML_LANGNAMES')) { |
||
| 51 | $easiestml_langs = explode(',', EASIESTML_LANGS); |
||
|
|
|||
| 52 | $langnames = explode(',', EASIESTML_LANGNAMES); |
||
| 53 | $lang_options = ''; |
||
| 54 | |||
| 55 | $content .= '<select name="mlanguages" id="mlanguages">'; |
||
| 56 | $content .= '<option value="">{#xoopsmlcontent_dlg.sellang}</option>'; |
||
| 57 | foreach ($easiestml_langs as $l => $lang) { |
||
| 58 | $content .= '<option value="' . $lang . '">' . $langnames[$l] . '</option>'; |
||
| 59 | } |
||
| 60 | $content .= '</select>'; |
||
| 61 | } else { |
||
| 62 | $content .= '<input type="text" name="mlanguages" />'; |
||
| 63 | } |
||
| 64 | $_SESSION['XoopsMLcontent'] = $content; |
||
| 65 | $_SESSION['XoopsMLcontent_expire'] = $time + 300; |
||
| 66 | } |
||
| 67 | |||
| 68 | echo $_SESSION['XoopsMLcontent']; |
||
| 69 | } |
||
| 131 |