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'une cat�gorie. */ public function doValidModifyComment() { $id_blog = $this->getRequest('id_blog', null); if (strlen($id_blog) == 0) { $id_blog = null; } $id_bact = $this->getRequest('id_bact', null); if (strlen($id_bact) == 0) { $id_bact = null; } $id_bacc = $this->getRequest('id_bacc', null); if (strlen($id_bacc) == 0) { $id_bacc = null; } if ($id_blog == null || $id_bact == null || $id_bacc == null) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.param'), 'back' => CopixUrl::get('blog|admin|listBlog'))); } if (!BlogAuth::canMakeInBlog('ADMIN_COMMENTS', create_blog_object($id_blog))) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManageComment'), 'back' => CopixUrl::get('blog|admin|listBlog'))); } $tpl = new CopixTpl(); $commentDAO = CopixDAOFactory::create('blog|blogarticlecomment'); // EDITION D'UNE CATEGORIE $comment = $commentDAO->get($id_bacc); $this->_validFromPostProperties($comment); $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.edit.comment.title')); $errors = _dao('blog|blogarticlecomment')->check($comment); if ($errors != 1) { // Traitement des erreurs $showErrors = true; } else { // Modification dans la base $commentDAO->update($comment); return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|listComment', array("id_blog" => $id_blog, "id_bact" => $id_bact))); } $articleDAO = CopixDAOFactory::create('blog|blogarticle'); $article = $articleDAO->get($id_bact); $comment->name_bact = $article->name_bact; $comment->time_bacc = BDToTime($comment->time_bacc); $tpl->assign('MAIN', CopixZone::process('EditComment', array('id_blog' => $id_blog, 'id_bact' => $id_bact, 'id_bacc' => $id_bacc, 'comment' => $comment, 'errors' => $errors, 'showErrors' => $showErrors))); return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl); }
/** * Validation d'un article. */ public function doValidArticle() { CopixHTMLHeader::addJSLink(_resource("js/jquery/jquery.ui.datepicker-fr.js")); $id_blog = $this->getRequest('id_blog', null); $go = $this->getRequest('go', 'preview'); //die ("go=$go"); if ($id_blog == null) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.param'), 'back' => CopixUrl::get('blog|admin|listBlog'))); } if (!BlogAuth::canMakeInBlog('ADMIN_ARTICLES', create_blog_object($id_blog))) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManageCategory'), 'back' => CopixUrl::get('blog|admin|listBlog'))); } $tpl = new CopixTpl(); // On r�cup�re l'utilisateur connect� $user = BlogAuth::getUserInfos(); $articleDAO = CopixDAOFactory::create('blog|blogarticle'); // Cat�gories coch�es... $tabSelectCat = array(); if (_request('tabSelectCat')) { $tabSelectCat = (array) _request('tabSelectCat'); } $id_bact = $this->getRequest('id_bact', null); if (strlen($id_bact) == 0) { $id_bact = null; } $showErrors = false; if ($id_bact != null) { // EDITION D'UN ARTICLE $article = $articleDAO->get($id_bact); $this->_validFromPostProperties($article); if (!$article->date_bact) { $article->date_bact = date('d/m/Y'); } if (!$article->time_bact) { $article->time_bact = date('H:i'); } $article->date_bact = CopixDateTime::dateToTimestamp($article->date_bact); $article->time_bact = timeToBD($article->time_bact); $article->author_bact = $user->userId; $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.edit.article.title')); //print_r($article); $errors = $articleDAO->check($article); if (count($tabSelectCat) == 0) { $errors = array(); array_push($errors, CopixI18N::get('blog.error.nocategoryselect')); } if ($errors != 1) { // Traitement des erreurs $showErrors = true; } elseif ($go == 'save') { // Modification dans la base $article->url_bact = killBadUrlChars($article->id_bact . '-' . $article->name_bact); $article->sumary_html_bact = smarty_modifier_blog_format_article($article->sumary_bact, $article->format_bact); $article->content_html_bact = smarty_modifier_blog_format_article($article->content_bact, $article->format_bact); $articleDAO->update($article); // Insertion dans la base blogarticle_blogarticlecategory $artctgDAO = CopixDAOFactory::create('blog|blogarticle_blogarticlecategory'); $artctgDAO->deleteAndInsert($article->id_bact, $tabSelectCat); return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0')))); } } else { // CREATION D'UN ARTICLE $article = CopixDAOFactory::createRecord('blogarticle'); $this->_validFromPostProperties($article); if (!$article->date_bact) { $article->date_bact = date('d/m/Y'); } if (!$article->time_bact) { $article->time_bact = date('H:i'); } $article->date_bact = CopixDateTime::dateToTimestamp($article->date_bact); $article->time_bact = timeToBD($article->time_bact); $article->author_bact = $user->userId; $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.create.article.title')); $errors = $articleDAO->check($article); if (count($tabSelectCat) == 0) { $errors = array(); array_push($errors, CopixI18N::get('blog.error.nocategoryselect')); } if ($errors != 1) { // Traitement des erreurs $showErrors = true; } elseif ($go == 'save') { // Insertion dans la base $article->sumary_html_bact = smarty_modifier_blog_format_article($article->sumary_bact, $article->format_bact); $article->content_html_bact = smarty_modifier_blog_format_article($article->content_bact, $article->format_bact); $articleDAO->insert($article); $article->url_bact = killBadUrlChars($article->id_bact . '-' . $article->name_bact); $articleDAO->update($article); // Insertion dans la base blogarticle_blogarticlecategory $artctgDAO = CopixDAOFactory::create('blog|blogarticle_blogarticlecategory'); $artctgDAO->deleteAndInsert($article->id_bact, $tabSelectCat); return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0')))); } } // Pr�paration du filtre CATEGORIES $blogArticleCategoryDAO = CopixDAOFactory::create('blog|blogarticlecategory'); $resArticleCategory = $blogArticleCategoryDAO->findAllOrder($id_blog); $tabArticleCategory = array(); foreach ($resArticleCategory as $cat) { if (in_array($cat->id_bacg, $tabSelectCat)) { $cat->selected = true; } else { $cat->selected = false; } array_push($tabArticleCategory, $cat); } $article->time_bact = BDToTime($article->time_bact); $tpl->assign('BODY_ON_LOAD', "setDatePicker('#date_bact')"); $tpl->assign('MAIN', CopixZone::process('EditArticle', array('id_blog' => $id_blog, 'id_bact' => $id_bact, 'article' => $article, 'kind' => $this->getRequest('kind', '0'), 'errors' => $errors, 'showErrors' => $showErrors, 'tabArticleCategory' => $tabArticleCategory, 'preview' => $go == 'preview' ? 1 : 0))); return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl); }