Skip to content
Snippets Groups Projects
Commit adcd01f0 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

Merge branch 'hotline#58091_memo_set_oai' into 'stable'

hotline #58091 when a record is FRBR linked to an album and has no thumbnail, get album's thumbnal

See merge request !2090
parents b25863f2 057cc670
Branches
Tags
4 merge requests!2334Master,!2094Master,!2091Stable,!2090hotline #58091 when a record is FRBR linked to an album and has no thumbnail, get album's thumbnal
Pipeline #908 failed with stage
in 20 minutes and 49 seconds
- ticket #58091 : Lorsqu'une notice est liée à un album via FRBR et que la notice n'a pas de vignette, celle-ci récupère la vignette de l'album
\ No newline at end of file
......@@ -27,6 +27,7 @@ class Class_Notice_Thumbnail_ProviderFactory {
'Album' => function($record) { return $this->_isAlbum($record); },
'Site' => function($record) { return $record->isSite(); },
'ThirdParty' => function($record) { return $this->_isThirdParty($record); },
'RecordWithAlbum' => function($record) { return $this->_isRecordWithAlbum($record); },
'CacheServer' => function() { return true; }];
foreach ($mapping as $name => $closure)
......@@ -43,6 +44,11 @@ class Class_Notice_Thumbnail_ProviderFactory {
}
protected function _isRecordWithAlbum($record) {
return Class_FRBR_Link::countAlbumsFromNotice($record);
}
protected function _isThirdParty($record) {
return Class_Profil::getCurrentProfil()
->getModulePreference('recherche',
......
<?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
*/
class Class_Notice_Thumbnail_ProviderRecordWithAlbum
extends Class_Notice_Thumbnail_ProviderLocal {
protected function _getOriginalUrlOrPath() {
if (!$links = Class_FRBR_Link::findAllAlbumsFromNotice($this->_record))
return null;
$album = $links[0]->getEntityOfType(Class_FRBR_Link::TYPE_ALBUM);
if ($url = $album->getThumbnailUrl())
return $url;
return $album->getFirstImagePathFoundInResources();
}
}
......@@ -63,6 +63,7 @@ class NoticeVignetteTest extends ModelTestCase {
$this->_notice_without_thumbnails = $this->fixture('Class_Notice',
['id' => 1,
'type_doc' => Class_TypeDoc::LIVRE,
'clef_alpha' => 'NOTHUMB',
'url_vignette' => '',
'url_image' => '']);
......@@ -216,6 +217,78 @@ class NoticeVignetteTest extends ModelTestCase {
}
/** @test */
public function withoutThumbnailWithAlbumLinkedFetchUrlLocalVignetteFoundShouldGetAlbumThumbnail() {
$this->_http_client->whenCalled('open_url')->never();
$album = $this->fixture('Class_Album',
['id' => 2,
'type_doc_id' => Class_TypeDoc::DIAPORAMA,
'fichier' => 'a_thumb.jpg']);
$this->fixture('Class_FRBR_Link',
['id' => 5,
'source' => Class_Url::absolute(['controller' => 'recherche',
'action' => 'viewnotice',
'clef' => $this->_notice_without_thumbnails->getClefAlpha()]),
'target' => Class_Url::absolute(['controller' => 'bib-numerique',
'action' => 'notice',
'id' => $album->getId()])]);
$image_factory = $this->mock()
->whenCalled('newImage')
->with($album->getThumbnailUrl())
->answers($this->mock()
->whenCalled('thumbnailImage')->answers(null)
->whenCalled('writeImage')->answers(null))
->beStrict();
Class_Notice_Thumbnail_ProviderAbstract::setDefaultImageFactory($image_factory);
$this->assertEquals('/temp/vignettes_titre/NOTHUMB.jpg',
$this->_notice_without_thumbnails->fetchUrlLocalVignette());
}
/** @test */
public function withoutThumbnailWithAlbumLinkedFetchUrlLocalVignetteFoundShouldGetAlbumFirstResourceThumbnail() {
$this->_http_client->whenCalled('open_url')->never();
$album = $this->fixture('Class_Album',
['id' => 2,
'type_doc_id' => Class_TypeDoc::DIAPORAMA]);
$album
->addRessource($this->fixture('Class_AlbumRessource',
['id' => 5,
'fichier' => 'resthumb.jpg']))
->save();
$this->fixture('Class_FRBR_Link',
['id' => 5,
'source' => Class_Url::absolute(['controller' => 'recherche',
'action' => 'viewnotice',
'clef' => $this->_notice_without_thumbnails->getClefAlpha()]),
'target' => Class_Url::absolute(['controller' => 'bib-numerique',
'action' => 'notice',
'id' => $album->getId()])]);
$image_factory = $this->mock()
->whenCalled('newImage')
->with(Class_AlbumRessource::find(5)->getOriginalPath())
->answers($this->mock()
->whenCalled('thumbnailImage')->answers(null)
->whenCalled('writeImage')->answers(null))
->beStrict();
Class_Notice_Thumbnail_ProviderAbstract::setDefaultImageFactory($image_factory);
$this->assertEquals('/temp/vignettes_titre/NOTHUMB.jpg',
$this->_notice_without_thumbnails->fetchUrlLocalVignette());
}
/** @test */
public function withoutThumbnailFetchUrlLocalVignetteNotFoundShouldAnswerLocalUrl() {
$this->_http_client
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment