/** * Validation d'une page. */ public function doValidPage() { $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_PAGES', create_blog_object($id_blog))) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManagePage'), 'back' => CopixUrl::get('blog|admin|listBlog'))); } $tpl = new CopixTpl(); $showErrors = false; $pageDAO = CopixDAOFactory::create('blog|blogpage'); $id_bpge = $this->getRequest('id_bpge', null); if (strlen($id_bpge) == 0) { $id_bpge = null; } // On r�cup�re l'utilisateur connect� $user = BlogAuth::getUserInfos(); if ($id_bpge != null) { // EDITION D'UNE PAGE $page = $pageDAO->get($id_bpge); $this->_validFromPostProperties($page); $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.edit.page.title')); $errors = _dao('blog|blogpage')->check($page); if ($errors != 1) { // Traitement des erreurs $showErrors = true; } elseif ($go == 'save') { // Modification dans la base $page->content_html_bpge = smarty_modifier_blog_format_article($page->content_bpge, $page->format_bpge); $pageDAO->update($page); return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0')))); } } else { // CREATION D'UNE PAGE $page = CopixDAOFactory::createRecord('blogpage'); $this->_validFromPostProperties($page); $page->order_bpge = $pageDAO->getNewPos($id_blog); $page->date_bpge = date('Ymd'); $page->author_bpge = $user->userId; $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.create.page.title')); $errors = _dao('blog|blogpage')->check($page); if ($errors != 1) { // Traitement des erreurs $showErrors = true; } elseif ($go == 'save') { // Insertion dans la base $page->content_html_bpge = smarty_modifier_blog_format_article($page->content_bpge, $page->format_bpge); $pageDAO->insert($page); $page->url_bpge = killBadUrlChars($page->id_bpge . '-' . $page->name_bpge); $pageDAO->update($page); //on vide la session //$this->_setSessionPage(null); return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0')))); } } $tpl->assign('MAIN', CopixZone::process('EditPage', array('id_blog' => $id_blog, 'id_bpge' => $id_bpge, 'page' => $page, 'errors' => $errors, 'showErrors' => $showErrors, 'kind' => $this->getRequest('kind', '0'), 'preview' => $go == 'preview' ? 1 : 0))); return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl); }
/** * Validation d'une cat�gorie. */ public function doValidCategory() { $id_blog = $this->getRequest('id_blog', null); 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_CATEGORIES', 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(); $categoryDAO = CopixDAOFactory::create('blog|blogarticlecategory'); $id_bacg = $this->getRequest('id_bacg', null); if (strlen($id_bacg) == 0) { $id_bacg = null; } if ($id_bacg != null) { // EDITION D'UNE CATEGORIE $category = $categoryDAO->get($id_bacg); $category->id_blog = $id_blog; $category->name_bacg = $this->getRequest('name_bacg'); $category->url_bacg = $this->getRequest('url_bacg'); if (strlen($category->url_bacg) == 0) { $category->url_bacg = killBadUrlChars($category->name_bacg); } $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.edit.category.title')); $errors = _dao('blog|blogarticlecategory')->check($category); if ($errors != 1) { // Traitement des erreurs $showErrors = true; } else { // Modification dans la base $categoryDAO->update($category); return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0')))); } } else { // CREATION D'UNE CATEGORIE $category = CopixDAOFactory::createRecord('blogarticlecategory'); $category->id_blog = $id_blog; $category->name_bacg = $this->getRequest('name_bacg'); $category->order_bacg = $categoryDAO->getNewPos($id_blog); $category->url_bacg = killBadUrlChars($category->name_bacg); if (strlen($category->url_bacg) == 0) { $category->url_bacg = killBadUrlChars($category->name_bacg); } $tpl->assign('TITLE_PAGE', CopixI18N::get('blog.get.create.category.title')); $errors = _dao('blog|blogarticlecategory')->check($category); if ($errors != 1) { // Traitement des erreurs $showErrors = true; } else { // Insertion dans la base $categoryDAO->insert($category); $category->url_bacg = killBadUrlChars($category->id_bacg . '-' . $category->name_bacg); $categoryDAO->update($category); return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $this->getRequest('kind', '0')))); } } $tpl->assign('MAIN', CopixZone::process('EditCategory', array('id_blog' => $id_blog, 'id_bacg' => $id_bacg, 'category' => $category, 'errors' => $errors, 'showErrors' => $showErrors, 'kind' => $this->getRequest('kind', '0')))); return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl); }
/** * Détermine l' "url_blog" unique d'un blog, à partir de son titre * * A partir du titre d'un blog, en déduit son "url_blog". Regarde dans la BDD si un blog de même titre n'existe pas déjà pour rendre cette valeur unique (au besoin, ajoute un numéro à la fin pour le rendre unique). Ne doit être appellé qu'à la création d'un blog. * * @author Christophe Beyer <*****@*****.**> * @since 2006/10/23 * @param integer $id Id du blog * @param string $titre Titre du blog * @return string url_blog à stocker dans la BDD. Chaine vide si problème */ public function calcule_url_blog($id, $titre) { if (strlen($titre) > 97) { $titre = substr($titre, 0, 97); } //print_r("titre=$titre<br>"); $titre = killBadUrlChars($titre); $exists = true; $fusible = 1; while ($exists && $fusible < 1000) { $id_nom = $titre . ($fusible > 1 ? $fusible : ""); $sql = "SELECT id_blog FROM module_blog WHERE url_blog='" . addslashes($id_nom) . "'"; if ($id) { $sql .= " AND id_blog!={$id}"; } //print_r ("sql=$sql<br>"); $p = _doQuery($sql); $exists = $p ? true : false; $fusible++; } if (!$exists) { $res = $id_nom; } else { $res = ''; } return $res; }
/** * apply updates to the edited object */ public function _validFromPostProperties(&$toUpdate) { $arMaj = array('id_blog', 'name_bact', 'sumary_bact', 'content_bact', 'date_bact', 'time_bact', 'author_bact', 'url_bact', 'format_bact'); foreach ($arMaj as $var) { if ($var == 'date_bact') { $toUpdate->{$var} = Kernel::_validDateProperties(_request($var)); } else { $toUpdate->{$var} = _request($var); } } if (strlen($toUpdate->url_bact) == 0 && strlen($toUpdate->name_bact) > 0) { $toUpdate->url_bact = killBadUrlChars($toUpdate->name_bact); } if (_request('sticky_bact')) { $toUpdate->sticky_bact = _request('sticky_bact'); } else { $toUpdate->sticky_bact = 0; } if (_request('is_online')) { $toUpdate->is_online = _request('is_online'); } else { $toUpdate->is_online = 0; } }