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