diff --git a/application/modules/admin/controllers/SectionBrowserController.php b/application/modules/admin/controllers/SectionBrowserController.php new file mode 100644 index 0000000000000000000000000000000000000000..bab89876c2195ba2ed7add0cc8539ae4a7d4d580 --- /dev/null +++ b/application/modules/admin/controllers/SectionBrowserController.php @@ -0,0 +1,27 @@ +<?php +/** + * Copyright (c) 2012-2017, 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 Admin_SectionBrowserController extends ZendAfi_Controller_Action { + public function getPlugins() { + return ['ZendAfi_Controller_Plugin_ResourceDefinition_Section']; + } +} \ No newline at end of file diff --git a/cosmogramme/cosmozend/application/modules/cosmo/controllers/SectionController.php b/cosmogramme/cosmozend/application/modules/cosmo/controllers/SectionController.php index 12e8d870e21e0d39c14eaada2d032c2044bbf422..020c64a76ac82ce77464bef993cb142c51b098d5 100644 --- a/cosmogramme/cosmozend/application/modules/cosmo/controllers/SectionController.php +++ b/cosmogramme/cosmozend/application/modules/cosmo/controllers/SectionController.php @@ -25,5 +25,4 @@ class Cosmo_SectionController extends ZendAfi_Controller_Action { return ['ZendAfi_Controller_Plugin_ResourceDefinition_Section', 'ZendAfi_Controller_Plugin_Manager_Section']; } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/library/Class/CodifSection.php b/library/Class/CodifSection.php index 44668b6b3ea1bd3028d23525273724d140732023..455b21229d81e84bd8946a5fc5f5e0247fddb68a 100644 --- a/library/Class/CodifSection.php +++ b/library/Class/CodifSection.php @@ -56,4 +56,9 @@ class Class_CodifSection extends Storm_Model_Abstract { protected $_table_primary = 'id_section'; protected $_default_attribute_values = ['invisible' => 0]; -} + + + public function getCategorie() { + return; + } +} \ No newline at end of file diff --git a/library/ZendAfi/Controller/Action/Helper/CodificationListViewMode.php b/library/ZendAfi/Controller/Action/Helper/CodificationListViewMode.php index 9381c4b6aa988ebf4250cf1b1cbefb79f7153449..c6c46cc56c2c3e649b335d2dadce6910cbf61208 100644 --- a/library/ZendAfi/Controller/Action/Helper/CodificationListViewMode.php +++ b/library/ZendAfi/Controller/Action/Helper/CodificationListViewMode.php @@ -31,15 +31,23 @@ class ZendAfi_Controller_Action_Helper_CodificationListViewMode $this->_categories = [(new Class_CodifAnnexe) ->setLibelle($this->_('Annexes')) ->setController('site-browser'), + (new Class_CodifAuteur) ->setLibelle($this->_('Auteurs')) ->setController('author-browser'), + (new Class_CodifEmplacement) ->setLibelle($this->_('Emplacements')) ->setController('location-browser'), + (new Class_CodifLangue) ->setLibelle($this->_('Langues')) ->setController('language-browser'), + + (new Class_CodifSection) + ->setLibelle($this->_('Sections')) + ->setController('section-browser'), + (new Class_CodifThesaurus) ->setLibelle($this->_('Thesaurus')) ->setController('thesauri')]; diff --git a/library/ZendAfi/Controller/Action/Helper/SectionListViewMode.php b/library/ZendAfi/Controller/Action/Helper/SectionListViewMode.php new file mode 100644 index 0000000000000000000000000000000000000000..22a1ed2a55838774d295d1e2da258d834f9c185f --- /dev/null +++ b/library/ZendAfi/Controller/Action/Helper/SectionListViewMode.php @@ -0,0 +1,117 @@ +<?php +/** + * Copyright (c) 2012-2017, 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_Controller_Action_Helper_SectionListViewMode + extends ZendAfi_Controller_Action_Helper_AbstractListViewMode { + + + public function sectionListViewMode($params) { + $this->_params = $params; + return $this; + } + + + public function direct($params) { + return $this->sectionListViewMode($params); + } + + + protected function _describeCategoriesIn($description) { + return $description; + } + + + protected function _describeItemsIn($description) { + return $description + ->addColumn($this->_('Libellé'), ['attribute' => 'libelle', + 'callback' => function($model, $attrib) + { + return $this->_renderItem($model, $attrib); + }]) + ->addColumn($this->_('Code facette'), ['attribute' => 'facet_code', + 'sort_attribute' => 'id_section']) + ->setSorterServer(); + } + + + public function getBreadcrumb() { + return [['url' => ['module' => 'admin', + 'controller' => 'codification-browser', + 'action' => 'index'], + 'label' => $this->_('Racine'), + 'options' => []], + + ['url' => ['module' => 'admin', + 'controller' => 'section-browser', + 'action' => 'index'], + 'label' => $this->_('Sections'), + 'options' => []]]; + } + + + public function getBaseUrl() { + return ['module' => 'admin', + 'controller' => 'section-browser', + 'action' => 'index']; + } + + + public function getItems() { + $default_params = ['limitPage' => [$this->getPage(), $this->_items_by_page], + 'order' => $this->getOrder()]; + + $params = $this->isSearching() + ? $this->getSearchParams() + : []; + + return Class_CodifSection::findAllBy(array_merge($params, $default_params)); + } + + + public function getSearchColumns() { + return ['libelle', + 'id_section']; + } + + + protected function enabledSorter() { + return false; + } + + + public function countItemsFor($model) { + return Class_CodifSection::count(); + } + + + public function getCountSearchResult() { + $params = array_merge($this->getItemsParams(), + $this->getSearchParams()); + unset($params['limitPage']); + return Class_CodifSection::countBy($params); + } + + + public function getOrder() { + return $this->getParam('order', 'libelle'); + } +} \ No newline at end of file diff --git a/library/ZendAfi/Controller/Plugin/Manager/Section.php b/library/ZendAfi/Controller/Plugin/Manager/Section.php index f9b4ade6e03f306733c100a8a974e9a86f197454..2d6b5f38e7b5f8580c098db7f034281fb076083f 100644 --- a/library/ZendAfi/Controller/Plugin/Manager/Section.php +++ b/library/ZendAfi/Controller/Plugin/Manager/Section.php @@ -32,5 +32,4 @@ class ZendAfi_Controller_Plugin_Manager_Section extends ZendAfi_Controller_Plugi 'icon' => 'delete', 'label' => $this->_('Supprimer')]]; } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/library/ZendAfi/Controller/Plugin/ResourceDefinition/Abstract.php b/library/ZendAfi/Controller/Plugin/ResourceDefinition/Abstract.php index ba5a03a9fc4353a48f1b094ad6128a2b638042e1..22cb953b84a990bed6f433a7ecbf8d1833bce545 100644 --- a/library/ZendAfi/Controller/Plugin/ResourceDefinition/Abstract.php +++ b/library/ZendAfi/Controller/Plugin/ResourceDefinition/Abstract.php @@ -315,7 +315,9 @@ abstract class ZendAfi_Controller_Plugin_ResourceDefinition_Abstract extends Zen protected function _isListViewModeEnabled() { - return isset($this->_attribs['listViewMode']) && $this->_attribs['listViewMode']; + return isset($this->_attribs['listViewMode']) + && $this->_attribs['listViewMode'] + && ('cosmo' != $this->_request->getModuleName()); } diff --git a/library/ZendAfi/Controller/Plugin/ResourceDefinition/Section.php b/library/ZendAfi/Controller/Plugin/ResourceDefinition/Section.php index a9000b9070dd46d67a4c1a7b4b0fa277eed0c72c..a4ad419222ad35ca931cf53a6648a78371ae32ae 100644 --- a/library/ZendAfi/Controller/Plugin/ResourceDefinition/Section.php +++ b/library/ZendAfi/Controller/Plugin/ResourceDefinition/Section.php @@ -28,11 +28,31 @@ class ZendAfi_Controller_Plugin_ResourceDefinition_Section extends ZendAfi_Contr 'order' => 'libelle', 'model_id' => 'id_section'], + 'listViewMode' => ['helper_method' => 'sectionListViewMode'], + 'messages' => ['successful_save' => $this->_('La section "%s" a été modifée'), 'successful_add' => $this->_('La section "%s" a été ajoutée'), 'successful_delete' => $this->_('La section "%s" a été suppriméee')], 'form_class_name' => 'ZendAfi_Form_Admin_Section']; } -} -?> \ No newline at end of file + + + public function getActions($model) { + if( (!$model) || ('cosmo' == $this->_request->getModuleName())) + return []; + + return [ + ['url' => $this->_view->url(['module' => 'opac', + 'controller' => 'recherche', + 'action' => 'simple', + 'facette' => $model->getFacetCode() + ], + null, + true), + 'icon' => 'view', + 'label' => $this->_('Voir les documents qui ont la facette "%s"',$model->getFacetCode()), + 'anchorOptions' => ['target' => '_blank'] + ]]; + } +} \ No newline at end of file diff --git a/tests/scenarios/CodificationBrowser/CodificationBrowserTest.php b/tests/scenarios/CodificationBrowser/CodificationBrowserTest.php index 21ac4785335cb0ef978459bdc23e2a37fdd67f3d..a82df21899d9d38f89463d29920fa8dbb920e61f 100644 --- a/tests/scenarios/CodificationBrowser/CodificationBrowserTest.php +++ b/tests/scenarios/CodificationBrowser/CodificationBrowserTest.php @@ -36,7 +36,8 @@ class CodificationBrowserIndexDispatchTest extends Admin_AbstractControllerTestC ['author-browser', 'Auteurs'], ['location-browser', 'Emplacements'], ['site-browser', 'Annexes'], - ['language-browser', 'Langues']]; + ['language-browser', 'Langues'], + ['section-browser', 'Sections']]; } @@ -141,5 +142,14 @@ class CodificationBrowserLanguageSimpleIndexTest extends CodificationBrowserSimp protected $_controller = 'language-browser', $_model = 'Class_CodifLangue', - $_attribs = ['id' => 6, 'libelle' => 'MySuperLangue', 'regles' => '784$v=TOTO']; + $_attribs = ['id' => 6, 'libelle' => 'MySuperLangue']; +} + + + +class CodificationBrowserSectionSimpleIndexTest extends CodificationBrowserSimpleIndexTestCase { + protected + $_controller = 'section-browser', + $_model = 'Class_CodifSection', + $_attribs = ['id' => 6, 'libelle' => 'MySuperSection', 'regles' => '784$v=TOTO']; }