diff --git a/FEATURES/55588 b/FEATURES/55588 new file mode 100644 index 0000000000000000000000000000000000000000..d59dc2b9480c84f62571d9675cbcf8f2cac19d27 --- /dev/null +++ b/FEATURES/55588 @@ -0,0 +1,10 @@ + '55588' => + ['Label' => $this->_('[contractuel] EXPLO SOLR Indexation en texte intégral des documents liés (pdf, html) (bulletins officiels) - Minsoc'), + 'Desc' => '', + 'Image' => '', + 'Video' => '', + 'Category' => '', + 'Right' => function($feature_description, $user) {return true;}, + 'Wiki' => '', + 'Test' => '', + 'Date' => '2019-04-01'], \ No newline at end of file diff --git a/VERSIONS_WIP/55588 b/VERSIONS_WIP/55588 new file mode 100644 index 0000000000000000000000000000000000000000..ceee8c0e3202fa46cf52a1b5374399a4f2748682 --- /dev/null +++ b/VERSIONS_WIP/55588 @@ -0,0 +1 @@ + - ticket #55588 : [contractuel] EXPLO SOLR Indexation en texte intégral des documents liés (pdf, html) (bulletins officiels) - Minsoc \ No newline at end of file diff --git a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php index bdcfdc9d61191bd3893c37c9ed287e954b00e074..07e6fed3bb9c2ed0d56cc176cafcef88612b90bf 100644 --- a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php +++ b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php @@ -358,6 +358,18 @@ class Cosmo_DataProfileControllerEditUnimarcKohaTest extends Cosmo_DataProfileCo } + /** @test */ + public function multiInputIndexFilesShouldBePresent() { + $this->assertXPath('//form//div[@id="multi_inputs_index_files"]'); + } + + + /** @test */ + public function inputIndexFileUriRegexDefaultValueShouldBeUserfilesFilesStarPDF() { + $this->assertXPathContentContains('//script', '"index_file_uri_regex":["\/userfiles\/files\/[a-zA-Z0-9_\\\-]+\\\.pdf"]'); + } + + /** @test */ public function selectRejetPeriodiquesShoudHaveNoSelected() { $this->assertXPathContentContains('//form//select[@id="rejet_periodiques"]/option[@value="0"][@selected]', 'Non'); @@ -431,6 +443,9 @@ class Cosmo_DataProfileControllerPostEditUnimarcKohaFileFormatTest extends Cosmo 'new'], 'interest_zone' => [0 => '932'], 'interest_champ' => [0 => '7'], + 'index_file_zone' => ['856'], + 'index_file_field' => ['u'], + 'index_file_uri_regex' => ['/userfiles/files/public/.+.pdf'], 'holds' => 'SUPPORT; SUPPORT', 'carts' => 'LIBELLE; ROLE', 'csv_item_fields' => 'ean;ean', @@ -549,10 +564,29 @@ class Cosmo_DataProfileControllerPostEditUnimarcKohaFileFormatTest extends Cosmo public function interestFieldShouldBe7() { $this->assertEquals('7', $this->_koha->getInterestField()); } + + + /** @test */ + public function indexFileZoneShouldBe856() { + $this->assertEquals('856', $this->_koha->getIndexFileZone()); + } + + + /** @test */ + public function indexFileFieldShouldBeU() { + $this->assertEquals('u', $this->_koha->getIndexFileField()); + } + + + /** @test */ + public function indexFildUriRegexShouldBeUserfilesPublic() { + $this->assertEquals('/userfiles/files/public/.+.pdf', $this->_koha->getIndexFileUriRegex()); + } } + class Cosmo_DataProfileControllerPostEditFieldsTest extends Cosmo_DataProfileControllerTestCase { protected $_nanook_profile; @@ -1110,7 +1144,10 @@ class Cosmo_DataProfileControllerMultiValuesTest extends Cosmo_DataProfileContro 4 => [], 5 => [], 6 => ['zone' => '995', - 'champ' => 'z'] + 'champ' => 'z'], + 7 => ['index_file_zone' => ['934'], + 'index_file_field' => ['u'], + 'index_file_uri_regex' => ['/.*']] ]]); $this->dispatch('cosmo/data-profile/edit/id/321', true); @@ -1146,6 +1183,15 @@ class Cosmo_DataProfileControllerMultiValuesTest extends Cosmo_DataProfileContro $this->assertXPathContentContains('//script', 'values:{"1_label":["am","bm","","em","mm","","","","","","",""],"1_zone":["BDA","BDJ","LFA","LFJ","LDA","LDJ","LCDA","LCDJ","PATIMP","PATMS","PERIP","PATINC"]}', $this->_response->getBody()); } + + + /** @test */ + public function indexFileShouldContainsZone934FieldURegexStar() { + $this->assertXPathContentContains('//script', 'values:{"index_file_zone":["934"],"index_file_field":["u"],"index_file_uri_regex":["\/.*"]}', + $this->_response->getBody()); + } + + } diff --git a/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php b/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php index b5140863edd40cf69ab1c329304350f0d0754c82..67c3d42b7d3caf5eb95767839376e2b04ddf72aa 100644 --- a/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php +++ b/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php @@ -496,3 +496,35 @@ class KohaRecordIntegrationEscapableAnnexeCodesTest extends KohaRecordIntegratio $this->assertEquals('CHYJR', $this->notice_data['exemplaires'][0]['annexe']); } } + + + + +class KohaRecordIntegrationPommeWithAttachedFileTest extends KohaRecordIntegrationTestCase { + public function getProfilDonnees() { + return Class_IntProfilDonnees::forKoha() + ->setIdProfil(111) + ->setIndexFile('856', 'u', '/userfiles/files/public/[a-zA-Z0-9_\-]+\.pdf') + ->getRawAttributes(); + } + + + public function setUp() { + parent::setUp(); + + $this->loadNotice('unimarc_pomme'); + $this->_notice = Class_Notice::find(1); + } + + + /** @test */ + public function titleShouldBeLaPommeDeTerre() { + $this->assertEquals('La pomme de terre', $this->_notice->getTitrePrincipal()); + } + + + /** @test */ + public function fileContentShouldContainsChlorprophame() { + $this->assertContains('chlorprophame', $this->_notice->getFileContent()); + } +} \ No newline at end of file diff --git a/cosmogramme/tests/php/classes/pomme.pdf b/cosmogramme/tests/php/classes/pomme.pdf new file mode 100644 index 0000000000000000000000000000000000000000..03540046580d04e896b9c62b8a29b37251e0661c Binary files /dev/null and b/cosmogramme/tests/php/classes/pomme.pdf differ diff --git a/cosmogramme/tests/php/classes/unimarc_pomme.txt b/cosmogramme/tests/php/classes/unimarc_pomme.txt new file mode 100644 index 0000000000000000000000000000000000000000..f341975fdec4c0243a379f20997e1bc00fb8a49d --- /dev/null +++ b/cosmogramme/tests/php/classes/unimarc_pomme.txt @@ -0,0 +1 @@ +00866 2200229 45000010005000000100025000050900009000301000041000392000048000802100025001282150037001532250016001901010008002063300120002146150017003346760010003516060034003617000027003954100016004228560038004389950160004764414 a2740417659d9.00 EUR a4414 a20040402d2004 a |0frey50 ||||ba1 a[La ]pomme de terrefTexte Anne RoyerbLIVR 1cMango-Jeunessed2004 1a32 p.cill. en coul.d25 x 20 cm1 aQui es-tu ? afre aPour tout savoir sur la pomme de terre : son histoire, sa plantation, sa récolte, les différentes varietés, etc. aDocumentaire 1a635.2 196068aLégumexPomme de terre 196067aRoyerbAnne4070 1tQui es-tu ? u/userfiles/files/public/pomme.pdf 2095418bMAUREScMAURESeDocumentaires adultef00519000087170kE 635.2m2014-12-23o0rLIVRh8717jLibrairie jeunesse au pays bleqJeunesp9,00s17/07/2004 \ No newline at end of file diff --git a/library/Class/IntProfilDonnees.php b/library/Class/IntProfilDonnees.php index 066498d0b4a525b495315dabdcbce4205404a87d..405b22a894569b6d8e28c95116b994769f52629c 100644 --- a/library/Class/IntProfilDonnees.php +++ b/library/Class/IntProfilDonnees.php @@ -876,6 +876,15 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { } + public function setIndexFile($zone, $field, $regex) { + $config = unserialize($this->getAttributs()); + $config[7] = ['index_file_zone' => [$zone], + 'index_file_field' => [$field], + 'index_file_uri_regex' => [$regex]]; + return $this->setAttributs($config); + } + + public function setItemField($name, $value) { $config = unserialize($this->getAttributs()); $config[0][$name] = $value; @@ -1085,6 +1094,22 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { } + public function getIndexFileZone() { + return $this->getProfilePrefs()->getIndexFileZone(); + } + + + public function getIndexFileField() { + return $this->getProfilePrefs()->getIndexFileField(); + } + + + public function getIndexFileUriRegex() { + return $this->getProfilePrefs()->getIndexFileUriRegex(); + } + + + public function getProfilePrefs() { if(!$this->_profile_prefs) $this->_profile_prefs = (new Class_ProfilePrefs())->setDatas($this->toArray()); diff --git a/library/Class/Notice.php b/library/Class/Notice.php index a19f11a27cbae72552be7614f571b4094646ca32..9e4955c78c44fc662e24b6bae94201188c1f69e3 100644 --- a/library/Class/Notice.php +++ b/library/Class/Notice.php @@ -206,7 +206,8 @@ class Class_Notice extends Storm_Model_Abstract { 'date_creation' => '', 'created_at' => null, 'type' => self::TYPE_BIBLIOGRAPHIC, - 'z3950_retry' => 0]; + 'z3950_retry' => 0, + 'file_content' => '']; public function __construct() { diff --git a/library/Class/ProfilePrefs.php b/library/Class/ProfilePrefs.php index fd8f2d1a5a72f73b63c9c862eb8a2bccabdcd40d..aff266f23a935f77a0fe23d8bd577d47f9305f80 100644 --- a/library/Class/ProfilePrefs.php +++ b/library/Class/ProfilePrefs.php @@ -118,13 +118,13 @@ class Class_ProfilePrefs extends Class_Entity { $default = ['interest_zone' => ['932'], 'interest_champ' => ['a']]; - if(!$interet_prefs = $this->getPrefs()[6]) + if (!$interet_prefs = $this->getPrefs()[6]) return $default; - if(!$interet_zone = $interet_prefs['zone']) + if (!$interet_zone = $interet_prefs['zone']) return $default; - if(!$interet_champ = $interet_prefs['champ']) + if (!$interet_champ = $interet_prefs['champ']) return $default; return ['interest_zone' => [$interet_zone], @@ -132,6 +132,32 @@ class Class_ProfilePrefs extends Class_Entity { } + public function getFileIndexation() { + $default = ['index_file_zone' => [''], + 'index_file_field' => [''], + 'index_file_uri_regex' => ['/userfiles/files/[a-zA-Z0-9_\-]+\.pdf']]; + $prefs = $this->getPrefs()[7]; + return $prefs + ? $prefs + : $default; + } + + + public function getIndexFileZone() { + return $this->getFileIndexation()['index_file_zone'][0]; + } + + + public function getIndexFileField() { + return $this->getFileIndexation()['index_file_field'][0]; + } + + + public function getIndexFileUriRegex() { + return $this->getFileIndexation()['index_file_uri_regex'][0]; + } + + public function getItemUrl() { $url_zone = $this->getItemUrlZone(); $url_champ = $this->getItemUrlChamp(); diff --git a/library/Class/ProfileSerializer/UnimarcRecord.php b/library/Class/ProfileSerializer/UnimarcRecord.php index 1bf6d6a7db80cd6af4201f2e6dd47e03525e1f16..6f003102d3727fd98cff1ac98ab6033541f7a12a 100644 --- a/library/Class/ProfileSerializer/UnimarcRecord.php +++ b/library/Class/ProfileSerializer/UnimarcRecord.php @@ -28,7 +28,8 @@ class Class_ProfileSerializer_UnimarcRecord extends Class_ProfileSerializer_Abst 3 => [], 4 => $this->_extractNovelty(), 5 => [], - 6 => $this->_extractInterests()]; + 6 => $this->_extractInterests(), + 7 => $this->_extractFileIndexation()]; } @@ -55,7 +56,8 @@ class Class_ProfileSerializer_UnimarcRecord extends Class_ProfileSerializer_Abst ->populateItemDocTypes(['label' => 'label', 'zone' => 'zone_995']) ->populateItemIdOrigine() ->populateItemUrl() - ->populateInterests(); + ->populateInterests() + ->populateFileIndexation(); } @@ -65,6 +67,13 @@ class Class_ProfileSerializer_UnimarcRecord extends Class_ProfileSerializer_Abst } + protected function _extractFileIndexation() { + return ['index_file_zone' => $this->_datas['index_file_zone'], + 'index_file_field' => $this->_datas['index_file_field'], + 'index_file_uri_regex' => $this->_datas['index_file_uri_regex']]; + } + + protected function _extractRecords() { return array_merge($this->_extractDocTypes(), $this->_extractItemFields(), diff --git a/library/ZendAfi/Form/Cosmo/DataProfile.php b/library/ZendAfi/Form/Cosmo/DataProfile.php index 887fbc0923149e96c91573e3e39211b1b472b070..43bcf8ea4be4644a0c1b3e99837b87279316feb8 100644 --- a/library/ZendAfi/Form/Cosmo/DataProfile.php +++ b/library/ZendAfi/Form/Cosmo/DataProfile.php @@ -147,7 +147,7 @@ class ZendAfi_Form_Cosmo_DataProfile extends ZendAfi_Form { ->addDocTypeGroup(['label' => $this->_('Label'), 'zone' => $this->_('Zone exemplaire')]) ->_recordNoveltyDate() ->_recordItemSerial() - ->_recordItemInterest(); + ->_recordIndexation(); } @@ -197,7 +197,7 @@ class ZendAfi_Form_Cosmo_DataProfile extends ZendAfi_Form { } - protected function _recordItemInterest() { + protected function _recordIndexation() { return $this->addElement('multiInput', 'interests', ['label' => $this->_('Prendre la zone centre d\'intérêts en'), @@ -205,8 +205,17 @@ class ZendAfi_Form_Cosmo_DataProfile extends ZendAfi_Form { ['name' => 'interest_champ', 'label' => $this->_('Champ')]], 'fixed' => true]) - ->addDisplayGroup(['interests'], - 'item_interests_group', + + ->addElement('multiInput', + 'index_files', + ['label' => $this->_('Indexer le contenu des fichiers spécifiés en'), + 'fields' => [['name' => 'index_file_zone', 'label' => $this->_('Zone')], + ['name' => 'index_file_field', 'label' => $this->_('Champ')], + ['name' => 'index_file_uri_regex', 'label' => $this->_('Chemin du fichier (expression régulière)')]], + 'fixed' => true]) + + ->addDisplayGroup(['interests', 'index_files'], + 'indexation_group', ['legend' => $this->_('Indexation')]); } @@ -465,6 +474,12 @@ class ZendAfi_Form_Cosmo_DataProfile extends ZendAfi_Form { } + public function populateFileIndexation() { + $this->index_files->setValues($this->_profile_prefs->getFileIndexation()); + return $this; + } + + public function setProfilePrefs($preferences) { $this->_profile_prefs = $preferences; }