diff --git a/VERSIONS b/VERSIONS index 3afcad60204111996f85a635ad3b9b55f2c23fc0..945fe3889b29ed89ec9fd6fc19a1bcf185096d11 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,3 +1,11 @@ +27/09/2017 - v7.11.2 + + - ticket #65212 : Les vignettes ne sont plus dupliquées dans le cache local de Bokeh + + - ticket #65395 : Administration : correction de la validation des boites. + + + 27/09/2017 - v7.11.1 - ticket #64357 : Correction des problèmes d'affichage sur tablette Apple des popups diff --git a/VERSIONS_HOTLINE/65395 b/VERSIONS_HOTLINE/65395 deleted file mode 100644 index b71676b2d692bbe23219c8ae4674e9f00ed00460..0000000000000000000000000000000000000000 --- a/VERSIONS_HOTLINE/65395 +++ /dev/null @@ -1,2 +0,0 @@ - - ticket #65395 : Administration : correction de la validation des boites. - \ No newline at end of file diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php index cac6b1bed5315bd3782e1de7fdd7cb6d117b40bc..a3b267889d5eebdb4ce93f06cd242682a9eb9b89 100644 --- a/application/modules/opac/controllers/RechercheController.php +++ b/application/modules/opac/controllers/RechercheController.php @@ -437,6 +437,19 @@ class RechercheController extends ZendAfi_Controller_Action { } + public function rawThumbnailAction() { + $viewRenderer = $this->getHelper('ViewRenderer'); + $viewRenderer->setNoRender(); + session_write_close(); + + $record = Class_Notice::find((int)$this->_getParam('id')); + (new Class_WebService_Vignette()) + ->renderThumbnail($record->getId(), + $record->getTitrePrincipal(), + $record->getTypeDoc()); + } + + public function reservationAction() { if ((!$library = Class_Bib::find((int)$this->_getParam('id_bib'))) || !$record = Class_Notice::find((int)$this->_getParam('id_notice'))) { diff --git a/library/Class/Notice.php b/library/Class/Notice.php index e26c8eeedd8414fe4b38761098606bb8b1be08cb..40a5d977b44cd56f70c64803381cdcde5a14807b 100644 --- a/library/Class/Notice.php +++ b/library/Class/Notice.php @@ -395,9 +395,7 @@ class Class_Notice extends Storm_Model_Abstract { $url = $this->getUrlVignette(); if ($url=='NO') - return Class_WebService_Vignette::saveImage($this->getId(), - $this->getTitrePrincipal(), - $this->getTypeDoc()); + return $this->_rawThumbnailUrl(); return $url ? $url : Class_WebService_Vignette::getAjaxUrl($this); } @@ -411,14 +409,19 @@ class Class_Notice extends Storm_Model_Abstract { $url = $this->getUrlVignette(); } - if ($url=='NO') - return $ws_vignette->saveImage($this->getId(), - $this->getTitrePrincipal(), - $this->getTypeDoc()); + return ($url=='NO') + ? $this->_rawThumbnailUrl() + : $ws_vignette->writeImageCache($this, $url); + } - return $ws_vignette->writeImageCache($this, $url); + + protected function _rawThumbnailUrl() { + return Class_Url::assemble(['controller' => 'recherche', + 'action' => 'raw-thumbnail', + 'id' => $this->getId()]); } + public function getFetchUrlVignette() { return $this->fetchUrlVignette(); } diff --git a/library/Class/Notice/Thumbnail/ProviderCacheServer.php b/library/Class/Notice/Thumbnail/ProviderCacheServer.php index 6548bf48271cad29e95f5b4e112531092542577a..cf7a41702934262ae57383c9e875ef4d4cd18bae 100644 --- a/library/Class/Notice/Thumbnail/ProviderCacheServer.php +++ b/library/Class/Notice/Thumbnail/ProviderCacheServer.php @@ -21,7 +21,7 @@ class Class_Notice_Thumbnail_ProviderCacheServer - extends Class_Notice_Thumbnail_ProviderCloud { + extends Class_Notice_Thumbnail_ProviderAbstract { public function updateNotice() { if (!$urls = $this->_getUrls()) diff --git a/library/Class/Notice/Thumbnail/ProviderCloud.php b/library/Class/Notice/Thumbnail/ProviderCloud.php deleted file mode 100644 index 41267a4f46df91a336ce7a61de497b796ab54455..0000000000000000000000000000000000000000 --- a/library/Class/Notice/Thumbnail/ProviderCloud.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php -/** - * Copyright (c) 2012-2014, 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 - */ - - -abstract class Class_Notice_Thumbnail_ProviderCloud - extends Class_Notice_Thumbnail_ProviderAbstract { - - public function writeImageCache($url) { - $nom_fic = 'notice_' . $this->_record->getId().".jpg"; - $path = $this->_getPath($nom_fic); - try { - if ($this->_filesystem->fileExists($path)==false) { - $data = (new Class_WebService_Abstract())->httpGet($url); - $this->_filesystem->filePutContents($path, $data); - } - - } catch(Exception $e) { - return null; - } - - return $this->_getUrl($nom_fic); - } -} diff --git a/library/Class/Notice/Thumbnail/ProviderThirdParty.php b/library/Class/Notice/Thumbnail/ProviderThirdParty.php index 8d681524072f438dd89f94ce8b4fd49f5443a261..21c4857a3bd2f7f31ac774b78d0e878565c6f882 100644 --- a/library/Class/Notice/Thumbnail/ProviderThirdParty.php +++ b/library/Class/Notice/Thumbnail/ProviderThirdParty.php @@ -21,7 +21,7 @@ class Class_Notice_Thumbnail_ProviderThirdParty - extends Class_Notice_Thumbnail_ProviderCloud { + extends Class_Notice_Thumbnail_ProviderAbstract { public function updateNotice() { return ($url = $this->_getThirdPartyUrl()) diff --git a/library/Class/WebService/Vignette.php b/library/Class/WebService/Vignette.php index 22de9bc469a919a8cbcc3e468fcb54bdeaf56e5d..aea3a993b17754d7db1b3241ca392754574a3d1c 100644 --- a/library/Class/WebService/Vignette.php +++ b/library/Class/WebService/Vignette.php @@ -88,20 +88,13 @@ class Class_WebService_Vignette extends Class_WebService_Abstract { } - static function saveImage($id_notice,$titre,$type_doc) { - $filename = "/temp/vignettes_titre/notice_".$id_notice.".png"; - $full_path = getcwd().$filename; - - if (static::getFileSystem()->fileExists($full_path)) - return $filename; - + static function renderThumbnail($id_notice,$titre,$type_doc) { $image = static::createImage($titre, $width=100, $height=90, $type_doc); - imagepng($image, $full_path); - return $filename; + imagepng($image); } diff --git a/library/ZendAfi/Controller/Plugin/InspectorGadget.php b/library/ZendAfi/Controller/Plugin/InspectorGadget.php index a402eb4d6495304e9bf4300ce1435050e8faa54d..03078e3990a05a2128c85199d01bf3d66728f33b 100644 --- a/library/ZendAfi/Controller/Plugin/InspectorGadget.php +++ b/library/ZendAfi/Controller/Plugin/InspectorGadget.php @@ -36,7 +36,8 @@ class ZendAfi_Controller_Plugin_InspectorGadget extends Zend_Controller_Plugin_A $this->beEnabled(); Class_WebService_SIGB_AbstractService::setLogger($this); - Class_WebService_MappedSoapClient::setLogger($this); + if (class_exists('SoapClient')) + Class_WebService_MappedSoapClient::setLogger($this); } diff --git a/library/startup.php b/library/startup.php index 1d1d5a6ecbaf27fd4e4915fdcd190a8ced44047e..9a66b298a099e4d0004d4b319de00b40903e24b0 100644 --- a/library/startup.php +++ b/library/startup.php @@ -82,7 +82,7 @@ class Bokeh_Engine { function setupConstants() { defineConstant('BOKEH_MAJOR_VERSION','7.11'); - defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.1'); + defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.2'); defineConstant('BOKEH_REMOTE_FILES', 'http://git.afi-sa.fr/afi/opacce/'); diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index 346d3e0484bee70513cf3801d5d4daeb2b9472ea..748056e7ee8eaa39257d1af8e6ae1f4a948b8f1f 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -645,16 +645,19 @@ class RechercheControllerViewNoticeMetasTest extends RechercheControllerNoticeTe -class RechercheControllerVignetteTest extends RechercheControllerNoticeTestCase { - public function setUp() { - parent::setUp(); +class RechercheControllerThumbnailTest extends RechercheControllerNoticeTestCase { + /** @test */ + public function rechercheVignetteActionShouldRedirectToRawThumbnailAction() { $this->dispatch('recherche/vignette/id_notice/345', true); + $this->assertRedirectTo(Class_Url::absolute('/recherche/raw-thumbnail/id/345'), + $this->getResponseLocation()); } + /** @test */ - public function responseShouldRedirectToVignetteUrl() { - $this->assertContains('/temp/vignettes_titre/notice_345.png', - $this->getResponseLocation()); + public function rawThumbnailForIdNoticeTwoShouldAnswerPngImage() { + $this->dispatch('/recherche/raw-thumbnail/id/345', true); + $this->assertContains('iVBORw0', base64_encode($this->_response->getBody())); } } @@ -682,8 +685,8 @@ class RechercheControllerVignetteEmptyTest extends AbstractControllerTestCase { /** @test */ - public function responseShouldRedirectToVignetteUrl() { - $this->assertContains('/temp/vignettes_titre/notice_1.png', + public function responseShouldRedirectToRawThumbnailUrl() { + $this->assertContains(Class_Url::absolute('/recherche/raw-thumbnail/id/1'), $this->getResponseLocation()); } } diff --git a/tests/library/Class/NoticeTest.php b/tests/library/Class/NoticeTest.php index d6232f81d735f56676aeceb96ddf38249cf1fe9c..ae6b7252e90eae38362ce8d5a0d19160a7ac2f3f 100644 --- a/tests/library/Class/NoticeTest.php +++ b/tests/library/Class/NoticeTest.php @@ -185,32 +185,34 @@ class NoticeVignetteTest extends ModelTestCase { 'image' => 'diplo.jpg'])) ->beStrict(); - $this->assertEquals('/temp/vignettes_titre/notice_9.png', + $this->assertEquals(Class_Url::assemble(['controller' => 'recherche', + 'action' => 'raw-thumbnail', + 'id' => 9]), $this->_serial_without_thumbnails->fetchUrlLocalVignette()); } /** @test */ - public function withInexistingThumbnailFetchUrlVignetteShouldAnswerLocalUrl() { + public function withInexistingThumbnailFetchUrlVignetteShouldAnswerRawUrlThumbnail() { $this->assertFalse($this->_http_client->methodHasBeenCalled('open_url')); - $this->assertEquals('/temp/vignettes_titre/notice_2.png', + $this->assertEquals(Class_Url::assemble(['controller' => 'recherche', + 'action' => 'raw-thumbnail', + 'id' => 2]), $this->_notice_inexisting_thumbnails->fetchUrlVignette()); } /** @test */ - public function withoutThumbnailFetchUrlLocalVignetteFoundShouldAnswerLocalUrl() { + public function withoutThumbnailFetchUrlLocalVignetteFoundShouldAnswerImageFromCacheServer() { $this->_http_client ->whenCalled('open_url') ->with('from_cache_small.jpg') ->answers('some data'); - $this->assertEquals('/temp/vignettes_titre/notice_1.jpg', + $this->assertEquals('from_cache_small.jpg', $this->_notice_without_thumbnails->fetchUrlLocalVignette()); - $this->assertContains('some data', - $this->_filesystem->fileGetContents(PATH_TEMP.'vignettes_titre/notice_1.jpg')); Class_Notice::clearCache(); $this->assertEquals('from_cache_small.jpg', Class_Notice::find(1)->getUrlVignette()); @@ -292,12 +294,14 @@ class NoticeVignetteTest extends ModelTestCase { /** @test */ - public function withoutThumbnailFetchUrlLocalVignetteNotFoundShouldAnswerLocalUrl() { + public function withoutThumbnailFetchUrlLocalVignetteNotFoundShouldAnswerRawUrlThumbnail() { $this->_http_client ->whenCalled('open_url') ->answers(''); - $this->assertEquals('/temp/vignettes_titre/notice_1.png', + $this->assertEquals(Class_Url::assemble(['controller' => 'recherche', + 'action' => 'raw-thumbnail', + 'id' => 1]), $this->_notice_without_thumbnails->fetchUrlLocalVignette()); Class_Notice::clearCache(); @@ -307,34 +311,22 @@ class NoticeVignetteTest extends ModelTestCase { /** @test */ public function withThumbnailFetchUrlLocalVignetteShouldAnswerIt() { - $this->_http_client - ->whenCalled('open_url') - ->with('tintin_small.jpg') - ->answers('some data'); - - $this->assertEquals('/temp/vignettes_titre/notice_3.jpg', + $this->assertEquals('tintin_small.jpg', $this->_notice_with_thumbnails->fetchUrlLocalVignette()); - - $this->assertContains('some data', - $this->_filesystem->fileGetContents(PATH_TEMP.'vignettes_titre/notice_3.jpg')); } /** @test */ public function urlThumbnailShoudBeFromGamAnnecy() { - $this->_http_client ->whenCalled('open_url') ->with('http://www.gamannecy.com/polysson/201009/05-3760127221081.jpg') ->answers('some data') ->beStrict(); - $this->assertEquals('/temp/vignettes_titre/notice_8.jpg', + $this->assertEquals('http://www.gamannecy.com/polysson/201009/05-3760127221081.jpg', $this->_notice_gam->fetchUrlLocalVignette()); - - $this->assertContains('some data', - $this->_filesystem->fileGetContents(PATH_TEMP.'vignettes_titre/notice_8.jpg')); } @@ -344,26 +336,19 @@ class NoticeVignetteTest extends ModelTestCase { Class_Profil::getCurrentProfil() ->setCfgModules(['recherche' => ['viewnotice'.Class_TypeDoc::DISQUE => $preferences]]); - - $this->_http_client - ->whenCalled('open_url') - ->with('from_cache_small.jpg') - ->answers('some data'); - - $this->assertEquals('/temp/vignettes_titre/notice_8.jpg', + $this->assertEquals('from_cache_small.jpg', $this->_notice_gam->fetchUrlLocalVignette()); - - $this->assertContains('some data', - $this->_filesystem->fileGetContents(PATH_TEMP.'vignettes_titre/notice_8.jpg')); } /** @test */ - public function withInexistingThumbnailFetchUrlLocalVignetteShouldAnswerLocalFile() { + public function withInexistingThumbnailFetchUrlLocalVignetteShouldAnswerRawUrlThumbnail() { $this->assertFalse($this->_http_client->methodHasBeenCalled('open_url')); - $this->assertEquals('/temp/vignettes_titre/notice_2.png', - $this->_notice_inexisting_thumbnails->fetchUrlLocalVignette()); + $this->assertEquals(Class_Url::assemble(['controller' => 'recherche', + 'action' => 'raw-thumbnail', + 'id' => 2]), + $this->_notice_inexisting_thumbnails->fetchUrlLocalVignette()); }