Commit 9f22eb1e authored by Ghislain Loas's avatar Ghislain Loas

Merge branch 'dev#75742_amelioration_de_la_visibilite_des_thesaurus' into 'master'

Dev#75742 amelioration de la visibilite des thesaurus

See merge request afi/opacce!2682
parents b573d8cc d9eb2c89
- ticket #75742 : amélioration de la visibilité des thesaurus
\ No newline at end of file
......@@ -158,46 +158,6 @@ class Admin_SystemeController extends Zend_Controller_Action {
}
public function updatethesaurusAction() {
$this->view->titre = $this->_('Mise à jour des thesauri');
$group=[];
$form = $this->view->newForm(['id' => 'updatethesaurus']);
foreach (Class_CodifThesaurus::getIndices('root',true) as $thesaurus) {
$form->addElement('text',
'libelle' . $thesaurus->getId(),
['label' => $thesaurus->getCode(),
'size' => 50,
'id' => $thesaurus->getId(),
'required' => true,
'allowEmpty' => false,
'value' => $thesaurus->getLibelleFacette()]);
$group[] = 'libelle' . $thesaurus->getId();
}
$form
->addDisplayGroup($group, 'thesaurus', ['legend' => 'Général'])
->addElement('submit', 'send', ['label' => 'Enregistrer']);
if ($this->_request->isPost()
&& $form->isValid($this->_request->getPost())) {
foreach (Class_CodifThesaurus::getIndices('root', true) as $thesaurus) {
if ($newlibelle=$this->_request->getPost("libelle" . $thesaurus->getId())) {
$thesaurus=Class_CodifThesaurus::find($thesaurus->getId());
$thesaurus->setLibelleFacette($newlibelle);
$thesaurus->save();
}
}
$this->view->message = $this->_('Les libellés ont été mis à jour');
}
$this->view->form = $form;
}
public function importthesaurusAction() {
$this->view->titre = $this->_('Importation d\'un thesaurus');
......
<?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_ThesauriController extends ZendAfi_Controller_Action {
public function getPlugins() {
return ['ZendAfi_Controller_Plugin_ResourceDefinition_Thesauri',
'ZendAfi_Controller_Plugin_Manager_Thesauri'];
}
public function indexAction() {
parent::indexAction();
if($this->_request->isPost())
return $this->_redirectToRefererWithNewParams(['title_search' => $this->_getPost()['title_search'],
'page' => $this->_getParam('page', 1),
'order' => $this->_getParam('order', 'libelle')]);
$thesauri = $this->_getParam('parent_id')
? Class_CodifThesaurus::find($this->_getParam('parent_id'))
: Class_CodifThesaurus::root();
$this->view->list = $this->_helper
->thesauriListViewMode(['model' => $thesauri,
'order' => $this->_getParam('order'),
'page' => $this->_getParam('page', 0),
'search_value' => $this->_getParam('title_search', '')]);
return $this->renderScript('admin/listViewMode.phtml');
}
}
\ No newline at end of file
<?php
echo $this->renderForm($this->form);
......@@ -362,7 +362,9 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
'STATUS_REPORT_TAGS' => Class_AdminVar_Meta::newMultiInput($this->_('Liste des tags à ajouter au rapport d\'état du système'))->bePrivate(),
'FEATURES_TRACKING_ENABLE' => Class_AdminVar_Meta::newOnOff('Affiche les dernières modifications apportés au logiciel Bokeh', ['value' => 1])->bePrivate(),
'INSPECTOR_GADGET_MARC_XML' => Class_AdminVar_Meta::newOnOff('Affiche le MARC XML de la notice dans Inspector Gadget')->bePrivate(),
'BUSINESS_EMAIL' => Class_AdminVar_Meta::newDefault($this->_('Email utilisé pour les demandes d\'accompagnement de mise en place ou d\'utilisation des fonctionnalités du logiciel'), ['value' => 'cial-bib@afi-sa.fr'])->bePrivate()
'BUSINESS_EMAIL' => Class_AdminVar_Meta::newDefault($this->_('Email utilisé pour les demandes d\'accompagnement de mise en place ou d\'utilisation des fonctionnalités du logiciel'), ['value' => 'cial-bib@afi-sa.fr'])->bePrivate(),
'THESAURI_BROWSER' => Class_AdminVar_Meta::newOnOff($this->_('Activer l\'outil de parcours des Thesaurus'))
->bePrivate()
];
}
......@@ -898,6 +900,11 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
}
public static function isThesauriBrowserEnabled() {
return Class_AdminVar::isModuleEnabled('THESAURI_BROWSER');
}
public function getBabelthequeId() {
$mathes = [];
if (preg_match('/bw_([^\.]+)\.js/', (string)Class_AdminVar::get('BABELTHEQUE_JS'), $matches))
......
......@@ -131,6 +131,27 @@ class CodifThesaurusLoader extends Storm_Model_Loader {
}
public function countChildrenOf($id_thesaurus) {
$where = sprintf('id_thesaurus like "%s%%" and LENGTH(id_thesaurus) > %s',
$id_thesaurus,
strlen($id_thesaurus));
return Class_CodifThesaurus::countBy(['where' => $where]);
}
public function findChildrenOfWith($id_thesaurus, $page, $items_by_page, $order) {
$where = sprintf('id_thesaurus like "%s%%" and LENGTH(id_thesaurus) = %s',
$id_thesaurus,
(strlen($id_thesaurus) + 4));
return Class_CodifThesaurus::findAllBy(['where' => $where,
'limitPage' => [$page,
$items_by_page],
'order' => $order]);
}
public function findRootOfId($id, $code, $label) {
if ($codif = Class_CodifThesaurus::findFirstBy(['id_thesaurus' => $id]))
return $codif;
......@@ -425,6 +446,11 @@ class CodifThesaurusLoader extends Storm_Model_Loader {
return array_unique($params);
}
public function root() {
return Class_CodifThesaurus::newInstance();
}
}
......@@ -444,7 +470,8 @@ class Class_CodifThesaurus extends Storm_Model_Abstract {
protected $_loader_class = 'CodifThesaurusLoader';
protected $_table_name = 'codif_thesaurus';
protected $_table_primary = 'id';
protected $_default_attribute_values = ['libelle_facette' => '',
protected $_default_attribute_values = ['libelle' => '',
'libelle_facette' => '',
'id_thesaurus' =>null,
'id_origine' => null,
'rules' => null,
......@@ -502,7 +529,12 @@ class Class_CodifThesaurus extends Storm_Model_Abstract {
public function getRulesLabel() {
return json_decode($this->getRules())->label;
if(!$rules = $this->getRules())
return '';
$json = json_decode($rules);
return $json ? $json->label : '';
}
......@@ -540,6 +572,7 @@ class Class_CodifThesaurus extends Storm_Model_Abstract {
public function cleanRecords() {
$facets = [];
foreach($this->getLoader()->findChildrenOf($this) as $child)
$facets[] = $child->getFacetteIndex();
......@@ -570,4 +603,49 @@ class Class_CodifThesaurus extends Storm_Model_Abstract {
public function getChildren() {
return $this->getLoader()->findChildrenOf($this);
}
public function getParentChildren() {
return array_filter($this->getChildren(),
function ($children)
{
return ($children->hasChildren());
});
}
public function getChildrenItems() {
return array_filter($this->getChildren(),
function ($children)
{
return (!$children->hasChildren());
});
}
public function getParent() {
return $this->getLoader()->findParent($this->getIdThesaurus());
}
public function getParentId() {
return $this->getParent()
? $this->getParent()->getId()
: null;
}
public function getTitre() {
return $this->getLibelleFacette();
}
public function numberOfChildrens() {
return $this->getLoader()->countChildrenOf($this->getIdThesaurus());
}
public function isNotRoot() {
return strlen($this->getIdThesaurus()) > Class_CodifThesaurus::ID_KEY_LENGTH;
}
}
\ No newline at end of file
......@@ -66,7 +66,8 @@ class ZendAfi_Acl_AdminControllerGroup {
'i18n' => Class_AdminVar::isTranslationEnabled(),
'stat/piwik' => (new Class_AdminVar_Piwik())->isEnabled(),
'multimedia' => Class_AdminVar::isMultimediaEnabled(),
'search-form' => Class_AdminVar::isCustomSearchFormEnabled()];
'search-form' => Class_AdminVar::isCustomSearchFormEnabled(),
'thesauri' => Class_AdminVar::isThesauriBrowserEnabled()];
}
......
......@@ -94,6 +94,7 @@ class ZendAfi_Acl_AdminControllerRoles extends Zend_Acl {
$this->add(new Zend_Acl_Resource('batch'));
$this->add(new Zend_Acl_Resource('file-manager'));
$this->add(new Zend_Acl_Resource('search-form'));
$this->add(new Zend_Acl_Resource('thesauri'));
//Roles
$this->addRole(new Zend_Acl_Role('invite'));
......@@ -148,6 +149,7 @@ class ZendAfi_Acl_AdminControllerRoles extends Zend_Acl {
$this->allow('admin_bib','menus');
$this->allow('admin_bib','external-agendas');
$this->allow('admin_bib','search-form');
$this->allow('admin_bib','thesauri');
$this->deny('modo_portail','catalogue');
$this->deny('modo_portail','rss');
......@@ -168,6 +170,7 @@ class ZendAfi_Acl_AdminControllerRoles extends Zend_Acl {
$this->deny('modo_portail','systeme');
$this->deny('modo_portail','batch');
$this->deny('modo_portail','search-form');
$this->deny('modo_portail','thesauri');
$this->allow('modo_portail');
$this->allow('admin_portail');
......
......@@ -42,14 +42,24 @@ abstract class ZendAfi_Controller_Action_Helper_AbstractListViewMode extends Zen
public function render($view, $callback) {
return $view->tagModelTable($this->getItems(),
$this->getItemsCols($view),
$this->getItemsAttribs(),
$this->getItemsAttribs(),
[function($model) use ($view)
{
return $view->renderPluginsActions($model);
}],
$this->getItemsId(),
$this->getItemsGroupBy(),
$this->isSearching() ? [$this->getItemsLabelAttrib() => $callback] : []);
{
return $view->renderPluginsActions($model);
}],
$this->getItemsId(),
$this->getItemsGroupBy(),
$this->isSearching() ? [$this->getItemsLabelAttrib() => $callback] : [], $this->enabledPager(), $this->enabledSorter());
}
protected function enabledPager() {
return false;
}
protected function enabledSorter() {
return true;
}
......@@ -147,9 +157,21 @@ abstract class ZendAfi_Controller_Action_Helper_AbstractListViewMode extends Zen
}
public function getSearchColumns() {
return ['titre'];
}
public function getSearchParams() {
return ['where' => 'titre like ' . Zend_Db_Table::getDefaultAdapter()->quote('%' . $this->getSearch() . '%') ,
'order' => 'titre'];
$search_param = Zend_Db_Table::getDefaultAdapter()->quote('%' . $this->getSearch() . '%');
$columns = $this->getSearchColumns();
$where = [];
foreach ($columns as $col)
$where [] = '('.$col.' like '.$search_param.')';
return ['where' => implode(' or ', $where),
'order' => $this->getOrder()];
}
......@@ -308,7 +330,7 @@ abstract class ZendAfi_Controller_Action_Helper_AbstractListViewMode extends Zen
->setText($this->_form_settings->getSearchText())
->setImage($view->tagImg(Class_Admin_Skin::current()
->getIconUrl('actions',
'loupe'),
'loupe'),
['style' => 'filter: invert();']))
->setAttribs(['onclick' => "var form=$(this).parents('form'); if (!form.length) form=$(this).parents('.boutons, .admin-buttons').prevAll('form');if (!form.length) form=$(this).parents('.boutons, .admin-buttons').nextAll('form');form.submit(); return false;",
'type' => 'submit',
......@@ -321,6 +343,21 @@ abstract class ZendAfi_Controller_Action_Helper_AbstractListViewMode extends Zen
}
public function getCategoriesCols() {
return [''];
}
public function getItemsCols($view) {
return [''];
}
public function getOrder() {
return $this->getParam('order', 'titre');
}
protected function _getSearchForm($view) {
return (new ZendAfi_Form())
->setAction($view->url(array_filter($this->getSearchUrl()), null, true))
......
......@@ -128,7 +128,7 @@ class ZendAfi_Controller_Action_Helper_AlbumListViewMode extends ZendAfi_Control
}
public function getItemsCols() {
public function getItemsCols($view) {
return [$this->_('Liste des albums')];
}
......
<?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_ThesauriListViewMode extends ZendAfi_Controller_Action_Helper_AbstractListViewMode {
public function thesauriListViewMode($params) {
$this->_params = $params;
return $this;
}
public function direct($params) {
return $this->thesauriListViewMode($params);
}
protected function enabledSorter() {
return false;
}
public function getBaseUrl() {
return ['module' => 'admin',
'controller' => 'thesauri'];
}
public function getParamKey() {
return 'parent_id';
}
public function getBreadcrumb() {
$breadcrumb = [['url' => ['module' => 'admin',
'controller' => 'thesauri',
'action' => 'index'],
'label' => $this->_('Racine'),
'options' => []]];
if($this->getModel()->isNew())
return $breadcrumb;
return array_merge($breadcrumb,
$this->getBreadcrumbFor($this->getModel()));
}
public function getCategories() {
$model = $this->getModel();
if($model->isNew())
return Class_CodifThesaurus::getIndices('root',true);
return $model->getParentChildren();
}
public function getItems() {
$model = $this->getModel();
if ($this->isSearching())
return Class_CodifThesaurus::findAllBy($this->getItemsParams());
if($model->isNew())
return [];
return Class_CodifThesaurus::findChildrenOfWith($model->getIdThesaurus(),
$this->getPage(),
$this->_items_by_page,
$this->getOrder());
}
public function countItemsFor($model) {
return count($model->getChildrenItems());
}
public function countItemsInTreeFrom($model) {
return $model->isNew()
? 0
: $model->numberOfChildrens();
}
public function getItemsCols($view) {
$order = $this->getOrder();
$anchor_wrapper = function($key, $label) use ($view, $order) {
$order_param = $key;
if((0 === strpos($order, $key)) && (false === strpos($order, 'desc')))
$order_param .= ' desc';
$data_order = (false === strpos($order, $key))
? ''
: str_replace(' ', '_', 'order_' . $order_param);
$url = ['order' => $order_param,
'page' => null];
return $view->tagAnchor($url, $label, ['data-order' => $data_order]);
};
$cols = [$anchor_wrapper('libelle', $this->_('Thesaurus')),
$anchor_wrapper('libelle_facette', $this->_('Libellé facette')),
$anchor_wrapper('code', $this->_('Code')),
$anchor_wrapper('id_thesaurus', $this->_('ID Thesaurus')),
$anchor_wrapper('rules_label', $this->_('Règle'))];
return $cols;
}
public function getCategoriesCols() {
return [$this->_('Thesaurus'),
$this->_('Libellé facette'),
$this->_('Code'),
$this->_('ID Thesaurus'),
$this->_('Règle')];
}
public function getItemsAttribs() {
return $this->getCategoriesAttribs();
}
public function getCategoriesAttribs() {
return ['libelle',
'libelle_facette',
'code',
'id_thesaurus',
'rules_label'];
}
public function getSearchColumns() {
return ['libelle',
'libelle_facette',
'code',
'id_thesaurus',
'rules'];
}
public function getCountSearchResult() {
$params = $this->getItemsParams();
unset($params['limitPage']);
return Class_CodifThesaurus::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_Manager_Thesauri extends ZendAfi_Controller_Plugin_Manager_Manager {
public function getActions($model) {
if(!$model)
return [];
return [
['url' => $this->_view->url(['module' => 'admin',
'controller' => 'thesauri',
'action' => 'index',
'parent_id' => $model->getParentId(),