From 1bde44d5c39234fe47855042afb73dc840205271 Mon Sep 17 00:00:00 2001 From: Ghislain Loas <ghislo@sandbox.pergame.net> Date: Wed, 28 Oct 2015 17:30:05 +0100 Subject: [PATCH] dev #30963 add cosmogramme config + add link in exemplaire tab --- .../opac/controllers/NoticeajaxController.php | 1 - cosmogramme/php/_init.php | 1 + .../php/classes/classe_notice_integration.php | 1 - cosmogramme/php/fonctions/objets_saisie.php | 5 +++ .../php/classes/NoticeIntegrationTest.php | 2 -- library/Class/Exemplaire.php | 3 +- library/Class/IntBib.php | 2 +- library/Class/IntProfilDonnees.php | 2 -- library/Class/Notice.php | 10 ++---- library/Class/Users.php | 1 - library/Class/WebService/SIGB/CdScript.php | 2 +- .../WebService/SIGB/CdScript/Service.php | 24 +++++++++++++ library/Class/WebService/SIGB/NoticeCache.php | 2 +- .../View/Helper/Notice/Exemplaires.php | 3 +- .../NoticeAjaxControllerCdScriptTest.php | 35 ++++++++++++++++--- .../Class/WebService/SIGB/CdScriptTest.php | 28 ++++++++++++++- 16 files changed, 97 insertions(+), 25 deletions(-) diff --git a/application/modules/opac/controllers/NoticeajaxController.php b/application/modules/opac/controllers/NoticeajaxController.php index 1d1c1a69cc5..c3201f48def 100644 --- a/application/modules/opac/controllers/NoticeajaxController.php +++ b/application/modules/opac/controllers/NoticeajaxController.php @@ -111,7 +111,6 @@ class NoticeAjaxController extends Zend_Controller_Action { $exemplaires = $this->_loadExemplaire(["id_notice" => $notice_ids]); - foreach($exemplaires as $exemplaire) $exemplaire->updateAvailabilityFromSIGB() ->save(); diff --git a/cosmogramme/php/_init.php b/cosmogramme/php/_init.php index 19dae8187ba..945aa9fd64d 100644 --- a/cosmogramme/php/_init.php +++ b/cosmogramme/php/_init.php @@ -18,6 +18,7 @@ define('COM_ORPHEE', 8); define('COM_MICROBIB', 9); define('COM_BIBLIXNET', 10); define('COM_DYNIX', 11); +define('COM_CDSCRIPT', 12); $basePath = dirname(realpath(__FILE__)); set_include_path(get_include_path() diff --git a/cosmogramme/php/classes/classe_notice_integration.php b/cosmogramme/php/classes/classe_notice_integration.php index 8535dd79fd6..7ce41cdba91 100644 --- a/cosmogramme/php/classes/classe_notice_integration.php +++ b/cosmogramme/php/classes/classe_notice_integration.php @@ -110,7 +110,6 @@ class notice_integration { } $this->format=$format; unset($this->analyseur); - switch($format) { // Unimarc diff --git a/cosmogramme/php/fonctions/objets_saisie.php b/cosmogramme/php/fonctions/objets_saisie.php index 6566004dd60..dbf0bba28aa 100644 --- a/cosmogramme/php/fonctions/objets_saisie.php +++ b/cosmogramme/php/fonctions/objets_saisie.php @@ -97,6 +97,11 @@ function getBlocsParams($id_bib, $type, $valeurs) { return getOuiNon($id, $valeur); }]]; + if(in_array($clef, [COM_CDSCRIPT])) + $champs_params[0] = ['server_url', + 'remote_library_id']; + + if (in_array($clef, [COM_VSMART, COM_MICROBIB, COM_BIBLIXNET])) $champs_params[0] = ['url_serveur']; diff --git a/cosmogramme/tests/php/classes/NoticeIntegrationTest.php b/cosmogramme/tests/php/classes/NoticeIntegrationTest.php index aaefcd3fada..8955bd800ef 100644 --- a/cosmogramme/tests/php/classes/NoticeIntegrationTest.php +++ b/cosmogramme/tests/php/classes/NoticeIntegrationTest.php @@ -136,10 +136,8 @@ abstract class NoticeIntegrationTestCase extends ModelTestCase { public function loadNoticeFromString($unimarc) { Codif_langue::getInstance()->setCodif(['fre' => ['id_langue' => 'fre', 'libelle' => 'français']]); - $this->notice_integration = new notice_integration(); $this->notice_integration->setParamsIntegration(1, 0, isset($this->_profil_donnees['id_profil']) ? $this->_profil_donnees['id_profil'] : 1); - xdebug_break(); $this->notice_integration->traiteNotice($unimarc); $this->notice_integration->traiteFacettes(); $this->notice_data = $this->notice_integration->getNotice(); diff --git a/library/Class/Exemplaire.php b/library/Class/Exemplaire.php index f21c0f981cc..21be5d23d2d 100644 --- a/library/Class/Exemplaire.php +++ b/library/Class/Exemplaire.php @@ -46,7 +46,8 @@ class Class_Exemplaire extends Storm_Model_Abstract { 'genre' => null, 'url' => null, 'emplacement' => '', - 'date_nouveaute' => '']; + 'date_nouveaute' => '', + 'cote' => '']; protected $_sigb_exemplaire; diff --git a/library/Class/IntBib.php b/library/Class/IntBib.php index 62a5606ac1e..5ab61c81eeb 100644 --- a/library/Class/IntBib.php +++ b/library/Class/IntBib.php @@ -50,7 +50,7 @@ class Class_IntBib extends Storm_Model_Abstract { self::COM_MICROBIB => 'Class_WebService_SIGB_Microbib', self::COM_BIBLIXNET => 'Class_WebService_SIGB_BiblixNet', self::COM_DYNIX => 'Class_WebService_SIGB_Dynix', - self::COM_CDSCRIPT => 'Class_WebService_CdScript']; + self::COM_CDSCRIPT => 'Class_WebService_SIGB_CdScript']; protected $_table_name = 'int_bib'; protected $_table_primary = 'id_bib'; diff --git a/library/Class/IntProfilDonnees.php b/library/Class/IntProfilDonnees.php index 8422ad81772..b7393013d5a 100644 --- a/library/Class/IntProfilDonnees.php +++ b/library/Class/IntProfilDonnees.php @@ -421,8 +421,6 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { public static function forCdScript() { - xdebug_break(); - return self:: newInstance(['libelle' => 'Unimarc Cd-Script', 'accents' => self::ENCODING_UTF8, diff --git a/library/Class/Notice.php b/library/Class/Notice.php index 0fd4e6916f4..0e43db0f502 100644 --- a/library/Class/Notice.php +++ b/library/Class/Notice.php @@ -1468,14 +1468,10 @@ class Class_Notice extends Storm_Model_Abstract { if ($album = $this->getAlbum()) return $album->getDescription(); - $resumes = ''; - $datas = $this->get_subfield('330', 'a'); + $data = $this->get_subfield('330', 'a'); - foreach($datas as $data) - $resumes.= (($resume = $this->_getHtmlSummary([$data])) ? - $resume : $this->_getTextSummary([$data])) . BR; - - return $this->_resume = $resumes; + return $this->_resume = (($resume = $this->_getHtmlSummary($data)) ? + $resume : $this->_getTextSummary($data)); } diff --git a/library/Class/Users.php b/library/Class/Users.php index e6359993850..28495ad3955 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -103,7 +103,6 @@ class UsersLoader extends Storm_Model_Loader { * @return Class_Users */ public function getIdentity() { - xdebug_break(); try { if (!$user = ZendAfi_Auth::getInstance()->getIdentity()) return null; diff --git a/library/Class/WebService/SIGB/CdScript.php b/library/Class/WebService/SIGB/CdScript.php index 341be17b623..371a4b8eae3 100644 --- a/library/Class/WebService/SIGB/CdScript.php +++ b/library/Class/WebService/SIGB/CdScript.php @@ -29,7 +29,7 @@ class Class_WebService_SIGB_CdScript { $instance = new static(); $classname = get_called_class().'_Service'; static::$service = $classname::getService($params['server_url'], - $params['bib']); + $params['remote_library_id']); } return static::$service; diff --git a/library/Class/WebService/SIGB/CdScript/Service.php b/library/Class/WebService/SIGB/CdScript/Service.php index b62c9299efc..e19f6c34af7 100644 --- a/library/Class/WebService/SIGB/CdScript/Service.php +++ b/library/Class/WebService/SIGB/CdScript/Service.php @@ -81,5 +81,29 @@ class Class_Webservice_SIGB_CdScript_Service { 'empty@email', $user->getDateFin()]); } + + + public function getNotice($id) { + $sigb_record = new Class_WebService_SIGB_Notice($id); + $item = Class_Exemplaire::findFirstBy(['code_barres' => $id]); + $sigb_item = new Class_WebService_SIGB_Exemplaire($id); + $sigb_item->setCodeBarre($id); + $sigb_item->setBibliotheque($item->getBib()); + $item->setUrl($this->getRessourceUrl($item))->save(); + return $sigb_record->addExemplaire($sigb_item); + } + + + public function getNoticeCache() { + if (!isset($this->_notice_cache)) + $this->_notice_cache = new Class_WebService_SIGB_NoticeCache($this); + return $this->_notice_cache; + } + + + public function getExemplaire($notice_id, $code_barre){ + $item = $this->getNoticeCache()->getExemplaire($notice_id, $code_barre); + return $item; + } } ?> \ No newline at end of file diff --git a/library/Class/WebService/SIGB/NoticeCache.php b/library/Class/WebService/SIGB/NoticeCache.php index ff1211d3f0d..b038912ef04 100644 --- a/library/Class/WebService/SIGB/NoticeCache.php +++ b/library/Class/WebService/SIGB/NoticeCache.php @@ -16,7 +16,7 @@ * * 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 */ /* diff --git a/library/ZendAfi/View/Helper/Notice/Exemplaires.php b/library/ZendAfi/View/Helper/Notice/Exemplaires.php index 0718501ce06..1372421bd89 100644 --- a/library/ZendAfi/View/Helper/Notice/Exemplaires.php +++ b/library/ZendAfi/View/Helper/Notice/Exemplaires.php @@ -23,6 +23,7 @@ class ZendAfi_View_Helper_Notice_Exemplaires extends ZendAfi_View_Helper_BaseHel protected $renderers = []; public function Notice_Exemplaires($exemplaires, $nb_notices_oeuvre=0, $aff="normal") { + xdebug_break(); $preferences = Class_Profil::getCurrentProfil()->getCfgNoticeAsArray()['exemplaires']; if (!$exemplaires) return false; @@ -151,7 +152,6 @@ class ZendAfi_View_Helper_Notice_Exemplaires extends ZendAfi_View_Helper_BaseHel class ZendAfi_View_Helper_Notice_Exemplaires_RenderByGroup extends ZendAfi_View_Helper_Notice_Exemplaires { public function Notice_Exemplaires_RenderByGroup($exemplaires, $preferences, $nb_notices_oeuvre=0, $aff="normal") { - $group_exemplaires = []; foreach($this->exemplairesToRows($exemplaires) as $ex) { $group_key = $ex['id_notice'].'_'.$ex['id_bib'].'_'.$ex['cote']; @@ -171,7 +171,6 @@ class ZendAfi_View_Helper_Notice_Exemplaires_RenderByGroup extends ZendAfi_View_ class ZendAfi_View_Helper_Notice_Exemplaires_RenderByItem extends ZendAfi_View_Helper_Notice_Exemplaires { public function Notice_Exemplaires_RenderByItem($exemplaires, $preferences, $nb_notices_oeuvre=0, $aff='normal') { $exemplaires = $this->_getSortedItems($exemplaires, $preferences); - return $this->render((new Class_CommSigb())->getDispoExemplaires($exemplaires), $preferences, $nb_notices_oeuvre, diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerCdScriptTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerCdScriptTest.php index 75d321eba59..1c1a64d4a10 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerCdScriptTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerCdScriptTest.php @@ -23,28 +23,55 @@ class NoticeAjaxControllerCdScriptRecordTest extends AbstractControllerTestCase { protected $_record_le_kiosque, - $_item_le_kiosque; + $_item_le_kiosque, + $_service, + $_sigb_le_kiosque; public function setUp() { parent::setUp(); + + $config = Class_Profil::getCurrentProfil()->getCfgNoticeAsArray(); + $config['exemplaires']['grouper'] = '1'; + Class_Profil::getCurrentProfil()->setCfgNotice($config); + + $this->fixture('Class_IntBib', + ['id' => 3, + 'comm_sigb' => Class_IntBib::COM_CDSCRIPT]); + + $this->fixture('Class_Bib', + ['id' => 3, + 'libelle' => 'Le kiosque library']); + $this->_item_le_kiosque = $this->fixture('Class_Exemplaire', ['id' => 1, 'code_barres' => '456789', 'id_origine' => '456789', + 'id_notice' => 2, 'id_int_bib' => '3', 'id_bib' => '3', 'zone995' => 'a:3:{i:0;a:2:{s:4:"code";s:1:"a";s:6:"valeur";s:10:"Le Kiosque";}i:1;a:2:{s:4:"code";s:1:"b";s:6:"valeur";s:3:"kio";}i:2;a:2:{s:4:"code";s:1:"f";s:6:"valeur";s:3:"319";}}']); $this->_record_le_kiosque = $this->fixture('Class_Notice', ['id' => 2, - 'exemplaire' => $this->_item_le_kiosque]); + 'exemplaires' => [$this->_item_le_kiosque]]); + + $this->_service = Class_WebService_SIGB_CdScript::getService(['server_url' => 'www.jumel39.fr/docnum.php', + 'bib' => 2]); + $this->_service->setTimeSource(new TimeSourceForTest('2015-10-28 09:00:00')); - $this->dispatch('/opac/noticeajax/id_notice/197143', true); + $this->dispatch('/opac/noticeajax/exemplaires/id_notice/2', true); + $this->_sigb_le_kiosque = $this->_service->getNotice('456789')->getExemplaireByCodeBarre('456789'); } /** @test */ public function linkToJumelShouldBePresent() { - $this->assertXPathContentContains('//table//a[contains(@href, "jumel.fr")]', 'Accès à la ressource'); + $this->assertXPathContentContains('//table//a[contains(@href, "www.jumel39.fr/docnum.php?bib=2&res=kio&lien=456789&time=1446019200")]', 'Description en ligne'); + } + + + /** @test */ + public function libraryLabelShouldBeLeKiosqueLibrary() { + $this->assertXPathContentContains('//table//td', 'Le kiosque library'); } } ?> \ No newline at end of file diff --git a/tests/library/Class/WebService/SIGB/CdScriptTest.php b/tests/library/Class/WebService/SIGB/CdScriptTest.php index 3fcb0b1ec08..ccbfcbb60ec 100644 --- a/tests/library/Class/WebService/SIGB/CdScriptTest.php +++ b/tests/library/Class/WebService/SIGB/CdScriptTest.php @@ -36,10 +36,16 @@ abstract class CdScriptTestCase extends Storm_Test_ModelTestCase { class CdScriptServiceTest extends CdScriptTestCase { protected $_paul, - $_le_kiosque; + $_le_kiosque, + $_sigb_le_kiosque; public function setUp() { parent::setUp(); + + $this->fixture('Class_Bib', + ['id' => 3, + 'libelle' => 'Le kiosque library']); + $this->_paul = $this->fixture('Class_Users', ['id' => 15, 'login' => 'paul', @@ -60,6 +66,8 @@ class CdScriptServiceTest extends CdScriptTestCase { 'id_int_bib' => '3', 'id_bib' => '3', 'zone995' => 'a:3:{i:0;a:2:{s:4:"code";s:1:"a";s:6:"valeur";s:10:"Le Kiosque";}i:1;a:2:{s:4:"code";s:1:"b";s:6:"valeur";s:3:"kio";}i:2;a:2:{s:4:"code";s:1:"f";s:6:"valeur";s:3:"319";}}']); + + $this->_sigb_le_kiosque = $this->_service->getNotice('456789')->getExemplaireByCodeBarre('456789'); } @@ -79,4 +87,22 @@ class CdScriptServiceTest extends CdScriptTestCase { public function ressourceUrlShouldBeJumelBib2UserPaulAnd12oclok() { $this->assertEquals('www.jumel39.fr/docnum.php?bib=2&res=kio&lien=456789&time=1446019200&user=654987:Le Pollux:Paul:2002-12-14:empty@email:2015-12-14', $this->_service->getRessourceUrl($this->_le_kiosque)); } + + + /** @test */ + public function leKiosqueItemIdShouldBe456789() { + $this->assertEquals('456789', $this->_sigb_le_kiosque->getId()); + } + + + /** @test */ + public function leKiosqueItemDispoShouldBeJumelLink() { + $this->assertEquals('www.jumel39.fr/docnum.php?bib=2&res=kio&lien=456789&time=1446019200&user=654987:Le Pollux:Paul:2002-12-14:empty@email:2015-12-14', $this->_sigb_le_kiosque->getDisponibilite()); + } + + + /** @test */ + public function leKiosqueBibShouldBeLeKiosqueLibrary() { + $this->assertEquals('Le kiosque library', $this->_sigb_le_kiosque->getBibliotheque()->getLibelle()); + } } -- GitLab