dirname()."/include/functions.php"); include_once(XOOPS_ROOT_PATH."/modules/".$xoopsModule->dirname()."/class/cat.php"); include_once(XOOPS_ROOT_PATH."/modules/".$xoopsModule->dirname()."/class/ads.php"); include_once(XOOPS_ROOT_PATH."/class/xoopstree.php"); $xoopsOption['template_main'] = 'annunci_index.html'; include(XOOPS_ROOT_PATH."/header.php"); $ads_handler =& xoops_getmodulehandler('ads'); $ts =& MyTextSanitizer::getInstance(); // array des sous-cat�gories 'enfant' d'une cat�gorie function getFirstChild($cat_id = 0) { global $allcat; $firstChild = array(); foreach($allcat as $onechild) { if( $onechild['pid'] == $cat_id) { array_push($firstChild, $onechild); } } return $firstChild; } function showsubcat($categorys, $level = 0, $cat_id = 0, $pid) { global $xoopsModule, $ts, $lastchildren, $nbadspercat, $newads, $arr_subcat, $cptsubcat, $nbcol, $tpltype; foreach($categorys as $onecat) { $link = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/adslist.php?cat_id=' . $onecat['cat_id']; $title = $ts->htmlSpecialChars($onecat['title']); if (in_array($onecat['cat_id'], $lastchildren)) { $arr_scat['nb'] = (array_key_exists($onecat['cat_id'], $nbadspercat)) ? "(".$nbadspercat[$onecat['cat_id']].")": ''; $arr_scat['new'] = (array_key_exists($onecat['cat_id'], $newads)) ? $newads[$onecat['cat_id']]: ''; } $arr_scat['link'] = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/adslist.php?cat_id=' . $onecat['cat_id']; $arr_scat['title'] = $title; $arr_scat['img'] = ""; if ($level == 0 && $tpltype == 1) { $arr_scat['newcol'] = ($cptsubcat > 0) ? true : false; $cptsubcat++; $arr_scat['newline'] = ($cptsubcat % $nbcol == 1) ? true : false; } array_push($arr_subcat, $arr_scat); $childcats = getFirstChild($onecat['cat_id']); if (count($childcats) > 0) { showsubcat($childcats, $level + 1, $onecat['cat_id'], $pid); } } return; } // annonces en attente de validation if ($xoopsModuleConfig['moderated'] == '1') { $ads_wait = $ads_handler->getCount(new Criteria('waiting', '1')); $xoopsTpl->assign('moderated', true); // si administrateur du module if ($xoopsUser && $xoopsUser->isAdmin($xoopsModule->getVar('mid'))) { $xoopsTpl->assign('admin_block', _MD_ANNUNCI_ADM_WAIT); if($ads_wait == 0) { $xoopsTpl->assign('confirm_ads', _MD_ANNUNCI_NO_WAIT); } else { $xoopsTpl->assign('confirm_ads', sprintf(_MD_ANNUNCI_NBWAIT, $ads_wait)."
"._MD_ANNUNCI_SEEWAIT.""); } } } $tpltype = $xoopsModuleConfig['tpltype'];// 1 en lignes, 2 en colonnes $xoopsTpl->assign('tpltype', $tpltype); $nbcol = $xoopsModuleConfig['nbcol']; $wcol = 100/$nbcol; $xoopsTpl->assign('wcol', $wcol); // nombre annonces actives par cat�gorie $criteria = new CriteriaCompo(new Criteria('waiting', '0')); $criteria->add(new Criteria('published', time(), '<')); $criteria->add(new Criteria('expired', time(),'>')); $nbadspercat = $ads_handler->getCountAdsByCat($criteria); // nombre annonces nouvelles par cat�gorie $criteria = new CriteriaCompo(new Criteria('published', time()- $xoopsModuleConfig['nb_days_new']*86400, '>')); $criteria->add(new Criteria('waiting', '0')); $criteria->add(new Criteria('expired', time(),'>')); $criteria->add(new Criteria('published', time(),'<')); $newads = $ads_handler->getCountAdsByCat($criteria); $allcat = AdsCategory::getAllCat(); // array de toutes les cat�gories $lastchildren = AdsCategory::getAllLastChild(); //array des cat�gories 'terminales''' $parray = AdsCategory::getCatWithPid(); //array des objets cat�gories principales $pcount = count($parray); $ptitle = ''; // cat�gories principales for ( $i = 0; $i < $pcount; $i++ ) { $arr_cat = array(); $arr_scat = array(); $arr_subcat = array(); $cptsubcat = 0; $cat_id = $parray[$i]->cat_id(); $title = $ts->htmlSpecialChars($parray[$i]->title()); $ptitle .= $title.' -'; $arr_cat[$i]['image'] = ""; $arr_cat[$i]['link'] = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/adslist.php?cat_id=' . $cat_id; $arr_cat[$i]['title'] = $title; if (in_array($cat_id, $lastchildren)) { $arr_cat[$i]['nb'] = (array_key_exists($cat_id, $nbadspercat)) ? "(".$nbadspercat[$cat_id].")": ''; $arr_cat[$i]['new'] = (array_key_exists($cat_id, $newads)) ? $newads[$cat_id]: ''; } $level = 0; $childcats = AdsCategory::getFirstChildArr($cat_id, 'weight'); unset($arr_scat); showsubcat($childcats, 0, $cat_id, $cat_id); if ($tpltype == 1) { // ajout blocks vides si template en lignes $mod = count($childcats) % $nbcol; $adjust = ($mod > 0) ? $nbcol - $mod : 0; for ( $j = 0; $j < $adjust; $j++ ) { $cptsubcat++; $arr_scat['newcol']=1; array_push($arr_subcat, $arr_scat); } } else { // calcul saut de ligne si template en colonnes $mod = ($i+1) % $nbcol; $arr_cat[$i]['newline'] = ($mod == 0) ? true : false; } $arr_cat[$i]['subcat'] = $arr_subcat; $xoopsTpl->append('categories', $arr_cat[$i]); } if ($tpltype == 2) { // ajout blocks vides si template en colonnes unset($arr_cat); $mod = $pcount % $nbcol; $adjust = ($mod > 0) ? $nbcol - $mod : 0; for ( $j = 0; $j < $adjust; $j++ ) { $arr_cat[$j]['title'] = ""; $xoopsTpl->append('categories', $arr_cat[$j]); } } $xoopsTpl->assign('xoops_pagetitle', $xoopsModule->name() . ' -' . $ptitle); // nombre annonces actives $criteria = new CriteriaCompo(new Criteria('waiting', '0')); $criteria->add(new Criteria('published', time(),'<')); $criteria->add(new Criteria('expired', time(),'>')); $nbads = $ads_handler->getCount($criteria); $xoopsTpl->assign('total_annonces',sprintf( _MD_ANNUNCI_ACTUALY, $nbads)); if ($xoopsModuleConfig['moderated'] == '1') { $xoopsTpl->assign('total_confirm', sprintf(_MD_ANNUNCI_ANDWAIT, $ads_wait)); } // derni�res annonces #questo blocco serve per visualizzare in home-annunci gli ultimi annunci inseriti /*if ($xoopsModuleConfig['nb_news'] > 0 ) { $xoopsTpl->assign('nbads', $nbads); if ($nbads > 0) { $xoopsTpl->assign('lang_title', _MD_ANNUNCI_LASTADD); $arr_lastads = showListAds(0, 0, 0, $xoopsModuleConfig['nb_news']); $xoopsTpl->assign('items', $arr_lastads); } }*/ // annunci_copyright(); include(XOOPS_ROOT_PATH."/footer.php"); ?>