| Conditions | 46 | 
| Paths | > 20000 | 
| Total Lines | 458 | 
| Code Lines | 336 | 
| Lines | 34 | 
| Ratio | 7.42 % | 
| 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 | ||
| 59 | function viewads($lid = 0) | ||
| 1 ignored issue–
                            show | |||
| 60 | { | ||
| 61 | global $xoopsDB, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $xoopsTpl, $xoopsUser, $myts, $meta, $moduleDirName, $main_lang, $prem_perm, $xoopsModule; | ||
| 1 ignored issue–
                            show | |||
| 62 |     $pathIcon16 = $xoopsModule->getInfo('icons16'); | ||
| 63 | |||
| 64 | $GLOBALS['xoopsOption']['template_main'] = 'adslight_item.tpl'; | ||
| 65 | include XOOPS_ROOT_PATH . '/header.php'; | ||
| 66 | include XOOPS_ROOT_PATH . '/include/comment_view.php'; | ||
| 67 | $lid = ((int)$lid > 0) ? (int)$lid : 0; | ||
| 68 | $rate = ($xoopsModuleConfig['adslight_rate_item'] == '1') ? '1' : '0'; | ||
| 69 |     $xoopsTpl->assign('rate', $rate); | ||
| 70 |     $xoopsTpl->assign('xmid', $xoopsModule->getVar('mid')); | ||
| 71 |     $xoopsTpl->assign('adslight_logolink', _ADSLIGHT_LOGOLINK); | ||
| 72 | |||
| 73 | // Hack redirection erreur 404 si lid=null | ||
| 74 | View Code Duplication |     if ($lid == '') { | |
| 1 ignored issue–
                            show | |||
| 75 |         header('Status: 301 Moved Permanently', false, 301); | ||
| 76 |         //        header('Location: '.XOOPS_URL.'/modules/adslight/404.php'); | ||
| 77 | // exit(); | ||
| 78 | redirect_header(XOOPS_URL . '/modules/adslight/404.php', 1); | ||
| 79 | } | ||
| 80 | |||
| 81 |     $xoopsTpl->assign('adslight_active_bookmark', $xoopsModuleConfig['adslight_active_bookmark']); | ||
| 82 |     $xoopsTpl->assign('adslight_style_bookmark', $xoopsModuleConfig['adslight_style_bookmark']); | ||
| 83 |     $xoopsTpl->assign('adslight_active_xpayement', $xoopsModuleConfig['adslight_active_xpayment']); | ||
| 84 | |||
| 85 | // adslight 2 | ||
| 86 |     $xoopsTpl->assign('adslight_active_menu', $xoopsModuleConfig['adslight_active_menu']); | ||
| 87 |     $xoopsTpl->assign('adslight_active_rss', $xoopsModuleConfig['adslight_active_rss']); | ||
| 88 | |||
| 89 |     if ($xoopsUser) { | ||
| 90 |         $member_usid = $xoopsUser->getVar('uid'); | ||
| 91 |         if ($usid = $member_usid) { | ||
| 92 |             $xoopsTpl->assign('istheirs', true); | ||
| 93 | |||
| 94 |             if (strlen($xoopsUser->getVar('name'))) { | ||
| 95 |                 $xoopsTpl->assign('user_name', $xoopsUser->getVar('name') . ' (' . $xoopsUser->getVar('uname') . ')'); | ||
| 96 |             } else { | ||
| 97 |                 $xoopsTpl->assign('user_name', $xoopsUser->getVar('uname')); | ||
| 98 | } | ||
| 99 | |||
| 100 |             $xoopsTpl->assign('user_email', $xoopsUser->getVar('email')); | ||
| 101 | |||
| 102 |             list($show_user) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE usid=$member_usid")); | ||
| 103 | |||
| 104 |             $xoopsTpl->assign('show_user', $show_user); | ||
| 105 |             $xoopsTpl->assign('show_user_link', 'members.php?usid=' . $member_usid . ''); | ||
| 106 | } | ||
| 107 | } | ||
| 108 | |||
| 109 |     if ($xoopsUser) { | ||
| 110 |         $currentid = $xoopsUser->getVar('uid', 'E'); | ||
| 111 | } | ||
| 112 | |||
| 113 | $cat_perms = ''; | ||
| 114 |     $categories = adslight_MygetItemIds('adslight_view'); | ||
| 115 |     if (is_array($categories) && count($categories) > 0) { | ||
| 116 |         $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') '; | ||
| 117 | } | ||
| 118 | |||
| 119 |     $result      = $xoopsDB->query('SELECT l.lid, l.cid, l.title, l.status, l.expire, l.type, l.desctext, l.tel, l.price, l.typeprice, l.typeusure, l.date, l.email, l.submitter, l.usid, l.town, l.country, l.contactby, l.premium, l.valid, l.photo, l.hits, l.item_rating, l.item_votes, l.user_rating, l.user_votes, l.comments, p.cod_img, p.lid, p.uid_owner, p.url FROM ' | ||
| 120 |                                    . $xoopsDB->prefix('adslight_listing') | ||
| 121 | . ' l LEFT JOIN ' | ||
| 122 |                                    . $xoopsDB->prefix('adslight_pictures') | ||
| 123 | . " p ON l.lid=p.lid WHERE l.valid='Yes' AND l.lid = " | ||
| 124 | . $xoopsDB->escape($lid) | ||
| 125 | . " and l.status!='1' $cat_perms"); | ||
| 126 | $recordexist = $xoopsDB->getRowsNum($result); | ||
| 127 | |||
| 128 | // Hack redirection erreur 404 si recordexist=null | ||
| 129 | View Code Duplication |     if ($recordexist == '') { | |
| 1 ignored issue–
                            show | |||
| 130 |         header('Status: 301 Moved Permanently', false, 301); | ||
| 131 |         //        header('Location: '.XOOPS_URL.'/modules/adslight/404.php'); | ||
| 132 | // exit(); | ||
| 133 | redirect_header(XOOPS_URL . '/modules/adslight/404.php', 1); | ||
| 134 | } | ||
| 135 | |||
| 136 |     if ($recordexist) { | ||
| 137 | list($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $usid, $town, $country, $contactby, $premium, $valid, $photo, $hits, $item_rating, $item_votes, $user_rating, $user_votes, $comments, $cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($result); | ||
| 138 | |||
| 139 | $newcount = $xoopsModuleConfig['adslight_countday']; | ||
| 140 | $startdate = (time() - (86400 * $newcount)); | ||
| 141 |         if ($startdate < $date) { | ||
| 142 | $newitem = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/newred.gif" alt="new" />'; | ||
| 143 |             $xoopsTpl->assign('new', $newitem); | ||
| 144 | } | ||
| 145 | |||
| 146 | $updir = $xoopsModuleConfig['adslight_link_upload']; | ||
| 147 |         $xoopsTpl->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']); | ||
| 148 |         $xoopsTpl->assign('add_from_title', _ADSLIGHT_ADDFROM); | ||
| 149 |         $xoopsTpl->assign('add_from_sitename', $xoopsConfig['sitename']); | ||
| 150 |         $xoopsTpl->assign('ad_exists', $recordexist); | ||
| 151 |         $xoopsTpl->assign('mydirname', $moduleDirName); | ||
| 152 | |||
| 153 | $count = 0; | ||
| 154 | $x = 0; | ||
| 155 | $i = 0; | ||
| 156 | |||
| 157 |         $result3 = $xoopsDB->query('SELECT cid, pid, title FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE  cid=' . $xoopsDB->escape($cid) . ''); | ||
| 158 | list($ccid, $pid, $ctitle) = $xoopsDB->fetchRow($result3); | ||
| 159 | |||
| 160 |         $xoopsTpl->assign('category_title', $ctitle); | ||
| 161 | |||
| 162 |         $module_id = $xoopsModule->getVar('mid'); | ||
| 163 |         if (is_object($xoopsUser)) { | ||
| 164 | $groups = $xoopsUser->getGroups(); | ||
| 165 |         } else { | ||
| 166 | $groups = XOOPS_GROUP_ANONYMOUS; | ||
| 167 | } | ||
| 168 |         $gperm_handler = xoops_getHandler('groupperm'); | ||
| 169 |         $xoopsTpl->assign('purchasable', $gperm_handler->checkRight('adslight_purchase', $cid, $groups, $module_id)); | ||
| 170 | |||
| 171 | $ctitle = $myts->htmlSpecialChars($ctitle); | ||
| 172 | $varid[$x] = $ccid; | ||
| 173 | $varnom[$x] = $ctitle; | ||
| 174 | |||
| 175 |         list($nbe) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE valid="Yes" AND cid=' . $xoopsDB->escape($cid) . ' AND status!="1"')); | ||
| 176 | |||
| 177 |         if ($pid != 0) { | ||
| 178 | $x = 1; | ||
| 179 |             while ($pid != 0) { | ||
| 180 |                 $result4 = $xoopsDB->query('SELECT cid, pid, title FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE cid=' . $xoopsDB->escape($pid) . ''); | ||
| 181 | list($ccid, $pid, $ctitle) = $xoopsDB->fetchRow($result4); | ||
| 182 | |||
| 183 | $ctitle = $myts->htmlSpecialChars($ctitle); | ||
| 184 | $varid[$x] = $ccid; | ||
| 185 | $varnom[$x] = $ctitle; | ||
| 186 | ++$x; | ||
| 187 | } | ||
| 188 | --$x; | ||
| 189 | } | ||
| 190 | $subcats = ''; | ||
| 191 | $arrow = ' <img src="' . XOOPS_URL . '/modules/adslight/assets/images/arrow.gif" alt="»" />'; | ||
| 192 |         while ($x != -1) { | ||
| 193 | $subcats .= ' ' . $arrow . ' <a href="viewcats.php?cid=' . $varid[$x] . '">' . $varnom[$x] . '</a>'; | ||
| 194 | --$x; | ||
| 195 | } | ||
| 196 |         $xoopsTpl->assign('nav_main', '<a href="index.php">' . _ADSLIGHT_MAIN . '</a>'); | ||
| 197 |         $xoopsTpl->assign('nav_sub', $subcats); | ||
| 198 |         $xoopsTpl->assign('nav_subcount', $nbe); | ||
| 199 | $viewcount_judge = true; | ||
| 200 | $useroffset = ''; | ||
| 201 |         if ($xoopsUser) { | ||
| 202 | $timezone = $xoopsUser->timezone(); | ||
| 203 |             if (isset($timezone)) { | ||
| 204 | $useroffset = $xoopsUser->timezone(); | ||
| 205 |             } else { | ||
| 206 | $useroffset = $xoopsConfig['default_TZ']; | ||
| 207 | } | ||
| 208 |             if ($xoopsUser->isAdmin()) { | ||
| 209 | $adslight_admin = true; | ||
| 210 |             } else { | ||
| 211 | $adslight_admin = false; | ||
| 212 | } | ||
| 213 | |||
| 214 |             if (($adslight_admin = true) || ($xoopsUser->getVar('uid') == $usid)) { | ||
| 215 | $viewcount_judge = false; | ||
| 216 | } | ||
| 217 | |||
| 218 | $contact_pm = '<a href="' . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . addslashes($usid) . '"> ' . _ADSLIGHT_CONTACT_BY_PM . '</a>'; | ||
| 219 | } | ||
| 220 |         if ($viewcount_judge == true) { | ||
| 221 |             $xoopsDB->queryF('UPDATE ' . $xoopsDB->prefix('adslight_listing') . ' SET hits=hits+1 WHERE lid = ' . $xoopsDB->escape($lid) . ''); | ||
| 222 | } | ||
| 223 |         if ($item_votes == 1) { | ||
| 224 | $votestring = _ADSLIGHT_ONEVOTE; | ||
| 225 |         } else { | ||
| 226 | $votestring = sprintf(_ADSLIGHT_NUMVOTES, $item_votes); | ||
| 227 | } | ||
| 228 | $date = ($useroffset * 3600) + $date; | ||
| 229 | $date2 = $date + ($expire * 86400); | ||
| 230 | $date = formatTimestamp($date, 's'); | ||
| 231 | $date2 = formatTimestamp($date2, 's'); | ||
| 232 | $title = $myts->htmlSpecialChars($title); | ||
| 233 | $status = $myts->htmlSpecialChars($status); | ||
| 234 | $expire = $myts->htmlSpecialChars($expire); | ||
| 235 | $type = $myts->htmlSpecialChars($type); | ||
| 236 | $desctext = $myts->displayTarea($desctext, 1, 1, 1); | ||
| 237 | $tel = $myts->htmlSpecialChars($tel); | ||
| 238 | // $price = XoopsLocal::number_format($price, 2, ',', ' '); | ||
| 239 | $typeprice = $myts->htmlSpecialChars($typeprice); | ||
| 240 | $typeusure = $myts->htmlSpecialChars($typeusure); | ||
| 241 | $submitter = $myts->htmlSpecialChars($submitter); | ||
| 242 | $usid = $myts->htmlSpecialChars($usid); | ||
| 243 | $town = $myts->htmlSpecialChars($town); | ||
| 244 | $country = $myts->htmlSpecialChars($country); | ||
| 245 | $contactby = $myts->htmlSpecialChars($contactby); | ||
| 246 | $premium = $myts->htmlSpecialChars($premium); | ||
| 247 | |||
| 248 |         if ($status == 2) { | ||
| 249 | $sold = _ADSLIGHT_RESERVED; | ||
| 250 |         } else { | ||
| 251 | $sold = ''; | ||
| 252 | } | ||
| 253 | |||
| 254 |         $xoopsTpl->assign('printA', '<a href="print.php?op=PrintAd&lid=' . $lid . '" ><img src="assets/images/print.gif" border=0 alt="' . _ADSLIGHT_PRINT . '" /></a> '); | ||
| 255 | |||
| 256 |         if ($usid > 0) { | ||
| 257 |             $xoopsTpl->assign('submitter', '<img src="assets/images/lesannonces.png" border="0" alt="' | ||
| 258 | . _ADSLIGHT_VIEW_MY_ADS | ||
| 259 | . '" />  <a href="members.php?usid=' | ||
| 260 | . addslashes($usid) | ||
| 261 | . '" />' | ||
| 262 | . _ADSLIGHT_VIEW_MY_ADS | ||
| 263 | . ' ' | ||
| 264 | . $submitter | ||
| 265 | . '</a>'); | ||
| 266 |         } else { | ||
| 267 |             $xoopsTpl->assign('submitter', _ADSLIGHT_VIEW_MY_ADS . ' $submitter'); | ||
| 268 | } | ||
| 269 |         $xoopsTpl->assign('lid', $lid); | ||
| 270 |         $xoopsTpl->assign('read', "$hits " . _ADSLIGHT_VIEW2); | ||
| 271 |         $xoopsTpl->assign('rating', XoopsLocal::number_format($item_rating, 2)); | ||
| 272 |         $xoopsTpl->assign('votes', $votestring); | ||
| 273 |         $xoopsTpl->assign('lang_rating', _ADSLIGHT_RATINGC); | ||
| 274 |         $xoopsTpl->assign('lang_ratethisitem', _ADSLIGHT_RATETHISITEM); | ||
| 275 |         $xoopsTpl->assign('xoop_user', false); | ||
| 276 | $isOwner = ''; | ||
| 277 |         if ($xoopsUser) { | ||
| 278 |             $xoopsTpl->assign('xoop_user', true); | ||
| 279 |             $currentid = $xoopsUser->getVar('uid', 'E'); | ||
| 280 |             if ($usid == $currentid) { | ||
| 281 |                 $xoopsTpl->assign('modifyads', '<img src=' | ||
| 282 | . $pathIcon16 | ||
| 283 | . '/edit.png border="0" alt="' | ||
| 284 | . _ADSLIGHT_MODIFANN | ||
| 285 | . '" />  <a href="modify.php?op=ModAd&lid=' | ||
| 286 | . $lid | ||
| 287 | . '">' | ||
| 288 | . _ADSLIGHT_MODIFANN | ||
| 289 | . '</a>'); | ||
| 290 |                 $xoopsTpl->assign('deleteads', '<img src=' | ||
| 291 | . $pathIcon16 | ||
| 292 | . '/delete.png border="0" alt="' | ||
| 293 | . _ADSLIGHT_SUPPRANN | ||
| 294 | . '" />  <a href="modify.php?op=ListingDel&lid=' | ||
| 295 | . $lid | ||
| 296 | . '">' | ||
| 297 | . _ADSLIGHT_SUPPRANN | ||
| 298 | . '</a>'); | ||
| 299 |                 $xoopsTpl->assign('add_photos', '<img src="assets/images/shape_square_add.png" border="0" alt="' | ||
| 300 | . _ADSLIGHT_SUPPRANN | ||
| 301 | . '" />  <a href="view_photos.php?lid=' | ||
| 302 | . $lid | ||
| 303 | . '&uid=' | ||
| 304 | . $usid | ||
| 305 | . '">' | ||
| 306 | . _ADSLIGHT_ADD_PHOTOS | ||
| 307 | . '</a>'); | ||
| 308 | |||
| 309 | $isOwner = true; | ||
| 310 |                 $xoopsTpl->assign('isOwner', $isOwner); | ||
| 311 | } | ||
| 312 | View Code Duplication |             if ($xoopsUser->isAdmin()) { | |
| 1 ignored issue–
                            show | |||
| 313 |                 $xoopsTpl->assign('admin', '<a href="' | ||
| 314 | . XOOPS_URL | ||
| 315 | . '/modules/adslight/admin/modify_ads.php?op=ModifyAds&lid=' | ||
| 316 | . $lid | ||
| 317 | . '"><img src=' | ||
| 318 | . $pathIcon16 | ||
| 319 | . '/edit.png border=0 alt="' | ||
| 320 | . _ADSLIGHT_MODADMIN | ||
| 321 | . '" /></a>'); | ||
| 322 | } | ||
| 323 | } | ||
| 324 | |||
| 325 |         $result7 = $xoopsDB->query('SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . ' WHERE id_type=' . $xoopsDB->escape($type) . ''); | ||
| 326 | list($nom_type) = $xoopsDB->fetchRow($result7); | ||
| 327 | |||
| 328 |         $result8 = $xoopsDB->query('SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . ' WHERE id_price=' . $xoopsDB->escape($typeprice) . ''); | ||
| 329 | list($nom_price) = $xoopsDB->fetchRow($result8); | ||
| 330 | |||
| 331 |         $result9 = $xoopsDB->query('SELECT nom_usure FROM ' . $xoopsDB->prefix('adslight_usure') . ' WHERE id_usure=' . $xoopsDB->escape($typeusure) . ''); | ||
| 332 | list($nom_usure) = $xoopsDB->fetchRow($result9); | ||
| 333 | |||
| 334 |         $xoopsTpl->assign('type', $myts->htmlSpecialChars($nom_type)); | ||
| 335 |         $xoopsTpl->assign('title', $title); | ||
| 336 |         $xoopsTpl->assign('status', $status); | ||
| 337 |         $xoopsTpl->assign('desctext', $desctext); | ||
| 338 |         $xoopsTpl->assign('xoops_pagetitle', $title . ' - ' . $town . ': ' . $country . ' - ' . $ctitle); | ||
| 339 | |||
| 340 | // meta description tags for ads | ||
| 341 | $desctextclean = strip_tags($desctext, '<font><img><strong><i><u>'); | ||
| 342 |         $xoTheme->addMeta('meta', 'description', "$title - " . substr($desctextclean, 0, 150)); | ||
| 343 | |||
| 344 |         if ($price > 0) { | ||
| 345 |             $xoopsTpl->assign('price', '<strong>' . _ADSLIGHT_PRICE2 . '</strong>' . $price . ' ' . $xoopsModuleConfig['adslight_money'] . ' - ' . $typeprice); | ||
| 346 |             $xoopsTpl->assign('price_head', _ADSLIGHT_PRICE2); | ||
| 347 |             //      $xoopsTpl->assign('price_price', $price.' '.$xoopsModuleConfig['adslight_money'].' '); | ||
| 348 | |||
| 349 |             $xoopsTpl->assign('price_price', XoopsLocal::money_format('%.2n', $price)); | ||
| 350 | |||
| 351 |             $xoopsTpl->assign('price_typeprice', $myts->htmlSpecialChars($nom_price)); | ||
| 352 |             $xoopsTpl->assign('price_currency', $xoopsModuleConfig['adslight_currency']); | ||
| 353 |             $xoopsTpl->assign('price_amount', $price); | ||
| 354 | } | ||
| 355 | |||
| 356 |         $xoopsTpl->assign('usure_typeusure', $nom_usure); | ||
| 357 |         $xoopsTpl->assign('premium', $premium); | ||
| 358 | |||
| 359 |         // $xoopsTpl->assign('mustlogin', _ADSLIGHT_MUSTLOGIN); | ||
| 360 |         $xoopsTpl->assign('redirect', '' . '?xoops_redirect=/modules/adslight/index.php'); | ||
| 361 | |||
| 362 |         if ($town) { | ||
| 363 |             $xoopsTpl->assign('local_town', $town); | ||
| 364 | } | ||
| 365 |         if ($xoopsModuleConfig['adslight_use_country'] == 1) { | ||
| 366 |             if ($country) { | ||
| 367 |                 $xoopsTpl->assign('local_country', $country); | ||
| 368 |                 $xoopsTpl->assign('country_head', '<img src="assets/images/world_go.png" border="0" alt="country" />  ' . _ADSLIGHT_COUNTRY); | ||
| 369 | } | ||
| 370 | } | ||
| 371 | |||
| 372 | $tphon = ''; | ||
| 373 |         if ($tel) { | ||
| 374 | $tphon = '<br>' . _ADSLIGHT_ORBY . ' <strong>' . _ADSLIGHT_TEL . '</strong> ' . $tel; | ||
| 375 | } | ||
| 376 | |||
| 377 |         if ($contactby == 1) { | ||
| 378 | $contact = '<a rel="nofollow" href="contact.php?lid=' . $lid . '">' . _ADSLIGHT_BYMAIL2 . '</a>' . $tphon . ''; | ||
| 379 | } | ||
| 380 |         if ($contactby == 2) { | ||
| 381 | $contact = $contact_pm . '' . $tphon; | ||
| 382 | } | ||
| 383 |         if ($contactby == 3) { | ||
| 384 | $contact = '<a rel="nofollow" href="contact.php?lid=' . $lid . '">' . _ADSLIGHT_BYMAIL2 . '</a>' . $tphon . '<br>' . _ADSLIGHT_ORBY . '' . $contact_pm; | ||
| 385 | } | ||
| 386 |         if ($contactby == 4) { | ||
| 387 | $contact = '<br><strong>' . _ADSLIGHT_TEL . '</strong> ' . $tel; | ||
| 388 | } | ||
| 389 |         // $xoopsTpl->assign('contact', $contact); | ||
| 390 |         $xoopsTpl->assign('local_head', '<img src="assets/images/house.png" border="0" alt="local_head" />  ' . _ADSLIGHT_LOCAL); | ||
| 391 | |||
| 392 |         if ($lid) { | ||
| 393 |             if ($sold) { | ||
| 394 |                 $xoopsTpl->assign('bullinfotext', $sold); | ||
| 395 |             } else { | ||
| 396 |                 if ($xoopsUser) { | ||
| 397 |                     $xoopsTpl->assign('bullinfotext', _ADSLIGHT_CONTACT_SUBMITTER . ' ' . $submitter . ' ' . _ADSLIGHT_CONTACTBY2 . ' ' . $contact); | ||
| 398 |                 } else { | ||
| 399 |                     $xoopsTpl->assign('bullinfotext', '<font color="#de090e"><b>' . _ADSLIGHT_MUSTLOGIN . '</b></font>'); | ||
| 400 | } | ||
| 401 | } | ||
| 402 | } | ||
| 403 | |||
| 404 | $user_profile = XoopsUser::getUnameFromId($usid); | ||
| 405 |         $xoopsTpl->assign('user_profile', '<img src="assets/images/profil.png" border="0" alt="' | ||
| 406 | . _ADSLIGHT_PROFILE | ||
| 407 | . '" />  <a rel="nofollow" href="' | ||
| 408 | . XOOPS_URL | ||
| 409 | . '/user.php?usid=' | ||
| 410 | . addslashes($usid) | ||
| 411 | . '">' | ||
| 412 | . _ADSLIGHT_PROFILE | ||
| 413 | . ' ' | ||
| 414 | . $user_profile | ||
| 415 | . '</a>'); | ||
| 416 | |||
| 417 |         if ($photo != '') { | ||
| 418 | include_once __DIR__ . '/class/pictures.php'; | ||
| 419 | |||
| 420 |             $criteria_lid          = new criteria('lid', $lid); | ||
| 421 |             $criteria_uid          = new criteria('uid', $usid); | ||
| 422 | $album_factory = new Xoopsjlm_picturesHandler($xoopsDB); | ||
| 423 | $pictures_object_array = $album_factory->getObjects($criteria_lid, $criteria_uid); | ||
| 424 | $pictures_number = $album_factory->getCount($criteria_lid, $criteria_uid); | ||
| 425 | View Code Duplication |             if ($pictures_number == 0) { | |
| 1 ignored issue–
                            show | |||
| 426 | $nopicturesyet = _ADSLIGHT_NOTHINGYET; | ||
| 427 |                 $xoopsTpl->assign('lang_nopicyet', $nopicturesyet); | ||
| 428 |             } else { | ||
| 429 | |||
| 430 | /** | ||
| 431 | * Lets populate an array with the data from the pictures | ||
| 432 | */ | ||
| 433 | $i = 0; | ||
| 434 |                 foreach ($pictures_object_array as $picture) { | ||
| 435 |                     $pictures_array[$i]['url']     = $picture->getVar('url', 's'); | ||
| 436 |                     $pictures_array[$i]['desc']    = $picture->getVar('title', 's'); | ||
| 437 |                     $pictures_array[$i]['cod_img'] = $picture->getVar('cod_img', 's'); | ||
| 438 |                     $pictures_array[$i]['lid']     = $picture->getVar('lid', 's'); | ||
| 439 |                     $xoopsTpl->assign('pics_array', $pictures_array); | ||
| 440 | |||
| 441 | ++$i; | ||
| 442 | } | ||
| 443 | } | ||
| 444 | $owner = new XoopsUser(); | ||
| 445 | $identifier = $owner->getUnameFromId($usid); | ||
| 446 |             if ($xoopsModuleConfig['adslight_lightbox'] == 1) { | ||
| 447 | $header_lightbox = '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/style/adslight.css" type="text/css" media="all" /> | ||
| 448 | <script type="text/javascript" src="assets/lightbox/js/jquery-1.7.2.min.js"></script> | ||
| 449 | <script type="text/javascript" src="assets/lightbox/js/jquery-ui-1.8.18.custom.min"></script> | ||
| 450 | <script type="text/javascript" src="assets/lightbox/js/jquery.smooth-scroll.min.js"></script> | ||
| 451 | <script type="text/javascript" src="assets/lightbox/js/lightbox.js"></script> | ||
| 452 | <link rel="stylesheet" href="style/galery.css" type="text/css" media="screen" /> | ||
| 453 | <link rel="stylesheet" type="text/css" media="screen" href="assets/lightbox/css/lightbox.css"></link>'; | ||
| 454 |             } else { | ||
| 455 | $header_lightbox = '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/style/adslight.css" type="text/css" media="all" /> | ||
| 456 | <link rel="stylesheet" href="style/galery.css" type="text/css" media="screen" />'; | ||
| 457 | } | ||
| 458 | |||
| 459 |             $xoopsTpl->assign('path_uploads', $xoopsModuleConfig['adslight_link_upload']); | ||
| 460 | |||
| 461 |             $xoopsTpl->assign('permit', $prem_perm); | ||
| 462 | |||
| 463 |             if ($xoopsModuleConfig['active_rewriteurl'] > 0) { | ||
| 464 | /* ici le meta Canonicale pour le Rewrite */ | ||
| 465 |                 $xoopsTpl->assign('xoops_module_header', $header_lightbox); | ||
| 466 |             } else { | ||
| 467 |                 $xoopsTpl->assign('xoops_module_header', $header_lightbox); | ||
| 468 | } | ||
| 469 |             $xoopsTpl->assign('photo', $photo); | ||
| 470 |             $xoopsTpl->assign('pic_lid', $pic_lid); | ||
| 471 |             $xoopsTpl->assign('pic_owner', $uid_owner); | ||
| 472 |         } else { | ||
| 473 |             $xoopsTpl->assign('photo', ''); | ||
| 474 | } | ||
| 475 |         $xoopsTpl->assign('date', '<img alt="date" border="0" src="assets/images/date.png" />  <strong>' | ||
| 476 | . _ADSLIGHT_DATE2 | ||
| 477 | . ':</strong> ' | ||
| 478 | . $date | ||
| 479 | . '<br><img alt="date_error" border="0" src="assets/images/date_error.png" />  <strong>' | ||
| 480 | . _ADSLIGHT_DISPO | ||
| 481 | . ':</strong> ' | ||
| 482 | . $date2 | ||
| 483 | . ''); | ||
| 484 |     } else { | ||
| 485 |         $xoopsTpl->assign('no_ad', _ADSLIGHT_NOCLAS); | ||
| 486 | } | ||
| 487 |     $result8 = $xoopsDB->query('SELECT title FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE cid=' . $xoopsDB->escape($cid) . ''); | ||
| 488 | |||
| 489 | list($ctitle) = $xoopsDB->fetchRow($result8); | ||
| 490 |     $xoopsTpl->assign('friend', '<img src="assets/images/friend.gif" border="0" alt="' | ||
| 491 | . _ADSLIGHT_SENDFRIENDS | ||
| 492 | . '" />  <a rel="nofollow" href="sendfriend.php?op=SendFriend&lid=' | ||
| 493 | . $lid | ||
| 494 | . '">' | ||
| 495 | . _ADSLIGHT_SENDFRIENDS | ||
| 496 | . '</a>'); | ||
| 497 | |||
| 498 |     $xoopsTpl->assign('alerteabus', '<img src="assets/images/error.png" border="0" alt="' | ||
| 499 | . _ADSLIGHT_ALERTEABUS | ||
| 500 | . '" />  <a rel="nofollow" href="report-abuse.php?op=ReportAbuse&lid=' | ||
| 501 | . $lid | ||
| 502 | . '">' | ||
| 503 | . _ADSLIGHT_ALERTEABUS | ||
| 504 | . '</a>'); | ||
| 505 | |||
| 506 |     $xoopsTpl->assign('link_main', '<a href="../adslight/">' . _ADSLIGHT_MAIN . '</a>'); | ||
| 507 |     $xoopsTpl->assign('link_cat', '<a href="viewcats.php?cid=' . addslashes($cid) . '">' . _ADSLIGHT_GORUB . ' ' . $ctitle . '</a>'); | ||
| 508 | |||
| 509 |     $xoopsTpl->assign('printA', '<img src="assets/images/print.gif" border="0" alt="' | ||
| 510 | . _ADSLIGHT_PRINT | ||
| 511 | . '" />  <a rel="nofollow" href="print.php?op=PrintAd&lid=' | ||
| 512 | . $lid | ||
| 513 | . '">' | ||
| 514 | . _ADSLIGHT_PRINT | ||
| 515 | . '</a>'); | ||
| 516 | } | ||
| 517 | |||
| 570 | 
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.