Conditions | 12 |
Paths | 5 |
Total Lines | 43 |
Code Lines | 32 |
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 |
||
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 | $xlanguage_handler = xoops_getModuleHandler('language', 'xlanguage'); |
||
37 | $xlanguage_handler->loadConfig(); |
||
|
|||
38 | $lang_list =& $xlanguage_handler->getAllList(); |
||
39 | |||
40 | $content .= '<select name="mlanguages" id="mlanguages">'; |
||
41 | $content .= '<option value="">{#xoopsmlcontent_dlg.sellang}</option>'; |
||
42 | if (is_array($lang_list) && count($lang_list) > 0) { |
||
43 | foreach (array_keys($lang_list) as $lang_name) { |
||
44 | $lang =& $lang_list[$lang_name]; |
||
45 | $content .= '<option value="' . $lang['base']->getVar('lang_code') . '">' . $lang['base']->getVar('lang_name') . '</option>'; |
||
46 | } |
||
47 | } |
||
48 | $content .= '</select>'; |
||
49 | } elseif (defined('EASIESTML_LANGS') && defined('EASIESTML_LANGNAMES')) { |
||
50 | $easiestml_langs = explode(',', EASIESTML_LANGS); |
||
51 | $langnames = explode(',', EASIESTML_LANGNAMES); |
||
52 | $lang_options = ''; |
||
53 | |||
54 | $content .= '<select name="mlanguages" id="mlanguages">'; |
||
55 | $content .= '<option value="">{#xoopsmlcontent_dlg.sellang}</option>'; |
||
56 | foreach ($easiestml_langs as $l => $lang) { |
||
57 | $content .= '<option value="' . $lang . '">' . $langnames[$l] . '</option>'; |
||
58 | } |
||
59 | $content .= '</select>'; |
||
60 | } else { |
||
61 | $content .= '<input type="text" name="mlanguages" />'; |
||
62 | } |
||
63 | $_SESSION['XoopsMLcontent'] = $content; |
||
64 | $_SESSION['XoopsMLcontent_expire'] = $time + 300; |
||
65 | } |
||
66 | |||
67 | echo $_SESSION['XoopsMLcontent']; |
||
68 | } |
||
130 |