| Conditions | 56 |
| Paths | > 20000 |
| Total Lines | 404 |
| Code Lines | 293 |
| Lines | 88 |
| Ratio | 21.78 % |
| 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 |
||
| 62 | function Adsview($cid = 0, $min = 0, $orderby, $show = 0) |
||
|
1 ignored issue
–
show
|
|||
| 63 | { |
||
| 64 | global $xoopsDB, $xoopsTpl, $xoopsConfig, $xoopsUser, $xoopsModuleConfig, $myts, $mytree, $imagecat, $meta, $moduleDirName, $main_lang, $xoopsUser, $mid, $prem_perm, $xoopsModule; |
||
|
1 ignored issue
–
show
|
|||
| 65 | $pathIcon16 = $xoopsModule->getInfo('icons16'); |
||
| 66 | |||
| 67 | $GLOBALS['xoopsOption']['template_main'] = 'adslight_category.tpl'; |
||
| 68 | include XOOPS_ROOT_PATH . '/header.php'; |
||
| 69 | |||
| 70 | $xoopsTpl->assign('xmid', $xoopsModule->getVar('mid')); |
||
| 71 | $xoopsTpl->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']); |
||
| 72 | $xoopsTpl->assign('add_from_title', _ADSLIGHT_ADDFROM); |
||
| 73 | $xoopsTpl->assign('add_from_sitename', $xoopsConfig['sitename']); |
||
| 74 | $xoopsTpl->assign('only_pix', _ADSLIGHT_ONLYPIX); |
||
| 75 | $xoopsTpl->assign('adslight_logolink', _ADSLIGHT_LOGOLINK); |
||
| 76 | $xoopsTpl->assign('permit', $prem_perm); |
||
| 77 | |||
| 78 | $xoopsTpl->assign('xoops_module_header', '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/style/adslight.css" type="text/css" media="all" />'); |
||
| 79 | |||
| 80 | // $adslight_use_catscode = $xoopsModuleConfig['adslight_use_catscode']; |
||
| 81 | // $adslight_cats_code = $xoopsModuleConfig['adslight_cats_code']; |
||
| 82 | |||
| 83 | $xoopsTpl->assign('adslight_use_catscode', $xoopsModuleConfig['adslight_use_catscode']); |
||
| 84 | $xoopsTpl->assign('adslight_cats_code', $xoopsModuleConfig['adslight_cats_code']); |
||
| 85 | |||
| 86 | $banner = xoops_getbanner(); |
||
| 87 | $xoopsTpl->assign('banner', $banner); |
||
| 88 | // $index_code_place = $xoopsModuleConfig['adslight_index_code_place']; |
||
| 89 | // $use_extra_code = $xoopsModuleConfig['adslight_use_index_code']; |
||
| 90 | // $adslight_use_banner = $xoopsModuleConfig['adslight_use_banner']; |
||
| 91 | // $index_extra_code = $xoopsModuleConfig['adslight_index_code']; |
||
| 92 | |||
| 93 | $xoopsTpl->assign('use_extra_code', $xoopsModuleConfig['adslight_use_index_code']); |
||
| 94 | $xoopsTpl->assign('adslight_use_banner', $xoopsModuleConfig['adslight_use_banner']); |
||
| 95 | $xoopsTpl->assign('index_extra_code', $xoopsModuleConfig['adslight_index_code']); |
||
| 96 | $xoopsTpl->assign('index_code_place', $xoopsModuleConfig['adslight_index_code_place']); |
||
| 97 | |||
| 98 | // adslight 2 |
||
| 99 | $xoopsTpl->assign('adslight_active_menu', $xoopsModuleConfig['adslight_active_menu']); |
||
| 100 | $xoopsTpl->assign('adslight_active_rss', $xoopsModuleConfig['adslight_active_rss']); |
||
| 101 | |||
| 102 | /// No Adds in this Cat /// |
||
| 103 | $submit_perms = adslight_MygetItemIds('adslight_submit'); |
||
| 104 | |||
| 105 | if ($xoopsUser && is_array($submit_perms) && count($submit_perms) > 0) { |
||
| 106 | $xoopsTpl->assign('not_adds_in_this_cat', |
||
| 107 | '' . _ADSLIGHT_ADD_LISTING_NOTADDSINTHISCAT . '<a href="addlisting.php?cid=' . addslashes($cid) . '">' . _ADSLIGHT_ADD_LISTING_NOTADDSSUBMIT . '</a>'); |
||
| 108 | } else { |
||
| 109 | $xoopsTpl->assign('not_adds_in_this_cat', |
||
| 110 | '' . _ADSLIGHT_ADD_LISTING_NOTADDSINTHISCAT . '<br>' . _ADSLIGHT_ADD_LISTING_BULL . '<a href="' . XOOPS_URL . '/register.php">' . _ADSLIGHT_ADD_LISTING_SUB . '</a>.'); |
||
| 111 | } |
||
| 112 | |||
| 113 | $xoopsTpl->assign('Feed_RSS_cat', ' <a href="rss.php?cid=' . addslashes($cid) . '"><img border="0" alt="Feed RSS" src="assets/images/rssfeed_buttons.png" /></a>'); |
||
| 114 | |||
| 115 | View Code Duplication | if ($xoopsUser) { |
|
|
1 ignored issue
–
show
|
|||
| 116 | $member_usid = $xoopsUser->getVar('uid'); |
||
| 117 | if ($usid = $member_usid) { |
||
| 118 | $xoopsTpl->assign('istheirs', true); |
||
| 119 | |||
| 120 | list($show_user) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE usid=' . $member_usid . '')); |
||
| 121 | |||
| 122 | $xoopsTpl->assign('show_user', $show_user); |
||
| 123 | $xoopsTpl->assign('show_user_link', 'members.php?usid=' . $member_usid . ''); |
||
| 124 | } |
||
| 125 | } |
||
| 126 | |||
| 127 | $default_sort = $xoopsModuleConfig['adslight_lsort_order']; |
||
| 128 | |||
| 129 | $cid = ((int)$cid > 0) ? (int)$cid : 0; |
||
| 130 | $min = ((int)$min > 0) ? (int)$min : 0; |
||
| 131 | $show = ((int)$show > 0) ? (int)$show : $xoopsModuleConfig['adslight_perpage']; |
||
| 132 | $max = $min + $show; |
||
| 133 | $orderby = isset($orderby) ? adslight_convertorderbyin($orderby) : $default_sort; |
||
| 134 | |||
| 135 | $updir = $xoopsModuleConfig['adslight_link_upload']; |
||
| 136 | $xoopsTpl->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']); |
||
| 137 | $xoopsTpl->assign('add_from_title', _ADSLIGHT_ADDFROM); |
||
| 138 | $xoopsTpl->assign('add_from_sitename', $xoopsConfig['sitename']); |
||
| 139 | $xoopsTpl->assign('subcat_title2', _ADSLIGHT_ANNONCES); |
||
| 140 | |||
| 141 | $categories = adslight_MygetItemIds('adslight_view'); |
||
| 142 | View Code Duplication | if (is_array($categories) && count($categories) > 0) { |
|
|
1 ignored issue
–
show
|
|||
| 143 | if (!in_array($cid, $categories)) { |
||
| 144 | redirect_header(XOOPS_URL . '/modules/adslight/index.php', 3, _NOPERM); |
||
| 145 | } |
||
| 146 | } else { // User can't see any category |
||
| 147 | redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM); |
||
| 148 | } |
||
| 149 | |||
| 150 | $arrow = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/arrow.gif" alt="»" />'; |
||
| 151 | |||
| 152 | $pathstring = '<a href="index.php">' . _ADSLIGHT_MAIN . '</a>'; |
||
| 153 | $pathstring .= $mytree->getNicePathFromId($cid, 'title', 'viewcats.php?'); |
||
| 154 | $xoopsTpl->assign('module_name', $xoopsModule->getVar('name')); |
||
| 155 | $xoopsTpl->assign('category_path', $pathstring); |
||
| 156 | $xoopsTpl->assign('category_id', $cid); |
||
| 157 | |||
| 158 | $countresult = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE cid=' . $xoopsDB->escape($cid) . ' AND valid="Yes" AND status!="1"'); |
||
| 159 | list($trow) = $xoopsDB->fetchRow($countresult); |
||
| 160 | $trows = $trow; |
||
| 161 | |||
| 162 | $cat_perms = ''; |
||
| 163 | if (is_array($categories) && count($categories) > 0) { |
||
| 164 | $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') '; |
||
| 165 | } |
||
| 166 | |||
| 167 | $result = $xoopsDB->query('SELECT cid, pid, title, cat_desc, cat_keywords FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE cid=' . $xoopsDB->escape($cid) . ' ' . $cat_perms . ''); |
||
| 168 | list($cid, $pid, $title, $cat_desc, $cat_keywords) = $xoopsDB->fetchRow($result); |
||
| 169 | |||
| 170 | $xoopsTpl->assign('cat_desc', $cat_desc); |
||
| 171 | $xoopsTpl->assign('cat_title', _ADSLIGHT_ANNONCES . ' ' . $title); |
||
| 172 | $xoopsTpl->assign('cat_keywords', $cat_keywords); |
||
| 173 | $xoopsTpl->assign('xoops_pagetitle', $title); |
||
| 174 | |||
| 175 | if ($cat_desc > '0') { |
||
| 176 | // meta description & keywords tags for categories |
||
| 177 | $cat_desc_clean = strip_tags($cat_desc, '<font><img><strong><i><u>'); |
||
| 178 | $cat_keywords_clean = strip_tags($cat_keywords, '<font><img><strong><i><u><br><li>'); |
||
| 179 | |||
| 180 | $xoTheme->addMeta('meta', 'description', '' . substr($cat_desc_clean, 0, 200)); |
||
| 181 | $xoTheme->addMeta('meta', 'keywords', '' . substr($cat_keywords_clean, 0, 1000)); |
||
| 182 | } |
||
| 183 | |||
| 184 | $submit_perms = adslight_MygetItemIds('adslight_submit'); |
||
| 185 | if ($xoopsUser && is_array($submit_perms) && count($submit_perms) > 0) { |
||
| 186 | $add_listing = '' . _ADSLIGHT_ADD_LISTING_BULLCATS . '<a href="addlisting.php?cid=' . addslashes($cid) . '">' . _ADSLIGHT_ADD_LISTING_SUBOK . '</a> |
||
| 187 | '; |
||
| 188 | } else { // User can't see any category |
||
| 189 | $add_listing = '' . _ADSLIGHT_ADD_LISTING_BULLCATSOK . '<a href="' . XOOPS_URL . '/register.php">' . _ADSLIGHT_ADD_LISTING_SUB . '</a>. |
||
| 190 | '; |
||
| 191 | } |
||
| 192 | |||
| 193 | if ($xoopsModuleConfig['adslight_main_cat'] == 1 || $pid != 0) { |
||
| 194 | $xoopsTpl->assign('bullinfotext', $add_listing); |
||
| 195 | } |
||
| 196 | |||
| 197 | $arr = array(); |
||
| 198 | $arr = $mytree->getFirstChild($cid, 'title'); |
||
| 199 | |||
| 200 | if (count($arr) > 0) { |
||
| 201 | $scount = 1; |
||
| 202 | foreach ($arr as $ele) { |
||
| 203 | if (in_array($ele['cid'], $categories)) { |
||
| 204 | $sub_arr = array(); |
||
| 205 | $sub_arr = $mytree->getFirstChild($ele['cid'], 'title'); |
||
| 206 | $space = 0; |
||
| 207 | $chcount = 0; |
||
| 208 | $infercategories = ''; |
||
| 209 | $totallisting = adslight_getTotalItems($ele['cid'], 1); |
||
| 210 | foreach ($sub_arr as $sub_ele) { |
||
| 211 | if (in_array($sub_ele['cid'], $categories)) { |
||
| 212 | $chtitle = $myts->htmlSpecialChars($sub_ele['title']); |
||
| 213 | |||
| 214 | if ($chcount > 5) { |
||
| 215 | $infercategories .= '...'; |
||
| 216 | break; |
||
| 217 | } |
||
| 218 | if ($space > 0) { |
||
| 219 | $infercategories .= ', '; |
||
| 220 | } |
||
| 221 | $infercategories .= '<a href="' . XOOPS_URL . '/modules/adslight/viewcats.php?cid=' . $sub_ele['cid'] . '">' . $chtitle . '</a>'; |
||
| 222 | |||
| 223 | $infercategories .= ' (' . adslight_getTotalItems($sub_ele['cid']) . ')'; |
||
| 224 | $infercategories .= ' ' . categorynewgraphic($sub_ele['cid']) . ''; |
||
| 225 | ++$space; |
||
| 226 | ++$chcount; |
||
| 227 | } |
||
| 228 | } |
||
| 229 | |||
| 230 | $xoopsTpl->append('subcategories', array( |
||
| 231 | 'title' => $myts->htmlSpecialChars($ele['title']), |
||
| 232 | 'id' => $ele['cid'], |
||
| 233 | 'infercategories' => $infercategories, |
||
| 234 | 'totallisting' => $totallisting, |
||
| 235 | '' |
||
| 236 | )); |
||
| 237 | |||
| 238 | ++$scount; |
||
| 239 | $xoopsTpl->assign('lang_subcat', _ADSLIGHT_AVAILAB); |
||
| 240 | } |
||
| 241 | } |
||
| 242 | } |
||
| 243 | |||
| 244 | $pagenav = ''; |
||
| 245 | if ($trows > '0') { |
||
| 246 | $xoopsTpl->assign('last_head', _ADSLIGHT_THE . ' ' . $xoopsModuleConfig['adslight_newcount'] . ' ' . _ADSLIGHT_LASTADD); |
||
| 247 | $xoopsTpl->assign('last_head_title', _ADSLIGHT_TITLE); |
||
| 248 | $xoopsTpl->assign('last_head_price', _ADSLIGHT_PRICE); |
||
| 249 | $xoopsTpl->assign('last_head_date', _ADSLIGHT_DATE); |
||
| 250 | $xoopsTpl->assign('last_head_local', _ADSLIGHT_LOCAL2); |
||
| 251 | $xoopsTpl->assign('last_head_hits', _ADSLIGHT_VIEW); |
||
| 252 | $xoopsTpl->assign('last_head_photo', _ADSLIGHT_PHOTO); |
||
| 253 | $xoopsTpl->assign('cat', $cid); |
||
| 254 | $xoopsTpl->assign('min', $min); |
||
| 255 | $rank = 1; |
||
| 256 | |||
| 257 | $cat_perms = ''; |
||
| 258 | if (is_array($categories) && count($categories) > 0) { |
||
| 259 | $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') '; |
||
| 260 | } |
||
| 261 | |||
| 262 | $sql = 'SELECT lid, title, status, type, price, typeprice, date, town, country, contactby, usid, premium, valid, photo, hits FROM ' |
||
| 263 | . $xoopsDB->prefix('adslight_listing') |
||
| 264 | . ' WHERE valid="Yes" and cid=' |
||
| 265 | . $xoopsDB->escape($cid) |
||
| 266 | . ' AND status!="1" ' |
||
| 267 | . $cat_perms |
||
| 268 | . ' ORDER BY ' |
||
| 269 | . $orderby |
||
| 270 | . ''; |
||
| 271 | $result1 = $xoopsDB->query($sql, $show, $min); |
||
| 272 | if ($trows > '1') { |
||
| 273 | $xoopsTpl->assign('show_nav', true); |
||
| 274 | $orderbyTrans = adslight_convertorderbytrans($orderby); |
||
| 275 | $xoopsTpl->assign('lang_sortby', _ADSLIGHT_SORTBY); |
||
| 276 | $xoopsTpl->assign('lang_title', _ADSLIGHT_TITLE); |
||
| 277 | $xoopsTpl->assign('lang_titleatoz', _ADSLIGHT_TITLEATOZ); |
||
| 278 | $xoopsTpl->assign('lang_titleztoa', _ADSLIGHT_TITLEZTOA); |
||
| 279 | $xoopsTpl->assign('lang_date', _ADSLIGHT_DATE); |
||
| 280 | $xoopsTpl->assign('lang_dateold', _ADSLIGHT_DATEOLD); |
||
| 281 | $xoopsTpl->assign('lang_datenew', _ADSLIGHT_DATENEW); |
||
| 282 | $xoopsTpl->assign('lang_price', _ADSLIGHT_PRICE); |
||
| 283 | $xoopsTpl->assign('lang_priceltoh', '' . _ADSLIGHT_PRICELTOH . ''); |
||
| 284 | $xoopsTpl->assign('lang_pricehtol', '' . _ADSLIGHT_PRICEHTOL . ''); |
||
| 285 | $xoopsTpl->assign('lang_popularity', _ADSLIGHT_POPULARITY); |
||
| 286 | $xoopsTpl->assign('lang_popularityleast', _ADSLIGHT_POPULARITYLTOM); |
||
| 287 | $xoopsTpl->assign('lang_popularitymost', _ADSLIGHT_POPULARITYMTOL); |
||
| 288 | $xoopsTpl->assign('lang_cursortedby', sprintf(_ADSLIGHT_CURSORTEDBY, adslight_convertorderbytrans($orderby))); |
||
| 289 | } |
||
| 290 | |||
| 291 | while (list($lid, $title, $status, $type, $price, $typeprice, $date, $town, $country, $contactby, $usid, $premium, $valid, $photo, $hits) = $xoopsDB->fetchRow($result1)) { |
||
| 292 | $a_item = array(); |
||
| 293 | $title = $myts->htmlSpecialChars($title); |
||
| 294 | $type = $myts->htmlSpecialChars($type); |
||
| 295 | // $price = number_format($price, 2, ',', ' '); |
||
| 296 | $town = $myts->htmlSpecialChars($town); |
||
| 297 | $country = $myts->htmlSpecialChars($country); |
||
| 298 | $contactby = $myts->htmlSpecialChars($contactby); |
||
| 299 | $useroffset = ''; |
||
| 300 | |||
| 301 | $newcount = $xoopsModuleConfig['adslight_countday']; |
||
| 302 | $startdate = (time() - (86400 * $newcount)); |
||
| 303 | View Code Duplication | if ($startdate < $date) { |
|
|
1 ignored issue
–
show
|
|||
| 304 | $newitem = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/newred.gif" />'; |
||
| 305 | $a_item['new'] = $newitem; |
||
| 306 | } |
||
| 307 | View Code Duplication | if ($xoopsUser) { |
|
|
1 ignored issue
–
show
|
|||
| 308 | $timezone = $xoopsUser->timezone(); |
||
| 309 | if (isset($timezone)) { |
||
| 310 | $useroffset = $xoopsUser->timezone(); |
||
| 311 | } else { |
||
| 312 | $useroffset = $xoopsConfig['default_TZ']; |
||
| 313 | } |
||
| 314 | } |
||
| 315 | $date = ($useroffset * 3600) + $date; |
||
| 316 | $date = formatTimestamp($date, 's'); |
||
| 317 | View Code Duplication | if ($xoopsUser) { |
|
|
1 ignored issue
–
show
|
|||
| 318 | if ($xoopsUser->isAdmin()) { |
||
| 319 | $a_item['admin'] = '<a href="' |
||
| 320 | . XOOPS_URL |
||
| 321 | . '/modules/adslight/admin/validate_ads.php?op=ModifyAds&lid=' |
||
| 322 | . $lid |
||
| 323 | . '"><img src="' |
||
| 324 | . $pathIcon16 |
||
| 325 | . '/edit.png' |
||
| 326 | . '" border=0 alt="' |
||
| 327 | . _ADSLIGHT_MODADMIN |
||
| 328 | . '" title="' |
||
| 329 | . _ADSLIGHT_MODADMIN |
||
| 330 | . '"/></a>'; |
||
| 331 | } |
||
| 332 | } |
||
| 333 | |||
| 334 | $result7 = $xoopsDB->query('SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . ' WHERE id_type=' . $xoopsDB->escape($type) . ''); |
||
| 335 | list($nom_type) = $xoopsDB->fetchRow($result7); |
||
| 336 | |||
| 337 | $result8 = $xoopsDB->query('SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . ' WHERE id_price=' . $xoopsDB->escape($typeprice) . ''); |
||
| 338 | list($nom_price) = $xoopsDB->fetchRow($result8); |
||
| 339 | |||
| 340 | $a_item['type'] = $myts->htmlSpecialChars($nom_type); |
||
| 341 | $a_item['title'] = '<a href="viewads.php?lid=' . $lid . '"><strong>' . $title . '</strong></a>'; |
||
| 342 | $a_item['status'] = $status; |
||
| 343 | if ($price > 0) { |
||
| 344 | |||
| 345 | // $a_item['price'] = $price. ' '. $xoopsModuleConfig['adslight_money'].''; |
||
| 346 | $a_item['price'] = XoopsLocal::money_format('%.2n', $price); |
||
| 347 | $a_item['price_typeprice'] = $myts->htmlSpecialChars($nom_price); |
||
| 348 | } |
||
| 349 | $a_item['date'] = $date; |
||
| 350 | $a_item['local'] = ''; |
||
| 351 | if ($town) { |
||
| 352 | $a_item['local'] .= $town; |
||
| 353 | } |
||
| 354 | $a_item['country'] = ''; |
||
| 355 | if ($country) { |
||
| 356 | $a_item['country'] = $country; |
||
| 357 | } |
||
| 358 | |||
| 359 | $cat = addslashes($cid); |
||
| 360 | if ($status == 2) { |
||
| 361 | $a_item['sold'] = _ADSLIGHT_RESERVEDMEMBER; |
||
| 362 | } |
||
| 363 | |||
| 364 | View Code Duplication | if ($xoopsModuleConfig['active_thumbscats'] > 0) { |
|
|
1 ignored issue
–
show
|
|||
| 365 | $a_item['no_photo'] = '<a href="' |
||
| 366 | . XOOPS_URL |
||
| 367 | . '/modules/adslight/viewads.php?lid=' |
||
| 368 | . $lid |
||
| 369 | . '"><img class="thumb" src="' |
||
| 370 | . XOOPS_URL |
||
| 371 | . '/modules/adslight/assets/images/nophoto.jpg" align="left" width="100px" alt="' |
||
| 372 | . $title |
||
| 373 | . '" /></a>'; |
||
| 374 | |||
| 375 | $updir = $xoopsModuleConfig['adslight_link_upload']; |
||
| 376 | $sql = 'SELECT cod_img, lid, uid_owner, url FROM ' |
||
| 377 | . $xoopsDB->prefix('adslight_pictures') |
||
| 378 | . ' WHERE uid_owner=' |
||
| 379 | . $xoopsDB->escape($usid) |
||
| 380 | . ' AND lid=' |
||
| 381 | . $xoopsDB->escape($lid) |
||
| 382 | . ' ORDER BY date_added ASC limit 1'; |
||
| 383 | $resultp = $xoopsDB->query($sql); |
||
| 384 | |||
| 385 | while (list($cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($resultp)) { |
||
| 386 | if ($photo) { |
||
| 387 | $a_item['photo'] = '<a href="' |
||
| 388 | . XOOPS_URL |
||
| 389 | . '/modules/adslight/viewads.php?lid=' |
||
| 390 | . $lid |
||
| 391 | . '"><img class="thumb" src="' |
||
| 392 | . $updir |
||
| 393 | . '/thumbs/thumb_' |
||
| 394 | . $url |
||
| 395 | . '" align="left" width="100px" alt="' |
||
| 396 | . $title |
||
| 397 | . '" /></a>'; |
||
| 398 | } |
||
| 399 | } |
||
| 400 | } else { |
||
| 401 | $a_item['no_photo'] = '<p><img src="' . XOOPS_URL . '/modules/adslight/assets/images/camera_nophoto.png" align="left" width="24" alt="' . $title . '" /></p>'; |
||
| 402 | $updir = $xoopsModuleConfig['adslight_link_upload']; |
||
| 403 | $sql = 'SELECT cod_img, lid, uid_owner, url FROM ' |
||
| 404 | . $xoopsDB->prefix('adslight_pictures') |
||
| 405 | . ' WHERE uid_owner=' |
||
| 406 | . $xoopsDB->escape($usid) |
||
| 407 | . ' AND lid=' |
||
| 408 | . $xoopsDB->escape($lid) |
||
| 409 | . ' ORDER BY date_added ASC limit 1'; |
||
| 410 | $resultp = $xoopsDB->query($sql); |
||
| 411 | while (list($cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($resultp)) { |
||
| 412 | if ($photo) { |
||
| 413 | $a_item['photo'] = '<p><img src="' . XOOPS_URL . '/modules/adslight/assets/images/camera_photo.png" align="left" width="24" alt="' . $title . '" /></p>'; |
||
| 414 | } |
||
| 415 | } |
||
| 416 | } |
||
| 417 | |||
| 418 | $a_item['hits'] = $hits; |
||
| 419 | ++$rank; |
||
| 420 | $xoopsTpl->append('items', $a_item); |
||
| 421 | } |
||
| 422 | |||
| 423 | $cid = ((int)$cid > 0) ? (int)$cid : 0; |
||
| 424 | |||
| 425 | $orderby = adslight_convertorderbyout($orderby); |
||
| 426 | $linkpages = ceil($trows / $show); |
||
| 427 | |||
| 428 | //Page Numbering |
||
| 429 | if ($linkpages != 1 && $linkpages != 0) { |
||
| 430 | $prev = $min - $show; |
||
| 431 | if ($prev >= 0) { |
||
| 432 | $pagenav .= "<a href='viewcats.php?cid=$cid&min=$prev&orderby=$orderby&show=$show'><strong><u>«</u></strong></a> "; |
||
| 433 | } |
||
| 434 | $counter = 1; |
||
| 435 | $currentpage = ($max / $show); |
||
| 436 | while ($counter <= $linkpages) { |
||
| 437 | $mintemp = ($show * $counter) - $show; |
||
| 438 | if ($counter == $currentpage) { |
||
| 439 | $pagenav .= "<strong>($counter)</strong> "; |
||
| 440 | } else { |
||
| 441 | $pagenav .= "<a href='viewcats.php?cid=$cid&min=$mintemp&orderby=$orderby&show=$show'>$counter</a> "; |
||
| 442 | } |
||
| 443 | ++$counter; |
||
| 444 | } |
||
| 445 | if ($trows > $max) { |
||
| 446 | $pagenav .= "<a href='viewcats.php?cid=$cid&min=$max&orderby=$orderby&show=$show'>"; |
||
| 447 | $pagenav .= '<strong><u>»</u></strong></a>'; |
||
| 448 | } |
||
| 449 | } |
||
| 450 | } |
||
| 451 | |||
| 452 | $xoopsTpl->assign('nav_page', $pagenav); |
||
| 453 | |||
| 454 | if (!$xoopsUser || $xoopsUser) { |
||
| 455 | global $xoopsDB; |
||
|
1 ignored issue
–
show
|
|||
| 456 | |||
| 457 | $xt = new XoopsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid'); |
||
| 458 | $jump = XOOPS_URL . '/modules/adslight/viewcats.php?cid='; |
||
| 459 | ob_start(); |
||
| 460 | $xt->makeMySelBox('title', 'title', $cid, 1, 'pid', "location=\"" . $jump . "\"+this.options[this.selectedIndex].value"); |
||
| 461 | $select_go_cats = ob_get_contents(); |
||
| 462 | ob_end_clean(); |
||
| 463 | $xoopsTpl->assign('select_go_cats', $select_go_cats); |
||
| 464 | } |
||
| 465 | } |
||
| 466 | |||
| 494 |
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.