Skip to content
Snippets Groups Projects
Commit 080efd20 authored by Matthias Meusburger's avatar Matthias Meusburger
Browse files

dev #21441 : clean sitocontroller

parent c324e30b
5 merge requests!1132Hotline#29412 images des articles dans le resultat de recherche,!1120Master,!1069Dev#25302 add custom fields to sitos,!1055Dev#25302 add custom fields to sitos,!1054Dev#21441 add custom fields to sitos
......@@ -21,9 +21,6 @@
class Admin_SitoController extends ZendAfi_Controller_Action {
private $id_zone;
private $id_bib;
private $_today;
public function getRessourceDefinitions() {
return [
......@@ -68,21 +65,6 @@ class Admin_SitoController extends ZendAfi_Controller_Action {
$this->_setParam('id_cat',$site->getCategorie()->getId());
}
// On force une bib s'il ny en a pas
if(!intval($this->id_bib))
{
if(intval($this->id_zone)) $this->id_bib=fetchOne("select ID_SITE from bib_c_site where ID_ZONE=".$this->id_zone." order by LIBELLE");
else {$this->id_bib="PORTAIL"; $this->id_zone="PORTAIL";}
}
// Objets de vue
$this->view->id_zone=$this->id_zone;
$this->view->id_bib=$this->id_bib;
/// OLD A MODIFIER ///////
$class_date = new Class_Date();
$this->_today = $class_date->DateTimeDuJour();
$identity = Class_Users::getLoader()->getIdentity();
if (ZendAfi_Acl_AdminControllerRoles::ADMIN_BIB >= $identity->getRoleLevel()) {
......@@ -131,7 +113,7 @@ class Admin_SitoController extends ZendAfi_Controller_Action {
$this->view->sitoActions = $this->_getTreeViewItemActions();
$this->view->headScript()->appendScript('var treeViewSelectedCategory = '
. (int)$this->_getParam('id_cat') . ';');
. (int)$this->_getParam('id_cat') . ';');
$this->view->headScript()->appendFile(URL_ADMIN_JS . 'tree-view.js');
}
......@@ -142,69 +124,69 @@ class Admin_SitoController extends ZendAfi_Controller_Action {
*/
private function _getTreeViewContainerActions() {
return array(
array(
'url' => $this->_getUrlForActionAndIdName('catedit'),
'icon' => 'ico/edit.gif',
'label' => 'Modifier'
),
array(
'url' => $this->_getUrlForActionAndIdName('catdel'),
'icon' => 'ico/del.gif',
'label' => 'Supprimer',
'condition' => 'hasNoChild',
'anchorOptions' => array(
'onclick' => "return confirm('Etes-vous sûr de vouloir supprimer cette catégorie ?')"
)
),
array(
'url' => $this->_getUrlForActionAndIdName('sitoadd', 'id_cat'),
'icon' => 'ico/add_news.gif',
'label' => 'Ajouter un site',
),
array(
'url' => $this->_getUrlForActionAndIdName('catadd'),
'icon' => 'ico/add_cat.gif',
'label' => 'Ajouter une sous-catégorie'
),
array(
'url' => $this->_getUrlForActionAndIdName('catedit'),
'icon' => 'ico/edit.gif',
'label' => 'Modifier'
),
array(
'url' => $this->_getUrlForActionAndIdName('catdel'),
'icon' => 'ico/del.gif',
'label' => 'Supprimer',
'condition' => 'hasNoChild',
'anchorOptions' => array(
'onclick' => "return confirm('Etes-vous sûr de vouloir supprimer cette catégorie ?')"
)
),
array(
'url' => $this->_getUrlForActionAndIdName('sitoadd', 'id_cat'),
'icon' => 'ico/add_news.gif',
'label' => 'Ajouter un site',
),
array(
'url' => $this->_getUrlForActionAndIdName('catadd'),
'icon' => 'ico/add_cat.gif',
'label' => 'Ajouter une sous-catégorie'
),
);
}
protected function _getUrlForActionAndIdName($action, $idName = 'id') {
return $this->view->url(array(
'module' => 'admin',
'controller'=> 'sito',
'action' => $action), null, true) . '/' . $idName . '/%s';
'module' => 'admin',
'controller'=> 'sito',
'action' => $action), null, true) . '/' . $idName . '/%s';
}
private function _getTreeViewItemActions() {
return
[
[
'url' => $this->_getUrlForActionAndIdName('sitoview').'?&iframe=true&width=80%%&height=80%%',
'icon' => 'ico/show.gif',
'label' => 'Visualiser',
'anchorOptions' => [
'rel' => 'prettyPhoto'
]
],
[
'url' => $this->_getUrlForActionAndIdName('edit'),
'icon' => 'ico/edit.gif',
'label' => 'Modifier',
],
[
'url' => $this->_getUrlForActionAndIdName('delete'),
'icon' => 'ico/del.gif',
'label' => 'Supprimer',
'anchorOptions' => [
'onclick' => "return confirm('Etes-vous sûr de vouloir supprimer ce site ?')"
],
]
];
[
'url' => $this->_getUrlForActionAndIdName('sitoview').'?&iframe=true&width=80%%&height=80%%',
'icon' => 'ico/show.gif',
'label' => 'Visualiser',
'anchorOptions' => [
'rel' => 'prettyPhoto'
]
],
[
'url' => $this->_getUrlForActionAndIdName('edit'),
'icon' => 'ico/edit.gif',
'label' => 'Modifier',
],
[
'url' => $this->_getUrlForActionAndIdName('delete'),
'icon' => 'ico/del.gif',
'label' => 'Supprimer',
'anchorOptions' => [
'onclick' => "return confirm('Etes-vous sûr de vouloir supprimer ce site ?')"
],
]
];
}
......@@ -218,8 +200,8 @@ class Admin_SitoController extends ZendAfi_Controller_Action {
if ($parent_categorie = Class_SitothequeCategorie::find((int)$this->_getParam('id')))
$categorie
->setParentCategorie($parent_categorie)
->setIdSite($parent_categorie->getIdSite());
->setParentCategorie($parent_categorie)
->setIdSite($parent_categorie->getIdSite());
if ($this->_isCategorieSaved($categorie)) {
$this->_helper->notify($this->_('La catégorie "%s" a été ajoutée', $categorie->getLibelle()));
......@@ -286,7 +268,7 @@ class Admin_SitoController extends ZendAfi_Controller_Action {
protected function _canAdd() {
$category = Class_SitothequeCategorie::find($this->_getParam('id_cat'));
$category = Class_SitothequeCategorie::find($this->_getParam('id_cat'));
return $category;
}
......@@ -298,73 +280,11 @@ class Admin_SitoController extends ZendAfi_Controller_Action {
}
function sitoaddAction() {
// parent::addAction();
if (!$categorie = Class_SitothequeCategorie::find($this->_getParam('id_cat'))) {
$this->_redirect('/admin/sito');
return;
}
$this->view->site = $site = new Class_Sitotheque();
$this->view->titre = "Ajouter un site";
$site->setIdCat($categorie->getId());
if ($domaine = Class_Catalogue::findWithSamePathAs($categorie))
$site->setDomaineIds($domaine->getId());
$this->displaySiteForm($site);
}
function sitoeditAction() {
if (!$site = Class_Sitotheque::find((int)$this->_getParam('id'))) {
$this->_redirect('/admin/sito');
return;
}
$this->view->titre = "Modifier un site";
$this->view->site = $site;
$this->displaySiteForm($site);
}
protected function _doAfterSave($model) {
$model->index();
(new Storm_Cache())->clean();
}
public function displaySiteForm($site) {
if ($this->_request->isPost()) {
$post = $this->_request->getPost();
unset($post['id_items']);
if ($site
->updateAttributes($post)
->save()) {
$site->index();
(new Storm_Cache())->clean();
$this->_helper->notify($this->_('Le site "%s" a été sauvegardé', $site->getTitre()));
$this->_redirect('/admin/sito/edit/id/'.$site->getId());
return;
}
}
// Action
$this->view->combo_cat =$this->view->comboCategories($site->getCategorie());
}
function sitodelAction() {
if (!$site = Class_Sitotheque::find((int)$this->_getParam('id'))) {
$this->_redirect('/admin/sito');
return;
}
$site->delete();
$this->_helper->notify($this->_('Le site "%s" a été supprimé', $site->getTitre()));
$this->_redirect('/admin/sito/index/id_cat/'.$site->getIdCat());
}
function sitoviewAction() {
$this->_redirect(Class_Sitotheque::find((int)$this->_getParam('id'))->getUrl());
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment