diff --git a/VERSIONS b/VERSIONS index efff2543af45c46003279eb3feb0e507a232c7bf..5dc3fb2cfe27efa06eaf03bd8d154631133980fd 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,3 +1,11 @@ +01/07/2019 - v8.0.19 + + - ticket #93469 : Indexation : Ajout d'un script de nettoyage des facettes dynamiques obsolètes + + - ticket #94248 : SIGB VSmart : Mise à jour le l'ip API + + + 24/06/2019 - v8.0.18 - ticket #77694 : Administration : Bokeh permet la suppression d'utilisateurs par lot correspondant aux critères de recherche sélectionnés diff --git a/application/modules/opac/controllers/AbonneController.php b/application/modules/opac/controllers/AbonneController.php index 8be567e89bfbf03ef6eeaad3ba653147bf554c4a..e2cfe91a7c40d9d1fab994277c4427e2c0ca4b70 100644 --- a/application/modules/opac/controllers/AbonneController.php +++ b/application/modules/opac/controllers/AbonneController.php @@ -1,5 +1,4 @@ <?php - /** * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. * @@ -1506,15 +1505,14 @@ class AbonneController extends ZendAfi_Controller_Action { public function selectionAction() { - if (!$this->view->selection = Class_PanierNotice::find($this->_getParam('id'))) { - $this->_helper->notify($this->_('Une erreur c\'est produite.'), ['status' => 'error']); + if (!$this->view->selection = Class_PanierNotice::find($this->_getParam('selection_id'))) { return $this->_redirectClose($this->_getReferer()); } } public function ajouterALaSelectionAction() { - if (!$this->view->selection = Class_PanierNotice::find($this->_getParam('id'))) { + if (!$this->view->selection = Class_PanierNotice::find($this->_getParam('selection_id'))) { $this->_helper->notify($this->_('Une erreur c\'est produite.'), ['status' => 'error']); return $this->_redirectClose($this->_getReferer()); } @@ -1532,28 +1530,54 @@ class AbonneController extends ZendAfi_Controller_Action { public function ajouterLeDocumentALaSelectionAction() { + if(!$this->_user) + return $this->_forward('popup-login', 'auth', 'opac'); + session_write_close(); - $this->getHelper('ViewRenderer')->setNoRender(); - if (!$selection = Class_PanierNotice::find($this->_getParam('id'))) - return $this->_response->setHttpResponseCode(404); + $selection = (($selection = Class_PanierNotice::find($this->_getParam('selection_id'))) + ? $selection + : Class_PanierNotice::findFirstBy(['id_user' => $this->_user->getId(), + 'libelle' => $this->_getParam('selection_label')])); + if (!$selection) { + $this->getHelper('ViewRenderer')->setNoRender(); + return $this->_response->setHttpResponseCode(520); + } - if (!$selection->isMine()) - return $this->_response->setHttpResponseCode(404); + if (!$selection->isMine()) { + $this->getHelper('ViewRenderer')->setNoRender(); + return $this->_response->setHttpResponseCode(520); + } - if (!$record = Class_Notice::find($this->_getParam('record_id'))) - return $this->_response->setHttpResponseCode(404); + if (!$record = Class_Notice::find($this->_getParam('record_id'))) { + $this->getHelper('ViewRenderer')->setNoRender(); + return $this->_response->setHttpResponseCode(520); + } $selection->addNotice($record); $selection->save(); + + $this->_helper->json(['anchor' => $this->view->tagAction((new Intonation_Library_Selection) + ->setView($this->view) + ->setUser($this->_user) + ->setRecord($record) + ->setTitle($this->_getParam('selection_label')) + ->setImage($this->_getParam('image')) + ->setRevertImage($this->_getParam('revert-image')) + ->getAction())]); } public function supprimerDeLaSelectionAction() { $this->view->titre = $this->_('Retirer un document'); - if (!$this->view->selection = Class_PanierNotice::find($this->_getParam('selection_id'))) { + $this->view->selection = (($selection = Class_PanierNotice::find($this->_getParam('selection_id'))) + ? $selection + : Class_PanierNotice::findFirstBy(['id_user' => $this->_user->getId(), + 'libelle' => $this->_getParam('selection_label')])); + + if (!$this->view->selection) { $this->_helper->notify($this->_('Une erreur c\'est produite.'), ['status' => 'error']); return $this->_redirectClose($this->_getReferer()); } @@ -1568,6 +1592,22 @@ class AbonneController extends ZendAfi_Controller_Action { return $this->_redirectClose($this->_getReferer()); } + if ($this->_getParam('ajax')) { + $this->view->selection + ->removeNotice($this->view->record) + ->save(); + + return $this->_helper->json(['anchor' => + $this->view->tagAction((new Intonation_Library_Selection) + ->setView($this->view) + ->setUser($this->_user) + ->setRecord($this->view->record) + ->setTitle($this->_getParam('selection_label')) + ->setImage($this->_getParam('image')) + ->setRevertImage($this->_getParam('revert-image')) + ->getAction())]); + } + if ($this->_getParam('delete')) { $this->view->selection ->removeNotice($this->view->record) @@ -1605,6 +1645,76 @@ class AbonneController extends ZendAfi_Controller_Action { } + public function supprimerLaSelectionAction() { + $this->view->titre = $this->_('Supprimer une sélection'); + + $this->view->selection = (($selection = Class_PanierNotice::find($this->_getParam('selection_id'))) + ? $selection + : Class_PanierNotice::findFirstBy(['id_user' => $this->_user->getId(), + 'libelle' => $this->_getParam('selection_label')])); + + if (!$this->view->selection) { + $this->_helper->notify($this->_('Une erreur c\'est produite.'), ['status' => 'error']); + return $this->_redirectClose($this->_getReferer()); + } + + if (!$this->view->selection->isMine()) { + $this->_helper->notify($this->_('Une erreur c\'est produite.'), ['status' => 'error']); + return $this->_redirectClose($this->_getReferer()); + } + + if ($this->_getParam('delete')) { + $this->view->selection->delete(); + $this->_helper->notify($this->_('La sélection a bien été supprimée'), + ['status' => 'delete']); + return $this->_redirectClose($this->view->url(['action' => 'selections'])); + } + } + + + public function renommerLaSelectionAction() { + $this->view->titre = $this->_('Renommer une sélection'); + + $this->view->selection = (($selection = Class_PanierNotice::find($this->_getParam('selection_id'))) + ? $selection + : Class_PanierNotice::findFirstBy(['id_user' => $this->_user->getId(), + 'libelle' => $this->_getParam('selection_label')])); + + if (!$this->view->selection) { + $this->_helper->notify($this->_('Une erreur c\'est produite.'), ['status' => 'error']); + return $this->_redirectClose($this->_getReferer()); + } + + if (!$this->view->selection->isMine()) { + $this->_helper->notify($this->_('Une erreur c\'est produite.'), ['status' => 'error']); + return $this->_redirectClose($this->_getReferer()); + } + + $this->view->form = new ZendAfi_Form(); + $this->view->form + ->addElement('text', + 'libelle', + ['value' => $this->view->selection->getLibelle(), + 'placeholder' => 'Titre de la sélection']) + ->addUniqDisplayGroup('group') + ->setAction($this->view->url()); + + if(!$this->_request->isPost()) + return; + + $this->view->selection->setLibelle($this->_request->getPost('libelle')); + + if(!$this->view->form->isValidModelAndArray($selection, $this->_request->getPost())) + return; + + $selection->save(); + $selection->index(); + + $this->_helper->notify($this->_('La sélection a bien été renommée.'), ['status' => 'success']); + return $this->_redirectClose($this->_getReferer()); + } + + public function mesAvisAction() { } @@ -1707,4 +1817,34 @@ class AbonneController extends ZendAfi_Controller_Action { $response->setHeader('Access-Control-Allow-Origin', '*'); $response->setBody($data); } + + + public function reserverAction() { + session_write_close(); + + $this->view->titre = $this->_('Réserver un document'); + + if (!$record = Class_Notice::find($this->_getParam('record_id', 0))) + return $this->_response->setHttpResponseCode(520); + + $nb_notices_oeuvre = Class_Notice::countBy(['clef_oeuvre' => $record->getClefOeuvre(), + 'id_notice not' => $record->getId()]); + + if (!$record->hasExemplaires()) + return $this->_response->setHttpResponseCode(520); + + $cond = ['id_notice' => $record->getId()]; + $session = Zend_Registry::get('session'); + $cond['id_bib'] = $session->id_bibs; + + $items = ($items = Class_Exemplaire::findAllBy(array_filter($cond))) + ? $items + : Class_Exemplaire::findAllBy($params); + + $items = (new Class_Profil_ItemsFilter())->select(Class_Profil::getCurrentProfil(), $items); + + $this->view->items = (new Class_CommSigb())->getDispoExemplaires($items); + + $record->updateFacetsFromExemplaires(); + } } diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php index 3f50fd04b4df6fb5fc27e829b1fbcae916bc428f..f7bd5adbbe08fcfb7b23211dc85d5a546bbf808c 100644 --- a/application/modules/opac/controllers/RechercheController.php +++ b/application/modules/opac/controllers/RechercheController.php @@ -99,9 +99,11 @@ class RechercheController extends ZendAfi_Controller_Action { $this->_extractMultifacetsPost())) { $url = $this->newCriteresRecherches($params) ->getUrlWithMultifacetsUpdate($multifacets); - $this->_redirect($this->view->url($url, null, true), + + isset($params ['titre']) ? ($url ['titre'] = $params ['titre']) : ''; + + return $this->_redirect($this->view->url($url, null, true), ['prependBase' => false]); - return; } $criteres_recherche = $this->newCriteresRecherches($params); @@ -110,10 +112,11 @@ class RechercheController extends ZendAfi_Controller_Action { $criteres_recherche->updateRubrique('guidee'); if ($this->_request->isPost()) { - $params = $criteres_recherche->getUrlCriteresWithFacettes(); + $criteria_params = $criteres_recherche->getUrlCriteresWithFacettes(); // preserve module as we may come from Telephone_RechercheController - $params['module'] = $this->_request->getModuleName(); - return $this->_redirect($this->view->url($params, null, true), + $criteria_params['module'] = $this->_request->getModuleName(); + isset($params ['titre']) ? ($criteria_params ['titre'] = $params ['titre']) : ''; + return $this->_redirect($this->view->url($criteria_params, null, true), ['prependBase' => false]); } diff --git a/application/modules/opac/views/scripts/abonne/renommer-la-selection.phtml b/application/modules/opac/views/scripts/abonne/renommer-la-selection.phtml new file mode 100644 index 0000000000000000000000000000000000000000..b1145c3dbae6ae4b09f3e97f4e9f790513e66d9a --- /dev/null +++ b/application/modules/opac/views/scripts/abonne/renommer-la-selection.phtml @@ -0,0 +1,2 @@ +<?php +echo $this->renderInlineForm($this->form); diff --git a/application/modules/opac/views/scripts/abonne/reserver.phtml b/application/modules/opac/views/scripts/abonne/reserver.phtml new file mode 100644 index 0000000000000000000000000000000000000000..63eafa231a896311b9c41a8958dd1694ad4519f4 --- /dev/null +++ b/application/modules/opac/views/scripts/abonne/reserver.phtml @@ -0,0 +1,2 @@ +<?php +echo $this->Notice_Exemplaires($this->items); diff --git a/application/modules/opac/views/scripts/abonne/supprimer-la-selection.phtml b/application/modules/opac/views/scripts/abonne/supprimer-la-selection.phtml new file mode 100644 index 0000000000000000000000000000000000000000..da0cee9c6befed36c79a7eeb50e10616011c4966 --- /dev/null +++ b/application/modules/opac/views/scripts/abonne/supprimer-la-selection.phtml @@ -0,0 +1,6 @@ +<?php +$description = $this->_('Supprimer la sélection %s qui contient %d document(s)', + $this->selection->getLibelle(), + $this->selection->numberOfNotices()); + +echo $this->renderDeleteQuestion($description, ['delete' => '1']); diff --git a/library/Class/CriteresRecherche.php b/library/Class/CriteresRecherche.php index 924c600ce6fe32349eb62dcf148b74280b9094e8..ae2615a9852d1aea5a408e42227aab4b0a24206e 100644 --- a/library/Class/CriteresRecherche.php +++ b/library/Class/CriteresRecherche.php @@ -332,7 +332,7 @@ class Class_CriteresRecherche { public function getFacettesUrlEncoded() { $facettes = $this->getFacettes(); - return $facettes ? implode('-',$facettes) : null; + return $facettes ? implode('-', $facettes) : null; } @@ -605,8 +605,7 @@ class Class_CriteresRecherche { $this->visitByRechercheType($visitor); - $facettes = $this->getFacettes(); - foreach($facettes as $facette) + foreach($this->getFacettes() as $facette) $visitor->visitFacette($facette); foreach($this->getMultiFacets() as $facet) @@ -769,25 +768,30 @@ class Class_CriteresRecherche { public function getUrlCriteresWithFacettes() { - $intersect=$this->_params; - if ($this->getFacettesUrlEncoded()!='') - $intersect['facettes']=$this->getFacettesUrlEncoded(); + $intersect = $this->_params; + + if ($facettes = $this->getFacettesUrlEncoded()) + $intersect['facettes'] = $facettes; + unset($intersect['facette']); unset($intersect['filtres']); + if ($intersect) return array_merge(['controller' => 'recherche', 'action' => 'simple'], $intersect); - return ['controller'=>'recherche', + return ['controller' => 'recherche', 'action' => 'simple']; } public function getCVSUrlCriteresWithFacettes() { $intersect=$this->_params; - if ($this->getFacettesUrlEncoded()!='') - $intersect['facettes']=$this->getFacettesUrlEncoded(); + + if ($facettes = $this->getFacettesUrlEncoded()) + $intersect['facettes'] = $facettes; + unset($intersect['facette']); unset($intersect['filtres']); if ($intersect) @@ -835,11 +839,14 @@ class Class_CriteresRecherche { public function getUrlCriteresWithoutElement($element) { $intersect=$this->_params; - if ($this->getFacettesUrlEncoded()!='') - $intersect['facettes']=$this->getFacettesUrlEncoded(); + + if ($facettes = $this->getFacettesUrlEncoded()) + $intersect['facettes'] = $facettes; + unset($intersect['facette']); unset($intersect[$element]); unset($intersect['filtres']); + return array_merge(['controller' => 'recherche', 'action' => 'simple'], $intersect); @@ -848,8 +855,10 @@ class Class_CriteresRecherche { public function getUrlCriteresWithoutTri() { $intersect=$this->_params; - if ($this->getFacettesUrlEncoded()!='') - $intersect['facettes']=$this->getFacettesUrlEncoded(); + + if ($facettes = $this->getFacettesUrlEncoded()) + $intersect['facettes'] = $facettes; + unset($intersect['facette']); unset($intersect['filtres']); unset($intersect['tri']); @@ -977,6 +986,11 @@ class Class_CriteresRecherche { } + public function getProfil() { + return $this->_profil; + } + + public function getFormat() { return $this->getParam('liste_format') ? $this->getParam('liste_format') @@ -1027,4 +1041,11 @@ class Class_CriteresRecherche { protected function _getBookmark() { return Class_User_BookmarkedSearch::find($this->getParam('bookmarked_search')); } + + + public function isEmpty() { + return ! ($this->hasExpressionRecherche() + || $this->getFacettes() + || $this->getMultiFacets()); + } } diff --git a/library/Class/WebService/Lastfm.php b/library/Class/WebService/Lastfm.php index 625edbd06bb7e59d6f27867bbb7108bbe459125e..a222cc8f0cb48f4818666335f651ddfb62c4b365 100644 --- a/library/Class/WebService/Lastfm.php +++ b/library/Class/WebService/Lastfm.php @@ -128,12 +128,13 @@ class Class_WebService_Lastfm extends Class_WebService_Abstract { public function getMorceaux($titre, $auteur) { - $album=$this->getAlbum($titre,$auteur); - if(!$album) return false; + if (!$album = $this->getAlbum($titre,$auteur)) + return false; $data = $this->httpGet($album['url']); + $dom = new Zend_Dom_Query($data); - $elements = $dom->queryXpath('//td[@class="chartlist-name"]//span/a'); + $elements = $dom->queryXpath('//td[@class="chartlist-name"]/a'); if (!$elements->count()) return ['nb_resultats' => 0]; diff --git a/library/Class/WebService/SIGB/VSmart/Service.php b/library/Class/WebService/SIGB/VSmart/Service.php index ae8faa31e4692d90f5328f0e96ed5152a7621e71..e44784509efb323992b021a1b9b14af1b7917976 100644 --- a/library/Class/WebService/SIGB/VSmart/Service.php +++ b/library/Class/WebService/SIGB/VSmart/Service.php @@ -20,7 +20,7 @@ */ class Class_WebService_SIGB_VSmart_Service extends Class_WebService_SIGB_AbstractRESTService { - const MOULINS_POPUP_SERVER = '46.20.169.9/moulins'; + const MOULINS_POPUP_SERVER = '77.159.173.139/moulins'; const METAINSTITUTION = 'RES'; const CONSULTATION_TAG = 'PATIMP'; diff --git a/library/ZendAfi/View/Helper/AdvancedSearch.php b/library/ZendAfi/View/Helper/AdvancedSearch.php index 3ffbf7c58ebc2b830fb3d84858c4e13ba131fe75..f37bb488a64f5813eb79a8aaa1ca0ce39bc4fe62 100644 --- a/library/ZendAfi/View/Helper/AdvancedSearch.php +++ b/library/ZendAfi/View/Helper/AdvancedSearch.php @@ -139,6 +139,7 @@ class ZendAfi_View_Helper_AdvancedSearch extends ZendAfi_View_Helper_BaseHelper $form->populate($request->getParams()); $form->setAction($this->view->url(['controller' => 'recherche', 'action' => 'simple', + 'titre' => $this->_('Recherche avancée'), 'form_id' => $form_id], null, true)); return $form; diff --git a/library/startup.php b/library/startup.php index 1f623fa8fd4880df5b52d82967099dd309ac5d80..393e2f666d3041ca155992474e5376a29961dc48 100644 --- a/library/startup.php +++ b/library/startup.php @@ -81,7 +81,7 @@ class Bokeh_Engine { function setupConstants() { defineConstant('BOKEH_MAJOR_VERSION','8.0'); - defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.18'); + defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.19'); defineConstant('BOKEH_REMOTE_FILES', 'http://git.afi-sa.fr/afi/opacce/'); diff --git a/library/templates/Intonation/Assets/css/intonation.css b/library/templates/Intonation/Assets/css/intonation.css index 0c57fdf2908e23a6e035950967f7427ab5df821d..29bd60883cb737db37751b8c6ab723a4b246d307 100644 --- a/library/templates/Intonation/Assets/css/intonation.css +++ b/library/templates/Intonation/Assets/css/intonation.css @@ -70,7 +70,12 @@ div:hover > .img_as_background { .card-img-overlay a:hover, .card-img-overlay a:visited { color: var(--front-overlay-text); - display: grid; + display: block; + height: 100%; +} + +.card-img-overlay a > div { + display: grid !important; height: 100%; } @@ -81,12 +86,20 @@ p > i { margin-right: 0.5em; } +.previous > i:first-child, +.next > i:first-child, +.card-columns .card-footer a, +.widget.rech_simple i:first-child, .nav-link i:first-child, .carousel-control-prev i:first-child, .carousel-control-next i:first-child { margin-right: 0; } +.d-table .next { + padding-left: 100%; +} + .card-body.behind_image { position: absolute; top: 0; @@ -263,6 +276,7 @@ pre { } [class*="carousel-control"] { + margin: 30% 0; width: auto; } @@ -450,17 +464,21 @@ header.col { font-size: 1em; } -.card .card-columns .card-img-overlay h3, -.card .card-columns .card-img-overlay h4, -.card .card-columns .card-img-overlay { +.img-thumbnail .card-columns .card-img-overlay h3, +.img-thumbnail .card-columns .card-img-overlay h4, +.img-thumbnail .card-columns .card-img-overlay { font-size: 0.875em; padding: 0; } -.no_wrap { +.w-s_nowrap { white-space: nowrap; } +.w-s_normal { + white-space: normal; +} + dl.row { margin: 0; } @@ -472,4 +490,70 @@ dl.row { .rating-score { display: inline-flex; -} \ No newline at end of file +} + +.list-group-item:first-child { + padding-top: 0 !important; + margin-top: 0 !important; +} + +.card-deck .button_text, +.card-columns .button_text { + display: none !important; +} + +.button_text_d_none > a > .button_text { + display: none !important; +} + +.dropdown-menu .button_text { + display: inline-block !important; +} + +.search_tools .nav.nav-fill > li.nav-item:first-child { + text-align: left; +} + +.search_tools .nav.nav-fill > li.nav-item:last-child { + text-align: right; +} + +.dropdown-menu label { + flex: 100%; + max-width: 100%; +} + +.user_ico { + height: 32px; +} + +.badge-group .badge.text-truncate { + max-width: 150px; +} + +.dropleft.dropup .dropdown-menu { + top: auto !important; + bottom: -0.5em !important; + right: 105% !important; + left: auto !important; + transform: none !important; +} + +.card-footer .dropleft.dropup .dropdown-menu { + bottom: 1.5em !important; + right: -0.5em !important; +} + +.jumbotron .dropleft.dropup .dropdown-menu { + bottom: auto !important; + top: 100% !important; + right: 0 !important; +} + + +.card-deck > .card, +.card-columns > .card { + overflow: hidden; +} + + diff --git a/library/templates/Intonation/Library/Search/Criteria.php b/library/templates/Intonation/Library/Search/Criteria.php new file mode 100644 index 0000000000000000000000000000000000000000..c3853df999ba7eb9c21d3c7213ad1cef5dc9fe0d --- /dev/null +++ b/library/templates/Intonation/Library/Search/Criteria.php @@ -0,0 +1,79 @@ +<?php +/** + * Copyright (c) 2012-2019, 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 Intonation_Library_Search_Criteria extends Class_CriteresRecherche { + + public function from($criteria) { + $this->_params = $criteria->getCriteres(); + $this->_profil = $criteria->getProfil(); + $this->setTime($criteria->getTime()); + $this->_validate_facette = $criteria->getValidateFacette(); + + return $this; + } + + + public function getUrlCriteresWithoutElement($element) { + $intersect = $this->_params; + + if ('' != $this->getFacettesUrlEncoded()) + $intersect['facettes'] = $this->getFacettesUrlEncoded(); + + unset($intersect['facette']); + unset($intersect[$element]); + unset($intersect['filtres']); + + return array_merge(['controller' => 'recherche', + 'action' => 'simple'], + $intersect); + } + + + public function getUrlRemoveAllFacet($facet) { + $code = $facet->getRubrique()->getCode(); + + $url_without_multifacet = $this->getUrlRemoveMultiFacet($code); + + $url_without_facet = parent::getUrlRemoveFacette($facet); + + $url = $this->getUrlRetourListe(); + + $url['facettes'] = isset($url_without_facet['facettes']) + ? $url_without_facet['facettes'] + : null; + + $url['multifacets'] = isset($url_without_multifacet['multifacets']) + ? $url_without_multifacet['multifacets'] + : null; + + $url['page'] = null; + $url['genre'] = null; + $url['facette'] = null; + + return $url; + } + + + public function getUrlRemoveFacette($facette) { + return $this->getUrlRemoveAllFacet($facette); + } +} diff --git a/library/templates/Intonation/Library/Selection.php b/library/templates/Intonation/Library/Selection.php new file mode 100644 index 0000000000000000000000000000000000000000..dc843e087e48b877d964b76bf7c678047a068812 --- /dev/null +++ b/library/templates/Intonation/Library/Selection.php @@ -0,0 +1,98 @@ +<?php +/** + * Copyright (c) 2012-2019, 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 Intonation_Library_Selection extends Class_Entity { + + use Trait_Translator; + + protected $_cache; + + + protected function _getImageForContext() { + return $this->_isIn() + ? $this->getImage() + : $this->getRevertImage(); + } + + + protected function _getTitleForContext() { + $record = $this->getRecord()->getTitrePrincipal(' '); + $selection = $this->getTitle(); + + return $this->_isIn() + ? $this->_('Retirer le document %s de la sélection %s', + $record, + $selection) + : $this->_('Ajouter le document %s à la sélection %s', + $record, + $selection); + } + + protected function _getUrlForContext() { + $action = $this->_isIn() + ? 'supprimer-de-la-selection' + : 'ajouter-le-document-a-la-selection'; + + return ['controller' => 'abonne', + 'action' => $action, + 'selection_label' => $this->getTitle(), + 'image' => $this->getImage(), + 'revert-image' => $this->getRevertImage(), + 'record_id' => $this->getRecord()->getId(), + 'ajax' => $this->_isIn() ? 'true' : '']; + } + + + protected function _isIn() { + if ($this->_cache) + return $this->_cache; + + if (!$user = $this->getUser()) + return $this->_cache = false; + + if (!$selection = Class_PanierNotice::findFirstBy(['libelle' => $this->getTitle(), + 'id_user' => $user->getId()])) + return $this->_cache = false; + + return $this->_cache = $selection->contains($this->getRecord()); + } + + + public function getAction() { + $url = $this->getView()->url($this->_getUrlForContext(), null, true); + + $js = sprintf("event.preventDefault(); event.stopPropagation(); var anchor = $(this); $.ajax({type: 'GET', url: '%s', success: function(data) {anchor.replaceWith(data.anchor);}});", + $url); + + $popup = Class_Users::getIdentity() ? false : 'true'; + + return new Intonation_Library_Link(['Url' => $url, + 'Attribs' => Class_Users::getIdentity() ? ['onclick' => $js] : [], + 'Text' => $this->getTitle(), + 'Image' => (Class_Template::current() + ->getIco($this->getView(), + $this->_getImageForContext(), + 'library')), + 'Title' => $this->_getTitleForContext(), + 'Popup' => $popup]); + } +} diff --git a/library/templates/Intonation/Library/Settings.php b/library/templates/Intonation/Library/Settings.php index fb14f5d02999e3f8593d5460562c2e06abe95fdb..22e19c19a4b9008c732b5d8f6de02bc796db0487 100644 --- a/library/templates/Intonation/Library/Settings.php +++ b/library/templates/Intonation/Library/Settings.php @@ -101,7 +101,9 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'dd' => 'col-12 col-sm-9', 'dt class user_info' => 'col-12 col-sm-6', 'dd class user_info' => 'col-12 col-sm-6', - 'a' => 'btn-link', + 'a' => 'text-primary', + 'a class btn' => 'text-light', + 'a class badge' => '', 'a class active' => '', 'a class nav-link' => '', 'a class card-link' => '', @@ -111,9 +113,8 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'div class _notify' => 'alert-warning', 'div class success_notify' => 'alert-success', 'div class delete_notify' => 'alert-danger', - 'form class indent-form' => 'px-4 py-1', 'div class card_article' => 'col-12 mb-3', - 'h1 class content_title' => 'p-3 m-1', + 'h1 class content_title' => 'py-2 px-0 my-2 mx-0 border-bottom', 'span class search_axe_operator_prefix' => 'col-4 col-sm-2', 'span class search_axe_label' => 'col-6 col-sm-3 pl-3', 'span class search_axe_input' => 'col-12 col-sm-7', @@ -134,6 +135,10 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'library' => 'class fas fa-landmark', 'available' => 'class far fa-check-circle', 'not-available' => 'class far fa-times-circle', + 'readed' => 'class fas fa-check-circle text-success', + 'unread' => 'class far fa-check-circle', + 'to_read' => 'class fas fa-bookmark text-warning', + 'to_not_read' => 'class far fa-bookmark', 'return-date' => 'class fas fa-dolly', 'place' => 'class fas fa-map-signs', 'cote' => 'class fas fa-crosshairs', @@ -151,6 +156,8 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'settings' => 'class fas fa-user-cog', 'selection' => 'class fas fa-heart', 'no-selection' => 'class far fa-heart', + 'like' => 'class fas fa-heart text-danger', + 'dislike' => 'class far fa-heart', 'subscription' => 'class fas fa-euro-sign', 'card-number' => 'class fas fa-barcode', 'read-document' => 'class far fa-arrow-alt-circle-right', @@ -161,8 +168,10 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'icons_map_utils' => ['image_place_holder' => '/library/templates/Intonation/Assets/images/image_place_holder.png', 'accessibility' => 'class fas fa-low-vision', + 'previous' => 'class fas fa-chevron-left', 'next' => 'class fas fa-chevron-right', + 'list' => 'class fas fa-list', 'wall' => 'class fas fa-th', @@ -173,16 +182,22 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'edit' => 'class fas fa-edit', 'check-list' => 'class fas fa-tasks', 'rename' => 'class fas fa-edit', + 'more' => 'class fas fa-ellipsis-h', + 'refresh' => 'class fas fa-sync-alt', 'rss' => 'class fas fa-rss', 'embed' => 'class fas fa-code', 'export' => 'class fas fa-file-export', + 'print' => 'class fas fa-print', + 'facebook' => 'class fab fa-facebook-f', + 'twitter' => 'class fab fa-twitter', 'tag' => 'class fas fa-tag', 'star' => 'class fas fa-star', 'star-empty' => 'class far fa-star', 'track' => 'class fas fa-music', 'video' => 'class fas fa-video', + 'image' => 'class far fa-image', ] ]; diff --git a/library/templates/Intonation/Library/UserPatcher.php b/library/templates/Intonation/Library/UserPatcher.php index 08952f31c2bc2540333c78c6d32f2a00f5a873b3..841553ffb7e9dd0b12e962fee58b64759ceb6bf6 100644 --- a/library/templates/Intonation/Library/UserPatcher.php +++ b/library/templates/Intonation/Library/UserPatcher.php @@ -34,10 +34,10 @@ class Intonation_Library_UserPatcher { public function patch() { - foreach($this->_getDefaultSelections() as $label) - if (!Class_PanierNotice::findFirstBy(['libelle' => $label, + foreach($this->getDefaultSelections() as $selection) + if (!Class_PanierNotice::findFirstBy(['libelle' => $selection->getTitle(), 'id_user' => $this->_user->getId()])) - $this->_addSelectionToUser($label); + $this->_addSelectionToUser($selection->getTitle()); return $this; } @@ -50,14 +50,26 @@ class Intonation_Library_UserPatcher { } - protected function _getDefaultSelections() { - return [$this->_('Mes préférés'), - $this->_('Déjà lu'), - $this->_('À lire')]; + public function getDefaultSelections() { + return [new Intonation_Library_Selection(['Title' => $this->_('Mes préférés'), + 'Image' => 'like', + 'RevertImage' => 'dislike']), + + new Intonation_Library_Selection(['Title' => $this->_('Déjà lu'), + 'Image' => 'readed', + 'RevertImage' => 'unread']), + + new Intonation_Library_Selection(['Title' => $this->_('À lire'), + 'Image' => 'to_read', + 'RevertImage' => 'to_not_read'])]; } public function isSelectionDefault($selection) { - return in_array($selection->getLibelle(), $this->_getDefaultSelections()); + $labels = []; + foreach($this->getDefaultSelections() as $default) + $labels [] = $default->getTitle(); + + return in_array($selection->getLibelle(), $labels); } } diff --git a/library/templates/Intonation/Library/View/Wrapper/Article.php b/library/templates/Intonation/Library/View/Wrapper/Article.php index e852acd23362895001f49b3289b865938fc7b2c6..bbc6471109d61bc6bdc0506cb90f6c371ce75a1e 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Article.php +++ b/library/templates/Intonation/Library/View/Wrapper/Article.php @@ -45,6 +45,9 @@ class Intonation_Library_View_Wrapper_Article extends Intonation_Library_View_Wr public function getMainLink() { return new Intonation_Library_Link(['Url' => $this->_model->getUrl(), + 'Image' => Class_Template::current()->getIco($this->_view, + 'read-document', + 'library'), 'Text' => $this->_('Lire l\'article'), 'Title' => $this->_getMainLinkTitle()]); } diff --git a/library/templates/Intonation/Library/View/Wrapper/Record.php b/library/templates/Intonation/Library/View/Wrapper/Record.php index f6a91dfc431f332e6e3c8c5fde7609dc15d2895e..0129058abc3a96d528e9825117a007c2a4f4cb65 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record.php @@ -64,7 +64,16 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra public function getPictureAction() { - return ''; + if (Class_Users::isCurrentUserCanAccesBackend()) + return new Intonation_Library_Link(['Url' => $this->_view->url(['module' => 'admin', + 'controller' => 'records', + 'action' => 'thumbnail', + 'id' => $this->_model->getId()]), + 'Popup' => 'true', + 'Attribs' => ['class' => 'menu_admin_front_anchor'], + 'Image' => Class_Template::current()->getIco($this->_view, 'edit', 'utils'), + 'Title' => $this->_('Modifier la vignette de %s', + $this->_model->getTitrePrincipal(' '))]); } @@ -114,7 +123,108 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra public function getActions() { - return []; + $actions = [new Intonation_Library_Link(['Url' => $this->_view->url(['controller' => 'abonne', + 'action' => 'reserver', + 'record_id' => $this->_model->getId()]), + 'Text' => $this->_('Réserver'), + 'Image' => (Class_Template::current() + ->getIco($this->_view, + 'hold', + 'library')), + 'Title' => $this->_('Réserver le document %s', + $this->getMainTitle()), + 'Popup' => true])]; + + foreach((new Intonation_Library_UserPatcher)->getDefaultSelections() as $selection) { + $selection + ->setView($this->_view) + ->setUser(Class_Users::getIdentity()) + ->setRecord($this->_model); + + $actions [] = $selection->getAction(); + } + + $actions [] = $this->_moreActions(); + + return $actions; + } + + + protected function _moreActions() { + $actions = array_merge([$this->_addToSelectionAction()], + $this->_socialNetworksActions(), + [$this->_printAction()], + $this->_thumbnailActions()); + + $button = new Intonation_Library_Link(['Text' => $this->_('Plus'), + 'Attribs' => ['class' => 'text-primary'], + 'Title' => $this->_('Voir plus d\'actions pour le document %s', + $this->_model->getTitrePrincipal(' ')), + 'Image' => Class_Template::current()->getIco($this->_view, + 'more', + 'utils')]); + + return $this->_view->renderDropdown($this->_view->renderActions($actions), $button, 'dropleft dropup'); + } + + + protected function _addToSelectionAction() { + return new Intonation_Library_Link(['Url' => $this->_view->url(['controller' => 'panier', + 'action' => 'add-record-ajax', + 'id_notice' => $this->_model->getId()]), + 'Image' => Class_Template::current()->getIco($this->_view, + 'add', + 'utils'), + 'Text' => $this->_('Ajouter …'), + 'Popup' => 'true', + 'Title' => $this->_('Ajouter %s dans une sélection', + $this->_model->getTitrePrincipal(' '))]); + } + + + protected function _socialNetworksActions() { + return $this->_view->socialNetworksActions($this->_model); + } + + + protected function _printAction() { + return (Class_ModeleFusion::canPrintRecordInProfile(Class_Profil::getCurrentProfil()) + ? new Intonation_Library_Link(['Url' => $this->_view->url(['controller' => 'recherche', + 'action' => 'print', + 'id' => $this->_model->getId()]), + 'Text' => $this->_('Imprimer'), + 'Image' => Class_Template::current()->getIco($this->_view, + 'print', + 'utils'), + 'Title' => $this->_('Imprimer "%s"', $this->_model->getTitrePrincipal(' ')), + 'Attribs' => ['target' => '_blank']]) + : ''); + } + + + protected function _thumbnailActions() { + $actions = []; + + if ($picture_action = $this->getPictureAction()) + $actions [] = $picture_action + ->setImage(Class_Template::current()->getIco($this->_view, + 'image', + 'utils')) + ->setText($this->_('Modifier …')); + + if (Class_Users::isCurrentUserCanAccesBackend()) + $actions [] = new Intonation_Library_Link(['Url' => $this->_view->url(['module' => 'admin', + 'controller' => 'records', + 'action' => 'reset-thumbnail']), + 'Attribs' => ['class' => 'menu_admin_front_anchor'], + 'Image' => Class_Template::current()->getIco($this->_view, + 'refresh', + 'utils'), + 'Text' => $this->_('Générer …'), + 'Title' => $this->_('Supprimer et re-générer la vignette de %s', + $this->_model->getTitrePrincipal(' '))]); + + return $actions; } diff --git a/library/templates/Intonation/Library/View/Wrapper/Record/RichContent.php b/library/templates/Intonation/Library/View/Wrapper/Record/RichContent.php index 9316f178a930a1f87a85a7e23ad1b47d84ad74fa..f6cb54565586cb68a7a6a210b577a27006222639 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record/RichContent.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record/RichContent.php @@ -58,54 +58,19 @@ class Intonation_Library_View_Wrapper_Record_RichContent { public function getActions() { - $html = [$this->getNavigation()->getPosition(), - - ($this->_view->display_modifier_vignette_link - ? $this->_view->Admin_Button((new Class_Entity()) - ->setUrl($this->_view->url(['module' => 'admin', - 'controller' => 'records', - 'action' => 'thumbnail'])) - ->setText($this->_('Modifier')) - ->setAttribs(['title' => $this->_('Modifier la vignette de la notice "%s"', - $this->_model->getTitrePrincipal()), - 'data-popup' => 'true'])) - : ''), - - ($this->_view->show_reset_thumbnail_link - ? $this->_view->Admin_Button((new Class_Entity()) - ->setUrl($this->_view->url(['module' => 'admin', - 'controller' => 'records', - 'action' => 'reset-thumbnail'])) - ->setText($this->_('Générer')) - ->setAttribs(['title' => $this->_('Supprimer et re-générer la vignette de la notice "%s"', - $this->_model->getTitrePrincipal())])) - : ''), - - $this->_view->tag('div', - $this->_view->reseauxSociaux($this->_model), - ['id' => 'reseaux-sociaux']), - - (Class_ModeleFusion::canPrintRecordInProfile(Class_Profil::getCurrentProfil()) - ? $this->_view->tagAnchor(['controller' => 'recherche', - 'action' => 'print'], - $this->_('Imprimer'), - ['title' => $this->_('Imprimer "%s"', $this->_model->getTitrePrincipal()), - 'target' => '_blank']) - : ''), - - $this->_view->tagAnchor($this->_view->url_panier, - $this->_('Ajouter au panier'), - ['class'=>'panier'. - ($this->_model->isInPanier() - ? ' dans_panier' - : ''), - 'data-popup' => 'true', - 'title' => $this->_('Ajouter "%s" dans un panier', $this->_model->getTitrePrincipal())]), - - $this->_view->Notice_LienReserver($this->_model), - $this->_view->renderAjax('noticeajax', 'resources', ['id' => $this->_model->getId()])]; - - return implode($html); + return $this->_view->renderAjax('noticeajax', 'resources', ['id' => $this->_model->getId()]); + } + + + public function getRowActions() { + $wrapper = (new Intonation_Library_View_Wrapper_Record) + ->setModel($this->_model) + ->setView($this->_view); + + $actions = array_merge([$this->getNavigation()->getPosition()], + $wrapper->getActions()); + + return $this->_view->renderActions($actions, ['class' => 'col col-lg-12 pt-1 mt-1 mr-1 pr-1 w-s_nowrap']); } diff --git a/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Navigation.php b/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Navigation.php index 15122cbe9a449f765650b956028654d5e5ceb3c3..44b79206f2ffdbbf44e1c5e1bcf2951c761f6412 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Navigation.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Navigation.php @@ -53,7 +53,7 @@ class Intonation_Library_View_Wrapper_Record_RichContent_Navigation { Class_Template::current()->getIco($this->_view, 'previous', 'utils', ['class' => 'ico_xl']), ['title' => $this->_('Document précédent : %s', $this->_view->notice_navigation->getNoticePrecedente()->getTitrePrincipal(' ')), - 'class' => 'align-middle d-table-cell' . $disabled]); + 'class' => 'previous align-middle d-table-cell' . $disabled]); } @@ -70,7 +70,7 @@ class Intonation_Library_View_Wrapper_Record_RichContent_Navigation { Class_Template::current()->getIco($this->_view, 'next', 'utils', ['class' => 'ico_xl']), ['title' => $this->_('Document suivant : %s', $this->_view->notice_navigation->getNoticeSuivante()->getTitrePrincipal(' ')), - 'class' => 'align-middle d-table-cell' . $disabled]); + 'class' => 'next align-middle d-table-cell' . $disabled]); } @@ -78,10 +78,13 @@ class Intonation_Library_View_Wrapper_Record_RichContent_Navigation { if (! $this->_isVisible()) return ''; - return $this->_view->tag('span', - $this->_('%d / %d', - $this->_view->notice_navigation->getCurrentNoticeIndex() +1, - $this->_view->notice_navigation->getNombreNotices())); + return $this->_view->div([], + $this->_view->tag('span', + $this->_('%d / %d', + $this->_view->notice_navigation->getCurrentNoticeIndex() +1, + $this->_view->notice_navigation->getNombreNotices()), + ['title' => $this->_('Position du document dans la recherche'), + 'class' => 'btn btn-sm btn-secondary'])); } diff --git a/library/templates/Intonation/Library/View/Wrapper/ReviewInRecord.php b/library/templates/Intonation/Library/View/Wrapper/ReviewInRecord.php new file mode 100644 index 0000000000000000000000000000000000000000..3faf0bb436ab156ed80995b4d97545f811b222d0 --- /dev/null +++ b/library/templates/Intonation/Library/View/Wrapper/ReviewInRecord.php @@ -0,0 +1,28 @@ +<?php +/** + * Copyright (c) 2012-2018, 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 Intonation_Library_View_Wrapper_ReviewInRecord extends Intonation_Library_View_Wrapper_Review { + + public function getActions() { + return []; + } +} \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php b/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php index 0e60765019282e061462b4c98326bd6b0b4df7c7..cb2c467d6f767f25d1ea3d5d79d50352f80471ff 100644 --- a/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php +++ b/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php @@ -31,7 +31,7 @@ class Intonation_Library_View_Wrapper_ReviewsByRecord extends Intonation_Library ->setModel($model->getRecord()); foreach ($model->getReviews() as $review) - $this->_reviews [] = (new Intonation_Library_View_Wrapper_Review()) + $this->_reviews [] = (new Intonation_Library_View_Wrapper_ReviewInRecord()) ->setView($this->_view) ->setModel($review); @@ -125,7 +125,7 @@ class Intonation_Library_View_Wrapper_ReviewsByRecord extends Intonation_Library public function getActions() { - return []; + return $this->_record->getActions(); } diff --git a/library/templates/Intonation/Library/View/Wrapper/Search.php b/library/templates/Intonation/Library/View/Wrapper/Search.php index 0fb26b7ee7c49c46f3b78ee8da3be1b453630c39..8734cc1e34391e507aaff04da945f40f6c11027a 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Search.php +++ b/library/templates/Intonation/Library/View/Wrapper/Search.php @@ -62,8 +62,7 @@ class Intonation_Library_View_Wrapper_Search extends Intonation_Library_View_Wra ? $this->_('Suivre cette recherche') : $this->_('Ne plus suivre cette recherche.')), 'Tag' => 'button', - 'Attribs' => ['data-popup' => true, - 'class' => 'btn btn-primary text-white']]); + 'Attribs' => ['data-popup' => true]]); } diff --git a/library/templates/Intonation/Library/View/Wrapper/Selection.php b/library/templates/Intonation/Library/View/Wrapper/Selection.php index accb0eaab9f865c815e9181fb58e732a3b9a06fe..67aa90d807ace79cd327deb6f5b3f0f416843df4 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Selection.php +++ b/library/templates/Intonation/Library/View/Wrapper/Selection.php @@ -82,7 +82,7 @@ class Intonation_Library_View_Wrapper_Selection extends Intonation_Library_View_ public function getMainLink() { return new Intonation_Library_Link(['Url' => $this->_view->url(['controller' => 'abonne', 'action' => 'selection', - 'id' => $this->_model->getId()]), + 'selection_id' => $this->_model->getId()]), 'Text' => $this->_('Gérer'), 'Title' => $this->_('Gérer la sélection'), 'Image' => Class_Template::current()->getIco($this->_view, @@ -145,7 +145,7 @@ class Intonation_Library_View_Wrapper_Selection extends Intonation_Library_View_ new Intonation_Library_Link(['Url' => $this->_view->url(['controller' => 'abonne', 'action' => 'ajouter-a-la-selection', - 'id' => $this->_model->getId()]), + 'selection_id' => $this->_model->getId()]), 'Text' => $this->_('Ajouter'), 'Title' => $this->_('Ajouter un document à la sélection %s', $this->_model->getLibelle()), @@ -167,21 +167,23 @@ class Intonation_Library_View_Wrapper_Selection extends Intonation_Library_View_ return array_merge($actions, [new Intonation_Library_Link(['Url' => $this->_view->url(['controller' => 'abonne', - 'action' => 'renommer-selection', - 'id' => $this->_model->getId()]), + 'action' => 'renommer-la-selection', + 'selection_id' => $this->_model->getId()]), 'Text' => $this->_('Renommer'), 'Title' => $this->_('Renommer la sélection %s', $this->_model->getLibelle()), + 'Popup' => 'true', 'Image' => Class_Template::current()->getIco($this->_view, 'rename', 'utils')]), new Intonation_Library_Link(['Url' => $this->_view->url(['controller' => 'abonne', - 'action' => 'supprimer-selection', - 'id' => $this->_model->getId()]), + 'action' => 'supprimer-la-selection', + 'selection_id' => $this->_model->getId()]), 'Text' => $this->_('Supprimer'), 'Title' => $this->_('Supprimer la sélection %s', $this->_model->getLibelle()), + 'Popup' => 'true', 'Image' => Class_Template::current()->getIco($this->_view, 'delete', 'utils')])]); diff --git a/library/templates/Intonation/Library/View/Wrapper/User.php b/library/templates/Intonation/Library/View/Wrapper/User.php index 2ac35340ad4639c6ae0466802c4fd6a8fc828a50..e935196d3146987464f617e7298c38de4a76d17f 100644 --- a/library/templates/Intonation/Library/View/Wrapper/User.php +++ b/library/templates/Intonation/Library/View/Wrapper/User.php @@ -62,12 +62,12 @@ class Intonation_Library_View_Wrapper_User extends Intonation_Library_View_Wrapp public function getPictureAction() { - return $this->_view->tagAnchor($this->_view->url(['controller' => 'abonne', - 'action' => 'change-image']), - Class_Template::current()->getIco($this->_view, 'edit', 'utils'), - ['class' => 'ml-1', - 'data-popup' => true, - 'title' => $this->_('Modifier mon image')]); + return new Intonation_Library_Link(['Url' => ['controller' => 'abonne', + 'action' => 'change-image'], + 'Image' => Class_Template::current()->getIco($this->_view, 'edit', 'utils'), + 'Attribs' => ['class' => 'ml-1'], + 'Popup' => true, + 'Title' => $this->_('Modifier mon image')]); } diff --git a/library/templates/Intonation/Library/View/Wrapper/User/RichContent.php b/library/templates/Intonation/Library/View/Wrapper/User/RichContent.php index a464cb7839910f0a1e4d91b6862ae68be277d94a..f8108da74beb65dea469a9f7d8bb7a1096b418ad 100644 --- a/library/templates/Intonation/Library/View/Wrapper/User/RichContent.php +++ b/library/templates/Intonation/Library/View/Wrapper/User/RichContent.php @@ -56,6 +56,11 @@ class Intonation_Library_View_Wrapper_User_RichContent { } + public function getRowActions() { + return ''; + } + + public function setSections($sections) { $this->_sections = $sections; return $this; diff --git a/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Selection.php b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Selection.php index 53f5563346ca801fcfcfafa92a581d6022e98cb3..aecc2d3002c243e83fafd8e28c4a24d48eba8966 100644 --- a/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Selection.php +++ b/library/templates/Intonation/Library/View/Wrapper/User/RichContent/Selection.php @@ -29,9 +29,6 @@ class Intonation_Library_View_Wrapper_User_RichContent_Selection extends Intonat public function getContent() { - if (!$records = $this->_model->getNoticesAsArray()) - return ''; - $wrapper = (new Intonation_Library_View_Wrapper_Selection) ->setModel($this->_model) ->setView($this->_view); @@ -43,7 +40,7 @@ class Intonation_Library_View_Wrapper_User_RichContent_Selection extends Intonat $this->_view->renderActions($wrapper->getActions())), $this->_view->div(['class' => 'col-12 col-sm-9'], - $this->_view->renderList(new Storm_Collection($records), + $this->_view->renderList(new Storm_Collection($this->_model->getNoticesAsArray()), function($record) { return diff --git a/library/templates/Intonation/Library/Widget/Login/View.php b/library/templates/Intonation/Library/Widget/Login/View.php index 2243741b64493a089930bd57fd0852333d75277a..4d0a713b3a3f239e3ca8bc81995c01e23232c422 100644 --- a/library/templates/Intonation/Library/Widget/Login/View.php +++ b/library/templates/Intonation/Library/Widget/Login/View.php @@ -99,8 +99,10 @@ abstract class IntonationLoginRenderAbstract { $options [Storm_Inflector::underscorize($key)] = $value; $form = ZendAfi_Form_Login::newWithOptions(['data' => $options]); - $form->setAction($this->_view->url(['controller' => 'auth', - 'action' => 'login'], null, true)); + + $form + ->setAction($this->_view->url(['controller' => 'auth', + 'action' => 'login'], null, true)); $form->removeElement('loginlink'); $form->removeElement('lostpass'); $form->removeElement('register'); @@ -294,62 +296,44 @@ class IntonationLoginRenderInline extends IntonationLoginRenderAbstract { class IntonationLoginRenderToggle extends IntonationLoginRenderAbstract { public function renderLogin() { - $html = parent::renderLogin(); - $user = $this->_user; - - $id = Storm_Inflector::camelize($this->_settings->getIdModule() . $this->_settings->getTitre()); - return $this->_view->tag('div', - $this->_view->tag('button', - $this->_settings->getTitre(), - ['id' => $id, - 'data-toggle' => 'dropdown', - 'aria-haspopup' => 'true', - 'type' => 'button', - 'class' => 'btn dropdown-toggle']) - . $this->_view->tag('div', - $this->_view->tag('div', - $html, - ['class' => 'dropdown-item']), - ['class' => 'dropdown-menu', - 'aria-labelledby' => $id])); + return $this->_view->renderDropdown(parent::renderLogin(), $this->_settings->getTitre()); } public function renderLogged() { - $user = $this->_user; - $user_url = $this->_view->url(['controller' => 'abonne', 'action' => 'fiche', 'id_profil' => $this->_settings->getProfilRedirect() > 0 ? $this->_settings->getProfilRedirect() : Class_Profil::getCurrentProfil()->getId()], null, true); - $links = [$this->_view->button((new Class_Entity()) - ->setUrl($user_url) - ->setText($this->_view->abonne_NamesOrLogin($user)) - ->setAttribs(['title' => $this->_('Accéder à l\'interface de gestion de %s.', $user->getNomComplet()), - 'class' => 'btn btn-sm btn-primary'])), - $this->_view->button((new Class_Entity()) + $links = [$this->_view->tagAction((new Intonation_Library_Link()) + ->setUrl($user_url) + ->setText($this->_settings->getTitreConnecte()) + ->setAttribs(['title' => $this->_('Accéder à l\'interface de gestion de %s.', $this->_user->getNomComplet()), + 'class' => 'btn btn-sm btn-primary'])), + + $this->_view->tagAction((new Intonation_Library_Link()) ->setText($this->_settings->getLienDeconnection()) - ->setAttribs(['class' => 'btn btn-sm btn-link', - 'title' => $this->_('Se déconnecter de la session %s', $user->getNomComplet())]) + ->setAttribs(['class' => 'btn btn-sm btn-secondary', + 'title' => $this->_('Se déconnecter de la session %s', $this->_user->getNomComplet())]) ->setUrl($this->_view->url(['controller'=>'auth', 'action'=>'logout'], null, true)))]; - $cards = new Class_User_Cards($user); + $cards = new Class_User_Cards($this->_user); if (!$cards->isEmpty()) $links = array_merge($links, $this->_view->ficheAbonneLinks($cards->getLoansCount(), $cards->getLateLoansCount(), $cards->getHoldsCount())); - if($notifications = $this->_view->renderNotifications($user)) + if($notifications = $this->_view->renderNotifications($this->_user)) $links = array_merge($links, $notifications); $links = array_filter($links); $links = array_map(function($link) { - return $this->_view->tag('li', $link); + return $this->_view->tag('li', $link, ['class' => 'mb-1']); }, $links); $html = $this->_view->tag('div', @@ -358,22 +342,7 @@ class IntonationLoginRenderToggle extends IntonationLoginRenderAbstract { $this->_getLinksListAttribs()), ['class' => 'align-self-center']); - $id = Storm_Inflector::camelize($this->_settings->getIdModule() . $this->_settings->getTitreConnecte()); - - return $this->_view->tag('div', - $this->_view->tag('button', - $this->_settings->getTitreConnecte(), - ['id' => $id, - 'data-toggle' => 'dropdown', - 'aria-haspopup' => 'true', - 'type' => 'button', - 'class' => 'btn dropdown-toggle']) - . $this->_view->tag('div', - $this->_view->tag('div', - $html, - ['class' => 'dropdown-item']), - ['class' => 'dropdown-menu', - 'aria-labelledby' => $id]), - ['class' => 'dropdown']); + return $this->_view->renderDropdown($html, + $this->_view->abonne_Name($this->_user)); } } diff --git a/library/templates/Intonation/Library/Widget/Nav/View.php b/library/templates/Intonation/Library/Widget/Nav/View.php index 3d63816b2fc36049fda008f9427c3dc90a11b117..6395bbdfed7271383aa0249292e63f328034418b 100644 --- a/library/templates/Intonation/Library/Widget/Nav/View.php +++ b/library/templates/Intonation/Library/Widget/Nav/View.php @@ -92,7 +92,7 @@ class Intonation_Library_Widget_Nav_View extends Zendafi_View_Helper_Accueil_Bas ['class' => 'navbar-toggler collapsed', 'type' => 'button', 'data-toggle' => 'collapse', - 'data-target' => '#navbar']); + 'data-target' => '#navbar_' . $this->_menu_id]); } @@ -122,7 +122,7 @@ class Intonation_Library_Widget_Nav_View extends Zendafi_View_Helper_Accueil_Bas return $this->_tag('div', $this->_renderChildren($this->_menu_settings['menus'], $this->_menu_id), ['class' => 'navbar-collapse collapse', - 'id' => 'navbar']); + 'id' => 'navbar_' . $this->_menu_id]); } diff --git a/library/templates/Intonation/Library/Widget/Search/View.php b/library/templates/Intonation/Library/Widget/Search/View.php index eb478333dd8c85f3bbc80adbf16553c85f33c572..b5408d37f4629395dbb6fb9de9a7b536d146cf74 100644 --- a/library/templates/Intonation/Library/Widget/Search/View.php +++ b/library/templates/Intonation/Library/Widget/Search/View.php @@ -98,7 +98,6 @@ abstract class IntonationSearchRenderAbstract { $action_url = $this->_view->url($action_url, null, true); $form = (new ZendAfi_Form) - ->setAttrib('class', 'indent-form') ->setAction($action_url); if ($doc_type) @@ -117,6 +116,27 @@ abstract class IntonationSearchRenderAbstract { 'class' => 'expressionRecherche', 'placeholder' => $this->_settings->getPlaceholder()]) + ->addElement('custom', + 'custom_reset_search', + ['render' => function() + { + if (!$this->_view->search_result) + return ''; + + if ($this->_view->search_result->getCriteresRecherche()->isEmpty()) + return ''; + + return $this->_view->tag('button', + Class_Template::current() + ->getIco($this->_view, + 'clean', + 'utils'), + ['Title' => $this->_('Réinitialiser la recherche'), + 'type' => 'button', + 'class' => 'btn btn-sm btn-warning border-dark', + 'onclick' => 'var form = $(this).closest(\'form\'); form.attr(\'action\', \'' . $this->_view->url(['controller' => 'recherche', 'action' => 'simple'], null, true) . '\'); form.find(\'.expressionRecherche\').attr(\'value\', \'\'); $(this).hide(); form.find(\'.criteres_recherche\').hide();']); + }]) + ->addElement('submit', 'search_submit', ['label' => $this->_settings->getSearchButton(), @@ -212,24 +232,21 @@ abstract class IntonationSearchRenderAbstract { protected function _renderToggle($html, $button_text = '') { - Class_ScriptLoader::getInstance() - ->addJqueryReady('$(".dropdown-menu").on("click", function (e) {e.stopPropagation();});'); + return $this->_view->renderDropdown($html, $button_text); + } - $id = 'dropdown_button_' . $this->_id; - return $this->_view->tag('div', - $this->_view->tag('button', - $button_text, - ['id' => $id, - 'data-toggle' => 'dropdown', - 'aria-haspopup' => 'true', - 'type' => 'button', - 'class' => 'search-button btn dropdown-toggle']) - . $this->_view->tag('div', - $html, - ['class' => 'dropdown-menu px-4 py-1', - 'aria-labelledby' => $id]), - ['class' => 'dropdown']); + protected function _renderCriteria($html) { + if (!$this->_view->search_result) + return $html; + + if ($this->_view->search_result->getCriteresRecherche()->isEmpty()) + return $html; + + $criteria = $this->_view->search_HtmlCriteria($this->_view->search_result->getCriteresRecherche()); + + return $html . $this->_view->div(['class' => 'w-s_normal'], + $criteria); } @@ -244,6 +261,8 @@ class IntonationSearchRenderDefault extends IntonationSearchRenderAbstract { $html = $this->_view->renderForm($this->_getForm() ->addUniqDisplayGroup('search_group')); + $html = $this->_renderCriteria($html); + return $this->_isAdvancedSearchEnabled() ? $html . $this->_renderAdvancedSearch() : $html; @@ -273,9 +292,11 @@ class IntonationSearchRenderInline extends IntonationSearchRenderAbstract { ? $this->_renderAdvancedSearch() : ''; + $criteria = $this->_renderCriteria(''); + $form = $this->_getMainForm(); - if ($html = implode($optional_form_elements) . $advanced_search) + if ($html = $criteria . implode($optional_form_elements) . $advanced_search) $form->addElement('custom', 'custom_advanced_search', ['render' => function() use ($html) @@ -284,6 +305,8 @@ class IntonationSearchRenderInline extends IntonationSearchRenderAbstract { }]); $form->addUniqDisplayGroup('search_group'); + $form->populate($this->_settings->toArray()); + return $this->_view->renderInlineForm($form); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/Abonne/Name.php b/library/templates/Intonation/View/Abonne/Name.php new file mode 100644 index 0000000000000000000000000000000000000000..9048e5e1fe88535bd8c5e4cb916cd339b34104de --- /dev/null +++ b/library/templates/Intonation/View/Abonne/Name.php @@ -0,0 +1,70 @@ +<?php +/** + * Copyright (c) 2012-2019, 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 Intonation_View_Abonne_Name extends ZendAfi_View_Helper_BaseHelper { + public function abonne_Name($user) { + return $this->_getImage($user) . $this->_name($user); + } + + + protected function _name($user) { + $names = $this->_getAvailableNames($user); + $html = []; + + foreach ($names as $name) + $html [] = $this->_tag('span', + $this->view->escape($name->getText()), + ['class' => 'ml-1 ' . $name->getClass()]); + + return implode($html); + } + + + protected function _getAvailableNames($user) { + if ($login = $user->getPseudo()) + return [new Class_Entity(['Text' => $login, + 'Class' => 'user_login'])]; + + $names = []; + + if ($first_name = $user->getPrenom()) + $names [] = new Class_Entity(['Text' => $first_name, + 'Class' => 'user_first_name']); + + if ($last_name = $user->getNom()) + $names [] = new Class_Entity(['Text' => $last_name, + 'Class' => 'user_last_name']); + + return $names; + } + + + protected function _getImage($user) { + $wrapper = (new Intonation_Library_View_Wrapper_User) + ->setModel($user) + ->setView($this->view); + + return ($image = $wrapper->getPicture()) + ? $this->view->tagImg($image, ['class' => 'user_ico']) + : ''; + } +} diff --git a/library/templates/Intonation/View/Abstract/Carousel.php b/library/templates/Intonation/View/Abstract/Carousel.php index 025e5ab0d46317c8110d993d3f192c0e07f4cdc5..e1824d57feae23724bb82a0fcf513f8d90ff7880 100644 --- a/library/templates/Intonation/View/Abstract/Carousel.php +++ b/library/templates/Intonation/View/Abstract/Carousel.php @@ -27,8 +27,8 @@ abstract class Intonation_View_Abstract_Carousel extends ZendAfi_View_Helper_Bas $id = 'carousel_' . uniqid(); - $content = $this->_indicators($this->_numberOfPages($collection), $id) - . $this->_carouselInner($collection, $id, $callback) + $content = $this->_carouselInner($collection, $id, $callback) + . $this->_indicators($this->_numberOfPages($collection), $id) . $this->_carouselControl($this->_shouldShowControls($collection), $id); return $this->_tag('div', @@ -56,7 +56,7 @@ abstract class Intonation_View_Abstract_Carousel extends ZendAfi_View_Helper_Bas return $this->_tag('ol', implode($lis), - ['class' => 'carousel-indicators']); + ['class' => 'carousel-indicators my-2 position-relative']); } diff --git a/library/templates/Intonation/View/Author/RenderCollaborations.php b/library/templates/Intonation/View/Author/RenderCollaborations.php index 34838e77264649368ddbebe15853448d0bda8e49..20f227453597a162747cc9c4bd18987172b4b2dc 100644 --- a/library/templates/Intonation/View/Author/RenderCollaborations.php +++ b/library/templates/Intonation/View/Author/RenderCollaborations.php @@ -52,7 +52,7 @@ class Intonation_View_Author_RenderCollaborations extends ZendAfi_View_Helper_Ba $author_description->getLabel(), $author->getLibelle())]); return $this->_div(['class' => 'card'], - $this->_div(['class' => 'p-1 bg-primary rounded pl-3'], + $this->_div(['class' => 'p-1 bg-light rounded pl-3'], $this->_tag('span', (new Class_Notice_FieldAuthor($author))->renderOn($this->view), ['class' => 'mr-3 text-white']) diff --git a/library/templates/Intonation/View/CardifyHorizontal.php b/library/templates/Intonation/View/CardifyHorizontal.php index f806f67f51e887cb94c124cd3d80d61895274231..df047013104897f9d10ac6f7efeebcda02e2164c 100644 --- a/library/templates/Intonation/View/CardifyHorizontal.php +++ b/library/templates/Intonation/View/CardifyHorizontal.php @@ -60,6 +60,6 @@ class Intonation_View_CardifyHorizontal extends ZendAfi_View_Helper_BaseHelper { . $this->view->div(['class' => 'col-12 col-sm-3 p-3'], $this->view->renderActions(array_merge([$element->getMainLink()], $element->getActions())))), - ['class' => 'card no_overflow']); + ['class' => 'card']); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/CardifyOnlyDescription.php b/library/templates/Intonation/View/CardifyOnlyDescription.php index 5d72c4842cf2d486a06ab1516437c1cd14588fcf..ce5e018c58ee2ff96bb9aa29ce99d051a1033270 100644 --- a/library/templates/Intonation/View/CardifyOnlyDescription.php +++ b/library/templates/Intonation/View/CardifyOnlyDescription.php @@ -44,15 +44,6 @@ class Intonation_View_CardifyOnlyDescription extends ZendAfi_View_Helper_BaseHel ['title' => strip_tags($element->getDescriptionTitle()), 'class' => 'card-text']); - $links = []; - if ($link = $element->getMainLink()) - $links [] = $this->view->tagAction($link); - - foreach($element->getActions() as $action) - $links [] = is_string($action) - ? $action - : $this->view->tagAction($action); - $html = []; if (!empty($content)) @@ -60,13 +51,20 @@ class Intonation_View_CardifyOnlyDescription extends ZendAfi_View_Helper_BaseHel implode($content), ['class' => 'card-body']); + $links = []; + if ($link = $element->getMainLink()) + $links [] = $this->view->tagAction($link); + + foreach($element->getActions() as $action) + $links [] = $this->view->tagAction($action); + if (!empty($links)) $html [] = $this->_tag('div', implode($links), - ['class' => 'card-footer d-flex flex-column flex-md-row justify-content-between']); + ['class' => 'card-footer d-flex flex-row justify-content-between button_text_d_none']); return $this->_tag('div', $img . implode($html), - ['class' => 'card no_overflow']); + ['class' => 'card']); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/CardifyWithOverlay.php b/library/templates/Intonation/View/CardifyWithOverlay.php index 189d34392f27c046d0f47fc2ea24e3296b40e1a8..0089af1352b7e7af71fa760c357ad326a0d3d697 100644 --- a/library/templates/Intonation/View/CardifyWithOverlay.php +++ b/library/templates/Intonation/View/CardifyWithOverlay.php @@ -24,7 +24,7 @@ class Intonation_View_CardifyWithOverlay extends ZendAfi_View_Helper_BaseHelper public function cardifyWithOverlay($element) { return $this->_tag('div', $this->_cardWithPicture($element), - ['class' => 'card no_overflow text-center']); + ['class' => 'card text-center']); } diff --git a/library/templates/Intonation/View/Facettes.php b/library/templates/Intonation/View/Facettes.php index a0035d0742aed22a9cb2fa4bdcf6ea634dc481d8..1dd4a49d15bd9b3df6fec3a38cfcfe6ea748924e 100644 --- a/library/templates/Intonation/View/Facettes.php +++ b/library/templates/Intonation/View/Facettes.php @@ -32,7 +32,9 @@ class Intonation_View_Facettes extends ZendAfi_View_Helper_BaseHelper { if (!$facets) return ''; - $this->_criteres = $criteres; + $this->_criteres = (new Intonation_Library_Search_Criteria) + ->from($criteres); + $this->_preferences = $preferences; Class_ScriptLoader::getInstance() @@ -52,9 +54,7 @@ class Intonation_View_Facettes extends ZendAfi_View_Helper_BaseHelper { $separator = preg_match('/;/', $codes) ? ';' : ''; $codes = 'T' . $separator . $codes; - return $this->_tag('div', - $this->listeFacettesHTML($codes, $facets, $url), - ['class' => 'facette']); + return $this->listeFacettesHTML($codes, $facets, $url); } @@ -73,7 +73,7 @@ class Intonation_View_Facettes extends ZendAfi_View_Helper_BaseHelper { ['class' => 'facette_titre list-group-item border-0 py-1 my-1']); } - $attribs = ['class' => 'multi_facets_submit bouton', + $attribs = ['class' => 'multi_facets_submit bouton btn btn-sm btn-primary', 'type' => 'submit', 'name' => 'multi_facets_submit']; if (!$this->_preferences['multi_facettes']) @@ -82,8 +82,10 @@ class Intonation_View_Facettes extends ZendAfi_View_Helper_BaseHelper { $button = $this->view->tag('button', $this->_('Affiner'), $attribs); return $this->_tag('form', - $button . $this->_tag('ul', $html, ['class' => 'list-group border-0 my-3']) . $button, - ['method' => 'POST', 'action' => $this->view->url($url)]); + $this->_tag('ul', $html, ['class' => 'list-group border-0 mb-2']) . $button, + ['method' => 'POST', + 'class' => 'no_overflow mb-2', + 'action' => $this->view->url($url)]); } @@ -147,7 +149,7 @@ class Intonation_View_Facettes extends ZendAfi_View_Helper_BaseHelper { protected function renderCheckbox($code) { - $attribs = ['checked' => $this->isMultiActive($code)]; + $attribs = ['checked' => $this->isMultiActive($code) || $this->isActive($code)]; if (!$this->_preferences['multi_facettes']) $attribs['style'] = 'display: none;'; @@ -169,14 +171,14 @@ class Intonation_View_Facettes extends ZendAfi_View_Helper_BaseHelper { protected function renderRemove($code, $label) { - $remove_url = $this->view->url($this->_criteres->getUrlRemoveFacette(Class_Notice_Facette::find($code)), + $facet = Class_Notice_Facette::find($code); + $remove_url = $this->view->url($this->_criteres->getUrlRemoveAllFacet($facet), null, true); return $this->view->tagAnchor($remove_url, $this->_('Retirer ') . $label, ['class' => 'remove_facette', - 'style' => 'display:none', 'title' => $this->view->_('Retirer la facette: %s', $label)]); } diff --git a/library/templates/Intonation/View/Jumbotron.php b/library/templates/Intonation/View/Jumbotron.php index ee3e8e23c051dcd695db102d2c8a9d53b1b5de74..453eeb341bf86852f4c388b472d7b2e3f325a43d 100644 --- a/library/templates/Intonation/View/Jumbotron.php +++ b/library/templates/Intonation/View/Jumbotron.php @@ -47,14 +47,14 @@ class Intonation_View_Jumbotron extends ZendAfi_View_Helper_BaseHelper { $html [] = $this->_div(['class' => 'order-1 col-1'], $this->_div(['class' => 'd-table h-100'], $previous)); if ($next = $this->_getNextItem()) - $html [] = $this->_div(['class' => 'order-3 order-md-4 order-xl-5 col-1'], $this->_div(['class' => 'd-table h-100'], $next)); + $html [] = $this->_div(['class' => 'order-3 order-md-4 order-lg-5 col-1'], $this->_div(['class' => 'd-table h-100'], $next)); - $html [] = $this->_div(['class' => ($previous ? '' : ' ' ) . 'order-2 col-10 col-sm-5 col-md-4 col-lg-3 col-xl-2'], $this->_thumbnail()); - $html [] = $this->_div(['class' => 'order-4 order-md-3 col-10 col-md-5 col-lg-6 col-xl-4 ml-1 px-3'], $this->_header()); - $html [] = $this->_div(['class' => 'order-5 order-xl-4 mh-100 no-gutters col-10 col-xl-3'], $this->_actions()); + $html [] = $this->_div(['class' => 'order-2 col-10 col-sm-5 col-md-4 col-lg-2 col-xl-2'], $this->_thumbnail()); + $html [] = $this->_div(['class' => 'order-4 order-md-3 col-10 col-md-5 col-lg-5 col-xl-5 ml-md-1 px-md-3'], $this->_header()); + $html [] = $this->_div(['class' => 'order-5 order-lg-4 mh-100 no-gutters col-10 col-md-9 col-lg-2'], $this->_getRowActions()); $html [] = $this->_div(['class' => 'order-6 col-10 col-xl-9 mt-2'], $this->_nav()); - return $this->_div(['class' => 'jumbotron jumbotron-fluid w-100 no_overflow py-3 mb-3'], + return $this->_div(['class' => 'jumbotron jumbotron-fluid w-100 py-3 mb-3'], $this->view->grid(implode($html), [], ['class' => 'justify-content-center'])); @@ -88,7 +88,7 @@ class Intonation_View_Jumbotron extends ZendAfi_View_Helper_BaseHelper { return $this->view->div([], $this->view->div(['class' => 'position-absolute'], - $this->_element->getPictureAction()) + $this->view->tagAction($this->_element->getPictureAction())) . $this->view->tagImg($image, ['class' => 'img-thumbnail w-100', 'alt' => ($image @@ -107,7 +107,7 @@ class Intonation_View_Jumbotron extends ZendAfi_View_Helper_BaseHelper { ['title' => $secondary_link->getTitle(), 'class' => 'card-link']); - return $html . $this->_element->getBadges(); + return $html . $this->_element->getBadges() . $this->_actions(); } @@ -119,6 +119,14 @@ class Intonation_View_Jumbotron extends ZendAfi_View_Helper_BaseHelper { } + protected function _getRowActions() { + if (!$rich_content = $this->_element->getRichContent()) + return; + + return $rich_content->getRowActions(); + } + + protected function _nav() { if (!$rich_content = $this->_element->getRichContent()) return; diff --git a/library/templates/Intonation/View/Notice/Exemplaires.php b/library/templates/Intonation/View/Notice/Exemplaires.php index 94d9e6f061bea2b86780630840ea73b65e590c1c..158bd15cd915b86b5a38af5900a604f17bba2e23 100644 --- a/library/templates/Intonation/View/Notice/Exemplaires.php +++ b/library/templates/Intonation/View/Notice/Exemplaires.php @@ -23,6 +23,9 @@ class Intonation_View_Notice_Exemplaires extends ZendAfi_View_Helper_BaseHelper { public function Notice_Exemplaires($exemplaires, $nb_notices_oeuvre = 0, $aff = "normal") { + if (!$exemplaires) + return ''; + $callback = function ($element) { return $this->view->cardifyOnlyDescription($element); }; diff --git a/library/templates/Intonation/View/RenderActions.php b/library/templates/Intonation/View/RenderActions.php index 3fa775d71477e10ace8aeb1432353384e179224a..6e380eefc3519dfa65d67653b0bf3959d4d09037 100644 --- a/library/templates/Intonation/View/RenderActions.php +++ b/library/templates/Intonation/View/RenderActions.php @@ -21,13 +21,11 @@ class Intonation_View_RenderActions extends ZendAfi_View_Helper_BaseHelper { - public function renderActions($actions) { + public function renderActions($actions, $items_attribs = ['class' => 'col col-sm-12 p-1 m-1']) { $links = []; foreach($actions as $action) - $links [] = $this->view->div(['class' => 'col col-sm-12 p-1 m-1'], - (is_string($action) - ? $action - : $this->view->tagAction($action))); + $links [] = $this->view->div($items_attribs, + $this->view->tagAction($action)); return $this->view->grid(implode($links)); } diff --git a/library/templates/Intonation/View/RenderBadges.php b/library/templates/Intonation/View/RenderBadges.php index e619070de8d65dfec3c05e82755ad4bdc3109e09..5c47f69b01d8efc176ef64e278c7093662a1617d 100644 --- a/library/templates/Intonation/View/RenderBadges.php +++ b/library/templates/Intonation/View/RenderBadges.php @@ -32,7 +32,7 @@ class Intonation_View_RenderBadges extends ZendAfi_View_Helper_BaseHelper { $instances = array_map(function($badge) { $attribs = ['title' => $badge->gettitle(), - 'class' => 'badge badge-' . $badge->getclass()]; + 'class' => 'text-truncate badge badge-' . $badge->getclass()]; if ($url = $badge->geturl()) $attribs['href'] = $url; diff --git a/library/templates/Intonation/View/RenderDeleteQuestion.php b/library/templates/Intonation/View/RenderDeleteQuestion.php new file mode 100644 index 0000000000000000000000000000000000000000..8081baa5ef7b60c0f4d0468f5d7075b6f6668b0d --- /dev/null +++ b/library/templates/Intonation/View/RenderDeleteQuestion.php @@ -0,0 +1,41 @@ +<?php +/** + * Copyright (c) 2012-2019, 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 Intonation_View_RenderDeleteQuestion extends ZendAfi_View_Helper_BaseHelper { + public function renderDeleteQuestion($description, $confirm_deletion_url) { + $html = [$this->view->div(['class' => 'col-10'], + $this->_tag('h3', + $description, + ['class' => 'pt-2 mx-2 border-top border-danger'])), + + $this->view->div(['class' => 'col-10'], + $this->view->div(['class' => 'm-2 p-2 btn-group text-white'], + $this->view->Button_Back(new Class_Entity(['Attribs' => ['class' => 'btn btn-info']])) + . $this->view->tagAnchor($confirm_deletion_url, + $this->_('Oui'), + ['class' => 'btn btn-danger'])))]; + + return $this->view->grid(implode($html), + [], + ['class' => 'justify-content-center text-center']); + } +} diff --git a/library/templates/Intonation/View/RenderDropdown.php b/library/templates/Intonation/View/RenderDropdown.php new file mode 100644 index 0000000000000000000000000000000000000000..439fd3335304d1346e61bf7de4f899099f344942 --- /dev/null +++ b/library/templates/Intonation/View/RenderDropdown.php @@ -0,0 +1,50 @@ +<?php +/** + * Copyright (c) 2012-2019, 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 Intonation_View_RenderDropdown extends ZendAfi_View_Helper_BaseHelper { + + public function renderDropdown($content, $button = '', $direction = '') { + $id = 'dropdown_button_' . uniqid(); + + $button = ($button instanceof Intonation_Library_Link) + ? $this->view->tagAction($button->setAttribs(array_merge((($attribs = $button->getAttribs()) + ? $attribs + : []), + ['id' => $id, + 'data-toggle' => 'dropdown', + 'aria-haspopup' => 'true']))) + : $this->_tag('button', + $button, + ['id' => $id, + 'data-toggle' => 'dropdown', + 'aria-haspopup' => 'true', + 'type' => 'button', + 'class' => 'btn btn-sm dropdown-toggle']); + + return $this->view->div(['class' => 'dropdown ' . $direction], + $button + . $this->view->div(['class' => 'dropdown-menu', + 'aria-labelledby' => $id], + $this->view->div(['class' => 'py-0 px-3'], + $content))); + } +} diff --git a/library/templates/Intonation/View/RenderExpandable.php b/library/templates/Intonation/View/RenderExpandable.php new file mode 100644 index 0000000000000000000000000000000000000000..d7dda0f3307390e3b92b6f215f17509d2badef19 --- /dev/null +++ b/library/templates/Intonation/View/RenderExpandable.php @@ -0,0 +1,46 @@ +<?php +/** + * Copyright (c) 2012-2019, 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 Intonation_View_RenderExpandable extends ZendAfi_View_Helper_BaseHelper { + public function renderExpandable($content, $button = '', $collapsing_class = 'navbar-expand-md') { + $id = 'navbar_' . uniqid(); + + $button = ($button + ? $button + : $this->_tag('span', '', ['class' => 'navbar-toggler-icon'])); + + $button = $this->_tag('button', + $button, + ['class' => 'navbar-toggler mb-2', + 'type' => 'button', + 'data-toggle' => 'collapse', + 'data-target' => '#' . $id]); + + $content = $this->view->div(['class' => 'collapse navbar-collapse no_overflow', + 'id' => $id], + $content); + + return $this->view->div(['class' => 'navbar d-print no_overflow p-0 m-0 navbar-light ' . $collapsing_class], + $button . $content); + + } +} diff --git a/library/templates/Intonation/View/Search/Facets.php b/library/templates/Intonation/View/Search/Facets.php new file mode 100644 index 0000000000000000000000000000000000000000..ea18e5d4ae318b527fc924a0774b2703da4c30a4 --- /dev/null +++ b/library/templates/Intonation/View/Search/Facets.php @@ -0,0 +1,247 @@ +<?php +/** + * Copyright (c) 2012, 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 Intonation_View_Search_Facets extends ZendAfi_View_Helper_BaseHelper { + const MULTI_FACET_KEY = 'multifacet_'; + + protected + $_criteres, + $_current, + $_preferences; + + + public function search_Facets($facets, $preferences, $criteres) { + if (!$facets) + return ''; + + $this->_criteres = (new Intonation_Library_Search_Criteria) + ->from($criteres); + + $this->_preferences = $preferences; + + Class_ScriptLoader::getInstance() + ->addJQueryReady('$(".facette .msg>a").click(function(e){ ' + .'e.preventDefault();' + .'var anchor = $(this);' + .'anchor.next("ul").find("li").hide().appendTo(anchor.parent().closest("ul")).slideToggle();' + .'anchor.parent().remove();' + .'})'); + + $url = array_merge($criteres->getUrlRetourListe(), + ['controller' => 'recherche', + 'action' => 'simple', + 'page' => null]); + + $codes = $this->_preferences['facettes_codes']; + $separator = preg_match('/;/', $codes) ? ';' : ''; + $codes = 'T' . $separator . $codes; + + return $this->listeFacettesHTML($codes, $facets, $url); + } + + + public function listeFacettesHTML($codes, $facets, $url) { + $html = ''; + $rubriques = Class_Notice_RubriqueFacette::parseRubriquesFromPreferenceField($codes); + + foreach($rubriques as $rubrique) { + $type = $rubrique->getCode(); + if (!isset($facets[$type])) + continue; + + + $html .= $this->_tag('li', + $this->_tag('b', $rubrique->getLibelle()) + . $this->listeFacettesElementHTML($type, $facets[$type], $url), + ['class' => 'facette_titre list-group-item border-0 py-1 my-1']); + } + + $attribs = ['class' => 'multi_facets_submit bouton btn btn-sm btn-primary mb-2', + 'type' => 'submit', + 'name' => 'multi_facets_submit']; + + if (!$this->_preferences['multi_facettes']) + $attribs = array_merge($attribs, ['style' => 'display: none;']); + + $button = $this->view->tag('button', $this->_('Affiner'), $attribs); + + return $this->_tag('form', + $button + . $this->_tag('ul', $html, ['class' => 'list-group border-0 mb-2']) + . $button, + ['method' => 'POST', + 'class' => 'no_overflow mb-2', + 'action' => $this->view->url($url)]); + } + + + public function listeFacettesElementHTML($type, $values, $url) { + $count = (new Class_AdminVar_UnleashedFacets())->isUnleashed($type) + ? count($values) + : $this->_preferences['facettes_nombre']; + + $first_facets = array_splice($values, 0, $count); + $following_facets = array_splice($values, 0, $count); + + $html = ''; + foreach($first_facets as $code => $count) + $html .= $this->renderLIFacette($url, $code, $count); + + if ($following_facets) + $html .= $this->_renderFollowingFacets($type, $following_facets, $url); + + return $this->_tag('ul', $html, + ['class' => 'list-group', + 'style' => 'list-style:none']); + } + + + protected function _renderFollowingFacets($type, $facets, $url) { + $html = ''; + foreach($facets as $code => $count) + $html .= $this->renderLIFacette($url, $code, $count); + + return $this + ->_tag('li', + $this->_tag('a', + $this->_('Afficher plus de facettes...'), + ['href' => '#', + 'title' => $this->_('Afficher plus de facettes "%s"', + Class_Codification::getInstance()->getNomChamp($code))]) + . $this->_tag('ul', $html, + ['id' => $type . '_msg', + 'style' => 'display:none']), + ['class' => 'msg']); + } + + + public function renderLIFacette($url, $code, $count) { + $url['facette'] = $code; + return $this->renderLi($url, $code, $count); + } + + + protected function renderLi($url, $code, $count) { + $label = Class_Codification::getInstance()->getLibelleFacette($code); + $title = Class_Codification::getInstance()->getNomChamp($code); + + return $this + ->_tag('li', + $this->renderCheckbox($code) + . $this->renderLabel($url, $label, $title, $code) + . $this->renderCount($count), + ['class' => 'list-group-item py-1 border-0 d-flex justify-content-between align-items-center facette' . ($this->isActive($code) ? ' selected' : '')]); + } + + + protected function renderCheckbox($code) { + $attribs = ['checked' => $this->isActive($code)]; + if (!$this->_preferences['multi_facettes']) + $attribs['style'] = 'display: none;'; + + return $this->view->formCheckbox($this->multiFacetNameFor($code), null, $attribs); + } + + + protected function renderLabel($url, $label, $title, $code) { + if ($this->isActive($code)) + return $this->renderRemove($code, $label); + + return $this->view->tagAnchor($this->view->url($url, null, true), + $label, + ['class' => 'facette', + 'title' => $this->view->_('Affiner le résultat par %s: %s', lcfirst($title), $label)]); + } + + + protected function renderCount($count) { + return $this->_tag('span', $count, ['class' => 'badge badge-primary badge-pill']); + } + + + protected function renderRemove($code, $label) { + $facet = Class_Notice_Facette::find($code); + $remove_url = $this->view->url($this->_criteres->getUrlRemoveAllFacet($facet), + null, + true); + + return $this->view->tagAnchor($remove_url, + $label, + ['class' => 'facette', + 'title' => $this->view->_('Retirer la facette: %s', $label)]); + } + + + protected function isActive($code) { + return in_array($code, $this->_criteres->getFacettes()) || $this->isMultiActive($code); + } + + + protected function isMultiActive($code) { + return in_array($code, $this->_criteres->getMultiFacets()); + } + + + protected function multiFacetNameFor($code) { + return static::MULTI_FACET_KEY . $code; + } + + + public static function multifacetCodeFromKey($key) { + return static::isMultiFacetKey($key) ? substr($key, strlen(static::MULTI_FACET_KEY)) : null; + } + + + public static function isMultiFacetKey($key) { + return static::MULTI_FACET_KEY == substr($key, 0, strlen(static::MULTI_FACET_KEY)); + } + + + public static function extractMultiFacets($datas) { + if (!$datas) + return null; + + $facets = []; + foreach($datas as $k => $v) + $facets = static::_extractMultiFacet($facets, $k, $v); + + return $facets; + } + + + protected static function _extractMultiFacet($facets, $k, $v) { + if ($facet = static::multifacetCodeFromKey($k)) { + $facets[$facet] = $v; + return $facets; + } + + if (0 !== strpos($k, 'custom_multifacets_')) + return $facets; + + if (!is_array($v)) { + $facets[$v] = 1; + return $facets; + } + + return array_merge($facets, + array_combine($v, array_fill(0, count($v), 1))); + } +} \ No newline at end of file diff --git a/library/templates/Intonation/View/Search/HtmlCriteria.php b/library/templates/Intonation/View/Search/HtmlCriteria.php new file mode 100644 index 0000000000000000000000000000000000000000..f6fdc0cfb9e4860676e568287cdf0e7be32c73c4 --- /dev/null +++ b/library/templates/Intonation/View/Search/HtmlCriteria.php @@ -0,0 +1,101 @@ +<?php +/** + * Copyright (c) 2012, 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 Intonation_View_Search_HtmlCriteria extends ZendAfi_View_Helper_TagCriteresRecherche { + protected $_cache; + + public function search_HtmlCriteria($criteres_recherche) { + if ($this->_cache) + return $this->_cache; + + $criteres_recherche = (new Intonation_Library_Search_Criteria) + ->from($criteres_recherche); + + $this->visitCriteresRecherche($criteres_recherche); + $this->_injectMultiFacets(); + + return $this->_cache = $this->_tag('div', $this->_html, + ['class' => 'criteres_recherche']); + } + + + public function visitMultiFacet($facet) { + if (!$facet) + return; + + $model = new Class_Notice_Facette($facet); + $key = $model->getRubrique()->getCode(); + if (!isset($this->_multi_facets[$key])) + $this->_multi_facets[$key] = ['label' => $model->getCodeRubriqueLibelle(), + 'facet' => $model, + 'values' => []]; + + $this->_multi_facets[$key]['values'][] = $model->getLibelleFacette(); + } + + + public function visitExpression($expression) { + if ($this->_criteres_recherche->getFacettes() || $this->_criteres_recherche->getMultiFacets()) + $this->_html .= $this->_tag('span', + $this->_('Restreint à :') . ' ', + ['class' => 'btn mb-2 btn-sm ml-0 pl-0']); + } + + + public function visitFacette($facette) { + $facette = new Class_Notice_Facette($facette); + $libelle = $facette->getCodeRubriqueLibelle() . ': ' . $facette->getLibelleFacette(); + $this->htmlAppend($this->getSuppressionImgUrlForLibelle($libelle, + $this->_criteres_recherche->getUrlRemoveAllFacet($facette))); + } + + + protected function _injectMultiFacets() { + foreach($this->_multi_facets as $code => $definition) { + $label = $definition['label'] . ': ' . implode($this->_(' ou '), $definition['values']); + $url = $this->_criteres_recherche->getUrlRemoveAllFacet($definition['facet']); + $this->htmlAppend($this->getSuppressionImgUrlForLibelle($label, $url)); + } + + return $this; + } + + + public function getSuppressionImgUrlForLibelle($label, $url) { + unset($url['page']); + + $text = $this->view->escape($label); + $title = $this->_('Retirer le critère: %s', $text); + + return $this->view->tagAnchor($this->view->url($url, null, true), + sprintf('%s %s', + $text, + Class_Template::current()->getIco($this->view, 'clean', 'utils')), + ['title' => $title, + 'class' => 'btn btn-warning btn-sm mb-2 mr-2 text-dark']); + } + + + public function htmlAppend($text, $attribs = ['class' => 'd-inline-block']) { + return parent::htmlAppend($text, $attribs); + } +} \ No newline at end of file diff --git a/library/templates/Intonation/View/Search/Result.php b/library/templates/Intonation/View/Search/Result.php index f1ebbfcc1f9c130cc66ed7591980910cd5f0c35c..7c611027b4b3092d907cacf29a58f59997548fbf 100644 --- a/library/templates/Intonation/View/Search/Result.php +++ b/library/templates/Intonation/View/Search/Result.php @@ -31,7 +31,7 @@ class Intonation_View_Search_Result extends ZendAfi_View_Helper_BaseHelper { ->setView($this->view); }, $records); - $records = Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR == $search->getCriteresRecherche()->getFormat() + $records_html = Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR == $search->getCriteresRecherche()->getFormat() ? $this->view->renderWall(new Storm_Collection($records), function($wrapped) { @@ -43,19 +43,36 @@ class Intonation_View_Search_Result extends ZendAfi_View_Helper_BaseHelper { return $this->view->cardifyHorizontal($wrapped); }); - $facets = $this->view->facettes($search->fetchFacetsAndTags($search->getSettings())['facettes'], - $search->getSettings(), - $search->getCriteresRecherche()); + $facets = $this->view->renderExpandable($this->view->search_Facets($search->fetchFacetsAndTags($search->getSettings())['facettes'], + $search->getSettings(), + $search->getCriteresRecherche())); $criteria = $search->getCriteresRecherche(); - $html_criteria = $this->view->tagCriteresRecherche($criteria); + $html_criteria = $this->view->search_HtmlCriteria($criteria); + $text_criteria = $this->view->search_TextCriteria($criteria); $title_from_url = $this->view->titre ? $this->view->titre : '*'; $this->view->titre = $this->_('Résultats pour %s %s', - $criteria->getExpressionRecherche() ? $criteria->getExpressionRecherche() : $title_from_url, - strip_tags($html_criteria)); + strtolower(($criteria->getExpressionRecherche() + ? $criteria->getExpressionRecherche() + : $title_from_url)), + strtolower($text_criteria)); + + $tools = $records + ? $this->_div(['class' => 'col-12 border-top border-bottom pt-2 mb-2 search_tools'], + $this->_renderTools($search, $criteria)) + : ''; + + $result = $records + ? $this->_div(['class' => 'col-12 col-md-9'], + $this->view->div(['class' => 'ml-md-3'], + $records_html)) + : $this->_div(['class' => 'col-12'], + $this->_tag('p', + $this->_('Aucun résultat'), + ['class' => 'text-center text-info p-3 m-3'])); $html = [$this->_div(['class' => 'col-12'], $this->_tag('h1', @@ -65,14 +82,16 @@ class Intonation_View_Search_Result extends ZendAfi_View_Helper_BaseHelper { $this->_div(['class' => 'col-12'], $html_criteria), - $this->_div(['class' => 'col-12'], - $this->_renderTools($search, $criteria)), + $tools, + + ($records + ? $this->_div(['class' => 'col-12 col-md-3'], + $facets) + : ''), - $this->_div(['class' => 'col-12 col-md-3 order-2 order-md-1 p-3'], - $facets), + $result, - $this->_div(['class' => 'col-12 col-md-9 order-1 order-md-2 px-3 my-3'], - $records)]; + $tools]; return $this->view->grid(implode($html), [], ['class' => 'justify-content-center']); } @@ -81,21 +100,25 @@ class Intonation_View_Search_Result extends ZendAfi_View_Helper_BaseHelper { protected function _renderTools($search, $criteria) { $wall_active = Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR == $search->getCriteresRecherche()->getFormat(); - $tools = [$this->view->button(new Class_Entity(['Url' => $this->view->url(['liste_format' => Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR]), - 'Image' => Class_Template::current()->getIco($this->view, 'wall', 'utils'), - 'Text' => $this->_('Mur'), - 'Title' => $this->_('Afficher le résultat de recherche en mode mur'), - 'Attribs' => ['class' => 'list_format' . ($wall_active ? ' active' : '')]])), + $tools = [$this->_tag( 'span' , + $this->_( '%d résultats' , $search->getRecordsCount()), + ['class' => 'btn btn-sm btn-info']), $this->view->button(new Class_Entity(['Url' => $this->view->url(['liste_format' => Class_Systeme_ModulesAppli::LISTE_FORMAT_LIST]), 'Image' => Class_Template::current()->getIco($this->view, 'list', 'utils'), 'Text' => $this->_('Liste'), 'Title' => $this->_('Afficher le résultat de recherche en mode liste'), - 'Attribs' => ['class' => 'ml-n3 list_format' . ($wall_active ? '' : ' active')]])), + 'Attribs' => ['class' => 'btn-sm list_format' . ($wall_active ? '' : ' active')]])), - $this->view->search_Order($criteria), + $this->view->button(new Class_Entity(['Url' => $this->view->url(['liste_format' => Class_Systeme_ModulesAppli::LISTE_FORMAT_MUR]), + 'Image' => Class_Template::current()->getIco($this->view, 'wall', 'utils'), + 'Text' => $this->_('Mur'), + 'Title' => $this->_('Afficher le résultat de recherche en mode mur'), + 'Attribs' => ['class' => 'btn-sm list_format' . ($wall_active ? ' active' : '')]])), - $this->view->search_PageSize($criteria)]; + $this->view->search_PageSize($criteria), + + $this->view->search_Order($criteria)]; $tools = array_merge($tools, $this->_pager($search, $criteria)); @@ -108,12 +131,16 @@ class Intonation_View_Search_Result extends ZendAfi_View_Helper_BaseHelper { ->setModel($bookmarked_search) ->setView($this->view); - $tools [] = $this->view->tagAction($search_wrapper->getMainLink()); + $tools [] = $this->view->tagAction($search_wrapper + ->getMainLink() + ->setAttribs(['data-popup' => true, + 'class' => 'btn btn-sm btn-primary text-white'])); $tools = array_map(function($tool) { - return $this->view->div(['class' => 'text-left nav-item px-3 mx-3 mb-1'], - $tool); + return $this->_tag('li', + $tool, + ['class' => 'nav-item mb-2']); }, $tools); @@ -130,23 +157,19 @@ class Intonation_View_Search_Result extends ZendAfi_View_Helper_BaseHelper { $count_pages = ceil( $count_result / $page_size ); - return [$this->_tag( 'span' , - $this->_( '%d résultats' , $count_result ), - ['class' => 'btn']), - - $this->view->div([], + return [$this->view->div([], implode([$this->view->tagAnchor(['page' => $current_page -1], - $this->_tag('i','',['class' => 'fas fa-chevron-left']), + $this->_tag('i','',['class' => 'fas fa-chevron-left m-0']), ['title' => $this->_('page précedente'), - 'class' => 'btn']), + 'class' => 'btn btn-sm btn-secondary']), $this->_tag( 'span' , $this->_('Page %d / %d' , $current_page, $count_pages), - ['class' => 'btn']), + ['class' => 'btn btn-sm']), $this->view->tagAnchor(['page' => $current_page +1], - $this->_tag('i','',['class' => 'fas fa-chevron-right']), + $this->_tag('i','',['class' => 'fas fa-chevron-right m-0']), ['title' => $this->_('page suivante'), - 'class' => 'btn'])]))]; + 'class' => 'btn btn-sm btn-secondary'])]))]; } } diff --git a/library/templates/Intonation/View/Search/TextCriteria.php b/library/templates/Intonation/View/Search/TextCriteria.php new file mode 100644 index 0000000000000000000000000000000000000000..d64a887995fe4901ac99d8bb83a64afbdedcfd7e --- /dev/null +++ b/library/templates/Intonation/View/Search/TextCriteria.php @@ -0,0 +1,82 @@ +<?php +/** + * Copyright (c) 2012, 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 Intonation_View_Search_TextCriteria extends ZendAfi_View_Helper_TagCriteresRecherche { + + public function search_TextCriteria($criteres_recherche) { + $criteres_recherche = (new Intonation_Library_Search_Criteria) + ->from($criteres_recherche); + + $this->visitCriteresRecherche($criteres_recherche); + $this->_injectMultiFacets(); + + return $this->_html; + } + + + public function visitMultiFacet($facet) { + if (!$facet) + return; + + $model = new Class_Notice_Facette($facet); + $key = $model->getRubrique()->getCode(); + if (!isset($this->_multi_facets[$key])) + $this->_multi_facets[$key] = ['label' => $model->getCodeRubriqueLibelle(), + 'facet' => $model, + 'values' => []]; + + $this->_multi_facets[$key]['values'][] = $model->getLibelleFacette(); + } + + + public function visitExpression($expression) { + } + + + public function visitFacette($facette) { + $facette = new Class_Notice_Facette($facette); + $libelle = $facette->getCodeRubriqueLibelle() . ': ' . $facette->getLibelleFacette(); + $this->htmlAppend($libelle); + } + + + protected function _injectMultiFacets() { + foreach($this->_multi_facets as $code => $definition) { + $label = $definition['label'] . ': ' . implode($this->_(' ou '), $definition['values']); + $url = $this->_criteres_recherche->getUrlRemoveAllFacet($definition['facet']); + $this->htmlAppend($label); + } + + return $this; + } + + + public function getSuppressionImgUrlForLibelle($label, $url) { + unset($url['page']); + return $this->view->escape($label); + } + + + public function htmlAppend($text, $attribs = []) { + return $this->_html .= ', ' . $this->view->escape($text); + } +} \ No newline at end of file diff --git a/library/templates/Intonation/View/SelectWidget.php b/library/templates/Intonation/View/SelectWidget.php index ed8647670e06322ff24f9b5d517ba23d8f278085..a06b1025ede982aacb64b4f296543acb8a565d10 100644 --- a/library/templates/Intonation/View/SelectWidget.php +++ b/library/templates/Intonation/View/SelectWidget.php @@ -31,7 +31,7 @@ class Intonation_View_SelectWidget extends ZendAfi_View_Helper_BaseHelper { 'action' => 'simple', $key => null]); - $onchange = "var value=$('#" . $id . "').val();document.location='" . $url_str . "/" . $key . "/'+value;"; + $onchange = "var value=$(this).val();document.location='" . $url_str . "/" . $key . "/'+value;"; $form = new ZendAfi_Form; diff --git a/library/templates/Intonation/View/SocialNetworksActions.php b/library/templates/Intonation/View/SocialNetworksActions.php new file mode 100644 index 0000000000000000000000000000000000000000..10ed79bee6bb15aa1d0dd84501b7d62eac1c2d16 --- /dev/null +++ b/library/templates/Intonation/View/SocialNetworksActions.php @@ -0,0 +1,49 @@ +<?php +/** + * Copyright (c) 2012-2019, 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 Intonation_View_SocialNetworksActions extends ZendAfi_View_Helper_ReseauxSociaux { + protected $_actions = []; + + public function socialNetworksActions($instance) { + parent::reseauxSociaux($instance); + $actions = $this->_actions; + $this->_actions = []; + return $actions; + } + + + public function shareLinkImgHtml($clef, $url_table) { + $label = $this->_('Partager %s sur %s', $url_table['titre'], $clef); + + $this->_actions [] = new Intonation_Library_Link(['Image' => (Class_Template::current() + ->getIco($this->view, + $clef, + 'utils')), + 'Tag' => 'button', + 'Text' => $clef, + 'Title' => $label, + 'Attribs' => ['class' => 'btn btn-link p-0', + 'onclick' => sprintf('$.getScript(\'%s\')', $this->getScriptFromController($url_table))]]); + + return ''; + } +} diff --git a/library/templates/Intonation/View/TagAction.php b/library/templates/Intonation/View/TagAction.php index 637a71cc12910eefd7655dde1ed6a55720955336..59e4f3388b90c116cc44d70c9058a7531784b724 100644 --- a/library/templates/Intonation/View/TagAction.php +++ b/library/templates/Intonation/View/TagAction.php @@ -25,10 +25,24 @@ class Intonation_View_TagAction extends ZendAfi_View_Helper_BaseHelper { if (!$action) return ''; + if (is_string($action)) + return $action; + $attribs = ($attribs = $action->getAttribs()) ? $attribs : []; + $classes = 'card-link'; + + if (isset($attribs['class'])) { + $classes .= ' ' . $attribs['class']; + unset($attribs['class']); + } + + $classes .= ($class = $action->getClass()) + ? ' ' . $class + : ''; + $img = ($img = $action->getImage()) ? $img : ''; @@ -36,10 +50,14 @@ class Intonation_View_TagAction extends ZendAfi_View_Helper_BaseHelper { if ('button' == $action->getTag()) return $this->view->button($action); - $content = $img . $action->getText(); + $text = $this->_getText($action, $img); + + if (!$content = $img . $text) + return ''; + $attribs = array_merge(['title' => $action->getTitle(), 'data-popup' => $action->getPopup(), - 'class' => 'card-link ' . $action->getClasses()], + 'class' => $classes], $attribs); return ($url = $action->getUrl()) @@ -50,4 +68,15 @@ class Intonation_View_TagAction extends ZendAfi_View_Helper_BaseHelper { $content, $attribs); } -} + + + protected function _getText($action, $img) { + if (!$text = $action->getText()) + return ''; + + if (!$img) + return $this->_tag('div', $text, ['class' => ' d-inline-block button_text']); + + return $this->_tag('div', $text, ['class' => 'd-none d-sm-inline-block button_text']); + } +} \ No newline at end of file diff --git a/library/templates/Intonation/View/TagCriteresRecherche.php b/library/templates/Intonation/View/TagCriteresRecherche.php index 08a4adba2a0fa87db53788e412cbbce363357ea4..2e606ee3231f32a992093a132b1806d4cf86f2cb 100644 --- a/library/templates/Intonation/View/TagCriteresRecherche.php +++ b/library/templates/Intonation/View/TagCriteresRecherche.php @@ -20,16 +20,12 @@ */ -class Intonation_View_TagCriteresRecherche extends ZendAfi_View_Helper_BaseHelper { - use Trait_SearchCriteriaVisitor; - - protected - $_html = '', - $_current_facettes = [], - $_multi_facets = []; - +class Intonation_View_TagCriteresRecherche extends ZendAfi_View_Helper_TagCriteresRecherche { public function tagCriteresRecherche($criteres_recherche) { + $criteres_recherche = (new Intonation_Library_Search_Criteria) + ->from($criteres_recherche); + $this->visitCriteresRecherche($criteres_recherche); $this->_injectMultiFacets(); @@ -38,90 +34,26 @@ class Intonation_View_TagCriteresRecherche extends ZendAfi_View_Helper_BaseHelpe } - public function visitCriteresRecherche($criteres_recherche) { - if (!isset($criteres_recherche)) - return ''; - - $this->_criteres_recherche = $criteres_recherche; - $this->_current_facettes = $criteres_recherche->getFacettes(); - $this->_multi_facets = []; - - $this->_libelles_operateur = ['and' => '', - 'or' => $this->_(' ou '), - 'and not' => $this->_(' sauf ')]; - - $this->_libelles_criteres = [ - 'titres' => $this->_('Titre'), - 'auteurs' => ($libelle = Class_AdminVar::get('FACETTE_AUTEUR_LIBELLE')) ? $libelle : $this->_('Auteur'), - 'matieres' => ($libelle = Class_AdminVar::get('FACETTE_MATIERE_LIBELLE')) ? $libelle : $this->_('Sujet'), - 'dewey' => ($libelle = Class_AdminVar::get('FACETTE_DEWEY_LIBELLE')) ? $libelle :$this->_('Dewey / pcdm4'), - 'collection' => $this->_('Collection') ]; - - if (isset($criteres_recherche)) - $criteres_recherche->acceptVisitor($this); - } - - - public function visitTextInput($name, $operateur, $type_recherche, $value) { - $libelle_operateur = $operateur ? $this->_libelles_operateur[$operateur] : ' et '; - $libelle = $libelle_operateur. - $this->_libelles_criteres[$name] . ' ' . - $this->_($type_recherche == 'commence' ? 'commence par': ':') .' ' . $value; - - $url = $this->_criteres_recherche->getUrlCriteresWithoutElement('rech_'.$name); - - $this->htmlAppend($this->getSuppressionImgUrlForLibelle($libelle, $url)); - } - - - public function visitNouveaute($nouveaute) { - if ($nouveaute == 0) + public function visitMultiFacet($facet) { + if (!$facet) return; - $url = $this->_criteres_recherche->getUrlCriteresWithoutElement('nouveaute'); - $libelle = $this->view->_('Nouveautés de moins de: ') . $nouveaute . ' ' . $this->_('mois'); - $this->htmlAppend($this->getSuppressionImgUrlForLibelle($libelle, $url)); - } - - - public function visitAnnexe($annexe) { - $this - ->htmlAppend($this->view->_('Site: %s', Class_Codification::getInstance()->getLibelleFacette('Y' . $annexe))) - ->htmlAppend(' » ' . $this->_tag('a', $this->_('Elargir la recherche à tous les sites'), - ['href' => $this->view->url(['annexe' => null])])); - } - - - public function visitTypeDoc($type_docs) { - $type_doc = array_shift($type_docs); - $url = $this->_criteres_recherche->getUrlCriteresWithoutElement('type_doc'); - $libelle = $this->view->_('Type de document: %s', Class_Codification::getInstance()->getLibelleFacette('T' . $type_doc)); - $this->htmlAppend($this->getSuppressionImgUrlForLibelle($libelle, $url)); - } - - - public function visitSerie($serie,$tri) { - $url = $this->_criteres_recherche->getUrlCriteresWithoutElement('serie'); - $libelle = Class_Codification::getLibelleForSerie(Class_Notice::findFirstNoticeForClefChapeau($serie)); - $this->htmlAppend($this->getSuppressionImgUrlForLibelle($libelle, $url)); - } - + $model = new Class_Notice_Facette($facet); + $key = $model->getRubrique()->getCode(); + if (!isset($this->_multi_facets[$key])) + $this->_multi_facets[$key] = ['label' => $model->getCodeRubriqueLibelle(), + 'facet' => $model, + 'values' => []]; - public function visitCodeRebond($code_rebond) { - $url = $this->_criteres_recherche->getUrlCriteresWithoutElement('code_rebond'); - $libelle = $this->view->_("Recherche élargie à : %s", Class_Codification::getInstance()->getLibelleFacette($code_rebond)); - $this->htmlAppend($this->getSuppressionImgUrlForLibelle($libelle, $url)); + $this->_multi_facets[$key]['values'][] = $model->getLibelleFacette(); } - public function visitAnneeDebutFin($annee_debut, $annee_fin) { - $texte = $this->view->_('Documents parus '); - $texte .= ($annee_debut == $annee_fin) - ? 'en ' . $annee_debut - : $this->view->_('entre %s et %s', $annee_debut, $annee_fin); - $url = $this->_criteres_recherche->getUrlCriteresWithoutElement('annee_debut'); - unset($url['annee_fin']); - $this->htmlAppend($this->getSuppressionImgUrlForLibelle($texte, $url)); + public function visitExpression($expression) { + if ($this->_criteres_recherche->getFacettes() || $this->_criteres_recherche->getMultiFacets()) + $this->_html .= $this->_tag('span', + $this->_('Restreint à :') . ' ', + ['class' => 'btn mb-2 btn-sm ml-0 pl-0']); } @@ -129,114 +61,36 @@ class Intonation_View_TagCriteresRecherche extends ZendAfi_View_Helper_BaseHelpe $facette = new Class_Notice_Facette($facette); $libelle = $facette->getCodeRubriqueLibelle() . ': ' . $facette->getLibelleFacette(); $this->htmlAppend($this->getSuppressionImgUrlForLibelle($libelle, - $this->_criteres_recherche->getUrlRemoveFacette($facette))); - } - - - public function getSuppressionImgUrlForLibelle($libelle, $url) { - unset($url['page']); - $title = $this->view->_('Retirer le critère: %s', $libelle); - return $this->view->tagAnchor($this->view->url($url, null, true), - $this->view->escape($libelle) . - ' ' . Class_Template::current()->getIco($this->view, 'clean', 'utils'), - ['title' => $title, - 'class' => 'btn btn-warning btn-sm mb-3 ml-3 text-dark']); - } - - - public function htmlAppend($text, $attribs = ['class' => 'd-inline-block']) { - $this->_html .= $this->_tag('div', - $text, - $attribs ); - return $this; - } - - - public function visitExpression($expression) { - if ($this->_current_facettes) - $this->_html .= $this->_tag('span', - $this->_('Restreint à :') . ' ', - ['class' => 'btn mb-3 btn-small']); - } - - - public function visitEditor($editor) { - $this->htmlAppend($this->getSuppressionImgUrlForLibelle($this->view->_('Editeur : %s', $editor), - $this->_criteres_recherche->getUrlCriteresWithoutElement('rech_editeur'))); - } - - - public function visitCatalogue($catalogue) { - $this - ->htmlAppend($this->getSuppressionImgUrlForLibelle($catalogue->getLibelle(), - $this->_criteres_recherche->getUrlCriteresWithoutElement('id_catalogue'))); - } - - - public function visitSelection($selection) { - $this - ->htmlAppend($this->getSuppressionImgUrlForLibelle($this->_('Sélection courante'), - $this->_criteres_recherche->getUrlCriteresWithoutElement('selection'))); - } - - - public function visitSection($section) { - $url = $this->_criteres_recherche->getUrlCriteresWithoutElement('section'); - $libelle = $this->_('Section: %s', Class_Codification::getInstance()->getLibelleFacette('S'.$section)); - $this->htmlAppend($this->getSuppressionImgUrlForLibelle($libelle,$url)); - } - - - public function visitFiltre($filtre) { - $libelle=[]; - - foreach ($filtre as $facet) { - $model = new Class_Notice_Facette($facet); - $key = $model->getRubrique()->getCode(); - $libelle[] = $model->getLibelleFacette(); - } - - $label = $model->getCodeRubriqueLibelle() . ': ' - . implode($this->_(' OU '), $libelle); - - $this->htmlAppend($label, ['class' => 'unremovable_criterion']); - } - - - public function visitMultiFacet($facet) { - if (!$facet) - return; - - $model = new Class_Notice_Facette($facet); - $key = $model->getRubrique()->getCode(); - if (!isset($this->_multi_facets[$key])) - $this->_multi_facets[$key] = ['label' => $model->getCodeRubriqueLibelle(), - 'values' => []]; - - $this->_multi_facets[$key]['values'][] = $model->getLibelleFacette(); + $this->_criteres_recherche->getUrlRemoveAllFacet($facette))); } protected function _injectMultiFacets() { foreach($this->_multi_facets as $code => $definition) { - $label = $definition['label'] . ': ' . implode($this->_(' OU '), $definition['values']); - $url = $this->_criteres_recherche->getUrlRemoveMultiFacet($code); + $label = $definition['label'] . ': ' . implode($this->_(' ou '), $definition['values']); + $url = $this->_criteres_recherche->getUrlRemoveAllFacet($definition['facet']); $this->htmlAppend($this->getSuppressionImgUrlForLibelle($label, $url)); } + + return $this; } - public function visitBookmarkedSearch($search, $version) { - if (!$search) - return; + public function getSuppressionImgUrlForLibelle($label, $url) { + unset($url['page']); - if (!$version) - return; + $title = $this->_('Retirer le critère: %s', $this->view->escape($label)); + + return $this->view->tagAnchor($this->view->url($url, null, true), + sprintf('%s %s', + $title, + Class_Template::current()->getIco($this->view, 'clean', 'utils')), + ['title' => $title, + 'class' => 'btn btn-warning btn-sm mb-2 mr-2 text-dark']); + } - $label = $this->_('Nouveautés du %s', - strftime($this->_('%d %B %Y'), $version->getDate())); - $url = $this->_criteres_recherche->getUrlRemoveBookmarkVersion(); - $this->htmlAppend($this->getSuppressionImgUrlForLibelle($label, $url)); + public function htmlAppend($text, $attribs = ['class' => 'd-inline-block']) { + return parent::htmlAppend($text, $attribs); } } \ No newline at end of file diff --git a/library/templates/Intonation/View/TagListeCoches.php b/library/templates/Intonation/View/TagListeCoches.php index b28dc578f9fe5b8e193aafc316bdf76a32308689..bb888c6bfbec1ce28ebffe49e1ab14da5b319e1d 100644 --- a/library/templates/Intonation/View/TagListeCoches.php +++ b/library/templates/Intonation/View/TagListeCoches.php @@ -63,7 +63,7 @@ class Intonation_View_TagListeCoches extends ZendAfi_View_Helper_TagListeCoches $this->view->tagAnchor(sprintf($selectAll, $flag), $label, - ['class' => 'btn btn-small btn-primary text-white']); + ['class' => 'btn btn-sm btn-primary text-white']); } diff --git a/library/templates/Intonation/View/TagMedia.php b/library/templates/Intonation/View/TagMedia.php index c4cd5e6b13d43ac0f9f237a238799bb61b816832..463ebf3583357a60d8cfe5ab3d4c75f12793473a 100644 --- a/library/templates/Intonation/View/TagMedia.php +++ b/library/templates/Intonation/View/TagMedia.php @@ -29,11 +29,16 @@ class Intonation_View_TagMedia extends ZendAfi_View_Helper_BaseHelper { if (!$media = $this->_getMedia($instance, $attribs, $img_attribs)) return ''; - return ($img_link = $instance->getMainLink()) + if (!$img_link = $instance->getMainLink()) + return $media; + + return $instance->getEmbedMedia() ? $this->view->tagAction($img_link - ->setText($media) - ->setImage('')) - : $media; + ->setText($media) + ->setImage('')) + : $this->view->tagAction($img_link + ->setText('') + ->setImage($media)); } diff --git a/library/templates/Intonation/View/Truncate.php b/library/templates/Intonation/View/Truncate.php index d38cb06edfacde2828b660ee253a320353d426f7..2824d2e2a4fc3a13817ba3f723d30ada4bc41698 100644 --- a/library/templates/Intonation/View/Truncate.php +++ b/library/templates/Intonation/View/Truncate.php @@ -34,7 +34,9 @@ class Intonation_View_Truncate extends ZendAfi_View_Helper_BaseHelper { $ellipsis = array_filter(explode(' ', $text)); if ($size >= count($ellipsis)) - return $text; + return $this->_tag($tag, + $text, + $attribs); $ellipsis = array_slice($ellipsis, 0, $size); diff --git a/scripts/clean_local_dymanic_facets.php b/scripts/clean_local_dymanic_facets.php new file mode 100644 index 0000000000000000000000000000000000000000..a4276595903a9e37d10a97e55d3a0971ef033259 --- /dev/null +++ b/scripts/clean_local_dymanic_facets.php @@ -0,0 +1,43 @@ +<?php +error_reporting(E_ERROR | E_PARSE); +require(__DIR__.'/../console.php'); + +echo "\n\nWelcome to the iFacetsCleaner Platinum tool by @patbator\n\n"; + +class Scripts_Local_DynamicFacets_Cleaner { + + public function clean($record) { + $existing = array_filter(explode(' ', $record->getFacettes())); + foreach($existing as $facet) + $is_hmot = $is_hmot || 'MOTC' == substr($facet, 1, 4); + + if (!$is_hmot) + return; + + echo '.'; + + $facets = []; + foreach($existing as $facet) { + if ((Class_CodifThesaurus::CODE_FACETTE != substr($facet, 0, 1)) + || (1 == Class_CodifThesaurus::countBy(['id_thesaurus' => substr($facet, 1)]))) + $facets[] = $facet; + } + + $record->setFacettes($facets); + $record->save(); + } +} + +$cleaner = new Scripts_Local_DynamicFacets_Cleaner(); +$page = 1; +while ($records = Class_Notice::findAllBy(['type' => Class_Notice::TYPE_BIBLIOGRAPHIC, + 'limitPage' => [$page, 1000]])) { + echo "\npage: $page\n"; + $page ++; + array_map([$cleaner, 'clean'], $records); + Storm_Model_Abstract::unsetLoaders(); + Storm_Model_Loader::resetCache(); + gc_collect_cycles(); +} + +echo "\n\nDONE !!!!\n\n"; \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php index ec3437d004b60cb365eebda492ddf2349dd17d82..7e6bee1b6998a13cc50e66c2e5500951068a53b6 100644 --- a/tests/scenarios/Templates/TemplatesTest.php +++ b/tests/scenarios/Templates/TemplatesTest.php @@ -832,7 +832,7 @@ class TemplatesDispatchIntonationWithSectionSettingsTest extends TemplatesIntona class TemplatesDispatchIntonationSearchTest extends TemplatesIntonationTestCase { public function setUp() { parent::setUp(); - $this->dispatch('/opac/recherche/simple/expressionRecherche/pomme/id_profil/72', true); + $this->dispatch('/opac/recherche/simple/expressionRecherche/pomme/id_profil/72/multifacets/T1-Y1/facette/Y1/section/1', true); } @@ -875,6 +875,11 @@ class TemplatesDispatchIntonationSearchTest extends TemplatesIntonationTestCase public function currentProfilTemplateShouldBeIntonation() { $this->assertEquals('INTONATION', Class_Profil::getCurrentProfil()->getTemplate()); } + + /** @test */ + public function linkToDeleteFacetShoulContainsMultifacetT3() { + $this->assertXPathContentContains('//div[@class="criteres_recherche"]//a[@href="/recherche/simple/expressionRecherche/pomme/multifacets/T1"]', 'Site:'); + } } @@ -2637,19 +2642,59 @@ class TemplatesNoticeajaxMediaDispatchTest extends TemplatesIntonationTestCase { class TemplatesDispatchIntonationSearchListFormatWallTest extends TemplatesIntonationTestCase { public function setUp() { parent::setUp(); - $this->dispatch('/opac/recherche/simple/expressionRecherche/pomme/id_profil/72/list_format/4', true); + + $records = [$this->fixture('Class_Notice', + ['id' => 89]), + $this->fixture('Class_Notice', + ['id' => 99])]; + + $result = $this->mock(); + + $result + ->whenCalled('setDuration') + ->answers($result) + + ->whenCalled('setSettings') + ->answers($result) + + ->whenCalled('getSettings') + ->answers(['facettes' => '']) + + ->whenCalled('fetchFacetsAndTags') + ->answers(['facettes' => '']) + + ->whenCalled('getRecordsCount') + ->answers(2) + + ->whenCalled('isError') + ->answers(false) + + ->whenCalled('getCriteresRecherche') + ->answers((new Intonation_Library_Search_Criteria)->setParams(['liste_format' => 4])) + + ->whenCalled('fetchRecords') + ->answers($records); + + $engine = $this->mock() + + ->whenCalled('lancerRecherche') + ->answers($result); + + Class_MoteurRecherche::setInstance($engine); + + $this->dispatch('/opac/recherche/simple/expressionRecherche/pomme/id_profil/72/liste_format/4/titre/Les documents', true); } /** @test */ public function searchResultShouldBeDisplay() { - $this->assertXPathContentContains('//h1', 'Résultats pour pomme'); + $this->assertXPathContentContains('//h1', 'les documents'); } /** @test */ public function buttonMurShouldBeActive() { - $this->assertXpath('//div//button[contains(@class, "active")][contains(@onclick, "/list_format/4")]'); + $this->assertXpath('//div//button[contains(@class, "active")][contains(@onclick, "/liste_format/4")]'); } } @@ -3094,8 +3139,8 @@ class TemplatesIntonationDispatchAccountEditTest extends TemplatesIntonationAcco class TemplatesIntonationDispatchAbonneSelectionTest extends TemplatesIntonationAccountTestCase { /** @test */ public function exporterSelection2LinkShouldBePresent() { - $this->dispatch('/opac/abonne/selection/id/2/id_profil/72'); - $this->assertXPathContentContains('//a[contains(@href, "/abonne/exporter-la-selection/id/2")]', 'Exporter'); + $this->dispatch('/opac/abonne/selection/selection_id/2/id_profil/72'); + $this->assertXPathContentContains('//a[contains(@href, "/abonne/exporter-la-selection/selection_id/2")]', 'Exporter'); } } @@ -3104,7 +3149,7 @@ class TemplatesIntonationDispatchAbonneSelectionTest extends TemplatesIntonation class TemplatesIntonationDispatchAbonneAjouterASelectionTest extends TemplatesIntonationAccountTestCase { /** @test */ public function titleShouldBeAjouterDesDocumentsALaSelection() { - $this->dispatch('/opac/abonne/ajouter-a-la-selection/id/2/id_profil/72'); + $this->dispatch('/opac/abonne/ajouter-a-la-selection/selection_id/2/id_profil/72'); $this->assertXPathContentContains('//h2', 'Ajouter des documents à la sélection'); } @@ -3121,8 +3166,8 @@ class TemplatesIntonationDispatchAbonneAjouterASelectionTest extends TemplatesIn ->answers($this->mock() ->whenCalled('fetchRecords') ->answers($records))); - $this->dispatch('/opac/abonne/ajouter-a-la-selection/id/2/id_profil/72'); - $this->assertXPath('//a[contains(@onclick, "abonne/ajouter-le-document-a-la-selection/id/2/id_profil/72/record_id/89")]'); + $this->dispatch('/opac/abonne/ajouter-a-la-selection/selection_id/2/id_profil/72'); + $this->assertXPath('//a[contains(@onclick, "abonne/ajouter-le-document-a-la-selection/selection_id/2/id_profil/72/record_id/89")]'); } } @@ -3137,9 +3182,22 @@ class TemplatesIntonationDispatchAbonneAjouterLeDocumentALaSelectionTest extends 'type_doc' => 2, 'clef_alpha' => 'NEIGE']); - $this->dispatch('/opac/abonne/ajouter-le-document-a-la-selection/id/2/id_profil/72/record_id/89'); + $this->dispatch('/opac/abonne/ajouter-le-document-a-la-selection/selection_id/2/id_profil/72/record_id/89'); $this->assertEquals('COMBAT ORDINAIRE;BLACKSAD;NEIGE', Class_PanierNotice::find(2)->getNotices()); } + + + /** @test */ + public function neigeShouldHaveBeenHadedToReaded() { + $this->fixture('Class_Notice', + ['id' => 89, + 'titre_principal' => 'Neige', + 'type_doc' => 2, + 'clef_alpha' => 'NEIGE']); + + $this->dispatch('/opac/abonne/ajouter-le-document-a-la-selection/selection_label/Déjà lu/id_profil/72/record_id/89'); + $this->assertEquals('NEIGE', Class_PanierNotice::findFirstBy(['libelle' => 'Déjà lu'])->getNotices()); + } } @@ -3180,6 +3238,43 @@ class TemplatesIntonationDispatchAbonneSupprimerDeLaSelectionTest extends Templa +class TemplatesIntonationDispatchAbonneSupprimerLaSelectionTest extends TemplatesIntonationAccountTestCase { + + /** @test */ + public function questionToDeleteShouldBePresent() { + $this->dispatch('/opac/abonne/supprimer-la-selection/selection_id/2/id_profil/72'); + $this->assertXPathContentContains('//div//a', 'Oui'); + } + + + /** @test */ + public function selection2ShouldHaveBeenDeleted() { + $this->dispatch('/opac/abonne/supprimer-la-selection/selection_id/2/id_profil/72/delete/1'); + $this->assertNull(Class_PanierNotice::find(2)); + } +} + + + +class TemplatesIntonationDispatchAbonneRenommerLaSelectionTest extends TemplatesIntonationAccountTestCase { + + /** @test */ + public function formToRenameSelectionShouldBePresent() { + $this->dispatch('/opac/abonne/renommer-la-selection/selection_id/2/id_profil/72'); + $this->assertXPath('//form'); + } + + + /** @test */ + public function renameSelectionToTopShouldRenameIt() { + $this->postDispatch('/opac/abonne/renommer-la-selection/selection_id/2/id_profil/72', + ['libelle' => 'Top']); + $this->assertEquals('Top', Class_PanierNotice::find(2)->getLibelle()); + } +} + + + class TemplatesIntonationDispatchAbonneExporterLaSelectionTest extends TemplatesIntonationAccountTestCase { /** @test */ @@ -3188,3 +3283,20 @@ class TemplatesIntonationDispatchAbonneExporterLaSelectionTest extends Templates $this->assertXPathContentContains('//div', 'UNIMARC'); } } + + + + +class TemplatesIntonationDispatchAbonneReserverTest extends TemplatesIntonationAccountTestCase { + /** @test */ + public function itemsShoulbBePresent() { + $record = $this->fixture('Class_Notice', + ['id' => 89, + 'titre_principal' => 'Neige', + 'type_doc' => 2, + 'clef_alpha' => 'NEIGE']); + + $this->dispatch('/opac/abonne/reserver/record_id/89/id_profil/72'); + $this->assertXPathContentContains('//div', 'Neige'); + } +}