Conditions | 8 |
Paths | 96 |
Total Lines | 84 |
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 |
||
39 | function printAd($lid): void |
||
40 | { |
||
41 | global $xoopsConfig, $xoopsDB, $useroffset, $myts; |
||
42 | $helper = Helper::getInstance(); |
||
43 | $currenttheme = $xoopsConfig['theme_set']; |
||
44 | $lid = (int)$lid; |
||
45 | |||
46 | $result = $xoopsDB->query( |
||
47 | 'SELECT l.lid, l.title, l.expire, l.type, l.desctext, l.tel, l.price, l.typeprice, l.date_created, l.email, l.submitter, l.town, l.country, l.photo, p.cod_img, p.lid, p.uid_owner, p.url FROM ' |
||
48 | . $xoopsDB->prefix('adslight_listing') |
||
49 | . ' l LEFT JOIN ' |
||
50 | . $xoopsDB->prefix('adslight_pictures') |
||
51 | . ' p ON l.lid=p.lid WHERE l.lid=' |
||
52 | . $xoopsDB->escape($lid) |
||
53 | ); |
||
54 | [$lid, $title, $expire, $type, $desctext, $tel, $price, $typeprice, $date_created, $email, $submitter, $town, $country, $photo, $cod_img, $pic_lid, $uid_owner, $url] = $xoopsDB->fetchRow($result); |
||
55 | |||
56 | $title = \htmlspecialchars($title, ENT_QUOTES | ENT_HTML5); |
||
57 | $expire = \htmlspecialchars($expire, ENT_QUOTES | ENT_HTML5); |
||
58 | $type = Utility::getNameType(htmlspecialchars($type, ENT_QUOTES | ENT_HTML5)); |
||
59 | $desctext = $myts->displayTarea($desctext, 1, 1, 1, 1, 1); |
||
60 | $tel = \htmlspecialchars($tel, ENT_QUOTES | ENT_HTML5); |
||
61 | $price = \htmlspecialchars($price, ENT_QUOTES | ENT_HTML5); |
||
62 | $typeprice = \htmlspecialchars($typeprice, ENT_QUOTES | ENT_HTML5); |
||
63 | $submitter = \htmlspecialchars($submitter, ENT_QUOTES | ENT_HTML5); |
||
64 | $town = \htmlspecialchars($town, ENT_QUOTES | ENT_HTML5); |
||
65 | $country = \htmlspecialchars($country, ENT_QUOTES | ENT_HTML5); |
||
66 | |||
67 | echo ' |
||
68 | <html> |
||
69 | <head><title>' . $xoopsConfig['sitename'] . "</title> |
||
70 | <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" > |
||
71 | <meta http-equiv=\”robots\” content=\"noindex, nofollow, noarchive\" > |
||
72 | <link rel=\"StyleSheet\" href=\"../../themes/" . $currenttheme . '/style/style.css" type="text/css"> |
||
73 | </head> |
||
74 | <body bgcolor="#FFFFFF" text="#000000"> |
||
75 | <table border=0><tr><td> |
||
76 | <table border=0 width=100% cellpadding=0 cellspacing=1 bgcolor="#000000"><tr><td> |
||
77 | <table border=0 width=100% cellpadding=15 cellspacing=1 bgcolor="#FFFFFF"><tr><td>'; |
||
78 | |||
79 | $useroffset = 0; |
||
80 | if ($GLOBALS['xoopsUser'] instanceof \XoopsUser) { |
||
81 | $timezone = $GLOBALS['xoopsUser']->timezone(); |
||
82 | $useroffset = empty($timezone) ? $xoopsConfig['default_TZ'] : $GLOBALS['xoopsUser']->timezone(); |
||
83 | } |
||
84 | $date_created = ($useroffset * 3600) + $date_created; |
||
85 | $date2 = $date_created + ($expire * 86400); |
||
86 | $date1 = formatTimestamp($date_created, 's'); |
||
|
|||
87 | $date2 = formatTimestamp($date2, 's'); |
||
88 | |||
89 | echo '<br><br><table width=99% border=0> |
||
90 | <tr> |
||
91 | <td>' . _ADSLIGHT_CLASSIFIED . " (No. ${lid} ) <br>" . _ADSLIGHT_FROM . " ${submitter} <br><br>"; |
||
92 | |||
93 | echo " <strong>${type} :</strong> <i>${title}</i><br>"; |
||
94 | if ($price > 0) { |
||
95 | echo '<strong>' . _ADSLIGHT_PRICE2 . "</strong> ${price} " . $helper->getConfig('adslight_currency_symbol') . " - ${typeprice}<br>"; |
||
96 | } |
||
97 | if ($photo) { |
||
98 | echo "<tr><td><div style='text-align:left'><img class=\"thumb\" src=\"" . XOOPS_URL . "/uploads/adslight/${url}\" width=\"130px\" border=0 ></div>"; |
||
99 | } |
||
100 | echo '</td> |
||
101 | </tr> |
||
102 | <tr> |
||
103 | <td><strong>' . _ADSLIGHT_DESC . "</strong><br><br><div style=\"text-align:justify;\">${desctext}</div><p>"; |
||
104 | if ('' !== $tel) { |
||
105 | echo '<br><strong>' . _ADSLIGHT_TEL . "</strong> ${tel}"; |
||
106 | } |
||
107 | if ('' !== $town) { |
||
108 | echo '<br><strong>' . _ADSLIGHT_TOWN . "</strong> ${town}"; |
||
109 | } |
||
110 | if ('' !== $country) { |
||
111 | echo '<br><strong>' . _ADSLIGHT_COUNTRY . "</strong> ${country}"; |
||
112 | } |
||
113 | echo '<hr>'; |
||
114 | echo '' . _ADSLIGHT_NOMAIL . ' <br>' . XOOPS_URL . '/modules/adslight/viewads.php?lid=' . $lid . '<br>'; |
||
115 | echo '<br><br>' . _ADSLIGHT_DATE2 . " ${date_created} " . _ADSLIGHT_AND . ' ' . _ADSLIGHT_DISPO . " ${date2}<br><br>"; |
||
116 | echo '</td> |
||
117 | </tr> |
||
118 | </table>'; |
||
119 | echo '<br><br></td></tr></table></td></tr></table> |
||
120 | <br><br><div style="text-align:center"> |
||
121 | ' . _ADSLIGHT_EXTRANN . ' <strong>' . $xoopsConfig['sitename'] . '</strong></div><br> |
||
122 | <a href="' . XOOPS_URL . '/modules/adslight/">' . XOOPS_URL . '/modules/adslight/</a> |
||
123 | </td></tr></table> |
||
141 |