diff --git a/application/modules/admin/controllers/ModulesController.php b/application/modules/admin/controllers/ModulesController.php index fd0e5c3a8d17626c11406ea2868a88109127c586..7c78419060befcece36b0e7b33a58c3b66a1bcb1 100644 --- a/application/modules/admin/controllers/ModulesController.php +++ b/application/modules/admin/controllers/ModulesController.php @@ -212,7 +212,6 @@ class Admin_ModulesController extends ZendAfi_Controller_Action { $erreur=''; $enreg=''; - xdebug_break(); if($this->_getParam('action1')=="resultat") { return $this->_forward('search-result'); } @@ -255,7 +254,6 @@ class Admin_ModulesController extends ZendAfi_Controller_Action { 'simple'), $post_values )); - xdebug_break(); if ($this->_request->isPost() && $form->isValid($post_values)) { return $this->updateEtRetour($post_values); } diff --git a/application/modules/opac/controllers/NoticeajaxController.php b/application/modules/opac/controllers/NoticeajaxController.php index d670579769601a77515cfb8095b8352044e42acd..f5d788f35bf5bfd2358e04a5fb471bb84e6e8cbe 100644 --- a/application/modules/opac/controllers/NoticeajaxController.php +++ b/application/modules/opac/controllers/NoticeajaxController.php @@ -477,7 +477,6 @@ class NoticeAjaxController extends Zend_Controller_Action { $criteres_recherche->setParams($this->_request->getParams()); $query=$this->view->tagCVSCriteresRecherche($criteres_recherche); - $cvs = Class_CVSLink::forUser($user); $notices = $cvs->searchNotices($query,$criteres_recherche->getPage(),$this->preferences['cvs_nb_result']); $nb_notices = $cvs->getTotalNotices(); @@ -485,15 +484,16 @@ class NoticeAjaxController extends Zend_Controller_Action { $html = "<script>"; if ($nb_notices) - $html .= "$('.cvs_boite:hidden').slideDown('slow');"; + $html .= "$('.cvs_container:hidden').slideDown('slow');"; $html .= "$(document).ready(function(){ - $('#cvs_resultat .pager a').click(function(){ + $('#cvs_result .pager a').click(function(e){ + e.preventDefault(); var url = $(this).attr('href'); - $('#cvs_resultat').load(url); + $('#cvs_result').load(url); return false; }); $('a[href*=\"modules/cvs\"]').attr('target', '_blank'); -});</script><div id='cvs_resultat'>"; +});</script><div id='cvs_result'>"; $html .= $helper->listeCVSNotices($notices, $nb_notices, diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php index d059a3eb5dd84b2bcfd0beb5645429435db0420f..5102ef96c538e392fc84e2d49bbb46189e874f35 100644 --- a/application/modules/opac/controllers/RechercheController.php +++ b/application/modules/opac/controllers/RechercheController.php @@ -101,12 +101,14 @@ class RechercheController extends ZendAfi_Controller_Action { protected function showCSVSearchResults($criteres_recherche) { + $preferences = Class_Profil::getCurrentProfil()->getSearchResultSettings(); $user = Class_Users::getLoader()->getIdentity(); $this->view->accessCVS=false; - if ($user && $user->hasRightAccesCVS()) { + if (($user && $user->hasRightAccesCVS()) && !$preferences['cvs_display_position']==0) { $this->view->accessCVS=true; + Class_ScriptLoader::getInstance() - ->addJQueryReady("$('<div></div>').load('".$this->view->url($criteres_recherche->getCVSUrlCriteresWithFacettes(),null,true)."').appendTo($('.cvs_boite'))"); + ->addJQueryReady("$('<div></div>').load('".$this->view->url($criteres_recherche->getCVSUrlCriteresWithFacettes(),null,true)."').appendTo($('.cvs_container'))"); } } diff --git a/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml b/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml index 0a81328f233ceb8f0d4a30521a002e922982e65a..73b9b5e7d2abad4195c59fef8cdd6a81023e0074 100644 --- a/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml +++ b/application/modules/opac/views/scripts/recherche/resultatRecherche.phtml @@ -65,20 +65,9 @@ $this->closeBoite(); if (!isset($tags)) $tags=[]; -?> -<?php if ($this->accessCVS) { ?> - <div style="width:100%;display:none" class="cvs_boite"> - <?php - $this->openBoite($preferences['cvs_resultat_titre']); - $this->closeBoite(); - ?> - </div> - <?php - $this->openBoite($preferences['cvs_autres_resultats']); - $this->closeBoite(); - } ?> + <?php $html_liste_notices = $this->listeNotices($this->liste, $nombre, @@ -105,22 +94,40 @@ if (!isset($tags)) $tags=[]; ?> + <div style="width:100%" class="conteneur_simple"> + + <?php + $html_result='<div class="resultat_recherche">'. + (!$preferences['cvs_autres_resultats'] == '' + ? '<h1>'.$preferences['cvs_autres_resultats'].'</h1>' + : ''). + $html_liste_notices.$html_pager. + '</div>'; + ?> + <?php + $html_filters = ''; if ($hasFacettes || $hasTags) { - echo '<div class="filtre_recherche">'; - if ($hasTags && (1 == $tagsPosition)) echo $html_nuage_tags; - if ($hasFacettes) echo $html_facettes; - if ($hasTags && (2 == $tagsPosition)) echo $html_nuage_tags; - echo '</div>'; + $html_filters .= '<div class="filtre_recherche">'; + if ($hasTags && (1 == $tagsPosition)) $html_filters.= $html_nuage_tags; + if ($hasFacettes) $html_filters.= $html_facettes; + if ($hasTags && (2 == $tagsPosition)) $html_filters.= $html_nuage_tags; + $html_filters.= '</div>'; } ?> - <div class="resultat_recherche"> - <?php - echo $html_liste_notices; - echo $html_pager; - ?> - </div> + <?php + $html_cvs=''; + if ($this->accessCVS) + $html_cvs .= '<div class="cvs_container position_'.$preferences['cvs_display_position'].'" style="display:none">'. + '<h1>'.$preferences['cvs_resultat_titre'].'</h1>'. + '</div>'; + + ?> +<?php +echo $this->Search_Result($preferences, $html_result, $html_filters, $html_cvs); +?> + <div class="clear"></div> </div> diff --git a/library/Class/Profil.php b/library/Class/Profil.php index eac5fd6c702ff523eee842d105a263b72e122c04..f014f8bcf50b245f6a9f48864a2fd584699e562f 100644 --- a/library/Class/Profil.php +++ b/library/Class/Profil.php @@ -1649,6 +1649,11 @@ class Class_Profil extends Storm_Model_Abstract { return explode(';', $zones); } + + public function getSearchResultSettings() { + return $this->getConfigurationOf('recherche', 'resultat' , 'simple'); + } + public function getConfigurationOf($module,$action, $action2) { $cfg = $this->getCfgModulesAsArray(); diff --git a/library/ZendAfi/Form/Configuration/SearchResult.php b/library/ZendAfi/Form/Configuration/SearchResult.php index 5b352cec9d918767d73d16101fbeb77774f522ba..c8628a143a385149a61a00d8b78d70bcbaaf7040 100644 --- a/library/ZendAfi/Form/Configuration/SearchResult.php +++ b/library/ZendAfi/Form/Configuration/SearchResult.php @@ -51,7 +51,6 @@ class ZendAfi_Form_Configuration_SearchResult extends ZendAfi_Form { 'facettes_message'], 'facettes', ['legend' => $form->_('Facettes')]) - ->addCvsGroup() ->addDisplayGroup(['tags_actif', 'tags_position', 'tags_calcul', @@ -60,6 +59,7 @@ class ZendAfi_Form_Configuration_SearchResult extends ZendAfi_Form { 'tags_message'], 'tags', ['legend' => $form->_('Nuage de tags')]) + ->addCvsGroup() ->addDisplayGroup(['submit'], 'submit', ['legend' => '']); @@ -187,7 +187,7 @@ class ZendAfi_Form_Configuration_SearchResult extends ZendAfi_Form { ->addElement('codeList', 'tags_codes', ['label' => $this->_('Types de tags'), - 'field' => 'type_tags', + 'field' => 'tags', 'values' => '', 'required' => true, 'validators' => [ diff --git a/library/ZendAfi/Form/Element/CodeList.php b/library/ZendAfi/Form/Element/CodeList.php index 576960b855590542e4f50f9edb347a0285d3cda8..494523507df76b79ff2fc968341c8defa243b889 100644 --- a/library/ZendAfi/Form/Element/CodeList.php +++ b/library/ZendAfi/Form/Element/CodeList.php @@ -58,8 +58,7 @@ class ZendAfi_Form_Element_CodeList extends Zend_Form_Element { public function getValue() { - xdebug_break(); - return $this->_values; + return $this->_values; } diff --git a/library/ZendAfi/View/Helper/ListeCVSNotices.php b/library/ZendAfi/View/Helper/ListeCVSNotices.php index 8eb3d0e8642ba2fc4750ded1f14d52c0de98c380..de91b937672f7ec91218868c12f14577aaec852f 100644 --- a/library/ZendAfi/View/Helper/ListeCVSNotices.php +++ b/library/ZendAfi/View/Helper/ListeCVSNotices.php @@ -18,42 +18,19 @@ * along with AFI-OPAC 2.0; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -////////////////////////////////////////////////////////////////////////////////////////// -// OPAC3 : Liste de notices -// formats : 1=liste normale -// 2=liste accordéon -// 3=liste vignette -// 4=Liste images mur -////////////////////////////////////////////////////////////////////////////////////////// + + class ZendAfi_View_Helper_ListeCVSNotices extends ZendAfi_View_Helper_ListeNotices { - /** - * @param array $notices - * @param int $nombre_resultats - * @param int $page - * @param array $preferences - * @return string - */ + public function listeCVSNotices($notices,$nombre_resultats,$page,$preferences) { - $html = '<div class="liste_notices_cvs" >'; - $html .= $this->displayTriRecherche($page,$nombre_resultats, null); - if(!$nombre_resultats) return $html; - $html = $this->displayList($html,$notices,$preferences); - return ($html.'</div>'); + return + !$nombre_resultats + ? '<span>'. + $this->view->_('Aucun document trouvé'). + '</span>' + : '<div class="cvs_record_list">'. + $this->displayList('',$notices,$preferences). + '</div>'; } - - public function displayTriRecherche($page, $nombre_resultats, $criteres_recherche){ - $html='<div class="resultats_cvs_page"><div><span>'; - if(!$nombre_resultats) $html.= $this->view->_('Aucun document trouvé'); - if($nombre_resultats == 1) $html.=$this->view->_('1 document trouvée'); - if($nombre_resultats > 1) $html.=sprintf($nombre_resultats.' %s',$this->view->_('documents trouvés')); - $html.='</span></div></div>'; - - return $html; - } - - public function getUrlNotice($notice){ - return $this->view->url(['controller' => 'modules', 'action' => 'cvs', 'docid'=> $notice->getId()], null, true); - } - } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Search/Result.php b/library/ZendAfi/View/Helper/Search/Result.php new file mode 100644 index 0000000000000000000000000000000000000000..079f1b5e21221e0496299f03f7d24e3ca1397860 --- /dev/null +++ b/library/ZendAfi/View/Helper/Search/Result.php @@ -0,0 +1,66 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 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). + * + * AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +////////////////////////////////////////////////////////////////////////////////////////// +// OPAC3 : Liste de notices +// formats : 1=liste normale +// 2=liste accordéon +// 3=liste vignette +// 4=Liste images mur +////////////////////////////////////////////////////////////////////////////////////////// + +class ZendAfi_View_Helper_Search_Result extends ZendAfi_View_Helper_BaseHelper { + /** + * @param array $notices + * @param int $nombre_resultats + * @param int $page + * @param array $preferences + * @param string $url + * @param string $tri + * @return string + */ + public function Search_Result($settings, $html_result, $html_filters, $html_cvs) { + $html = + $html_filters. + $html_result. + $html_cvs; + + if($settings['cvs_display_position']=='1') + $html= + $html_result. + $html_cvs. + $html_filters; + + if($settings['cvs_display_position']=='2' || $settings['cvs_display_position']=='4') + $html= + $html_result. + $html_filters. + $html_cvs; + + if($settings['cvs_display_position']=='3') + $html= + $html_cvs. + $html_result. + $html_filters; + + return $html; + + } +} \ No newline at end of file diff --git a/public/opac/css/global.css b/public/opac/css/global.css index a34ff488ba498df5d6e2ef10c3e25725b0e77fbe..85268e90f69ce3ef734bd2d696d9e9404bc300e9 100644 --- a/public/opac/css/global.css +++ b/public/opac/css/global.css @@ -2645,4 +2645,25 @@ a.readspeaker { .barre_nav span + span:before { padding:0px 5px; content:">"; -} \ No newline at end of file +} + + +.cvs_container.position_0 { + display:none!important; +} + +.cvs_container.position_1, +.cvs_container.position_2 { + float:right; + clear:right; + display:block; + width:40%!important; +} + +.cvs_container.position_3, +.cvs_container.position_4 { + float:left; + clear:left; + display:block; + width:100%!important; +} diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php index 8dfbea9dd41c1d366b16e22dfdb9db1ff839de28..a502c84c96972320f6d5e43b2c6edc2587c709dd 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php @@ -964,79 +964,87 @@ class NoticeAjaxControllerNoticeWithAvisAvisTest extends NoticeAjaxControllerNot } - - -abstract class NoticeAjaxControllerCvsSearchTest extends AbstractControllerTestCase { - public function setUp() { - parent::setUp(); - $logged_user=Class_Users::newInstanceWithId(15,['login'=>'polo'])->beAbonneSIGB(); - $this->group_multimedia = Class_UserGroup::newInstanceWithId('20', ['libelle' => 'Multimedia', - 'rights_token' => Class_UserGroup::RIGHT_ACCES_ARTEVOD]); +abstract class NoticeAjaxControllerCvsSearchtest extends AbstractControllerTestCase { + public function setup() { + parent::setup(); + RessourcesNumeriquesFixtures::activateCVS(); + $group_cvs = $this->fixture('Class_UserGroup', ['id' => 20 , + 'libelle' => 'CVS acces', + 'rights_token' => Class_UserGroup::RIGHT_ACCES_ARTEVOD]); + $polo= $this->fixture('Class_Users', ['id' => 15, + 'login' => 'polo', + 'password' => '456', + 'pseudo' => 'polo']) + ->beAbonneSIGB() + ->setUserGroups([$group_cvs]); - $logged_user->beAbonneSIGB() - ->setUserGroups([$this->group_multimedia]); - ZendAfi_Auth::getInstance()->logUser($logged_user); - - $preferences = [ - 'cvs_nb_result' => '5']; + ZendAfi_Auth::getInstance()->logUser($polo); + } +} - $this->mock_cvs = Storm_Test_ObjectWrapper::mock(); +class NoticeAjaxControllerCvsSearchWithNoRecordTest extends NoticeAjaxControllerCvsSearchtest { + public function setUp() { + parent::setUp(); + + $mock_cvs = Storm_Test_ObjectWrapper::mock(); - RessourcesNumeriquesFixtures::activateCVS(); Storm_Test_ObjectWrapper::mock() ->whenCalled('forUser') ->answers($this->mock_cvs); - $this->mock_cvs + $mock_cvs ->whenCalled('searchNotices') ->answers([]); - Class_Profil::getCurrentProfil()->setCfgModules(['recherche' => ['resultat' => $preferences]]); + + Class_Profil::getCurrentProfil()->setCfgModules(['recherche' => ['resultat' => []]]); $this->dispatch('/opac/noticeajax/cvs-search/expressionRecherche/Cuisson/page/2', true); } /** @test */ - public function withNoResultShouldReturnAucunDocument() { - $this->assertContains('Aucun document trouvé',$this->_response->getBody()); + public function resultShouldReturnEmptyMessage() { + $this->assertXPathContentContains('//div[@id="cvs_result"]/span','Aucun document trouv',$this->_response->getBody()); } } -abstract class NoticeAjaxControllerCvsWithNoticesSearchTest extends AbstractControllerTestCase { +class NoticeAjaxControllerCvsWithRecordsSearchTest extends NoticeAjaxControllerCvsSearchtest { + protected $_cvs; public function setUp() { parent::setUp(); - $logged_user=Class_Users::newInstanceWithId(15,['login'=>'polo'])->beAbonneSIGB(); - $this->group_multimedia = Class_UserGroup::newInstanceWithId('20', ['libelle' => 'Multimedia', - 'rights_token' => Class_UserGroup::RIGHT_ACCES_ARTEVOD]); + RessourcesNumeriquesFixtures::activateCVS(); + $record = $this->fixture('Class_Notice',['id'=> 10, + 'titre_principal' => 'Le photographe', + 'auteur_principal' => 'Guibert']); + $this->_cvs = Class_CVSLink::forUser($record); + $http_client = Storm_Test_ObjectWrapper::mock(); + + Class_CVSLink::setTimeSource((new TimeSourceForTest)->setTime(1369640315)); + Class_CVSLink::setDefaultHttpClient($http_client); + Class_Xml::setDefaultHttpClient($http_client); + RessourcesNumeriquesFixtures::activateCVS(); - $logged_user->beAbonneSIGB() - ->setUserGroups([$this->group_multimedia]); - ZendAfi_Auth::getInstance()->logUser($logged_user); + $http_client + ->whenCalled('postData') + ->answers($this->_returnedXML()) + ; - $preferences = [ - 'cvs_nb_result' => '5']; - RessourcesNumeriquesFixtures::activateCVS(); + $this->dispatch('/opac/noticeajax/cvs-search/expressionRecherche/Cuisson/page/2', true); + } - $this->mock_cvs = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CVSLink'); - $this->mock_cvs - ->whenCalled('searchNotices') - ->answers([Class_Notice::newInstanceWithId('10')]); - $this->mock_cvs - ->whenCalled('forUser') - ->answers($this->mock_cvs); - - Class_Profil::getCurrentProfil()->setCfgModules(['recherche' => ['resultat' => $preferences]]); - $this->dispatch('/opac/noticeajax/cvs-search/expressionRecherche/Cuisson/page/2', true); + protected function _returnedXML() { + $xml = file_get_contents(realpath(dirname(__FILE__)). '/../../../../fixtures/cvs_search_ecole.xml'); + return $xml; } /** @test */ - public function withesultShouldReturnAucunDocument() { - $this->assertContains('Aucun document trouvé',$this->_response->getBody()); + public function simpleContentShouldContainsCVSDiv() { + $this->assertXPath('//div[@id="cvs_result"]//div[@class="cvs_record_list"]', $this->_response->getBody()); } } diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index 559d604af2be609cb0c21326ba7a572cf1dd77bf..1ce2bd59091a9d8c734f0c9910c024348e27e849 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -1772,4 +1772,99 @@ class RechercheControllerViewNoticeWichIsInMyPanier extends AbstractControllerTe } } + + + +class RechercheControllerSimpleActionWithCvsActivatedTest extends RechercheControllerSimpleActionTestCase { + public function setUp() { + parent::setUp(); + + Class_Profil::getCurrentProfil() + ->setCfgModules(['recherche' => + ['resultatsimple' => [ 'cvs_autres_resultats' => 'Results from opac', + 'cvs_resultat_titre' => 'CVS Ressources', + 'cvs_nb_result' => '5', + 'cvs_display_position' => '1']]]); + $zork = $this->fixture('Class_Users', + ['id' => 4, + 'login' => 'zork_sigb', + 'role_level' => 2, + 'idabon' => '98475', + 'id_site' => 2, + 'password' => 'xzy']); + $group_multimedia = Class_UserGroup::newInstanceWithId('20', ['libelle' => 'Multimedia', + 'rights_token' => Class_UserGroup::RIGHT_ACCES_CVS]); + + + $zork->beAbonneSIGB() + ->setUserGroups([$this->group_multimedia]) + ->save(); + ZendAfi_Auth::getInstance()->logUser($zork); + RessourcesNumeriquesFixtures::activateCVS(); + + $this->dispatch('/recherche/simple/expressionRecherche/pomme/tri/alpha_auteur',true); + + } + + + /** @test **/ + public function titleResultFromOpacShouldBeDiplay() { + $this->assertXPathContentContains('//h1','Results from opac'); + } + + + /** @test */ + public function simpleContentShouldContainsCVSDiv() { + $this->assertXPath('//div[@class="conteneur_simple"]//div[contains(@class,"cvs_container")]', $this->_response->getBody()); + } + + + /** @test **/ + public function cvsBoiteShouldHaveTitreCVSRessources() { + $this->assertXPathContentContains('//div[@class="conteneur_simple"]//div[contains(@class,"cvs_container")]//h1', 'CVS Ressources', $this->_response->getBody()); + } + + /** @test **/ + public function cvsBoiteClassShouldHavePosition1() { + $this->assertXPath('//div[@class="conteneur_simple"]//div[@class="cvs_container position_1"]', $this->_response->getBody()); + } +} + + + +class RechercheControllerSimpleActionWithCvsActivatedAndPreferencesHiddenTest extends RechercheControllerSimpleActionTestCase { + public function setUp() { + parent::setUp(); + + Class_Profil::getCurrentProfil() + ->setCfgModules(['recherche' => + ['resultatsimple' => [ 'cvs_display_position' => '0']]]); + $zork = $this->fixture('Class_Users', + ['id' => 4, + 'login' => 'zork_sigb', + 'role_level' => 2, + 'idabon' => '98475', + 'id_site' => 2, + 'password' => 'xzy']); + $group_multimedia = Class_UserGroup::newInstanceWithId('20', ['libelle' => 'Multimedia', + 'rights_token' => Class_UserGroup::RIGHT_ACCES_CVS]); + + + $zork->beAbonneSIGB() + ->setUserGroups([$this->group_multimedia]) + ->save(); + ZendAfi_Auth::getInstance()->logUser($zork); + RessourcesNumeriquesFixtures::activateCVS(); + + $this->dispatch('/recherche/simple/expressionRecherche/pomme/tri/alpha_auteur',true); + + } + + + /** @test */ + public function simpleContentShouldNotContainsCVSDiv() { + $this->assertNotXPath('//div[@class="conteneur_simple"]//div[contains(@class,"cvs_container")]', $this->_response->getBody()); + } + +} ?>