// // ------------------------------------------------------------------------- // // Original Author: Pascal Le Boustouller // Author Website : pascal.e-xoops@perso-search.com // Licence Type : GPL // ------------------------------------------------------------------------- // include("header.php"); include(XOOPS_ROOT_PATH."/modules/myAds/cache/config.php"); include(XOOPS_ROOT_PATH."/modules/myAds/include/functions.php"); include_once(XOOPS_ROOT_PATH."/modules/myAds/class/arbre.php"); $mytree = new XoopsArbre($xoopsDB->prefix("ann_categories"),"cid","pid"); if($xoopsConfig['startpage'] == "MyAds") { $xoopsOption['show_rblock'] =1; include(XOOPS_ROOT_PATH."/header.php"); make_cblock(); } else { $xoopsOption['show_rblock'] =0; include(XOOPS_ROOT_PATH."/header.php"); } # function index ##################################################### function index() { global $xoopsDB, $xoopsConfig, $xoopsUser, $xoopsTpl, $moderated, $myts, $mytree, $souscat, $classm, $nbsouscat, $meta, $newann; $GLOBALS['xoopsOption']['template_main'] = 'myads_index.html'; $xoopsTpl->assign('add_from', _CLA_ADDFROM." ".$xoopsConfig['sitename']); if ($moderated == '1') { $result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("ann_annonces")." WHERE valid='No'"); list($propo) = $xoopsDB->fetchRow($result); $xoopsTpl->assign('moderated', true); if ($xoopsUser) { if ($xoopsUser->isAdmin()) { $xoopsTpl->assign('admin_block', _CLA_ADMINCADRE); if($propo == 0) $xoopsTpl->assign('confirm_ads', _CLA_NO_CLA); else $xoopsTpl->assign('confirm_ads', _CLA_THEREIS." $propo "._CLA_WAIT."
"._CLA_SEEIT.""); } } } $result=$xoopsDB->query("SELECT cid, title, img FROM ".$xoopsDB->prefix("ann_categories")." WHERE pid = 0 ORDER BY $classm") or die("Error"); list($ncatp) = $xoopsDB->fetchRow($xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("ann_categories")." WHERE pid=0")); $count = 0; while($myrow = $xoopsDB->fetchArray($result)) { $a_cat = array(); $cid = $myrow['cid']; $title = $myts->makeTboxData4Show($myrow['title']); $totallink = getTotalItems($myrow['cid'], _YES); $a_cat['image'] = ""; $a_cat['link'] = "$title"; $a_cat['count'] = $totallink; if ($souscat == 1) { // get child category objects $arr=array(); $arr=$mytree->getFirstChild($myrow['cid'], "$classm"); $space = 0; $chcount = 1; $subcat = ''; foreach($arr as $ele) { $chtitle=$myts->makeTboxData4Show($ele['title']); if ($chcount > $nbsouscat) { $subcat .= ", ..."; break; } if ($space > 0) { $subcat .= ", "; } $subcat .= "".$chtitle.""; $space++; $chcount++; $a_cat['subcat'] = $subcat; } } $bis = ($ncatp+1)/2; $bis = (int)$bis; $a_cat['i'] = $count; $xoopsTpl->append('categories', $a_cat); $count++; } $xoopsTpl->assign('cat_count', $count-1); list($ann) = $xoopsDB->fetchRow($xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("ann_annonces")." WHERE valid='Yes'")); list($catt) = $xoopsDB->fetchRow($xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("ann_categories")."")); $xoopsTpl->assign('total_annonces', _CLA_ACTUALY." $ann "._CLA_ANNONCES." "._CLA_INCAT." $catt "._CLA_CAT2); if ($moderated == '1') $xoopsTpl->assign('total_confirm', _CLA_AND." $propo "._CLA_WAIT3); if ($newann == 1) showNew(); copyright(); SupprClaDay(); } # function view (categories) ##################################################### function view($cid, $debut) { global $xoopsDB, $xoopsTpl, $xoopsConfig, $nb_affichage, $myts, $mytree, $imagecat, $classm, $meta; $GLOBALS['xoopsOption']['template_main'] = 'myads_category.html'; include(XOOPS_ROOT_PATH."/modules/myAds/class/nav.php"); $xoopsTpl->assign('add_from', _CLA_ADDFROM." ".$xoopsConfig['sitename']); $xoopsTpl->assign('add_annonce', ""._CLA_ADDANNONCE2.""); $count = 0; if (!$debut) $debut = 0; $x=0; $i=0; $requete = $xoopsDB->query("select cid, pid, title from ".$xoopsDB->prefix("ann_categories")." where cid=".$cid.""); list($ccid, $pid, $title) = $xoopsDB->fetchRow($requete); $title = $myts->makeTboxData4Show($title); $varid[$x]=$ccid; $varnom[$x]=$title; list($nbe) = $xoopsDB->fetchRow($xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("ann_annonces")." where valid='Yes' AND cid='$cid'")); $pagenav=new PageNav($nbe, $nb_affichage, $debut, "pa=view&cid=$cid&debut", ""); if($pid!=0) { $x=1; while($pid!=0) { $requete2 = $xoopsDB->query("select cid, pid, title from ".$xoopsDB->prefix("ann_categories")." where cid=".$pid.""); list($ccid, $pid, $title) = $xoopsDB->fetchRow($requete2); $title = $myts->makeTboxData4Show($title); $varid[$x]=$ccid; $varnom[$x]=$title; $x++; } $x=$x-1; } $subcats = ''; while($x!=-1) { $subcats .= " » ".$varnom[$x].""; $x=$x-1; } $xoopsTpl->assign('nav_main', ""._CLA_MAIN.""); $xoopsTpl->assign('nav_sub', $subcats); $xoopsTpl->assign('nav_subcount', $nbe); $subresult=$xoopsDB->query("select cid, title, img from ".$xoopsDB->prefix("ann_categories")." where pid=$cid ORDER BY $classm"); $numrows = $xoopsDB->getRowsNum($subresult); if ($numrows != 0) { $scount = 0; $xoopsTpl->assign('availability', _CLA_AVAILAB); while(list($ccid, $title, $img) = $xoopsDB->fetchRow($subresult)) { $a_cat = array(); $title = $myts->makeTboxData4Show($title); $numrows = getTotalItems($ccid, _YES); $a_cat['image'] = ""; $a_cat['link'] = "$title"; $a_cat['adcount'] = $numrows; $a_cat['i'] = $scount; $a_cat['new'] = categorynewgraphic($ccid); $scount++; if ($scount==4) $scount = 0; $xoopsTpl->append('subcategories', $a_cat); } if ($count == 0) $cols = 4-$scount; $xoopsTpl->assign('subcat_count', $scount - 1); } showViewAnnonces($debut, $cid, $nb_affichage, $nbe); if(!isset($debut)) $debut=0; //show render nav $xoopsTpl->assign('nav_page', $pagenav->renderNav()); copyright(); } # function viewannonces ##################################################### function viewannonces($lid) { global $xoopsDB, $xoopsConfig, $xoopsTpl, $xoopsUser, $monnaie, $claday, $ynprice, $myts, $meta; $GLOBALS['xoopsOption']['template_main'] = 'myads_item.html'; $result=$xoopsDB->query("SELECT lid, cid, title, type, description, tel, price, typeprix, date, email, submitter, usid, town, country, valid, photo, view FROM ".$xoopsDB->prefix("ann_annonces")." WHERE lid = '$lid'"); $recordexist = $xoopsDB->getRowsNum($result); $xoopsTpl->assign('add_from', _CLA_ADDFROM." ".$xoopsConfig['sitename']); $xoopsTpl->assign('ad_exists', $recordexist); if ($recordexist) { list($lid, $cid, $title, $type, $description, $tel, $price, $typeprix, $date, $email, $submitter, $usid, $town, $country, $valid, $photo, $view)=$xoopsDB->fetchRow($result); $xoopsDB->queryf("UPDATE ".$xoopsDB->prefix("ann_annonces")." SET view=view+1 WHERE lid = '$lid'"); $useroffset = ""; if($xoopsUser) { $timezone = $xoopsUser->timezone(); if(isset($timezone)) $useroffset = $xoopsUser->timezone(); else $useroffset = $xoopsConfig['default_TZ']; } $date = ($useroffset*3600) + $date; $date2 = $date + ($claday*86400); $date = formatTimestamp($date,"s"); $date2 = formatTimestamp($date2,"s"); $title = $myts->makeTboxData4Show($title); $type = $myts->makeTboxData4Show($type); $description = $myts->makeTboxData4Show($description); $tel = $myts->makeTboxData4Show($tel); $price = $myts->makeTboxData4Show($price); $typeprix = $myts->makeTboxData4Show($typeprix); $submitter = $myts->makeTboxData4Show($submitter); $town = $myts->makeTboxData4Show($town); $country = $myts->makeTboxData4Show($country); $imprD = "\""._CLA_PRINT."\" "; $envD = "\""._CLA_FRIENDSEND."\""; if ($usid > 0) $xoopsTpl->assign('submitter', _CLA_ANNFROM . " $submitter"); else $xoopsTpl->assign('submitter', _CLA_ANNFROM . " $submitter"); $xoopsTpl->assign('read', "$view " . _CLA_VIEW2); if ($xoopsUser) { $calusern = $xoopsUser->getVar("uid", "E"); if ($usid == $calusern) $xoopsTpl->assign('modify', "\""._CLA_MODIFANN."\" \""._CAL_SUPPRANN."\""); if ($xoopsUser->isAdmin()) $xoopsTpl->assign('admin', "\""._CLA_MODADMIN."\""); } $xoopsTpl->assign('type', $type); $xoopsTpl->assign('title', $title); $xoopsTpl->assign('description', $description); if ($ynprice == 1 && $price > 0) $xoopsTpl->assign('price', '' . _CLA_PRICE2 . " $price $monnaie - $typeprix"); $contact = '' . _CLA_CONTACT." "._CLA_BYMAIL2.""; if ($tel) $contact .= "
"._CLA_TEL." $tel"; if ($town) $contact .= "
"._CLA_TOWN." $town"; if ($country) $contact .= "
"._CLA_COUNTRY." $country"; $xoopsTpl->assign('contact', $contact); if ($photo) $xoopsTpl->assign('photo', ""); $xoopsTpl->assign('date', _CLA_DATE2." $date "._CLA_DISPO." $date2    $imprD $envD"); } else $xoopsTpl->assign('no_ad', _CLA_NOCLAS); $result8 = $xoopsDB->query("select title from ".$xoopsDB->prefix("ann_categories")." where cid=$cid"); list($ctitle) = $xoopsDB->fetchRow($result8); $xoopsTpl->assign('link_main', ""._CLA_MAIN.""); $xoopsTpl->assign('link_cat', ""._CLA_GORUB." $ctitle"); copyright(); } # function categorynewgraphic ##################################################### function categorynewgraphic($cat) { global $xoopsDB; $newresult = $xoopsDB->query("select date from ".$xoopsDB->prefix("ann_annonces")." where cid=$cat and valid = 'Yes' order by date desc limit 1"); list($timeann)= $xoopsDB->fetchRow($newresult); $count = 1; $startdate = (time()-(86400 * $count)); if ($startdate < $timeann) return ""; } if (!isset($pa)) $pa = ''; if (!isset($debut)) $debut = ''; switch($pa) { case "viewannonces": viewannonces($lid); break; case "view": view($cid, $debut); break; case "views": views($sid, $debut); break; default: index(); break; } include(XOOPS_ROOT_PATH."/footer.php"); ?>