From e0760f159efd39104cc975b2c37d0e42260a107c Mon Sep 17 00:00:00 2001 From: Laurent Laffont <llaffont@afi-sa.fr> Date: Fri, 25 Jan 2019 15:32:40 +0100 Subject: [PATCH] dev #34523dev #34523 create dynamic facets on 686 classificationsdev #34523 create dynamic facets on 686 classifications --- FEATURES/34523 | 10 +++ VERSIONS_WIP/34523 | 1 + .../modules/cosmo/views/scripts/module.phtml | 1 + .../DynamicFacetsControllerTest.php | 28 ++++++- cosmogramme/css/main.css | 6 ++ .../php/classes/KohaRecordIntegrationTest.php | 6 +- .../classes/NanookRecordsIntegrationTest.php | 72 ++++++++++++++++++ .../php/classes/NoticeIntegrationTest.php | 8 ++ .../tests/php/classes/NoticeUnimarcTest.php | 11 --- .../php/classes/unimarc_classifications.txt | 2 + library/Class/CodifThesaurus.php | 30 +++++++- library/Class/CodifThesaurus/Rules.php | 75 ++++++++++++++++--- .../Record/BibliographicDynamicFacets.php | 27 ++++--- library/Class/Notice.php | 3 +- library/Class/NoticeUnimarc.php | 43 ++++++++--- library/ZendAfi/Form/Admin/DynamicFacet.php | 19 ++++- .../ZendAfi/View/Helper/Admin/HelpLink.php | 5 +- 17 files changed, 290 insertions(+), 57 deletions(-) create mode 100644 FEATURES/34523 create mode 100644 VERSIONS_WIP/34523 create mode 100644 cosmogramme/tests/php/classes/unimarc_classifications.txt diff --git a/FEATURES/34523 b/FEATURES/34523 new file mode 100644 index 00000000000..ae1bc4e7908 --- /dev/null +++ b/FEATURES/34523 @@ -0,0 +1,10 @@ + '34523' => + ['Label' => $this->_('[Story] Gestion des classifications autres que PCDM4 et Dewey'), + 'Desc' => '', + 'Image' => '', + 'Video' => '', + 'Category' => '', + 'Right' => function($feature_description, $user) {return true;}, + 'Wiki' => '', + 'Test' => '', + 'Date' => '2019-01-25'], \ No newline at end of file diff --git a/VERSIONS_WIP/34523 b/VERSIONS_WIP/34523 new file mode 100644 index 00000000000..6d584752a3f --- /dev/null +++ b/VERSIONS_WIP/34523 @@ -0,0 +1 @@ + - ticket #34523 : [Story] Gestion des classifications autres que PCDM4 et Dewey \ No newline at end of file diff --git a/cosmogramme/cosmozend/application/modules/cosmo/views/scripts/module.phtml b/cosmogramme/cosmozend/application/modules/cosmo/views/scripts/module.phtml index 0c8c66939f5..6a0a898dcfa 100644 --- a/cosmogramme/cosmozend/application/modules/cosmo/views/scripts/module.phtml +++ b/cosmogramme/cosmozend/application/modules/cosmo/views/scripts/module.phtml @@ -58,6 +58,7 @@ $script_loader = Class_ScriptLoader::getInstance(); ?> </head> <body class="droite"> + <?php echo $this->helpLink($this->action); ?> <?php echo $html; ?> </body> </html> diff --git a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DynamicFacetsControllerTest.php b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DynamicFacetsControllerTest.php index 029e4d57336..ca4047fa16f 100644 --- a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DynamicFacetsControllerTest.php +++ b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DynamicFacetsControllerTest.php @@ -110,6 +110,18 @@ class Cosmo_DynamicFacetsControllerAddTest extends CosmoControllerTestCase { } + /** @test */ + public function pageShouldContainsSelectForFilterField() { + $this->assertXPath('//select[@name="rule_filter_field"]'); + } + + + /** @test */ + public function pageShouldContainsInputForFilterValue() { + $this->assertXPath('//input[@name="rule_filter_value"]'); + } + + /** @test */ public function labelForBokehShouldBePresent() { $this->assertXPath('//input[@name="libelle_facette"][@value="** nouvelle facette dynamique **"]'); @@ -141,7 +153,9 @@ class Cosmo_DynamicFacetsControllerAddPostValidTest extends CosmoControllerTestC 'rule_label_field' => 'a', 'rule_id_field' => '9', 'rule_label_start_pos' => '2', - 'rule_label_length' => '4']); + 'rule_label_length' => '4', + 'rule_filter_field' => 't', + 'rule_filter_value' => 'Take me']); Class_CodifThesaurus::clearCache(); $this->model = Class_CodifThesaurus::findFirstBy(['libelle' => 'New facet name']); @@ -188,6 +202,18 @@ class Cosmo_DynamicFacetsControllerAddPostValidTest extends CosmoControllerTestC public function rulesLabelLengthShouldBeFour() { $this->assertEquals('4', $this->model->getRulesAsArray()['rule_label_length']); } + + + /** @test */ + public function ruleFilterFieldShouldBeT() { + $this->assertEquals('t', $this->model->getRulesAsArray()['rule_filter_field']); + } + + + /** @test */ + public function ruleFilterValueShouldBeTakeMe() { + $this->assertEquals('Take me', $this->model->getRulesAsArray()['rule_filter_value']); + } } diff --git a/cosmogramme/css/main.css b/cosmogramme/css/main.css index e75480d69d4..cb599d9ec14 100644 --- a/cosmogramme/css/main.css +++ b/cosmogramme/css/main.css @@ -321,3 +321,9 @@ table.tablesorter > tbody > tr:hover td { .table_tooltip_wrapper:hover .table_tooltip { display: block; } + +a.ardans_help { + position: absolute; + right: 100px; + top: 10px; +} \ No newline at end of file diff --git a/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php b/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php index effbfc65605..b5140863edd 100644 --- a/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php +++ b/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php @@ -23,6 +23,8 @@ require_once('NoticeIntegrationTest.php'); abstract class KohaRecordIntegrationTestCase extends NoticeIntegrationTestCase { + protected $_storm_default_to_volatile = true; + public function getProfilDonnees() { return Class_IntProfilDonnees::forKoha()->getRawAttributes(); } @@ -214,7 +216,7 @@ class KohaRecordIntegrationFacetPresseTest extends KohaRecordIntegrationTestCase /** @test */ public function facettesShouldContainsT2AndHANNE0001AndHMOIS0001AndJOUR0001() { - $this->assertEquals('HANNE0001 HMOIS0001 HJOUR0001 Lfre T2 B1 YMEDSTMAR', + $this->assertEquals('HANNE0001 HMOIS0001 HJOUR0001 T2 B1 YMEDSTMAR', Class_Notice::find(1) ->updateFacetsFromExemplaires() ->getFacettes()); @@ -223,7 +225,7 @@ class KohaRecordIntegrationFacetPresseTest extends KohaRecordIntegrationTestCase /** @test */ public function facettesForRecord25ShouldContainsT2AndHANNE0001AndHMOIS0001() { - $this->assertEquals('HANNE0001 HMOIS0007 HJOUR0006 Lfre T2 B1 YMEDSTMAR', + $this->assertEquals('HANNE0001 HMOIS0007 HJOUR0006 T2 B1 YMEDSTMAR', Class_Notice::find(25) ->updateFacetsFromExemplaires() ->getFacettes()); diff --git a/cosmogramme/tests/php/classes/NanookRecordsIntegrationTest.php b/cosmogramme/tests/php/classes/NanookRecordsIntegrationTest.php index 2b2d3cfde1b..44c24977976 100644 --- a/cosmogramme/tests/php/classes/NanookRecordsIntegrationTest.php +++ b/cosmogramme/tests/php/classes/NanookRecordsIntegrationTest.php @@ -177,6 +177,8 @@ class NanookRecordsIntegrationSymphonieTest extends NanookRecordsIntegrationTest /** @see http://forge.afi-sa.fr/issues/16628 */ class NanookRecordsIntegrationInterestEsperluetteTest extends NanookRecordsIntegrationTestCase { + protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); @@ -515,4 +517,74 @@ class NanookRecordsIntegrationSerialLiensFamiliauxTest extends NanookRecordsInte public function firstArticleShouldBeOnEstPasDesChiens() { $this->assertEquals("Revue Quart Monde n° 231<br /> «On n’est pas des chiens !» : Editorial", $this->notice->getArticlesPeriodique()[0]['titre']); } +} + + + + +class NanookRecordsIntegrationMultiClassificationTest extends NanookRecordsIntegrationTestCase { + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + + $this->fixture('Class_CodifThesaurus', + ['id' => 1, + 'libelle' => 'Jeux - ESAR', + 'id_thesaurus' => 'ESAR', + 'id_origine' => null, + 'code' => 'esar', + 'rule_zone' => '686', + 'rule_label_field' => 't', + 'rule_id_field' => 'a', + 'rule_filter_field' => '2', + 'rule_filter_value' => 'ESAR (Ludothèque)' + ]); + + + $this->fixture('Class_CodifThesaurus', + ['id' => 2, + 'libelle' => 'Jeux - durée', + 'id_thesaurus' => 'JDUR', + 'id_origine' => null, + 'code' => 'jduree', + 'rule_zone' => '686', + 'rule_label_field' => 't', + 'rule_id_field' => 'a', + 'rule_filter_field' => '2', + 'rule_filter_value' => 'Ludo - Durée partie' + ]); + + $this->loadRecordsFromFile("unimarc_classifications"); + } + + + /** @test */ + public function firstRecordFacetsShouldContainsHESAR0001AndHJDUR0001() { + $this->assertEquals('HESAR0001 HJDUR0001 A1 F1 F2', Class_Notice::find(1)->getFacettes()); + } + + + /** @test */ + public function secondRecordFacetsShouldContainsHESAR0002AndHJDUR0002() { + $this->assertEquals('HESAR0002 HJDUR0002 F3 F4', + Class_Notice::find(2)->getFacettes()); + } + + + /** @test */ + public function codifHESAR0001ValueShouldBeJeuDeStrategie() { + $this->assertNotNull(Class_CodifThesaurus::findFirstBy(['id_thesaurus' => 'ESAR0001', + 'id_origine' => 'A503', + 'libelle' => 'JEU DE STRATEGIE COMPLEXE'])); + } + + + /** @test */ + public function codifHESAR0002ValueShouldBeJeuDAgencement() { + $this->assertNotNull(Class_CodifThesaurus::findFirstBy(['id_thesaurus' => 'ESAR0002', + 'id_origine' => 'A302', + 'libelle' => 'JEU D\'AGENCEMENT'])); + } } \ No newline at end of file diff --git a/cosmogramme/tests/php/classes/NoticeIntegrationTest.php b/cosmogramme/tests/php/classes/NoticeIntegrationTest.php index bbc65566e15..d97564beca9 100644 --- a/cosmogramme/tests/php/classes/NoticeIntegrationTest.php +++ b/cosmogramme/tests/php/classes/NoticeIntegrationTest.php @@ -162,6 +162,7 @@ abstract class NoticeIntegrationTestCase extends ModelTestCase { class NoticeIntegrationLollipopGeneratedNoticeRecordTest extends NoticeIntegrationTestCase { public function setUp() { parent::setUp(); + $this->loadNotice('unimarc_lollipop'); } @@ -1102,6 +1103,9 @@ class NoticeIntegrationConcertoSaintSaensTest extends NoticeIntegrationTestCase /** @see http://forge.afi-sa.fr/issues/17605 */ class NoticeIntegrationArchivesAlsaceTest extends NoticeIntegrationTestCase { + protected $_storm_default_to_volatile = true; + + public function getProfilDonnees() { return Class_IntProfilDonnees::forKarvi() ->setIdProfil(110) @@ -1112,6 +1116,10 @@ class NoticeIntegrationArchivesAlsaceTest extends NoticeIntegrationTestCase { public function setUp() { parent::setUp(); + $this->fixture('Class_CodifLangue', + ['id' => 'fre', + 'libelle' => 'Français']); + $this->fixture('Class_CodifMatiere', ['id' => 1, 'libelle' => 'Alsace (France) : Descriptions Et Voyages : Vues : 1870-1914', diff --git a/cosmogramme/tests/php/classes/NoticeUnimarcTest.php b/cosmogramme/tests/php/classes/NoticeUnimarcTest.php index 6ab7b880324..dbc34804b53 100644 --- a/cosmogramme/tests/php/classes/NoticeUnimarcTest.php +++ b/cosmogramme/tests/php/classes/NoticeUnimarcTest.php @@ -27,17 +27,6 @@ require_once 'NoticeIntegrationTest.php'; -class NoticeUnimarcThesaurusFieldTest extends ModelTestCase { - /** @test */ - public function decoupeBlocThesaurusShouldReturn() { - $unimarc = new Class_NoticeUnimarc(); - $this->assertEquals([['code' => 'a', 'valeur' => 'GDOC005'], - ['code' => '2' , 'valeur' => 'genreelectre']], - $unimarc->decoupe_bloc_champ_thesaurus(' aGDOC0052genreelectre')); - } -} - - /** @see http://forge.afi-sa.fr/issues/24999 */ class NoticeUnimarcMultipleIsbnTest extends NoticeIntegrationTestCase { diff --git a/cosmogramme/tests/php/classes/unimarc_classifications.txt b/cosmogramme/tests/php/classes/unimarc_classifications.txt new file mode 100644 index 00000000000..9c00cc9afe7 --- /dev/null +++ b/cosmogramme/tests/php/classes/unimarc_classifications.txt @@ -0,0 +1,2 @@ +01639nrm0 2200217 450 001000700000100001300007200001700020210001000037300040100047300002200448330062700470686002701097686004901124686004601173686005601219700002001275801004201295932001301337932001401350995005701364118658 a201601161 a20EME SIECLE gIello a45 tuiles de territoire, 30 tuiles de technologie, 1 plateau de jeu, 5 plateaux de jeu individuels, 1 tuil de coût de technologie double face, 1 pion de joueur, 20 jetons de population, 1 compteur de score, 95 jetons de déchets, 4 ponts, 1 marqueur de coût de technologie, 1 compteur de tours, 6 cartes de score, 9 cartes de catastrophe, 94 cartes figurant les pièces et les points de science aune règle du jeu aComme toutes les autres nations, votre pays est engagé dans une course au progrès et au développement. Science et commerce contribuent à façonner son avenir, mais à quel prix? La prospérité ne peut se faire qu'en polluant toujours plus et les grandes avancées technologique peuvent être désastreuses pour l'environnement. Comment ferez-vous face aux inévitables catastrophes écologiques qui vous attendent? En tant que dirigeant, votre mission est de faire de votre pays un lieu où écologie rime avec prospérité. Si vous y parvenez, votre nation sera alors considérée comme véritablement développée. aA12+tA12+2Ludo - Age a3-5 JOUEURSt3-5 JOUEURS2Ludo - Nb joueurs aPLUS 1 HtPLUS 1 H2Ludo - Durée partie aA503tJEU DE STRATEGIE COMPLEXE2ESAR (Ludothèque) 1aSuchybVladimir 2aFrbLes Halles Chateaugironc20190123 aTACTIQUE aPLACEMENT aLudothèquef1906kRO6Bm20190123qurzj31906opv100528nrm0 2200181 450 001000700000100001300007200001400020210000700034300002800041686002500069686004300094686004800137686004700185801004200232932001200274932001000286995005000296118659 a201512051 a3 PUZZLES cMB a3 puzzles de 50 pièces aA5+tA5+2Ludo - Age a1 JOUEURt1 JOUEUR2Ludo - Nb joueurs a30 MN MAXt30 MN MAX2Ludo - Durée partie aA302tJEU D'AGENCEMENT2ESAR (Ludothèque) 2aFrbLes Halles Chateaugironc20190123 aANIMAUX aChats aLudothèquef0687m20190123qurzj3687opv100450nrm0 2200145 450 001000700000100001300007200002500020210002000045300003100065686002500096686004300121686004800164801004200212995005000254118661 a201306281 a4 X 4 TERRAIN BUSTER cL'ARBRE A JOUER avehicule sur grosses roues aA7+tA7+2Ludo - Age a1 JOUEURt1 JOUEUR2Ludo - Nb joueurs a15 MN MAXt15 MN MAX2Ludo - Durée partie 2aFrbLes Halles Chateaugironc20190123 aLudothèquef0379m20190123qurzj3379opv100312nrm0 2200109 450 001000700000100001300007200001400020300005000034686002500084801004200109995005100151118662 a201305311 a50 FORMES a50 formes en bois, (cf boite pour le détail) aA2+tA2+2Ludo - Age 2aFrbLes Halles Chateaugironc20190123 aLudothèquef1531m20190123qurzj31531opv101216nrm0 2200205 450 001000700000100001300007200003700020210002100057300022300078330037700301686002500678686004900703686004800752686004800800702001900848801004200867932001200909932003200921995005700953118680 a201604011 aA VOS TRÉSORS, PRÊTS, PARTEZ ! aBad RodachcHaba a 1 plateau de jeu, 4 animaux (girafe, crocodile, rhinocéros, zèbre), 6 cubes de couleurs (2 rouges, 2 bleus, 2 jaunes), 120 cartes, 8 trésors (plaquettes rondes en carton), 1 dé symboles, 1 sablier, 1 règle du jeu aQuel remue-ménage sur l'île aux trésors! Les chasseurs de trésors sont de nouveau à la recherche des pièces d'or du célèbre aventurier Sabremain. Mais avant de pouvoir s'accaparer d'un trésor, ils doivent exécuter des actions pas faciles demandées par l'aventurier. Et seul celui qui les accomplira dans le temps voulu pourra récupérer plein de pièces d'or. aA5+tA5+2Ludo - Age a2-4 JOUEURSt2-4 JOUEURS2Ludo - Nb joueurs a20 MN MAXt20 MN MAX2Ludo - Durée partie aA401tJEU D'ASSOCIATION2ESAR (Ludothèque) 1aFragabRoberto 2aFrbLes Halles Chateaugironc20190123 aANIMAUX aexplorateurs et aventuriers aLudothèquef1215kR01Vm20190123qurzj31215opv100531nrm0 2200145 450 001000700000100001300007200001900020300008600039686002600125686004300151686004800194686005000242801004200292995005100334118683 a201510031 aABC MAGNET-BOX alettres en bois magnétiques, - 26 majuscules , -102 minuscules (dont 2 tirets), aA6+tA6+ 2Ludo - Age a1 JOUEURt1 JOUEUR2Ludo - Nb joueurs a45 MN MAXt45 MN MAX2Ludo - Durée partie aA301tJEU DE CONSTRUCTION2ESAR (Ludothèque) 2aFrbLes Halles Chateaugironc20190123 aLudothèquef1592m20190123qurzj31592opv101041nrm0 2200229 450 001000700000100001300007200001400020210002800034300011200062301006900174330017700243686004200420686002500462686004900487686004800536801004200584932001700626932001200643995004900655995005600704995005100760118686 a201603041 aACROBATES aAllemagnecRavensburger a31 acrobates:, - 8 rouges, - 8 bleus, - 8 verts, - 8 jaunes , - 1 noir, 1support plastique, 1 règle du jeu a2366: 29 grands acrobates, 1 socle, 1 règle du jeu plastifiée. aBut du jeu: Essaie de construire la tour la plus haute. Veille à ne pas faire tomber d'acrobates, car le gagnant sera celui qui aura posé tous ses acrobates en premier. + aA405tJEU SPORTIF2ESAR (Ludothèque) aA5+tA5+2Ludo - Age a1-4 JOUEURSt1-4 JOUEURS2Ludo - Nb joueurs a20 MN MAXt20 MN MAX2Ludo - Durée partie 2aFrbLes Halles Chateaugironc20190123 aCONSTRUCTION aADRESSE aLudothèquef0026m20190123qurzj326odv0 aLudothèquef0428kR04Jm20190123qurzj3428odv0 aLudothèquef2366kR04Jm20190123qurzjopv1 \ No newline at end of file diff --git a/library/Class/CodifThesaurus.php b/library/Class/CodifThesaurus.php index d132f694d38..6d148193a54 100644 --- a/library/Class/CodifThesaurus.php +++ b/library/Class/CodifThesaurus.php @@ -590,6 +590,19 @@ class Class_CodifThesaurus extends Storm_Model_Abstract { } + public function setRuleFilterField($field) { + $this->_rules->setFilterField($field); + return $this; + } + + + public function setRuleFilterValue($field) { + $this->_rules->setFilterValue($field); + return $this; + } + + + public function setRuleLabelLength($value) { $this->_rules->setLabelLength($value); return $this; @@ -616,7 +629,9 @@ class Class_CodifThesaurus extends Storm_Model_Abstract { 'rule_label_field' => $this->_rules->getLabelField(), 'rule_id_field' => $this->_rules->getIdField(), 'rule_label_start_pos' => $this->_rules->getLabelStartPos(), - 'rule_label_length' => $this->_rules->getLabelLength()]; + 'rule_label_length' => $this->_rules->getLabelLength(), + 'rule_filter_field' => $this->_rules->getFilterField(), + 'rule_filter_value' => $this->_rules->getFilterValue()]; } @@ -687,8 +702,17 @@ class Class_CodifThesaurus extends Storm_Model_Abstract { } - public function withLabelRulesDo($closure) { - return $this->_rules->withLabelFieldDo($closure); + public function withRulesDo($closure) { + if ((!$this->_rules->getZone()) + || (!$this->_rules->getLabelField())) + return; + + return $closure($this->_rules); + } + + + public function rulesCanHandle($reader) { + return $this->_rules->canHandle($reader); } diff --git a/library/Class/CodifThesaurus/Rules.php b/library/Class/CodifThesaurus/Rules.php index 4315312db7d..f9b054539d6 100644 --- a/library/Class/CodifThesaurus/Rules.php +++ b/library/Class/CodifThesaurus/Rules.php @@ -27,10 +27,12 @@ class Class_CodifThesaurus_Rules extends Class_Entity { $_attribs = ['LabelStartPos' => 1, 'LabelLength' => 0], $_persistent_attribs = ['Zone', - 'LabelField', - 'IdField', - 'LabelStartPos', - 'LabelLength']; + 'LabelField', + 'IdField', + 'LabelStartPos', + 'LabelLength', + 'FilterField', + 'FilterValue']; public function initialize($datas) { @@ -85,15 +87,59 @@ class Class_CodifThesaurus_Rules extends Class_Entity { } - public function withLabelFieldDo($closure) { - if ((!$zone = $this->getZone()) - || (!$field = $this->getLabelField())) - return; - return $closure($this->getZonePadded(), trim($field)); + /** + * @param $reader cosmogramme notice_unimarc + */ + protected function _getZonesToParse($reader) { + $zones = array_map(function($bloc) use ($reader) + { + return $reader->parseZoneFields($bloc); + }, + $reader->get_subfield($this->getZonePadded())); + + $filter_zone = $this->getZone(); + $filter_field = $this->getFilterField(); + $filter_value = $this->getFilterValue(); + if (!$filter_zone || (null === $filter_field) | !$filter_value) + return $zones; + + return array_filter($zones, + function($fields) use ($filter_field, $filter_value) + { + return (isset($fields[$filter_field]) + && + ($fields[$filter_field] === $filter_value)); + }); } + /** + * @param $reader cosmogramme notice_unimarc + */ + public function extractIdAndFields($reader) { + $label_field = trim($this->getLabelField()); + $id_field = trim($this->getIdField()); + + $id_labels = array_map(function($fields) use ($label_field, $id_field) + { + if (!isset($fields[$label_field])) + return null; + + $label = $this->truncateLabel($fields[$label_field]); + if (!$this->isValidLabel($label)) + return null; + + $id = (isset($fields[$id_field]) ? $fields[$id_field] : null); + return ['id' => strtoupper($this->isValidLabel($id) ? $id : $label), + 'label' => $label]; + }, + $this->_getZonesToParse($reader)); + return array_filter($id_labels); + } + + + public function truncateLabels($labels) { return array_filter( array_map([$this, 'truncateLabel'], $labels), @@ -102,9 +148,14 @@ class Class_CodifThesaurus_Rules extends Class_Entity { public function truncateLabel($label) { - return substr($label, - max(0, $this->getLabelStartPos()-1), - $this->getLabelLength()); + if (!$this->getLabelLength()) + return $label; + + return $this->isValidLabel($label) + ? substr($label, + max(0, $this->getLabelStartPos()-1), + $this->getLabelLength()) + : ''; } diff --git a/library/Class/Cosmogramme/Integration/Record/BibliographicDynamicFacets.php b/library/Class/Cosmogramme/Integration/Record/BibliographicDynamicFacets.php index 4ec66244804..88b4276a82c 100644 --- a/library/Class/Cosmogramme/Integration/Record/BibliographicDynamicFacets.php +++ b/library/Class/Cosmogramme/Integration/Record/BibliographicDynamicFacets.php @@ -27,7 +27,7 @@ class Class_Cosmogramme_Integration_Record_BibliographicDynamicFacets { foreach (Class_CodifThesaurus::findAllBy(['rules not' => null]) as $thesaurus) $thesauri = array_merge($thesauri, $this->_newFor($thesaurus, $int_bib)->thesauriOf($reader)); - return $thesauri; + return array_filter($thesauri); } @@ -50,15 +50,22 @@ class Class_Cosmogramme_Integration_Record_BibliographicDynamicFacets_Simple { public function thesauriOf($reader) { - $labels = $this->_thesaurus - ->withLabelRulesDo( - function($field, $subfield) use($reader) { - return $reader->get_subfield($field, $subfield); - }); - if ($this->_thesaurus->getRuleLabelLength()) - $labels = $this->_thesaurus->rulesTruncateLabels($labels); - - return $this->_thesaurus->getOrCreateChildren($labels); + return $this->_thesaurus + ->withRulesDo( + function($rules) use($reader) { + return $this->_getOrCreateChildren($rules, $reader); + }); + } + + + protected function _getOrCreateChildren($rules, $reader) { + $id_labels = $rules->extractIdAndFields($reader); + return array_map(function($id_label) + { + return $this->_thesaurus->getOrCreateChild($id_label['id'], + $id_label['label']); + }, + $id_labels); } } diff --git a/library/Class/Notice.php b/library/Class/Notice.php index c1feac0a3e3..d28aa97a2d5 100644 --- a/library/Class/Notice.php +++ b/library/Class/Notice.php @@ -206,7 +206,8 @@ class Class_Notice extends Storm_Model_Abstract { 'url_image' => '', 'date_creation' => '', 'created_at' => null, - 'type' => self::TYPE_BIBLIOGRAPHIC]; + 'type' => self::TYPE_BIBLIOGRAPHIC, + 'z3950_retry' => '']; public function __construct() { diff --git a/library/Class/NoticeUnimarc.php b/library/Class/NoticeUnimarc.php index 91eddde2192..12c10094b5f 100644 --- a/library/Class/NoticeUnimarc.php +++ b/library/Class/NoticeUnimarc.php @@ -183,24 +183,43 @@ class Class_NoticeUnimarc { $fields = explode($this->subfield_begin, $bloc); foreach($fields as $field) $sc[] = $num == true - ? [substr($field, 0, 1), substr($field, 1)] - : ['code' => substr($field, 0, 1), 'valeur' => substr($field, 1)]; + ? [substr($field, 0, 1), trim(substr($field, 1))] + : ['code' => substr($field, 0, 1), 'valeur' => trim(substr($field, 1))]; return (0 == count($sc)) ? null : $sc; } - public function decoupe_bloc_champ_thesaurus($bloc) - { - $bloc=substr($bloc,3); - $champs=explode($this->subfield_begin,$bloc); - for($j=0;$j<count($champs); $j++) - { - $sc[$j]["code"]=substr($champs[$j],0,1); - $sc[$j]["valeur"]=substr($champs[$j],1); - } - return $sc; + /** + * ex: $unimarc->parseZone(686) + * + * answers: + * [ + * [ 'a' => 'A12+' + * 't' => 'A12+' + * '2' => 'Ludo - Age'], + * + * [ 'a' => '3-5J' + * 't' => '3-5 JOUEURS' + * '2' => 'Ludo - Nb joueurs'] + * ] + */ + public function parseZone($zone) { + return array_map(function($bloc) + { + return $this->parseZoneFields($bloc); + }, + $this->get_subfield($this->getZonePadded())); + } + + + /** @see parseZone */ + public function parseZoneFields($marc) { + $fields = []; + foreach(explode($this->subfield_begin, substr($marc,3)) as $field) + $fields[substr($field, 0, 1)] = trim(substr($field, 1)); + return $fields; } diff --git a/library/ZendAfi/Form/Admin/DynamicFacet.php b/library/ZendAfi/Form/Admin/DynamicFacet.php index 08a3791067d..730bbd93295 100644 --- a/library/ZendAfi/Form/Admin/DynamicFacet.php +++ b/library/ZendAfi/Form/Admin/DynamicFacet.php @@ -40,6 +40,12 @@ class ZendAfi_Form_Admin_DynamicFacet extends ZendAfi_Form { 'required' => true, 'allowEmpty' => false]) + + ->addElement('text', + 'libelle_facette', + ['label' => $this->_('Libellé dans le résultat de recherche')]) + + ->addElement('text', 'rule_zone', ['label' => $this->_('Zone'), @@ -64,7 +70,6 @@ class ZendAfi_Form_Admin_DynamicFacet extends ZendAfi_Form { 'allowEmpty' => false, 'min' => 1]) - ->addElement('number', 'rule_label_length', ['label' => $this->_('Longueur du libellé (0 pour prendre totalité du libellé)'), @@ -74,12 +79,18 @@ class ZendAfi_Form_Admin_DynamicFacet extends ZendAfi_Form { ->addElement('select', 'rule_id_field', - ['label' => $this->_('Prendre l\'identifiant en'), + ['label' => $this->_('Prendre l\'identifiant/indice en'), + 'multiOptions' => $field_options]) + + + ->addElement('select', + 'rule_filter_field', + ['label' => $this->_('Filtrer l\'application de la facette par le champ'), 'multiOptions' => $field_options]) ->addElement('text', - 'libelle_facette', - ['label' => $this->_('Libellé dans Bokeh')]) + 'rule_filter_value', + ['label' => $this->_('Le champ de filtrage doit contenir la valeur')]) ->addElement('text', 'code', diff --git a/library/ZendAfi/View/Helper/Admin/HelpLink.php b/library/ZendAfi/View/Helper/Admin/HelpLink.php index 516eacce6de..149d4ea69da 100644 --- a/library/ZendAfi/View/Helper/Admin/HelpLink.php +++ b/library/ZendAfi/View/Helper/Admin/HelpLink.php @@ -107,7 +107,10 @@ class ZendAfi_View_Helper_Admin_HelpLinkBokehWiki { 'stat' => ['matomo' => 'Matomo'], 'print' => ['index' => 'Imprimer_un_résultat_de_recherche,_une_notice_ou_des_articles'], 'file-manager' => ['index' => 'Explorateur_de_fichiers'], - 'url-manager' => ['index' => 'Gestion_des_URL'] + 'url-manager' => ['index' => 'Gestion_des_URL'], + 'facets' => ['index' => 'Facettes_dynamiques'], + 'data-profile' => ['index' => 'Catégorie:Profils_de_données'], + 'integration' => ['index' => 'Import_d\'un_étalon'] ]; -- GitLab