| Conditions | 3 |
| Paths | 4 |
| Total Lines | 51 |
| Code Lines | 28 |
| 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 |
||
| 31 | function SendFriend($lid) |
||
| 32 | { |
||
| 33 | global $xoopsDB, $xoopsTheme, $xoopsLogger; |
||
| 34 | $idd = $idde = $iddee = ''; |
||
|
|
|||
| 35 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
| 36 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
| 37 | $GLOBALS['xoTheme']->addMeta('meta', 'robots', 'noindex, nofollow'); |
||
| 38 | |||
| 39 | $result = $xoopsDB->query('SELECT lid, title, type FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE lid={$lid}"); |
||
| 40 | list($lid, $title, $type) = $xoopsDB->fetchRow($result); |
||
| 41 | |||
| 42 | echo "<table width='100%' border='0' cellspacing='1' cellpadding='8'><tr class='bg4'><td valign='top'> |
||
| 43 | <strong>" . _ADSLIGHT_SENDTO . " $lid \"<strong>$type : $title</strong>\" " . _ADSLIGHT_FRIEND . "<br><br> |
||
| 44 | <form action=\"sendfriend.php\" method=post> |
||
| 45 | <input type=\"hidden\" name=\"lid\" value=\"$lid\" >"; |
||
| 46 | |||
| 47 | if ($GLOBALS['xoopsUser'] instanceof \XoopsUser) { |
||
| 48 | $idd = $GLOBALS['xoopsUser']->getVar('uname', 'E'); |
||
| 49 | $idde = $GLOBALS['xoopsUser']->getVar('email', 'E'); |
||
| 50 | } |
||
| 51 | |||
| 52 | echo " |
||
| 53 | <table width='99%' class='outer' cellspacing='1'> |
||
| 54 | <tr> |
||
| 55 | <td class='head' width='30%'>" . _ADSLIGHT_NAME . " </td> |
||
| 56 | <td class='even'><input class='textbox' type='text' name='yname' value='$idd' ></td> |
||
| 57 | </tr> |
||
| 58 | <tr> |
||
| 59 | <td class='head'>" . _ADSLIGHT_MAIL . " </td> |
||
| 60 | <td class='even'><input class='textbox' type='text' name='ymail' value='$idde' ></td> |
||
| 61 | </tr> |
||
| 62 | <tr> |
||
| 63 | <td class='head'>" . _ADSLIGHT_NAMEFR . " </td> |
||
| 64 | <td class='even'><input class='textbox' type='text' name='fname' ></td> |
||
| 65 | </tr> |
||
| 66 | <tr> |
||
| 67 | <td class='head'>" . _ADSLIGHT_MAILFR . " </td> |
||
| 68 | <td class='even'><input class='textbox' type='text' name='fmail' ></td> |
||
| 69 | </tr>"; |
||
| 70 | |||
| 71 | if ('1' == $GLOBALS['xoopsModuleConfig']['adslight_use_captcha']) { |
||
| 72 | echo "<tr><td class='head'>" . _ADSLIGHT_CAPTCHA . " </td><td class='even'>"; |
||
| 73 | $jlm_captcha = ''; |
||
| 74 | $jlm_captcha = new \XoopsFormCaptcha(_ADSLIGHT_CAPTCHA, 'xoopscaptcha', false); |
||
| 75 | echo $jlm_captcha->render(); |
||
| 76 | echo '</td></tr>'; |
||
| 77 | } |
||
| 78 | |||
| 79 | echo '</table><br> |
||
| 80 | <input type=hidden name=op value=MailAd> |
||
| 81 | <input type=submit value=' . _ADSLIGHT_SENDFR . '> |
||
| 82 | </form></td></tr></table>'; |
||
| 180 |