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