Skip to content
Snippets Groups Projects
Commit 81e2dd32 authored by Laurent's avatar Laurent
Browse files

hotline #90555 Accept record thumbnail URLs provided by Koha

parent cd00c3fc
Branches
Tags
3 merge requests!3297WIP: Master,!3153Hotline,!3144hotline #90555 Accept record thumbnail URLs provided by Koha
Pipeline #7169 passed with stage
in 38 minutes and 32 seconds
- ticket #90555 : SIGB Koha : Bokeh peut maintenant afficher les vignettes de notices stockées dans Koha et précisées dans l'unimarc
\ No newline at end of file
......@@ -16,23 +16,31 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_Validate_VignetteUrl extends Zend_Validate_Abstract {
const INVALID_EXTENSION = 'invalidExtension';
protected $_messageTemplates = array(self::INVALID_EXTENSION => "'%value%' n'est pas une extension de type .png, .jpeg, .jpg, .gif.");
public function isValid($value) {
if ($this->_isKohaThumbnail($value))
return true;
$parts = explode('.', $value);
$extension = end($parts);
$this->_setValue($extension);
if (!in_array(strtolower($extension), ['png', 'jpg', 'jpeg', 'gif'])) {
$this->_error(self::INVALID_EXTENSION);
return false;
}
return true;
}
protected function _isKohaThumbnail($value) {
return preg_match('|\/cgi-bin\/koha\/opac-image\.pl\?thumbnail=|', $value);
}
}
?>
\ No newline at end of file
......@@ -50,39 +50,51 @@ class ZendAfi_View_Helper_Notice_VignetteNoThumbnailTest
}
protected function _setupRecordWithThumbnailUrl($thumbnail_url) {
Class_Profil::getCurrentProfil()->setModulePreference('recherche',
'viewnotice1',
'thumbnail_fields',
'859-u');
return $this
->fixture('Class_Notice',
['id' => 42,
'type_doc' => 1,
'titre_principal' => 'Never Giveup',
'url_vignette' => Class_WebService_Vignette::NO_DATA,
'url_image' => Class_WebService_Vignette::NO_DATA,
])
->set_subfield('859', 'u', $thumbnail_url);
}
/** @test */
public function withThumbnailZoneAndUrlInUnimarcViewnoticeShouldContainsThumbnail() {
$record = $this->fixture('Class_Notice',
['id' => 42,
'type_doc' => 1,
'titre_principal' => 'Never Giveup',
'url_vignette' => Class_WebService_Vignette::NO_DATA,
'url_image' => Class_WebService_Vignette::NO_DATA,
]);
$record->set_subfield('859', 'u', 'https://epicpics.org/7bxDlg.png');
Class_Profil::getCurrentProfil()
->setModulePreference('recherche', 'viewnotice1', 'thumbnail_fields', '859-u');
$record = $this->_setupRecordWithThumbnailUrl('https://epicpics.org/7bxDlg.png');
$html = $this->_helper->notice_Vignette($record, [], 'view');
$this->assertXPath($html, '//img[@src="https://epicpics.org/7bxDlg.png"]', $html);
}
/** @test */
public function withThumbnailZoneAndUrlInUnimarcResultAndNoDataShouldTryToRegenerateThumbnailInAjax() {
$record = $this->fixture('Class_Notice',
['id' => 42,
'type_doc' => 1,
'titre_principal' => 'Never Giveup',
'url_vignette' => Class_WebService_Vignette::NO_DATA,
'url_image' => Class_WebService_Vignette::NO_DATA,
]);
$record->set_subfield('859', 'u', 'https://epicpics.org/7bxDlg.png');
Class_Profil::getCurrentProfil()
->setModulePreference('recherche', 'viewnotice1', 'thumbnail_fields', '859-u');
public function withThumbnailZoneAndUrlInUnimarcAndInvalidUrlViewnoticeShouldNotContainsThumbnailButBlank() {
$record = $this->_setupRecordWithThumbnailUrl('https://bloub.org/7364?zork=glub');
$html = $this->_helper->notice_Vignette($record, [], 'view');
$this->assertXPath($html, '//img[contains(@src, "public/admin/images/blank.gif")]', $html);
}
/** @test */
public function withThumbnailZoneAndKohaStyleUrlInUnimarcViewnoticeShouldContainsThumbnail() {
$record = $this->_setupRecordWithThumbnailUrl('https://koha.somewhere.com/cgi-bin/koha/opac-image.pl?thumbnail=1&biblionumber=261990');
$html = $this->_helper->notice_Vignette($record, [], 'view');
$this->assertXPath($html, '//img[@src="https://koha.somewhere.com/cgi-bin/koha/opac-image.pl?thumbnail=1&biblionumber=261990"]', $html);
}
/** @test */
public function withThumbnailZoneAndUrlInUnimarcResultAndNoDataShouldTryToRegenerateThumbnailInAjax() {
$record = $this->_setupRecordWithThumbnailUrl('https://epicpics.org/7bxDlg.png');
$html = $this->_helper->notice_Vignette($record);
$this->assertXPath($html, '//img[contains(@src, "/recherche/vignette/clef/")]', $html);
}
......
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