diff --git a/VERSIONS_HOTLINE/123632 b/VERSIONS_HOTLINE/123632 new file mode 100644 index 0000000000000000000000000000000000000000..d347c3907f83a3c64b990ef79b43d3b4f1a2a4d1 --- /dev/null +++ b/VERSIONS_HOTLINE/123632 @@ -0,0 +1 @@ + - ticket #123632 : Magasin de thèmes : Amélioration du rebond nouveauté dans le résultat de recherche. Le badge et le critère de recherche nouveauté correspondent. \ No newline at end of file diff --git a/library/Class/Journal/ProfileType.php b/library/Class/Journal/ProfileType.php index de6ab4aea910a415a04c9a68f31bf90cd0393545..34456a995cddf62d53a88d57138fff2fc41b5c21 100644 --- a/library/Class/Journal/ProfileType.php +++ b/library/Class/Journal/ProfileType.php @@ -35,11 +35,12 @@ class Class_Journal_ProfileType extends Class_Journal_Type { return false; $this->_journal->addDetail(static::MODEL_ID, $model->getId()); - + $current = $model->getRawAttributes(); $previous = $model->getRawDbAttributes(); - $this->_journal->addDetail(static::NEW_VALUE, json_encode(static::_unserialize($current['cfg_accueil']))); + if (isset($current['cfg_accueil'])) + $this->_journal->addDetail(static::NEW_VALUE, json_encode(static::_unserialize($current['cfg_accueil']))); if (!isset($previous['cfg_accueil'])) return true; diff --git a/library/Class/MoteurRecherche.php b/library/Class/MoteurRecherche.php index e6eb31d2cee95e77f3281cefda20c2b43ee62099..f0ea4ea6c49d45707fae02d817f318f41bc5de77 100644 --- a/library/Class/MoteurRecherche.php +++ b/library/Class/MoteurRecherche.php @@ -316,9 +316,13 @@ class Class_MoteurRecherche { public function visitNouveaute($nouveaute) { + $month = is_numeric($nouveaute) + ? (int) $nouveaute + : 0; + $now = $this->getTimeSource()->time(); $novel_time = mktime(0, 0, 0, - date('m', $now) - (int)$nouveaute, + date('m', $now) - $month, date('d', $now), date('Y', $now)); diff --git a/library/templates/Intonation/Library/View/Wrapper/Abstract.php b/library/templates/Intonation/Library/View/Wrapper/Abstract.php index 18cdb61c82d04d7fc1e7b488f5162291902e1459..1cb748f6f421008efd88aea297b67e51be130359 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Abstract.php +++ b/library/templates/Intonation/Library/View/Wrapper/Abstract.php @@ -45,7 +45,7 @@ abstract class Intonation_Library_View_Wrapper_Abstract { ->setView($view) ->setModel($model); - $this->_widget_context = new Intonation_Library_Widget_Carousel_NullContext; + $this->setWidgetContext(new Intonation_Library_Widget_Carousel_NullContext); } diff --git a/library/templates/Intonation/Library/View/Wrapper/Record.php b/library/templates/Intonation/Library/View/Wrapper/Record.php index 1e75d52d62fc80a95d0e4d0c66aa8f5fa9b280a9..3b206a4900190adb9baeb4c39a42ab60e7ca59d6 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record.php @@ -173,7 +173,7 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra : '')) ->setUrl($this->_view->url(['controller' => 'recherche', 'action' => 'simple', - 'nouveaute' => 1, + 'nouveaute' => 'maintenant', 'page' => null])) ->setText($this->_model->isNouveaute() ? $this->_('Nouveauté') : '') ->setTitle($this->_('Le document %s est nouveau dans votre bibliothèque', @@ -654,32 +654,10 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra public function getAnchor() { - $id = $this->_model->getId(); - - if (Intonation_Library_View_Wrapper_RecordCache::hasAnchorCache($id)) - return ''; - - Intonation_Library_View_Wrapper_RecordCache::setAnchorCache($id); - - return $this->_view->div(['class' => 'scroll_anchor', - 'id' => $id]); - } -} - - - - -class Intonation_Library_View_Wrapper_RecordCache { - protected static $_anchor_cache = []; - - - public static function hasAnchorCache($id) { - return isset(static::$_anchor_cache[$id]); - } - - - public static function setAnchorCache($id) { - static::$_anchor_cache[$id] = true; + return $this->_widget_context instanceOf Intonation_View_Search_Context + ? $this->_view->div(['class' => 'scroll_anchor', + 'id' => $this->_model->getId()]) + : ''; } } diff --git a/library/templates/Intonation/Library/Widget/Carousel/NullContext.php b/library/templates/Intonation/Library/Widget/Carousel/NullContext.php index cc3f687db2955d3925a7ad7504a058f36a7eddcd..b625bfcf80cf60b45cb54892225fac11da1fd6cc 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/NullContext.php +++ b/library/templates/Intonation/Library/Widget/Carousel/NullContext.php @@ -21,4 +21,10 @@ class Intonation_Library_Widget_Carousel_NullContext extends Class_Entity { + + public function getLinkToAllParams() { + return $params = parent::getLinkToAllParams() + ? $params + : []; + } } diff --git a/library/templates/Intonation/View/Search/Context.php b/library/templates/Intonation/View/Search/Context.php new file mode 100644 index 0000000000000000000000000000000000000000..5699698eb9f830694e4cb5e5c5bdaf7fe826edaf --- /dev/null +++ b/library/templates/Intonation/View/Search/Context.php @@ -0,0 +1,24 @@ +<?php +/** + * Copyright (c) 2012-2021, 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_Context extends Intonation_Library_Widget_Carousel_NullContext { +} diff --git a/library/templates/Intonation/View/Search/Result.php b/library/templates/Intonation/View/Search/Result.php index 4a8cad52965ee94df0f913e04c7850604f42516d..70377afd4b86cbe8c8f3d46126ab78ad773f29b1 100644 --- a/library/templates/Intonation/View/Search/Result.php +++ b/library/templates/Intonation/View/Search/Result.php @@ -200,6 +200,7 @@ class Intonation_View_Search_Result extends ZendAfi_View_Helper_BaseHelper { return (new $wrapper_class) ->setModel($model) ->setView($this->view) + ->setWidgetContext(new Intonation_View_Search_Context) ->setSelectableAction(1) ->setAllowXSL(1); } diff --git a/tests/application/modules/AbstractControllerTestCase.php b/tests/application/modules/AbstractControllerTestCase.php index 9a4d9e8039e460964592a81a8b465df4431a192e..2c03c93ebaf52bc673b1d38e1bfbeb3d5d519d67 100644 --- a/tests/application/modules/AbstractControllerTestCase.php +++ b/tests/application/modules/AbstractControllerTestCase.php @@ -170,6 +170,7 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe Class_ScriptLoader::resetInstance(); Class_Codification::resetInstance(); Class_MoteurRecherche::resetInstance(); + Class_MoteurRecherche::setTimeSource(null); Class_WebService_Abstract::resetHttpClient(); Class_WebService_AllServices::setHttpClient(null); Class_I18n::reset(); @@ -182,6 +183,7 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe Class_Notice_Thumbnail_ResizeImage::reset(); Class_FileManager::reset(); Class_Notice_Xsl::reset(); + Class_Notice::setTimeSource(null); Class_CommSigb::setInstance(null); ZendAfi_Acl_AdminControllerGroup::setAcl(null); Class_Systeme_ModulesAccueil::reset(); diff --git a/tests/scenarios/Templates/TemplatesSearchTest.php b/tests/scenarios/Templates/TemplatesSearchTest.php index 47d700657d7fca6b7dcd6bb718e95dae797e174b..db900c5da6a31c4d8c38f221a7bb056b23eeeb0d 100644 --- a/tests/scenarios/Templates/TemplatesSearchTest.php +++ b/tests/scenarios/Templates/TemplatesSearchTest.php @@ -236,7 +236,7 @@ class TemplatesSearchViewRecordTest extends TemplatesIntonationTestCase { /** @test */ public function shouldBeANovelty() { - $this->assertXPathContentContains('//a[contains(@href, "/nouveaute/1")]', 'Nouveauté'); + $this->assertXPathContentContains('//a[contains(@href, "/nouveaute/maintenant")]', 'Nouveauté'); } @@ -676,8 +676,8 @@ abstract class TemplatesSearchDispatchTest extends AbstractControllerTestCase { public function setUp() { parent::setUp(); $this->_buildTemplateProfil( - ['id' => 5, - 'template' => 'CHILI']); + ['id' => 5, + 'template' => 'CHILI']); $records = [$this->fixture('Class_Notice', ['id' => 89]), @@ -757,4 +757,46 @@ class TemplatesSearchDispatchWithArticlesIndexedTest extends TemplatesSearchDisp public function linkToBonjourLesTerriensShouldBeCmsArticleViewId34() { $this->assertXPath('//main//div[contains(@class,"search_records_col")]//a[contains(@href, "/cms/articleview/expressionRecherche/solaire/id_profil/5/id/34")]'); } +} + + + + +class TemplatesSearchDispatchWithNouveauteNowParamTest extends AbstractControllerTestCase { + + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + + $this->_buildTemplateProfil(['id' => 8987]); + + $time_source = new TimeSourceForTest('2021-01-13'); + Class_MoteurRecherche::setTimeSource($time_source); + Class_Notice::setTimeSource($time_source); + + $record = $this->fixture('Class_Notice', + ['id' => 89, + 'date_creation' => '2021-02-01' + ]); + + $sql = $this->mock() + ->whenCalled('fetchAll') + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey) AGAINST('+(POMME POMMES POM)' IN BOOLEAN MODE) and date_creation >'2021-01-13') and type=1 order by (MATCH(titres) AGAINST(' POMME') * 1.5) + (MATCH(auteurs) AGAINST(' POMME')) desc", + true, + false) + ->answers([[89 ]]) + ; + + Zend_Registry::set('sql', $sql); + + $this->dispatch('/opac/recherche/simple/expressionRecherche/pomme/id_profil/72/nouveaute/maintenant/id_profil/8987'); + } + + + /** @test */ + public function linkWithNouveauteMaintantShouldBeDisplayedInRecord89() { + $this->assertXPathContentContains('//div[@id="89"]/following-sibling::div//a[contains(@href, "nouveaute/maintenant")]//span', 'Nouveauté'); + } } \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php index c6a11c1bcfd6b80cb2e23de92a3b9bc083410818..7a6e10252aecbafa0d8742faf45aa1302984a727 100644 --- a/tests/scenarios/Templates/TemplatesTest.php +++ b/tests/scenarios/Templates/TemplatesTest.php @@ -227,8 +227,10 @@ class TemplatesControllerTryHistoricTest extends TemplatesEnabledTestCase { abstract class TemplatesIntonationTestCase extends TemplatesEnabledTestCase { + protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp();