| Conditions | 3 |
| Paths | 3 |
| Total Lines | 64 |
| Code Lines | 55 |
| 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 |
||
| 92 | function MailAd($lid, $yname, $ymail, $fname, $fmail) |
||
| 93 | { |
||
| 94 | global $xoopsConfig, $xoopsTpl, $xoopsDB, $xoopsModule, $myts; |
||
| 95 | |||
| 96 | if ('1' == $GLOBALS['xoopsModuleConfig']['adslight_use_captcha']) { |
||
| 97 | xoops_load('xoopscaptcha'); |
||
| 98 | $xoopsCaptcha = XoopsCaptcha::getInstance(); |
||
| 99 | if (!$xoopsCaptcha->verify()) { |
||
| 100 | redirect_header(XOOPS_URL . '/modules/adslight/index.php', 2, $xoopsCaptcha->getMessage()); |
||
| 101 | } |
||
| 102 | } |
||
| 103 | |||
| 104 | $result = $xoopsDB->query('SELECT lid, title, expire, type, desctext, tel, price, typeprice, date, email, submitter, town, country, photo FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE lid=' . $xoopsDB->escape($lid)); |
||
| 105 | list($lid, $title, $expire, $type, $desctext, $tel, $price, $typeprice, $date, $email, $submitter, $town, $country, $photo) = $xoopsDB->fetchRow($result); |
||
| 106 | |||
| 107 | $title = $myts->addSlashes($title); |
||
| 108 | $expire = $myts->addSlashes($expire); |
||
| 109 | $type = $myts->addSlashes($type); |
||
| 110 | $desctext = $myts->displayTarea($desctext, 1, 1, 1, 1, 1); |
||
| 111 | $tel = $myts->addSlashes($tel); |
||
| 112 | $price = $myts->addSlashes($price); |
||
| 113 | $typeprice = $myts->addSlashes($typeprice); |
||
| 114 | $submitter = $myts->addSlashes($submitter); |
||
| 115 | $town = $myts->addSlashes($town); |
||
| 116 | $country = $myts->addSlashes($country); |
||
| 117 | |||
| 118 | $tags = []; |
||
| 119 | $tags['YNAME'] = stripslashes($yname); |
||
| 120 | $tags['YMAIL'] = $ymail; |
||
| 121 | $tags['FNAME'] = stripslashes($fname); |
||
| 122 | $tags['FMAIL'] = $fmail; |
||
| 123 | $tags['HELLO'] = _ADSLIGHT_HELLO; |
||
| 124 | $tags['LID'] = $lid; |
||
| 125 | $tags['LISTING_NUMBER'] = _ADSLIGHT_LISTING_NUMBER; |
||
| 126 | $tags['TITLE'] = $title; |
||
| 127 | $tags['TYPE'] = Adslight\Utility::getNameType($type); |
||
| 128 | $tags['DESCTEXT'] = $desctext; |
||
| 129 | $tags['PRICE'] = $price; |
||
| 130 | $tags['TYPEPRICE'] = $typeprice; |
||
| 131 | $tags['TEL'] = $tel; |
||
| 132 | $tags['TOWN'] = $town; |
||
| 133 | $tags['COUNTRY'] = $country; |
||
| 134 | $tags['OTHER'] = '' . _ADSLIGHT_INTERESS . '' . $xoopsConfig['sitename'] . ''; |
||
| 135 | $tags['LISTINGS'] = XOOPS_URL . '/modules/adslight/'; |
||
| 136 | $tags['LINK_URL'] = XOOPS_URL . '/modules/adslight/viewads.php?lid=' . $lid; |
||
| 137 | $tags['THINKS_INTERESTING'] = _ADSLIGHT_MESSAGE; |
||
| 138 | $tags['NO_MAIL'] = _ADSLIGHT_NOMAIL; |
||
| 139 | $tags['YOU_CAN_VIEW_BELOW'] = _ADSLIGHT_YOU_CAN_VIEW_BELOW; |
||
| 140 | $tags['WEBMASTER'] = _ADSLIGHT_WEBMASTER; |
||
| 141 | $tags['NO_REPLY'] = _ADSLIGHT_NOREPLY; |
||
| 142 | $subject = '' . _ADSLIGHT_SUBJET . ' ' . $xoopsConfig['sitename'] . ''; |
||
| 143 | $xoopsMailer = xoops_getMailer(); |
||
| 144 | $xoopsMailer->multimailer->isHTML(true); |
||
| 145 | $xoopsMailer->useMail(); |
||
| 146 | $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/mail_template/'); |
||
| 147 | $xoopsMailer->setTemplate('listing_send_friend.tpl'); |
||
| 148 | $xoopsMailer->setFromEmail($ymail); |
||
| 149 | $xoopsMailer->setToEmails($fmail); |
||
| 150 | $xoopsMailer->setSubject($subject); |
||
| 151 | $xoopsMailer->assign($tags); |
||
| 152 | $xoopsMailer->send(); |
||
| 153 | echo $xoopsMailer->getErrors(); |
||
| 154 | |||
| 155 | redirect_header('index.php', 3, _ADSLIGHT_ANNSEND); |
||
| 156 | } |
||
| 180 |