From 7be59cb98950e41b601e308ffedcdf5117a45fed Mon Sep 17 00:00:00 2001 From: Patrick Barroca <pbarroca@afi-sa.fr> Date: Wed, 11 Jan 2017 17:33:29 +0100 Subject: [PATCH] dev #45275 fix rt --- .../admin/controllers/AlbumController.php | 13 --- .../admin/controllers/BibController.php | 3 - .../controllers/CmsCategoryController.php | 27 ----- .../admin/controllers/CmsController.php | 14 --- .../admin/controllers/SitoController.php | 80 +-------------- .../admin/controllers/UsergroupController.php | 66 ------------- .../admin/views/scripts/album/index.phtml | 5 +- .../admin/views/scripts/cms/index.phtml | 8 +- .../admin/views/scripts/sito/index.phtml | 9 +- .../admin/views/scripts/usergroup/index.phtml | 8 +- library/Class/AlbumCategorie.php | 23 +---- library/Class/MultiSelection/Abstract.php | 10 +- library/Class/MultiSelection/Album.php | 43 ++++---- library/Class/MultiSelection/Article.php | 59 +++++------ library/ZendAfi/Controller/Action.php | 6 +- library/ZendAfi/Controller/Action/Plugins.php | 27 +++-- .../ZendAfi/Controller/Plugin/Abstract.php | 22 ++--- .../Controller/Plugin/Manager/Article.php | 4 +- .../Controller/Plugin/Manager/Library.php | 34 +++++++ .../Controller/Plugin/Manager/Newsletter.php | 4 +- .../Plugin/MultiSelection/AbstractActions.php | 11 --- library/ZendAfi/Form/Admin/Sitotheque.php | 6 +- .../Helper/Admin/CustomFieldsCategories.php | 35 +------ .../ZendAfi/View/Helper/Admin/Libraries.php | 50 +--------- .../ZendAfi/View/Helper/CategoriesActions.php | 39 -------- .../ZendAfi/View/Helper/ModelActionsTable.php | 59 ----------- .../View/Helper/ModelActionsTable/Album.php | 56 ----------- .../ModelActionsTable/AlbumCategories.php | 73 -------------- .../View/Helper/ModelActionsTable/Article.php | 76 -------------- .../ModelActionsTable/ArticlesCategories.php | 99 ------------------- .../View/Helper/ModelActionsTable/Bib.php | 59 ----------- .../Helper/Plugin/MultiSelection/Widget.php | 13 +-- library/ZendAfi/View/Helper/TreeView.php | 12 +-- 33 files changed, 134 insertions(+), 919 deletions(-) delete mode 100644 library/ZendAfi/View/Helper/CategoriesActions.php delete mode 100644 library/ZendAfi/View/Helper/ModelActionsTable.php delete mode 100644 library/ZendAfi/View/Helper/ModelActionsTable/Album.php delete mode 100644 library/ZendAfi/View/Helper/ModelActionsTable/AlbumCategories.php delete mode 100644 library/ZendAfi/View/Helper/ModelActionsTable/Article.php delete mode 100644 library/ZendAfi/View/Helper/ModelActionsTable/ArticlesCategories.php delete mode 100644 library/ZendAfi/View/Helper/ModelActionsTable/Bib.php diff --git a/application/modules/admin/controllers/AlbumController.php b/application/modules/admin/controllers/AlbumController.php index 4ccc978e706..fdf018014a7 100644 --- a/application/modules/admin/controllers/AlbumController.php +++ b/application/modules/admin/controllers/AlbumController.php @@ -44,8 +44,6 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { $this->view->categories = [ ['bib' => Class_Bib::getPortail(), 'containers' => $categories]]; - $this->view->containersActions = $this->_getTreeViewContainerActions(); - $this->view->itemsActions = $this->_getTreeViewItemActions(); $this->view->headScript()->appendScript('var treeViewSelectedCategory = ' . (int)$this->_getParam('cat_id') . ';' @@ -163,17 +161,6 @@ class Admin_AlbumController extends ZendAfi_Controller_Action { } - - protected function _getTreeViewContainerActions() { - return (new ZendAfi_View_Helper_ModelActionsTable_AlbumCategories($this->view, 'album'))->getActions(); - } - - - protected function _getTreeViewItemActions() { - return (new ZendAfi_View_Helper_ModelActionsTable_Album($this->view, 'album'))->getActions(); - } - - protected function _renderList() { $cat_id = $this->_getParam('cat_id', ''); $category = Class_AlbumCategorie::find($cat_id); diff --git a/application/modules/admin/controllers/BibController.php b/application/modules/admin/controllers/BibController.php index e7db534ec69..d71bd931b01 100644 --- a/application/modules/admin/controllers/BibController.php +++ b/application/modules/admin/controllers/BibController.php @@ -36,7 +36,6 @@ class Admin_BibController extends ZendAfi_Controller_Action { $this->view->id_zone = $this->id_zone; $this->view->id_bib = $this->id_bib; - } @@ -52,8 +51,6 @@ class Admin_BibController extends ZendAfi_Controller_Action { } - - public function localisationsAction() { $cls_loc = new Class_Localisation(); $id_bib = (int)$this->_request->getParam('id_bib'); diff --git a/application/modules/admin/controllers/CmsCategoryController.php b/application/modules/admin/controllers/CmsCategoryController.php index 872c1882dec..a1de7f9d0dc 100644 --- a/application/modules/admin/controllers/CmsCategoryController.php +++ b/application/modules/admin/controllers/CmsCategoryController.php @@ -28,33 +28,6 @@ class Admin_CmsCategoryController extends ZendAfi_Controller_Action { 'ZendAfi_Controller_Plugin_Manager_ArticleCategory']; } - public function getRessourceDefinitions() { - return - ['model' => ['class' => 'Class_ArticleCategorie', - 'name' => 'category'], - - 'messages' => ['successful_save' => $this->_('Categorie "%s" sauvegardée'), - 'successful_add' => $this->_('La catégorie "%s" a été sauvegardée'), - 'successful_delete' => $this->_('Categorie "%s" supprimée')], - - 'actions' => ['add' => ['title' => $this->_("Ajouter une catégorie")], - 'edit' => ['title' => $this->_("Modifier une catégorie")]], - - 'after_add' => function ($model) { - $this->_redirectToReferer(); - }, - - 'after_edit' => function ($model) { - $this->_redirectToReferer(); - }, - - 'after_delete' => function($model) { - $this->_redirectToReferer(); - }, - - 'form_class_name' => 'ZendAfi_Form_Admin_CmsCategory']; - } - public function permissionsAction() { $this->_helper->getHelper('ViewRenderer')->setNoRender(); diff --git a/application/modules/admin/controllers/CmsController.php b/application/modules/admin/controllers/CmsController.php index 731807ca98a..5b023488c18 100644 --- a/application/modules/admin/controllers/CmsController.php +++ b/application/modules/admin/controllers/CmsController.php @@ -141,9 +141,6 @@ class Admin_CmsController extends ZendAfi_Controller_Action { $categories = array_map($datas_closure, $bibs); $this->view->categories = $categories; - $this->view->categorieActions = $this->_getTreeViewContainerActions(); - $this->view->articleActions = $this->_getTreeViewItemActions(); - $this->view->containersFilter = function($category) { $permissions = Class_Permission::getCmsPermissions(); return $this->identity->hasAnyPermissionUnder($category, $permissions) @@ -166,21 +163,10 @@ class Admin_CmsController extends ZendAfi_Controller_Action { } - private function _getTreeViewContainerActions() { - return (new ZendAfi_View_Helper_ModelActionsTable_ArticlesCategories($this->view, 'article'))->getActions(); - } - - - private function _getTreeViewItemActions() { - return (new ZendAfi_View_Helper_ModelActionsTable_Article($this->view, 'article'))->getActions(); - } - - public function categoriesAction() { $this->_helper->viewRenderer->setNoRender(); $this->getResponse()->setHeader('Content-Type', 'application/json; charset=utf-8'); $this->getResponse()->setBody((new Class_ArticleCategorie())->getCategoriesJson()); } - } ?> \ No newline at end of file diff --git a/application/modules/admin/controllers/SitoController.php b/application/modules/admin/controllers/SitoController.php index 947544dbc75..8a185dc7c72 100644 --- a/application/modules/admin/controllers/SitoController.php +++ b/application/modules/admin/controllers/SitoController.php @@ -43,10 +43,8 @@ class Admin_SitoController extends ZendAfi_Controller_Action { } } - //---------------------------------------------------------------------------------- - // Liste des sites - //---------------------------------------------------------------------------------- - function indexAction() { + + public function indexAction() { $this->view->titre = 'Gestion de la sitothèque'; @@ -76,84 +74,10 @@ class Admin_SitoController extends ZendAfi_Controller_Action { $add_link_label)); } - $this->view->categorieActions = $this->_getTreeViewContainerActions(); $this->view->categories = $categories; - $this->view->sitoActions = $this->_getTreeViewItemActions(); $this->view->headScript()->appendScript('var treeViewSelectedCategory = ' . (int)$this->_getParam('id_cat') . ';'); $this->view->headScript()->appendFile(URL_ADMIN_JS . 'tree-view.js'); } - - - - /** - * @return array - */ - private function _getTreeViewContainerActions() { - return array( - array( - 'url' => $this->_getUrlForActionAndIdName('catedit'), - 'icon' => 'edit', - 'label' => 'Modifier' - ), - array( - 'url' => $this->_getUrlForActionAndIdName('catdel'), - 'icon' => 'delete', - 'label' => 'Supprimer', - 'condition' => 'hasNoChild', - 'anchorOptions' => array( - 'onclick' => "return confirm('Etes-vous sûr de vouloir supprimer cette catégorie ?')" - ) - ), - array( - 'url' => $this->_getUrlForActionAndIdName('add', 'id_cat'), - 'icon' => 'add_page', - 'label' => 'Ajouter un site', - ), - array( - 'url' => $this->_getUrlForActionAndIdName('catadd'), - 'icon' => 'add_category', - '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'; - } - - - private function _getTreeViewItemActions() { - return - [ - [ - 'url' => $this->_getUrlForActionAndIdName('sitoview').'?&iframe=true&width=80%%&height=80%%', - 'icon' => 'show', - 'label' => 'Visualiser', - 'anchorOptions' => [ - 'rel' => 'prettyPhoto' - ] - ], - - [ - 'url' => $this->_getUrlForActionAndIdName('edit'), - 'icon' => 'edit', - 'label' => 'Modifier', - ], - - [ - 'url' => $this->_getUrlForActionAndIdName('delete'), - 'icon' => 'delete', - 'label' => 'Supprimer', - 'anchorOptions' => [ - 'onclick' => "return confirm('Etes-vous sûr de vouloir supprimer ce site ?')" - ], - ] - ]; - } } \ No newline at end of file diff --git a/application/modules/admin/controllers/UsergroupController.php b/application/modules/admin/controllers/UsergroupController.php index e50cd142239..737efacbf62 100644 --- a/application/modules/admin/controllers/UsergroupController.php +++ b/application/modules/admin/controllers/UsergroupController.php @@ -49,78 +49,12 @@ class Admin_UsergroupController extends ZendAfi_Controller_Action { 'add_link' => $this->view->tagAnchor($this->view->url(array_merge($add_link_options, ['id_bib' => $bib->getId()])), $add_link_label,[])]; - $this->view->categorieActions = $this->_getTreeViewContainerActions(); - $this->view->usergroupActions = $this->_getTreeViewItemActions(); $this->view->headScript()->appendScript('var treeViewSelectedCategory = ' . (int)$this->_getParam('id_cat') . ';'); $this->view->headScript()->appendFile(URL_ADMIN_JS . 'tree-view.js'); } - /** - * @return array - */ - private function _getTreeViewContainerActions() { - return [['url' => $this->_getUrlForActionAndIdName('catedit'), - 'icon' => 'edit', - 'label' => 'Modifier'], - - ['url' => $this->_getUrlForActionAndIdName('catdel'), - 'icon' => 'delete', - 'label' => 'Supprimer', - 'condition' => 'hasNoChild', - 'anchorOptions' => ['onclick' => "return confirm('Etes-vous sûr de vouloir supprimer cette catégorie ?')"]], - - ['url' => $this->_getUrlForActionAndIdName('add', 'id_cat'), - 'icon' => 'add_page', - 'label' => 'Ajouter un groupe'], - - ['url' => $this->_getUrlForActionAndIdName('catadd'), - 'data-popup' => true, - 'icon' => 'add_category', - 'label' => 'Ajouter une sous-catégorie']]; - } - - - protected function _getUrlForActionAndIdName($action, $idName = 'id') { - return $this->view->url(array( - 'module' => 'admin', - 'controller'=> 'usergroup', - 'action' => $action), null, true) . '/' . $idName . '/%s'; - } - - - - private function _getTreeViewItemActions() { - return - [ - [ - 'url' => $this->_getUrlForActionAndIdName('editmembers'), - 'icon' => 'users', - 'label' => 'Membres', - 'caption' => 'formatedCount' - ], - - - [ - 'url' => $this->_getUrlForActionAndIdName('edit'), - 'icon' => 'edit', - 'label' => 'Modifier', - ], - - [ - 'url' => $this->_getUrlForActionAndIdName('delete'), - 'icon' => 'delete', - 'label' => 'Supprimer', - 'anchorOptions' => [ - 'onclick' => "return confirm('Etes-vous sûr de vouloir supprimer ce groupe ?')" - ], - ] - ]; - } - - - public function listJsonAction() { $json_groups = []; foreach(Class_UserGroupCategorie::getTopCategories() as $group_category) diff --git a/application/modules/admin/views/scripts/album/index.phtml b/application/modules/admin/views/scripts/album/index.phtml index 5f6d36885a0..8aa7a435f15 100644 --- a/application/modules/admin/views/scripts/album/index.phtml +++ b/application/modules/admin/views/scripts/album/index.phtml @@ -8,8 +8,5 @@ if (Class_AdminVar::isBibNumEnabled()) ); echo $this->getHelper('TreeView') ->renderItemWithIconeSupport() - ->treeView($this->categories, - $this->containersActions, - $this->itemsActions, - false); + ->treeView($this->categories, false); ?> diff --git a/application/modules/admin/views/scripts/cms/index.phtml b/application/modules/admin/views/scripts/cms/index.phtml index 03ba1c74555..d7fdf3c3394 100644 --- a/application/modules/admin/views/scripts/cms/index.phtml +++ b/application/modules/admin/views/scripts/cms/index.phtml @@ -1,9 +1,3 @@ <?php -echo $this->treeView( - $this->categories, - $this->categorieActions, - $this->articleActions, - true, - $this->containersFilter -); +echo $this->treeView($this->categories, true, $this->containersFilter); ?> diff --git a/application/modules/admin/views/scripts/sito/index.phtml b/application/modules/admin/views/scripts/sito/index.phtml index 0f1f86baa9c..5c6302c1bb0 100644 --- a/application/modules/admin/views/scripts/sito/index.phtml +++ b/application/modules/admin/views/scripts/sito/index.phtml @@ -1,8 +1,3 @@ <?php -echo $this->treeView( - $this->categories, - $this->categorieActions, - $this->sitoActions, - false -); -?> \ No newline at end of file +echo $this->treeView($this->categories, false); +?> diff --git a/application/modules/admin/views/scripts/usergroup/index.phtml b/application/modules/admin/views/scripts/usergroup/index.phtml index 583fe9c29f9..5c6302c1bb0 100644 --- a/application/modules/admin/views/scripts/usergroup/index.phtml +++ b/application/modules/admin/views/scripts/usergroup/index.phtml @@ -1,9 +1,3 @@ <?php -echo $this->treeView( - $this->categories, - $this->categorieActions, - $this->usergroupActions, - false -); - +echo $this->treeView($this->categories, false); ?> diff --git a/library/Class/AlbumCategorie.php b/library/Class/AlbumCategorie.php index 145bf00436c..ca57a44f11f 100644 --- a/library/Class/AlbumCategorie.php +++ b/library/Class/AlbumCategorie.php @@ -115,27 +115,8 @@ class AlbumCategorieLoader extends Storm_Model_Loader { public function getAlbumsIdsFromCategories($ids) { - $albums_ids = []; - $sub_categories = []; - foreach($ids as $id) { - $albums = []; - - if(!$cat = Class_AlbumCategorie::find($id)) - continue; - - $albums = $cat->getAlbums(); - - foreach($cat->getSousCategories() as $sub_cat) - $sub_categories[] = $sub_cat->getId(); - - foreach($albums as $album) - $albums_ids[] = $album->getId(); - } - - if(empty($albums_ids) && empty($sub_categories)) - return []; - - return array_merge($albums_ids, $this::getAlbumsIdsFromCategories($sub_categories)); + $albums = new Storm_Model_Collection(Class_AlbumCategorie::getAlbumsFromCategories($ids)); + return $albums->collect('id')->getArrayCopy(); } } diff --git a/library/Class/MultiSelection/Abstract.php b/library/Class/MultiSelection/Abstract.php index 433f901eacb..6902ec1359d 100644 --- a/library/Class/MultiSelection/Abstract.php +++ b/library/Class/MultiSelection/Abstract.php @@ -83,10 +83,12 @@ abstract class Class_MultiSelection_Abstract { } - public function acceptVisitor($visitor) { - $visitor - ->visitWidget($this) - ->visitActions($this); + public function acceptWidgetVisitor($visitor) { + return $this; + } + + + public function acceptActionsVisitor($visitor) { return $this; } diff --git a/library/Class/MultiSelection/Album.php b/library/Class/MultiSelection/Album.php index 6d24ffe407e..d69bd94af52 100644 --- a/library/Class/MultiSelection/Album.php +++ b/library/Class/MultiSelection/Album.php @@ -27,14 +27,15 @@ class Class_MultiSelection_Album extends Class_MultiSelection_Abstract { return []; return (new Storm_Model_Collection(Class_Album::getItemsOf($id))) - ->collect('id') - ->getArrayCopy(); + ->collect('id') + ->getArrayCopy(); } public function getModels() { if(!$values = $this->getValues()) return new Storm_Model_Collection([]); + return new Storm_Model_Collection(Class_Album::findAllBy(['id' => $values, 'order' => 'titre'])); } @@ -48,37 +49,37 @@ class Class_MultiSelection_Album extends Class_MultiSelection_Abstract { ->visitTitle($this->_('Sélection multiple d\'albums')) ->visitCount($this->_plural($count, - '', - 'Vous avez sélectionné 1 album', - 'Vous avez sélectionné %d albums', - $count)) + '', + 'Vous avez sélectionné 1 album', + 'Vous avez sélectionné %d albums', + $count)) ->visitEditSelection($this->_plural($count, - '', - 'Modifier l\'album sélectionné', - 'Modifier les %d albums sélectionnés', - $count)) + '', + 'Modifier l\'album sélectionné', + 'Modifier les %d albums sélectionnés', + $count)) ->visitShowSelection($this->_plural($count, - '', - 'Voir l\'album sélectionné', - 'Voir la liste des %d albums sélectionnés', - $count)) + '', + 'Voir l\'album sélectionné', + 'Voir la liste des %d albums sélectionnés', + $count)) ->visitClearSelection($this->_plural($count, - '', - 'Déselectionner l\'album sélectionné', - 'Déselectionner les %d albums sélectionnés', - $count)) + '', + 'Déselectionner l\'album sélectionné', + 'Déselectionner les %d albums sélectionnés', + $count)) ->visitSelectedItems($models->getArrayCopy()) ->visitTitleKey('titre') ->visitStrategy('album') ->visitCategoryLabel(function($model) - { - return $model->getCategoryLabel(); - }); + { + return $model->getCategoryLabel(); + }); return $this; } diff --git a/library/Class/MultiSelection/Article.php b/library/Class/MultiSelection/Article.php index 77e4e5d1b83..e60e11eca7f 100644 --- a/library/Class/MultiSelection/Article.php +++ b/library/Class/MultiSelection/Article.php @@ -30,6 +30,7 @@ class Class_MultiSelection_Article extends Class_MultiSelection_Abstract { public function getModels() { if(!$values = $this->getValues()) return new Storm_Model_Collection([]); + return new Storm_Model_Collection(Class_Article::findAllBy(['id_article' => $values, 'order' => 'titre'])); } @@ -43,52 +44,52 @@ class Class_MultiSelection_Article extends Class_MultiSelection_Abstract { ->visitTitle($this->_('Sélection multiple d\'articles')) ->visitCount($this->_plural($count, - '', - 'Vous avez sélectionné 1 article', - 'Vous avez sélectionné %d articles', - $count)) + '', + 'Vous avez sélectionné 1 article', + 'Vous avez sélectionné %d articles', + $count)) ->visitEditSelection($this->_plural($count, - '', - 'Modifier l\'article sélectionné', - 'Modifier les %d articles sélectionnés', - $count)) + '', + 'Modifier l\'article sélectionné', + 'Modifier les %d articles sélectionnés', + $count)) ->visitShowSelection($this->_plural($count, - '', - 'Voir l\'article sélectionné', - 'Voir la liste des %d articles sélectionnés', - $count)) + '', + 'Voir l\'article sélectionné', + 'Voir la liste des %d articles sélectionnés', + $count)) ->visitClearSelection($this->_plural($count, - '', - 'Déselectionner l\'article sélectionné', - 'Déselectionner les %d articles sélectionnés', - $count)) + '', + 'Déselectionner l\'article sélectionné', + 'Déselectionner les %d articles sélectionnés', + $count)) ->visitSelectedItems($models->getArrayCopy()) ->visitTitleKey('titre') ->visitStrategy('article') ->visitCategoryLabel(function($model) - { - return $model->getCategorieLibelle(); - }); + { + return $model->getCategorieLibelle(); + }); return $this; } - public function acceptActionsVisitor($visitor) { - $user = Class_Users::getIdentity(); - $permission_closure = function($model) use($user){ - if('Class_Article' == get_class($model)) - $model = $model->getCategorie(); + public function acceptActionsVisitor($visitor) { + $user = Class_Users::getIdentity(); + $permission_closure = function($model) use($user){ + if('Class_Article' == get_class($model)) + $model = $model->getCategorie(); - return $user - ->hasAnyPermissionOn($model, - [Class_Permission::createArticle(), - Class_Permission::createArticleCategory()]); - }; + return $user + ->hasAnyPermissionOn($model, + [Class_Permission::createArticle(), + Class_Permission::createArticleCategory()]); + }; $visitor ->visitControllerName('cms') diff --git a/library/ZendAfi/Controller/Action.php b/library/ZendAfi/Controller/Action.php index 9915f9e2e86..d57e83df6bc 100644 --- a/library/ZendAfi/Controller/Action.php +++ b/library/ZendAfi/Controller/Action.php @@ -44,7 +44,7 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action { return $this->_redirectToIndex(); } - return $plugins->first()->call($method_name, $args); + return call_user_func_array([$plugins->first(), $method_name], $args); } @@ -68,8 +68,7 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action { public function preDispatch() { $plugins_helper = new ZendAfi_Controller_Action_Plugins($this); - $this->_plugins = $plugins_helper->getPlugins(); - $this->_plugins = $this->view->plugins = $plugins_helper->init(); + $this->view->plugins = $this->_plugins = $plugins_helper->getPlugins(); if ($this->isPopupRequest()) $this->switchToPopupMode(); @@ -277,7 +276,6 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action { ->visitResponse($this->_response) ->visitHelper($this->_helper) ->visitViewRenderer($this->getHelper('ViewRenderer')) - ->visitPlugins($this->_plugins) ->visitGetPost(function() { return $this->_getPost(); diff --git a/library/ZendAfi/Controller/Action/Plugins.php b/library/ZendAfi/Controller/Action/Plugins.php index 89bdf119d94..15cf4bbdcf6 100644 --- a/library/ZendAfi/Controller/Action/Plugins.php +++ b/library/ZendAfi/Controller/Action/Plugins.php @@ -23,29 +23,28 @@ class ZendAfi_Controller_Action_Plugins { protected $_plugins; - public function __construct($controller) { - if(!$plugins = $controller->getPlugins()) + public function __construct($pluggable) { + if(!$plugins = $pluggable->getPlugins()) $instances = []; - $instances = array_map(function($plugin) use ($controller) - { - return new $plugin($controller); - }, - $plugins); + $instances = array_map(function($plugin) use ($pluggable) + { + return new $plugin($pluggable); + }, + $plugins); $this->_plugins = new Storm_Collection($instances); + $this->_plugins + ->eachDo(function($plugin) + { + $plugin->visitPlugins($this->_plugins); + $plugin->init(); + }); } public function getPlugins() { return $this->_plugins; } - - public function init() { - return $this->_plugins->eachDo(function($plugin) - { - $plugin->init(); - }); - } } ?> \ No newline at end of file diff --git a/library/ZendAfi/Controller/Plugin/Abstract.php b/library/ZendAfi/Controller/Plugin/Abstract.php index 1df6bc6f830..92821e2a679 100644 --- a/library/ZendAfi/Controller/Plugin/Abstract.php +++ b/library/ZendAfi/Controller/Plugin/Abstract.php @@ -23,22 +23,14 @@ abstract class ZendAfi_Controller_Plugin_Abstract { use Trait_Translator; - protected $_controller; + protected + $_controller; public function __call($name, $args) { - if (!preg_match('/(visit)(\w+)/', $name)) - return $this->$name($args); + if (preg_match('/(visit)(\w+)/', $name)) + return $this; - if($this->isActionDefined($name)) - return $this->$name($args); - - return $this; - } - - public function call($name, $args) { - if($this->isActionDefined($name)) - return $this->$name($args); - return null; + parent::__call($name, $args); } @@ -52,7 +44,7 @@ abstract class ZendAfi_Controller_Plugin_Abstract { } - public function init(){ + public function init() { $this->_controller->acceptVisitor($this); } @@ -81,7 +73,7 @@ abstract class ZendAfi_Controller_Plugin_Abstract { $plugins ->reject(function($plugin) { - return $plugin == $this; + return $plugin === $this; }) ->eachDo(function($plugin) { diff --git a/library/ZendAfi/Controller/Plugin/Manager/Article.php b/library/ZendAfi/Controller/Plugin/Manager/Article.php index b2386bf7b5a..23c8a088e24 100644 --- a/library/ZendAfi/Controller/Plugin/Manager/Article.php +++ b/library/ZendAfi/Controller/Plugin/Manager/Article.php @@ -42,7 +42,7 @@ class ZendAfi_Controller_Plugin_Manager_Article extends ZendAfi_Controller_Plugi } -public function newsduplicateAction() { + public function newsduplicateAction() { if (!$model = Class_Article::find($this->_getParam('id'))) return $this->_redirect('admin/cms'); @@ -420,7 +420,7 @@ public function newsduplicateAction() { } - public function getActions($model) { + public function getActions($model) { if('Class_Article' == get_class($model)) return $this->_articleActions($model); diff --git a/library/ZendAfi/Controller/Plugin/Manager/Library.php b/library/ZendAfi/Controller/Plugin/Manager/Library.php index 43a1e462ff8..7842318419a 100644 --- a/library/ZendAfi/Controller/Plugin/Manager/Library.php +++ b/library/ZendAfi/Controller/Plugin/Manager/Library.php @@ -53,5 +53,39 @@ class ZendAfi_Controller_Plugin_Manager_Library extends ZendAfi_Controller_Plugi $this->_redirect('admin/bib/index'); } + + public function getActions($model) { + return [['url' => '/admin/bib/edit/id/%s', + 'icon' => 'edit', + 'label' => $this->_('Modifier la bibliothèque')], + + ['url' => '/admin/bib/delete/id/%s', + 'icon' => 'delete', + 'label' => $this->_('Supprimer la bibliothèque'), + 'condition' => function($model) + { + return !Class_Users::getIdentity()->isRoleLibraryLimited(); + }], + + ['url' => '/admin/bib/plans/id_bib/%s', + 'icon' => 'map', + 'label' => $this->_('Plans de la bibliothèque')], + + ['url' => '/admin/bib/localisations/id_bib/%s', + 'icon' => 'localisation', + 'label' => $this->_('Localisations de la bibliothèque')], + + ['url' => '/admin/ouvertures/index/id_site/%s', + 'icon' => 'calendar', + 'label' => $this->_('Planification des ouvertures')], + + ['url' => '/admin/ouvertures/index/id_site/%s/multimedia/1', + 'icon' => 'computers', + 'label' => $this->_('Planification des ouvertures multimédia'), + 'condition' => function($model) + { + return Class_AdminVar::isMultimediaEnabled(); + }]]; + } } ?> \ No newline at end of file diff --git a/library/ZendAfi/Controller/Plugin/Manager/Newsletter.php b/library/ZendAfi/Controller/Plugin/Manager/Newsletter.php index 9db0b354bb7..e755bb98021 100644 --- a/library/ZendAfi/Controller/Plugin/Manager/Newsletter.php +++ b/library/ZendAfi/Controller/Plugin/Manager/Newsletter.php @@ -64,7 +64,7 @@ function sendNewsletterClick(event) { } - public function previewAction() { + public function previewAction() { if (!$newsletter = Class_Newsletter::find((int)$this->_getParam('id'))) { $this->_redirectToIndex(); return; @@ -152,7 +152,7 @@ function sendNewsletterClick(event) { } - public function duplicateAction() { + public function duplicateAction() { $this->_redirectToIndex(); if (!$newsletter = Class_Newsletter::find($this->_getParam('id'))) { diff --git a/library/ZendAfi/Controller/Plugin/MultiSelection/AbstractActions.php b/library/ZendAfi/Controller/Plugin/MultiSelection/AbstractActions.php index a01360819a1..b1eeb78d106 100644 --- a/library/ZendAfi/Controller/Plugin/MultiSelection/AbstractActions.php +++ b/library/ZendAfi/Controller/Plugin/MultiSelection/AbstractActions.php @@ -22,18 +22,7 @@ abstract class ZendAfi_Controller_Plugin_MultiSelection_AbstractActions { public function __construct($multi_selection) { - $multi_selection->acceptVisitor($this); - } - - - public function visitWidget($multi_selection) { - return $this; - } - - - public function visitActions($multi_selection) { $multi_selection->acceptActionsVisitor($this); - return $this; } diff --git a/library/ZendAfi/Form/Admin/Sitotheque.php b/library/ZendAfi/Form/Admin/Sitotheque.php index 9dba6d35f2a..2fe78ea719a 100644 --- a/library/ZendAfi/Form/Admin/Sitotheque.php +++ b/library/ZendAfi/Form/Admin/Sitotheque.php @@ -33,11 +33,11 @@ class ZendAfi_Form_Admin_Sitotheque extends ZendAfi_Form { ->addElement('text', 'titre', - ['label' => $this->_('Titre'), 'size' => 50]) + ['label' => $this->_('Titre'), 'size' => 50, 'required' => true, 'allowEmpty' => false]) - ->addElement('text', + ->addElement('url', 'url', - ['label' => $this->_('Url'), 'size' => 50]) + ['label' => $this->_('Url'), 'size' => 50, 'required' => true, 'allowEmpty' => false]) ->addElement('checkbox', 'indexation', diff --git a/library/ZendAfi/View/Helper/Admin/CustomFieldsCategories.php b/library/ZendAfi/View/Helper/Admin/CustomFieldsCategories.php index e982984f073..ef0ab123ac9 100644 --- a/library/ZendAfi/View/Helper/Admin/CustomFieldsCategories.php +++ b/library/ZendAfi/View/Helper/Admin/CustomFieldsCategories.php @@ -28,45 +28,12 @@ class ZendAfi_View_Helper_Admin_CustomFieldsCategories extends ZendAfi_View_Help 'containers' => Class_CustomField_Model::getModels(), 'add_link' => '']]; - - $categories_actions = [ ['url' => $this->view->url([ - 'module' => 'admin', - 'controller' => 'custom-fields', - 'action' => 'add'], null, true).'/model/%s', - 'icon' => 'add_page', - 'label' => $this->view->_('Rattacher un champ personnalisé')]]; - - $fields_actions = [ ['url' => $this->view->url(['module' => 'admin', - 'controller' => 'custom-fields', - 'action' => 'up'], null, true).'/id/%s', - 'icon' => 'up', - 'label' => $this->view->_('Monter') ], - - ['url' => $this->view->url(['module' => 'admin', - 'controller' => 'custom-fields', - 'action' => 'down'], null, true).'/id/%s', - 'icon' => 'down', - 'label' => $this->view->_('Descendre') ], - - ['url' => $this->view->url(['module' => 'admin', - 'controller' => 'custom-fields', - 'action' => 'edit'], null, true).'/id/%s', - 'icon' => 'edit', - 'label' => $this->view->_('Modifier') ], - - ['url' => $this->view->url(['module' => 'admin', - 'controller' => 'custom-fields', - 'action' => 'delete'], null, true).'/id/%s', - 'icon' => 'delete', - 'label' => $this->view->_('Supprimer'), - 'anchorOptions' => ['onclick' => "return confirm('".$this->view->_('Etes-vous sûr de vouloir supprimer ce champs ?')."');"]]]; - $script_loader = Class_ScriptLoader::getInstance(); if ($model) $script_loader->addInlineScript('var treeViewSelectedCategory = "'. $model .'";'); $script_loader->addAdminScript('tree-view.js'); - return $this->view->treeView($categories, $categories_actions, $fields_actions, false); + return $this->view->treeView($categories, false); } } ?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Admin/Libraries.php b/library/ZendAfi/View/Helper/Admin/Libraries.php index c8aa96537bd..823d9774e50 100644 --- a/library/ZendAfi/View/Helper/Admin/Libraries.php +++ b/library/ZendAfi/View/Helper/Admin/Libraries.php @@ -29,60 +29,12 @@ class ZendAfi_View_Helper_Admin_Libraries extends ZendAfi_View_Helper_BaseHelper ['Nom de la bibliothèque', 'ville'], ['libelle', 'ville'], [function($library) { - return $this->_getActions($library); + return $this->view->renderPluginsActions($library); }], 'libraries'); } - protected function _getActions($library) { - $actions_datas = [['url' => $this->view->url(['action' => 'edit', 'id' => $library->getId()]), - 'icon' => 'edit', - 'label' => $this->_('Modifier la bibliothèque')], - - ['url' => $this->view->url(['action' => 'delete', 'id' => $library->getId()]), - 'icon' => 'delete', - 'label' => $this->_('Supprimer la bibliothèque')], - - ['url' => $this->view->url(['action' => 'plans', 'id_bib' => $library->getId()]), - 'icon' => 'map', - 'label' => $this->_('Plans de la bibliothèque')], - - ['url' => $this->view->url(['action' => 'localisations', 'id_bib' => $library->getId()]), - 'icon' => 'localisation', - 'label' => $this->_('Localisations de la bibliothèque')], - - ['url' => $this->view->url(['controller' => 'ouvertures', 'action' => 'index', 'id_site' => $library->getId()]), - 'icon' => 'calendar', - 'label' => $this->_('Planification des ouvertures')]]; - - if (Class_AdminVar::isMultimediaEnabled()) - $actions_datas[] = ['url' => $this->view->url(['controller' => 'ouvertures', - 'action' => 'index', - 'id_site' => $library->getId(), - 'multimedia' => 1]), - 'icon' => 'computers', - 'label' => $this->_('Planification des ouvertures multimédia')]; - - $current_skin = Class_Admin_Skin::current(); - $actions = ''; - - foreach ($actions_datas as $action) { - $icon = $current_skin->renderActionIconOn($action['icon'], - $this->view, - ['alt' => $action['label'], - 'title' => $action['label']]); - - if('delete' == $action['icon'] && Class_Users::getIdentity()->isAdminBib()) - continue; - - $actions .= $this->view->tagAnchor($action['url'], $icon); - } - - return $actions; - } - - protected function _localisationAndAddButton($id_zone, $id_bib) { if (!Class_Users::getIdentity()->canAccessAllBibs()) return ''; diff --git a/library/ZendAfi/View/Helper/CategoriesActions.php b/library/ZendAfi/View/Helper/CategoriesActions.php deleted file mode 100644 index f6bd7f6f625..00000000000 --- a/library/ZendAfi/View/Helper/CategoriesActions.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php -/** - * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. - * - * BOKEH is free software; you can redistribute it and/or modify - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by - * the Free Software Foundation. - * - * There are special exceptions to the terms and conditions of the AGPL as it - * is applied to this software (see README file). - * - * BOKEH is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE - * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -class ZendAfi_View_Helper_CategoriesActions extends Zend_View_Helper_Abstract { - public function categoriesActions($model) { - $strategy = get_class($model); - - if('Class_Album' == $strategy) - return (new ZendAfi_View_Helper_ModelActionsTable_AlbumCategories($this->view, $model))->getActions(); - - if('Class_Bib' == $strategy) - return (new ZendAfi_View_Helper_ModelActionsTable_Bib($this->view, $model))->getActions(); - - if('Class_Article' == $strategy) - return (new ZendAfi_View_Helper_ModelActionsTable_ArticlesCategories($this->view, $model))->getActions(); - - return []; - } -} -?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ModelActionsTable.php b/library/ZendAfi/View/Helper/ModelActionsTable.php deleted file mode 100644 index 151c693fe63..00000000000 --- a/library/ZendAfi/View/Helper/ModelActionsTable.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php -/** - * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. - * - * BOKEH is free software; you can redistribute it and/or modify - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by - * the Free Software Foundation. - * - * There are special exceptions to the terms and conditions of the AGPL as it - * is applied to this software (see README file). - * - * BOKEH is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE - * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -class ZendAfi_View_Helper_ModelActionsTable { - use Trait_Translator; - - protected $view, - $_model; - - - public function __construct($view, $model) { - $this->view = $view; - $this->_model = $model; - } - - - public function setActions($actions) { - return $actions; - } - - - protected function _getUrlForAction($action, $reset = false) { - return $this->_getUrlFor('', $action, 'id', $reset); - } - - - protected function _getUrlFor($controller = '', $action = '', $id_key = 'id', $reset = false) { - return $this->view->url(array_merge($this->getBaseUrl(), - array_filter(['controller'=> $controller, - 'action' => $action, - $id_key => ''])), null, $reset) - . '/' . $id_key . '/%s'; - } - - - protected function _getUrlForActionAndIdName($action, $id_key = '') { - return $this->_getUrlFor('', $action, $id_key); - } -} -?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ModelActionsTable/Album.php b/library/ZendAfi/View/Helper/ModelActionsTable/Album.php deleted file mode 100644 index 1ec16b98db5..00000000000 --- a/library/ZendAfi/View/Helper/ModelActionsTable/Album.php +++ /dev/null @@ -1,56 +0,0 @@ -<?php -/** - * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. - * - * BOKEH is free software; you can redistribute it and/or modify - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by - * the Free Software Foundation. - * - * There are special exceptions to the terms and conditions of the AGPL as it - * is applied to this software (see README file). - * - * BOKEH is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE - * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -class ZendAfi_View_Helper_ModelActionsTable_Album extends ZendAfi_View_Helper_ModelActionsTable { - - protected function getBaseUrl() { - return ['module' => 'admin', - 'controller' => 'album']; - } - - - public function getActions() { - if(!$this->_model) - return []; - - $actions = [['url' => $this->_getUrlForAction('edit_album'), - 'icon' => 'edit', - 'label' => 'Modifier l\'album'], - - ['url' => $this->_getUrlForAction('edit_images'), - 'icon' => 'images', - 'label' => 'Gérer les médias', - 'caption' => 'formatedCount'], - - ['url' => $this->_getUrlForAction('preview_album'), - 'icon' => function($model) {return $model->isVisible() ? 'view' : 'hide';}, - 'label' => 'Visualisation de l\album'], - - ['url' => $this->_getUrlForAction('delete_album'), - 'icon' => 'delete', - 'label' => 'Supprimer l\'album', - 'anchorOptions' => ['onclick' => 'return confirm(\'' . $this->view->_('Êtes-vous sûr de vouloir supprimer cet album') . ';\')']]]; - - return $this->setActions($actions); - } -} -?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ModelActionsTable/AlbumCategories.php b/library/ZendAfi/View/Helper/ModelActionsTable/AlbumCategories.php deleted file mode 100644 index c0a719d955e..00000000000 --- a/library/ZendAfi/View/Helper/ModelActionsTable/AlbumCategories.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php -/** - * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. - * - * BOKEH is free software; you can redistribute it and/or modify - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by - * the Free Software Foundation. - * - * There are special exceptions to the terms and conditions of the AGPL as it - * is applied to this software (see README file). - * - * BOKEH is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE - * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -class ZendAfi_View_Helper_ModelActionsTable_AlbumCategories extends ZendAfi_View_Helper_ModelActionsTable { - protected function getBaseUrl() { - return ['module' => 'admin', - 'controller' => 'album']; - } - - - public function getActions() { - if (!$this->_model) { - return $this->setActions([ ['url' => $this->_getUrlForAction('add_categorie'), - 'icon' => 'add_category', - 'label' => 'Ajouter une sous-catégorie']]); - } - - $actions = Class_AdminVar::isBibNumEnabled() - ? [['url' => $this->_getUrlForAction('add_categorie_to'), - 'icon' => 'add_category', - 'label' => 'Ajouter une sous-catégorie'], - - ['url' => $this->_getUrlForAction('add_album_to'), - 'icon' => 'add_page', - 'label' => 'Ajouter un album']] - : []; - - $actions = array_merge($actions, - [ ['url' => $this->_getUrlForAction('edit_categorie'), - 'icon' => 'edit', - 'label' => 'Modifier la catégorie'], - - ['url' => $this->_getUrlForAction('delete_categorie'), - 'icon' => 'delete', - 'label' => 'Supprimer la catégorie', - 'anchorOptions' => ['onclick' => "return confirm('Etes-vous sûr de vouloir supprimer cette catégorie ?')"]], - [ - 'url' => $this->_getUrlFor('album', 'add-model-to-selection', 'select_id_cat', true), - 'icon' => 'basket', - 'label' => 'sélectionner la catégorie', - 'condition' => function($model) { - return !Class_MultiSelection_Album::isCategorySelected($model->getId()); - }], - [ - 'url' => $this->_getUrlFor('album', 'remove-model-from-selection', 'select_id_cat', true), - 'icon' => 'cancel', - 'label' => 'Désélectionner la catégorie', - 'condition' => function($model) { - return Class_MultiSelection_Album::isCategorySelected($model->getId()); - }]]); - return $this->setActions($actions); - } -} -?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ModelActionsTable/Article.php b/library/ZendAfi/View/Helper/ModelActionsTable/Article.php deleted file mode 100644 index 517d8c514ce..00000000000 --- a/library/ZendAfi/View/Helper/ModelActionsTable/Article.php +++ /dev/null @@ -1,76 +0,0 @@ -<?php -/** - * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. - * - * BOKEH is free software; you can redistribute it and/or modify - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by - * the Free Software Foundation. - * - * There are special exceptions to the terms and conditions of the AGPL as it - * is applied to this software (see README file). - * - * BOKEH is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE - * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -class ZendAfi_View_Helper_ModelActionsTable_Article extends ZendAfi_View_Helper_ModelActionsTable { - protected $identity; - - - protected function getBaseUrl() { - return ['module' => 'admin', - 'controller' => 'cms']; - } - - - public function getActions() { - $this->identity = Class_Users::getIdentity(); - - $permission_closure = function($model) { - return $this->identity - ->hasAnyPermissionOn($model->getCategorie(), - [Class_Permission::createArticle(), - Class_Permission::createArticleCategory()]); - }; - - $actions[] = [ - 'url' => $this->_getUrlForAction('makeinvisible'), - 'icon' => 'show', - 'label' => 'Rendre cet article invisible', - 'condition' => function($model) use ($permission_closure) { - return $permission_closure($model) && $model->isVisible(); - }]; - - $actions[] = [ - 'url' => $this->_getUrlForAction('makevisible'), - 'icon' => 'hide', - 'label' => 'Rendre cet article visible', - 'condition' => function($model) use ($permission_closure) { - return $permission_closure($model) && $model->isNotVisible(); - }]; - - $actions[] = ['url' => $this->_getUrlForAction('edit'), - 'icon' => 'edit', - 'label' => 'Modifier', - 'condition' => $permission_closure]; - - $actions[] = ['url' => $this->_getUrlForAction('newsduplicate'), - 'icon' => 'copy', - 'label' => 'Dupliquer', - 'condition' => $permission_closure]; - - $actions[] = ['url' => $this->_getUrlForAction('delete'), - 'icon' => 'delete', - 'label' => 'Supprimer', - 'condition' => $permission_closure]; - - return $this->setActions($actions); - } -} -?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ModelActionsTable/ArticlesCategories.php b/library/ZendAfi/View/Helper/ModelActionsTable/ArticlesCategories.php deleted file mode 100644 index 39112defa3c..00000000000 --- a/library/ZendAfi/View/Helper/ModelActionsTable/ArticlesCategories.php +++ /dev/null @@ -1,99 +0,0 @@ -<?php -/** - * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. - * - * BOKEH is free software; you can redistribute it and/or modify - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by - * the Free Software Foundation. - * - * There are special exceptions to the terms and conditions of the AGPL as it - * is applied to this software (see README file). - * - * BOKEH is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE - * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -class ZendAfi_View_Helper_ModelActionsTable_ArticlesCategories extends ZendAfi_View_Helper_ModelActionsTable { - protected $identity; - - protected function getBaseUrl() { - return ['module' => 'admin', - 'controller' => 'cms-category']; - } - - - public function getActions() { - $this->identity = Class_Users::getIdentity(); - $parent_permission = function($model) { - return $this->identity - ->hasParentPermissionOn(Class_Permission::createArticleCategory(), - $model); - }; - $actions[] = ['url' => $this->_getUrlForAction('edit', true), - 'icon' => 'edit', - 'label' => 'Modifier', - 'condition' => $parent_permission]; - - $actions[] = [ - 'url' => $this->_getUrlForAction('delete', true), - 'icon' => 'delete', - 'label' => 'Supprimer', - 'condition' => function($model) use ($parent_permission) { - return $parent_permission($model) && $model->hasNoChild(); - }, - 'anchorOptions' => [ - 'onclick' => "return confirm('Etes-vous sûr de vouloir supprimer cette catégorie ?')"]]; - - - $actions[] = [ - 'url' => $this->_getUrlFor('cms', 'add', 'id_cat', true), - 'icon' => 'add_page', - 'label' => 'Ajouter un article', - 'condition' => function($model) { - return $this->identity - ->hasAnyPermissionOn($model, - [Class_Permission::createArticle(), - Class_Permission::createArticleCategory()]); - }]; - - $actions[] = [ - 'url' => $this->_getUrlForAction('add', true), - 'icon' => 'add_category', - 'label' => 'Ajouter une sous-catégorie', - 'condition' => function($model) { - return $this->identity - ->hasPermissionOn(Class_Permission::createArticleCategory(), - $model); - }]; - - $actions[] = [ - 'url' => $this->_getUrlFor('cms', 'add-model-to-selection', 'select_id_cat', true), - 'icon' => 'basket', - 'label' => 'sélectionner la catégorie', - 'condition' => function($model) { - return $this->identity - ->hasPermissionOn(Class_Permission::createArticleCategory(), - $model) && (!Class_MultiSelection_Article::isCategorySelected($model->getId())); - }]; - - $actions[] = [ - 'url' => $this->_getUrlFor('cms', 'remove-model-from-selection', 'select_id_cat', true), - 'icon' => 'cancel', - 'label' => 'Désélectionner la catégorie', - 'condition' => function($model) { - return $this->identity - ->hasPermissionOn(Class_Permission::createArticleCategory(), - $model) && (Class_MultiSelection_Article::isCategorySelected($model->getId())); - }]; - - return $this->setActions($actions); - } -} -?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/ModelActionsTable/Bib.php b/library/ZendAfi/View/Helper/ModelActionsTable/Bib.php deleted file mode 100644 index 4ea50937529..00000000000 --- a/library/ZendAfi/View/Helper/ModelActionsTable/Bib.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php -/** - * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. - * - * BOKEH is free software; you can redistribute it and/or modify - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by - * the Free Software Foundation. - * - * There are special exceptions to the terms and conditions of the AGPL as it - * is applied to this software (see README file). - * - * BOKEH is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE - * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -class ZendAfi_View_Helper_ModelActionsTable_Bib extends ZendAfi_View_Helper_ModelActionsTable { - protected $_identity; - - protected function getBaseUrl() { - return ['module' => 'admin', - 'controller' => 'cms-category']; - } - - - public function getActions() { - $this->_identity = Class_Users::getIdentity(); - $actions = []; - $actions[] = ['url' => $this->_getUrlForActionAndIdName('add', 'id_bib'), - 'icon' => 'add_category', - 'label' => $this->_('Ajouter une catégorie'), - 'condition' => function($model) { - return $this->_identity->isRoleMoreThanModoPortail() - || $this->_identity->hasPermissionOn(Class_Permission::createArticleCategory(), - $model); - }]; - - $actions[] = ['url' => $this->_getUrlFor('bib', 'permissions'), - 'icon' => 'groups', - 'label' => $this->_('Permissions par défaut'), - 'condition' => function($model) { - return $this->_identity->isRoleMoreThanModoPortail(); - }]; - - return $this->setActions($actions); - } - - - protected function _getUrlForAction($actions, $reset = false) { - return $actions; - } -} -?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Plugin/MultiSelection/Widget.php b/library/ZendAfi/View/Helper/Plugin/MultiSelection/Widget.php index 6906fedb466..8e0ab82c494 100644 --- a/library/ZendAfi/View/Helper/Plugin/MultiSelection/Widget.php +++ b/library/ZendAfi/View/Helper/Plugin/MultiSelection/Widget.php @@ -29,7 +29,7 @@ class ZendAfi_View_Helper_Plugin_MultiSelection_Widget extends ZendAfi_View_Help if(0 == count($multi_selection->getModels())) return ''; - $multi_selection->acceptVisitor($this); + $multi_selection->acceptWidgetVisitor($this); return $this->_render(); } @@ -91,17 +91,6 @@ class ZendAfi_View_Helper_Plugin_MultiSelection_Widget extends ZendAfi_View_Help } - public function visitWidget($multi_selection) { - $multi_selection->acceptWidgetVisitor($this); - return $this; - } - - - public function visitActions($multi_selection) { - return $this; - } - - public function visitTitle($title) { $this->_title = $title; return $this; diff --git a/library/ZendAfi/View/Helper/TreeView.php b/library/ZendAfi/View/Helper/TreeView.php index 8599efacdf1..d75f5412823 100644 --- a/library/ZendAfi/View/Helper/TreeView.php +++ b/library/ZendAfi/View/Helper/TreeView.php @@ -23,12 +23,6 @@ class ZendAfi_View_Helper_TreeView extends Zend_View_Helper_Abstract { const NODE_CONTAINER = 'container'; const NODE_ITEM = 'item'; - /** @var array */ - protected $_containerActions; - - /** @var array */ - protected $_itemActions; - /** @var Abstract_TreeViewRenderItem */ protected $_item_render_strategy; @@ -46,13 +40,9 @@ class ZendAfi_View_Helper_TreeView extends Zend_View_Helper_Abstract { * @param array $containerActions * @return string */ - public function treeView(array $elements, - array $containerActions = [], - array $itemActions = [], + public function treeView($elements, $withWorkflow = true, $containers_filter = null) { - $this->_containerActions = $containerActions; - $this->_itemActions = $itemActions; $this->_is_workflow = $withWorkflow && Class_AdminVar::isWorkflowEnabled(); $this->_containers_filter = $containers_filter; -- GitLab