diff --git a/application/modules/admin/controllers/LanguageBrowserController.php b/application/modules/admin/controllers/LanguageBrowserController.php new file mode 100644 index 0000000000000000000000000000000000000000..a2ae025b9e260e93d11597e90be8901df23df6ca --- /dev/null +++ b/application/modules/admin/controllers/LanguageBrowserController.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_LanguageBrowserController extends ZendAfi_Controller_Action { + public function getPlugins() { + return ['ZendAfi_Controller_Plugin_ResourceDefinition_Language']; + } +} \ No newline at end of file diff --git a/library/Class/CodifLangue.php b/library/Class/CodifLangue.php index 20e24c28fc1636e85e2e8e56bb76bf0a23f33cbb..51f2117889f299d742cb4ab7eb2162f4bfe3832d 100644 --- a/library/Class/CodifLangue.php +++ b/library/Class/CodifLangue.php @@ -1,6 +1,6 @@ <?php /** - * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * 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 @@ -16,20 +16,18 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// OPAC3 : Liste des langues dans cosmogramme -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + class Class_CodifLangue extends Storm_Model_Abstract { + use Trait_Facetable; + const CODE_FACETTE = 'L'; + protected $_table_name = 'codif_langue'; protected $_table_primary = 'id_langue'; - public static function getLoader() { - return self::getLoaderFor(__CLASS__); - } /** * @param Array langues @@ -50,6 +48,9 @@ class Class_CodifLangue extends Storm_Model_Abstract { public static function allByIdLibelle() { return self::toIdLibelleArray(self::getLoader()->findAllBy(array('order' => 'libelle'))); } -} -?> + + public function getCategorie() { + return; + } +} diff --git a/library/ZendAfi/Controller/Action/Helper/CodificationListViewMode.php b/library/ZendAfi/Controller/Action/Helper/CodificationListViewMode.php index 18a115aae20eacc6bb30e9b717518c8c8ddfb329..9381c4b6aa988ebf4250cf1b1cbefb79f7153449 100644 --- a/library/ZendAfi/Controller/Action/Helper/CodificationListViewMode.php +++ b/library/ZendAfi/Controller/Action/Helper/CodificationListViewMode.php @@ -37,11 +37,15 @@ class ZendAfi_Controller_Action_Helper_CodificationListViewMode (new Class_CodifEmplacement) ->setLibelle($this->_('Emplacements')) ->setController('location-browser'), + (new Class_CodifLangue) + ->setLibelle($this->_('Langues')) + ->setController('language-browser'), (new Class_CodifThesaurus) ->setLibelle($this->_('Thesaurus')) ->setController('thesauri')]; } + public function codificationListViewMode($params) { $this->_params = $params; return $this; diff --git a/library/ZendAfi/Controller/Action/Helper/LanguageListViewMode.php b/library/ZendAfi/Controller/Action/Helper/LanguageListViewMode.php new file mode 100644 index 0000000000000000000000000000000000000000..cbf75a46b5cdfc55ac164ab76d6a85f4e665c717 --- /dev/null +++ b/library/ZendAfi/Controller/Action/Helper/LanguageListViewMode.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_LanguageListViewMode + extends ZendAfi_Controller_Action_Helper_AbstractListViewMode { + + + public function languageListViewMode($params) { + $this->_params = $params; + return $this; + } + + + public function direct($params) { + return $this->languageListViewMode($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_langue']) + ->setSorterServer(); + } + + + public function getBreadcrumb() { + return [['url' => ['module' => 'admin', + 'controller' => 'codification-browser', + 'action' => 'index'], + 'label' => $this->_('Racine'), + 'options' => []], + + ['url' => ['module' => 'admin', + 'controller' => 'language-browser', + 'action' => 'index'], + 'label' => $this->_('Langues'), + 'options' => []]]; + } + + + public function getBaseUrl() { + return ['module' => 'admin', + 'controller' => 'language-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_CodifLangue::findAllBy(array_merge($params, $default_params)); + } + + + public function getSearchColumns() { + return ['libelle', + 'id_langue']; + } + + + protected function enabledSorter() { + return false; + } + + + public function countItemsFor($model) { + return Class_CodifLangue::count(); + } + + + public function getCountSearchResult() { + $params = array_merge($this->getItemsParams(), + $this->getSearchParams()); + unset($params['limitPage']); + return Class_CodifLangue::countBy($params); + } + + + public function getOrder() { + return $this->getParam('order', 'libelle'); + } +} \ No newline at end of file diff --git a/library/ZendAfi/Controller/Plugin/ResourceDefinition/Language.php b/library/ZendAfi/Controller/Plugin/ResourceDefinition/Language.php new file mode 100644 index 0000000000000000000000000000000000000000..ba817c47d89162874d7012efe8a99f7a8bb9f957 --- /dev/null +++ b/library/ZendAfi/Controller/Plugin/ResourceDefinition/Language.php @@ -0,0 +1,55 @@ +<?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_Plugin_ResourceDefinition_Language + extends ZendAfi_Controller_Plugin_ResourceDefinition_Abstract { + + public function getDefinitions() { + return + ['model' => ['class' => 'Class_CodifLangue', + 'name' => 'langue', + 'order' => 'libelle'], + + 'listViewMode' => ['helper_method' => 'languageListViewMode'], + + 'actions' => ['index' => ['title' => $this->_('Parcourir les langues')]]]; + } + + + public function getActions($model) { + if(!$model) + 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 f7fcab36bef2c033b1b3d496f47a93da91b620c0..21ac4785335cb0ef978459bdc23e2a37fdd67f3d 100644 --- a/tests/scenarios/CodificationBrowser/CodificationBrowserTest.php +++ b/tests/scenarios/CodificationBrowser/CodificationBrowserTest.php @@ -35,7 +35,8 @@ class CodificationBrowserIndexDispatchTest extends Admin_AbstractControllerTestC return [['thesauri', 'Thesaurus'], ['author-browser', 'Auteurs'], ['location-browser', 'Emplacements'], - ['site-browser', 'Annexes']]; + ['site-browser', 'Annexes'], + ['language-browser', 'Langues']]; } @@ -133,3 +134,12 @@ class CodificationBrowserSiteSimpleIndexTest extends CodificationBrowserSimpleIn $_model = 'Class_CodifAnnexe', $_attribs = ['id' => 5, 'libelle' => 'MySuperSite', 'regles' => '784$v=TOTO']; } + + + +class CodificationBrowserLanguageSimpleIndexTest extends CodificationBrowserSimpleIndexTestCase { + protected + $_controller = 'language-browser', + $_model = 'Class_CodifLangue', + $_attribs = ['id' => 6, 'libelle' => 'MySuperLangue', 'regles' => '784$v=TOTO']; +}