public function _createContent(&$toReturn) { $tpl = new CopixTpl(); $blog = $this->getParam('blog', ''); $comment = $this->getParam('comment', NULL); //on récupère l'ensemble des articles du blog $dao = _dao('blog|blogarticle'); //$article = $dao->getArticleByUrl($blog->id_blog, $this->getParam('article', '')); list($id_bact, ) = explode("-", $this->getParam('article', '')); $article = $dao->getArticleById($blog->id_blog, $id_bact); if (!$article) { $toReturn = '{/}' . $tpl->fetch('showarticle.tpl'); return true; } //encodage des URL des catégories pour caractères spéciaux if (is_array($article->categories)) { foreach ($article->categories as $key => $categorie) { $article->categories[$key]->url_bacg = urlencode($categorie->url_bacg); } } $tpl->assign('article', $article); // Recherche de tous les commentaires associés à cet article $commentDAO = _dao('blog|blogarticlecomment'); $res = $commentDAO->findCommentOrderBy($article->id_bact, 1); $listComment = array(); foreach ($res as $r) { $r->time_bacc = BDToTime($r->time_bacc); array_push($listComment, $r); } if ($comment) { $toEdit = $comment; } else { // On récupère l'utilisateur connecté $user = BlogAuth::getUserInfos(); $toEdit = _record('blogarticlecomment'); $toEdit->authorid_bacc = $user->userId; $toEdit->authorname_bacc = $user->name; $toEdit->authoremail_bacc = $user->email; $toEdit->authorweb_bacc = $user->web; } $tpl->assign('blog', $blog); $tpl->assign('toEdit', $toEdit); $tpl->assign('listComment', $listComment); $tpl->assign('errors', $this->getParam('errors', null)); $tpl->assign('showErrors', $this->getParam('showErrors', false)); $tpl->assign('canComment', BlogAuth::canComment($blog->id_blog)); $plugStats = CopixPluginRegistry::get("stats|stats"); $plugStats->setParams(array('objet_a' => $article->id_bact)); // retour de la fonction : $toReturn = $article->name_bact . '{/}' . $tpl->fetch('showarticle.tpl'); return true; }
/** * Validation d'un commentaire. */ public function doValidComment() { if (Kernel::isSpam()) { return new CopixActionReturn(CopixActionReturn::HTTPCODE, CopixHTTPHeader::get404(), "Page introuvable"); } $url_bact = _request('url_bact'); //On verifit que le blog existe (on r�cup�re le blog avec son nom) $dao = CopixDAOFactory::create('blog|blog'); if (!($blog = $dao->getBlogByName(_request('blog')))) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.unableToFindBlog'), 'back' => CopixUrl::get(''))); } // On v�rifie que le droit de lecture est pr�sent if (!BlogAuth::canMakeInBlog('READ', $blog)) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get(''))); } if (!$blog->has_comments_activated) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.add.comment.closed'), 'back' => CopixUrl::get('', array('blog' => _request('blog'))))); } $id_bact = $this->getRequest('id_bact', null); if (!BlogAuth::canComment($blog->id_blog)) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManageComment'), 'back' => CopixUrl::get('', array('blog' => _request('blog'))))); } $tpl = new CopixTpl(); $commentDAO = CopixDAOFactory::create('blog|blogarticlecomment'); $comment = CopixDAOFactory::createRecord('blog|blogarticlecomment'); $this->_validFromPostProperties($comment); $comment->date_bacc = date('Ymd'); $comment->time_bacc = date('Hi'); $comment->is_online = $blog->type_moderation_comments != 'POST' ? 0 : 1; $comment->authorip_bacc = $_SERVER["REMOTE_ADDR"]; CopixHTMLHeader::addCSSLink(CopixUrl::get('blog||getBlogCss', array('id_blog' => $blog->id_blog))); $tpl->assign('blog', $blog); $errors = $commentDAO->check($comment); //print_r($comment); $showErrors = false; if ($errors != 1) { // Traitement des erreurs $showErrors = true; } else { // Insertion dans la base $commentDAO->insert($comment); } $zoneArticle = CopixZone::process('ShowArticle', array('blog' => $blog, 'article' => $this->getRequest('article', ''), 'errors' => $errors, 'showErrors' => $showErrors, 'comment' => $comment)); list($title, $article) = explode("{/}", $zoneArticle); $tpl->assign('TITLE_PAGE', $title . ' - ' . $blog->name_blog); $tpl->assign('Article', $article); $tpl->assign('ListLink', CopixZone::process('ListLink', array('blog' => $blog))); $tpl->assign('ListCategory', CopixZone::process('ListCategory', array('blog' => $blog))); $tpl->assign('ListArchive', CopixZone::process('ListArchive', array('blog' => $blog))); $tpl->assign('ListPage', CopixZone::process('ListPage', array('blog' => $blog))); $tpl->assign('ListSearch', CopixZone::process('ListSearch', array('blog' => $blog))); if (!$showErrors) { if ($comment->is_online == 1) { return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog||showArticle', array('blog' => urlencode($blog->url_blog), 'article' => _request('article'))) . '#comments'); } else { return CopixActionGroup::process('genericTools|Messages::getInformation', array('message' => CopixI18N::get('blog.comments.offline.info'), 'continue' => CopixUrl::get('blog|default|showArticle', array('blog' => $blog->url_blog, 'article' => $url_bact)))); } } // $menu = array(); $parent = Kernel::getModParentInfo("MOD_BLOG", $blog->id_blog); //print_r($parent); $blog->parent = $parent; /* if ($parent['type']=='CLUB') { $droit = Kernel::getLevel($parent['type'], $parent['id']); //print_r($droit); if (GroupeService::canMakeInGroupe('VIEW_HOME', $droit)) $menu[] = array('url'=>CopixUrl::get ('groupe||getHome', array("id"=>$parent['id'])), 'txt'=>CopixI18N::get ('blog.menuToGroup')); } if (BlogAuth::canMakeInBlog('ACCESS_ADMIN',$blog)) $menu[] = array('url'=>CopixUrl::get ('admin|showBlog', array("id_blog"=>$blog->id_blog)), 'txt'=>CopixI18N::get ('blog.menuAdmin')); */ //print_r($menu); $menu = array(); if (BlogAuth::canMakeInBlog('ACCESS_ADMIN', $blog)) { $menu = getBlogAdminMenu($blog); } $tpl->assign('MENU', $menu); CopixHtmlHeader::addOthers('<link rel="alternate" href="' . CopixUrl::get('blog||rss', array("blog" => $blog->url_blog)) . '" type="application/rss+xml" title="' . htmlentities($blog->name_blog) . '" />'); if ($blog->template) { $MAIN = $tpl->fetch($blog->template); } else { $MAIN = $tpl->fetch('blog_main.tpl'); } $tpl->assign('MAIN', $MAIN); $tpl->assign('HEADER_MODE', 'compact'); return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl); }