/** * Affiche la liste des blogs ayant au moins un article, pour un groupe de ville, ou une ou plusieurs villes * * @author Christophe Beyer <*****@*****.**> * @since 2006/03/23 * @param string $kw Mot-cl� pour la recherche (option) * @param integer grville Id de groupe de ville * @param array ville Tableau avec les ID des villes */ public function _createContent(&$toReturn) { CopixHtmlHeader::addJSLink(CopixUrl::get() . 'js/iconito/module_fichesecoles.js'); $kw = $this->getParam('kw', null); $pGrVille = $this->getParam('grville', null); $pVille = $this->getParam('ville', null); // Tableau $tpl = new CopixTpl(); if ($pVille) { $villes = AnnuaireService::getVilles($pVille); } else { $villes = AnnuaireService::getVillesInGrville($pGrVille); } //print_r($villes); $tpl->assign('villes', $villes); $ecoles = array(); foreach ($villes as $ville) { //$ecoles $ec = AnnuaireService::getEcolesInVille($ville['id'], array('directeur' => false)); foreach ($ec as $k => $e) { $blog = getNodeBlog('BU_ECOLE', $e['id']); //print_r($blog); if ($blog && $blog->is_public == 1) { $ec[$k]['blog']['url_blog'] = $blog->url_blog; } } $ecoles[$ville['id']] = $ec; } //print_r($ecoles); $tpl->assign('ecoles', $ecoles); if ($kw) { $critere = " SELECT * FROM module_blog WHERE is_public=1 AND name_blog LIKE '%" . addslashes($kw) . "%' ORDER BY name_blog"; } else { $critere = " SELECT * FROM module_blog WHERE is_public=1 AND 1 ORDER BY name_blog"; } $sql = _doQuery($critere); $list = array(); $arTypes = array(); if (CopixConfig::exists('public|blogs.types') && CopixConfig::get('public|blogs.types')) { $arTypes = explode(",", CopixConfig::get('public|blogs.types')); } $arTypes[] = 'CLUB'; //print_r($sql); foreach ($sql as $blog) { $parent = Kernel::getModParentInfo("MOD_BLOG", $blog->id_blog); if ($parent) { if ($arTypes && !in_array($parent['type'], $arTypes)) { continue; } //var_dump($parent); $blog->parent = $parent['nom']; switch ($parent['type']) { case 'CLUB': if (Kernel::getKernelLimits('ville')) { $ville = GroupeService::getGroupeVille($parent['id']); if (!in_array($ville, Kernel::getKernelLimits('ville_as_array'))) { continue; } } $blog->type = CopixI18N::get('public.blog.typeClub'); break; /* case 'BU_CLASSE' : $blog->type = CopixI18N::get ('public.blog.typeClasse'); $blog->parent .= ' - '.$parent['ALL']->eco_nom; if ($parent['ALL']->eco_type) $blog->parent .= ' - '.$parent['ALL']->eco_type.''; break; */ //case 'BU_ECOLE' : $blog->type = CopixI18N::get ('public.blog.typeEcole'); break; //case 'BU_VILLE' : $blog->type = CopixI18N::get ('public.blog.typeVille'); break; //case 'BU_GRVILLE' : $blog->type = CopixI18N::get ('public.blog.typeGrville'); break; //default : $blog->type = $parent['type']; break; } if (!isset($blog->type)) { continue; } $blog->stats = KernelBlog::getStats($blog->id_blog); //print_r($blog); /* Activer pour cacher les blogs non lisibles */ // if( !blogauth::canMakeInBlog('READ', $blog) ) continue; if ($blog->stats['nbArticles']['value'] > 0) { $list[] = $blog; } } } usort($list, "order_tab_blogs"); $tpl->assign('list', $list); if (!CopixConfig::exists('|can_public_rssfeed') || CopixConfig::get('|can_public_rssfeed')) { $tpl->assign('can_public_rssfeed', 1); } else { $tpl->assign('can_public_rssfeed', 0); } $toReturn = $tpl->fetch('getlistblogszone2.tpl'); return true; }
/** * Récupère la liste des derniers articles publiés dans des blogs publics. A utiliser pour des flux RSS ou des zones de la Une * * @author Christophe Beyer <*****@*****.**> * @since 2012/02/21 * @param array $options * [nb] Nombre d'éléments à afficher * [categories] Pour ajouter les catégories de chaque article * [parent] Pour récupérer les infos sur le parent du blog * [blogId] Pour limiter à un blog précis * [future] Pour afficher ou non les articles post-datés (true par défaut) * */ public function findPublic($options = array()) { $limit = isset($options['nb']) && $options['nb'] ? $options['nb'] : 10; $arTypes = array(); if (CopixConfig::exists('public|blogs.types') && CopixConfig::get('public|blogs.types')) { $arTypes = explode(",", CopixConfig::get('public|blogs.types')); } $arTypes[] = 'CLUB'; $params = array(); $critere = 'SELECT ART.id_bact, ART.name_bact, ART.url_bact, ART.date_bact, ART.time_bact, ART.sumary_bact, ART.sumary_html_bact, BLOG.url_blog, KME.node_type AS parent_type, KME.node_id AS parent_id FROM module_blog BLOG, module_blog_article ART, kernel_mod_enabled KME WHERE ART.id_blog=BLOG.id_blog AND KME.module_id=BLOG.id_blog AND KME.module_type=\'MOD_BLOG\' AND BLOG.is_public=1 AND ART.is_online=1'; $blogId = isset($options['blogId']) && $options['blogId'] ? (int) $options['blogId'] : 0; $future = isset($options['future']) ? $options['future'] : true; if ($blogId) { $critere .= ' AND ART.id_blog = :blogId'; $params['blogId'] = $blogId; } else { $critere .= ' AND KME.node_type IN (\'' . implode('\',\'', $arTypes) . '\')'; } if (!$future) { $critere .= ' AND (ART.date_bact < :today1 OR (ART.date_bact = :today2 AND ART.time_bact <= :now))'; $params['today1'] = $params['today2'] = date('Ymd'); $params['now'] = date('Hi'); } $critere .= ' ORDER BY ART.date_bact DESC, ART.time_bact DESC, ART.id_bact ASC'; if (!$blogId && Kernel::getKernelLimits('ville')) { $critere .= ' LIMIT ' . $limit * 10; } else { $critere .= ' LIMIT ' . $limit; } $list = _doQuery($critere, $params); $arArticle = array(); foreach ($list as $article) { $add = true; if (!$blogId) { switch ($article->parent_type) { case 'CLUB': if (Kernel::getKernelLimits('ville')) { $ville = GroupeService::getGroupeVille($article->parent_id); if (!in_array($ville, Kernel::getKernelLimits('ville_as_array'))) { $add = false; } } break; } } if (isset($options['categories']) && $options['categories']) { $sp = _daoSp(); $sp->addCondition('id_bact', '=', $article->id_bact); $article->categories = array(); foreach (_ioDAO('blog|blogarticle_blogarticlecategory')->findBy($sp) as $object) { $article->categories[] = _ioDAO('blog|blogarticlecategory')->get($object->id_bacg); } } $date = array(); $date['Y'] = substr($article->date_bact, 0, 4); $date['m'] = substr($article->date_bact, 4, 2); $date['d'] = substr($article->date_bact, 6, 2); $date['H'] = substr($article->time_bact, 0, 2); $date['i'] = substr($article->time_bact, 2, 2); $article->dateRFC822 = gmdate('D, d M Y H:i:s', mktime($date['H'], $date['i'], 0, $date['m'], $date['d'], $date['Y'])) . ' GMT'; if ($add) { if (!isset($options['parent']) || $options['parent']) { $article->parent = Kernel::getNodeInfo($article->parent_type, $article->parent_id); } $arArticle[] = $article; } } if (!$blogId && Kernel::getKernelLimits('ville')) { $arArticle = array_slice($arArticle, 0, $limit); } return $arArticle; }
/** * Liste de groupes * * @author Christophe Beyer <*****@*****.**> * @since 2005/11/08 * @param integer $forum Id du forum * @return array Tableau avec les groupes */ public function getListPublic($offset, $count, $kw = null) { $criteres = _daoSp(); $criteres->addCondition('is_open', '=', 1); if (CopixConfig::exists('kernel|groupeAssistance') && ($groupeAssistance = CopixConfig::get('kernel|groupeAssistance'))) { $criteres->addCondition('id', '!=', $groupeAssistance); } // D�coupage du pattern if ($kw) { $testpattern = str_replace(array(" ", "%20"), "%20", $kw); $temp = split("%20", $testpattern); $criteres->startGroup(); foreach ($temp as $word) { if ($word != "") { $criteres->addCondition('titre', 'LIKE', "%{$word}%", 'or'); $criteres->addCondition('description', 'LIKE', "%{$word}%", 'or'); } } $criteres->endGroup(); } if ($offset) { $criteres->setOffset($offset); } if ($count) { $criteres->setCount($count); } $criteres->orderBy(array('date_creation', 'desc')); $list = _ioDao('groupe|groupe')->findBy($criteres); //search tags by Id or Name $listTag = new CopixDAORecordIterator(_doQuery('SELECT g.id AS id, g.titre AS titre, g.description AS description, g.is_open AS is_open, g.createur AS createur, g.date_creation AS date_creation FROM module_groupe_groupe AS g JOIN module_tags_groups AS tg ON tg.id_group = g.id JOIN module_tags AS t ON tg.id_tag = t.id WHERE g.is_open=1 AND t.name LIKE "%' . $kw . '%" OR t.id = ' . (int) $kw), $this->getDAOId()); //merge records $listGroupFinal = array(); foreach ($list as $l) { $listGroupFinal[] = $l; } foreach ($listTag as $l) { $listGroupFinal[] = $l; } $list = $listGroupFinal; $arGroupes = array(); $groupListId = array(); foreach ($list as $groupe) { if (in_array($groupe->id, $groupListId)) { continue; } $groupListId[] = $groupe->id; $parent = Kernel::getNodeParents("CLUB", $groupe->id); $ok = true; if (Kernel::getKernelLimits('ville')) { if ($parent) { $ville = GroupeService::getGroupeVille($groupe->id, $parent); if (!in_array($ville, Kernel::getKernelLimits('ville_as_array'))) { $ok = false; } } else { $ok = false; } } if ($ok) { $groupe->parent = $parent; $arGroupes[] = $groupe; } } $results = $arGroupes; return $results; }