diff --git a/VERSIONS_HOTLINE/133329 b/VERSIONS_HOTLINE/133329 new file mode 100644 index 0000000000000000000000000000000000000000..64c6f52e5c8dd2a94c271148710aa99c2575da59 --- /dev/null +++ b/VERSIONS_HOTLINE/133329 @@ -0,0 +1 @@ + - ticket #133329 : Magasin de thèmes : Correction page bibliothèque, le lien de navigation précédent et suivant ne fonctionnait pas avec le mode url personnalisé \ No newline at end of file diff --git a/VERSIONS_HOTLINE/137943 b/VERSIONS_HOTLINE/137943 new file mode 100644 index 0000000000000000000000000000000000000000..cbb0114f06adbe676ddb04147e5057a748a6523b --- /dev/null +++ b/VERSIONS_HOTLINE/137943 @@ -0,0 +1 @@ + - ticket #137943 : Integration : Ajout du support pour le titre principal des Titres multiples pour cause de présence de transcription dans d'autres langues \ No newline at end of file diff --git a/VERSIONS_HOTLINE/141158 b/VERSIONS_HOTLINE/141158 new file mode 100644 index 0000000000000000000000000000000000000000..d797fb00c4d1c3be02c1f8411a8f25b25e29ff1c --- /dev/null +++ b/VERSIONS_HOTLINE/141158 @@ -0,0 +1 @@ + - ticket #141158 : Administration : Correction du droit d'inscription aux activités \ No newline at end of file diff --git a/VERSIONS_HOTLINE/141556 b/VERSIONS_HOTLINE/141556 new file mode 100644 index 0000000000000000000000000000000000000000..ff31276ef08d6d38da7502d60a499e710d8ed0c7 --- /dev/null +++ b/VERSIONS_HOTLINE/141556 @@ -0,0 +1 @@ + - ticket #141556 : Magasin de thèmes : Correction de l'invalidation du cache du compte abonné. \ No newline at end of file diff --git a/VERSIONS_HOTLINE/142649 b/VERSIONS_HOTLINE/142649 new file mode 100644 index 0000000000000000000000000000000000000000..444d82c9316f67d807bd0e094578ff9685ee70fb --- /dev/null +++ b/VERSIONS_HOTLINE/142649 @@ -0,0 +1,2 @@ + - ticket #142649 : Magasin de thèmes : Amélioration des performances du rendu liste à interactions. + Amélioration des performances de rendu des exemplaires de périodiques. Lorsqu'une notice de périodiques a plus de 20 exemplaires, elle utilise le rendu de liste à interactions. \ No newline at end of file diff --git a/VERSIONS_HOTLINE/143652 b/VERSIONS_HOTLINE/143652 new file mode 100644 index 0000000000000000000000000000000000000000..58c3bd3e0d26245d9c1337fdc950d72db6e3d385 --- /dev/null +++ b/VERSIONS_HOTLINE/143652 @@ -0,0 +1 @@ + - ticket #143652 : Magasin de thèmes : Affichage d'informations complémentaires sur les sélections lorsqu'Inspecteur Gadget est activé. \ No newline at end of file diff --git a/VERSIONS_WIP/143667 b/VERSIONS_WIP/143667 new file mode 100644 index 0000000000000000000000000000000000000000..9edcd3df362cd1fadec55ecee47680bee98b4d43 --- /dev/null +++ b/VERSIONS_WIP/143667 @@ -0,0 +1 @@ + - ticket #143667 : Administration : la fonction de test d'envoie de mail permet d'attacher un fichier \ No newline at end of file diff --git a/application/modules/admin/controllers/SystemeController.php b/application/modules/admin/controllers/SystemeController.php index 38683a21e3569c20c16d3eaa0f4ddd0809e49d40..5db2c4b5c877ff60681df651c06192b22ebe8f3c 100644 --- a/application/modules/admin/controllers/SystemeController.php +++ b/application/modules/admin/controllers/SystemeController.php @@ -237,37 +237,48 @@ class Admin_SystemeController extends Zend_Controller_Action { $this->view->titre = $this->_('Test de l\'envoi des mails'); $form = $this->view - ->newForm(['id' => 'mailtest']) - ->addElement('text', 'sender', ['label' => 'Emetteur', + ->newForm(['id' => 'mailtest', + 'enctype' => Zend_Form::ENCTYPE_MULTIPART]) + ->addElement('text', 'sender', ['label' => $this->_('Emetteur'), 'size' => 50, 'required' => true, 'allowEmpty' => false, 'validators' => ['emailAddress'], 'value' => Class_Profil::getLoader()->getPortail()->getMailSite()]) - ->addElement('text', 'recipient', ['label' => 'Destinataire', + ->addElement('text', 'recipient', ['label' => $this->_('Destinataire'), 'size' => 50, 'required' => true, 'allowEmpty' => false, 'validators' => ['emailAddress']]) - ->addDisplayGroup(['sender', 'recipient'], + ->addElement('file', 'attachment', ['label' => $this->_('Fichier joint')]) + ->addDisplayGroup(['sender', 'recipient', 'attachment'], 'mail', ['legend' => 'Général']) ->addElement('submit', 'send', ['label' => $this->_('Envoyer')]); + $this->view->form = $form; + + if (!$this->_request->isPost() || !$form->isValid($this->_request->getPost())) + return $this; - if ($this->_request->isPost() && $form->isValid($this->_request->getPost())) { - $mail = new ZendAfi_Mail(); - $mail - ->setFrom($this->_request->getPost('sender')) - ->addTo($this->_request->getPost('recipient')) - ->setSubject('[Bokeh] test envoi mails') - ->setBodyText('Envoyé depuis '.BASE_URL) - ->send(); - $this->view->message = $this->_('Le mail a bien été envoyé'); + $mail = new ZendAfi_Mail(); + + if (isset($_FILES['attachment']) && $_FILES['attachment']['size'] > 0) { + $attachment = $_FILES['attachment']; + $mail->attachFile($attachment['tmp_name'], + $attachment['type'], + $attachment['name']); } - $this->view->form = $form; + $mail + ->setFrom($this->_request->getPost('sender')) + ->addTo($this->_request->getPost('recipient')) + ->setSubject('[Bokeh] test envoi mails') + ->setBodyText('Envoyé depuis '. Class_AdminVar::get('NOM_DOMAINE')) + ->send(); + + $this->view->message = $this->_('Le mail a bien été envoyé'); } @@ -275,4 +286,4 @@ class Admin_SystemeController extends Zend_Controller_Action { $this->view->titre = $this->_('Etat du système'); } } -?> \ No newline at end of file +?> diff --git a/application/modules/opac/controllers/AbonneController.php b/application/modules/opac/controllers/AbonneController.php index dad49362518ae64183ffc5e238eff586dedabf7d..28eefc4e706ddb52acdbfdf261babb8c7da41faa 100644 --- a/application/modules/opac/controllers/AbonneController.php +++ b/application/modules/opac/controllers/AbonneController.php @@ -77,9 +77,13 @@ class AbonneController extends ZendAfi_Controller_Action { protected function clearEmprunteurCache() { - $no_cache_actions = Class_Template::current()->isLegacy() - ? ['prets', 'reservations', 'fiche', 'loans-history', 'ajax-loans', 'suggestions'] - : ['fiche', 'loans-history', 'ajax-loans', 'suggestions']; + $no_cache_actions = + ['fiche', + 'prets', + 'reservations', + 'loans-history', + 'ajax-loans', + 'suggestions']; if (!in_array($this->getRequest()->getActionName(), $no_cache_actions)) diff --git a/application/modules/opac/controllers/IndexController.php b/application/modules/opac/controllers/IndexController.php index 62ef77af1675dbd0f118d96e4a6e014bbdc9ba91..1d9fc7afc4923cd4881a9b8e1548f36ad926fa7c 100644 --- a/application/modules/opac/controllers/IndexController.php +++ b/application/modules/opac/controllers/IndexController.php @@ -121,10 +121,10 @@ class IndexController extends ZendAfi_Controller_Action { public function ajaxPaginatedListAction() { session_write_close(); - $callback = function() { - if (! $helper = Intonation_Library_AjaxPaginatedListHelper::find($this->_getParam('id'))) - return ''; + if (! $helper = Intonation_Library_AjaxPaginatedListHelper::find($this->_getParam('id'))) + return $this->_javascriptRedirectToReferrer(); + $callback = function() use ($helper) { $helper ->setView($this->view) ->setPageSize($this->_getParam('size', 3)) @@ -143,4 +143,4 @@ class IndexController extends ZendAfi_Controller_Action { session_write_close(); $this->getHelper('ViewRenderer')->setNoRender(); } -} \ No newline at end of file +} diff --git a/application/modules/opac/controllers/NoticeajaxController.php b/application/modules/opac/controllers/NoticeajaxController.php index ba2f54863554488171605cfac10a1c08657d3b0f..6333306eaee53ea9ac7a941a190278204f7d891a 100644 --- a/application/modules/opac/controllers/NoticeajaxController.php +++ b/application/modules/opac/controllers/NoticeajaxController.php @@ -518,17 +518,9 @@ class NoticeAjaxController extends ZendAfi_Controller_Action { public function itemsResourcesAction() { - $record = new Intonation_Library_Record($this->notice); - - if ($record->isExternalResource()) - return $this->_helper->ajax(function() use ($record) - { - return $this->_getLinkOnline($record->getUrl()); - }); - - - $this->_helper->ajax(function() use ($record) + $this->_helper->ajax(function() { + $record = new Intonation_Library_Record($this->notice); return $this->view ->RenderRecord_RenderItems($record->getItemsFromSIGB(), $record->getSameWorkItemsFromSIGB()); @@ -552,20 +544,13 @@ class NoticeAjaxController extends ZendAfi_Controller_Action { } - protected function _getLinkOnline($url) { - return $this->view->tagAnchor($url, - $this->_('Description en ligne'), - ['class' => 'btn btn-lg btn-primary m-3']); - } - - public function urlResourcesAction() { if (!$items = $this->notice->getExemplaires()) return $this->_helper->ajax(); $first_item = $items[0]; $callback = function() use ($first_item) { - return $this->_getLinkOnline($first_item->getExternalUrl()); + return $this->view->RenderRecord_ExternalUrl($first_item->getExternalUrl()); }; return $this->_helper->ajax($callback); diff --git a/cosmogramme/php/classes/classe_notice_integration.php b/cosmogramme/php/classes/classe_notice_integration.php index 4ab4413bd260916f89f0c35019a81ff07cb66f9a..194964c78b637710c2e48e932d6e95b554d019c0 100644 --- a/cosmogramme/php/classes/classe_notice_integration.php +++ b/cosmogramme/php/classes/classe_notice_integration.php @@ -421,8 +421,7 @@ class notice_integration { foreach($this->notice['exemplaires'] as $item) $serial_integration->_traitePeriodiquesKohaItem($this->notice, unserialize($item['zone995']), - $champ_numero, - $id_origine); + $champ_numero); if ($this->id_article_periodique == Class_IntProfilDonnees::SERIAL_FORMAT_ORPHEE) { $this->statut = static::RECORD_SKIP; @@ -801,7 +800,7 @@ class notice_integration { $exemplaires = []; foreach ($this->notice['exemplaires'] as $ex) { $code_barres []= $ex['code_barres']; - if ($ex["activite"]=="d") + if (isset($ex['activite']) && $ex["activite"]=="d") continue; $exemplaire = Class_Exemplaire::newInstance($ex) diff --git a/cosmogramme/php/classes/classe_unimarc.php b/cosmogramme/php/classes/classe_unimarc.php index dec124117069d2b1665f8605cc2859844f37a3d0..fe031a790ccafb3b752a45e071ed542d2feadadc 100644 --- a/cosmogramme/php/classes/classe_unimarc.php +++ b/cosmogramme/php/classes/classe_unimarc.php @@ -458,9 +458,13 @@ class notice_unimarc extends iso2709_record { public function getTitrePrincipal() { - if(!$titre = $this->get_subfield('200', 'a')) + $titres_field = $this->get_subfield('200'); + + if (!$titres_field) return ''; - $titre = trim($titre[0]); + + $titre = implode(' ',array_unique($this->get_subfield('200','a'))); + $titre = $this->filtreTitre($titre); return $titre; } @@ -596,8 +600,10 @@ class notice_unimarc extends iso2709_record { $ex['annexe'] = ($annexe) ? $annexe->getCode() : $champ['valeur']; } - if ($champs_nouveaute['zone'] == $item_zone - && $champ['code'] == $champs_nouveaute['champ']) { + if (isset($champs_nouveaute['zone']) + && isset($champs_nouveaute['champ']) + && ($champs_nouveaute['zone'] == $item_zone + && $champ['code'] == $champs_nouveaute['champ'])) { $ex['date_nouveaute'] = $this->calculDateNouveaute($champ['valeur']); } @@ -1164,6 +1170,7 @@ class notice_unimarc extends iso2709_record { $z995r = $this->get_subfield($zone, $this->profil['attributs'][0]['champ_type_doc']); + $z995p = []; } else { $z995r = $this->get_subfield($zone, 'r'); $z995p = $this->get_subfield($zone, 'p'); @@ -1616,8 +1623,7 @@ class notice_unimarc extends iso2709_record { public function getAll() { - $data = $this->get_subfield(200, 'a'); - $notice["titre_princ"] = $data[0]; + $notice["titre_princ"] = $this->getTitrePrincipal(); $label[]=["Longueur de la notice",$this->inner_guide["rl"]]; $label[]=["Statut de la notice",$this->inner_guide["rs"]]; diff --git a/cosmogramme/tests/php/classes/CarthameIntegrationTest.php b/cosmogramme/tests/php/classes/CarthameIntegrationTest.php index 6e41201b134b4de421e5024d088c5020e3488fdb..87791e647dd26aa51cd895ccc94b9346c04cfef9 100644 --- a/cosmogramme/tests/php/classes/CarthameIntegrationTest.php +++ b/cosmogramme/tests/php/classes/CarthameIntegrationTest.php @@ -22,75 +22,75 @@ require_once 'NoticeIntegrationTest.php'; abstract class CarthameIntegrationTestCase extends NoticeIntegrationTestCase { - public function setUp() { - parent::setUp(); - $vars = ['filtrer_fulltext' => 1, - 'homogene_code_qualite' => 10, - 'homogene' => 0, - 'mode_doublon'=> 0, - 'tracer_accents_iso'=> 1, - 'non_exportable'=> 'electre;decitre;gam;zebris', - 'controle_codes_barres'=> 0, - 'unimarc_zone_titre' => '200$a;461$t', - 'unicite_code_barres' => Class_CosmoVar::UNIQ_BARCODE_ONLY, - 'champs_sup' => '', - 'ean_345' => '']; - foreach($vars as $key => $value) - Class_CosmoVar::newInstanceWithId($key, ['valeur' => $value]); - } - - - public function getProfilDonnees() { - return - ['id_profil' => 106, - 'libelle' => 'Carthame', - 'accents' => Class_IntProfilDonnees::ENCODING_ISO2709, - 'rejet_periodiques' => '1', - 'id_article_periodique' => Class_IntProfilDonnees::SERIAL_FORMAT_NONE, - 'type_fichier' => Class_IntProfilDonnees::FT_RECORDS, - 'format' => Class_IntProfilDonnees::FORMAT_UNIMARC, - 'attributs' => serialize( - [ [ - 'type_doc' => [ - [ 'code' => '0', 'label' => '', 'zone_995' => '' ], - [ 'code' => '1', 'label' => 'am;na', 'zone_995' => 'au;ku' ], - [ 'code' => '2', 'label' => '', 'zone_995' => ''], - [ 'code' => '3', 'label' => 'i;j', 'zone_995' => 'je;jd'], - [ 'code' => '4', 'label' => 'g','zone_995' => 'g'], - [ 'code' => '5', 'label' => 'l;m', 'zone_995' => 'le'], - [ 'code' => '6', 'label' => 'f;k', 'zone_995' => 'f;k'], - [ 'code' => '10', 'label' => '', 'zone_995' => 'uu'], - ], - 'champ_code_barres' => 'f', - 'champ_cote' => 'k', - 'champ_type_doc' => '', - 'champ_genre' => '', - 'champ_section' => '', - 'champ_emplacement' => '', - 'champ_annexe' => '' - ], - - [ 'champs' => ''], - [ 'champs' => ''], - [ 'champs' => ''], - [ 'champs' => ''], - [ 'zone' => '995', 'champ' => '', 'format' => '', 'jours' => '', 'valeurs' => ''] - ])]; - } + public function setUp() { + parent::setUp(); + $vars = ['filtrer_fulltext' => 1, + 'homogene_code_qualite' => 10, + 'homogene' => 0, + 'mode_doublon'=> 0, + 'tracer_accents_iso'=> 1, + 'non_exportable'=> 'electre;decitre;gam;zebris', + 'controle_codes_barres'=> 0, + 'unimarc_zone_titre' => '200$a;461$t', + 'unicite_code_barres' => Class_CosmoVar::UNIQ_BARCODE_ONLY, + 'champs_sup' => '', + 'ean_345' => '']; + foreach($vars as $key => $value) + Class_CosmoVar::newInstanceWithId($key, ['valeur' => $value]); + } + + + public function getProfilDonnees() { + return + ['id_profil' => 106, + 'libelle' => 'Carthame', + 'accents' => Class_IntProfilDonnees::ENCODING_ISO2709, + 'rejet_periodiques' => '1', + 'id_article_periodique' => Class_IntProfilDonnees::SERIAL_FORMAT_NONE, + 'type_fichier' => Class_IntProfilDonnees::FT_RECORDS, + 'format' => Class_IntProfilDonnees::FORMAT_UNIMARC, + 'attributs' => serialize( + [ [ + 'type_doc' => [ + [ 'code' => '0', 'label' => '', 'zone_995' => '' ], + [ 'code' => '1', 'label' => 'am;na', 'zone_995' => 'au;ku' ], + [ 'code' => '2', 'label' => '', 'zone_995' => ''], + [ 'code' => '3', 'label' => 'i;j', 'zone_995' => 'je;jd'], + [ 'code' => '4', 'label' => 'g','zone_995' => 'g'], + [ 'code' => '5', 'label' => 'l;m', 'zone_995' => 'le'], + [ 'code' => '6', 'label' => 'f;k', 'zone_995' => 'f;k'], + [ 'code' => '10', 'label' => '', 'zone_995' => 'uu'], + ], + 'champ_code_barres' => 'f', + 'champ_cote' => 'k', + 'champ_type_doc' => '', + 'champ_genre' => '', + 'champ_section' => '', + 'champ_emplacement' => '', + 'champ_annexe' => '' + ], + + [ 'champs' => ''], + [ 'champs' => ''], + [ 'champs' => ''], + [ 'champs' => ''], + [ 'zone' => '995', 'champ' => '', 'format' => '', 'jours' => '', 'valeurs' => ''] + ])]; + } } class TangoMangoCarthameIntegrationTest extends CarthameIntegrationTestCase { - protected $_notice; + protected $_notice; - public function setUp() { - parent::setUp(); + public function setUp() { + parent::setUp(); Class_CosmoVar::setValueOf('url_services', 'https://websvc.afi-sa.net/afi_opac_services/main.php'); - $this->fixture(Class_Notice::class, + $this->fixture(Class_Notice::class, ['id' => 7939934, 'type_doc' => 1, 'facettes' => 'Lfre G3 T1 B7 B2 V2 2015-09', @@ -103,38 +103,55 @@ class TangoMangoCarthameIntegrationTest extends CarthameIntegrationTestCase { 'date_creation' => '2015-09-08 00:00:00', 'date_maj' => '2015-03-13 02:00:12', 'unimarc' => '01041cam0 2200289 450 001002100000003004700021010003900068020001700107021002700124073001800151100004100169101000800210102000700218105001800225106000600243200000500249210000100254215000100255225000100256300000100257330048800258461000100746686000100747700000100748801000100749930000100750FRBNF437016350000001http://catalogue.bnf.fr/ark:/12148/cb43701635n a978-2-35910-416-5brel.d12,90 EUR aFRb01364260 aFRbDLE-20131029-62048 0a9782359104165 a20131029d2013 m y0frey50 ba0 afre aFR a||||t 00|a| ar1 aaaAn 982, alors qu\' Elaine et Encre Noire continuent de réparer leur bateau, un évènement inattendu bouleverse les Eaux Tièdes : le retour de la Gazette du Pirate !aLa Gazette du pirate annonce le retour du grand tournoi, le rendez-vous incontournable des écumeurs des mers. Encre Noire et Elaine décident de voler des trésors et d\'amasser de l\'argent pour acheter un nouveau gouvernail afin de mettre toutes les chances de leur côté pour remporter l\'épreuve. ÂElectre 2015']); - } + } - /** @test */ - public function importFromFileShouldNotCreateAnOtherRecord() { - $this->loadNotice('unimarc_tangomango'); - $notice = Class_Notice::find(7939934); - $this->assertCount(1, Class_Notice::findAll()); - return $notice; - } + /** @test */ + public function importFromFileShouldNotCreateAnOtherRecord() { + $this->loadNotice('unimarc_tangomango'); + $notice = Class_Notice::find(7939934); + $this->assertCount(1, Class_Notice::findAll()); + return $notice; + } - /** - * @depends importFromFileShouldNotCreateAnOtherRecord - * @test - * */ - public function importFromFileShouldUpdateNotice($notice) { - $this->assertEquals('TangoMango n° 2<br />La Gazette du pirate', $notice->getTitrePrincipal()); - } + /** + * @depends importFromFileShouldNotCreateAnOtherRecord + * @test + * */ + public function importFromFileShouldUpdateNotice($notice) { + $this->assertEquals('TangoMango n° 2<br />La Gazette du pirate', $notice->getTitrePrincipal()); + } - /** + /** * @test * @group real_network_call */ - public function homogenizeShouldUpdateNotice() { - $notice = Class_Notice::find(7939934); - $notice_integration = new notice_integration(); - $notice_integration->traiteHomogene($notice); - - Class_Notice::clearCache(); - $notice = Class_Notice::find(7939934); - $this->assertEquals('Tangomango n° 2<br />La gazette du pirate', $notice->getTitrePrincipal()); - } + public function homogenizeShouldUpdateNotice() { + $notice = Class_Notice::find(7939934); + $notice_integration = new notice_integration(); + $notice_integration->traiteHomogene($notice); + + Class_Notice::clearCache(); + $notice = Class_Notice::find(7939934); + $this->assertEquals('Tangomango n° 2<br />La gazette du pirate', $notice->getTitrePrincipal()); + } +} + + + + +class CarthameIntegrationPelleasMelissandeWithMultiple200DollarATest extends CarthameIntegrationTestCase { + public function setUp() { + parent::setUp(); + $this->loadRecordsFromFile("unimarc_pelleas"); + } + + + /** @test */ + public function alphaKeyShouldBePELLEASETMELISANDEMELODIESPELLEASETMELISANDEEXTRAIT__DEBUSSYC__EMI_1942_3() { + $this->assertEquals('PELLEASETMELISANDEMELODIESPELLEASETMELISANDEEXTRAIT--DEBUSSYC--EMI-1942-3', + Class_Notice::find(1)->getClefAlpha()); + } } diff --git a/cosmogramme/tests/php/classes/unimarc_pelleas.txt b/cosmogramme/tests/php/classes/unimarc_pelleas.txt new file mode 100644 index 0000000000000000000000000000000000000000..b775840e446507ae7535a0758e7338b4ee235924 --- /dev/null +++ b/cosmogramme/tests/php/classes/unimarc_pelleas.txt @@ -0,0 +1,3 @@ +01303cjm0 22003132 450 001000700000005001700007073001700024100004100041200031800082210001900400215001600419300005100435686001600486690001100502701005700513701003200570701003200602701003400634701003300668711004100701701003500742701002900777701005700806801002100863801002300884801002300907951001600930995004300946I1689720140212153723.0 a077776103822 a19970117d1942 u0frey0103 ba11aPellÂeas et MÂelisandeaMÂelodiesaPellÂeas et MÂelisande, extraitfcomposÂe par Claude DebussygIrÁene Joachim , sopranogJacques Jansen et Henri Etcheverry , barytongGermaine Cernay , mezzo-sopranogChoeurs Yvonne GouvernÂe , choeurgdirigÂe par Roger DesormiÁeregMary Garden , sopranogClaude Debussy , piano 3271cEMId1942 a3 cd.e3 cd adisc 1 : 57'31 +disc 2 : 69'42 +disc 3 : 68'21 3114860a3.3 3341a3 3124390aDebussybClaudecCompositeurf1862-19184230 316647aJoachimbIrÁene4590 316646aJansenbJacques4590 318310aEtcheverrybHenri4590 318311aCernaybGermaine459002318312aChoeurs Yvonne GouvernÂe4590 318314aDesormiÁerebRoger4300 318316aGardenbMary4590 3124390aDebussybClaudecCompositeurf1862-19184590 1bOrigine inconnue 2aFRbCCTCc20140212 3aFRbCCTCc20140820 aDKb ** c1 aCCTCf012771k335 DEBopqurjuyThann \ No newline at end of file diff --git a/library/Class/Hold/Pnb.php b/library/Class/Hold/Pnb.php index 5c5202fad6020a8c23c6179c064e2ba4b752c565..b567c188da0bc71a54d3c7bbed09e0dfcc4e842c 100644 --- a/library/Class/Hold/Pnb.php +++ b/library/Class/Hold/Pnb.php @@ -128,6 +128,8 @@ class Class_Hold_Pnb extends Storm_Model_Abstract { 'referenced_in'=>'user_id']], $_default_attribute_values = ['expiration_date' => null, 'user_id' => null, + 'record_origin_id' => 0, + 'hold_date' => null, 'subscriber_id' => '']; diff --git a/library/Class/InspectorGadget/Data.php b/library/Class/InspectorGadget/Data.php new file mode 100644 index 0000000000000000000000000000000000000000..1425dfa2832e7378e64831d0a2d001474122382d --- /dev/null +++ b/library/Class/InspectorGadget/Data.php @@ -0,0 +1,43 @@ +<?php +/** + * Copyright (c) 2012-2021, 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_InspectorGadget_Data { + protected + $_button_text, + $_dialog_content; + + + public function __construct($button_text, $dialog_content) { + $this->_button_text = $button_text; + $this->_dialog_content = $dialog_content; + } + + + public function getLabel() { + return $this->_button_text; + } + + + public function getContent() { + return $this->_dialog_content; + } +} diff --git a/library/Class/Loan/Pnb.php b/library/Class/Loan/Pnb.php index 2fb75b78eec174530a57999d295b5bcd1764a00e..e0cfe5fc4fe88379d3df0b1cfdf9657155466512 100644 --- a/library/Class/Loan/Pnb.php +++ b/library/Class/Loan/Pnb.php @@ -119,6 +119,7 @@ class Class_Loan_Pnb extends Storm_Model_Abstract { $_belongs_to = ['user' => ['model' => 'Class_Users']], $_default_attribute_values = ['expected_return_date' => '', 'loan_link' => '', + 'record_origin_id' => 0, 'options' => '']; diff --git a/library/Class/Newsletter.php b/library/Class/Newsletter.php index c0d5b46577217239c5b187c498dd4b3f1401af79..ddc01d765cacbcce04c409e3e58a178a717348fc 100644 --- a/library/Class/Newsletter.php +++ b/library/Class/Newsletter.php @@ -112,7 +112,8 @@ class Class_Newsletter extends Storm_Model_Abstract { 'id_catalogue' => '', 'id_panier' => '', 'articles_ids' => '', - 'articles_categories_ids' => '']; + 'articles_categories_ids' => '', + 'mail_subject' => '']; public function validate() { diff --git a/library/Class/Notice/Work.php b/library/Class/Notice/Work.php index 9212ec040e683ee705a4f0d6b5a66d3582ada2ef..9292a5beae12a009552493c89b01b43ed7318b74 100644 --- a/library/Class/Notice/Work.php +++ b/library/Class/Notice/Work.php @@ -27,6 +27,9 @@ class Class_Notice_Work { public static function loadWithFacets($key, $facets='') { + if ( ! $key) + return null; + if (!$record = Class_Notice::findFirstBy(['clef_oeuvre' => $key])) return null; diff --git a/library/Class/SessionActivityInscription.php b/library/Class/SessionActivityInscription.php index cb1157b4b4e80a9d0fc1278010364f57ad70f1a2..a4af03a79d83c7fd5dda2fd6ea9af35fb7ce1d49 100644 --- a/library/Class/SessionActivityInscription.php +++ b/library/Class/SessionActivityInscription.php @@ -83,7 +83,8 @@ class Class_SessionActivityInscription extends Storm_Model_Abstract { 'stagiaire_id' => null, 'notified_at' => null, 'queue' => false, - 'created_at' => null]; + 'created_at' => null, + 'session_activity_id' => 0]; public function validate() { @@ -323,7 +324,9 @@ class Class_SessionActivityInscription extends Storm_Model_Abstract { public function getIntervenants() { - return $this->_getSessionAttribute('intervenants'); + return ($intervenants = $this->_getSessionAttribute('intervenants')) + ? $intervenants + : []; } diff --git a/library/Class/User/BookmarkedSearch.php b/library/Class/User/BookmarkedSearch.php index 84f25e6729b288785140be30fae07cf05db3a00b..f7e1d3911027eb9945ac34f6d55f44b776df4bf5 100644 --- a/library/Class/User/BookmarkedSearch.php +++ b/library/Class/User/BookmarkedSearch.php @@ -138,7 +138,7 @@ class Class_User_BookmarkedSearch extends Storm_Model_Abstract { return $this->_search_result; if (!$criterias = $this->getUnserializedCriterias()) - return new Class_MoteurRecherche_Result; + return new Class_MoteurRecherche_Result(null, null); return $this->_search_result = Class_MoteurRecherche::getInstance() diff --git a/library/Class/User/CardsOperationDecorator.php b/library/Class/User/CardsOperationDecorator.php index b4acf4a0d8609d80680164e71e8e8568fadddb03..60a697011122df0defdc48f7f244cffe06f16725 100644 --- a/library/Class/User/CardsOperationDecorator.php +++ b/library/Class/User/CardsOperationDecorator.php @@ -53,6 +53,11 @@ class Class_User_CardsOperationDecorator { } + public function getOperation() { + return $this->_operation; + } + + public function getOperationId() { return $this->_operation->getId(); } diff --git a/library/Class/WebService/SIGB/Exemplaire.php b/library/Class/WebService/SIGB/Exemplaire.php index be43b6529babad588c6d6285b7deb52ef9ad907f..812900a9abc249f82bf82dde9094a90a70feef61 100644 --- a/library/Class/WebService/SIGB/Exemplaire.php +++ b/library/Class/WebService/SIGB/Exemplaire.php @@ -22,6 +22,30 @@ class Class_WebService_SIGB_Exemplaire { use Trait_Translator; + + public function __sleep() { + return ['id', + 'nb_resas', + 'edition', + 'titre', + 'reservable', + 'no_notice', + 'code_barre', + 'date_retour', + 'visible_opac', + 'code_annexe', + '_disponibiliteLabel', + '_isEnPret', + '_cote', + '_emplacement', + '_issue_date', + '_url_for_current_user', + 'consultation', + 'onhold', + 'renewals']; + } + + protected $id, $notice, /** @var Class_WebService_SIGB_Notice */ diff --git a/library/Trait/InspectorGadgetAware.php b/library/Trait/InspectorGadgetAware.php index accec79e68e34ae583a4e506027eb229a014a73a..e2b2217866a978e9a15a77c749ea363c411419da 100644 --- a/library/Trait/InspectorGadgetAware.php +++ b/library/Trait/InspectorGadgetAware.php @@ -49,6 +49,15 @@ trait Trait_InspectorGadgetAware { ? static::$_inspector : static::$_inspector = new NullInspector; } + + + protected function _renderInspectorGadgetButton($callback) { + if ( ! $this->_getInspector()->isEnabled()) + return ''; + + $this->_getInspector()->shouldRender(); + return $this->_getInspector()->renderButton($callback()); + } } @@ -57,4 +66,9 @@ trait Trait_InspectorGadgetAware { class NullInspector { public function log() {} public function logError($url, $message) {} + + + public function isEnabled() { + return false; + } } \ No newline at end of file diff --git a/library/ZendAfi/Acl/AdminControllerGroup.php b/library/ZendAfi/Acl/AdminControllerGroup.php index 05eff8f0132b4e4c7a67fdcf785a203c09af6976..844e69e4e4ef60cfbf2464ad14d6026afab81223 100644 --- a/library/ZendAfi/Acl/AdminControllerGroup.php +++ b/library/ZendAfi/Acl/AdminControllerGroup.php @@ -48,6 +48,8 @@ class ZendAfi_Acl_AdminControllerGroup { Class_UserGroup::RIGHT_REGISTER_ACTIVITY], 'session-activity/export_inscriptions' => [Class_UserGroup::RIGHT_DIRIGER_ACTIVITY, Class_UserGroup::RIGHT_REGISTER_ACTIVITY], + 'session-activity-inscription' => [Class_UserGroup::RIGHT_DIRIGER_ACTIVITY, + Class_UserGroup::RIGHT_REGISTER_ACTIVITY], 'catalogue' => [Class_UserGroup::RIGHT_USER_DOMAINES_SUPPRESSION_LIMIT, Class_UserGroup::RIGHT_USER_DOMAINES_TOTAL_ACCESS], diff --git a/library/ZendAfi/Controller/Plugin/InspectorGadget.php b/library/ZendAfi/Controller/Plugin/InspectorGadget.php index 6112e5ed284b959b18e7f49d7e8a3d42663710c7..2923231b246858fd3b771c32d9d062ab753c9dcf 100644 --- a/library/ZendAfi/Controller/Plugin/InspectorGadget.php +++ b/library/ZendAfi/Controller/Plugin/InspectorGadget.php @@ -121,7 +121,7 @@ class ZendAfi_Controller_Plugin_InspectorGadget extends Zend_Controller_Plugin_A } - protected function shouldRender() { + public function shouldRender() { $renderer = Zend_Controller_Action_HelperBroker::hasHelper('ViewRenderer') ? Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer') : null; @@ -265,4 +265,11 @@ create: function(event, ui) { if (ui.panel.hasClass(\'ig-accordion\')) ui.panel. $this->_buttons[]= $instance; return $this; } + + + public function renderButton($instance) { + return $this->renderDialog($instance->getLabel(), + ['title' => $instance->getLabel(), + 'content' => $instance->getContent()]); + } } diff --git a/library/ZendAfi/Mail.php b/library/ZendAfi/Mail.php index 7ec8adf38603573d2efd0f458e0d74bf0da60062..a9df3e838012155efc4c9f7c2b114a8b98d9a607 100644 --- a/library/ZendAfi/Mail.php +++ b/library/ZendAfi/Mail.php @@ -20,11 +20,23 @@ */ class ZendAfi_Mail extends Zend_Mail { + use Trait_StormFileSystem; + public function __construct($charset = 'utf-8') { parent::__construct($charset); } + public function attachFile($path, $type, $name) { + $content = $this->getFileSystem() + ->fileGetContents($path); + + $attachment = $this->createAttachment($content, $type); + $attachment->filename = $name; + return $this; + } + + public function addTo($email, $name='') { $validator = $this->_getValidator(); $mails = array_filter( diff --git a/library/templates/Intonation/Assets/css/intonation.css b/library/templates/Intonation/Assets/css/intonation.css index b7ba818f681d09f9511db7eeaf4092a214021492..4e994b7da9a17d58ea138d703a47d388d54cb54c 100644 --- a/library/templates/Intonation/Assets/css/intonation.css +++ b/library/templates/Intonation/Assets/css/intonation.css @@ -358,6 +358,11 @@ pre { margin-top: 0.75rem; } +.record_items [id*='resources'] .list-group { + max-height: unset; + overflow: unset; +} + [id*='resources'] .list-group-item { padding-top: 0; } diff --git a/library/templates/Intonation/Library/AjaxPaginatedListHelper.php b/library/templates/Intonation/Library/AjaxPaginatedListHelper.php index 413af52f9c1417d3e45732820b4efe80c3febad5..579ab93da04b68ec7b59df2a9461910aa87f593b 100644 --- a/library/templates/Intonation/Library/AjaxPaginatedListHelper.php +++ b/library/templates/Intonation/Library/AjaxPaginatedListHelper.php @@ -25,6 +25,7 @@ class Intonation_Library_AjaxPaginatedListHelper { protected $_id, $_collection, + $_collection_ids, $_rendering = 'cardifyHorizontal', $_search, $_current_page = 1, @@ -33,7 +34,9 @@ class Intonation_Library_AjaxPaginatedListHelper { $_view, $_carousel_context, $_order, - $_new_order; + $_new_order, + $_has_been_sliced = false, + $_count_search_result; public static function find($id) { @@ -49,7 +52,56 @@ class Intonation_Library_AjaxPaginatedListHelper { ->setRendering($cache->get('rendering')) ->setCarouselContext($cache->get('carousel_context')) ->setOrder($cache->get('order')) - ->setId($id); + ->setId($id) + ->setHasBeenSliced($cache->get('has_been_slice')); + } + + + public function getId() { + if ($this->_id) + return $this->_id; + + $this->_id = md5(json_encode($this->getCollectionIds())); + $this->_cache(); + return $this->_id; + } + + + protected function _cache() { + $cache_success = + ((new Storm_Cache()) + ->save($this->getDataToCache(), + $this->_id)); + + if ($cache_success) + return true; + + if ( 101 > count($this->_collection)) + return true; + + return $this + ->_sliceCollection() + ->_cache(); + } + + + protected function _sliceCollection() { + $this->_has_been_sliced = true; + $total = count($this->_collection); + $collection_as_array = $this->_collection->getArrayCopy(); + $collection_as_array = array_slice($collection_as_array, 0, ($total - 100)); + $this->_collection = new Storm_Collection($collection_as_array); + return $this; + } + + + public function getDataToCache() { + return ['id' => $this->_id, + 'has_been_slice' => $this->_has_been_sliced, + 'collection' => $this->getCollection(), + 'rendering' => $this->getRendering(), + 'carousel_context' => $this->getCarouselContext(), + 'order' => $this->getOrder()]; } @@ -64,6 +116,19 @@ class Intonation_Library_AjaxPaginatedListHelper { } + public function getCollectionIds() { + if ( $this->_collection_ids) + return $this->_collection_ids; + + return $this->_collection_ids = + $this->getCollection() + ->select(function($wrapper) + { + return $wrapper->getId(); + }); + } + + public function setRendering($rendering) { $this->_rendering = $rendering; return $this; @@ -112,16 +177,6 @@ class Intonation_Library_AjaxPaginatedListHelper { } - public function getId() { - if ($this->_id) - return $this->_id; - - $this->_id = md5(json_encode($this->getCollection())); - $this->_cache(); - return $this->_id; - } - - public function setId($id) { $this->_id = $id; return $this; @@ -136,30 +191,53 @@ class Intonation_Library_AjaxPaginatedListHelper { $sub = array_slice($collection->getArrayCopy(), (($page - 1) * $this->_page_size), $this->_page_size); - return $this->_page = new Storm_Collection($sub); + return $this->_page = ((new Storm_Collection($sub)) + ->eachDo(function($wrapper) + { + if ($wrapper->getModel()) + return; + + $this->_wakeUp($wrapper); + })); }; if ( ! $search = $this->getSearchTerm()) return $slice($this->getCollection()); $result = $this->_search($search, $this->getCollection()); + $this->_count_search_result = count($result); + $this->_cache(); return $slice($result); } protected function _search($term, $collection) { - $term = strtolower($term); - return $collection->select(function($element) use ($term) + $terms = strtolower($term); + $terms = explode(' ', $terms); + return $collection->select(function($wrapper) use ($terms) { - $element - ->setView($this->_view) - ->setModel($element->getModel()) - ->inJsSearch(); - return false !== strpos(strtolower($element->getContentForJSSearch()), $term); + if ( ! $this->_wakeUp($wrapper->inJsSearch())) + return false; + + foreach($terms as $term) + if (false === strpos(strtolower($wrapper->getContentForJSSearch()), $term)) + return false; + + return true; }); } + protected function _wakeUp($wrapper) { + if (!$classname = $wrapper->getClassname()) + return null; + + return $wrapper + ->setView($this->_view) + ->setModel(call_user_func([$classname, 'find'], $wrapper->getId())); + } + + public function getPageSize() { return $this->_page_size; } @@ -172,11 +250,12 @@ class Intonation_Library_AjaxPaginatedListHelper { public function getSize() { - return $this->getSearchTerm() ? $this->getPage($this->getCurrentPage())->count() : $this->getCollection()->count(); + return $this->getSearchTerm() + ? $this->_count_search_result + : $this->getCollection()->count(); } - public function setCarouselContext($context) { $this->_carousel_context = $context; return $this; @@ -220,20 +299,20 @@ class Intonation_Library_AjaxPaginatedListHelper { } - protected function _cache() { - return (new Storm_Cache()) - ->save(['id' => $this->_id, - 'collection' => $this->getCollection(), - 'rendering' => $this->getRendering(), - 'carousel_context' => $this->getCarouselContext(), - 'order' => $this->getOrder()], - $this->_id); - } - - protected function _sortCollection($order) { $this->setOrder($order); $this->setCollection($this->getCarouselContext()->newCollectionWith($order)); return $this; } + + + public function hasBeenSliced() { + return $this->_has_been_sliced; + } + + + public function setHasBeenSliced($bool) { + $this->_has_been_sliced = $bool; + return $this; + } } diff --git a/library/templates/Intonation/Library/Record.php b/library/templates/Intonation/Library/Record.php index ae9f62d74f3ae364f28606fd2295312814615368..ae3132e79d8880aacb19fab3e9338e121f108edf 100644 --- a/library/templates/Intonation/Library/Record.php +++ b/library/templates/Intonation/Library/Record.php @@ -37,14 +37,6 @@ class Intonation_Library_Record { public function __construct($record) { $this->_record = $record; $this->_record_id = $record->getId(); - - if (!$this->_record->isFirstItemTypeSerialArticle()) - return; - - if ($item = $this->_record->getFirstExemplaire()) { - $this->_record = $item->getPMBSerialRecord(); - $this->_record_id = $this->_record->getId(); - } } diff --git a/library/templates/Intonation/Library/Record/Items.php b/library/templates/Intonation/Library/Record/Items.php index ba8de010855fe79d717d1070de49b4771f773cfd..bc88f7734c046013c2a8d76cecda6e29958406a7 100644 --- a/library/templates/Intonation/Library/Record/Items.php +++ b/library/templates/Intonation/Library/Record/Items.php @@ -47,6 +47,9 @@ class Intonation_Library_Record_Items { protected function _getItemsFromSIGB($items) { + if ( ! $this->_shouldCallSIGB($items)) + return $items; + foreach($items as $item) $item ->updateAvailabilityAndLocationFromSIGBAndSaveIfNeeded(); @@ -55,6 +58,19 @@ class Intonation_Library_Record_Items { } + protected function _shouldCallSIGB($items) { + if ( ! $items) + return false; + + $first_item = reset($items); + + if ( ! $first_item->isTypeSerialArticle()) + return true; + + return Intonation_View_RenderTruncateList::$ajax_size >= count($items); + } + + protected function _findItems() { if (empty($this->_records)) return []; @@ -81,5 +97,4 @@ class Intonation_Library_Record_Items { return (new Class_Profil_ItemsFilter()) ->select(Class_Profil::getCurrentProfil(), $items->getArrayCopy()); } - } diff --git a/library/templates/Intonation/Library/View/Wrapper/Abstract.php b/library/templates/Intonation/Library/View/Wrapper/Abstract.php index 6c384ee1e035177561982ea1faf912f2647c3816..e071b22cbe67081a2e1876970db7b87a1663939a 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Abstract.php +++ b/library/templates/Intonation/Library/View/Wrapper/Abstract.php @@ -27,6 +27,9 @@ abstract class Intonation_Library_View_Wrapper_Abstract { protected $_view, $_model, + $_model_id, + $_search_content, + $_model_classname, $_widget_context, $_widget_context_params = [], $_rich_content, @@ -34,9 +37,15 @@ abstract class Intonation_Library_View_Wrapper_Abstract { public function __sleep() { - return ['_model', - '_widget_context_params', - '_in_js_search']; + if ($this->_model) { + $this->_model_id = $this->getModelId(); + $this->_model_classname = $this->getModelClassname(); + } + + return ['_model_id', + '_model_classname', + '_search_content', + '_widget_context_params']; } @@ -49,6 +58,16 @@ abstract class Intonation_Library_View_Wrapper_Abstract { } + public function getId() { + return $this->_model_id; + } + + + public function getClassname() { + return $this->_model_classname; + } + + public function setView($view) { $this->_view = $view; return $this; @@ -66,6 +85,11 @@ abstract class Intonation_Library_View_Wrapper_Abstract { } + protected function getModelClassname() { + return get_class($this->_model); + } + + public function getModel() { return $this->_model; } @@ -125,7 +149,10 @@ abstract class Intonation_Library_View_Wrapper_Abstract { public function getContentForJSSearch() { - return $this->_in_js_search + if ($this->_search_content) + return $this->_search_content; + + return $this->_search_content = $this->_in_js_search ? $this->_view->dNone(implode(' ', [$this->getMainTitle(), $this->getSecondaryTitle(), $this->getDescription(), diff --git a/library/templates/Intonation/Library/View/Wrapper/ActivitySession.php b/library/templates/Intonation/Library/View/Wrapper/ActivitySession.php index 9b779be5e818c8a20b2b0865bdad59c9e15a4d6b..d933caa5810d919b49118a68b7ceb722af3fb64d 100644 --- a/library/templates/Intonation/Library/View/Wrapper/ActivitySession.php +++ b/library/templates/Intonation/Library/View/Wrapper/ActivitySession.php @@ -186,7 +186,10 @@ class Intonation_Library_View_Wrapper_ActivitySession if ($media = $this->_mediaInSession($callback)) return $media; - If ( ! $description = $this->_model->getActivity()->getDescription()) + If ( ! $activity = $this->_model->getActivity()) + return ''; + + If ( ! $description = $activity->getDescription()) return ''; $article = Class_Article::newInstance(['contenu' => $description]); diff --git a/library/templates/Intonation/Library/View/Wrapper/Author.php b/library/templates/Intonation/Library/View/Wrapper/Author.php index 7ff32cc14b78d40cf2d57446b8d5eda685c6e041..77d2b45e0096cfd098c8e7653e136c3c64a33c24 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Author.php +++ b/library/templates/Intonation/Library/View/Wrapper/Author.php @@ -116,7 +116,7 @@ class Intonation_Library_View_Wrapper_Author extends Intonation_Library_View_Wra $description = new Class_CodifAuteur_Description($this->_model); if (!$records = $description->getRecords()) - return [$actions]; + return $actions; $record = array_shift($records); diff --git a/library/templates/Intonation/Library/View/Wrapper/DriveCheckoutPlan.php b/library/templates/Intonation/Library/View/Wrapper/DriveCheckoutPlan.php index 86a2453bc777de78063da5885473677f729fd2cd..63034c4ee33e25119eba6939989a0dcd1defe1ac 100644 --- a/library/templates/Intonation/Library/View/Wrapper/DriveCheckoutPlan.php +++ b/library/templates/Intonation/Library/View/Wrapper/DriveCheckoutPlan.php @@ -28,6 +28,16 @@ class Intonation_Library_View_Wrapper_DriveCheckoutPlan } + public function getModelClassname() { + return get_class($this); + } + + + public static function find($id) { + return new Class_DriveCheckout_Plan([], null); + } + + public function getSecondaryTitle() { return ''; } diff --git a/library/templates/Intonation/Library/View/Wrapper/Hold.php b/library/templates/Intonation/Library/View/Wrapper/Hold.php index 307f938b402143bc7d4a2c8711620f924a41ae03..3475530756680d339b29813f3608b64d0e22d7c8 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Hold.php +++ b/library/templates/Intonation/Library/View/Wrapper/Hold.php @@ -23,12 +23,21 @@ class Intonation_Library_View_Wrapper_Hold extends Intonation_Library_View_Wrapper_Abstract { protected + $_operation, $_wrapper_cache, $_ready, $_library_label, $_end_availability; + public function __sleep() { + $this->_operation = $this->_model->getOperation(); + $sleep_params = parent::__sleep(); + $sleep_params [] = '_operation'; + return $sleep_params; + } + + public function getMainTitle() { $hold_by = $this->_('Réservé par %s %s', $this->_tag('span', @@ -257,4 +266,23 @@ class Intonation_Library_View_Wrapper_Hold extends Intonation_Library_View_Wrapp return $this->_wrapper_cache = Class_Template::current()->newWrapper($this->_model->getNoticeOPAC(), $this->_view); } + + + public function getModelId() { + $id = ($user = $this->_model->getUser()) + ? $user->getId() + : 0; + + return [$this->_operation, $id]; + } + + + public function getModelClassname() { + return get_class($this); + } + + + public static function find($id) { + return new Class_User_CardsOperationDecorator($id[0], Class_Users::find($id[1])); + } } \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/Item.php b/library/templates/Intonation/Library/View/Wrapper/Item.php index fbf55700db2d726cf3154a12246088c6aae00094..ce61a7fb78e79096206673467308dc065e90572a 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Item.php +++ b/library/templates/Intonation/Library/View/Wrapper/Item.php @@ -35,7 +35,7 @@ class Intonation_Library_View_Wrapper_Item extends Intonation_Library_View_Wrapp if (!$this->_isCheckedInSettings('dispo')) return ''; - $dispo = $this->_model->getDisponibilite(); + $dispo = $this->_getAvailability(); return $this->_view->tag('span', $this->getIco(($this->_model->isDisponible(true) @@ -83,7 +83,7 @@ class Intonation_Library_View_Wrapper_Item extends Intonation_Library_View_Wrapp $secondary_title = $this->getSecondaryTitle(); $striped_secondary_title = strtolower(strip_tags($secondary_title)); - $title = ($hold_link = $this->_model->getHoldLink()) + $title = ($hold_link = $this->_getHoldLink()) ? $this->_('Réserver un exemplaire du document: %s, l\'exemplaire est %s', $this->_model->getTitrePrincipal(), $striped_secondary_title) @@ -221,7 +221,7 @@ class Intonation_Library_View_Wrapper_Item extends Intonation_Library_View_Wrapp protected function _getReservationsBadge() { - if (!$this->_model->getNbResas()) + if ( ! $this->_getCurrentHoldsNumber()) return null; return (new Intonation_Library_Badge) @@ -275,4 +275,19 @@ class Intonation_Library_View_Wrapper_Item extends Intonation_Library_View_Wrapp return $this->_profile_settings->isSettingEnabled($key); } + + + protected function _getAvailability() { + return $this->_model->getDisponibilite(); + } + + + protected function _getHoldLink() { + return $this->_model->getHoldLink(); + } + + + protected function _getCurrentHoldsNumber() { + return $this->_model->getNbResas(); + } } diff --git a/library/templates/Intonation/Library/View/Wrapper/ItemWithoutSIGB.php b/library/templates/Intonation/Library/View/Wrapper/ItemWithoutSIGB.php new file mode 100644 index 0000000000000000000000000000000000000000..00c070daa8372943ebf9b2f786ee443a685dc3db --- /dev/null +++ b/library/templates/Intonation/Library/View/Wrapper/ItemWithoutSIGB.php @@ -0,0 +1,37 @@ +<?php +/** +* Copyright (c) 2012-2018, 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 Intonation_Library_View_Wrapper_ItemWithoutSIGB extends Intonation_Library_View_Wrapper_Item { + protected function _getAvailability() { + return; + } + + + protected function _getHoldLink() { + return ''; + } + + + protected function _getCurrentHoldsNumber() { + return 0; + } +} diff --git a/library/templates/Intonation/Library/View/Wrapper/Library/RichContent/Navigation.php b/library/templates/Intonation/Library/View/Wrapper/Library/RichContent/Navigation.php index 60b206a2882a762fc5d759fe5503ceef82032b07..a9cb6aacb639db32dd498d739d4983a31ddf8121 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Library/RichContent/Navigation.php +++ b/library/templates/Intonation/Library/View/Wrapper/Library/RichContent/Navigation.php @@ -65,7 +65,7 @@ class Intonation_Library_View_Wrapper_Library_RichContent_Navigation { if (!$prev = prev($list)) return; - return $this->_view->tagAnchor(['id' => $prev->getId()], + return $this->_view->tagAnchor($prev->getUrl(), Class_Template::current()->getIco($this->_view, 'previous', 'utils', ['class' => 'ico_xl']), ['title' => $this->_('Bibliothèque précédente : %s', $prev->getLibelle()), @@ -82,7 +82,7 @@ class Intonation_Library_View_Wrapper_Library_RichContent_Navigation { if (!$next = next($list)) return; - return $this->_view->tagAnchor(['id' => $next->getId()], + return $this->_view->tagAnchor($next->getUrl(), Class_Template::current()->getIco($this->_view, 'next', 'utils', ['class' => 'ico_xl']), ['title' => $this->_('Bibliothèque suivante : %s', $next->getLibelle()), diff --git a/library/templates/Intonation/Library/View/Wrapper/Loan.php b/library/templates/Intonation/Library/View/Wrapper/Loan.php index cb535ffb3dd328046f769539a679a3d08cee44e3..6d3cba5632920ddb5812b8c312beb30f69db186a 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Loan.php +++ b/library/templates/Intonation/Library/View/Wrapper/Loan.php @@ -22,7 +22,17 @@ class Intonation_Library_View_Wrapper_Loan extends Intonation_Library_View_Wrapper_Abstract { - protected $_record; + protected + $_record, + $_operation; + + + public function __sleep() { + $this->_operation = $this->_model->getOperation(); + $sleep_params = parent::__sleep(); + $sleep_params [] = '_operation'; + return $sleep_params; + } public function getMainTitle() { @@ -245,4 +255,23 @@ class Intonation_Library_View_Wrapper_Loan extends Intonation_Library_View_Wrapp public function getOsmData() { return null; } + + + public function getModelId() { + $id = ($user = $this->_model->getUser()) + ? $user->getId() + : 0; + + return [$this->_operation, $id]; + } + + + public function getModelClassname() { + return get_class($this); + } + + + public static function find($id) { + return new Class_User_CardsOperationDecorator($id[0], Class_Users::find($id[1])); + } } diff --git a/library/templates/Intonation/Library/View/Wrapper/MenuEntry.php b/library/templates/Intonation/Library/View/Wrapper/MenuEntry.php index 90d57f9b8755ec1713751de31b7746c13e00d092..50432761b90e9025179b3113c3353980d6a7ff4e 100644 --- a/library/templates/Intonation/Library/View/Wrapper/MenuEntry.php +++ b/library/templates/Intonation/Library/View/Wrapper/MenuEntry.php @@ -126,4 +126,25 @@ class Intonation_Library_View_Wrapper_MenuEntry extends Intonation_Library_View_ public function getOsmData() { return null; } + + + public function getModelId() { + return [$this->_model->getId(), + $this->_model->getParent(), + $this->_model->getProfileId()]; + } + + + public function getModelClassname() { + return get_class($this); + } + + + public static function find($id) { + return (new Class_Systeme_Widget_Menu) + ->setId($id[0]) + ->setParent($id[1]) + ->setProfileId($id[2]) + ->load(); + } } diff --git a/library/templates/Intonation/Library/View/Wrapper/PNBHold.php b/library/templates/Intonation/Library/View/Wrapper/PNBHold.php index 0d1c2c41244ae3710b0c494cd3f7e79383b3781e..8bf27a32bd1fb167047a8953f547713ca15349a0 100644 --- a/library/templates/Intonation/Library/View/Wrapper/PNBHold.php +++ b/library/templates/Intonation/Library/View/Wrapper/PNBHold.php @@ -22,6 +22,14 @@ class Intonation_Library_View_Wrapper_PNBHold extends Intonation_Library_View_Wrapper_Hold { + + public function __sleep() { + $params = parent::__sleep(); + $this->_operation = $this->_model->getOperationId(); + return $params; + } + + protected function _addParagraphe($html) { return $html; } @@ -68,4 +76,20 @@ class Intonation_Library_View_Wrapper_PNBHold extends Intonation_Library_View_Wr private function _getModelId() { return $this->_model->getOperationId(); } + + + public function getModelId() { + $id = ($user = $this->_model->getUser()) + ? $user->getId() + : 0; + + return [$this->_model->getOperationId(), $id]; + } + + + public static function find($id) { + return new Class_User_CardsOperationDecorator(Class_Hold_Pnb::findFirstBy(['id' => $id[0], + 'user_id' => $id[1]]), + Class_Users::find($id[1])); + } } \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/PNBLoan.php b/library/templates/Intonation/Library/View/Wrapper/PNBLoan.php index ceb9107c46752f59324342127dc791595d9e8945..08ce8567a832775feb0abf1322809eb85de8d0be 100644 --- a/library/templates/Intonation/Library/View/Wrapper/PNBLoan.php +++ b/library/templates/Intonation/Library/View/Wrapper/PNBLoan.php @@ -23,6 +23,13 @@ class Intonation_Library_View_Wrapper_PNBLoan extends Intonation_Library_View_Wrapper_Loan { + public function __sleep() { + $params = parent::__sleep(); + $this->_operation = $this->_model->getOperationId(); + return $params; + } + + public function getSecondaryTitle() { return ($record = $this->_getRecord()) ? $record->getSecondaryTitle() @@ -120,4 +127,21 @@ class Intonation_Library_View_Wrapper_PNBLoan extends Intonation_Library_View_Wr '%s'])) : ''; } + + + public function getModelId() { + $id = ($user = $this->_model->getUser()) + ? $user->getId() + : 0; + + return [$this->_model->getOperationId(), $id]; + } + + + + public static function find($id) { + return new Class_User_CardsOperationDecorator(Class_Loan_Pnb::findFirstBy(['id' => $id[0], + 'user_id' => $id[1]]), + Class_Users::find($id[1])); + } } diff --git a/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Items.php b/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Items.php index 6aeb155f42d9562ce366fa86bd9a91a76181a072..a94d83b7b7711f551ae937ac0797ef3fb1a1df1b 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Items.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record/RichContent/Items.php @@ -31,13 +31,10 @@ class Intonation_Library_View_Wrapper_Record_RichContent_Items extends Intonatio public function getContent() { - if ($this->_content) - return $this->_content; - - return $this->_content = $this->_view->renderAjax('noticeajax', - 'resources', - ['id' => $this->_model->getId()], - $this->_getJsCallback()); + return $this->_view->renderAjax('noticeajax', + 'resources', + ['id' => $this->_model->getId()], + $this->_getJsCallback()); } diff --git a/library/templates/Intonation/Library/View/Wrapper/RecordInSelection.php b/library/templates/Intonation/Library/View/Wrapper/RecordInSelection.php index 866415b3719dfa14827d8fb07130b8d0927bb9f0..db96d36d614c312cc763910e0fc496511b5727d2 100644 --- a/library/templates/Intonation/Library/View/Wrapper/RecordInSelection.php +++ b/library/templates/Intonation/Library/View/Wrapper/RecordInSelection.php @@ -31,6 +31,9 @@ class Intonation_Library_View_Wrapper_RecordInSelection extends Intonation_Libra } public function getActions() { + if ( ! $this->_selection) + return []; + return [(new Intonation_Library_Link) ->setUrl($this->_view->url(['controller' => 'abonne', 'action' => 'supprimer-de-la-selection', diff --git a/library/templates/Intonation/Library/View/Wrapper/RecordToSelect.php b/library/templates/Intonation/Library/View/Wrapper/RecordToSelect.php index c332c790419af0bb8003a1aebcd5daedfeaec3d6..b796ae030f1b5b78f59afd816615f803c73f2d38 100644 --- a/library/templates/Intonation/Library/View/Wrapper/RecordToSelect.php +++ b/library/templates/Intonation/Library/View/Wrapper/RecordToSelect.php @@ -42,6 +42,9 @@ class Intonation_Library_View_Wrapper_RecordToSelect extends Intonation_Library_ public function getMainLink() { + if ( ! $this->_selection) + return null; + $url = $this->_view->url(['controller' => 'abonne', 'action' => 'ajouter-le-document-a-la-selection', 'record_id' => $this->_model->getId(), diff --git a/library/templates/Intonation/Library/View/Wrapper/Review.php b/library/templates/Intonation/Library/View/Wrapper/Review.php index 2f9aec86a290b45c2d1b0687931fc36a950f554f..59899016e754c03e61fbee074350ad631ea9012b 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Review.php +++ b/library/templates/Intonation/Library/View/Wrapper/Review.php @@ -220,6 +220,9 @@ class Intonation_Library_View_Wrapper_Review extends Intonation_Library_View_Wra protected function _allowHTMLInDescription() { + if ( ! $this->_widget_context) + return true; + return Intonation_Library_Widget_Carousel_NullContext::class == get_class($this->_widget_context) ? true : parent::_allowHTMLInDescription(); diff --git a/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php b/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php index 7699cae9aab1eab38b4e2b00f00c72affb37ab25..3c086dba837cfa16de959ad2f8605fb340d03a29 100644 --- a/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php +++ b/library/templates/Intonation/Library/View/Wrapper/ReviewsByRecord.php @@ -25,16 +25,17 @@ class Intonation_Library_View_Wrapper_ReviewsByRecord extends Intonation_Library protected $_record, $_reviews = []; + public function setModel($model) { if ( ! $model) return parent::setModel($model); - $this->_record = (new Intonation_Library_View_Wrapper_Record()) + $this->_record = (new Intonation_Library_View_Wrapper_Record) ->setView($this->_view) ->setModel($model->getRecord()); foreach ($model->getReviews() as $review) - $this->_reviews [] = (new Intonation_Library_View_Wrapper_ReviewInRecord()) + $this->_reviews [] = (new Intonation_Library_View_Wrapper_ReviewInRecord) ->setView($this->_view) ->setModel($review); @@ -151,4 +152,35 @@ class Intonation_Library_View_Wrapper_ReviewsByRecord extends Intonation_Library public function getOsmData() { return null; } + + + public function getModelId() { + $ids = []; + + if ($this->_record) + $ids = [$this->_record->getModelId()]; + + foreach ( $this->_reviews as $review) + $ids [][] = $review->getModelId(); + + return $ids; + } + + + public function getModelClassname() { + return get_class($this); + } + + + public static function find($ids) { + $record_data = array_slice($ids, 0, 1, true); + $record = Class_Notice::find(array_shift($record_data)); + + $reviews_data = array_slice($ids, 1, 2, true); + $reviews = Class_AvisNotice::findAllBy(['id' => array_shift($reviews_data)]); + + return (new Class_ReviewsByRecord) + ->setRecord($record) + ->setReviews($reviews); + } } \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/RssItem.php b/library/templates/Intonation/Library/View/Wrapper/RssItem.php index ebcc3b55d2be57c1fbcc6f9c165f61ab66a7ff2f..282256070e8ca659e13d886a3c4d3f28644f71b0 100644 --- a/library/templates/Intonation/Library/View/Wrapper/RssItem.php +++ b/library/templates/Intonation/Library/View/Wrapper/RssItem.php @@ -38,7 +38,8 @@ class Intonation_Library_View_Wrapper_RssItem extends Intonation_Library_View_Wr $this->_description = $this->getDescription(); return array_merge(parent::__sleep(), - ['_title', + ['_model', + '_title', '_link', '_picture', '_description', @@ -121,6 +122,9 @@ class Intonation_Library_View_Wrapper_RssItem extends Intonation_Library_View_Wr public function getBadges() { + if ( ! $this->_view) + return ''; + $badges = [(new Intonation_Library_Badge) ->setTag('span') ->setClass('badge-info') diff --git a/library/templates/Intonation/Library/View/Wrapper/SearchHistory.php b/library/templates/Intonation/Library/View/Wrapper/SearchHistory.php index 06b20c5bb34744587371ae5c5494c5f57a789e61..d8772c819207a2938f349e04940edb91df06ef6e 100644 --- a/library/templates/Intonation/Library/View/Wrapper/SearchHistory.php +++ b/library/templates/Intonation/Library/View/Wrapper/SearchHistory.php @@ -35,7 +35,7 @@ class Intonation_Library_View_Wrapper_SearchHistory extends Intonation_Library_V public function getBadges() { if (!$criterias = $this->_model->getUnserializedCriterias()) - return []; + return ''; $badges = [((new Intonation_Library_Badge) ->setTag('span') diff --git a/library/templates/Intonation/Library/View/Wrapper/Selection.php b/library/templates/Intonation/Library/View/Wrapper/Selection.php index d427dc6c75fc828b11cf65df5d92d96e03c42e9d..a35b3a041bc6b15512ad5fde4bcf1449acf654bf 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Selection.php +++ b/library/templates/Intonation/Library/View/Wrapper/Selection.php @@ -22,6 +22,9 @@ class Intonation_Library_View_Wrapper_Selection extends Intonation_Library_View_Wrapper_Abstract { + use Trait_InspectorGadgetAware; + + public function getMainTitle() { return $this->_model->getLibelle(); } @@ -54,10 +57,24 @@ class Intonation_Library_View_Wrapper_Selection extends Intonation_Library_View_ $records_title [] = $record->getTitrePrincipal(' '); return $this->getBadges() + . BR + . $this->_('Liste des documents : %s', $this->_view->truncate(implode(', ', $records_title), - ['class' => 'model_description_' . get_class($this->_model)])); + ['class' => 'model_description_' . get_class($this->_model)])) + + . $this->_renderInspectorGadgetButton(function() { return $this->_asInspecor();}); + } + + + protected function _asInspecor() { + $notices = BR . implode(BR, explode(';', $this->_model->getNotices())); + + $html = + $this->_view->tagNotice($this->_('Clés des documents dans la colonne "notices" : %s ', $notices)); + return + new Class_InspectorGadget_Data($this->_('Informations'), $html); } diff --git a/library/templates/Intonation/Library/View/Wrapper/Suggestion.php b/library/templates/Intonation/Library/View/Wrapper/Suggestion.php index 3da043e4dba69a19f7aa04e52692262b6aa7314a..a9b7c57c16a130db149486425190321db3714f49 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Suggestion.php +++ b/library/templates/Intonation/Library/View/Wrapper/Suggestion.php @@ -22,6 +22,16 @@ class Intonation_Library_View_Wrapper_Suggestion extends Intonation_Library_View_Wrapper_Abstract { + protected $_operation; + + public function __sleep() { + $this->_operation = $this->_model->getOperationId(); + $sleep_params = parent::__sleep(); + $sleep_params [] = '_operation'; + return $sleep_params; + } + + public function getMainTitle() { return $this->_('%s suggéré par %s %s', $this->_model->getTitre(), @@ -184,4 +194,25 @@ class Intonation_Library_View_Wrapper_Suggestion extends Intonation_Library_View public function getOsmData() { return null; } + + + public function getModelClassname() { + return get_class($this); + } + + + public function getModelId() { + $id = ($user = $this->_model->getUser()) + ? $user->getId() + : 0; + + return [$this->_model->getOperationId(), $id]; + } + + + public static function find($id) { + return new Class_User_CardsOperationDecorator(Class_SuggestionAchat::findFirstBy(['id' => $id[0], + 'user_id' => $id[1]]), + Class_Users::find($id[1])); + } } \ No newline at end of file diff --git a/library/templates/Intonation/Library/View/Wrapper/Website.php b/library/templates/Intonation/Library/View/Wrapper/Website.php index 9f3331b4d480bd18596d1ac9259b85c11ca09f91..5df120eb4c8ed357eb6d72b4498baecde5c56b30 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Website.php +++ b/library/templates/Intonation/Library/View/Wrapper/Website.php @@ -89,6 +89,9 @@ class Intonation_Library_View_Wrapper_Website extends Intonation_Library_View_Wr public function getDescription() { + if ( ! $this->_view) + return ''; + return $this->getBadges() . ($description = $this->_truncate($this->_model->getDescription())) ? $this->_view->tag('p', $description, ['class' => 'website_description']) @@ -106,6 +109,9 @@ class Intonation_Library_View_Wrapper_Website extends Intonation_Library_View_Wr public function getBadges() { + if (! $this->_view) + return ''; + $badges = []; $badges [] = ((new Intonation_Library_Badge) @@ -139,4 +145,15 @@ class Intonation_Library_View_Wrapper_Website extends Intonation_Library_View_Wr public function getOsmData() { } + + + public function getModelClassname() { + return get_class($this); + } + + + public static function find($id) { + $smeltery = new Intonation_Library_View_Wrapper_Website_Smeltery; + return $smeltery->meltWebsite(Class_Sitotheque::find($id)); + } } diff --git a/library/templates/Intonation/Library/View/Wrapper/Work.php b/library/templates/Intonation/Library/View/Wrapper/Work.php index 2b59c496f2dc3a929f0516a4370be8bd294a9480..1f6966f4b86f2238d554b60139535c610a95264d 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Work.php +++ b/library/templates/Intonation/Library/View/Wrapper/Work.php @@ -158,4 +158,21 @@ class Intonation_Library_View_Wrapper_Work extends Intonation_Library_View_Wrapp public function getDocTypeLabel() {} public function getOsmData() {} + + + public function getModelClassname() { + return get_class($this); + } + + + public function getModelId() { + return ($model = $this->_model->getRecord()) + ? $model->getClefOeuvre() + : ''; + } + + + public static function find($id) { + return Class_Notice_Work::loadWithFacets($id); + } } \ No newline at end of file diff --git a/library/templates/Intonation/View/RenderAjaxPaginatedList.php b/library/templates/Intonation/View/RenderAjaxPaginatedList.php index 8e86884d5ce0bf011dabfa60c443143b526a3a28..e88d224bc64c8ce6c16edea3c8dc685c85767958 100644 --- a/library/templates/Intonation/View/RenderAjaxPaginatedList.php +++ b/library/templates/Intonation/View/RenderAjaxPaginatedList.php @@ -76,25 +76,30 @@ class Intonation_View_RenderAjaxPaginatedList extends ZendAfi_View_Helper_BaseHe ? true : null; + $previous_page = $current_page -1; + $anchor_previous_url = $this->view->url(['controller' => 'index', 'action' => 'ajax-paginated-list', 'id' => $this->_id, 'size' => $helper->getPageSize(), - 'page' => $current_page -1], null, true); + 'page' => $previous_page], null, true); $anchor_previous = $this->view->tagAnchor($anchor_previous_url, $this->_tag('i','',['class' => 'fas fa-chevron-left m-0']), array_filter(['title' => $this->_('page précedente'), 'class' => 'btn btn-sm btn-secondary ajax_anchor previous_ajax_anchor', 'id' => 'previous_' . $this->_id, + 'data-page' => $previous_page, 'data-disabled' => $previous_button_disabled])); + $next_page = $current_page +1; + $anchor_next_url = $this->view->url(['controller' => 'index', 'action' => 'ajax-paginated-list', 'id_profil' => Class_Profil::getCurrentProfil()->getId(), 'id' => $this->_id, 'size' => $helper->getPageSize(), - 'page' => $current_page +1], + 'page' => $next_page], null, true); @@ -102,6 +107,7 @@ class Intonation_View_RenderAjaxPaginatedList extends ZendAfi_View_Helper_BaseHe $this->_tag('i','',['class' => 'fas fa-chevron-right m-0']), array_filter(['title' => $this->_('page suivante'), 'class' => 'btn btn-sm btn-secondary ajax_anchor next_ajax_anchor', + 'data-page' => $next_page, 'id' => 'next_' . $this->_id, 'data-disabled' => $next_button_disabled])); @@ -117,7 +123,6 @@ class Intonation_View_RenderAjaxPaginatedList extends ZendAfi_View_Helper_BaseHe protected function _renderTools($helper, $sub_collection) { - $collection = $helper->getCollection(); $form = new ZendAfi_Form; $form @@ -164,6 +169,7 @@ class Intonation_View_RenderAjaxPaginatedList extends ZendAfi_View_Helper_BaseHe return $this->view->RenderTruncateList_Tools($form, $helper->getSize(), - 'ajax_paginated_form'); + 'ajax_paginated_form', + $helper->hasBeenSliced()); } } diff --git a/library/templates/Intonation/View/RenderRecord/ExternalUrl.php b/library/templates/Intonation/View/RenderRecord/ExternalUrl.php new file mode 100644 index 0000000000000000000000000000000000000000..8f382073bdaae0da58129d14007d2ddea642b87e --- /dev/null +++ b/library/templates/Intonation/View/RenderRecord/ExternalUrl.php @@ -0,0 +1,30 @@ +<?php +/** + * Copyright (c) 2012-2018, 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 Intonation_View_RenderRecord_ExternalUrl extends ZendAfi_View_Helper_BaseHelper { + + public function RenderRecord_ExternalUrl($url) { + return $this->view->tagAnchor($url, + $this->_('Description en ligne'), + ['class' => 'btn btn-lg btn-primary m-3']); + } +} diff --git a/library/templates/Intonation/View/RenderRecord/RenderItems.php b/library/templates/Intonation/View/RenderRecord/RenderItems.php index 7ed41452b02d116af7e5ad6addb17598c8aa1ae4..bf939ca8a670f81b162726e22981c406ea41f73f 100644 --- a/library/templates/Intonation/View/RenderRecord/RenderItems.php +++ b/library/templates/Intonation/View/RenderRecord/RenderItems.php @@ -25,6 +25,19 @@ class Intonation_View_RenderRecord_RenderItems extends ZendAfi_View_Helper_BaseH if (!$items) return ''; + if (Intonation_View_RenderTruncateList::$ajax_size < count($items)) { + $elements = array_map(function($element) + { + return (new Intonation_Library_View_Wrapper_ItemWithoutSIGB($element, $this->view)); + }, $items); + + return $this->view->renderCollection(new Storm_Collection($elements)); + } + + $record = new Intonation_Library_Record(reset($items)->getNotice()); + if ($record->isExternalResource()) + return $this->view->RenderRecord_ExternalUrl($record->getUrl()); + $html = [ $this->_hookForMoreHtml($items) ]; $html []= $this->_renderOsmMap($items, $same_work); diff --git a/library/templates/Intonation/View/RenderTruncateList.php b/library/templates/Intonation/View/RenderTruncateList.php index dae9aa91c8846458aca1886ff170a307654b51ff..76971c8454130a127d314ad022c1f3e920ac74f0 100644 --- a/library/templates/Intonation/View/RenderTruncateList.php +++ b/library/templates/Intonation/View/RenderTruncateList.php @@ -22,10 +22,11 @@ class Intonation_View_RenderTruncateList extends Intonation_View_Abstract_Layout { + public static $ajax_size = 20; + protected $_min_size_for_tools = 3, $_page_size = 3, - $_ajax_size = 20, $_container_id, $_widget_id, $_top_tools_id, @@ -38,7 +39,7 @@ class Intonation_View_RenderTruncateList extends Intonation_View_Abstract_Layout $size = $collection->count(); - if ($this->_ajax_size < $size) + if (static::$ajax_size < $size) return $this->_ajaxifyList($collection); $this->_page_size = $page_size; @@ -145,4 +146,4 @@ class Intonation_View_RenderTruncateList extends Intonation_View_Abstract_Layout return $this->view->renderAjaxPaginatedList($helper); } -} \ No newline at end of file +} diff --git a/library/templates/Intonation/View/RenderTruncateList/Tools.php b/library/templates/Intonation/View/RenderTruncateList/Tools.php index 37596b95e044f9db16ec90ae9c87530b83d59a0d..a3798673728b2ae15dbfa11e82688be4055a6ca7 100644 --- a/library/templates/Intonation/View/RenderTruncateList/Tools.php +++ b/library/templates/Intonation/View/RenderTruncateList/Tools.php @@ -21,7 +21,11 @@ class Intonation_View_RenderTruncateList_Tools extends ZendAfi_View_Helper_BaseHelper { - public function RenderTruncateList_Tools($form, $size, $form_class) { + public function RenderTruncateList_Tools($form, $size, $form_class, $has_been_sliced = false) { + $size_title = $has_been_sliced + ? $this->_('Le nombre d\'éléments a été volontairement réduit pour des raisons de performances') + : $this->_('Nombre total d\'élements présent dans la liste'); + $size_html = $this->_div(['class' => 'truncate_list_size_wrapper'], $this->_tag('span' , $this->_plural($size, @@ -30,7 +34,8 @@ class Intonation_View_RenderTruncateList_Tools extends ZendAfi_View_Helper_BaseH '%s éléments', $this->_tag('span', $size, - ['class' => 'truncate_list_size_number'])), + ['class' => 'truncate_list_size_number', + 'title' => $size_title])), ['class' => 'truncate_list_size'])); $form_html = $this->_div(['class' => 'truncate_list_form_wrapper ' . $form_class], diff --git a/public/opac/js/ajaxifyPaginatedList/ajaxifyPaginatedList.js b/public/opac/js/ajaxifyPaginatedList/ajaxifyPaginatedList.js index 61dc24503a3b754b6e9dd510d6b826f9ca03961b..2fe150973f7d88c9c09027fcd59014acbb2821c3 100644 --- a/public/opac/js/ajaxifyPaginatedList/ajaxifyPaginatedList.js +++ b/public/opac/js/ajaxifyPaginatedList/ajaxifyPaginatedList.js @@ -51,10 +51,9 @@ widget.ajaxifyPaginatedList(); }; - var links = widget.find("a.ajax_anchor"); links.click(function(event) { - refresh($(this), event, 'href'); + refreshWithOption($(this).attr('data-page'), 'page', event); }); var refreshWithOption = function(option, param, event) { @@ -62,11 +61,13 @@ ? form.attr('action') + '/' + param + '/' + encodeURIComponent(option) : form.attr('action'); + if ('search' != param) + url = url + '/search/' + encodeURIComponent(widget.find(".ajax_search").val()); + form.attr('data-url', url); refresh(form, event, 'data-url'); }; - var inputs = widget.find(".ajax_search"); inputs.attr('onkeypress', 'return event.keyCode != 13;'); diff --git a/tests/application/modules/admin/controllers/SystemeControllerTest.php b/tests/application/modules/admin/controllers/SystemeControllerTest.php index a4da63551f4c4eb5da39b537157a1e1ab8acdf53..e85a732560edcf1e579dc874f4dcce052e3e8f93 100644 --- a/tests/application/modules/admin/controllers/SystemeControllerTest.php +++ b/tests/application/modules/admin/controllers/SystemeControllerTest.php @@ -60,24 +60,55 @@ class SystemeControllerMailTestActionTest extends Admin_AbstractControllerTestCa public function formShouldContainsSubmitButton() { $this->assertXPath('//form//input[@type="submit"]'); } + + + /** @test */ + public function formShouldContainsFileInputAttachment() { + $this->assertXPath('//form//input[@type="file"][@name="attachment"]'); + } + + + /** @test */ + public function formEncTypeShouldMultiPartFormData() { + $this->assertXPath('//form[@enctype="multipart/form-data"]'); + } } -class SystemeControllerPostMailActionTest extends Admin_AbstractControllerTestCase { - protected $_mail; +abstract class SystemeControllerPostMailActionTestCase extends Admin_AbstractControllerTestCase { + protected + $_storm_default_to_volatile = true, + $_mock_transport, + $_mail; + public function setUp() { parent::setUp(); - $mock_transport = new MockMailTransport(); - Zend_Mail::setDefaultTransport($mock_transport); + $this->_mock_transport = new MockMailTransport(); + Zend_Mail::setDefaultTransport($this->_mock_transport); + Class_AdminVar::set('NOM_DOMAINE', 'sushis.com'); + } + + + public function postDatas($datas) { $this->postDispatch('admin/systeme/mailtest', - ['sender' => 'pollux@afi-sa.fr', - 'recipient' => 'castor@afi-sa.fr']); + $datas); + + $this->_mail = $this->_mock_transport->sent_mail; + } +} + - $this->_mail = $mock_transport->sent_mail; + + +class SystemeControllerPostMailActionTest extends SystemeControllerPostMailActionTestCase { + public function setUp() { + parent::setUp(); + $this->postDatas(['sender' => 'pollux@afi-sa.fr', + 'recipient' => 'castor@afi-sa.fr']); } @@ -102,8 +133,8 @@ class SystemeControllerPostMailActionTest extends Admin_AbstractControllerTestCa /** @test */ - public function bodyTextShouldContainsEnvoyeDepuisBASE_URL() { - $this->assertEquals('Envoyé depuis '.BASE_URL, + public function bodyTextShouldContainsEnvoyeDepuisSushisDotCom() { + $this->assertEquals('Envoyé depuis sushis.com' , quoted_printable_decode($this->_mail->getBodyText()->getContent())); } @@ -117,6 +148,68 @@ class SystemeControllerPostMailActionTest extends Admin_AbstractControllerTestCa +class SystemeControllerPostMailWithAttachmentTestActionTest extends SystemeControllerPostMailActionTestCase { + public function setUp() { + parent::setUp(); + $_FILES['attachment'] = ['size' => (250 * 1000), + 'name' => 'greetings.txt', + 'type' => 'text/plain', + 'tmp_name' => '/tmp/greetings.txt', + 'error' => UPLOAD_ERR_OK]; + + $file_system = (new Storm_FileSystem_Volatile()) + ->mkdir('/tmp') + ->filePutContents('/tmp/greetings.txt', + 'this is not a file'); + + ZendAfi_Mail::setFileSystem($file_system); + + $this->postDatas(['sender' => 'pollux@afi-sa.fr', + 'recipient' => 'castor@afi-sa.fr']); + } + + + public function tearDown() { + ZendAfi_Mail::setFileSystem(null); + parent::tearDown(); + } + + + /** @test */ + public function mailShouldContainsHaveOneAttachment() { + $this->assertEquals(1, count($parts = $this->_mail->getParts())); + return $parts[0]; + } + + + /** + * @depends mailShouldContainsHaveOneAttachment + * @test + */ + public function mailShouldContainsAttachmentGreetingsDotTxt($part) { + $this->assertEquals(['text/plain', + 'base64', + 'attachment'], + [$part->type, + $part->encoding, + $part->disposition]); + } + + + /** + * @depends mailShouldContainsHaveOneAttachment + * @test + */ + public function attachmentContentShouldBeThisIsNotAFile($part) { + $this->assertEquals('this is not a file', + base64_decode($part->getContent())); + } + +} + + + + class SystemeControllerPostInvalidPostTest extends Admin_AbstractControllerTestCase { protected $_mail; diff --git a/tests/library/Class/Cosmogramme/Integration/PhaseNoticeTest.php b/tests/library/Class/Cosmogramme/Integration/PhaseNoticeTest.php index f649b99a8b89f56305c01b5f49097d5ea6f86ef0..ddc1a3aa8daaba9a888a968d4fd4f62ec3c6a843 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhaseNoticeTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhaseNoticeTest.php @@ -495,3 +495,29 @@ class PhaseNoticeSpecialCharactersImportItemTest extends PhaseNoticeTestCase { $this->assertContains('MALM', Class_Notice::find(2)->getClefAlpha()); } } + + + + +/* + * @see https://forge.afi-sa.net/issues/137943 + */ +class PhaseNoticeTotalImportTwo200Test extends PhaseNoticeTestCase { + protected function _prepareFixtures() { + parent::_prepareFixtures(); + + Class_IntBib::find(2)->setNomCourt('VRSL') + ->setSigb(Class_IntBib::SIGB_KOHA); + + Class_Cosmogramme_Integration::find(999)->setFichier('duplicate_200.mrc'); + + Class_IntProfilDonnees::find(102) + ->updateAttributes(Class_IntProfilDonnees::forKoha()->getRawAttributes()); + } + + + /** @test */ + public function firstRecordAlphaTitreShouldBeKENCHIKUBUNKA() { + $this->assertEquals('KENCHIKU BUNKA', Class_Notice::find(1)->getAlphaTitre()); + } +} diff --git a/tests/library/Class/Cosmogramme/Integration/duplicate_200.mrc b/tests/library/Class/Cosmogramme/Integration/duplicate_200.mrc new file mode 100644 index 0000000000000000000000000000000000000000..0d5fe369165eee08016855fd0adb2a2a7f402409 --- /dev/null +++ b/tests/library/Class/Cosmogramme/Integration/duplicate_200.mrc @@ -0,0 +1 @@ +07849cas0 2200697 4500001000700000003003000007005001700037009001000054011002500064035001400089035001400103035002100117035001900138035001700157035001700174090001100191098001500202099003500217100004100252101000800293102000700301105001800308106000600326110001600332181002500348181002000373182002100393182001100414183002500425200002600450200002800476210004200504210004400546510003100590530001900621606004400640607001100684608004400695676002000739801004100759801002300800802000700823923081900830923004801649923012501697923050401822924022202326924091202548924059403460930004104054930003804095930004304133955140304176955090305579955012506482959021806607995007706825995007606902995008206978995009107060144303http://www.sudoc.fr/03631006920210205201409.0036310069 a0003-8490f0003-8490 aPBLV15258 aMALQ42204 a0888288169sudoc a(OCoLC)2667802 accn0017/7687 aissn00038490 a144303 e2019-02-19 tREVc2007-04-30s1e2020-07-01 a19830101b19462004k y0frey50 da0 ajpn aJP ay ||||||||| ar aafa||||0|u| 6z01ctxt2rdacontent 16z01ai#bxxxe## 6z01cn2rdamedia 16z01an 16z01anga2rdacarrier1 6a017daa建築文化1 6a017baaKenchiku bunka 6a027daaæ±äº¬c彰国社d1946-2004 6a027baaTokyÅcShÅkokushad1946-2004 aArchitectural culturezeng0 aKenchiku bunka 30272289839339162aArchitecture2rameau 2RAMEAU 302724640X9339056aPériodiques2rameau a720v[original] 3aFRbAbesc20200630gAFNORh088828816 3aFRbISSNc20050729 a09 aVRSLbvol. 14, no 148, 1959 ; vol. 14, no 153, 1959 ; vol. 15, no 159, 1960 - vol. 15, no 166, 1960 ; vol. 15, no 168, 1960 ; vol. 16, no 171, 1961 ; vol. 16, no 178, 1961 ; vol. 16, no 180, 1961 - vol. 16, no 181, 1961 ; vol. 17, no 183, 1962 ; vol. 17, no 187, 1962 - vol. 17 no 188, 1962 ; vol. 17, no 190, 1962 ; vol. 18, no 199, 1963 ; vol. 18 no 201, 1963 - vol. 18, no 202, 1963 ; vol. 18, no 204, 1963 - vol. 18, no 205, 1963 ; vol. 20, no 222, 1965 - vol. 20 no 226, 1965 ; vol. 21, no 235, 1966 ; vol. 22, no 243, 1967 - vol. 22 no 245, 1967 ; vol. 22, no 247, 1967 ; vol. 22, no 251, 1967 ; vol. 22, no 254, 1967 ; vol. 23, no 256, 1968 ; vol. 23, no 258, 1968 - vol. 23, no 260, 1968 ; vol. 24, no 267, 1969 - vol. 271, 1969 ; vol. 24, no 274, 1969 - no 275, 1969 ; vol. 24, no 277, 1969 - no 278, 1969 aMALQbno 2, 1969 - no 12, 1969c(1969) 4, 8 aPBLVbno 172, 1961 - no 219, 1965c(1961) 171, 173 à 180 ; (1962) 190 à 194 ; (1964) 209 à 213, 216; 217 ; (1965) 220 aMLVLeen placard 8bvol.11, no 117, 1956 ; vol.11, no 119, 1956 - vol.11, no 120, 1956 ; vol.12, no 122, 1957 - vol.12, no 124, 1957 ; vol.12, no 129, 1957 - vol.12, no 134, 1957 ; vol.14, no 152, 1959 - vol.14, no 154, 1959 ; vol.15, no 160, 1960 - vol.15, no 163, 1960 ; vol.15, no 166, 1960 - vol.19, no 217, 1964 ; vol.20, no 219, 1965 - vol.21, no 242, 1966 ; vol.22, no 245, 1967 ; vol.22, no 248, 1967 ; vol.22, no 252, 1967 - vol.22, no 258, 1968 ; no 669, 2004 - no 672, 2004 ; no 674, 2004 5751192301:628962401b751192301cRESjfrno. 172 (1961) - no. 219 (1965) [lacunes]B172B219I1961I1965WlacunesRno.171, 173 à 180 (1961) ; no.190 à 194 (1962) ; no.209 à 213, 216; 217 (1964) ; no.220 (1965) 5786462302:115960023b786462302jfrvol. 14 no. 148 (1959) ; vol. 14 no. 153 (1959) ; vol. 15 no. 159 (1960) - vol. 15 no. 166 (1960) ; vol. 15 no. 168 (1960) ; vol. 16 no. 171 (1961) ; vol. 16 no. 178 (1961) ; vol. 16 no. 180 (1961) - vol. 16 no. 181 (1961) ; vol. 17 no. 183 (1962) ; vol. 17 no. 187 (1962) - vol. 17 no. 188 (1962) ; vol. 17 no. 190 (1962) ; vol. 18 no. 199 (1963) ; vol. 18 no. 201 (1963) - vol. 18 no. 202 (1963) ; vol. 18 no. 204 (1963) - vol. 18 no. 205 (1963) ; vol. 20 no. 222 (1965) - vol. 20 no. 226 (1965) ; vol. 21 no. 235 (1966) ; vol. 22 no. 243 (1967) - vol. 22 no. 245 (1967) ; vol. 22 no. 247 (1967) ; vol. 22 no. 251 (1967) ; vol. 22 no. 254 (1967) ; vol. 23 no. 256 (1968) ; vol. 23 no. 258 (1968) - vol. 23 no. 260 (1968) ; vol. 24 no. 267 (1969) - vol. 271 (1969) ; vol. 24 no. 274 - no. 275 (1969) ; vol. 24 no. 277 - no. 278 (1969)B277B278I1969 5774682305:401647501b774682305a-jfrvol. 11 no. 117 (1956) ; vol. 11 no. 119 (1956) - vol. 11 no. 120 (1956) ; vol. 12 no. 122 (1957) - vol. 12 no. 124 (1957) ; vol. 12 no. 129 (1957) - vol. 12 no. 134 (1957) ; vol. 14 no. 152 (1959) - vol. 14 no. 154 (1959) ; vol. 15 no. 160 (1960) - vol. 15 no. 163 (1960) ; vol. 15 no. 166 (1960) - vol. 19 no. 217 (1964) ; vol. 20 no. 219 (1965) - vol. 21 no. 242 (1966) ; vol. 22 no. 245 (1967) ; vol. 22 no. 248 (1967) ; vol. 22 no. 252 (1967) - vol. 22 no. 258 (1968) ; no. 669 (2004) - no. 672 (2004) ; no. 674 (2004)B674I2004 5774682305:401647501b774682305a-jf 5786462302:115960023b786462302jf 5751192301:628962401b751192301cRESjf415786462302:115960023a14b148i1959a14b153i1959a15b159i1960a15b166i1960a15b168i1960a16b171i1961a16b178i1961a16b180i1961a16b181i1961a17b183i1962a17b187i1962a17b188i1962a17b190i1962a18b199i1963a18b201i1963a18b202i1963a18b204i1963a18b205i1963a20b222i1965a20b226i1965a21b235i1966a22b243i1967a22b245i1967a22b247i1967a22b251i1967a22b254i1967a23b256i1968a23b258i1968a23b260i1968a24b267i1969a271i1969a24b274b275i1969a24b277b278i1969rvol. 14 no. 148 (1959) ; vol. 14 no. 153 (1959) ; vol. 15 no. 159 (1960) - vol. 15 no. 166 (1960) ; vol. 15 no. 168 (1960) ; vol. 16 no. 171 (1961) ; vol. 16 no. 178 (1961) ; vol. 16 no. 180 (1961) - vol. 16 no. 181 (1961) ; vol. 17 no. 183 (1962) ; vol. 17 no. 187 (1962) - vol. 17 no. 188 (1962) ; vol. 17 no. 190 (1962) ; vol. 18 no. 199 (1963) ; vol. 18 no. 201 (1963) - vol. 18 no. 202 (1963) ; vol. 18 no. 204 (1963) - vol. 18 no. 205 (1963) ; vol. 20 no. 222 (1965) - vol. 20 no. 226 (1965) ; vol. 21 no. 235 (1966) ; vol. 22 no. 243 (1967) - vol. 22 no. 245 (1967) ; vol. 22 no. 247 (1967) ; vol. 22 no. 251 (1967) ; vol. 22 no. 254 (1967) ; vol. 23 no. 256 (1968) ; vol. 23 no. 258 (1968) - vol. 23 no. 260 (1968) ; vol. 24 no. 267 (1969) - vol. 271 (1969) ; vol. 24 no. 274 - no. 275 (1969) ; vol. 24 no. 277 - no. 278 (1969)9ENSA de Versailles415774682305:401647501a11b117i1956a11b119i1956a11b120i1956a12b122i1957a12b124i1957a12b129i1957a12b134i1957a14b152i1959a14b154i1959a15b160i1960a15b163i1960a15b166i1960a19b217i1964a20b219i1965a21b242i1966a22b245i1967a22b248i1967a22b252i1967a22b258i1968b669i2004b672i2004b674i2004rvol. 11 no. 117 (1956) ; vol. 11 no. 119 (1956) - vol. 11 no. 120 (1956) ; vol. 12 no. 122 (1957) - vol. 12 no. 124 (1957) ; vol. 12 no. 129 (1957) - vol. 12 no. 134 (1957) ; vol. 14 no. 152 (1959) - vol. 14 no. 154 (1959) ; vol. 15 no. 160 (1960) - vol. 15 no. 163 (1960) ; vol. 15 no. 166 (1960) - vol. 19 no. 217 (1964) ; vol. 20 no. 219 (1965) - vol. 21 no. 242 (1966) ; vol. 22 no. 245 (1967) ; vol. 22 no. 248 (1967) ; vol. 22 no. 252 (1967) - vol. 22 no. 258 (1968) ; no. 669 (2004) - no. 672 (2004) ; no. 674 (2004)9ENSA de Paris-Est415751192301:628962401b172i1961b219i1965wlacunesrno. 172 (1961) - no. 219 (1965) [lacunes]9ENSA de Paris-Belleville 5751192301:628962401e171, 173 à 180a19610 e190 à 194 a19620 e209 à 213, 216; 217a19640 e220a1965rno.171, 173 à 180 (1961) ; no.190 à 194 (1962) ; no.209 à 213, 216; 217 (1964) ; no.220 (1965) 00203152015-01-28f12345689627886bVRSLcVRSLeSLo3rREVw2015-01-28 002052015-02-18f123345779631939bPBLVcPBLVeRESo3rREVw2015-02-18 002052015-12-18f09881839658899bMALQcMALQeRDCkREVUEo3rREVw2015-12-18 002052016-01-22f123414139661300bMLVLcMLVLePLA1ken placard 8o3rREVw2016-01-22 \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/Accueil/PretsTest.php b/tests/library/ZendAfi/View/Helper/Accueil/PretsTest.php index 0578c0d70c739e45d369a054840a88d30db0761e..25db79465714ba3f7adc0aa6d517008d9370e516 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/PretsTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/PretsTest.php @@ -123,9 +123,10 @@ class PretsTestWithConnectedUser extends ViewHelperTestCase { /** @test */ public function dateRetour2021ShouldNotBeInClassPretEnRetard () { + //Bonjour toi du futur ! Merci de rajouter quelques années à la date histoire de faire passer le test. $this->assertNotXPathContentContains($this->html, '//ul//li[@class="pret_en_retard"]//span[@class="date_retour"]', - '21/10/2021'); + '21/10/2022'); } diff --git a/tests/scenarios/Activities/AdminControllerInscriptionWithQuotasTest.php b/tests/scenarios/Activities/AdminControllerInscriptionWithQuotasTest.php index c2365c1b314df909a9f27b769ef0eea9d25f344f..d5188b538d3b193c0531d260d9f7b594b1fd0e9a 100644 --- a/tests/scenarios/Activities/AdminControllerInscriptionWithQuotasTest.php +++ b/tests/scenarios/Activities/AdminControllerInscriptionWithQuotasTest.php @@ -388,4 +388,37 @@ class Activities_AdminControllerInscriptionWithQuotasSubscribeFullChildrenTest public function pageShouldContainNoMoreChildrenRoomMessage() { $this->assertXPathContentContains('//div', 'Aucune place enfant disponible'); } -} \ No newline at end of file +} + + + + +/* hotline : #141158 */ +class Activities_AdminControllerInscriptionWithQuotasSubscribeForAdminPortailTest + extends AdminControllerInscriptionWithQuotasTestCase { + + public function setUp() { + parent::setUp(); + + $user_group = $this->fixture(Class_UserGroup::class, + ['id' => 20, + 'libelle' => 'Redacteur portail', + 'rights' => [Class_UserGroup::RIGHT_REGISTER_ACTIVITY]]); + + $logged_user = $this->fixture(Class_Users::class, + ['id' => 6, + 'login' => 'totoro', + 'password' => '123456']) + ->setUserGroups([$user_group]); + + ZendAfi_Auth::getInstance()->logUser($logged_user); + + $this->dispatch('/admin/session-activity-inscription/subscribe/id/32/stagiaire_id/10'); + } + + + /** @test */ + public function pageShouldContainNombresAdultes() { + $this->assertXPath('//label[@data-name="adults"][text()="Nombres d\'adultes"]'); + } +} diff --git a/tests/scenarios/Templates/TemplatesAbonneSelectionsTest.php b/tests/scenarios/Templates/TemplatesAbonneSelectionsTest.php index 2af23e416400aec6c241d5671f012c78329cfeb2..28d10dde7d6861c67e78ffb749caee0d2d62c110 100644 --- a/tests/scenarios/Templates/TemplatesAbonneSelectionsTest.php +++ b/tests/scenarios/Templates/TemplatesAbonneSelectionsTest.php @@ -633,3 +633,56 @@ class TemplatesAbonneSelectionsInDomainsAsAdminTest . '[contains(@href, "/selection_id/2")]'); } } + + + + +class TemplatesAbonneSelectionsInDomainsAsAdminWithInspectorGadgetTest + extends AbstractControllerTestCase { + + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + + Intonation_Library_View_Wrapper_Selection::setInspector(null); + + $this->_buildTemplateProfil(['id' => 11]); + + $user = $this->fixture(Class_Users::class, + ['id' => 89, + 'login' => 'log', + 'password' => 'pass' + ]); + + ZendAfi_Auth::getInstance()->logUser($user); + + $this->fixture(Class_PanierNotice::class, + ['id' => 2, + 'libelle' => 'Mes BD', + 'user' => $user, + 'date_maj' => '10/02/2011', + 'notices' => 'COMBAT ORDINAIRE;BLACKSAD']); + + $this->dispatch('/opac/abonne/selections/inspector_gadget/1'); + } + + + public function tearDown() { + Intonation_Library_View_Wrapper_Selection::setInspector(null); + parent::tearDown(); + } + + + /** @test */ + public function buttonToAccessInspectorGadgetForSelection2ShouldBePresent() { + $this->assertXPathContentContains('//button', 'Informations'); + } + + + /** @test */ + public function inspectorGadgetInformationsForSelection2ShouldBePresent() { + $this->assertContains('des documents dans la colonne', $this->_response->getBody()); + } +} \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesAbonneTest.php b/tests/scenarios/Templates/TemplatesAbonneTest.php index f06cb8215475881e1aecac0530d4922b21fce89e..c11815f1037f65c754425caadab72cb1f8e6c5cf 100644 --- a/tests/scenarios/Templates/TemplatesAbonneTest.php +++ b/tests/scenarios/Templates/TemplatesAbonneTest.php @@ -309,7 +309,7 @@ class TemplatesDispatchAbonneLoansPaginatedTest extends TemplatesIntonationAccou $id = $helper->getId(); $this->dispatch('/opac/index/ajax-paginated-list/id/' . $id . '/page/2/render/ajax/id_profil/72'); - $this->assertContains('input_023b947302c4fac4349cda76fc057a89', $this->_response->getBody()); + $this->assertContains('input_99914b932bd37a50b983c5e7c90ae93b', $this->_response->getBody()); } @@ -365,7 +365,7 @@ class TemplatesDispatchAbonneLoansPaginatedTest extends TemplatesIntonationAccou $id = $helper->getId(); $this->dispatch('/opac/index/ajax-paginated-list/id/' . $id . '/page/2/render/ajax/id_profil/72/size/1/search/roi'); - $this->assertContains('input_69219ce1da1a3a70c6511767a99d5a05', $this->_response->getBody()); + $this->assertContains('input_99914b932bd37a50b983c5e7c90ae93b', $this->_response->getBody()); $this->assertContains('avec sa couronne', $this->_response->getBody()); } @@ -396,8 +396,8 @@ class TemplatesDispatchAbonneLoansPaginatedTest extends TemplatesIntonationAccou $this->dispatch('/opac/index/ajax-paginated-list/id/' . $id . '/page/1/id_profil/72/search/house/size/10'); $this->assertXPathContentContains('//div//a', 'Dr House'); - $this->assertXPathContentContains('//div//a[contains(@href, "/bib-numerique/return-pnb-loan/id/38bcd646a69f4da7fce8921d4cf762ad/page/1/id_profil/72/search/house/size/10/loan_id/666_3")]', 'Retour anticip'); - $this->assertXPathContentContains('//div//a[contains(@href, "/bib-numerique/extends-pnb-loan/id/38bcd646a69f4da7fce8921d4cf762ad/page/1/id_profil/72/search/house/size/10/loan_id/666_3")]', 'Prolonger'); + $this->assertXPathContentContains('//div//a[contains(@href, "/bib-numerique/return-pnb-loan/id/99914b932bd37a50b983c5e7c90ae93b/page/1/id_profil/72/search/house/size/10/loan_id/666_3")]', 'Retour anticip', $this->_response->getBody()); + $this->assertXPathContentContains('//div//a[contains(@href, "/bib-numerique/extends-pnb-loan/id/99914b932bd37a50b983c5e7c90ae93b/page/1/id_profil/72/search/house/size/10/loan_id/666_3")]', 'Prolonger'); } @@ -440,6 +440,7 @@ class TemplatesDispatchAbonneAjaxLoansTest extends TemplatesIntonationAccountTes $this->dispatch('/opac/abonne/ajax-loans/id_profil/72'); } + /** @test */ public function ajaxLoanAliceShouldDisplayButtonToutProlonger() { $this->assertXPathContentContains('//div[contains(@class,"button_text")]', 'Tout prolonger'); @@ -1518,4 +1519,127 @@ class TemplatesAbonneKohaAjaxLoansTest extends AbstractControllerTestCase { public function shouldRenderEmptyBodyWithoutFatalError() { $this->assertEmpty($this->_response->getBody()); } +} + + + + +abstract class TemplatesAbonneCacheTestCase extends AbstractControllerTestCase { + + + protected $_storm_default_to_volatile = true; + + + public function setUp(){ + parent::setUp(); + + $this->_buildTemplateProfil(['id' => 8932]); + + $int_bib = $this->fixture(Class_IntBib::class, + ['id' => 1, + 'comm_sigb' => Class_IntBib::COM_NANOOK, + 'comm_params' => ['url_serveur' => 'http://localhost']]); + + $user = $this->fixture(Class_Users::class, + ['id' => 3, + 'login' => 'patron', + 'password' => 'patron', + 'id_int_bib' => 1, + 'id_site' => 1, + 'idabon' => '007', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB]); + + $cache = $this + ->mock() + ->whenCalled('remove') + ->answers(true) + + ->whenCalled('test') + ->answers(false) + + ->whenCalled('save') + ->answers(true); + + Storm_Cache::setDefaultZendCache($cache); + + ZendAfi_Auth::getInstance()->logUser($user); + } + + + public function tearDown() { + Storm_Cache::setDefaultZendCache(null); + parent::tearDown(); + } + + + /** @test */ + public function removeCacheShouldHaveBeenCalled() { + $this->assertTrue(Storm_cache::getDefaultZendCache()->methodHasBeenCalled('remove')); + } +} + + + + +class TemplatesAbonneCacheReservationsTest extends TemplatesAbonneCacheTestCase { + + public function setUp() { + parent::setUp(); + $this->dispatch('/opac/abonne/reservations'); + } +} + + + + +class TemplatesAbonneCacheFicheTest extends TemplatesAbonneCacheTestCase { + + public function setUp() { + parent::setUp(); + $this->dispatch('/opac/abonne/fiche'); + } +} + + + + +class TemplatesAbonneCachePretsTest extends TemplatesAbonneCacheTestCase { + + public function setUp() { + parent::setUp(); + $this->dispatch('/opac/abonne/prets'); + } +} + + + + +class TemplatesAbonneCacheLoansHistoryTest extends TemplatesAbonneCacheTestCase { + + public function setUp() { + parent::setUp(); + $this->dispatch('/opac/abonne/loans-history'); + } +} + + + + +class TemplatesAbonneCacheAjaxLoansTest extends TemplatesAbonneCacheTestCase { + + public function setUp() { + parent::setUp(); + $this->dispatch('/opac/abonne/ajax-loans'); + } +} + + + + +class TemplatesAbonneCacheSuggestionsTest extends TemplatesAbonneCacheTestCase { + + public function setUp() { + parent::setUp(); + $this->dispatch('/opac/abonne/suggestions'); + } } \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesAjaxPaginatedListTest.php b/tests/scenarios/Templates/TemplatesAjaxPaginatedListTest.php new file mode 100644 index 0000000000000000000000000000000000000000..bfd668fc0b3f88d3f22406395d5c2dfc7e9f47ba --- /dev/null +++ b/tests/scenarios/Templates/TemplatesAjaxPaginatedListTest.php @@ -0,0 +1,867 @@ +<?php +/** + * Copyright (c) 2012-2021, 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 TemplatesAjaxPaginatedListNoCacheTest extends AbstractControllerTestCase { + + + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + Storm_Cache::beVolatile(); + $this->dispatch('/opac/index/ajax-paginated-list/id/123123'); + } + + + public function tearDown() { + Storm_Cache::setDefaultZendCache(null); + return parent::tearDown(); + } + + + + /** @test */ + public function shouldReloadPageByJavascript() { + $this->assertXPathContentContains('//script', 'location.reload();'); + } +} + + + + +abstract class TemplatesAjaxPaginatedListTestCase extends AbstractControllerTestCase { + + + protected + $_storm_default_to_volatile = true, + $_view_renderer, + $_ajax_paginated_list_helper, + $_ajax_paginated_list_helper_id, + $_collection_cache; + + + public function setUp() { + parent::setUp(); + + Storm_Cache::beVolatile(); + + $this->_buildTemplateProfil(['id' => '34']); + + $this->_view_renderer = new ZendAfi_Controller_Action_Helper_ViewRenderer; + $this->_view_renderer->preDispatch(); + + $this->_ajax_paginated_list_helper = (new Intonation_Library_AjaxPaginatedListHelper) + ->setCollection($this->_getCollection()) + ->setRendering('cardifyHorizontal'); + + $this->_ajax_paginated_list_helper_id = $this->_ajax_paginated_list_helper->getId(); + + $this->dispatch('/opac/index/ajax-paginated-list/id/' . $this->_ajax_paginated_list_helper_id); + } + + + public function tearDown() { + Storm_Cache::setDefaultZendCache(null); + return parent::tearDown(); + } + + + /** @test */ + public function pageShouldContainsSearchInput() { + $this->assertXPath('//form//input[@name="input_' . $this->_ajax_paginated_list_helper_id . '"]'); + } + + + /** @test */ + public function pageShouldContainsAnElementInTheList() { + $this->assertXPath('//div[@class="ajax_content"]//div[contains(@class, "list-group")]//div[contains(@class, "list-group-item")]'); + } + + + /** @test */ + public function dataToCacheShouldBeLowerThanExpectedSize() { + $data = $this->_ajax_paginated_list_helper->getDataToCache(); + $serialized = serialize($data); + $size = mb_strlen($serialized); + $this->assertTrue('1024' > $size); + } + + + protected function _getCollection() { + if ($this->_collection_cache) + return $this->_collection_cache; + + return $this->_collection_cache = new Storm_Collection($this->_getCollectionAsArray()); + } + + + abstract protected function _getCollectionAsArray(); +} + + + + +class TemplatesAjaxPaginatedListWithActivitySessionInscriptionTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_SessionActivityInscription::class, + ['id' => 1]); + + return [new Intonation_Library_View_Wrapper_ActivitySessionInscription($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithActivitySessionTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fishing = $this->fixture('Class_Activity', + ['id' => 3, + 'libelle' => 'Learn fishing', + 'description' => 'fishing']); + + + $fixture = $this->fixture(Class_SessionActivity::class, + ['id' => 1, + 'activity' => $fishing, + 'libelle' => 'act', + 'date_debut' => '2021-02-10', + 'date_fin' => '2021-02-20',]); + + return [new Intonation_Library_View_Wrapper_ActivitySession($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithAritcleTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_Article::class, + ['id' => 1, + 'titre' => 'art', + 'contenu' => 'un article']); + + return [new Intonation_Library_View_Wrapper_Article($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithAuthorTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_CodifAuteur::class, + ['id' => 1]); + + return [new Intonation_Library_View_Wrapper_Author($fixture)]; + } +} + + + + + +class TemplatesAjaxPaginatedListWithCardTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_Users::class, + ['id' => 1, + 'login' => 'Log', + 'password' => 'pass']); + + return [new Intonation_Library_View_Wrapper_Card($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithDomainTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_Catalogue::class, + ['id' => 1, + 'libelle'=> 'lib']); + + return [new Intonation_Library_View_Wrapper_Domain($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithDriveCheckoutPlanTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = new Class_DriveCheckout_Plan([], + $this->fixture(Class_Users::class, + ['id' => 1, + 'login'=> 'log', + 'password' => 'pass'])); + + return [new Intonation_Library_View_Wrapper_DriveCheckoutPlan($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithHoldTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $item = new Class_WebService_SIGB_Exemplaire(1); + $hold = new Class_WebService_SIGB_Reservation(1, $item); + $user = $this->fixture(Class_Users::class, + ['id' => 1, + 'login'=> 'log', + 'password' => 'pass']); + + $card_operation_decorator = new Class_User_CardsOperationDecorator($hold, $user); + return [new Intonation_Library_View_Wrapper_Hold($card_operation_decorator)]; + } + + + /** @test */ + public function dataToCacheShouldBeLowerThanExpectedSize() { + $data = $this->_ajax_paginated_list_helper->getDataToCache(); + $serialized = serialize($data); + $size = mb_strlen($serialized); + $this->assertTrue('1524' > $size); + } +} + + + + +class TemplatesAjaxPaginatedListWithItemForOsmTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_Exemplaire::class, + ['id' => 1, + 'id_notice' => 23 + ]); + return [new Intonation_Library_View_Wrapper_ItemForOsm($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithItemTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_Exemplaire::class, + ['id' => 1, + 'id_notice' => 23 + ]); + return [new Intonation_Library_View_Wrapper_Item($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithLibraryTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_Bib::class, + ['id' => 1, + ]); + return [new Intonation_Library_View_Wrapper_Library($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithLoanTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $item = new Class_WebService_SIGB_Exemplaire(1); + $loan = new Class_WebService_SIGB_Emprunt(1, $item); + $user = $this->fixture(Class_Users::class, + ['id' => 1, + 'login'=> 'log', + 'password' => 'pass']); + + $card_operation_decorator = new Class_User_CardsOperationDecorator($loan, $user); + return [new Intonation_Library_View_Wrapper_Loan($card_operation_decorator)]; + } + + + /** @test */ + public function dataToCacheShouldBeLowerThanExpectedSize() { + $data = $this->_ajax_paginated_list_helper->getDataToCache(); + $serialized = serialize($data); + $size = mb_strlen($serialized); + $this->assertTrue('1524' > $size); + } +} + + + + +class TemplatesAjaxPaginatedListWithLocationTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_Lieu::class, + ['id' => 1, + 'libelle' => 'lib' + ]); + return [new Intonation_Library_View_Wrapper_Location($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithMenuEntryTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $profile = Class_Profil::find(34); + (new Class_Profil_Import($profile))->import(realpath(__DIR__) . '/../ProfilImportExport/7.json'); + $profile->save(); + + $fixture = (new Class_Systeme_Widget_Menu()) + ->setId(5) + ->setProfileId(34) + ->setParent(3) + ->load(); + + return [new Intonation_Library_View_Wrapper_MenuEntry($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithNewsletterTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_Newsletter::class, + ['id' => 1, + 'titre' => 'tit', + 'mail_subject' => 'mai']); + return [new Intonation_Library_View_Wrapper_Newsletter($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithParentCardTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_Users::class, + ['id' => 332423, + 'login' => 'log', + 'password' => 'pass']); + return [new Intonation_Library_View_Wrapper_ParentCard($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithPnbHoldTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $hold = $this->fixture(Class_Hold_Pnb::class, + ['id' => 145, + 'user_id' => 90 + ]); + + $user = $this->fixture(Class_Users::class, + ['id' => 90, + 'login'=> 'log', + 'password' => 'pass']); + + $card_operation_decorator = new Class_User_CardsOperationDecorator($hold, $user); + + return [new Intonation_Library_View_Wrapper_PNBHold($card_operation_decorator)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithPnbLoanTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $loan = $this->fixture(Class_Loan_Pnb::class, + ['id' => 3232, + 'user_id' => 123 + ]); + + $user = $this->fixture(Class_Users::class, + ['id' => 123, + 'login'=> 'log', + 'password' => 'pass']); + + $card_operation_decorator = new Class_User_CardsOperationDecorator($loan, $user); + return [new Intonation_Library_View_Wrapper_PNBLoan($card_operation_decorator)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithProTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_Users::class, + ['id' => 332423, + 'login' => 'log', + 'password' => 'pass']); + return [new Intonation_Library_View_Wrapper_Pro($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithRecordInSelectionTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_Notice::class, + ['id' => 332423]); + return [new Intonation_Library_View_Wrapper_RecordInSelection($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithRecordTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_Notice::class, + ['id' => 332423]); + return [new Intonation_Library_View_Wrapper_Record($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithRecordToRateTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_Notice::class, + ['id' => 332423]); + return [new Intonation_Library_View_Wrapper_RecordToRate($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithRecordToSelectTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_Notice::class, + ['id' => 332423]); + return [new Intonation_Library_View_Wrapper_RecordToSelect($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithRendezVousTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $agenda = $this->fixture(Class_UserGroup::class, + ['id' => 43, + 'model_class'=> 'Class_RendezVous', + 'libelle' => 'MonSuperAgenda', + 'users' => []]); + + $fixture = $this->fixture(Class_RendezVous::class, + ['id' => 332423, + 'date' => '2019-04-09', + 'begin_time' => '09:15', + 'end_time' => '10:30', + 'agenda' => $agenda]); + + return [new Intonation_Library_View_Wrapper_RendezVous($fixture)]; + } +} + + + + + +class TemplatesAjaxPaginatedListWithReviewInRecordTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_AvisNotice::class, + ['id' => 332423, + 'entete' => 'ent']); + return [new Intonation_Library_View_Wrapper_ReviewInRecord($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithReviewTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_AvisNotice::class, + ['id' => 332423, + 'entete' => 'ent']); + return [new Intonation_Library_View_Wrapper_Review($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithReviewsByRecordTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $review = $this->fixture(Class_AvisNotice::class, + ['id' => 332423, + 'entete' => 'ent']); + + $record = $this->fixture(Class_Notice::class, + ['id' => 8789]); + + $fixture = (new Class_ReviewsByRecord) + ->setRecord($record) + ->setReviews([$review]); + + return [new Intonation_Library_View_Wrapper_ReviewsByRecord($fixture)]; + } +} + + + + +require_once 'tests/fixtures/LemondeRss.php'; + +class TemplatesAjaxPaginatedListWithRssItemTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + Class_WebService_Abstract::setHttpClient($this + ->mock() + ->whenCalled('open_url') + ->with('https://rss.lemonde.fr/c/205/f/3050/index.rss') + ->answers(RssFixtures::lemondeRSS()) + ->beStrict()); + $rss = $this->fixture(Class_Rss::class, + ['id' => 1, + 'titre' => 'Flux RSS lemonde', + 'url' => 'https://rss.lemonde.fr/c/205/f/3050/index.rss', + 'description' => 'lemonde.', + 'tags' => 'test;bokeh;libre;git']); + + $rss_items = $rss->getFeedItems(); + + return [new Intonation_Library_View_Wrapper_RssItem(array_shift($rss_items))]; + } + + + /** @test */ + public function dataToCacheShouldBeLowerThanExpectedSize() { + $data = $this->_ajax_paginated_list_helper->getDataToCache(); + $serialized = serialize($data); + $size = mb_strlen($serialized); + $this->assertTrue('1524' > $size); + } +} + + + + +class TemplatesAjaxPaginatedListWithRssTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $rss = $this->fixture(Class_Rss::class, + ['id' => 1, + 'titre' => 'Flux RSS lemonde', + 'url' => 'https://rss.lemonde.fr/c/205/f/3050/index.rss', + 'description' => 'lemonde.', + 'tags' => 'test;bokeh;libre;git']); + + return [new Intonation_Library_View_Wrapper_Rss($rss)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithSearchHistoryTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_User_BookmarkedSearch::class, + ['id' => '231']); + + return [new Intonation_Library_View_Wrapper_SearchHistory($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithSearchTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_User_BookmarkedSearch::class, + ['id' => '231']); + + return [new Intonation_Library_View_Wrapper_Search($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithSelectionTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_PanierNotice::class, + ['id' => '231']); + + return [new Intonation_Library_View_Wrapper_Selection($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithSuggestionTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $suggesion = $this->fixture(Class_SuggestionAchat::class, + ['id' => 9087, + 'titre' => 'tit', + 'type_doc' => Class_TypeDoc::newWithLabel('Livres'), + 'user_id' => 1 + ]); + + $user = $this->fixture(Class_Users::class, + ['id' => 1, + 'login'=> 'log', + 'password' => 'pass']); + + $card_operation_decorator = new Class_User_CardsOperationDecorator($suggesion, $user); + return [new Intonation_Library_View_Wrapper_Suggestion($card_operation_decorator)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithUserTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixture = $this->fixture(Class_Users::class, + ['id' => 332423, + 'login' => 'log', + 'password' => 'pass']); + return [new Intonation_Library_View_Wrapper_User($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithWebsiteTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $website = $this->fixture(Class_Sitotheque::class, + ['id' => 332423, + 'titre' => 'tit', + 'url' => 'https://bokeh.opac.net']); + + $smeltery = new Intonation_Library_View_Wrapper_Website_Smeltery; + $fixture = $smeltery->meltWebsite($website); + + return [new Intonation_Library_View_Wrapper_Website($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithWorkTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $record = $this->fixture(Class_Notice::class, + ['id' => 8789, + 'clef_oeuvre' => 'clef']); + + $fixture = new Class_Notice_Work($record, ''); + return [new Intonation_Library_View_Wrapper_Work($fixture)]; + } +} + + + + +class TemplatesAjaxPaginatedListWithLotsOfRecordsTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $fixtures = []; + + for ( $id = 1 ; $id < 1000; $id++) + $fixtures [] = new Intonation_Library_View_Wrapper_Record($this->fixture(Class_Notice::class, + ['id' => $id])); + + return $fixtures; + } + + + /** @test */ + public function dataToCacheShouldBeLowerThanExpectedSize() { + $data = $this->_ajax_paginated_list_helper->getDataToCache(); + $serialized = serialize($data); + $size = mb_strlen($serialized); + + $this->assertEquals('191,34 ko', number_format(($size / 1024), 2, ',', ' ') . ' ko'); + } + + + /** @test */ + public function shouldContainsSpanTitleWithFullSizeMessage() { + $this->assertXPath('//span[@title="Nombre total d\'élements présent dans la liste"]'); + } +} + + + +class TemplatesAjaxPaginatedListWithTooMutchRecordsForCacheTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $cache = $this->mock(); + + $cache + ->whenCalled('save') + ->willDo(function() use ($cache) + { + return 3 < $cache->methodCallCount('save') + ? true + : false; + }) + + ->whenCalled('load') + ->willDo(function() + { + return serialize($this->_ajax_paginated_list_helper->getDataToCache()); + }); + + Storm_Cache::setDefaultZendCache($cache); + + $fixtures = []; + + for ( $id = 1 ; $id < 500; $id++) + $fixtures [] = new Intonation_Library_View_Wrapper_Record($this->fixture(Class_Notice::class, + ['id' => $id])); + + return $fixtures; + } + + + /** @test */ + public function dataToCacheShouldBeLowerThanExpectedSize() { + $data = $this->_ajax_paginated_list_helper->getDataToCache(); + $serialized = serialize($data); + $size = mb_strlen($serialized); + $this->assertTrue(0 < strcasecmp('40,00 ko', (number_format(($size / 1024), 2, ',', ' ')) . ' ko')); + } + + + /** @test */ + public function collectionShouldHaveBeenSlicedTo199WrappedRecords() { + $this->assertCount(199, $this->_ajax_paginated_list_helper->getCollection()); + } + + + /** @test */ + public function shouldContainsSpanTitleWithPerformanceLimitedMessage() { + $this->assertXPath('//span[@title="Le nombre d\'éléments a été volontairement réduit pour des raisons de performances"]'); + } +} + + + + +class TemplatesAjaxPaginatedListWithCorruptedSaveInCacheTest extends TemplatesAjaxPaginatedListTestCase { + + protected function _getCollectionAsArray() { + $cache = $this->mock(); + + $cache + ->whenCalled('save') + ->willDo(function() use ($cache) + { + return 200 < $cache->methodCallCount('save') + ? true + : false; + }) + + ->whenCalled('load') + ->willDo(function() + { + return serialize($this->_ajax_paginated_list_helper->getDataToCache()); + }); + + Storm_Cache::setDefaultZendCache($cache); + + $fixtures = []; + + for ( $id = 1 ; $id < 500; $id++) + $fixtures [] = new Intonation_Library_View_Wrapper_Record($this->fixture(Class_Notice::class, + ['id' => $id])); + + return $fixtures; + } + + + /** @test */ + public function dataToCacheShouldBeLowerThanExpectedSize() { + $data = $this->_ajax_paginated_list_helper->getDataToCache(); + $serialized = serialize($data); + $size = mb_strlen($serialized); + $this->assertTrue( 0 < strcasecmp('20,00 ko', (number_format(($size / 1024), 2, ',', ' ')) . ' ko')); + } + + + /** @test */ + public function collectionShouldHaveBeenSlicedTo99WrappedRecords() { + $this->assertCount(99, $this->_ajax_paginated_list_helper->getCollection()); + } + + + /** @test */ + public function shouldContainsSpanTitleWithPerformanceLimitedMessage() { + $this->assertXPath('//span[@title="Le nombre d\'éléments a été volontairement réduit pour des raisons de performances"]'); + } +} \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesArticlesTest.php b/tests/scenarios/Templates/TemplatesArticlesTest.php index c08533a98667dd51ef020853067232eeae20e7f2..ce4b7a53bfec90eb72c6a8725d93b1c3c959f8f6 100644 --- a/tests/scenarios/Templates/TemplatesArticlesTest.php +++ b/tests/scenarios/Templates/TemplatesArticlesTest.php @@ -738,6 +738,9 @@ abstract class TemplatesArticlesWidgetAjaxRenderingTestCase extends AbstractCont public function setUp() { parent::setUp(); + + Storm_Cache::beVolatile(); + $this->_buildTemplateProfil(['id' => 34]); $this->fixture('Class_ArticleCategorie', @@ -768,6 +771,12 @@ abstract class TemplatesArticlesWidgetAjaxRenderingTestCase extends AbstractCont } + public function tearDown() { + Storm_Cache::setDefaultZendCache(null); + return parent::tearDown(); + } + + public function getOrders() { return [['Random', 'Aléatoire'], diff --git a/tests/scenarios/Templates/TemplatesItemsPaginatedTest.php b/tests/scenarios/Templates/TemplatesItemsPaginatedTest.php new file mode 100644 index 0000000000000000000000000000000000000000..aa4b594c2b718d221c118ac35404fce602a58508 --- /dev/null +++ b/tests/scenarios/Templates/TemplatesItemsPaginatedTest.php @@ -0,0 +1,158 @@ +<?php +/** + * Copyright (c) 2012-2021, 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 TemplateItemsPaginatedTestCase extends AbstractControllerTestCase { + + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + + $this->_buildTemplateProfil(['id' => 1]); + + $params = ['url_serveur' => 'https://monsuperkoha.org', + 'restful' => '1', + 'id_bib' => 10, + 'type' => Class_IntBib::COM_KOHA]; + + $service = Class_WebService_SIGB_Koha::getService($params); + + $this->fixture('Class_IntBib', + ['id' => 10, + 'comm_sigb' => Class_IntBib::COM_KOHA, + 'comm_params' => ['url_serveur' => 'https://monsuperkoha.org', + 'restful' => '1']]); + + $service->setLogger($this->_getLog()); + $service->setWebClient($this->_getWebClient()); + + $this->_buildItems(Intonation_View_RenderTruncateList::$ajax_size + 1); + + $this->dispatch('/noticeajax/resources/id/456'); + } + + + protected function _buildItems($number_of_items) { + $record = $this->fixture(Class_Notice::class, + ['id' => 456]); + + $params = ['code_barres' => '2661690090', + 'id_notice' => 456, + 'id_bib' => 10, + 'id_int_bib' => 10, + 'id_origine' => 456123, + 'type' => $this->_getItemDocType(), + 'section' => 1, + 'emplacement' => 1, + 'zone995' => serialize([ + ['code' => 'a', + 'valeur' => '200022200188'], + ['code' => 'v', + 'valeur' => '2900 mai-juin'], + ['code' => 'b', + 'valeur' => 'EMPL1'] + ])]; + + for($i = 1; $i < $number_of_items; $i++ ) { + $item = + Class_Exemplaire::newInstanceWithIdAssertSave($i, $params); + + $record->addExemplaire($item); + } + + $record->save(); + } + + + /** @test */ + public function totalShouldBe21Items() { + $this->assertXPathContentContains('//span[contains(@class,"truncate_list_size_number")]', '21'); + } + + + /** @test */ + public function shouldOnlyDisplay10Items() { + $this->assertXPathCount('//div[contains(@class,"list-group-item")]', 10); + } + + + /** @test */ + public function shouldHaveLinkToNextPage() { + $this->assertXPath('//a[contains(@href,"/index/ajax-paginated-list/id_profil/1/id/")][contains(@href,"/size/10/page/2")]'); + } + + + /** @test */ + public function shouldDisplaySearchForm() { + $this->assertXPath('//input[contains(@class,"zendafi_form_ajax_search")]'); + } +} + + + + +class TemplateItemsPaginatedWithSerialsTest extends TemplateItemsPaginatedTestCase { + protected function _getItemDocType() { + return Class_Notice::TYPE_SERIAL_ARTICLE; + } + + + protected function _getWebClient() { + return $this + ->mock() + ->shouldNotBeCalled('open_url') + ->beStrict(); + } + + + protected function _getLog() { + return $this + ->mock() + ->beStrict(); + } +} + + + + +class TemplateItemsPaginatedWithBiblioTest extends TemplateItemsPaginatedTestCase { + protected function _getItemDocType() { + return Class_Notice::TYPE_BIBLIOGRAPHIC; + } + + + protected function _getWebClient() { + return $this + ->mock() + ->whenCalled('open_url') + ->answers('response'); + } + + + protected function _getLog() { + return $this + ->mock() + ->whenCalled('log') + ->answers(true); + } +} \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesLibraryTest.php b/tests/scenarios/Templates/TemplatesLibraryTest.php index 77200fc8f84e8d1d83b2f222765183470b1a5713..544c1bc0141ef3521e81f187ac6ba86aeceedc7c 100644 --- a/tests/scenarios/Templates/TemplatesLibraryTest.php +++ b/tests/scenarios/Templates/TemplatesLibraryTest.php @@ -745,3 +745,35 @@ class TemplatesLibraryWidgetWithCarouselThreeColumnsAndOpeningHoursTest extends 'Mardi : 10h - 12h'); } } + + + + +class TemplatesLibraryWithRewriteUrlNavigationTest + extends TemplatesLibraryTestCase { + + public function setUp() { + parent::setUp(); + + Class_Bib::find(4) + ->setRewriteUrl('meythet') + ->assertSave(); + Class_Bib::find(5) + ->setRewriteUrl('pringy') + ->assertSave(); + + $this->dispatch('/meythet'); + } + + + /** @test */ + public function prevNavShouldHaveBibEnLirePlusId2Url() { + $this->assertXPath('//div[contains(@class, "jumbotron_previous")]//a[contains(@class, "previous")][@href="/annecy"]'); + } + + + /** @test */ + public function nextNavShouldHaveBibEnLirePlusId4Url() { + $this->assertXPath('//div[contains(@class, "jumbotron_next")]//a[contains(@class, "next")][@href="/pringy"]'); + } +} diff --git a/tests/scenarios/Templates/TemplatesRecordsTest.php b/tests/scenarios/Templates/TemplatesRecordsTest.php index e7ca9c97e27e4e557a751146c4a36e7f00ab56b3..19bcc55bfafd588673491caa23eefd370611b620 100644 --- a/tests/scenarios/Templates/TemplatesRecordsTest.php +++ b/tests/scenarios/Templates/TemplatesRecordsTest.php @@ -249,6 +249,52 @@ class TemplatesRecordsViewnoticeTest extends TemplateRecordsWithDescriptionAndUn +/* + * @see https://forge.afi-sa.net/issues/137943 + */ +class TemplatesRecordsViewnoticeDouble200Test extends AbstractControllerTestCase { + + public function setUp() { + parent::setUp(); + + $this->_buildTemplateProfil(['id' => 34, + 'template' => 'INTONATION']); + + $notice_unimarc = (new Class_NoticeUnimarc_Fluent) + ->zoneWithChildren('200',['a' => '建築文化']) + ->zoneWithChildren('200',['a'=> 'Kenchiku bunka']); + + $this->fixture(Class_Notice::class, + ['id' => 2, + 'unimarc' => $notice_unimarc->render() + ] + ); + + $this->dispatch('/opac/recherche/viewnotice/id/2/profile_id/34'); + } + + + /** @test */ + public function cardTitleShouldContainsOnlyKanjis() { + $this->assertXPath('//div[contains(@class, "card-title")][text()="建築文化"]'); + } + + + /** @test */ + public function pageTitleShouldContainsOnlyKanjis() { + $this->assertXPath('//title[text()="建築文化"]'); + } + + + /** @test */ + public function pageMetaDCtitleShouldBeKenchikuBunka() { + $this->assertXPath('//meta[@property="dc.title"][@content="建築文化"]'); + } +} + + + + class TemplatesRecordsRechercheSimpleTest extends TemplateRecordsWithDescriptionAndUnimarcTest { public function setUp() { diff --git a/tests/scenarios/Templates/TemplatesSearchItemsTest.php b/tests/scenarios/Templates/TemplatesSearchItemsTest.php index d6048df200b1a6683bb3b58cffda88d4937acbdd..d3df48076a4eeba294acf3cfdcd4dc1ebbb5340a 100644 --- a/tests/scenarios/Templates/TemplatesSearchItemsTest.php +++ b/tests/scenarios/Templates/TemplatesSearchItemsTest.php @@ -324,4 +324,4 @@ class TemplatesSearchItemsModulesNoticeExemplairesMultiInputsTest '/admin/modulesnotice/exemplaires/id_profil/1'); $this->assertXPathContentContains('//script', 'values:{"datas_items_code":[],"datas_items_label":["Cote"]}'); } -} +} \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesWebsitesTest.php b/tests/scenarios/Templates/TemplatesWebsitesTest.php index 6864592a9811e85d32ad10a61cc302bd7f9a4c4c..8c606bb41b662e76f7cb66a18937532b300e6d79 100644 --- a/tests/scenarios/Templates/TemplatesWebsitesTest.php +++ b/tests/scenarios/Templates/TemplatesWebsitesTest.php @@ -431,6 +431,6 @@ class TemplatesWebsitesDispatchPaginatedTest extends TemplatesWebsitesFixturesTe $id = $helper->getId(); $this->dispatch('/opac/index/ajax-paginated-list/id/' . $id . '/page/1/render/ajax/id_profil/19'); - $this->assertContains('input_38bcd646a69f4da7fce8921d4cf762ad', $this->_response->getBody()); + $this->assertXPath('//form//input[@name="input_99914b932bd37a50b983c5e7c90ae93b"]'); } } \ No newline at end of file