Skip to content
Snippets Groups Projects

Hotline#13302 Rename Rss Cat

Merged Laurent requested to merge hotline#13302_rename_rss_cat into hotline_6.45
Compare and
+ 242
181
Preferences
Compare changes
Files
@@ -71,106 +71,48 @@ class Admin_RssController extends Zend_Controller_Action {
}
function cataddAction()
{
$this->view->titre = "Ajouter une catégorie de flux RSS";
$class_rss = new Class_Rss();
function cataddAction() {
$this->view->titre = $this->_("Ajouter une catégorie de flux RSS");
$rss_categorie = new Class_RssCategorie();
if ($parent_categorie = Class_RssCategorie::find((int)$this->_getParam('id'))) {
$rss_categorie
->setParentCategorie($parent_categorie)
->setIdSite($parent_categorie->getIdSite());
}
if ($this->_request->isPost())
{
$filter = new Zend_Filter_StripTags();
$libelle = trim($filter->filter($this->_request->getPost('libelle')));
$id_cat_mere = (int)$this->_request->getPost('id_cat_mere');
$data = array(
'ID_CAT' => '',
'ID_CAT_MERE' => $id_cat_mere,
'LIBELLE' => $libelle,
'ID_SITE' => $this->id_bib,
);
$menu_deploy = $this->saveTreeMenu($id_cat_mere);
$class_rss = new Class_Rss();
$errorMessage = $class_rss->addCategorie($data);
if ($errorMessage == ''){$this->_redirect('admin/rss?z='.$this->id_zone.'&b='.$this->id_bib);}
else
{
$this->view->cat = new stdClass();
$this->view->cat->ID_CAT = null;
$this->view->cat->ID_CAT_MERE = $id_cat_mere;
$this->view->cat->LIBELLE = $libelle;
$this->view->id_cat_mere = $id_cat_mere;
$this->view->message = $errorMessage;
}
}
else
{
$id = (int)$this->_request->getParam('id', 0); if(!$id || $id ==0) $id_cat_mere = 0; else $id_cat_mere = $id;
$menu_deploy = $this->saveTreeMenu($id_cat_mere);
// Cat _blank
$this->view->cat = new stdClass();
$this->view->cat->ID_CAT = null;
$this->view->cat->LIBELLE = '';
$this->view->cat->ID_CAT_MERE = $id_cat_mere;
}
// Action
$this->view->action = 'add';
$this->view->sess_id_zone = $this->id_zone;
$this->view->sess_id_site = $this->id_bib;
$this->addOrEditCategorie($rss_categorie);
}
function cateditAction()
{
$this->view->titre = "Modifier une catégorie de flux RSS";
$class_rss = new Class_Rss();
if ($this->_request->isPost())
{
$filter = new Zend_Filter_StripTags();
$id_cat_mere = (int)$this->_request->getPost('id_cat_mere');
$id_cat = (int)$this->_request->getParam('id_cat', 0);
$libelle = trim($filter->filter($this->_request->getPost('libelle')));
if ($id !== false) {
function cateditAction() {
$this->view->titre = $this->_("Modifier une catégorie de flux RSS");
$id = (int)$this->_request->getParam('id', 0);
$data = array(
'ID_CAT_MERE' => $id_cat_mere,
'LIBELLE' => $libelle,
);
if (!$rss_categorie = Class_RssCategorie::find($id))
$this->_redirect('admin/rss?z='.$this->id_zone.'&b='.$this->id_bib);
$this->addOrEditCategorie($rss_categorie);
}
public function addOrEditCategorie($rss_categorie) {
if ($this->_request->isPost() && $rss_categorie->updateAttributes($this->_request->getPost())->save())
$this->_redirect('admin/rss/index/z/'.$this->id_zone.'/b/'.$this->id_bib);
$this->saveTreeMenu($rss_categorie->getIdCatMere());
$this->view->message = implode(',', $rss_categorie->getErrors());
$errorMessage = $class_rss->editCategorie($data, $id_cat);
if ($errorMessage == ''){$this->_redirect('admin/rss?z='.$this->id_zone.'&b='.$this->id_bib);}
else
{
$rssCategorie = $class_rss->getCategorieByIdCat($id_cat);
if (is_string($categorie) ){$this->_redirect('admin/error/database');}
else
{
$this->view->combo_cat = $this->rendComboCat($this->id_bib,$rssCategorie->ID_CAT,$rssCategorie->ID_CAT_MERE);
$this->view->rss = $rssCategorie;
$this->view->id_cat_mere = $id_cat_mere;
$this->view->message = $errorMessage;
}
}
}
}
else
{
$id = (int)$this->_request->getParam('id', 0);
$menu_deploy = $this->saveTreeMenu($id);
if ( $id > 0 )
{
$rssCategorie = $class_rss->getCategorieByIdCat($id);
$this->view->combo_cat = $this->rendComboCat($this->id_bib,$rssCategorie->ID_CAT,$rssCategorie->ID_CAT_MERE);
if ( is_string($rssCategorie) ){$this->_redirect('admin/error/database');}
elseif($rssCategorie == null){$this->_redirect('admin/rss?z='.$this->id_zone.'&b='.$this->id_bib);}
else{$this->view->rss = $rssCategorie; }
}
else {$this->_redirect('admin/rss?z='.$this->id_zone.'&b='.$this->id_bib);}
}
// Action
$this->view->action = 'edit';
$this->view->sess_id_zone = $this->id_zone;
$this->view->sess_id_site = $this->id_bib;
$this->view->rss_cat = $rss_categorie;
$this->view->combo_cat = $this->view->comboParentCategorie($rss_categorie);
}
function catdelAction()
{
$class_rss = new Class_Rss();
@@ -361,26 +303,7 @@ class Admin_RssController extends Zend_Controller_Action {
$this->_redirect('admin/rss?z='.$this->id_zone.'&b='.$this->id_bib);
}
function rendComboCat($id_bib,$id_cat,$id_cat_mere)
{
$class_rss = new Class_Rss();
$cat_array = $class_rss->getAllCategorieByIdBib($id_bib);
$html[]='<select name="id_cat_mere" id="id_cat_mere" style="width:100%">';
$html[]='<option value="'.$id_cat_mere.'" selected="selected">Aucune</option>';
foreach ($cat_array as $cat)
{
if ($id_bib ==0)
{
if ($id_cat !=$cat->ID_CAT && $cat->ID_CAT_MERE != $id_cat) $html[]='<option value="'.$cat->ID_CAT.'">'.$cat->LIBELLE.'</option>';
}
else
{
if($id_cat !=$cat["ID_CAT"] && $cat["ID_CAT_MERE"] != $id_cat)$html[]='<option value="'.$cat["ID_CAT"].'">'.$cat["LIBELLE"].'</option>';
}
}
$html[]='</select>';
return implode('',$html);
}
function saveTreeMenu($id_cat)
{
@@ -394,4 +317,6 @@ class Admin_RssController extends Zend_Controller_Action {
}
$_SESSION["MENU_DEPLOY"]["RSS"] = $id_menu;
}
}
\ No newline at end of file
}
?>
\ No newline at end of file