Commit 31a68f68 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

Merge branch 'hotline#78216_liens_vers_les_ressources_numeriques_ko' into 'hotline'

Hotline#78216 liens vers les ressources numeriques ko

See merge request !2763
parents aced8bda c32fb8ca
Pipeline #4729 passed with stage
in 45 minutes and 14 seconds
- ticket #78216 : Ressource numérique : migration de la ressource ToutApprendre vers le système de plugin. Ajout d'un tag "ToutApprendre" à tous les albums moissonnés par cette ressource. Correction du moissonage en cas de réponse vide du webservice ToutApprendre.
\ No newline at end of file
......@@ -245,9 +245,13 @@ class Admin_FileManagerController extends ZendAfi_Controller_Action {
return $this->_redirectWithMessage($this->_('Dimensions "%s" invalident. Les dimensions valident sont : %s .', $dimensions, $available_dimensions));
list($width, $height) = explode('x', $dimensions);
$message = (new Class_Notice_Thumbnail_ResizeImage($item))->resize($width, $height)
? $this->_('L\'image "%s" a été redimensionnée.', $item->getId())
: $this->_('Erreur. L\'image "%s" n\'a pas été redimensionnée.', $item->getId());
$resized_image = (new Class_Notice_Thumbnail_ResizeImage($item))->resize($width, $height);
$message = (($message = $resized_image->getMessage())
? $this->_('Erreur : "%s". L\'image "%s" n\'a pas été redimensionnée.',
$message,
$item->getId())
: $this->_('L\'image "%s" a été redimensionnée.', $item->getId()));
$this->_redirectWithMessage($message);
}
......@@ -257,9 +261,14 @@ class Admin_FileManagerController extends ZendAfi_Controller_Action {
$item = $this->_findItemFromParams();
list($width, $height) = explode('x', $item->getDimensions());
$message = (new Class_Notice_Thumbnail_ResizeImage($item))->resize($width, $height)
? $this->_('L\'image "%s" a été compressée.', $item->getId())
: $this->_('Erreur. L\'image "%s" n\'a pas été compressée.', $item->getId());
$compressed_image = (new Class_Notice_Thumbnail_ResizeImage($item))->resize($width, $height);
$message = (($message = $compressed_image->getMessage())
? $this->_('Erreur : "%s". L\'image "%s" n\'a pas été compressée.',
$message,
$item->getId())
: $this->_('L\'image "%s" a été compressée.', $item->getId()));
$this->_redirectWithMessage($message);
}
......
......@@ -64,7 +64,6 @@ class Admin_HarvestController extends ZendAfi_Controller_Action {
protected function getServices() {
return array_merge(
['vodeclic' => new Class_WebService_BibNumerique_Vodeclic(),
'toutapprendre' => new Class_WebService_BibNumerique_ToutApprendre(),
'numilog' => new Class_WebService_BibNumerique_Numilog(),
'cyberlibris' => new Class_WebService_BibNumerique_Cyberlibris(),
'numerique-premium' => new Class_WebService_BibNumerique_NumeriquePremium(),
......
......@@ -23,7 +23,6 @@ class ModulesController extends ZendAfi_Controller_Action {
public function preDispatch() {
$mapping = ['vodeclic' => 'Vodeclic',
'toutapprendre' => 'ToutApprendre',
'lesocial' => 'LeSocial',
'mycow' => 'MyCow',
'planetnemo' => 'PlanetNemo',
......
......@@ -49,9 +49,6 @@ class Telephone_RechercheController extends RechercheController {
if ($notice->isAudioRecord() || $notice->is1DTouch())
return [$this->_('Accéder à l\'album') => $action_array];
if ($notice->isToutApprendre())
return [$this->_('Accéder au cours') => $action_array];
return [$this->_('Accéder à la ressource') => $action_array];
}
......
<?php
(new Class_Migration_DigitalResource_ToutApprendre())->run();
\ No newline at end of file
......@@ -36,7 +36,7 @@ class CdScriptIntegrationLeKiosqueTest extends CdScriptIntegrationTestCase {
$this->fixture('Class_CosmoVar',
['id' => 'types_docs',
'liste' => '0:Livre et cartes\r\n1:Livres\r\n2:Revues\r\n3:Disques\r\n4:DVD\r\n5:Cédéroms\r\n6:Partitions\r\n7:Livres lus\r\n8:articles\r\n9:fils rss\r\n10:Le Kiosque\r\n11:ToutApprendre\r\n12:ArteVOD\r\n']);
'liste' => '0:Livre et cartes\r\n1:Livres\r\n2:Revues\r\n3:Disques\r\n4:DVD\r\n5:Cédéroms\r\n6:Partitions\r\n7:Livres lus\r\n8:articles\r\n9:fils rss\r\n10:Le Kiosque\r\n11:ArteVOD\r\n']);
$this->loadRecordsFromFile('unimarc_le_kiosque');
$this->_deco_magazine = Class_Notice::find(1);
......
......@@ -166,9 +166,6 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
'ARTE_VOD_KEY' => Class_AdminVar_Meta::newDefault($this->_('Clé ARTE VOD'))->bePrivate(),
'ARTE_VOD_SSO_KEY' => Class_AdminVar_Meta::newDefault($this->_('Clé ARTE VOD Single Sign-On'))->bePrivate(),
'TOUTAPPRENDRE_BIB_ID' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage <a href="http://forge.afi-sa.fr/projects/opac3/wiki/Ressources_externes_enrichissements#Tout-Apprendre">ToutApprendre</a>'))->bePrivate(),
'TOUTAPPRENDRE_KEY' => Class_AdminVar_Meta::newDefault($this->_('Paramétrage <a href="http://forge.afi-sa.fr/projects/opac3/wiki/Ressources_externes_enrichissements#Tout-Apprendre">ToutApprendre</a>'))->bePrivate(),
'NUMERIQUE_PREMIUM_URL' => Class_AdminVar_Meta::newDefault('')->bePrivate(),
'JAMENDO_CLIENT_ID' => Class_AdminVar_Meta::newDefault($this->_('ID client Jamendo')),
......@@ -661,11 +658,6 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
}
public function isToutApprendreEnabled() {
return (('' != Class_AdminVar::get('TOUTAPPRENDRE_BIB_ID')) && ('' != Class_AdminVar::get('TOUTAPPRENDRE_KEY')));
}
public function isMyCowEnabled() {
return ('' != Class_AdminVar::get('MYCOW_EID'));
}
......
......@@ -141,7 +141,8 @@ class Class_Album extends Storm_Model_Abstract {
'annexes' => '',
'sections' => '',
'status' => self::STATUS_DRAFT,
'pcdm4' => ''];
'pcdm4' => '',
'tags' => ''];
/** @var Class_Upload */
......@@ -497,16 +498,6 @@ class Class_Album extends Storm_Model_Abstract {
}
public function beCoursToutApprendre() {
return $this->setTypeDocId(Class_TypeDoc::TOUTAPPRENDRE);
}
public function isCoursToutApprendre() {
return $this->getTypeDocId() == Class_TypeDoc::TOUTAPPRENDRE;
}
public function isArteVOD() {
return $this->getTypeDocId() == Class_TypeDoc::ARTEVOD;
}
......
......@@ -40,7 +40,6 @@ class Class_Album_Renderer {
'gallicaPlayer' => function($album) { return $album->isGallica(); },
'tagVideo' => function($album) { return $album->isArteVod(); },
'tagFormationVodeclic' => function($album) { return $album->isFormationVodeclic(); },
'tagCoursToutApprendre' => function($album) { return $album->isCoursToutApprendre(); },
'monocleReaderServerSide' => function($album) { return $album->isEPUB(); },
'tagJamendoPlayer' => function($album) { return $album->isJamendo(); },
'tagSoundCloudPlayer' => function($album) { return $album->isSoundCloud(); },
......
......@@ -51,7 +51,6 @@ class Class_BatchLoader extends Storm_Model_Loader {
Class_Batch_NumeriquePremium::TYPE => new Class_Batch_NumeriquePremium(),
Class_Batch_Numilog::TYPE => new Class_Batch_Numilog(),
Class_Batch_Cyberlibris::TYPE => new Class_Batch_Cyberlibris(),
Class_Batch_ToutApprendre::TYPE => new Class_Batch_ToutApprendre(),
Class_Batch_OneDTouch::TYPE => new Class_Batch_OneDTouch(),
Class_Batch_Orphea::TYPE => new Class_Batch_Orphea(),
Class_Batch_Jamendo::TYPE => new Class_Batch_Jamendo(),
......
......@@ -108,6 +108,18 @@ class Class_DigitalResource extends Class_Entity {
}
public function getSsoActionForPlugin($name) {
$action_name = $this->getPlugins()
->collect(function($config) use ($name)
{
return ($name == $config->getName()) ? $config->getSsoAction() : null;
})
->getArrayCopy();
$action_name = array_filter($action_name);
return reset($action_name);
}
public function getPluginsDescription() {
return $this->pluginsByName(function($config)
{
......@@ -316,7 +328,7 @@ class Class_DigitalResource extends Class_Entity {
public function getAdminVar($plugin, $name) {
return Class_AdminVar::get($this->withNamespace($plugin, $name));
return Class_AdminVar::getValueOrDefault($this->withNamespace($plugin, $name));
}
......
......@@ -213,6 +213,9 @@ class Class_DigitalResource_Config extends Class_Entity {
if($album = $this->_albumFromParams($params))
return $this->getAlbumSsoUrl($user, $album);
if($resource = $this->_albumResourceFromParams($params))
return $this->getAlbumResourceSsoUrl($user, $resource);
return $this->getSsoUrl($user);
}
......@@ -231,6 +234,13 @@ class Class_DigitalResource_Config extends Class_Entity {
}
protected function _albumResourceFromParams($params) {
return array_key_exists('resource_id', $params)
? Class_AlbumRessource::find($params['resource_id'])
: null;
}
public function getSsoUrl($user) {
return '';
}
......@@ -244,6 +254,17 @@ class Class_DigitalResource_Config extends Class_Entity {
}
public function getAlbumResourceSsoUrl($user, $resource) {
if (!$resource)
return '';
if (!$album = $resource->getAlbum())
return '';
return $album->getExternalUri();
}
public function getHarvestUrl($page = 1) {
return '';
}
......
......@@ -47,4 +47,19 @@ class Class_DigitalResource_Service extends Class_WebService_BibNumerique_Abstra
public function getName() {
return $this->_config->getName();
}
protected function _deleteNonHarvestedAlbums() {
if (!$harvested_ids = $this->getHarvestedIds())
return $this;
(new Storm_Model_Collection(Class_Album::findAllBy(['type_doc_id' => $this->getDocType()])))
->reject(
function($album) use($harvested_ids) {
return in_array($album->getIdOrigine(), $harvested_ids);
})
->eachDo('delete');
return $this;
}
}
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
* 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
......@@ -19,25 +19,32 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_WebService_BibNumerique_ToutApprendre_Formation extends Class_WebService_BibNumerique_RessourceNumerique {
public function fillAlbum($album) {
$album
->beCoursToutApprendre()
->addAuthor('Tout Apprendre')
->setDateMaj($this->getDateMaj())
->setAnnee($this->getAnnee())
->setDescription($this->getDescription());
class Class_Migration_DigitalResource_ToutApprendre extends Class_Migration_DigitalResource_Abstract {
protected function _getOldRightToken() {
return 6;
}
protected function _getAdminVarMapping() {
return ['TOUTAPPRENDRE_BIB_ID' => 'ToutApprendre_BIB_ID',
'TOUTAPPRENDRE_KEY' => 'ToutApprendre_KEY'];
}
protected function _getConfig() {
return ToutApprendre_Config::getInstance();
}
public function getRessourceCategorieLibelle() {
return 'Cours en ligne Tout Apprendre';
protected function _getOldMenuName() {
return 'TOUTAPPRENDRE';
}
public function getBaseUrl(){
return Class_WebService_BibNumerique_ToutApprendre::BASE_URL;
protected function _getOldBatchName() {
return 'MOISSONNAGE_TOUTAPPRENDRE';
}
}
?>
\ No newline at end of file
}
\ No newline at end of file
......@@ -516,11 +516,6 @@ class Class_Notice extends Storm_Model_Abstract {
}
public function isToutApprendre() {
return ($this->getTypeDoc() == Class_TypeDoc::TOUTAPPRENDRE);
}
public function isDilicom() {
return $this->getTypeDoc() == Class_TypeDoc::DILICOM;
}
......
......@@ -49,9 +49,9 @@ class Class_Notice_Thumbnail_ResizeImage {
}
public function resize($width, $height, $unlink = false, $bestfit = true) {
public function thumbnail($width, $height, $unlink = false, $bestfit = true) {
if (!$this->_image || !$this->_image->isImage())
return new Class_Entity();
return new Class_Entity(['Message' => $this->_('Il y a un problème avec le fichier source.')]);
$pattern = 'temp/thumbnails/file-manager/%sx%s';
......@@ -70,33 +70,58 @@ class Class_Notice_Thumbnail_ResizeImage {
$this->_image->getName()));
if (@$this->getFileWriter()->fileExists($thumb_path))
return new Class_Entity(['Url' => $thumb_url,
return new Class_Entity(['Message' => $this->_('Le fichier existe déjà.'),
'Url' => $thumb_url,
'Alt' => $this->_('Vignette de l\'image "%s"', $this->_image->getName())]);
if (!@$this->getFileWriter()->fileExists($thumb_parent_path))
@$this->getFileWriter()->mkdir($thumb_parent_path, 0755, true);
try {
$image = static::getImageFactory($this->_image->getPath());
$image->scaleImage($width, $height, $bestfit);
$image->setImageBackgroundColor('none');
$image->setImageCompressionQuality(Class_AdminVar::get('IMAGICK_IMAGE_COMPRESSION_QUALITY'));
$image->setSamplingFactors(explode(';', Class_AdminVar::get('IMAGICK_SAMPLING_FACTORS')));
$callback = $unlink
? (function() use ($thumb_path)
{ @$this->getFileWriter()->unlink($thumb_path);})
: null;
$into = $thumb_path;
try {
$this->_resizeEngine($this->_image->getPath(), $thumb_path, $width, $height, $bestfit, $callback);
} catch(Exception $e) {
return new Class_Entity(['Message' => $this->_('Erreur lors du vignettage de l\'image "%s". %s', $this->_image->getName(),
$e->getMessage())]);
}
if($unlink)
@$this->getFileWriter()->unlink($into);
return new Class_Entity(['Url' => $thumb_url,
'Title' => $this->_('Vignette de l\'image "%s"', $this->_image->getName())]);
}
$image->writeImage($into);
$image->destroy();
public function resize($width, $height, $bestfit = true) {
try {
$this->_resizeEngine($this->_image->getPath(),
$this->_image->getPath(),
$width,
$height,
$bestfit);
} catch(Exception $e) {
return new Class_Entity(['Title' => $this->_('Erreur lors du vignettage de l\'image "%s". %s', $this->_image->getName(),
$e->getMessage())]);
return new Class_Entity(['Message' => $this->_('Erreur lors du vignettage de l\'image "%s". %s',
$this->_image->getName(),
$e->getMessage())]);
}
return new Class_Entity(['Url' => $thumb_url,
'Title' => $this->_('Vignette de l\'image "%s"', $this->_image->getName())]);
return new Class_Entity;
}
protected function _resizeEngine($path, $into, $width, $height, $bestfit = true, $callback = null) {
$image = static::getImageFactory($path);
$image->scaleImage($width, $height, $bestfit);
$image->setImageBackgroundColor('none');
$image->setImageCompressionQuality(Class_AdminVar::getValueOrDefault('IMAGICK_IMAGE_COMPRESSION_QUALITY'));
$image->setSamplingFactors(explode(';', Class_AdminVar::getValueOrDefault('IMAGICK_SAMPLING_FACTORS')));
if($callback)
$callback();
$image->writeImage($into);
$image->destroy();
}
}
\ No newline at end of file
......@@ -114,7 +114,6 @@ class Class_Systeme_ModulesMenu extends Class_Systeme_ModulesAbstract {
"ABON_ACTIVITIES" => new Class_Systeme_ModulesMenu_AbonneActivities(),
"FORM_CONTACT" => new Class_Systeme_ModulesMenu_FormulaireContact(),
"VODECLIC" => new Class_Systeme_ModulesMenu_Vodeclic(),
"TOUTAPPRENDRE" => new Class_Systeme_ModulesMenu_ToutApprendre(),
"NUMILOG" => new Class_Systeme_ModulesMenu_Numilog(),
"ARTEVOD" => new Class_Systeme_ModulesMenu_ArteVOD(),
"MYCOW" => new Class_Systeme_ModulesMenu_MyCow(),
......
......@@ -326,7 +326,6 @@ class Class_TypeDoc extends Storm_Model_Abstract {
const ARTEVOD = 104;
const VODECLIC = 105;
const NUMILOG = 106;
const TOUTAPPRENDRE = 108;
const AUDIO_RECORD = 109;
const NUMERIQUEPREMIUM = 110;
const CYBERLIBRIS = 111;
......@@ -360,7 +359,6 @@ class Class_TypeDoc extends Storm_Model_Abstract {
self::ARTEVOD => 'Arte VOD',
self::VODECLIC => 'Formation Vodeclic',
self::NUMILOG => 'Livres numériques',
self::TOUTAPPRENDRE => 'Cours en ligne',
self::AUDIO_RECORD => 'Enregistrement audio',
self::NUMERIQUEPREMIUM => 'Numérique Premium',
self::CYBERLIBRIS => 'Cyberlibris',
......
......@@ -136,7 +136,6 @@ class Class_UserGroup extends Storm_Model_Abstract {
const RIGHT_ACCES_ARTEVOD = 2;
const RIGHT_ACCES_NUMILOG = 3;
const RIGHT_ACCES_VODECLIC = 5;
const RIGHT_ACCES_TOUTAPPRENDRE = 6;
const RIGHT_ACCES_NUMERIQUEPREMIUM = 20;
const RIGHT_ACCES_CYBERLIBRIS = 22;
const RIGHT_ACCES_MYCOW = 24;
......@@ -179,7 +178,6 @@ class Class_UserGroup extends Storm_Model_Abstract {
self::RIGHT_ACCES_NUMILOG => 'Bibliothèque numérique: accéder à Numilog',
self::RIGHT_ACCES_CYBERLIBRIS => 'Bibliothèque numérique: accéder à Cyberlibris',
self::RIGHT_ACCES_VODECLIC => 'Bibliothèque numérique: accéder à Vodéclic',
self::RIGHT_ACCES_TOUTAPPRENDRE => 'Bibliothèque numérique: accéder à Tout Apprendre',
self::RIGHT_ACCES_NUMERIQUEPREMIUM => 'Bibliothèque numérique: accéder à Numérique Premium',
self::RIGHT_ACCES_MYCOW => 'Bibliothèque numérique: accéder à MyCOW.EU',
self::RIGHT_ACCES_PLANETNEMO => 'Bibliothèque numérique: accéder à planetnemo.fr',
......@@ -229,7 +227,6 @@ class Class_UserGroup extends Storm_Model_Abstract {
'ArteVod' => [Class_UserGroup::RIGHT_ACCES_ARTEVOD],
'Numilog' => [Class_UserGroup::RIGHT_ACCES_NUMILOG],
'Vodeclic' => [Class_UserGroup::RIGHT_ACCES_VODECLIC],
'ToutApprendre' => [Class_UserGroup::RIGHT_ACCES_TOUTAPPRENDRE],
'NumeriquePremium' => [Class_UserGroup::RIGHT_ACCES_NUMERIQUEPREMIUM],
'MyCow' => [Class_UserGroup::RIGHT_ACCES_MYCOW],
'Kidilangues' => [Class_UserGroup::RIGHT_ACCES_KIDILANGUES],
......
Markdown is supported
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