Skip to content
Snippets Groups Projects
Commit 9e2f946e authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

dev #75882 add codif domain

parent 01cdc0e9
Branches
Tags
3 merge requests!2711Dev#75882 minsoc faire des filtres sur des facettes et des domaines au moment de la recherche s2,!2707Tessadoc lost pass,!2699Dev#75882 minsoc faire des filtres sur des facettes et des domaines au moment de la recherche s2
Pipeline #4380 passed with stage
in 36 minutes and 3 seconds
<?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_DomainBrowserController extends ZendAfi_Controller_Action {
public function getPlugins() {
return ['ZendAfi_Controller_Plugin_ResourceDefinition_Domain'];
}
}
\ No newline at end of file
......@@ -603,12 +603,27 @@ class CatalogueLoader extends Storm_Model_Loader {
foreach($sous_domaines as $sous_domaine)
$this->addCataloguePathAndChildrenTo($sous_domaine, $liste);
}
public function findParentChildrenOf($model) {
if ($model->isNew())
return array_filter(Class_Catalogue::findTopCatalogues(),
[$this, '_isParent']);
$children = $model->getSousDomaines();
return array_filter($children, [$this, '_isParent']);
}
protected function _isParent($model) {
return $model->hasSousDomaines();
}
}
class Class_Catalogue extends Storm_Model_Abstract {
use Trait_TreeNode, Trait_Translator, Trait_CustomFields;
use Trait_TreeNode, Trait_Translator, Trait_CustomFields, Trait_Facetable;
const CODE_FACETTE = 'Q';
......@@ -696,7 +711,7 @@ class Class_Catalogue extends Storm_Model_Abstract {
public function getFacette() {
return self::CODE_FACETTE . $this->getId();
return $this->getFacetCode();
}
......@@ -1325,6 +1340,16 @@ class Class_Catalogue extends Storm_Model_Abstract {
public function getTitre() {
return $this->getLibelle();
}
public function getCategorie() {
return $this->getParent();
}
public function getParentChildren() {
return Class_Catalogue::getLoader()->findParentChildrenOf($this);
}
}
......
......@@ -36,6 +36,10 @@ class ZendAfi_Controller_Action_Helper_CodificationListViewMode
->setLibelle($this->_('Auteurs'))
->setController('author-browser'),
(new Class_Catalogue)
->setLibelle($this->_('Domaines pour sélections'))
->setController('domain-browser'),
(new Class_CodifEmplacement)
->setLibelle($this->_('Emplacements'))
->setController('location-browser'),
......
<?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_DomainListViewMode
extends ZendAfi_Controller_Action_Helper_AbstractListViewMode {
public function domainListViewMode($params) {
$this->_params = $params;
return $this;
}
public function direct($params) {
return $this->domainListViewMode($params);
}
protected function _describeCategoriesIn($description) {
return $description
->addColumn($this->_('Libellé'), ['attribute' => 'libelle',
'callback' => function($model, $attrib)
{
return $this->_renderCategory($model, $attrib);
}])
->addColumn($this->_('Code facette'), ['attribute' => 'facet_code',
'sort_attribute' => 'id_catalogue'])
;
}
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_catalogue'])
->setSorterServer();
}
public function getBreadcrumb() {
$breadcrumb = [['url' => ['module' => 'admin',
'controller' => 'codification-browser',
'action' => 'index'],
'label' => $this->_('Racine'),
'options' => []],
['url' => ['module' => 'admin',
'controller' => 'domain-browser',
'action' => 'index'],
'label' => $this->_('Domains'),
'options' => []]];
if($this->getModel()->isNew())
return $breadcrumb;
return array_merge($breadcrumb,
$this->getBreadcrumbFor($this->getModel()));
}
public function getBaseUrl() {
return ['module' => 'admin',
'controller' => 'domain-browser',
'action' => 'index'];
}
public function getCategories() {
return $this->getModel()->getParentChildren();
}
public function getItems() {
$default_params = ['limitPage' => [$this->getPage(), $this->_items_by_page],
'order' => $this->getOrder()];
if ($this->isSearching())
return Class_Catalogue::findAllBy(array_merge($this->getSearchParams(), $default_params));
$params = [];
$params['parent_id'] = $this->getModel()->isNew()
? null
: $this->getModel()->getId();
$models = Class_Catalogue::findAllBy(array_merge($params, $default_params));
return array_filter($models,
function($model) { return !$model->hasSousDomaines(); });
}
public function getSearchColumns() {
return ['libelle',
'id_catalogue'];
}
protected function enabledSorter() {
return false;
}
public function countItemsFor($model) {
return $model->numberOfSousDomaines();
}
public function getCountSearchResult() {
$params = array_merge($this->getItemsParams(),
$this->getSearchParams());
unset($params['limitPage']);
return Class_Catalogue::countBy($params);
}
public function getOrder() {
return $this->getParam('order', 'libelle');
}
}
\ No newline at end of file
<?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_Domain
extends ZendAfi_Controller_Plugin_ResourceDefinition_Abstract {
public function getDefinitions() {
return ['model' => ['class' => 'Class_Catalogue',
'name' => 'domain',
'order' => 'libelle'],
'listViewMode' => ['helper_method' => 'domainListViewMode',
'model' => function()
{
return $this->_getParam('id')
? Class_Catalogue::find($this->_getParam('id'))
: new Class_Catalogue;
}]];
}
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
......@@ -37,7 +37,8 @@ class CodificationBrowserIndexDispatchTest extends Admin_AbstractControllerTestC
['location-browser', 'Emplacements'],
['site-browser', 'Annexes'],
['language-browser', 'Langues'],
['section-browser', 'Sections']];
['section-browser', 'Sections'],
['domain-browser', 'Domaines pour sélections']];
}
......@@ -153,3 +154,12 @@ class CodificationBrowserSectionSimpleIndexTest extends CodificationBrowserSimpl
$_model = 'Class_CodifSection',
$_attribs = ['id' => 6, 'libelle' => 'MySuperSection', 'regles' => '784$v=TOTO'];
}
class CodificationBrowserDomainSimpleIndexTest extends CodificationBrowserSimpleIndexTestCase {
protected
$_controller = 'domain-browser',
$_model = 'Class_Catalogue',
$_attribs = ['id' => 6, 'libelle' => 'MySuperDomain'];
}
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