diff --git a/FEATURES/110215 b/FEATURES/110215 new file mode 100644 index 0000000000000000000000000000000000000000..62c9df431f55155e2cbb07f2c192999176783204 --- /dev/null +++ b/FEATURES/110215 @@ -0,0 +1,10 @@ + '110215' => + ['Label' => $this->_('Evolution du moteur de recherche'), + 'Desc' => $this->_('Indexation plus large des titres, auteurs, sujets... pour améliorer la pertinence de la recherche. Introduction de la recherche par expression, en mettant plusieurs mots entre "". Nécessite un export total du SIGB'), + 'Image' => '', + 'Video' => '', + 'Category' => $this->_('Moteur de recherche'), + 'Right' => function($feature_description, $user) {return true;}, + 'Wiki' => 'https://wiki.bokeh-library-portal.org/index.php?title=Indexation_et_Recherche#Pond.C3.A9ration_et_classement_des_r.C3.A9sultats', + 'Test' => '', + 'Date' => '2022-02-24'], \ No newline at end of file diff --git a/VERSIONS_WIP/110215 b/VERSIONS_WIP/110215 new file mode 100644 index 0000000000000000000000000000000000000000..11267d7182250734f2ab13a50292585b6a7b2bee --- /dev/null +++ b/VERSIONS_WIP/110215 @@ -0,0 +1 @@ + - fonctionnalité #110215 : Moteur de recherche : Indexation plus large des titres, auteurs, sujets... pour améliorer la pertinence de la recherche. Introduction de la recherche par expression, en mettant plusieurs mots entre "". Nécessite un export total du SIGB \ No newline at end of file diff --git a/cosmogramme/php/_menu.php b/cosmogramme/php/_menu.php index 300264d45f83ba239c94598f705e85da469be578..a64b70cb57f66500a59c2c942813ed66dfe400bc 100644 --- a/cosmogramme/php/_menu.php +++ b/cosmogramme/php/_menu.php @@ -34,15 +34,12 @@ if($_SESSION["passe"] == "catalogueur") <a href="<?php print(URL_BASE . "index.php?action=logout");?>" target="_top"><img src="<?php print(URL_IMG); ?>deconnexion.gif" style="cursor:pointer;margin-top:5px;margin-left:10px" title="Se déconnecter" border="0"></a> <div class="menu_section">Recherches</div> <?php - ligneMenu("Recherche de notices","recherche_recherche.php"); ligneMenu("Accès notices par identifiants","recherche_identifiants.php"); ?> <div class="menu_section">Autorités et codifications</div> <?php ligneMenu("Auteurs","codif_auteur.php"); ligneMenu("Matières","codif_matiere.php"); - ligneMenu("Indices Dewey","codif_dewey.php"); - ligneMenu("Indices PCDM4","codif_pcdm4.php"); ?> <div class="menu_section">Statistiques</div> <?php @@ -83,11 +80,9 @@ else ?> <div class="menu_section">Recherches</div> <?php - ligneMenu("Recherche de notices","recherche_recherche.php"); ligneMenu("Accès notices par identifiants","recherche_identifiants.php"); ligneMenu("Nuages de tags Auteurs","recherche_tags_auteurs.php"); ligneMenu("Nuages de tags tous mots","recherche_tags.php"); - ligneMenu("Recherche guidée","recherche_guide.php?mode=INTRO"); ?> <div class="menu_section">Configurations</div> <?php @@ -106,8 +101,6 @@ else ligneMenu("Emplacements", '../cosmozend/cosmo/emplacement'); ligneMenu("Auteurs","codif_auteur.php"); ligneMenu("Matières","codif_matiere.php"); - ligneMenu("Indices Dewey","codif_dewey.php"); - ligneMenu("Indices PCDM4","codif_pcdm4.php"); ligneMenu("Facettes dynamiques","../cosmozend/cosmo/facets/index"); ?> <div class="menu_section">Statistiques</div> @@ -143,4 +136,4 @@ function ligneMenu( $texte, $url,$confirmation=false) print($texte); print('</a></div>'); } -?> \ No newline at end of file +?> diff --git a/cosmogramme/php/classes/classe_dewey.php b/cosmogramme/php/classes/classe_dewey.php deleted file mode 100644 index 407d1301679969607c447f2d677aaa09557134bc..0000000000000000000000000000000000000000 --- a/cosmogramme/php/classes/classe_dewey.php +++ /dev/null @@ -1,158 +0,0 @@ -<?PHP -/** - * Copyright (c) 2012, 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 dewey { - - public function getIndicesSanslibelle($indice, $limite) { - global $sql; - $liste = []; - if ($indice) - $where = "and id_dewey like '$indice%'"; - - $handle = $sql->prepareListe("Select id_dewey from codif_dewey Where LENGTH(id_dewey)=$limite and libelle ='' ".$where." order by id_dewey"); - while ($indice = $sql->fetchNext($handle,true)) - $liste[] = $this->formatIndice($indice); - - return $liste; - } - - - static function getIndices($pere) { - global $sql; - if ($pere == "root") - return $sql->fetchAll("select * from codif_dewey where LENGTH(id_dewey)=1 order by id_dewey"); - - $long = strlen($pere)+1; - $req = "select * from codif_dewey where id_dewey like '$pere%' and LENGTH(id_dewey)=$long order by id_dewey"; - return $sql->fetchAll($req); - } - - - static function formatIndice($indice) { - if(strlen($indice)< 4) - return $indice; - - $new = ''; - while(strlen($indice) > 3) { - $new .= substr($indice,0,3) . "."; - $indice = substr($indice, 3, strlen($indice)); - } - - return $new . $indice; - } - - - static function filtreIndice($indice) { - $indice = trim($indice); - if(strlen($indice) > 18) - return false; - - if(substr($indice,1,1) == ".") - return ''; // si c'est de la pcdm4 on dégage - - $new = ''; - for($i=0; $i < strlen($indice); $i++) { - $car = $indice[$i]; - if ($car >= "0" and $car <= "9") - $new .= $car; - } - - return $new; - } - - - static function getLibelle($indice) { - global $sql; - $libelle = $sql->fetchOne("select libelle from codif_dewey where id_dewey='$indice'"); - if(!$libelle) - $libelle = dewey::formatIndice($indice) . " - intitulé non renseigné"; - - return $libelle; - } - - - public function ecrire($indice, $libelle) { - global $sql; - - $indice = trim($indice); - $indice = str_replace(".", "", $indice); - $libelle = trim(str_replace("'", "''", $libelle)); - if($indice == "") - return false; - - $controle = $sql->fetchOne("select count(*) from codif_dewey where id_dewey='$indice'"); - if (0 == $controle) { - $sql->execute("insert into codif_dewey (id_dewey,libelle) Values('$indice','$libelle')"); - return 1; - } - - // Maj du libelle - $sql->execute("Update codif_dewey set libelle='$libelle' Where id_dewey='$indice'"); - // Maj des mots-recherche pour le nouveau libelle - $this->majFulltext($indice); - return 1; - } - - - public function majFulltext($indice) { - global $sql; - - require_once("classe_indexation.php"); - $ix = new indexation(); - - $indice = trim($indice); - $indice = str_replace(".","",$indice); - $code = "+D".$indice; - - $liste = $sql->prepareListe("select id_notice,facettes from notices where match(facettes) against('".$code."' IN BOOLEAN MODE)"); - if(!$liste) - return; - - while($ligne = $sql->fetchNext($liste)) - $this->_updateRecord($ligne, $ix); - } - - - protected function _updateRecord($ligne, $ix) { - global $sql; - - $id_notice = $ligne["id_notice"]; - $facets = explode(" ", $ligne["facettes"]); - foreach ($faces as $facet) { - if (!$facet) - continue; - - $code = substr($facet, 0, 1); - $map = ['D' => 'dewey', 'P' => 'pcdm4']; - if (!array_key_exists($code, $map)) - continue; - - $value = substr($facet, 1); - if ($libelle = $sql->fetchOne("select libelle from codif_". $map[$code] . " where id_" . $map[$code] . "='" . $value ."'")) - $fulltext .= ' ' . $libelle; - } - - $fulltext = $ix->getFulltext($fulltext); - $sql->execute("update notices set dewey='$fulltext' where id_notice=$id_notice"); - } -} - -?> \ No newline at end of file diff --git a/cosmogramme/php/classes/classe_indexation.php b/cosmogramme/php/classes/classe_indexation.php index dde19fe198ac13e7993f3b55e2da822a5440a76d..befc2e07a6cc326a9b9fa756b5e21ab0b29937e8 100644 --- a/cosmogramme/php/classes/classe_indexation.php +++ b/cosmogramme/php/classes/classe_indexation.php @@ -20,16 +20,16 @@ */ class indexation extends Class_Indexation { - protected static $phonetixCache = []; + protected static $phonetixCache = []; - public function phonetix($sIn) { - if (strlen($sIn)<4 || is_numeric($sIn)) - return false; + public function phonetix(string $sIn) : string { + if (strlen($sIn)<4 || is_numeric($sIn)) + return ''; - return isset(static::$phonetixCache[$sIn]) - ? static::$phonetixCache[$sIn] - : static::$phonetixCache[$sIn] = $this->phonetixCompute($sIn); - } + return isset(static::$phonetixCache[$sIn]) + ? static::$phonetixCache[$sIn] + : static::$phonetixCache[$sIn] = $this->phonetixCompute($sIn); + } } -?> \ No newline at end of file +?> diff --git a/cosmogramme/php/classes/classe_notice_archive_calice.php b/cosmogramme/php/classes/classe_notice_archive_calice.php index 51d3538c8d9fe7dbda591c0f36a61334d50967e1..a2f33c868ddc788a448b9e73a3091abe404933ab 100644 --- a/cosmogramme/php/classes/classe_notice_archive_calice.php +++ b/cosmogramme/php/classes/classe_notice_archive_calice.php @@ -99,6 +99,7 @@ class notice_archive_calice $notice["collation"] = $this->getCollation(); $notice["notes"] = $this->getNotes(); $notice["exportable"] = true; + $notice['other_terms'] = []; // clefs d'index $notice["alpha_titre"]=$this->indexation->codeAlphaTitre($notice["titre_princ"]." ".$notice["tome_alpha"]); @@ -211,11 +212,9 @@ class notice_archive_calice // ---------------------------------------------------------------- // Collection // ---------------------------------------------------------------- - public function getCollection() - { - return trim($this->champs[7]); - } - + public function getCollection() : array { + return [trim($this->champs[7])]; + } // ---------------------------------------------------------------- // Notes // ---------------------------------------------------------------- diff --git a/cosmogramme/php/classes/classe_notice_ascii.php b/cosmogramme/php/classes/classe_notice_ascii.php index 7bd21dca726ced7a124d7b415e9ef4e6049a8ec1..56cb759854ad6d704828689c2a10a7d906191455 100644 --- a/cosmogramme/php/classes/classe_notice_ascii.php +++ b/cosmogramme/php/classes/classe_notice_ascii.php @@ -110,7 +110,7 @@ class notice_ascii $notice["titres"]=""; $notice["auteurs"]=$this->enreg["auteurs"]; $notice["editeur"]=$this->enreg["editeur"]; - $notice["collection"]=$this->enreg["collection"]; + $notice["collection"] = [$this->enreg["collection"]]; $notice["matieres"]=$this->enreg["matieres"]; $notice["tome_alpha"] = $this->enreg["tome_alpha"]; $notice["annee"] = $this->enreg["annee"]; @@ -119,6 +119,7 @@ class notice_ascii $notice["data"] = $this->enreg["data"]; $notice["warnings"]=array(); $notice["id_commerciale"] = ''; + $notice['other_terms'] = []; if($this->enreg["isbn"]) { @@ -191,4 +192,4 @@ class notice_ascii return $this->erreur; } } -?> \ No newline at end of file +?> diff --git a/cosmogramme/php/classes/classe_notice_avenio.php b/cosmogramme/php/classes/classe_notice_avenio.php index de83ce8e5872511c5f8e1bca2e3ce2e8a4c4e85f..4d6a8fcc7a1f9e053ae6eb8cd4980f4f51122f17 100644 --- a/cosmogramme/php/classes/classe_notice_avenio.php +++ b/cosmogramme/php/classes/classe_notice_avenio.php @@ -91,6 +91,7 @@ class notice_avenio { $notice['titre_princ'] = $notice['titres'][0]; $notice['auteurs'] = $this->getAuteurs(); $notice['auteurs_renvois'] = []; + $notice['other_terms'] = []; $notice['editeur'] = $this->getEditeur(); $notice['lieu_edition'] = $this->getLieuEdition(); $notice['collection'] = $this->getCollection(); @@ -210,8 +211,8 @@ class notice_avenio { } - public function getCollection(){ - return trim($this->champs[10]); + public function getCollection() : array { + return [trim($this->champs[10])]; } diff --git a/cosmogramme/php/classes/classe_notice_integration.php b/cosmogramme/php/classes/classe_notice_integration.php index 1aaf7295fc55b1d43482a394437074775cee40da..639069e8246009f24e52354f34e67cd9399e2d5d 100644 --- a/cosmogramme/php/classes/classe_notice_integration.php +++ b/cosmogramme/php/classes/classe_notice_integration.php @@ -574,7 +574,7 @@ class notice_integration { $this->traiteFacettes(); $notice = Class_Notice::newInstance($this->noticeToDBEnreg()); - $notice->save(); + (new Class_Notice_Indexation($notice))->indexAndSave(); $this->statut = static::RECORD_INSERT; return $notice->getId(); @@ -585,15 +585,8 @@ class notice_integration { $record = ['type_doc' => $this->notice['type_doc'], 'alpha_titre' => $this->notice['alpha_titre'], 'alpha_auteur' => $this->notice['alpha_auteur'], - 'titres' => $this->indexation->getfullText(array_merge($this->notice['titres'], - [$this->notice['clef_chapeau'], - $this->notice['tome_alpha']])), - 'auteurs' => $this->indexation->getfullText($this->_getFulltextAuthors()), - 'other_terms'=> $this->indexation->getfulltext($this->notice['other_terms']), - 'editeur' => $this->indexation->getfullText($this->notice['editeur']), - 'collection' => $this->indexation->getfullText($this->notice['collection']), - 'matieres' => $this->indexation->getfullText($this->_getFulltextSubjects()), - 'dewey' => $this->indexation->getfullText($this->notice['full_dewey']), + 'matieres' => $this->indexation->getFulltext($this->_getFulltextSubjects()), + 'dewey' => $this->indexation->getFulltext($this->notice['full_dewey']), 'file_content' => $this->notice['file_content'], 'facettes' => $this->notice['facettes'], 'isbn' => $this->notice['isbn'], @@ -621,31 +614,9 @@ class notice_integration { } - protected function _getFulltextAuthors() { - if (!$this->notice['auteurs']) - return $this->notice["200_f"]; - - return array_merge($this->notice["auteurs"], - $this->notice["auteurs_renvois"], - $this->_getCodifAuteurRenvois()); - } - - - protected function _getCodifAuteurRenvois() { - $see_also = []; - foreach($this->notice['auteurs'] as $author) { - if (($codif = $this->_getCodifAuthorFor($author)) - && $codif->hasMotsRenvois()) - $see_also[] = $codif->getMotsRenvois(); - } - - return $see_also; - } - - - protected function _getFulltextSubjects() { + protected function _getFulltextSubjects() : array { if (!$this->notice['matieres']) - return ; + return []; return array_merge($this->notice["matieres"], $this->notice["matieres_renvois"], @@ -653,7 +624,7 @@ class notice_integration { } - protected function _getCodifSubjectsRenvois() { + protected function _getCodifSubjectsRenvois() : array { $see_also = []; foreach($this->notice['matieres'] as $subject) { @@ -923,7 +894,7 @@ class notice_integration { } - public function traiteFacettes($id_notice=null) { + public function traiteFacettes($id_notice=null) : self { $facettes = []; // Tags @@ -937,7 +908,7 @@ class notice_integration { } // Dewey - $this->notice["full_dewey"] = ''; + $this->notice["full_dewey"] = []; if($this->notice["dewey"]) { foreach($this->notice["dewey"] as $indice) @@ -949,7 +920,7 @@ class notice_integration { } - $this->notice["full_dewey"] .= $dewey->getLibelle()." "; + $this->notice["full_dewey"] [] = $dewey->getLibelle(); $facettes[]= $dewey->asFacet(); } } @@ -973,7 +944,7 @@ class notice_integration { if (empty($thesaurus)) continue; if ($thesaurus->getLibelle()) - $this->notice["full_dewey"] .= $thesaurus->getLibelle().' '; + $this->notice["full_dewey"] [] = $thesaurus->getLibelle(); $facettes[]= $thesaurus->asFacet(); } } @@ -1008,7 +979,7 @@ class notice_integration { } $facettes[] = $centre_interet->asFacet(); - $this->notice["full_dewey"] .= $interet." "; + $this->notice["full_dewey"] [] = $interet; } } @@ -1031,7 +1002,7 @@ class notice_integration { { $facettes[]= Class_CodifGenre::CODE_FACETTE . $genre; if ($codif_genre = Class_CodifGenre::find($genre)) - $this->notice["full_dewey"] .= ' ' . $codif_genre->getLibelle(); + $this->notice["full_dewey"] [] = $codif_genre->getLibelle(); } } @@ -1043,13 +1014,14 @@ class notice_integration { // Maj enreg facette $this->notice["facettes"] = trim(implode(' ', array_unique($facettes))); + return $this; } protected function _processPCDM4($indice) { $pcdm4 = Class_CodifPcdm4::getOrCreate($indice); - $this->notice["full_dewey"] .= $pcdm4->getLibelle()." "; + $this->notice["full_dewey"] [] = $pcdm4->getLibelle(); return $pcdm4->getFacetCode(); } diff --git a/cosmogramme/php/classes/classe_unimarc.php b/cosmogramme/php/classes/classe_unimarc.php index 771fe55ccd5d168eecaeea0af00d40d8e21628cd..dc01ca7aa3dd890396e47b1cc7cfe932aabef42a 100644 --- a/cosmogramme/php/classes/classe_unimarc.php +++ b/cosmogramme/php/classes/classe_unimarc.php @@ -21,8 +21,6 @@ require_once 'classe_profil_donnees.php'; require_once 'classe_iso2709.php'; -require_once 'classe_dewey.php'; -require_once 'classe_pcdm4.php'; require_once 'classe_indexation.php'; require_once("Class/Isbn.php"); require_once 'classe_codif_cache.php'; @@ -43,8 +41,6 @@ class notice_unimarc extends iso2709_record { const FIELD_RECORDISNEW = 4; const FIELD_INTERESTZONE = 6; - static protected $CHAR_NSB, $CHAR_NSE; - private $id_profil; // Id du profil de données pour le fichier chargé private $profil_unimarc; // Instance du profil unimarc pour optimiser private $type_doc_force; // Type de document forcé dans maj_auto @@ -69,7 +65,6 @@ class notice_unimarc extends iso2709_record { $this->copyright = explode(';', $data); $this->controle_codes_barres = getVariable('controle_codes_barres'); $this->ean345 = getVariable('ean_345'); - $this->_setNonSortingCharacters(); // Règles sections, genres, emplacements $this->_codif_rules = new Class_Codification_RulesHelper(); @@ -77,18 +72,6 @@ class notice_unimarc extends iso2709_record { } - protected function _setNonSortingCharacters(){ - if (($intbib = Class_IntBib::find($this->_id_bib)) - && $intbib->isCommFlora()) { - static::$CHAR_NSB = chr(0xc2) . chr(0x98); // NON SORTING BLOCK BEGIN - static::$CHAR_NSE = chr(0xc2) . chr(0x9c); // NON SORTING BLOCK END - return; - } - static::$CHAR_NSB = chr(0xc2) . chr(0x88); // NON SORTING BLOCK BEGIN - static::$CHAR_NSE = chr(0xc2) . chr(0x89); // NON SORTING BLOCK END - } - - public function setCodificationRules($codification_rules) { $this->_codif_rules = $codification_rules; return $this; @@ -217,19 +200,8 @@ class notice_unimarc extends iso2709_record { $notice["titre_princ"] = $this->getTitrePrincipal(); $notice["alpha_titre"] = $this->indexation->codeAlphaTitre($notice["titre_princ"]." ".$notice["tome_alpha"]); $notice["id_commerciale"] = $this->getIdCommerciale($notice["alpha_titre"]); - $notice["titres"] = $this->getTitres(); - $notice["auteurs"] = $this->getAuteurs(); - $notice["auteurs_renvois"] = $this->getAuteursRenvois(); - // si pas d'auteur on prend le 200$f - if(!$notice["auteurs"]) { - $notice["200_f"] = $this->get200f(); - $notice["alpha_auteur"] = ''; - } else { - $notice["alpha_auteur"] = $this->indexation->alphaMaj($notice["auteurs"][0]); - } - $notice["other_terms"] = $this->getOtherIndexedTerms(); - $notice["editeur"] = $this->getEditeur(); - $notice["collection"] = $this->getCollection(); + $notice["auteurs"] = (new Class_Notice_Authors($this))->getAllAuthors(); + $notice["alpha_auteur"] = $this->indexation->alphaMaj($notice["auteurs"][0] ?? ''); $notice["matieres"] = $this->getMatieresLabels(); $notice["matieres_renvois"] = $this->getMatieresRenvois(); $notice["annee"] = $this->getAnnee(); @@ -422,11 +394,11 @@ class notice_unimarc extends iso2709_record { switch($this->profil["id_article_periodique"]) { case Class_IntProfilDonnees::SERIAL_FORMAT_PERGAME: - $titre = array_map([$this, 'filtreTitre'], $this->get_subfield("461","t")); - $numero = $this->get_subfield("461","v"); - $notice["clef_chapeau"] = $this->indexation->codeAlphaTitre($titre[0]); + $titre = (new Class_Notice_Titles($this))->getTitleSerial(); + $numero = $this->get_subfield("461", "v"); + $notice["clef_chapeau"] = $this->indexation->codeAlphaTitre($titre); $notice["clef_numero"] = $this->indexation->alphaMaj($numero[0]); - $notice["titre_numero"] = $titre[0]." n° ".$numero[0]; + $notice["titre_numero"] = $titre . ' n° ' . $numero[0]; break; case Class_IntProfilDonnees::SERIAL_FORMAT_ALOES_INDEXPRESS: @@ -477,15 +449,7 @@ class notice_unimarc extends iso2709_record { public function getTitrePrincipal() { - $titres_field = $this->get_subfield('200'); - - if (!$titres_field) - return ''; - - $titre = implode(' ',array_unique($this->get_subfield('200','a'))); - - $titre = $this->filtreTitre($titre); - return $titre; + return (new Class_Notice_Titles($this))->getMainTitle(); } @@ -1261,51 +1225,12 @@ class notice_unimarc extends iso2709_record { public function getTitres() { - $zones = getVariable('unimarc_zone_titre'); - $zones = explode(';', trim($zones)); - $titre = []; - foreach($zones as $elem) { - $zone = substr($elem, 0, 3); - $champ = substr($elem, -1, 1); - $data = $this->get_subfield($zone); - foreach($data as $items) { - $sous_champs = $this->decoupe_bloc_champ($items); - foreach($sous_champs as $item) { - if($item["code"] == $champ) { - $item = trim($item['valeur']); - if($item) - $titre[] = $this->filtreTitre($item); - } - } - } - } - return($titre); - } - - - /** first one only */ - public function getComplementTitre() { - if (!$titre = $this->get_subfield('200', 'e')) - return ''; - return $this->filtreTitre($titre[0]); + return (new Class_Notice_Titles($this))->getTitles(); } - private function filtreTitre($valeur) { - $titre = trim($valeur); - $titre = str_replace(['[', '<', static::$CHAR_NSB, static::$CHAR_NSE], '', $titre); - $titre = str_replace([']', '>'], ' ', $titre); - - if (substr($titre, 0, 1) == '?') { - $deb = substr($titre, 0, 6); - $titre = str_replace('?', '', $deb) . substr($titre, 6); - } - - $titre = trim($titre); - if(in_array(substr($titre, -1, 1), ['/', ';', ',', '.', ':', '-'])) - $titre = substr($titre, 0, strlen($titre) - 1); - - return trim($titre); + public function getComplementTitre() : string { + return (new Class_Notice_Titles($this))->getTitleSupplement(); } @@ -1338,88 +1263,25 @@ class notice_unimarc extends iso2709_record { } - public function getAuteurs() { - $auteur = []; - foreach ($this->_getAuthorFields() as $zone) { - $data = $this->get_subfield($zone); - foreach ($data as $items) { - $sous_champs = $this->decoupe_bloc_champ($items); - $nom = $prenom = ''; - $mappings = ['a' => function ($value) use (&$nom) {$nom = $value;}, - 'b' => function ($value) use (&$prenom) {$prenom = $value;}]; - foreach ($sous_champs as $item) { - if (array_key_exists($item['code'], $mappings)) - $mappings[$item['code']](trim($item['valeur'])); - } - - $nm = $nom . '|' . $prenom; - if ((strlen($nm) > 2 or $this->indexation->isMotInclu($nom)) - and striPos($nm, "ANONYME") === false) // On elimine les auteurs avec 1 seule lettre - { - $auteur[] = $nm; - } - } - } - - return $auteur; - } - - - public function getAuteurPrincipal() { - if (!$auteurs = $this->getAuteurs()) + public function getAuteurPrincipal() : string { + if (!$auteurs = (new Class_Notice_Authors($this))->getAllAuthors()) return ''; return trim(str_replace('|', ' ', $auteurs[0])); } - public function getAuteurClefAlpha() { - if (!$auteurs = $this->getAuteurs()) + public function getAuteurClefAlpha() : string { + if (!$auteurs = (new Class_Notice_Authors($this))->getAllAuthors()) return ''; list($nom, $prenom) = explode('|', $auteurs[0]); return trim($nom . substr($prenom, 0, 1)); } - public function getAuteursRenvois() { - $auteur = []; - foreach($this->_getAuthorFields() as $zone) { - $data = $this->get_subfield($zone); - foreach($data as $items) { - $sous_champs = $this->decoupe_bloc_champ($items); - foreach($sous_champs as $item) { - if($item['code'] == '8') { - $nom = trim($item["valeur"]); - if (strlen($nom)>1) - $auteur[] = $nom; - } - } - } - } - return $auteur; - } - - - protected function _getAuthorFields() { - return ['700','710','720','730','701','702','711','712','721','722']; - } - - - public function get200f() { - return $this->get_subfield('200', 'f'); - } - - - public function getDewey() { - $data = $this->get_subfield('676'); - $dewey = []; - foreach ($data as $items) { - $sous_champs = $this->decoupe_bloc_champ($items); - foreach ($sous_champs as $item) - if (($item['code'] == 'a') - && ($indice = dewey::filtreIndice($item['valeur']))) - $dewey[] = $indice; - } - return $dewey; + public function getDewey() : array { + return array_filter( + array_map([Class_CodifDewey::class, 'filtreIndice'], + $this->get_subfield('676', 'a'))); } @@ -1429,31 +1291,15 @@ class notice_unimarc extends iso2709_record { } - public function processPcdm4($subfields) { - $indice = ''; - foreach($subfields as $item) { - if ($item['code'] == 'a' - && $indice = Class_CodifPcdm4::filtreIndice($item['valeur'])) { - return $indice; - } - } - return null; - } - - public function getPcdm4() { if ($indice = $this->_getPergamePcdm4()) return $indice; - $data = array_merge($this->get_subfield('686'), $this->get_subfield('676')); - $pcdm4 = array_filter( array_map([$this, '_getPcdm4DataField'], $data)); - - return implode(" ",$pcdm4); - } - - - protected function _getPcdm4DataField($item){ - return $this->processPcdm4($this->decoupe_bloc_champ($item)); + return implode(' ', + array_filter( + array_map([Class_CodifPcdm4::class, 'filtreIndice'], + [...$this->get_subfield('686', 'a'), + ...$this->get_subfield('676', 'a')]))); } @@ -1482,7 +1328,7 @@ class notice_unimarc extends iso2709_record { } - public function getEditeur() { + public function getEditeur() : string { return (new Class_Notice_Editeur($this))->getFirstEditeur(); } @@ -1564,14 +1410,6 @@ class notice_unimarc extends iso2709_record { } - public function getCollection() { - $data = $this->get_subfield(225, 'a'); - if(!count($data)) - $data = $this->get_subfield(410, 't'); - return $data; - } - - public function getLangues() { $data = $this->get_subfield(101); $langues = []; diff --git a/cosmogramme/php/codif_dewey.php b/cosmogramme/php/codif_dewey.php deleted file mode 100644 index e2099430c4bce827af23775c7e016d0961c41b68..0000000000000000000000000000000000000000 --- a/cosmogramme/php/codif_dewey.php +++ /dev/null @@ -1,356 +0,0 @@ -<?PHP -/** - * Copyright (c) 2012, 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 - */ -/////////////////////////////////////////////////////////////////// -// -// GESTION DES INDICES DEWEY -// -//////////////////////////////////////////////////////////////////// -include("_init_frame.php"); - -require_once("classe_dewey.php"); -$dewey = new dewey(); -extract($_POST); - -?> -<script> - function give_libelle(sIndice,sValeur) - { - if(sValeur == "") return; - oChampRetour=document.getElementById("indice_a_ecrire"); - oChampRetour.value=oChampRetour.value + sIndice + "#" + sValeur + ";"; - } - function give_suppression() - { - oChampRetour=document.getElementById("indice_a_ecrire"); - chaine=""; - for (var i=0;i<document.getElementsByName("selection").length;i++) - { - if (document.getElementsByName("selection")[i].checked==true) - { - if(chaine > '') chaine=chaine+";"; - chaine=chaine+document.getElementsByName("selection")[i].id; - } - } - oChampRetour.value=oChampRetour.value=chaine; - } -</script> -<?PHP - -// ---------------------------------------------------------------- -// ACCUEIL -// ---------------------------------------------------------------- -if($_REQUEST["action"]=="") -{ - print('<h1>Gestion des indices Dewey</h1>'); - $nb=$sql->fetchOne("Select count(*) from codif_dewey"); - $nb1=$sql->fetchOne("Select count(*) from codif_dewey where libelle=''" ); - print('<span class="orange"><b>La base contient '.number_format($nb, 0, ',', ' ').' fiches Dewey</b></span>'.BR); - print('<span class="orange"><b>Libellés non renseignés : '.number_format($nb1, 0, ',', ' ').'</b></span>'.BR.BR); - print('<div class="liste" style="width:700px">'); - - $url="codif_dewey.php?action=NOLIB"; - print('<form id="nolib" method="post" action="'.$url.'">'); - print('<table width="60%" cellspacing="0">'); - print('<tr><th align="left" width="50%">Indices sans libellés</th>'); - print('<th align="right"><input type="submit" class="bouton" value="Lancer"> </th>'); - print('</tr>'); - print('<tr>'); - print('<td align="right">Nombre de décimales: </td>'); - print('<td><input type ="text" name="nbdec" value="3" size="3" align="left"></td>'); - print('</tr>'); - print('</table></form>'.BR); - - $url="codif_dewey.php?action=MAJ"; - print('<form id="suppression" method="post" action="'.$url.'">'); - print('<table width="60%" cellspacing="0">'); - print('<tr><th align="left" width="50%">Modification de libellés</th>'); - print('<th align="right"><input type="submit" class="bouton" value="Lancer"> </th>'); - print('</tr>'); - print('<tr>'); - print('<td align="right">Nombre de décimales: </td>'); - print('<td><input type ="text" name="nbdec" value="3" size="3" align="left"></td>'); - print('</tr>'); - print('<tr>'); - print('<td align="right">Indices commencent par: </td>'); - print('<td><input type ="text" name="commencepar" value="" size="7" align="left"></td>'); - print('</tr>'); - print('</table></form>'.BR); - - $url="codif_dewey.php?action=SUPPRESSION"; - print('<form id="suppression" method="post" action="'.$url.'">'); - print('<table width="60%" cellspacing="0">'); - print('<tr><th align="left" width="50%">Suppression d\'indices</th>'); - print('<th align="right"><input type="submit" class="bouton" value="Lancer"> </th>'); - print('</tr>'); - print('<tr>'); - print('<td align="right">Nombre de décimales: </td>'); - print('<td><input type ="text" name="nbdec" value="3" size="3" align="left"></td>'); - print('</tr>'); - print('<tr>'); - print('<td align="right">Indices commencent par: </td>'); - print('<td><input type ="text" name="commencepar" value="" size="7" align="left"></td>'); - print('</tr>'); - print('</table></form>'.BR); - - $url="codif_dewey.php?action=CONSOLIDATION"; - print('<form id="consolidation" method="post" action="'.$url.'">'); - print('<table width="60%" cellspacing="0">'); - print('<tr><th align="left" width="70%">Consolidation par une liste d\'indices</th>'); - print('<th align="right"><input type="submit" class="bouton" value="Lancer"> </th>'); - print('</tr>'); - print('<tr>'); - print('<td colspan="2" align="center"><input type ="checkbox" name="remplacer">Remplacer les libellés présents dans la base</td>'); - print('</tr>'); - print('</table></form>'.BR); - - $url="codif_dewey.php?action=NIVEAUX"; - print('<form id="niveaux" method="post" action="'.$url.'">'); - print('<table width="60%" cellspacing="0">'); - print('<tr><th align="left" width="70%">Création des niveaux intermédiaires</th>'); - print('<th align="right"><input type="submit" class="bouton" value="Lancer"> </th>'); - print('</tr>'); - print('<tr>'); - print('<td colspan="2">Cette fonction créee les niveaux intermédiaires pour un bon fonctionnement de la recherche guidée</td>'); - print('</tr>'); - print('</table></form>'.BR); - -} - -// ---------------------------------------------------------------- -// CONSOLIDATION PAR LISTE -// ---------------------------------------------------------------- -if($_REQUEST["action"]=="CONSOLIDATION") -{ - print('<h1>Consolidation par une liste d\'indices</h1>'); - print('<div align="center">'); - print('<h3>Collez votre liste dans le champ ci-dessous, puis validez</h3>'); - print('<p align="left">NB : Les lignes doivent être séparées par des retours-chariot et l\'indice doit être séparé du libellé par une tabulation.</p>'); - $url="codif_dewey.php?action=ECRIRE_LISTE&remplacer=".$_REQUEST["remplacer"]; - print('<tr><form id="consolidation" method="post" action="'.$url.'">'); - print('<br><textarea name="liste_indice" cols="70" rows="20"></textarea>'); - print('<br><br><input type="submit" class="bouton" value="Valider la liste">'); - print('</form>'); -} - -// ---------------------------------------------------------------- -// CONSOLIDATION PAR LISTE => ECRITURE -// ---------------------------------------------------------------- -if($_REQUEST["action"]=="ECRIRE_LISTE") -{ - extract($_POST); - print('<h1>Ecriture des indices</h1>'); - print('<div>'); - if(trim($liste_indice) > "" ) - { - $indices=explode(chr(13).chr(10), $liste_indice); - $majs=0; $pas_traites=0; $creations=0; - for($i=0; $i<count($indices); $i++) - { - $elem=explode(chr(9),$indices[$i]); - $indice=$elem[0]; $libelle=$elem[1]; - $indice=trim(str_replace(".","",$indice)); - if(!$indice) continue; - $controle=$sql->fetchOne("select count(*) from codif_dewey where id_dewey='$indice'"); - if($controle) - { - if($_REQUEST["remplacer"] == "on") - { - $mode="Remplacement"; - $majs+=$dewey->ecrire($indice,$libelle); - } - else {$mode="Pas de traitement car existe déjà "; $pas_traites++;} - } - else {$mode="Création"; $creations++; $sql->insert("codif_dewey",array("id_dewey"=>$indice,"libelle"=>$libelle));} - print('<span class="violet" style="margin-left:20px"><b>'.$indice.' : </b></span><span>'.$mode.'</span>'.BR); - } - print('<br><h3>Traitement terminé avec succès</h3>'); - print('<h3>'.$creations." fiche(s) créée(s) - ".$majs." fiche(s) modifiée(s) - ".$pas_traites." fiche(s) non traitée(s)</h3>"); - } -} - -// ---------------------------------------------------------------- -// MISES A JOUR DE LIBELLES -// ---------------------------------------------------------------- -if($_REQUEST["action"]=="MAJ") -{ - print('<h1>Mise à jour des libellés</h1>'); - print('<div align="center">'); - print('<h3>Modifiez les libellés puis validez en bas de la page</h3>'); - $url="codif_dewey.php?action=ECRIRE"; - print('<form method="POST" action="'.$url.'">'); - print('<input type="hidden" id="indice_a_ecrire" name="indice_a_ecrire">'); - print('<table>'); - - $req="Select id_dewey,libelle from codif_dewey "; - if($nbdec >0) $where=" Where LENGTH(id_dewey)<= $nbdec"; - if($commencepar > "") - { - if( $where > "" ) $where .=" and "; else $where = " Where "; - $where.="id_dewey like '$commencepar%'"; - } - $req.= $where." order by id_dewey"; - $result=$sql->prepareListe($req); - if($result) - { - While($ret=$sql->fetchNext($result)) - { - print('<tr><td>'.$dewey->formatIndice($ret["id_dewey"]).'</td><td><input type="text" size="70" onblur="give_libelle(\''.$ret["id_dewey"].'\',this.value)" value="'.$ret["libelle"].'"></td></tr>'); - } - } - print('</table>'); - print('<br><input type="submit" class="bouton" value="Valider les libellés">'); - print('</form'); -} - -// ---------------------------------------------------------------- -// SUPPRESSION INDICES -// ---------------------------------------------------------------- -if($_REQUEST["action"]=="SUPPRESSION") -{ - print('<h1>Suppression d\'indices</h1>'); - print('<div align="center">'); - print('<h3>Cochez les indices à supprimer puis validez en bas de la page</h3>'); - $url="codif_dewey.php?action=DELETE"; - print('<form method="POST" action="'.$url.'">'); - print('<input type="hidden" id="indice_a_ecrire" name="indice_a_ecrire">'); - print('<table>'); - - $req="Select id_dewey,libelle from codif_dewey"; - if($nbdec >0) $where=" Where LENGTH(id_dewey)<= $nbdec"; - if($commencepar > "") - { - if( $where > "" ) $where .=" and "; else $where = " Where "; - $where.="id_dewey like '$commencepar%' order by id_dewey"; - } - $req.= $where; - $result=$sql->prepareListe($req); - if($result) - { - While($ret=$sql->fetchNext($result)) - { - print('<tr>'); - $coche='<input type="checkbox" name="selection" id="'.$ret["id_dewey"].'">'; - print('<td>'.$coche.'</td><td>'.$dewey->formatIndice($ret["id_dewey"]).'</td><td>'.$ret["libelle"].'</td></tr>'); - } - } - print('</table>'); - print('<br><input type="submit" class="bouton" value="Supprimer les indices cochés" onclick="give_suppression(); return true;">'); - print('</form'); -} - -// ---------------------------------------------------------------- -// TRAITEMENT DES SUPPRESSIONS -// ---------------------------------------------------------------- -if($_REQUEST["action"]=="DELETE") -{ - print('<h1>Suppression d\'indices</h1>'); - print('<div>'); - $indice=explode(";",$indice_a_ecrire); - for($i=0; $i<count($indice); $i++) - { - print("Suppression : ".$dewey->formatIndice($indice[$i])."<br>"); - $indice[$i]=str_replace(".","",$indice[$i]); - $req="Delete From codif_dewey Where id_dewey ='".$indice[$i]."'"; - $sql->execute($req); - $dewey->majFulltext($indice[$i]); - } - print('<br><h3>Traitement terminé avec succès</h3>'); -} - -// ---------------------------------------------------------------- -// INDICES SANS LIBELLE -// ---------------------------------------------------------------- -if($_REQUEST["action"]=="NOLIB") -{ - print('<h1>Indices Dewey sans libellés</h1>'); - print('<div align="center">'); - print('<h3>Renseignez les libellés puis validez en bas de la page</h3>'); - $url="codif_dewey.php?action=ECRIRE"; - print('<form method="POST" action="'.$url.'">'); - print('<input type="hidden" id="indice_a_ecrire" name="indice_a_ecrire">'); - print('<table>'); - - $ret=$dewey->getIndicesSanslibelle("",$nbdec); - for($i=0; $i<count($ret); $i++) - { - print('<tr><td>'.$ret[$i].'</td><td><input type="text" size="70" onblur="give_libelle(\''.$ret[$i].'\',this.value)"></td></tr>'); - } - print('</table>'); - print('<br><input type="submit" class="bouton" value="Valider les libellés">'); - print('</form'); -} - -// ---------------------------------------------------------------- -// ECRITURE DES LIBELLES -// ---------------------------------------------------------------- -if($_REQUEST["action"]=="ECRIRE") -{ - print('<h1>Mise à jour des Indices Dewey</h1>'); - if(trim($indice_a_ecrire)=="") - { - print('<br><h3>Aucun indice n\'a été modifié</h3>'); - } - else - { - $nb=0; - $liste=explode(";",$indice_a_ecrire); - for($i=0; $i<count($liste); $i++) - { - $elem=explode("#",$liste[$i]); - print($elem[0]." - " .$elem[1]."<br>"); - $nb+=$dewey->ecrire($elem[0],$elem[1]); - } - print("<br><h3>".$nb. " indice(s) ont été mis à jour avec succès.</h3>"); - } -} - -// ---------------------------------------------------------------- -// CREATION DES NIVEAUX INTERMEDIAIRES -// ---------------------------------------------------------------- -if($_REQUEST["action"]=="NIVEAUX") -{ - echo '<h1>Création des niveaux intermédiaires</h1>'; - $indices=fetchAll("select id_dewey from codif_dewey order by id_dewey"); - echo '<div>'; - $creation=0; - foreach($indices as $ligne) - { - $id_dewey=substr($ligne["id_dewey"],0,7); - for($i=strlen($id_dewey)-1; $i>1; $i--) - { - $id=substr($id_dewey,0,$i); - $controle=fetchOne("select count(*) from codif_dewey where id_dewey='$id'"); - if(strlen($id)>6) continue; - if($controle>0) continue; - sqlExecute("insert into codif_dewey(id_dewey) values('$id')"); - $creation++; - echo $id.BR; - } - } - echo '</div>'; - echo '<h3>'.$creation.' indices à créer</h3>'.BR.BR; -} - -?> - -</center></div> -</body> -</html> diff --git a/cosmogramme/php/codif_pcdm4.php b/cosmogramme/php/codif_pcdm4.php deleted file mode 100644 index ae148ad61b42959beb73c91db2c121d14cb9f092..0000000000000000000000000000000000000000 --- a/cosmogramme/php/codif_pcdm4.php +++ /dev/null @@ -1,319 +0,0 @@ -<?PHP -/** - * Copyright (c) 2012, 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 - */ -/////////////////////////////////////////////////////////////////// -// -// GESTION DES INDICES PCDM4 -// -//////////////////////////////////////////////////////////////////// -include("_init_frame.php"); - -require_once("classe_pcdm4.php"); -$pcdm4=new pcdm4(); -extract($_POST); - -?> -<script> - function give_libelle(sIndice,sValeur) - { - if(sValeur == "") return; - oChampRetour=document.getElementById("indice_a_ecrire"); - oChampRetour.value=oChampRetour.value + sIndice + "#" + sValeur + ";"; - } - function give_suppression() - { - oChampRetour=document.getElementById("indice_a_ecrire"); - chaine=""; - for (var i=0;i<document.getElementsByName("selection").length;i++) - { - if (document.getElementsByName("selection")[i].checked==true) - { - if(chaine > '') chaine=chaine+";"; - chaine=chaine+document.getElementsByName("selection")[i].id; - } - } - oChampRetour.value=oChampRetour.value=chaine; - } -</script> -<?PHP - -// ---------------------------------------------------------------- -// ACCUEIL -// ---------------------------------------------------------------- -if($_REQUEST["action"]=="") -{ - print('<h1>Gestion des indices PCDM4</h1>'); - $nb=$sql->fetchOne("Select count(*) from codif_pcdm4"); - $nb1=$sql->fetchOne("Select count(*) from codif_pcdm4 where libelle=''" ); - print('<span class="orange"><b>La base contient '.number_format($nb, 0, ',', ' ').' fiches pcdm4</b></span>'.BR); - print('<span class="orange"><b>Libellés non renseignés : '.number_format($nb1, 0, ',', ' ').'</b></span>'.BR.BR); - - print('<div class="liste">'); - - $url="codif_pcdm4.php?action=NOLIB"; - print('<tr><form id="nolib" method="post" action="'.$url.'">'); - print('<table width="60%" cellspacing="0">'); - print('<tr><th align="left" width="50%">Indices sans libellés</th>'); - print('<th align="right"><input type="submit" class="bouton" value="Lancer"> </th>'); - print('</tr>'); - print('<tr>'); - print('<td align="right">Nombre de décimales: </td>'); - print('<td><input type ="text" name="nbdec" value="3" size="3" align="left"></td>'); - print('</tr>'); - print('</table></form>'); - - $url="codif_pcdm4.php?action=MAJ"; - print('<tr><form id="suppression" method="post" action="'.$url.'">'); - print('<table width="60%" cellspacing="0">'); - print('<tr><th align="left" width="50%">Modification de libellés</th>'); - print('<th align="right"><input type="submit" class="bouton" value="Lancer"> </th>'); - print('</tr>'); - print('<tr>'); - print('<td align="right">Nombre de décimales: </td>'); - print('<td><input type ="text" name="nbdec" value="3" size="3" align="left"></td>'); - print('</tr>'); - print('<tr>'); - print('<td align="right">Indices commencent par: </td>'); - print('<td><input type ="text" name="commencepar" value="" size="7" align="left"></td>'); - print('</tr>'); - print('</table></form>'); - - $url="codif_pcdm4.php?action=SUPPRESSION"; - print('<tr><form id="suppression" method="post" action="'.$url.'">'); - print('<table width="60%" cellspacing="0">'); - print('<tr><th align="left" width="50%">Suppression d\'indices</th>'); - print('<th align="right"><input type="submit" class="bouton" value="Lancer"> </th>'); - print('</tr>'); - print('<tr>'); - print('<td align="right">Nombre de décimales: </td>'); - print('<td><input type ="text" name="nbdec" value="3" size="3" align="left"></td>'); - print('</tr>'); - print('<tr>'); - print('<td align="right">Indices commencent par: </td>'); - print('<td><input type ="text" name="commencepar" value="" size="7" align="left"></td>'); - print('</tr>'); - print('</table></form>'); - - $url="codif_pcdm4.php?action=CONSOLIDATION"; - print('<tr><form id="consolidation" method="post" action="'.$url.'">'); - print('<table width="60%" cellspacing="0">'); - print('<tr><th align="left" width="50%">Consolidation par une liste d\'indices</th>'); - print('<th align="right"><input type="submit" class="bouton" value="Lancer"> </th>'); - print('</tr>'); - print('<tr>'); - print('<td colspan="2" align="center"><input type ="checkbox" name="remplacer">Remplacer les libellés présents dans la base</td>'); - print('</tr>'); - print('</table></form>'); - -} - -// ---------------------------------------------------------------- -// CONSOLIDATION PAR LISTE -// ---------------------------------------------------------------- -if($_REQUEST["action"]=="CONSOLIDATION") -{ - print('<h1>Consolidation par une liste d\'indices</h1>'); - print('<div align="center">'); - print('<h3>Collez votre liste dans le champ ci-dessous, puis validez</h3>'); - print('<p align="left">NB : Les lignes doivent être séparées par des retours-chariot et l\'indice doit être séparé du libellé par une tabulation.</p>'); - $url="codif_pcdm4.php?action=ECRIRE_LISTE&remplacer=".$_REQUEST["remplacer"]; - print('<tr><form id="consolidation" method="post" action="'.$url.'">'); - print('<br><textarea name="liste_indice" cols="70" rows="20" style="margin-left:30px"></textarea>'); - print('<br><br><input type="submit" class="bouton" value="Valider la liste">'); - print('</form>'); -} - -// ---------------------------------------------------------------- -// CONSOLIDATION PAR LISTE => ECRITURE -// ---------------------------------------------------------------- -if($_REQUEST["action"]=="ECRIRE_LISTE") -{ - extract($_POST); - print('<h1>Ecriture des indices</h1>'); - print('<div>'); - if(trim($liste_indice) > "" ) - { - $indices=explode(chr(13).chr(10), $liste_indice); - $majs=0; $pas_traites=0; $creations=0; - for($i=0; $i<count($indices); $i++) - { - $elem=explode(chr(9),$indices[$i]); - $indice=$elem[0]; $libelle=$elem[1]; - $indice=trim(str_replace(".","",$indice)); - if(!$indice) continue; - $controle=$sql->fetchOne("select count(*) from codif_pcdm4 where id_pcdm4='$indice'"); - if($controle) - { - if($_REQUEST["remplacer"] == "on") - { - $mode="Remplacement"; - $majs+=$pcdm4->ecrire($indice,$libelle); - } - else {$mode="Pas de traitement car existe déjà "; $pas_traites++;} - } - else {$mode="Création"; $creations++; $sql->insert("codif_pcdm4",array("id_pcdm4"=>$indice,"libelle"=>$libelle));} - print('<span class="violet" style="margin-left:20px"><b>'.$indice.' : </b></span><span>'.$mode.'</span>'.BR); - } - print('<br><h3>Traitement terminé avec succès</h3>'); - print('<h3>'.$creations." fiche(s) créée(s) - ".$majs." fiche(s) modifiée(s) - ".$pas_traites." fiche(s) non traitée(s)</h3>"); - } -} - -// ---------------------------------------------------------------- -// MISES A JOUR DE LIBELLES -// ---------------------------------------------------------------- -if($_REQUEST["action"]=="MAJ") -{ - print('<h1>Mise à jour des libellés</h1>'); - print('<div align="center">'); - print('<h3>Modifiez les libellés puis validez en bas de la page</h3>'); - $url="codif_pcdm4.php?action=ECRIRE"; - print('<form method="POST" action="'.$url.'">'); - print('<input type="hidden" id="indice_a_ecrire" name="indice_a_ecrire">'); - print('<table>'); - - $req="Select id_pcdm4,libelle from codif_pcdm4"; - if($nbdec >0) $where=" Where LENGTH(id_pcdm4)<= $nbdec"; - if($commencepar > "") - { - if( $where > "" ) $where .=" and "; else $where = " Where "; - $where.="id_pcdm4 like '$commencepar%'"; - } - $req.= $where ." order by id_pcdm4"; - $result=$sql->prepareListe($req); - if($result) - { - While($ret=$sql->fetchNext($result)) - { - print('<tr><td>'.$pcdm4->formatIndice($ret["id_pcdm4"]).'</td><td><input type="text" size="70" onblur="give_libelle(\''.$ret["id_pcdm4"].'\',this.value)" value="'.$ret["libelle"].'"></td></tr>'); - } - } - print('</table>'); - print('<br><input type="submit" class="bouton" value="Valider les libellés">'); - print('</form'); -} - -// ---------------------------------------------------------------- -// SUPPRESSION INDICES -// ---------------------------------------------------------------- -if($_REQUEST["action"]=="SUPPRESSION") -{ - print('<h1>Suppression d\'indices</h1>'); - print('<div align="center">'); - print('<h3>Cochez les indices à supprimer puis validez en bas de la page</h3>'); - $url="codif_pcdm4.php?action=DELETE"; - print('<form method="POST" action="'.$url.'">'); - print('<input type="hidden" id="indice_a_ecrire" name="indice_a_ecrire">'); - print('<table>'); - - $req="Select id_pcdm4,libelle from codif_pcdm4"; - if($nbdec >0) $where=" Where LENGTH(id_pcdm4)<= $nbdec"; - if($commencepar > "") - { - if( $where > "" ) $where .=" and "; else $where = " Where "; - $where.="id_pcdm4 like '$commencepar%'"; - } - $req.= $where." order by id_pcdm4"; - $result=$sql->prepareListe($req); - if($result) - { - While($ret=$sql->fetchNext($result)) - { - print('<tr>'); - $coche='<input type="checkbox" name="selection" id="'.$ret["id_pcdm4"].'">'; - print('<td>'.$coche.'</td><td>'.$pcdm4->formatIndice($ret["id_pcdm4"]).'</td><td>'.$ret["libelle"].'</td></tr>'); - } - } - print('</table>'); - print('<br><input type="submit" class="bouton" value="Supprimer les indices cochés" onclick="give_suppression(); return true;">'); - print('</form'); -} - -// ---------------------------------------------------------------- -// TRAITEMENT DES SUPPRESSIONS -// ---------------------------------------------------------------- -if($_REQUEST["action"]=="DELETE") -{ - print('<h1>Suppression d\'indices</h1>'); - print('<div>'); - $indice=explode(";",$indice_a_ecrire); - for($i=0; $i<count($indice); $i++) - { - print("Suppression : ".$pcdm4->formatIndice($indice[$i])."<br>"); - $indice[$i]=str_replace(".","",$indice[$i]); - $req="Delete From codif_pcdm4 Where id_pcdm4 ='".$indice[$i]."'"; - $sql->execute($req); - $pcdm4->majFulltext($indice[$i]); - } - print('<br><h3>Traitement terminé avec succès</h3>'); -} - -// ---------------------------------------------------------------- -// INDICES SANS LIBELLE -// ---------------------------------------------------------------- -if($_REQUEST["action"]=="NOLIB") -{ - print('<h1>Indices pcdm4 sans libellés</h1>'); - print('<div align="center">'); - print('<h3>Renseignez les libellés puis validez en bas de la page</h3>'); - $url="codif_pcdm4.php?action=ECRIRE"; - print('<form method="POST" action="'.$url.'">'); - print('<input type="hidden" id="indice_a_ecrire" name="indice_a_ecrire">'); - print('<table>'); - - $ret=$pcdm4->getIndicesSanslibelle("",$nbdec); - for($i=0; $i<count($ret); $i++) - { - print('<tr><td>'.$ret[$i].'</td><td><input type="text" size="70" onblur="give_libelle(\''.$ret[$i].'\',this.value)"></td></tr>'); - } - print('</table>'); - print('<br><input type="submit" class="bouton" value="Valider les libellés">'); - print('</form'); -} - -// ---------------------------------------------------------------- -// ECRITURE DES LIBELLES -// ---------------------------------------------------------------- -if($_REQUEST["action"]=="ECRIRE") -{ - print('<h1>Mise à jour des Indices PCDM4</h1>'); - if(trim($indice_a_ecrire)=="") - { - print('<br><h3>Aucun indice n\'a été modifié</h3>'); - } - else - { - $nb=0; - $liste=explode(";",$indice_a_ecrire); - for($i=0; $i<count($liste); $i++) - { - $elem=explode("#",$liste[$i]); - print($elem[0]." - " .$elem[1]."<br>"); - $nb+=$pcdm4->ecrire($elem[0],$elem[1]); - } - print("<br><h3>".$nb. " indice(s) ont été mis à jour avec succès.</h3>"); - } -} - -?> - -</center></div> -</body> -</html> diff --git a/cosmogramme/php/recherche_guide.php b/cosmogramme/php/recherche_guide.php deleted file mode 100644 index b90b49e31b80dadea261087aacdb0f2ba46742fe..0000000000000000000000000000000000000000 --- a/cosmogramme/php/recherche_guide.php +++ /dev/null @@ -1,520 +0,0 @@ -<?PHP -/** - * Copyright (c) 2012, 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 - */ -////////////////////////////////////////////////////////////////////////////// -// RECHERCHE GUIDEE -////////////////////////////////////////////////////////////////////////////// -include("_init_frame.php"); - -unset($_SESSION["url_retour"]); -if(!$_REQUEST["rubrique"]) unset($_SESSION["guide"]); - -// Classe indexation -require_once("fonctions/objets_saisie.php"); -require_once("classe_bib.php"); -require_once("classe_liste_notices.php"); -require_once("classe_dewey.php"); -require_once("classe_pcdm4.php"); -$oListe=new liste_notices(); -$oBib=new bibliotheque(); - -// Comptage des notices et des exemplaires -print('<h1>Recherche guidée</h1>'); -$nb_notices=$sql->fetchOne("select count(*) from notices"); -$nb_ex=$sql->fetchOne("select count(*) from exemplaires"); -print('<span class="orange"><b>La base contient '.number_format($nb_notices,0, ',', ' ').' notices et '.number_format($nb_ex,0, ',', ' ').' exemplaires</b></span>'.BR.BR); - -// On met les criteres de recherche dans la session -$page=$_REQUEST["page"]; -if(count($_POST) > 1) $_SESSION["guide_selection"]=$_POST; else $_POST=$_SESSION["guide_selection"]; - -// Formulaire de saisie -if($_REQUEST["mode"]=="INTRO") -{ - print('<form method="post" action="recherche_guide.php">'); - print('<table class="form" cellspacing="0" style="width:500px;margin-left:20px">'); - print('<tr><th class="form" colspan="2">Critères de sélection</td></tr>'); - print('<tr><td align="right" class="form_milieu">Type de document </td><td class="form_milieu">'. getCombo(2) .'</td></tr>'); - print('<tr><td align="right" class="form_milieu">Bibliothèque </td><td class="form_milieu">'. getCombo(4) .'</td></tr>'); - print('<tr><td align="right" class="form_milieu">Mode d\'affichage du résultat </td><td class="form_milieu">'. getCombo(6) .'</td></tr>'); - print('<th class="form" colspan="2" align="center"><input type="submit" value="Lancer" class="bouton"></th>'); - print('</table></form>'); - quit(""); -} - -// ---------------------------------------------------------------- -// Rubriques -// ---------------------------------------------------------------- -$html='<div class="guide">'; -$html.=getFilAriane(); - -// Racine -if(!$_REQUEST["rubrique"]) -{ - $rubriques=getRubriquesMain(); - $html.=getHtmlGuide($rubriques); - print($html); - print('</div>'); - quit(""); -} -// Sous niveaux -$rubriques=getRubriques(); -$html.=getHtmlGuide($rubriques); -print($html); -print('</div>'); - -// ---------------------------------------------------------------- -// Criteres de selection du formulaire -// ---------------------------------------------------------------- -$condition=""; -if($_SESSION["guide_selection"]["type_document"]) -{ - $condition="type_doc=".$_SESSION["guide_selection"]["type_document"]." and "; - $texte_condition="Type de document = ".getLibCodifVariable("types_docs",$_SESSION["guide_selection"]["type_document"]); -} -if($_SESSION["guide_selection"]["bibliotheque"]) -{ - $against=" +".$_SESSION["guide_selection"]["bibliotheque"]; - if($texte_condition) $texte_condition.=" - "; - $texte_condition.="bibliothèque = ".$oBib->getNomCourt(substr($_SESSION["guide_selection"]["bibliotheque"],1)); -} - -$rubrique=$_REQUEST["rubrique"]; -if($rubrique[0]=="X") quit(""); -else $rubrique ="+".$rubrique."*"; - -// ---------------------------------------------------------------- -// Affichage mode liste de Notices -// ---------------------------------------------------------------- -if($_SESSION["guide_selection"]["affichage"]==1) -{ - $req = " from notices where ".$condition."MATCH(facettes) AGAINST('".$rubrique.$against." ' IN BOOLEAN MODE)"; - $req_comptage="select count(*)".$req; - $req_liste="select id_notice".$req; - print(BR."<B>Requete : </b>".$req_liste.BR); - if($texte_condition) print(BR.'<span class="violet" style="margin-left:10px"><b>'.$texte_condition.'</b></span>'); - $temps=time(); - $nombre=$sql->fetchOne($req_comptage); - print(BR.'<span class="orange" style="margin-left:10px"><b>Temps requête de comptage : '.(time()-$temps).' secondes'.'</b></span>'.BR); - if(!$nombre) quit("Aucun résultat trouvé"); - $temps=time(); - $liste=$oListe->getListe($req_liste,$page); - print('<span class="orange" style="margin-left:10px"><b>Temps requête résultat : '.(time()-$temps).' secondes'.'</b></span>'.BR); - print('<span class="orange" style="margin-left:10px"><b>Résultats trouvés : '.$nombre.'</b></span>'.BR); - $args_url="rubrique=".$_REQUEST["rubrique"]; - print(BR.$oListe->getHtml($liste,$args_url)); -} - -// ---------------------------------------------------------------- -// Affichage mode Tags auteurs -// ---------------------------------------------------------------- -if($_SESSION["guide_selection"]["affichage"]==3) -{ - $req = "select facettes from notices where ".$condition." MATCH(facettes) AGAINST('".$rubrique.$against."' IN BOOLEAN MODE)"; - print(BR."<B>Requete : </b>".$req.BR); - if($texte_condition) print(BR.'<span class="violet" style="margin-left:10px"><b>'.$texte_condition.'</b></span>'); - $temps=time(); - $html=getTags($req); - print(BR.'<span class="orange" style="margin-left:10px"><b>Temps de calcul des tags : '.(time()-$temps).' secondes'.'</b></span>'.BR); - if(!$html) quit("Aucun résultat trouvé"); - print(BR.$html.BR.BR); -} - -// ---------------------------------------------------------------- -// Affichage mode Facettes -// ---------------------------------------------------------------- -if($_SESSION["guide_selection"]["affichage"]==2) -{ - $req = "select facettes from notices where ".$condition." MATCH(facettes) AGAINST('".$rubrique.$against."' IN BOOLEAN MODE)"; - print(BR."<B>Requete : </b>".$req.BR); - if($texte_condition) print(BR.'<span class="violet" style="margin-left:10px"><b>'.$texte_condition.'</b></span>'); - $temps=time(); - $html=getFacettes($req); - print(BR.'<span class="orange" style="margin-left:10px"><b>Temps de calcul des facettes : '.(time()-$temps).' secondes'.'</b></span>'.BR); - if(!$html) quit("Aucun résultat trouvé"); - print(BR.$html.BR.BR); -} - -quit(""); - -// ---------------------------------------------------------------- -// Fonctions -// ---------------------------------------------------------------- -function getFilAriane() -{ - $puce=" »"; - if($_SESSION["guide"]["fil_ariane"]) $elems=explode(";",$_SESSION["guide"]["fil_ariane"]); - $elems[]=$_REQUEST["rubrique"]; - foreach($elems as $elem) - { - if(!$elem) continue; - $fil_ariane.=";".$elem; - $url="recherche_guide.php?fil_ariane=".$fil_ariane."&rubrique=".$elem; - $html.='<a class="guide_ariane" href="'.$url.'">'.$puce.getCodif($elem).'</a>'; - if($elem == $_REQUEST["rubrique"]) break; - } - - // Html - $_SESSION["guide"]["fil_ariane"]=$fil_ariane; - $html='<div class="guide_ariane">'.'<a class="guide_ariane" href="recherche_guide.php">'.$puce.'Accueil</a>'.$html.'</div>'; - return $html; -} - -function getCodif($code) -{ - global $sql; - $type=$code[0]; - $id=substr($code,1); - if($type == "X") { $rubrique=array(" ","Dewey","Pcdm4","Matières"); return $rubrique[intval($id)]; } - if($type == "D") return dewey::getLibelle($id); - if($type == "P") return pcdm4::getLibelle($id); -} - -function getRubriquesMain() -{ - return array(array("id"=>"X1"),array("id"=>"X2")); -} - -function getRubriques() -{ - global $sql; - $tag=$_REQUEST["rubrique"]; - $rubrique=$tag[0]; - $id=substr($tag,1); - - // Rubriques racine - if($rubrique == "X") - { - switch(intval($id)) - { - case 1: // dewey - $liste=dewey::getIndices("root"); - foreach($liste as $indice) $items[]="D".$indice["id_dewey"]; - break; - case 2: // pcdm4 - $liste=pcdm4::getIndices("root"); - foreach($liste as $indice) $items[]="P".$indice["id_pcdm4"]; - break; - } - } - // Dewey - if($rubrique == "D") - { - $liste=dewey::getIndices($id); - if(!$liste) return false; - foreach($liste as $indice) $items[]="D".$indice["id_dewey"]; - } - // Pcdm4 - if($rubrique == "P") - { - $liste=pcdm4::getIndices($id); - if(!$liste) return false; - foreach($liste as $indice) $items[]="P".$indice["id_pcdm4"]; - } - // Compter les items - for($i=0; $i < count($items); $i++) - { - //$req="select count(*) from notices where MATCH(facettes) AGAINST('+".$items[$i]."' IN BOOLEAN MODE)"; - //$nombre=$sql->fetchOne($req); - //if(!$nombre) continue; - $ret[]=array("id"=>$items[$i],"nombre"=>$nombre); - } - return $ret; -} - -function getHtmlGuide($rubriques) -{ - $puce="» "; - $html='<div class="guide_contenu">'; - if(!$rubriques) $html.='<h3>Il n\'y a plus de sous-niveaux</h3>'; - else - { - foreach($rubriques as $rubrique) - { - $url='recherche_guide.php?rubrique='.$rubrique["id"]; - $html.=$puce.'<a class="guide_contenu" href="'.$url.'">'.getCodif($rubrique["id"]).'</a>'.BR; - } - } - $html.='</div>'; - return $html; -} - -function getTags($req) -{ - global $sql,$max_tags; - // Nombre max de tags - if(!$max_tags) $max_tags=100; - $max=0; - $min=1000000; - - $result=$sql->prepareListe($req); - while($notice=$sql->fetchNext($result)) - { - $items=explode(" ",trim($notice["facettes"])); - foreach($items as $item) - { - $type=$item[0]; - if($type == "A") $facettes[$item]++; - $nb++; - if($nb==10000) - { - $nb=0; - arsort($facettes); - $facettes=array_slice($facettes,0,10000); - } - } - } - if($facettes) arsort($facettes); - - // Auteurs - $nb=0; - if($facettes) - { - foreach($facettes as $clef => $nombre) - { - if($nombre > $max) $max=$nombre; - if($nombre < $min) $min=$nombre; - $nb++; - if($nb>$max_tags) break; - $id_auteur=substr($clef,1); - $table[$nb]["id"]=$clef; - $table[$nb]["libelle"]=$sql->fetchOne("select libelle from codif_auteur where id_auteur=$id_auteur"); - $table[$nb]["nombre"]=$nombre; - $alea[$clef]=$nb; - } - } - - // Déterminer les tranches - if($max < 11) $tranches=array(1,2,3,4,5,6,7,8,9,10); - else - { - $tranche=intVal(($max - $min)/10); - for($i=0;$i<10; $i++) $tranches[$i]=intval($min + ($i * $tranche)); - } - // Remettre dans un ordre aleatoire - if(!$nb) return false; - ksort($alea); - - // Fabriquer le Html - $html='<div class="nuage" style="margin-left:20px">'; - foreach($alea as $index) - { - $enreg=$table[$index]; - for($niveau=9; $niveau > 0; $niveau--) if($enreg["nombre"]>=$tranches[$niveau]) break; - $classe="nuage_niveau".($niveau+1); - //$url=URL_BASE.'php/recherche_tags_auteurs.php?tag='.$enreg["id"]; - $url="#"; - $html.='<span class="nuage"><a class="'.$classe.'" href="'.$url.'">'.$enreg["libelle"].' </a></span>'; - } - $html.='</div>'; - return $html; -} - -function getCombo($type) -{ - switch($type) - { - // Types de documents - case 2: - $name = "type_document"; - return getComboCodif($name,"types_docs",$_POST[$name],"",true); - break; - // Bibliotheque - case 4: - $name = "bibliotheque"; - $valeurs=array(""=>"toutes"); - global $oBib; - $bibs=$oBib->getAll(); - foreach($bibs as $bib) - { - $code="B".$bib["id_bib"]; - $valeurs[$code]=stripSlashes($bib["nom_court"]); - } - break; - // Mode d'affichage du résultat - case 6: - $name = "affichage"; - $valeurs=array("1"=>"Liste de notices","2"=>"Facettes","3"=>"Nuages de tags Auteurs"); - break; - } - $selection=$_POST[$name]; - $combo='<select name="'.$name.'">'; - foreach($valeurs as $clef => $valeur) - { - if($selection == $clef) $selected=' selected="selected"'; else $selected =""; - $combo.='<option value="'.$clef.'"'.$selected.'>'.$valeur.'</option>'; - } - $combo.='</select>'; - return $combo; -} -// Calcul des facettes -function getFacettes($req) -{ - global $sql; - $result=$sql->prepareListe($req); - while($notice=$sql->fetchNext($result)) - { - $type="T".$notice["type_doc"]; - $facettes["type_doc"][$type]++; - $items=explode(" ",trim($notice["facettes"])); - foreach($items as $item) - { - $type=substr($item,0,1); - $facettes[$type][$item]++; - } - } - arsort($facettes["type_doc"]); - arsort($facettes["B"]); - if($facettes["A"]) arsort($facettes["A"]); - if($facettes["D"]) arsort($facettes["D"]); - if($facettes["P"]) arsort($facettes["P"]); - if($facettes["M"]) arsort($facettes["M"]); - if($facettes["L"]) arsort($facettes["L"]); - - // Types de docs - $nb=0; - $table["type_doc"]["titre"]="Type de document"; - foreach($facettes["type_doc"] as $clef => $nombre) - { - $nb++; - if($nb>5) break; - $id_type_doc=substr($clef,1); - $table["type_doc"][$nb]["id"]=$clef; - $table["type_doc"][$nb]["libelle"]=getLibCodifVariable("types_docs",$id_type_doc); - $table["type_doc"][$nb]["nombre"]=$nombre; - } - // Bibliotheques - $nb=0; - $table["B"]["titre"]="Bibliothèque"; - foreach($facettes["B"] as $clef => $nombre) - { - $nb++; - if($nb>5) break; - $id_bib=substr($clef,1); - $table["B"][$nb]["id"]=$clef; - $table["B"][$nb]["libelle"]=$sql->fetchOne("select nom_court from int_bib where id_bib=$id_bib"); - $table["B"][$nb]["nombre"]=$nombre; - } - // Auteurs - $nb=0; - if($facettes["A"]) - { - $table["A"]["titre"]="Auteur"; - foreach($facettes["A"] as $clef => $nombre) - { - $nb++; - if($nb>5) break; - $id_auteur=substr($clef,1); - $table["A"][$nb]["id"]=$clef; - $table["A"][$nb]["libelle"]=$sql->fetchOne("select libelle from codif_auteur where id_auteur=$id_auteur"); - $table["A"][$nb]["nombre"]=$nombre; - } - } - // Dewey - $nb=0; - if($facettes["D"]) - { - $table["D"]["titre"]="Dewey"; - foreach($facettes["D"] as $clef => $nombre) - { - $nb++; - if($nb>5) break; - $id_dewey=substr($clef,1); - $table["D"][$nb]["id"]=$clef; - $table["D"][$nb]["libelle"]=dewey::getLibelle($id_dewey); - $table["D"][$nb]["nombre"]=$nombre; - } - } - // Pcdm4 - $nb=0; - if($facettes["P"]) - { - $table["P"]["titre"]="Pcdm4"; - foreach($facettes["P"] as $clef => $nombre) - { - $nb++; - if($nb>5) break; - $id_pcdm4=substr($clef,1); - $table["P"][$nb]["id"]=$clef; - $table["P"][$nb]["libelle"]=pcdm4::getLibelle($id_pcdm4); - $table["P"][$nb]["nombre"]=$nombre; - } - } - // Matières - $nb=0; - if($facettes["M"]) - { - $table["M"]["titre"]="Mot-matière"; - foreach($facettes["M"] as $clef => $nombre) - { - $nb++; - if($nb>5) break; - $id_matiere=substr($clef,1); - $table["M"][$nb]["id"]=$clef; - $table["M"][$nb]["libelle"]=$sql->fetchOne("select libelle from codif_matiere where id_matiere=$id_matiere"); - $table["M"][$nb]["nombre"]=$nombre; - } - } - // Langues - $nb=0; - if($facettes["L"]) - { - $table["L"]["titre"]="Langue"; - foreach($facettes["L"] as $clef => $nombre) - { - $nb++; - if($nb>5) break; - $id_langue=substr($clef,1); - $table["L"][$nb]["id"]=$clef; - $table["L"][$nb]["libelle"]=$sql->fetchOne("select libelle from codif_langue where id_langue='$id_langue'"); - $table["L"][$nb]["nombre"]=$nombre; - } - } - // Fabriquer le Html - $html='<div style="width:500px;margin-left:20px"><table class="form">'; - foreach($table as $type => $valeurs) - { - $html.='<tr><th class="form" align="left" colspan="2">'.$valeurs["titre"].'</th></tr>'; - for($i=1; $i< count($valeurs); $i++) - { - //$url='<a href="'.URL_BASE.'php/recherche_recherche.php?lancer=oui'; - //if($type=="type_doc") $url.="&type_doc=".substr($valeurs[$i]["id"],1).'">'; - //else - //{ - // if($_REQUEST["type_doc"]) $url.="&type_doc=".$_REQUEST["type_doc"]; - // $facette='['.$valeurs[$i]["id"]."]"; - // if(strpos($_REQUEST["facette"],$facette) !== false) $facette=""; - // $url.='&facette='.$_REQUEST["facette"].$facette.'">'; - //} - $html.='<tr><td style="width:15px" class="form"></td>'; - $html.='<td class="form">'.$url.$valeurs[$i]["libelle"]." : ".$valeurs[$i]["nombre"].'</a></td></tr>'; - } - } - $html.='</table></div>'; - return $html; -} -function quit($msg) -{ - if($msg) print(BR.BR.'<h3 class="erreur" style="margin-left:30px">'.$msg.'</h3>'); - print('</body></html>'); - exit; -} - -?> diff --git a/cosmogramme/php/recherche_recherche.php b/cosmogramme/php/recherche_recherche.php deleted file mode 100644 index 5ef3e8366ceaaae12fa98eadb2840141c44bd557..0000000000000000000000000000000000000000 --- a/cosmogramme/php/recherche_recherche.php +++ /dev/null @@ -1,374 +0,0 @@ -<?PHP -/** - * Copyright (c) 2012, 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 - */ -////////////////////////////////////////////////////////////////////////////// -// RECHERCHE -////////////////////////////////////////////////////////////////////////////// -include("_init_frame.php"); - -unset($_SESSION["url_retour"]); - -// Classe indexation -require_once("fonctions/objets_saisie.php"); -require_once("classe_bib.php"); -require_once("classe_indexation.php"); -require_once("classe_dewey.php"); -require_once("classe_pcdm4.php"); -require_once("classe_liste_notices.php"); -$oListe=new liste_notices(); -$ix= new indexation(); - -// Comptage des notices et des exemplaires -print('<h1>Recherche de notices</h1>'); -$nb_notices=$sql->fetchOne("select count(*) from notices"); -$nb_ex=$sql->fetchOne("select count(*) from exemplaires"); -print('<span class="orange"><b>La base contient '.number_format($nb_notices,0, ',', ' ').' notices et '.number_format($nb_ex,0, ',', ' ').' exemplaires</b></span>'.BR.BR); - -// On met les criteres de recherche dans la session -$page=$_REQUEST["page"]; -if($_POST["expression_recherche"]) $_SESSION["recherche"]=$_POST; -else $_POST=$_SESSION["recherche"]; -$_SESSION["url_retour"]=URL_BASE."php/recherche_recherche.php?lancer=oui&page=".$page; -if($_REQUEST["facette"]) $_SESSION["url_retour"].="&facette=".$_REQUEST["facette"]; -if($_REQUEST["type_doc"]) {$_POST["type_document"]=$_REQUEST["type_doc"];$_SESSION["url_retour"].="&type_doc=".$_REQUEST["type_doc"];} - -// HTML -print('<form method="post" action="recherche_recherche.php?lancer=oui">'); -print('<table class="form" cellspacing="0" style="width:500px;margin-left:20px"><tr>'); -print('<th class="form" align="right" style="height:50px">Recherche</th>'); -print('<th class="form"><input type="text" name="expression_recherche" size="50" value="'.stripSlashes($_POST["expression_recherche"]).'"></th>'); -print('<th class="form"><input type="submit" value="Lancer" class="bouton"></th>'); -print('</tr><tr><td colspan="3" class="form" align="center">'); -afficherOptions(); -print('</td></tr></table></form>'); - -if(!$_REQUEST["lancer"]) quit(""); - -///////////////////////////////////////////////////////////////// -// Resultat de la recherche -///////////////////////////////////////////////////////////////// - -// Analyse de l'expression -$recherche_saisie=trim(strip_tags($_POST["expression_recherche"])); -if(! $recherche_saisie) quit("Aucune expression saisie"); - -$mots=$ix->getMots($recherche_saisie); -$recherche=""; -foreach($mots as $mot) -{ - $mot=$ix->getExpressionRecherche($mot); - if($mot) - { - if($_POST["pertinence"]=="1") $recherche.=" ".$mot; - else $recherche.=" +".$mot; - } -} - -$recherche=trim($recherche); -if(!$recherche) quit("Il n'y aucun mot assez significatif pour la recherche."); - -// Constitution des requetes -$req_comptage="Select count(*)from notices "; -$req_facettes="select id_notice,type_doc,facettes from notices "; -if($_POST["pertinence"]=="1") $against=" AGAINST('".$recherche."')"; -else $against=" AGAINST('".$recherche."' IN BOOLEAN MODE)"; - -if($_POST["axe_recherche"] > "") -{ - if($_POST["axe_recherche"]=="unimarc") - { - $against=""; $where="Where unimarc like '%$recherche_saisie%'"; - $_POST["tri_resultat"]="alpha_titre"; - } - else $where="Where MATCH(".$_POST["axe_recherche"].")"; -} -if(!$where) $where="Where MATCH(titres,auteurs,editeur,collection,matieres,dewey)"; -if($_REQUEST["facette"]) {$facette=str_replace("["," +", $_REQUEST["facette"]);$facette=str_replace("]","",$facette);} -if($_POST["bibliotheque"] > "") $facette.= " +".$_POST["bibliotheque"].$facette; -if($facette) $conditions=" And MATCH(facettes) AGAINST('".$facette."' IN BOOLEAN MODE)"; -if($_POST["type_document"] > "") $conditions.=" And type_doc='".$_POST["type_document"]."'"; -if($_POST["tri_resultat"] > "") -{ - $req="select id_notice from notices "; - $order_by=" order by ".$_POST["tri_resultat"]; -} -else -{ - $req="select id_notice,MATCH(alpha_titre) ".str_replace("+"," ",$against)." as rel1, "; - $req.="MATCH(alpha_auteur)".str_replace("+"," ",$against)." as rel2 "; - $req.="from notices "; - $order_by=" ORDER BY (rel1)+(rel2) desc"; -} - -$req.=$where.$against.$conditions.$order_by; -$req_comptage.=$where.$against.$conditions; -$req_facettes.=$where.$against.$conditions; - -print(BR."<B>Requete : </b>".$req.BR); - -// Lancer les requetes -$temps=time(); -$nombre=$sql->fetchOne($req_comptage); -print(BR.'<span class="orange" style="margin-left:10px"><b>Temps d\'éxécution requête de comptage : '.(time()-$temps).' secondes'.'</b></span>'.BR); -if(!$nombre) quit("Aucun résultat trouvé"); - -$temps=time(); -$liste=$oListe->getListe($req,$page); -print('<span class="orange" style="margin-left:10px"><b>Temps d\'éxécution requête de recherche : '.(time()-$temps).' secondes</b></span>'.BR); -$temps=time(); -$html_facettes=getFacettes($req_facettes); -print('<span class="orange" style="margin-left:10px"><b>Temps de calcul des facettes : '.(time()-$temps).' secondes</b></span>'.BR); -print('<span class="orange" style="margin-left:10px"><b>Résultats : '.$nombre.'</b></span>'.BR); -flush(); -print(BR.$html_facettes); - -// Résultat -$args_url="lancer=oui"; -if($_REQUEST["facette"]) $args_url.="&facette=".$_REQUEST["facette"]; -print(BR.$oListe->getHtml($liste,$args_url)); -quit(""); - -// options -function afficherOptions() -{ - print('<table cellspacing="0" width="100%">'); - print('<tr><td align="right" class="form_milieu" width="50%">Axe de recherche </td><td class="form_milieu">'. getCombo(1) .'</td></tr>'); - print('<tr><td align="right" class="form_milieu">Type de document </td><td class="form_milieu">'. getCombo(2) .'</td></tr>'); - print('<tr><td align="right" class="form_milieu">Bibliothèque </td><td class="form_milieu">'. getCombo(4) .'</td></tr>'); - print('<tr><td align="right" class="form_milieu">Tri du résultat </td><td class="form_milieu">'. getCombo(3) .'</td></tr>'); - if($_POST["pertinence"] == "1") $coche=" checked"; else $coche=""; - print('<tr><td align="right" class="form_milieu">Elargir la recherche (pertinence) </td><td class="form_milieu"><input type="checkbox" name="pertinence" value="1"'.$coche.'>'.'</td></tr>'); - if($_POST["expression_exacte"] == "1") $coche=" checked"; else $coche=""; - print('</table>'); -} - -function getCombo($type) -{ - switch($type) - { - // Axes de recherche - case 1: - $name = "axe_recherche"; - $valeurs=array(""=>"tous","titres"=>"Titres","auteurs"=>"Auteurs","editeur"=>"Editeurs","collection"=>"collections","matieres"=>"matieres /sujets","dewey"=>"Dewey / pcdm4","unimarc"=>"Full unimarc" ); - break; - // Types de documents - case 2: - $name = "type_document"; - return getComboCodif($name,"types_docs",$_POST[$name],"",true); - break; - // Tris du résultat - case 3: - $name = "tri_resultat"; - $valeurs=array(""=>"aucun","alpha_titre"=>"Par titres","alpha_auteur"=>"Par auteurs","annee desc"=>"Par années"); - break; - // Bibliotheque - case 4: - $name = "bibliotheque"; - $oBib=new bibliotheque(); - $valeurs=array(""=>"toutes"); - $bibs=$oBib->getAll(); - foreach($bibs as $bib) - { - $code="B".$bib["id_bib"]; - $valeurs[$code]=stripSlashes($bib["nom_court"]); - } - break; - } - $selection=$_POST[$name]; - $combo='<select name="'.$name.'">'; - foreach($valeurs as $clef => $valeur) - { - if($selection == $clef) $selected=' selected="selected"'; else $selected =""; - $combo.='<option value="'.$clef.'"'.$selected.'>'.$valeur.'</option>'; - } - $combo.='</select>'; - return $combo; -} -// Calcul des facettes -function getFacettes($req) -{ - global $sql; - $result=$sql->prepareListe($req); - while($notice=$sql->fetchNext($result)) - { - $type="T".$notice["type_doc"]; - $facettes["type_doc"][$type]++; - $items=explode(" ",trim($notice["facettes"])); - foreach($items as $item) - { - $type=substr($item,0,1); - $facettes[$type][$item]++; - } - } - arsort($facettes["type_doc"]); - arsort($facettes["B"]); - if($facettes["A"]) arsort($facettes["A"]); - if($facettes["D"]) arsort($facettes["D"]); - if($facettes["P"]) arsort($facettes["P"]); - if($facettes["M"]) arsort($facettes["M"]); - if($facettes["L"]) arsort($facettes["L"]); - if($facettes["F"]) arsort($facettes["F"]); - - // Types de docs - $nb=0; - $table["type_doc"]["titre"]="Type de document"; - foreach($facettes["type_doc"] as $clef => $nombre) - { - $nb++; - if($nb>5) break; - $id_type_doc=substr($clef,1); - $table["type_doc"][$nb]["id"]=$clef; - $table["type_doc"][$nb]["libelle"]=getLibCodifVariable("types_docs",$id_type_doc); - $table["type_doc"][$nb]["nombre"]=$nombre; - } - // Bibliotheques - $nb=0; - $table["B"]["titre"]="Bibliothèque"; - foreach($facettes["B"] as $clef => $nombre) - { - $nb++; - if($nb>5) break; - $id_bib=substr($clef,1); - $table["B"][$nb]["id"]=$clef; - $table["B"][$nb]["libelle"]=$sql->fetchOne("select nom_court from int_bib where id_bib=$id_bib"); - $table["B"][$nb]["nombre"]=$nombre; - } - // Auteurs - $nb=0; - if($facettes["A"]) - { - $table["A"]["titre"]="Auteur"; - foreach($facettes["A"] as $clef => $nombre) - { - $nb++; - if($nb>5) break; - $id_auteur=substr($clef,1); - $table["A"][$nb]["id"]=$clef; - $table["A"][$nb]["libelle"]=$sql->fetchOne("select libelle from codif_auteur where id_auteur=$id_auteur"); - $table["A"][$nb]["nombre"]=$nombre; - } - } - // Dewey - $nb=0; - if($facettes["D"]) - { - $table["D"]["titre"]="Dewey"; - foreach($facettes["D"] as $clef => $nombre) - { - $nb++; - if($nb>5) break; - $id_dewey=substr($clef,1); - $table["D"][$nb]["id"]=$clef; - $table["D"][$nb]["libelle"]=dewey::getLibelle($id_dewey); - $table["D"][$nb]["nombre"]=$nombre; - } - } - // Pcdm4 - $nb=0; - if($facettes["P"]) - { - $table["P"]["titre"]="Pcdm4"; - foreach($facettes["P"] as $clef => $nombre) - { - $nb++; - if($nb>5) break; - $id_pcdm4=substr($clef,1); - $table["P"][$nb]["id"]=$clef; - $table["P"][$nb]["libelle"]=pcdm4::getLibelle($id_pcdm4); - $table["P"][$nb]["nombre"]=$nombre; - } - } - // Matières - $nb=0; - if($facettes["M"]) - { - $table["M"]["titre"]="Mot-matière"; - foreach($facettes["M"] as $clef => $nombre) - { - $nb++; - if($nb>5) break; - $id_matiere=substr($clef,1); - $table["M"][$nb]["id"]=$clef; - $table["M"][$nb]["libelle"]=$sql->fetchOne("select libelle from codif_matiere where id_matiere=$id_matiere"); - $table["M"][$nb]["nombre"]=$nombre; - } - } - // Langues - $nb=0; - if($facettes["L"]) - { - $table["L"]["titre"]="Langue"; - foreach($facettes["L"] as $clef => $nombre) - { - $nb++; - if($nb>5) break; - $id_langue=substr($clef,1); - $table["L"][$nb]["id"]=$clef; - $table["L"][$nb]["libelle"]=$sql->fetchOne("select libelle from codif_langue where id_langue='$id_langue'"); - $table["L"][$nb]["nombre"]=$nombre; - } - } - // Centres d'interet - $nb=0; - if($facettes["F"]) - { - $table["F"]["titre"]="Centre d'intérêt"; - foreach($facettes["F"] as $clef => $nombre) - { - $nb++; - if($nb>5) break; - $id_interet=substr($clef,1); - $table["F"][$nb]["id"]=$clef; - $table["F"][$nb]["libelle"]=$sql->fetchOne("select libelle from codif_interet where id_interet='$id_interet'"); - $table["F"][$nb]["nombre"]=$nombre; - } - } - // Fabriquer le Html - $html='<div style="width:500px;margin-left:20px"><table class="form">'; - foreach($table as $type => $valeurs) - { - $html.='<tr><th class="form" align="left" colspan="2">'.$valeurs["titre"].'</th></tr>'; - for($i=1; $i< count($valeurs); $i++) - { - $url='<a href="'.URL_BASE.'php/recherche_recherche.php?lancer=oui'; - if($type=="type_doc") $url.="&type_doc=".substr($valeurs[$i]["id"],1).'">'; - else - { - if($_REQUEST["type_doc"]) $url.="&type_doc=".$_REQUEST["type_doc"]; - $facette='['.$valeurs[$i]["id"]."]"; - if(strpos($_REQUEST["facette"],$facette) !== false) $facette=""; - $url.='&facette='.$_REQUEST["facette"].$facette.'">'; - } - $html.='<tr><td style="width:15px" class="form"></td>'; - $html.='<td class="form">'.$url.$valeurs[$i]["libelle"]." : ".$valeurs[$i]["nombre"].'</a></td></tr>'; - } - } - $html.='</table></div>'; - return $html; -} - -function quit($msg) -{ - if($msg) print(BR.BR.'<h3 class="erreur" style="margin-left:30px">'.$msg.'</h3>'); - print('</body></html>'); - exit; -} - -?> diff --git a/cosmogramme/php/recherche_tags.php b/cosmogramme/php/recherche_tags.php index 7b88bfa560e8d5c279e2f041d6dfac4aafbfdceb..04cab46d7c0f4c0921b7ac51581fcd6cfd045c53 100644 --- a/cosmogramme/php/recherche_tags.php +++ b/cosmogramme/php/recherche_tags.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ ////////////////////////////////////////////////////////////////////////////// // TAGS TOUS MOTS @@ -29,8 +29,6 @@ unset($_SESSION["url_retour"]); require_once("fonctions/objets_saisie.php"); require_once("classe_bib.php"); require_once("classe_indexation.php"); -require_once("classe_dewey.php"); -require_once("classe_pcdm4.php"); require_once("classe_liste_notices.php"); $oListe=new liste_notices(); $ix= new indexation(); @@ -100,25 +98,25 @@ function getTags($req) if(!$max_tags) $max_tags=100; $max=0; $min=1000000; - + $result=$sql->prepareListe($req); while($notice=$sql->fetchNext($result)) { $items=explode(" ",trim($notice["facettes"])); foreach($items as $item) - { + { $type=$item[0]; if($type=="M" or $type=="D" or $type=="P") $facettes[$item]++; } } - + // Trier par ordre décroissant du nombre if(!$facettes) return false; - arsort($facettes); - + arsort($facettes); + // Calcul des tranches par ecart a la moyenne $tranche=calcultranches(array_slice($facettes,0,$max_tags),$max_tags); - + // Prendre les tags a représenter $nb=0; foreach($facettes as $clef => $nombre) @@ -143,7 +141,7 @@ function getTags($req) // Remettre dans un ordre aleatoire ksort($alea); - + // Fabriquer le Html $html='<div class="nuage" style="margin-left:20px">'; foreach($alea as $index) @@ -172,7 +170,7 @@ function getCombo($type) $oBib=new bibliotheque(); $valeurs=array(""=>"toutes"); $bibs=$oBib->getAll(); - foreach($bibs as $bib) + foreach($bibs as $bib) { $code="B".$bib["id_bib"]; $valeurs[$code]=stripSlashes($bib["nom_court"]); @@ -201,7 +199,7 @@ function calcultranches($tableau,$nb_elements) $data=array_values($tableau); //tracedebug(1,$data); $min=1000000; - + for ($i = 0; $i < $nb_elements; $i++) { $sumX += $data[$i]; @@ -210,7 +208,7 @@ function calcultranches($tableau,$nb_elements) if($data[$i] > $max) $max = $data[$i]; } $mean = $sumX / $nb_elements; - $stdDev = sqrt($sumX2 - $mean * $mean * $nb_elements) / $nb_elements; + $stdDev = sqrt($sumX2 - $mean * $mean * $nb_elements) / $nb_elements; $fBreakVal = $mean - ($stdDev * 3); for( $i = 0; $i < 10; $i++) { @@ -225,7 +223,7 @@ function calcultranches($tableau,$nb_elements) function quit($msg) { if($msg) print(BR.BR.'<h3 class="erreur" style="margin-left:30px">'.$msg.'</h3>'); - print('</body></html>'); + print('</body></html>'); exit; } diff --git a/cosmogramme/tests/php/classes/KohaPeriodiquesTest.php b/cosmogramme/tests/php/classes/KohaPeriodiquesTest.php index 9808391b9c776573a80ba3605c73bc61e7f45927..951859ded32d5ac831aaa3322d2f2bdb5f81b4fd 100644 --- a/cosmogramme/tests/php/classes/KohaPeriodiquesTest.php +++ b/cosmogramme/tests/php/classes/KohaPeriodiquesTest.php @@ -625,7 +625,7 @@ class KohaPeriodiquesMatriculeAngesTest extends KohaPeriodiquesWithArticlesTestC public function firstMatriculeAngesSerialShouldHave461WithIdAndNumber() { $record = Class_Notice::findFirstBy(['clef_chapeau' => 'MATRICULE DES ANGES LE']); - $this->assertEquals('111511 Matricule des Anges (Le) 179', + $this->assertEquals(['111511', 'Matricule des Anges (Le)', '179'], $record->getAllStringsInFields([['461', '9'], ['461', 't'], ['461', 'v'],])); } diff --git a/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php b/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php index 1b4809c6a2aa4733ce62677ee5e71524213b5577..db230b016d4f0393a62e27a0dd845e995853ff53 100644 --- a/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php +++ b/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php @@ -53,7 +53,7 @@ class KohaRecordIntegrationBadUnimarcTest extends KohaRecordIntegrationTestCase /** @test */ public function titleShouldBePagaille() { - $this->assertEquals('La Pagaille', $this->notice_data['titres'][0]); + $this->assertEquals('La Pagaille', Class_Notice::find(1)->getRecordTitle()); } } @@ -109,7 +109,7 @@ class KohaRecordIntegrationBdMilleniumTest extends KohaRecordIntegrationTestCase /** @test */ public function editorDupuisShouldBeIndexedOnSave() { - $this->assertEquals('DUPUIS DUPUI', $this->notice_integration->noticeToDBEnreg()['editeur']); + $this->assertEquals('DUPUIS DUPUI', $this->millenium->getEditeur()); } @@ -561,7 +561,7 @@ class KohaRecordIntegrationEscapableAnnexeCodesTest extends KohaRecordIntegratio /** @test */ public function titleShouldBeAbecedaire() { - $this->assertEquals('abécédaire imaginaire de Balthazar (L\')', $this->notice_data['titres'][0]); + $this->assertEquals('abécédaire imaginaire de Balthazar (L\')', Class_Notice::find(1)->getRecordTitle()); } @@ -974,6 +974,7 @@ class NoticeIntegrationWithSubfieldDeduplicationDollarNineTest extends NoticeInt + class NoticeIntegrationWithSubfieldDeduplicationNoneTest extends NoticeIntegrationWithSubfieldDeduplicationTest { public function getProfilDonnees() { return Class_IntProfilDonnees::forKoha() @@ -1010,3 +1011,36 @@ class KohaRecordIntegrationUnimarcArchiTest extends KohaRecordIntegrationTestCas $this->assertEquals(7, Class_Exemplaire::countBy([])); } } + + + + +class NoticeIntegrationTest extends KohaRecordIntegrationTestCase { + + public function setUp() { + parent::setUp(); + + Class_CosmoVar::setValueOf('unimarc_zone_titre', '200$a;464$t'); + + $this->loadNotice('unimarc_martial_solal'); + } + + + /** @test */ + public function titlesShouldContainsAllTracks() { + $this->assertEquals('P_MY P_ONE P_AND P_ONLY P_LOVE MY ONE AND ONLY LOVE HAVE YOU MET MISS JONES MEDLEY CARAVAN PRELUDE TO A KISS SOPHISTICATED LADY SATIN DOLL TAKE THE A TRAIN COMING YESTERDAY KOLN DUET BODY AND SOUL NIGHT AND DAY MARCHE TURQUE ALL THE THINGS YOU ARE NIGHT IN TUNISIA TEA FOR TWO SIR JACK II INTERVIEW WITH MARTIAL SOLAL ONLI LOV AV MI JON MEDLAI KARAVAN PRELUD KI SOFISTIKAT LADI DOL TAK TRIN KOMING IESTERDAI DU BODI NI MARCH TURK TING JAK OUI', Class_Notice::find(1)->getTitres()); + } + + + /** @test */ + public function titlesShouldHaveTakeTheATrainWithAllWords() { + $this->assertContains('TAKE THE A TRAIN', Class_Notice::find(1)->getTitres()); + } + + + /** @test */ + public function auteursShouldContainsMartialSolalMarkedAsPrimary() { + $this->assertEquals('P_SOLAL P_MARTIAL SOLAL MARTIAL SOLAL', + Class_Notice::find(1)->getAuteurs()); + } +} diff --git a/cosmogramme/tests/php/classes/NanookRecordsIntegrationTest.php b/cosmogramme/tests/php/classes/NanookRecordsIntegrationTest.php index c4431e70b003fae25e0afe5345970efd4e45b315..2cd666a835407c6aa77f96d2f9d9670162143ef9 100644 --- a/cosmogramme/tests/php/classes/NanookRecordsIntegrationTest.php +++ b/cosmogramme/tests/php/classes/NanookRecordsIntegrationTest.php @@ -196,7 +196,7 @@ class NanookRecordsIntegrationInterestEsperluetteTest extends NanookRecordsInteg /** @test */ public function deweyShouldContainsEsperluette() { - $this->assertEquals('80993352 ESPERLUETTE ESPERLUET 2014', $this->notice->getDewey()); + $this->assertEquals('80993352 ESPERLUETTE 2014 ESPERLUET', $this->notice->getDewey()); } } @@ -357,10 +357,18 @@ class NanookRecordsIntegrationLeChatonDansLaSouriciereTest extends NanookRecords $this->assertEquals([],$this->_notice->getNoticesMemeSeries()); } + /** @test */ public function clefChapeauShouldBeMiniSourisNoire() { $this->assertEquals('MINI SOURIS NOIRE', $this->_notice->getClefChapeau()); } + + + /** @test */ + public function auteursTermsShouldBeExactTermsLouchardAntoninLouchard() { + $this->assertEquals('P_PIQUEMAL P_MICHEL PIQUEMAL MICHEL PIQUEMAL LOUCHARD ANTONIN LOUCHARD PIKEMAL LOUCHAR', + $this->_notice->getAuteurs()); + } } @@ -424,7 +432,7 @@ class NanookRecordsIntegrationOblivionTest extends NanookRecordsIntegrationTestC /** @test */ public function deweyShouldBeIndexedWithFilmFantastique() { - $this->assertEquals('FANTASTIQUE FANTASTIK FANTASY FANTASI ACTION AKSION FILM', + $this->assertEquals('SF FANTASTIQUE FANTASY ACTION FILM FANTASTIQUE FANTASTIK FANTASI AKSION', $this->_notice->getDewey()); } @@ -803,4 +811,4 @@ class NanookRecordsIntegrationModifLabelOnDynamicFacetTest extends NanookRecords public function codifThesaurusShouldHaveLibelle0_4ans() { $this->assertEquals('0-4 ans' , Class_CodifThesaurus::find(2)->getLibelle()); } -} \ No newline at end of file +} diff --git a/cosmogramme/tests/php/classes/NoticeIntegrationAloesTest.php b/cosmogramme/tests/php/classes/NoticeIntegrationAloesTest.php index 7ed7b2708bd09a05f35e5fb1b675b64fdcb38284..6037fd210521da6737438eb390c2163b5e87f339 100644 --- a/cosmogramme/tests/php/classes/NoticeIntegrationAloesTest.php +++ b/cosmogramme/tests/php/classes/NoticeIntegrationAloesTest.php @@ -31,178 +31,186 @@ abstract class NoticeIntegrationAloesTestCase extends NoticeIntegrationTestCase public function getProfilDonnees() { - return Class_IntProfilDonnees::forALOES() - ->setIdProfil(111) - ->getRawAttributes(); - } + return Class_IntProfilDonnees::forALOES() + ->setIdProfil(111) + ->getRawAttributes(); + } } class NoticeIntegrationAloes11septembre2001Test extends NoticeIntegrationAloesTestCase { - public function getProfilDonnees() { - return Class_IntProfilDonnees::forALOES() - ->setAttributs(serialize( - [ [ - 'type_doc' => [ - [ 'code' => '0', 'label' => '', 'zone_995' => '' ], - [ 'code' => '1', 'label' => 'am;na', 'zone_995' => 'LIV;MS' ], - [ 'code' => '2', 'label' => 'as', 'zone_995' => 'PER'], - [ 'code' => '3', 'label' => 'i;j', 'zone_995' => 'CD;LIVCD;LIVK7;K7'], - [ 'code' => '4', 'label' => 'g','zone_995' => 'DVD'], - [ 'code' => '5', 'label' => 'l;m', 'zone_995' => 'CDR'], - [ 'code' => '6', 'label' => 'cm', 'zone_995' => 'PAR'], - [ 'code' => '7', 'label' => '', 'zone_995' => 'BRO' ], - [ 'code' => '8', 'label' => '', 'zone_995' => 'DOS'], - [ 'code' => '9', 'label' => '', 'zone_995' => ''], - [ 'code' => '10', 'label' => '', 'zone_995' => 'WEB;MF'], - [ 'code' => '11', 'label' => '', 'zone_995' => 'MET'], - [ 'code' => '12', 'label' => '', 'zone_995' => 'JEU'], - [ 'code' => '13', 'label' => '', 'zone_995' => 'CAR'], - [ 'code' => '14', 'label' => '', 'zone_995' => 'DDD'], - [ 'code' => '15', 'label' => '', 'zone_995' => 'DIA'], - [ 'code' => '16', 'label' => '', 'zone_995' => 'DIS'], - [ 'code' => '17', 'label' => '', 'zone_995' => 'CDJ'], - [ 'code' => '18', 'label' => '', 'zone_995' => 'LDVD'], - [ 'code' => '19', 'label' => '', 'zone_995' => 'LIA'], - [ 'code' => '20', 'label' => '', 'zone_995' => 'LIS'], - [ 'code' => '21', 'label' => '', 'zone_995' => 'TXT'], - [ 'code' => '22', 'label' => '', 'zone_995' => ''], - [ 'code' => '23', 'label' => '', 'zone_995' => 'VDD;VID;UMATIC'], - [ 'code' => '24', 'label' => '', 'zone_995' => 'METI'], - ], - 'champ_code_barres' => 'f', - 'champ_cote' => 'k', - 'champ_type_doc' => 'r', - 'champ_genre' => '', - 'champ_section' => 'q', - 'champ_emplacement' => 'u', - 'champ_annexe' => 'b' - ], - - [ 'champs' => ''], - [ 'champs' => ''], - [ 'champs' => ''], - [ 'champs' => '', 'xml_balise_abonne' => '', 'xml_champs_abonne' => [ 'IDABON' => '', - 'ORDREABON' => '', - 'NOM' => '', - 'PRENOM' => '', - 'NAISSANCE' => '', - 'PASSWORD' => '', - 'MAIL' => '', - 'DATE_DEBUT' => '', - 'DATE_FIN' => '', - 'ID_SIGB' => '' ] ], - [ 'zone' => '995', 'champ' => 'v', 'format' => '3', 'jours' => '', 'valeurs' => 'n'] - ])) - ->setIdProfil(111) - ->getRawAttributes(); - } - - public function setUp() { - parent::setUp(); - - $this->fixture('Class_CosmoVar', - ['id' => 'nature_docs', - 'liste' => "1:Collection\r\n2:Dataset\r\n3:Event\r\n4:Image"]); - - $this->fixture('Class_CosmoVar', - ['id' => 'types_docs', - 'liste' => "0:non identifié\r\n1:livres\r\n2:périodiques\r\n3:disques\r\n4:DVD\r\n5:cédéroms\r\n8:articles cms\r\n9:fils rss\r\n10:sites internet\r\n15:Liseuse\r\n21:Texte audio\r\n100:Livre Numérique\r\n101:Diaporamas\r\n102:Type doc\r\n103:OAI\r\n104:Type doc\r\n105:Formation Vodéclic\r\n106:Livres Numériques\r\n107:Vidéos à la demande\r\n108:Tout apprendre\r\n109:Enregistrement audio\r\n110:Numérique Premium"]); - } - - - /** @test */ - public function notice11Septembre2001ShouldHaveTypeDoc21() { - $this->loadNotice('unimarc_11_septembre_2001'); - - $notice = Class_Notice::find(1); - $this->assertEquals(21, $notice->getTypeDoc()); - } + public function getProfilDonnees() { + return Class_IntProfilDonnees::forALOES() + ->setAttributs(serialize( + [ [ + 'type_doc' => [ + [ 'code' => '0', 'label' => '', 'zone_995' => '' ], + [ 'code' => '1', 'label' => 'am;na', 'zone_995' => 'LIV;MS' ], + [ 'code' => '2', 'label' => 'as', 'zone_995' => 'PER'], + [ 'code' => '3', 'label' => 'i;j', 'zone_995' => 'CD;LIVCD;LIVK7;K7'], + [ 'code' => '4', 'label' => 'g','zone_995' => 'DVD'], + [ 'code' => '5', 'label' => 'l;m', 'zone_995' => 'CDR'], + [ 'code' => '6', 'label' => 'cm', 'zone_995' => 'PAR'], + [ 'code' => '7', 'label' => '', 'zone_995' => 'BRO' ], + [ 'code' => '8', 'label' => '', 'zone_995' => 'DOS'], + [ 'code' => '9', 'label' => '', 'zone_995' => ''], + [ 'code' => '10', 'label' => '', 'zone_995' => 'WEB;MF'], + [ 'code' => '11', 'label' => '', 'zone_995' => 'MET'], + [ 'code' => '12', 'label' => '', 'zone_995' => 'JEU'], + [ 'code' => '13', 'label' => '', 'zone_995' => 'CAR'], + [ 'code' => '14', 'label' => '', 'zone_995' => 'DDD'], + [ 'code' => '15', 'label' => '', 'zone_995' => 'DIA'], + [ 'code' => '16', 'label' => '', 'zone_995' => 'DIS'], + [ 'code' => '17', 'label' => '', 'zone_995' => 'CDJ'], + [ 'code' => '18', 'label' => '', 'zone_995' => 'LDVD'], + [ 'code' => '19', 'label' => '', 'zone_995' => 'LIA'], + [ 'code' => '20', 'label' => '', 'zone_995' => 'LIS'], + [ 'code' => '21', 'label' => '', 'zone_995' => 'TXT'], + [ 'code' => '22', 'label' => '', 'zone_995' => ''], + [ 'code' => '23', 'label' => '', 'zone_995' => 'VDD;VID;UMATIC'], + [ 'code' => '24', 'label' => '', 'zone_995' => 'METI'], + ], + 'champ_code_barres' => 'f', + 'champ_cote' => 'k', + 'champ_type_doc' => 'r', + 'champ_genre' => '', + 'champ_section' => 'q', + 'champ_emplacement' => 'u', + 'champ_annexe' => 'b' + ], + + [ 'champs' => ''], + [ 'champs' => ''], + [ 'champs' => ''], + [ 'champs' => '', 'xml_balise_abonne' => '', 'xml_champs_abonne' => [ 'IDABON' => '', + 'ORDREABON' => '', + 'NOM' => '', + 'PRENOM' => '', + 'NAISSANCE' => '', + 'PASSWORD' => '', + 'MAIL' => '', + 'DATE_DEBUT' => '', + 'DATE_FIN' => '', + 'ID_SIGB' => '' ] ], + [ 'zone' => '995', 'champ' => 'v', 'format' => '3', 'jours' => '', 'valeurs' => 'n'] + ])) + ->setIdProfil(111) + ->getRawAttributes(); + } + + public function setUp() { + parent::setUp(); + + $this->fixture('Class_CosmoVar', + ['id' => 'nature_docs', + 'liste' => "1:Collection\r\n2:Dataset\r\n3:Event\r\n4:Image"]); + + $this->fixture('Class_CosmoVar', + ['id' => 'types_docs', + 'liste' => "0:non identifié\r\n1:livres\r\n2:périodiques\r\n3:disques\r\n4:DVD\r\n5:cédéroms\r\n8:articles cms\r\n9:fils rss\r\n10:sites internet\r\n15:Liseuse\r\n21:Texte audio\r\n100:Livre Numérique\r\n101:Diaporamas\r\n102:Type doc\r\n103:OAI\r\n104:Type doc\r\n105:Formation Vodéclic\r\n106:Livres Numériques\r\n107:Vidéos à la demande\r\n108:Tout apprendre\r\n109:Enregistrement audio\r\n110:Numérique Premium"]); + } + + + /** @test */ + public function notice11Septembre2001ShouldHaveTypeDoc21() { + $this->loadNotice('unimarc_11_septembre_2001'); + + $notice = Class_Notice::find(1); + $this->assertEquals(21, $notice->getTypeDoc()); + } } class NoticeIntegrationAloesSiesteMamansTest extends NoticeIntegrationAloesTestCase { - public function setUp() { - parent::setUp(); - $this->loadNotice('unimarc_sieste_des_mamans'); - $this->loadNotice('unimarc_sieste_des_mamans'); - } - - /** @test */ - public function EuroSymbolShouldBeWellEncoded() { - $unimarc = new Class_NoticeUnimarc(); - $unimarc->setNotice(Class_Notice::find(1)->getUnimarc()); - $this->assertEquals('12 €', $unimarc->get_subfield('010', 'd')[0]); - } + public function setUp() { + parent::setUp(); + $this->loadNotice('unimarc_sieste_des_mamans'); + $this->loadNotice('unimarc_sieste_des_mamans'); + } + + /** @test */ + public function EuroSymbolShouldBeWellEncoded() { + $unimarc = new Class_NoticeUnimarc(); + $unimarc->setNotice(Class_Notice::find(1)->getUnimarc()); + $this->assertEquals('12 €', $unimarc->get_subfield('010', 'd')[0]); + } } class NoticeIntegrationAloesPommeDeReinetteTest extends NoticeIntegrationAloesTestCase { - public function getProfilDonnees() { - return Class_IntProfilDonnees::forALOES() - ->setIdProfil(111) + public function getProfilDonnees() { + return Class_IntProfilDonnees::forALOES() + ->setIdProfil(111) ->setItemField(Class_IntProfilDonnees::FIELD_ITEM_EMPLACEMENT, 'u') - ->getRawAttributes(); - } + ->getRawAttributes(); + } + + public function setUp() { + parent::setUp(); - public function setUp() { - parent::setUp(); + VariableCache::getInstance() + ->setListeCache([ + 'nature_docs'=> "1:Collection\r\n2:Dataset\r\n3:Event\r\n4:Image", + 'types_docs' => "0:non identifié\r\n1:livres\r\n2:périodiques\r\n3:disques\r\n4:DVD\r\n5:cédéroms\r\n8:articles cms\r\n9:fils rss\r\n10:sites internet\r\n15:Liseuse\r\n21:Texte audio\r\n100:Livre Numérique\r\n101:Diaporamas\r\n102:Type doc\r\n103:OAI\r\n104:Type doc\r\n105:Formation Vodéclic\r\n106:Livres Numériques\r\n107:Vidéos à la demande\r\n108:Tout apprendre\r\n109:Enregistrement audio\r\n110:Numérique Premium" + ]); - VariableCache::getInstance() - ->setListeCache([ - 'nature_docs'=> "1:Collection\r\n2:Dataset\r\n3:Event\r\n4:Image", - 'types_docs' => "0:non identifié\r\n1:livres\r\n2:périodiques\r\n3:disques\r\n4:DVD\r\n5:cédéroms\r\n8:articles cms\r\n9:fils rss\r\n10:sites internet\r\n15:Liseuse\r\n21:Texte audio\r\n100:Livre Numérique\r\n101:Diaporamas\r\n102:Type doc\r\n103:OAI\r\n104:Type doc\r\n105:Formation Vodéclic\r\n106:Livres Numériques\r\n107:Vidéos à la demande\r\n108:Tout apprendre\r\n109:Enregistrement audio\r\n110:Numérique Premium" - ]); + Class_CosmoVar::setValueOf('unimarc_zone_titre', '200$a;200$e'); - $this->fixture('Class_CodifEmplacement', - ['id' => 46, - 'libelle' => 'Espace Bébé', - 'regles' => '995$u=59;Espace bébé']); + $this->fixture('Class_CodifEmplacement', + ['id' => 46, + 'libelle' => 'Espace Bébé', + 'regles' => '995$u=59;Espace bébé']); - $this->loadNotice('unimarc_pomme_de_reinette'); + $this->loadNotice('unimarc_pomme_de_reinette'); - $this->_notice = Class_Notice::find(1); - $this->_exemplaire = Class_Exemplaire::findFirstBy(['id_notice' => 1, - 'code_barres' => '1203195946']); - } + $this->_notice = Class_Notice::find(1); + $this->_exemplaire = Class_Exemplaire::findFirstBy(['id_notice' => 1, + 'code_barres' => '1203195946']); + } - /** @test */ - public function exemplaireShouldHaveEmplacementE46() { - $this->assertEquals(46, $this->_exemplaire->getEmplacement()); - } + /** @test */ + public function exemplaireShouldHaveEmplacementE46() { + $this->assertEquals(46, $this->_exemplaire->getEmplacement()); + } - /** @test */ - public function facettesShouldContainsE46() { - $this->assertContains(' E46', $this->_notice->getFacettes()); - } + /** @test */ + public function facettesShouldContainsE46() { + $this->assertContains(' E46', $this->_notice->getFacettes()); + } + + + /** @test */ + public function titresTermsShouldBeExactTermsPommeDeReinetteEtDapiLesComptinesDesPetitsBeforeThenPhonetic() { + $this->assertEquals('P_POMME P_DE P_REINETTE P_ET P_POMME P_D P_API POMME DE REINETTE ET POMME D API LES COMPTINES DES PETITS POM RAINET KONTIN PETI', $this->_notice->getTitres()); + } } class NoticeIntegrationAloesSerialIndexpressBellesHistoireTest extends NoticeIntegrationAloesTestCase { - public function setUp() { - parent::setUp(); + public function setUp() { + parent::setUp(); - $contents = file_get_contents(dirname(__FILE__)."/unimarc_petit_doucet.txt"); + $contents = file_get_contents(dirname(__FILE__)."/unimarc_petit_doucet.txt"); - array_map([$this, 'loadNoticeFromString'], - preg_split('/'.chr(30).chr(29).'/', $contents)); + array_map([$this, 'loadNoticeFromString'], + preg_split('/'.chr(30).chr(29).'/', $contents)); - $this->notice = Class_Notice::find(1); - } + $this->notice = Class_Notice::find(1); + } - /** @test */ - public function mainTitleShouldBeBellesHistoires() { - $this->assertEquals('Belles histoires (Les)', $this->notice->getTitrePrincipal()); - } + /** @test */ + public function mainTitleShouldBeBellesHistoires() { + $this->assertEquals('Belles histoires (Les)', $this->notice->getTitrePrincipal()); + } /** @@ -217,228 +225,228 @@ class NoticeIntegrationAloesSerialIndexpressBellesHistoireTest extends NoticeInt class NoticeIntegrationAloesBienveillantesTest extends NoticeIntegrationAloesTestCase { - public function setUp() { - parent::setUp(); - $this->fixture('Class_CodifEmplacement', - ['id' => 2, - 'libelle' => 'Reserve', - 'regles' => '995$l=RES']); - $this->loadNotice("unimarc_bienveillantes"); - } - - /** @test */ - public function recordShouldContainsSixItems() { - $this->assertEquals(6, count($this->notice_data['exemplaires'])); - } - - /** @test */ - public function locationForFirstItemShouldNotHaveId2() { - $this->assertNotEquals(2, $this->notice_data['exemplaires'][0]['emplacement']); - } - - /** @test */ - public function thirdItemShouldHaveId2() { - $this->assertEquals(2, $this->notice_data['exemplaires'][2]['emplacement']); - } + public function setUp() { + parent::setUp(); + $this->fixture('Class_CodifEmplacement', + ['id' => 2, + 'libelle' => 'Reserve', + 'regles' => '995$l=RES']); + $this->loadNotice("unimarc_bienveillantes"); + } + + /** @test */ + public function recordShouldContainsSixItems() { + $this->assertEquals(6, count($this->notice_data['exemplaires'])); + } + + /** @test */ + public function locationForFirstItemShouldNotHaveId2() { + $this->assertNotEquals(2, $this->notice_data['exemplaires'][0]['emplacement']); + } + + /** @test */ + public function thirdItemShouldHaveId2() { + $this->assertEquals(2, $this->notice_data['exemplaires'][2]['emplacement']); + } } class NoticeIntegrationAloesZanzibarTest extends NoticeIntegrationAloesTestCase { - public function setUp() { - parent::setUp(); + public function setUp() { + parent::setUp(); - $this->loadNotice("unimarc_zanzibara"); - } + $this->loadNotice("unimarc_zanzibara"); + } - /** @test */ - public function subfield200AShouldBeZanzibaraVol8() { - $this->assertEquals('Zanzibara, vol. 8', - $this->notice_integration->get_subfield('200', 'a')[0]); - } + /** @test */ + public function subfield200AShouldBeZanzibaraVol8() { + $this->assertEquals('Zanzibara, vol. 8', + $this->notice_integration->get_subfield('200', 'a')[0]); + } - /** @test */ - public function subfield345AShouldBeGAM() { - $this->assertEquals('GAM', - $this->notice_integration->get_subfield('345', 'a')[0]); - } + /** @test */ + public function subfield345AShouldBeGAM() { + $this->assertEquals('GAM', + $this->notice_integration->get_subfield('345', 'a')[0]); + } - /** @test */ - public function subfield330ShouldContainsRajabSuleiman() { - $this->assertContains('L\'as du qanun Rajab Suleiman', - $this->notice_integration->get_subfield('330', 'a')[0]); - } + /** @test */ + public function subfield330ShouldContainsRajabSuleiman() { + $this->assertContains('L\'as du qanun Rajab Suleiman', + $this->notice_integration->get_subfield('330', 'a')[0]); + } } class NoticeIntegrationAloesDimancheALaPiscineTest extends NoticeIntegrationAloesTestCase { - public function getProfilDonnees() { - return Class_IntProfilDonnees::forALOES() - ->setIdProfil(111) + public function getProfilDonnees() { + return Class_IntProfilDonnees::forALOES() + ->setIdProfil(111) ->setItemField(Class_IntProfilDonnees::FIELD_ITEM_EMPLACEMENT, 'u') - ->getRawAttributes(); + ->getRawAttributes(); } - public function setUp() { - parent::setUp(); - $this->notice_sgbd=new notice_unimarc(); + public function setUp() { + parent::setUp(); + $this->notice_sgbd=new notice_unimarc(); + + $this->fixture('Class_CodifEmplacement', + ['id' => 54, + 'libelle' => 'adulte', + 'regles' => '995$u=Littérature adulte']); + + $this->fixture('Class_CodifSection', + ['id' => 2, + 'libelle' => 'adulte', + 'regles' => '995$q=A']); + + $this->fixture('Class_CodifGenre', + ['id' => 8, + 'libelle' => 'roman', + 'regles' => '902$a=Roman']); + + $this->fixture('Class_CodifAnnexe', ['id_origine' => 'A', + 'libelle' => 'Antibes', + 'id_bib' => 4, + 'invisible' => 0]); + + $this->onLoaderOfModel('Class_Exemplaire'); + $this->loadNotice("unimarc_dimanche_a_la_piscine"); + } - $this->fixture('Class_CodifEmplacement', - ['id' => 54, - 'libelle' => 'adulte', - 'regles' => '995$u=Littérature adulte']); - $this->fixture('Class_CodifSection', - ['id' => 2, - 'libelle' => 'adulte', - 'regles' => '995$q=A']); + /** @test */ + public function emplacementShouldHaveId54() { + $this->assertEquals(54, $this->notice_data['exemplaires'][0]['emplacement']); + } - $this->fixture('Class_CodifGenre', - ['id' => 8, - 'libelle' => 'roman', - 'regles' => '902$a=Roman']); - $this->fixture('Class_CodifAnnexe', ['id_origine' => 'A', - 'libelle' => 'Antibes', - 'id_bib' => 4, - 'invisible' => 0]); + /** @test */ + public function sectionShouldHaveId2() { + $this->assertEquals(2, $this->notice_data['exemplaires'][0]['section']); + } - $this->onLoaderOfModel('Class_Exemplaire'); - $this->loadNotice("unimarc_dimanche_a_la_piscine"); - } + /** @test */ + public function genreShouldHaveId8() { + $this->assertEquals(8, $this->notice_data['exemplaires'][0]['genre']); + } - /** @test */ - public function emplacementShouldHaveId54() { - $this->assertEquals(54, $this->notice_data['exemplaires'][0]['emplacement']); - } + /** @test */ + public function deweyShouldContainsRoman() { + $this->assertContains('ROMAN', + Class_Notice::find(1)->getDewey()); + } - /** @test */ - public function sectionShouldHaveId2() { - $this->assertEquals(2, $this->notice_data['exemplaires'][0]['section']); - } + /** @test */ + public function exemplairesCountShouldBeOne() { + $this->assertEquals(1, count($this->notice_data['exemplaires'])); + } - /** @test */ - public function genreShouldHaveId8() { - $this->assertEquals(8, $this->notice_data['exemplaires'][0]['genre']); - } + /** + * @test + * @see #13453 + */ + public function uniciteCodeBarreShouldNotRegress() { + $this->assertEquals( + [ + 'id_notice' => 1, + 'id_int_bib' => 1, + 'code_barres' => [2060303] + ], + Class_Exemplaire::getLoader()->getFirstAttributeForLastCallOn('basicDeleteBy') + ); + } - /** @test */ - public function deweyShouldContainsRoman() { - $this->assertContains('ROMAN', - Class_Notice::find(1)->getDewey()); - } + /** @test */ + public function exemplaireShouldHaveBeenSavedForNotice1() { + $exemplaire = Class_Exemplaire::findFirstBy(['id_notice' => 1]); + $this->assertNotEmpty($exemplaire); + return $exemplaire; + } - /** @test */ - public function exemplairesCountShouldBeOne() { - $this->assertEquals(1, count($this->notice_data['exemplaires'])); - } + /** + * @test + * @depends exemplaireShouldHaveBeenSavedForNotice1 + */ + public function exemplaireIdOrigineShouldBe0419704($exemplaire) { + $this->assertEquals('0419704', $exemplaire->getIdOrigine()); + } - /** - * @test - * @see #13453 - */ - public function uniciteCodeBarreShouldNotRegress() { - $this->assertEquals( - [ - 'id_notice' => 1, - 'id_int_bib' => 1, - 'code_barres' => [2060303] - ], - Class_Exemplaire::getLoader()->getFirstAttributeForLastCallOn('basicDeleteBy') - ); - } - - - /** @test */ - public function exemplaireShouldHaveBeenSavedForNotice1() { - $exemplaire = Class_Exemplaire::findFirstBy(['id_notice' => 1]); - $this->assertNotEmpty($exemplaire); - return $exemplaire; - } - - - /** - * @test - * @depends exemplaireShouldHaveBeenSavedForNotice1 - */ - public function exemplaireIdOrigineShouldBe0419704($exemplaire) { - $this->assertEquals('0419704', $exemplaire->getIdOrigine()); - } - - - /** - * @test - * @depends exemplaireShouldHaveBeenSavedForNotice1 - */ - public function exemplaireAnnexeShouldBeAntibes($exemplaire) { - $this->assertEquals('A', $exemplaire->getAnnexe()); - } - - - /** - * @test - * @depends exemplaireShouldHaveBeenSavedForNotice1 - */ - public function exemplaireIdBibShouldBeFour($exemplaire) { - $this->assertEquals(4, $exemplaire->getIdBib()); - } - - - /** - * @test - * @depends exemplaireShouldHaveBeenSavedForNotice1 - */ - public function exemplaireIdIntBibShouldBeOne($exemplaire) { - $this->assertEquals(1, $exemplaire->getIdIntBib()); - } - - - /** @test */ - public function noticeOneDateMajShouldBeToday() { - $this->assertContains(date('Y-m-d'), Class_Notice::find(1)->getDateMaj()); - } - - - /** @test */ - public function supprimerExemplaireShouldRemoveIt() { - $this->notice_integration->supprimerExemplaire(1, ['code_barres' => '2060303']); - Class_Exemplaire::clearCache(); - $this->assertEmpty(Class_Exemplaire::findFirstBy(['id_notice' => 1])); - } - - - /** @test */ - public function supprimerExemplaireWithUnknownCodeBarresShouldSetError() { - $this->notice_integration->supprimerExemplaire(1, ['code_barres' => '666']); - $this->assertEquals(['statut' => 0, - 'erreur' => 'code-barres à supprimer non trouvé', - 'warnings' => [], - 'identification' => 'non trouvée'], - $this->notice_integration->getLastStatut()); - } - - - /** @test */ - public function supprimerExemplaireWithNoIdNoticeShouldSetError() { - $this->notice_integration->supprimerExemplaire(0, []); - $this->assertEquals(['statut' => 0, - 'erreur' => 'notice de l\'exemplaire à supprimer non trouvée', - 'warnings' => [], - 'identification' => 'non trouvée'], - $this->notice_integration->getLastStatut()); - } + + /** + * @test + * @depends exemplaireShouldHaveBeenSavedForNotice1 + */ + public function exemplaireAnnexeShouldBeAntibes($exemplaire) { + $this->assertEquals('A', $exemplaire->getAnnexe()); + } + + + /** + * @test + * @depends exemplaireShouldHaveBeenSavedForNotice1 + */ + public function exemplaireIdBibShouldBeFour($exemplaire) { + $this->assertEquals(4, $exemplaire->getIdBib()); + } + + + /** + * @test + * @depends exemplaireShouldHaveBeenSavedForNotice1 + */ + public function exemplaireIdIntBibShouldBeOne($exemplaire) { + $this->assertEquals(1, $exemplaire->getIdIntBib()); + } + + + /** @test */ + public function noticeOneDateMajShouldBeToday() { + $this->assertContains(date('Y-m-d'), Class_Notice::find(1)->getDateMaj()); + } + + + /** @test */ + public function supprimerExemplaireShouldRemoveIt() { + $this->notice_integration->supprimerExemplaire(1, ['code_barres' => '2060303']); + Class_Exemplaire::clearCache(); + $this->assertEmpty(Class_Exemplaire::findFirstBy(['id_notice' => 1])); + } + + + /** @test */ + public function supprimerExemplaireWithUnknownCodeBarresShouldSetError() { + $this->notice_integration->supprimerExemplaire(1, ['code_barres' => '666']); + $this->assertEquals(['statut' => 0, + 'erreur' => 'code-barres à supprimer non trouvé', + 'warnings' => [], + 'identification' => 'non trouvée'], + $this->notice_integration->getLastStatut()); + } + + + /** @test */ + public function supprimerExemplaireWithNoIdNoticeShouldSetError() { + $this->notice_integration->supprimerExemplaire(0, []); + $this->assertEquals(['statut' => 0, + 'erreur' => 'notice de l\'exemplaire à supprimer non trouvée', + 'warnings' => [], + 'identification' => 'non trouvée'], + $this->notice_integration->getLastStatut()); + } } @@ -447,92 +455,92 @@ class NoticeIntegrationAloesDimancheALaPiscineTest extends NoticeIntegrationAloe class NoticeIntegrationAloesBiblioArcheoAnimauxTest extends NoticeIntegrationAloesTestCase { - public function setUp() { - parent::setUp(); - $this->loadNotice('unimarc_archeo_animaux'); + public function setUp() { + parent::setUp(); + $this->loadNotice('unimarc_archeo_animaux'); - $this->notice_sgbd->ouvrirNotice($this->notice_integration->noticeToDBEnreg($this->notice_data)['unimarc'], 0); - } + $this->notice_sgbd->ouvrirNotice($this->notice_integration->noticeToDBEnreg($this->notice_data)['unimarc'], 0); + } - /** @test */ - public function typeDocShouldBeOne() { - $this->assertEquals(1, - $this->notice_integration->noticeToDBEnreg($this->notice_data)['type_doc']); - } + /** @test */ + public function typeDocShouldBeOne() { + $this->assertEquals(1, + $this->notice_integration->noticeToDBEnreg($this->notice_data)['type_doc']); + } - /** @test */ - public function field200AShouldBeAsExpected() { - $this->assertEquals('Archéo animaux',$this->notice_sgbd->get_subfield('200', 'a')[0]); - } + /** @test */ + public function field200AShouldBeAsExpected() { + $this->assertEquals('Archéo animaux',$this->notice_sgbd->get_subfield('200', 'a')[0]); + } - /** @test */ - public function field200EShouldBeAsExpected() { - $this->assertEquals("l'incroyable histoire de l'archéologie des animaux",$this->notice_sgbd->get_subfield('200', 'e')[0]); - } + /** @test */ + public function field200EShouldBeAsExpected() { + $this->assertEquals("l'incroyable histoire de l'archéologie des animaux",$this->notice_sgbd->get_subfield('200', 'e')[0]); + } - /** @test */ - public function field200FShouldBeLamysHachem() { - $this->assertEquals('Lamys Hachem',$this->notice_sgbd->get_subfield('200', 'f')[0]); - } + /** @test */ + public function field200FShouldBeLamysHachem() { + $this->assertEquals('Lamys Hachem',$this->notice_sgbd->get_subfield('200', 'f')[0]); + } - /** @test */ - public function field200GShouldBeLamysHachem() { - $this->assertEquals("ill. d'Hélène Georges",$this->notice_sgbd->get_subfield('200', 'g')[0]); - } + /** @test */ + public function field200GShouldBeLamysHachem() { + $this->assertEquals("ill. d'Hélène Georges",$this->notice_sgbd->get_subfield('200', 'g')[0]); + } - /** @test */ - public function firstField210AShouldBeAsExpected() { - $this->assertEquals('Arles',$this->notice_sgbd->get_subfield('210', 'a')[0]); - } + /** @test */ + public function firstField210AShouldBeAsExpected() { + $this->assertEquals('Arles',$this->notice_sgbd->get_subfield('210', 'a')[0]); + } - /** @test */ - public function secondField210AShouldBeAsExpected() { - $this->assertEquals('[Paris]',$this->notice_sgbd->get_subfield('210', 'a')[1]); - } + /** @test */ + public function secondField210AShouldBeAsExpected() { + $this->assertEquals('[Paris]',$this->notice_sgbd->get_subfield('210', 'a')[1]); + } - /** @test */ - public function field210CShouldBeAsExpected() { - $this->assertEquals('Actes Sud junior',$this->notice_sgbd->get_subfield('210', 'c')[0]); - } + /** @test */ + public function field210CShouldBeAsExpected() { + $this->assertEquals('Actes Sud junior',$this->notice_sgbd->get_subfield('210', 'c')[0]); + } - /** @test */ - public function field210DShouldBeAsExpected() { - $this->assertEquals('2013',$this->notice_sgbd->get_subfield('210', 'd')[0]); - } + /** @test */ + public function field210DShouldBeAsExpected() { + $this->assertEquals('2013',$this->notice_sgbd->get_subfield('210', 'd')[0]); + } - /** @test */ - public function field215AShouldBeAsExpected() { - $this->assertEquals('1 vol. (84 p.)',$this->notice_sgbd->get_subfield('215', 'a')[0]); - } + /** @test */ + public function field215AShouldBeAsExpected() { + $this->assertEquals('1 vol. (84 p.)',$this->notice_sgbd->get_subfield('215', 'a')[0]); + } - /** @test */ - public function field215CShouldBeAsExpected() { - $this->assertEquals('ill. en coul., couv. ill. en coul.',$this->notice_sgbd->get_subfield('215', 'c')[0]); - } + /** @test */ + public function field215CShouldBeAsExpected() { + $this->assertEquals('ill. en coul., couv. ill. en coul.',$this->notice_sgbd->get_subfield('215', 'c')[0]); + } - /** @test */ - public function field215DShouldReturn28Cm() { - $this->assertEquals('28 cm',$this->notice_sgbd->get_subfield('215', 'd')[0]); - } + /** @test */ + public function field215DShouldReturn28Cm() { + $this->assertEquals('28 cm',$this->notice_sgbd->get_subfield('215', 'd')[0]); + } - /** @test */ - public function unimarc330ShoulBeAsExpected() { - $this->assertEquals('Documentaire d\'une très grande qualité qui permet d\'apprendre ce qu\'est l\'archéozoologie (l\'archéologie appliquée aux découvertes animales) et de découvrir les méthodes et techniques utilisées par les professionnels. Un livre enrichissant, à conseiller aux enfants comme aux adultes, pour en savoir plus sur les différents rôles des animaux auprès des hommes au fil des époques et l\'évolution des modes de vie, et découvrir les divers aspects du métier passionnant d\'archéozoologue. A noter : ce livre a remporté le prix « Le Goût des sciences 2013 », (catégorie « La science expliquée aux jeunes »).', $this->notice_sgbd->get_subfield('330', 'a')[0]); - } + /** @test */ + public function unimarc330ShoulBeAsExpected() { + $this->assertEquals('Documentaire d\'une très grande qualité qui permet d\'apprendre ce qu\'est l\'archéozoologie (l\'archéologie appliquée aux découvertes animales) et de découvrir les méthodes et techniques utilisées par les professionnels. Un livre enrichissant, à conseiller aux enfants comme aux adultes, pour en savoir plus sur les différents rôles des animaux auprès des hommes au fil des époques et l\'évolution des modes de vie, et découvrir les divers aspects du métier passionnant d\'archéozoologue. A noter : ce livre a remporté le prix « Le Goût des sciences 2013 », (catégorie « La science expliquée aux jeunes »).', $this->notice_sgbd->get_subfield('330', 'a')[0]); + } } @@ -540,9 +548,9 @@ class NoticeIntegrationAloesBiblioArcheoAnimauxTest extends NoticeIntegrationAlo class NoticeIntegrationAloesUnimarcTest extends NoticeIntegrationAloesTestCase { - public function setUp() { - parent::setUp(); - $this->loadNotice('unimarc_boite_pastel'); + public function setUp() { + parent::setUp(); + $this->loadNotice('unimarc_boite_pastel'); } diff --git a/cosmogramme/tests/php/classes/NoticeIntegrationOrpheeTest.php b/cosmogramme/tests/php/classes/NoticeIntegrationOrpheeTest.php index 66ef8c70df33b16627f1a00ca6b1ad1763c7a86b..8a0dacd77e154490b3e593743f1abcafbaf086a8 100644 --- a/cosmogramme/tests/php/classes/NoticeIntegrationOrpheeTest.php +++ b/cosmogramme/tests/php/classes/NoticeIntegrationOrpheeTest.php @@ -128,10 +128,10 @@ class NoticeIntegrationOrpheeSerialWithDoubleSearchNoneTest extends NoticeIntegr class NoticeIntegrationOrpheeSerialInrockuptiblesTest extends NoticeIntegrationOrpheeTestCase { - public function setUp() { - parent::setUp(); - $this->loadNotice('unimarc_inrocks'); - } + public function setUp() { + parent::setUp(); + $this->loadNotice('unimarc_inrocks'); + } /** @test */ @@ -164,4 +164,4 @@ class NoticeIntegrationOrpheeSerialInrockuptiblesTest extends NoticeIntegrationO $this->assertEquals('INROCKUPTIBLES', Class_Notice::findFirstBy(['type_doc' => Class_TypeDoc::PERIODIQUE])->getClefChapeau()); } -} \ No newline at end of file +} diff --git a/cosmogramme/tests/php/classes/NoticeIntegrationSubjectTest.php b/cosmogramme/tests/php/classes/NoticeIntegrationSubjectTest.php index dc6181056ceb76e5fbcb3625d74bcee26d8fd986..4dcf875cf8cde50928c11699f7e7285e615d8fb5 100644 --- a/cosmogramme/tests/php/classes/NoticeIntegrationSubjectTest.php +++ b/cosmogramme/tests/php/classes/NoticeIntegrationSubjectTest.php @@ -49,7 +49,7 @@ class NoticeIntegrationSubjectTest extends NoticeIntegrationTestCase { /** @test */ public function noticeIndexMatieresShouldBeAllPhoneticLabel() { - $this->assertEquals('ANNEES AN TECHNIQUE TEKNIK 2020 INITIATION INITIASION SPORT SPOR NAUTIQUE NOTIK PADDLE PADL', + $this->assertEquals('ANNEES TECHNIQUE 2020 ANNEES INITIATION 2020 ANNEES 2020 SPORT NAUTIQUE PADDLE AN TEKNIK INITIASION SPOR NOTIK PADL', Class_Notice::find(1)->getMatieres()); } diff --git a/cosmogramme/tests/php/classes/NoticeIntegrationTest.php b/cosmogramme/tests/php/classes/NoticeIntegrationTest.php index 9540d12a8315a755aae6e06ee598cb8e0d7c5b69..261de58c70bdc1bb6f0a5b3c2320fd3e41e25421 100644 --- a/cosmogramme/tests/php/classes/NoticeIntegrationTest.php +++ b/cosmogramme/tests/php/classes/NoticeIntegrationTest.php @@ -101,6 +101,8 @@ abstract class NoticeIntegrationTestCase extends ModelTestCase { 'ean_345' => '']) ->setListeCache(['nature_docs'=> "1:Collection\r\n2:Dataset\r\n3:Event\r\n4:Image"]); + Class_CosmoVar::setValueOf('unimarc_zone_titre', '200$a;461$t'); + Codif_Langue::getInstance() ->setCodif(['fre' => ['id_langue' => 'fre', 'libelle' => 'français']]); @@ -202,16 +204,16 @@ class NoticeIntegrationLollipopGeneratedNoticeRecordTest extends NoticeIntegrati /** @test */ - public function noticeDbEnregTitresShouldBeLollipopAndLolipop() { - $this->assertEquals('LOLLIPOP LOLIPOP NEUF NEF', - $this->notice_integration->noticeToDBEnreg($this->notice_data)['titres']); + public function recordId1TitresShouldBeMainTitleLollipopAndSecondaryNeufWithPhonetix() { + $this->assertEquals('P_LOLLIPOP LOLLIPOP NEUF LOLIPOP NEF', + Class_Notice::find(1)->getTitres()); } /** @test */ - public function noticeDbEnregEditeurShouldBeEcoleEkolLoisirsLoisir() { - $this->assertEquals('ECOLE EKOL LOISIRS LOISIR', - $this->notice_integration->noticeToDBEnreg($this->notice_data)['editeur']); + public function recordId1EditeurShouldBeEcoleDesLoisirsWithPhonetix() { + $this->assertEquals('ECOLE DES LOISIRS EKOL LOISIR', + Class_Notice::find(1)->getEditeur()); } } @@ -402,8 +404,8 @@ class NoticeIntegrationMarc21WithItemsIn952Test extends NoticeIntegrationMarc21D + class NoticeIntegrationKohaNeonWithPcmd4GeneratedNoticeRecordTest extends NoticeIntegrationTestCase { - protected $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); @@ -411,7 +413,6 @@ class NoticeIntegrationKohaNeonWithPcmd4GeneratedNoticeRecordTest extends Notice Codif_langue::getInstance()->setCodif(['fre' => ['id_langue' => 'fre', 'libelle' => 'français']]); - $this->notice_integration = new notice_integration(); $this->notice_integration->setParamsIntegration(1, 0, 110); } @@ -474,14 +475,15 @@ class NoticeIntegrationMussoWithoutRenvoisTest extends NoticeIntegrationTestCase /** @test */ - public function auteursShouldContainsMUSSO() { - $this->assertContains('MUSSO MUSO GUILLAUME', - $this->notice_integration->noticeToDBEnreg($this->notice_data)['auteurs']); + public function auteursShouldContainsMUSSO_GUILLAUME() { + $this->assertEquals('P_MUSSO P_GUILLAUME MUSSO GUILLAUME MUSSO MUSO GIOM', + Class_Notice::find(1)->getAuteurs()); } } + class NoticeIntegrationCekovTest extends NoticeIntegrationTestCase { protected $_profil_donnees = @@ -565,9 +567,9 @@ class NoticeIntegrationLearningWithRenvoisTest extends NoticeIntegrationTestCase /** @test */ - public function auteursShouldContainsFrey() { - $this->assertContains('FREY FRAI PIERRE PIER', - $this->notice_integration->noticeToDBEnreg($this->notice_data)['auteurs']); + public function auteursShouldEqualsFreyPierreFreyAndPhonetix() { + $this->assertEquals('P_FREY P_PIERRE FREY PIERRE FREY FRAI PIER', + Class_Notice::find(1)->getAuteurs()); } } @@ -634,15 +636,15 @@ class NoticeIntegrationBearsBeerMicrobibTest extends NoticeIntegrationTestCase { /** @test */ public function auteursShouldContainsBEAULIEUJIMMY() { - $this->assertEquals('BEAULIEU BOLI JIMMY JIMI APOSTOLIDES APOSTOLID JEAN JAN MARIE MARI BOSSE BOS SIMON BOUCHARD BOUCHAR GREGOIRE GREGOIR PIERRE PIER BROERSMA MATTHEW MATEW DELPORTE DELPORT JULIE JULI DOYON DOION RIVEST RIVES EKEBOM EKEBON TERHI TERI FORSYTHE FORSIT GENEST CATHERINE KATERIN GIARD JIAR LUC GIRARD JIRAR PASCAL PASKAL GOLDBERG GOLDBER ELEONORE ELEONOR HUBER UB MARKUS MARKU IRIS IRI JOLY JOLI BENOIT BENOI LEMAY LEMAI SYLVAIN SILVIN MUSTURI TOMMI TOMI NYLSO NILSO OBOM OBON PISHIER PICHI RICCI RIKSI STEFANO SAMSON JACQUES JAK DIECK DIEK MARTIN TOM TRAHAN TRAN SEBASTIEN SEBASTIN TURGEON TURJON DAVID DAVI VAYRYNEN VAIRINAN MIKKO MIKO VIAU VIO MICHEL WARD OIR BARNABY BARNABI WIGGERT OUIJER GREGOR ZVIANE ZVIAN', - $this->notice_integration->noticeToDBEnreg($this->notice_data)['auteurs']); + $this->assertEquals('P_BEAULIEU P_JIMMY BEAULIEU JIMMY BEAULIEU APOSTOLIDES JEAN MARIE APOSTOLIDES BOSSE SIMON BOSSE BOUCHARD GREGOIRE BOUCHARD BOUCHARD PIERRE BOUCHARD BROERSMA MATTHEW BROERSMA DELPORTE JULIE DELPORTE DOYON RIVEST EKEBOM TERHI EKEBOM FORSYTHE MATTHEW FORSYTHE GENEST CATHERINE GENEST GIARD LUC GIARD GIRARD PASCAL GIRARD GOLDBERG ELEONORE GOLDBERG HUBER MARKUS HUBER IRIS JOLY BENOIT JOLY LEMAY SYLVAIN LEMAY MUSTURI TOMMI MUSTURI NYLSO OBOM PISHIER RICCI STEFANO RICCI SAMSON JACQUES SAMSON DIECK MARTIN TOM DIECK TRAHAN SEBASTIEN TRAHAN TURGEON DAVID TURGEON VAYRYNEN MIKKO VAYRYNEN VIAU MICHEL VIAU WARD BARNABY WARD WIGGERT GREGOR WIGGERT ZVIANE BOLI JIMI APOSTOLID JAN MARI BOS BOUCHAR GREGOIR PIER MATEW DELPORT JULI DOION RIVES EKEBON TERI FORSIT KATERIN JIAR JIRAR PASKAL GOLDBER ELEONOR UB MARKU IRI JOLI BENOI LEMAI SILVIN TOMI NILSO OBON PICHI RIKSI JAK DIEK TRAN SEBASTIN TURJON DAVI VAIRINAN MIKO VIO OIR BARNABI OUIJER ZVIAN', + Class_Notice::find(1)->getAuteurs()); } /** @test */ public function titlesContainsBEAR() { - $this->assertEquals('BEARS BEAR BEER BE FORMULE FORMUL 1', - $this->notice_integration->noticeToDBEnreg($this->notice_data)['titres']); + $this->assertEquals('P_BEARS P_BEER P_FORMULE P_N P_1 BEARS BEER FORMULE N 1 BEAR BE FORMUL', + Class_Notice::find(1)->getTitres()); } @@ -882,16 +884,19 @@ class NoticeIntegrationDossier64Test extends NoticeIntegrationTestCase { $this->notice_sgbd->ouvrirNotice($this->datas['unimarc'], 0); } + /** @test */ public function priceShouldBeTwentyTwoEuros() { $this->assertEquals('22.90 €', $this->notice_sgbd->get_subfield('010', 'd')[0]); } + /** @test */ - public function titleShouldBeDossier64() { - $this->assertContains('DOSSIER', $this->datas['titres']); + public function titleShouldContainsDossier() { + $this->assertContains('DOSSIER', Class_Notice::find(1)->getTitres()); } + /** @test */ public function zone200aShouldBeDossier64() { $this->assertEquals('Dossier 64', $this->notice_sgbd->get_subfield('200', 'a')[0]); @@ -1128,8 +1133,6 @@ 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() @@ -1141,17 +1144,17 @@ class NoticeIntegrationArchivesAlsaceTest extends NoticeIntegrationTestCase { public function setUp() { parent::setUp(); - $this->fixture('Class_CodifLangue', + $this->fixture(Class_CodifLangue::class, ['id' => 'fre', 'libelle' => 'Français']); - $this->fixture('Class_CodifMatiere', + $this->fixture(Class_CodifMatiere::class, ['id' => 1, 'libelle' => 'Alsace (France) : Descriptions Et Voyages : Vues : 1870-1914', 'code_alpha' => 'ALSACE FRANCE DESCRIPTIONS ET VOYAGES VUES 1870 1914', ]); - $this->fixture('Class_CodifDewey', + $this->fixture(Class_CodifDewey::class, ['id' => 94438, 'libelle' => 'Lorraine et Alsace']); @@ -1160,24 +1163,24 @@ class NoticeIntegrationArchivesAlsaceTest extends NoticeIntegrationTestCase { Class_CosmoVar::newInstanceWithId('unimarc_zone_matiere', ['valeur' => '600abcjxyz;601abcx;602ajxyz;605a;606ajxyz;607ajxyz;608ajxyz;610aejxyz;615amnx;616acfjxy;620abcdefghi']); - $this->loadNotice('unimarc_archives_alsace'); } /** @test */ - public function matieresShouldAlsaceDescriptions() { - $this->assertEquals('ALSACE ALSAS FRANCE FRANS DESCRIPTIONS DESKRIPSION VOYAGES VOIAJ VUES VU 1870 1914 OUVRAGES OUVRAJ ILLUSTRES ILUSTR 1871 1918 PERIODE PERIOD ALLEMANDE ALEMAND', + public function matieresShouldBeAlsaceFranceDescriptionsWithAllWordsAndPhonetix() { + $this->assertEquals('ALSACE FRANCE DESCRIPTIONS ET VOYAGES VUES 1870 1914 ALSACE FRANCE OUVRAGES ILLUSTRES 1871 1918 PERIODE ALLEMANDE ALSAS FRANS DESKRIPSION VOIAJ VU OUVRAJ ILUSTR PERIOD ALEMAND', Class_Notice::find(1)->getMatieres()); } /** @test */ - public function deweyShouldBeLorraineAlsace() { - $this->assertEquals('LORRAINE LORAIN ALSACE ALSAS', + public function deweyShouldBeLorraineEtAlsaceAndPhonetix() { + $this->assertEquals('LORRAINE ET ALSACE LORAIN ALSAS', Class_Notice::find(1)->getDewey()); } + /** @test */ public function codifMatiereOneShouldContainsAlsace() { $this->assertEquals('Alsace (France) : Descriptions et voyages : Vues : 1870-1914', @@ -1208,8 +1211,10 @@ class NoticeIntegrationArchivesAlsaceTest extends NoticeIntegrationTestCase { + /** @see http://forge.afi-sa.fr/issues/15989 */ class NoticeIntegrationMarioCartWiiTest extends NoticeIntegrationTestCase { + public function getProfilDonnees() { $profil = Class_IntProfilDonnees::forAstrolab()->setIdProfil(110); return $profil->getRawAttributes(); @@ -1225,7 +1230,6 @@ class NoticeIntegrationMarioCartWiiTest extends NoticeIntegrationTestCase { $this->fixture('Class_CodifEmplacement', ['id' => 9, 'libelle' => 'Espace bébés', 'regles' => '995$u=43;Espace bébés']); - $writer = new Class_NoticeUnimarc_Writer(); $writer->setNotice(file_get_contents(dirname(__FILE__)."/unimarc_mario_kart.txt")); $writer->add_field('995', @@ -1242,7 +1246,6 @@ class NoticeIntegrationMarioCartWiiTest extends NoticeIntegrationTestCase { Class_CosmoVar::setValueOf('other_index_fields', '300$a;330$a'); - $this->loadNoticeFromString($writer->getFullRecord()); $this->items = Class_Notice::findFirstBy([])->getExemplaires(); } @@ -1273,8 +1276,8 @@ class NoticeIntegrationMarioCartWiiTest extends NoticeIntegrationTestCase { /** @test */ - public function titresShouldBeMARIO_KART_WII() { - $this->assertEquals('MARIO KART KAR WII', Class_Notice::find(1)->getTitres()); + public function titresShouldBeMARIO_KART_WIIAsPrimary() { + $this->assertEquals('P_MARIO P_KART P_WII MARIO KART WII KAR', Class_Notice::find(1)->getTitres()); } @@ -1294,7 +1297,9 @@ class NoticeIntegrationMarioCartWiiTest extends NoticeIntegrationTestCase { + class NoticeIntegrationNoNoticeTest extends NoticeIntegrationTestCase { + public function tearDown() { Storm_Model_Loader::defaultToDb(); parent::tearDown(); @@ -1324,6 +1329,7 @@ class NoticeIntegrationNoNoticeTest extends NoticeIntegrationTestCase { class NoticeIntegrationZone214Test extends NoticeIntegrationTestCase { + public function getProfilDonnees() { return Class_IntProfilDonnees::forNanook() ->setIdProfil(108) @@ -1345,9 +1351,9 @@ class NoticeIntegrationZone214Test extends NoticeIntegrationTestCase { /** @test */ - public function noticeDbEnregEditeurShouldBeVagnon() { + public function recordEditeurShouldBeVagnon() { $this->assertEquals('VAGNON VANION', - $this->notice_integration->noticeToDBEnreg($this->notice_data)['editeur']); + Class_Notice::find(1)->getEditeur()); } @@ -1403,6 +1409,7 @@ class NoticeIntegrationNSBNSETest extends NoticeIntegrationTestCase { $this->loadNotice('unimarc_nsbnse'); } + /** @test */ public function noticeTitreShouldbeLesDessousDuSportChinois() { $this->assertEquals('Les dessous du sport chinois', @@ -1421,6 +1428,7 @@ class NoticeIntegrationNSBNSETest extends NoticeIntegrationTestCase { class NoticeIntegrationAsservissementConsentiTest extends NoticeIntegrationTestCase { + public function getProfilDonnees() { return Class_IntProfilDonnees::forFlora() ->setAccents(Class_IntProfilDonnees::ENCODING_MARC21) @@ -1431,7 +1439,7 @@ class NoticeIntegrationAsservissementConsentiTest extends NoticeIntegrationTestC public function setUp() { parent::setUp(); $this->fixture(Class_IntBib::class, - [ 'id' => 1, + ['id' => 1, 'comm_sigb' => Class_IntBib::COM_FLORA]); $this->loadNotice('unimarc_asservissementconsenti'); } diff --git a/cosmogramme/tests/php/classes/PMBIntegrationTest.php b/cosmogramme/tests/php/classes/PMBIntegrationTest.php index 08f1a4570885191b22fab952eeaadc532a589d54..9da8cb34a562185732a295fae81fc7c4e4353a00 100644 --- a/cosmogramme/tests/php/classes/PMBIntegrationTest.php +++ b/cosmogramme/tests/php/classes/PMBIntegrationTest.php @@ -22,6 +22,7 @@ require_once('NoticeIntegrationTest.php'); abstract class PMBIntegrationRecordsTestCase extends NoticeIntegrationTestCase { + public function getProfilDonnees() { $profil = Class_IntProfilDonnees::forPMB()->setIdProfil(115); return $profil->getRawAttributes(); @@ -30,7 +31,9 @@ abstract class PMBIntegrationRecordsTestCase extends NoticeIntegrationTestCase { + class PMBIntegrationRecordsTest extends PMBIntegrationRecordsTestCase { + public function setUp() { parent::setUp(); $this->fixture('Class_CodifSection', @@ -84,6 +87,7 @@ class PMBIntegrationRecordsTest extends PMBIntegrationRecordsTestCase { class PMBIntegrationRecordsSixSequencesTest extends PMBIntegrationRecordsTestCase { + public function setUp() { parent::setUp(); @@ -113,6 +117,7 @@ class PMBIntegrationRecordsSixSequencesTest extends PMBIntegrationRecordsTestCas class PMBIntegrationSerialsTest extends PMBIntegrationRecordsTestCase { + public function getProfilDonnees() { return Class_IntProfilDonnees::forPMB() ->setIdProfil(115) @@ -120,6 +125,7 @@ class PMBIntegrationSerialsTest extends PMBIntegrationRecordsTestCase { ->getRawAttributes(); } + public function setUp() { parent::setUp(); @@ -244,12 +250,20 @@ class PMBIntegrationSerialsTest extends PMBIntegrationRecordsTestCase { $this->assertEquals('Revue française de pédagogie', Class_Notice::findFirstBy(['type_doc' => 2])->getTitreChapeau()); } + + + /** @test */ + public function fulltextTitresShouldContainsREVUE_FRANCAISE_DE_PEDAGOGIE() { + $this->assertContains('REVUE FRANCAISE DE PEDAGOGIE', + Class_Notice::findFirstBy(['type_doc' => 2])->getTitres()); + } } class PMBIntegrationSerialsBretagneSacreeTest extends PMBIntegrationRecordsTestCase { + public function getProfilDonnees() { return Class_IntProfilDonnees::forPMB() ->setIdProfil(115) @@ -298,6 +312,7 @@ class PMBIntegrationSerialsBretagneSacreeTest extends PMBIntegrationRecordsTestC class PMBIntegrationRecordNourritureRepasTest extends PMBIntegrationRecordsTestCase { + protected $_record; public function setUp() { @@ -307,6 +322,7 @@ class PMBIntegrationRecordNourritureRepasTest extends PMBIntegrationRecordsTestC $this->_record = Class_Notice::find(1); } + /** @test */ public function titleShouldBeNourriture() { $this->assertContains('Nourriture et repas dans les milieux juifs', $this->_record->getTitrePrincipal()); @@ -321,7 +337,9 @@ class PMBIntegrationRecordNourritureRepasTest extends PMBIntegrationRecordsTestC + class PMBIntegrationRecordSacreSaintTest extends PMBIntegrationRecordsTestCase { + protected $_record; public function setUp() { @@ -331,6 +349,7 @@ class PMBIntegrationRecordSacreSaintTest extends PMBIntegrationRecordsTestCase { $this->_record = Class_Notice::find(1); } + /** @test */ public function titleShouldBeDuSacreAuSaint() { $this->assertContains('Du sacré au saint', $this->_record->getTitrePrincipal()); @@ -345,7 +364,10 @@ class PMBIntegrationRecordSacreSaintTest extends PMBIntegrationRecordsTestCase { -class PMBIntegrationRecordOeuvreCompleteSaintTest extends PMBIntegrationRecordsTestCase { + +class PMBIntegrationRecordOeuvreCompleteSaintTest + extends PMBIntegrationRecordsTestCase { + protected $_record; public function setUp() { @@ -370,7 +392,9 @@ class PMBIntegrationRecordOeuvreCompleteSaintTest extends PMBIntegrationRecordsT + class PMBIntegrationRecordPeresEgliseTest extends PMBIntegrationRecordsTestCase { + protected $_record; public function setUp() { @@ -380,6 +404,7 @@ class PMBIntegrationRecordPeresEgliseTest extends PMBIntegrationRecordsTestCase $this->_record = Class_Notice::find(1); } + /** @test */ public function titleShouldBeDictionnaireContemporainPeresEglise() { $this->assertContains('Dictionnaire contemporain des Pères de l\'Église', @@ -388,8 +413,8 @@ class PMBIntegrationRecordPeresEgliseTest extends PMBIntegrationRecordsTestCase /** @test */ - public function titresShouldContainsEGLISE() { - $this->assertContains('EGLISE EGLIS', $this->_record->getTitres()); + public function titresShouldBeDictionnaireContemporainDesPeresDeLEgliseAsPrimaryWithPhonetix() { + $this->assertEquals('P_DICTIONNAIRE P_CONTEMPORAIN P_DES P_PERES P_DE P_L P_EGLISE DICTIONNAIRE CONTEMPORAIN DES PERES DE L EGLISE DIKSIONAIR KONTANPORIN PER EGLIS', $this->_record->getTitres()); } } @@ -397,6 +422,7 @@ class PMBIntegrationRecordPeresEgliseTest extends PMBIntegrationRecordsTestCase class PMBIntegrationRecordTheologicoTest extends PMBIntegrationRecordsTestCase { + protected $_record; public function setUp() { @@ -406,6 +432,7 @@ class PMBIntegrationRecordTheologicoTest extends PMBIntegrationRecordsTestCase { $this->_record = Class_Notice::find(1); } + /** @test */ public function titleShouldBeImaginationTheologicoPolitique() { $this->assertContains('L\'imagination théologico-politique de l\'Eglise', @@ -422,7 +449,9 @@ class PMBIntegrationRecordTheologicoTest extends PMBIntegrationRecordsTestCase { -class PMBIntegrationRecordLePecheurDoubleSearchIdsThenAlphaTest extends PMBIntegrationRecordsTestCase { +class PMBIntegrationRecordLePecheurDoubleSearchIdsThenAlphaTest + extends PMBIntegrationRecordsTestCase { + public function setUp() { parent::setUp(); Class_CosmoVar::setValueOf('mode_doublon', Class_CosmoVar::DOUBLE_SEARCH_IDS_THEN_ALPHA_KEY); diff --git a/cosmogramme/tests/php/classes/unimarc_bad_pagaille.txt b/cosmogramme/tests/php/classes/unimarc_bad_pagaille.txt index c172f18042c88eefc2338f9418d0e47d993b92b1..785881d51742afbebe3669a57bfb2aca3e4651d2 100644 --- a/cosmogramme/tests/php/classes/unimarc_bad_pagaille.txt +++ b/cosmogramme/tests/php/classes/unimarc_bad_pagaille.txt @@ -1 +1 @@ -03400 2200229 45000010006000000100014000060710037000200730018000570900009000750910019000840990016001031000041001191010008001602000148001682100038003162150026003543000066003803300492004466100013009387000029009519702190009801258 d34.07 Eur bL.c.j. Editions Productionsa820 a3550460034185 a1258 a2b20140822c0 eVERLAYtDVD a20120910 frey50 afre aLa Pagaille fPascal Thomas, réal. et scén.gAgenore Incrocci, scén.gFrançois Périer, Patrick Chesnais, Remy Girard, Coralie Seyrig, act. cL.c.j. Editions Productionsd1991 a1 DVD (100 mn)ccoul. aPrêt + Consultation sur place coll. et Projection collective aMartin, séparé de sa femme Brigitte depuis 7 ans, vit avec Clément et Emilie ses deux enfants d'une vingtaine d'années, et Gabriel son beau père. Il a une relation régulière avec une jeune femme Patricia. Martin retrouve par hasard Brigitte et ils revivent un second grand amour, au grand dam de leurs proches, qui étaient tout à fait satisfaits de ce mode de vie "moderne". Pour échapper à ceux qui veulent les séparer, les époux préfèrent quitter le domicile familial... aComédie aThomasbPascal43704690 3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m9746643http://catalogue.bnf.fr/ark:/12148/cb16745882maIncroccibAgenoref1919-20054690 13146571743http://ca 13139308153http://catalogue.bnf.f 1aPérier bFrançois4005 0aFRbCVSc20120822 fSTJ006212i34.07w2014-03-05300094077cMTRSTJ20kCo THO52012-12-07o0ecinema adultesddcrDVDm2014-02 +03188 2200229 4500010001400000071003700014073001800051090000900069091001900078099001600097100004100113101000800154200014800162210003800310215002600348300006600374330049200440610001300932700002900945970196500974995001902939 d34.07 Eur bL.c.j. Editions Productionsa820 a3550460034185 a1258 a2b20140822c0 eVERLAYtDVD a20120910 frey50 afre aLa Pagaille fPascal Thomas, réal. et scén.gAgenore Incrocci, scén.gFrançois Périer, Patrick Chesnais, Remy Girard, Coralie Seyrig, act. cL.c.j. Editions Productionsd1991 a1 DVD (100 mn)ccoul. aPrêt + Consultation sur place coll. et Projection collective aMartin, séparé de sa femme Brigitte depuis 7 ans, vit avec Clément et Emilie ses deux enfants d'une vingtaine d'années, et Gabriel son beau père. Il a une relation régulière avec une jeune femme Patricia. Martin retrouve par hasard Brigitte et ils revivent un second grand amour, au grand dam de leurs proches, qui étaient tout à fait satisfaits de ce mode de vie "moderne". Pour échapper à ceux qui veulent les séparer, les époux préfèrent quitter le domicile familial... aComédie aThomasbPascal43704690 3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m3http://catalogue.bnf.fr/ark:/12148/cb16745882m9746643http://catalogue.bnf.fr/ark:/12148/cb16745882maIncroccibAgenoref1919-20054690 f37701005785598 \ No newline at end of file diff --git a/cosmogramme/tests/php/classes/unimarc_lollipop.txt b/cosmogramme/tests/php/classes/unimarc_lollipop.txt index 804ba25f2d8363f634230f0c33495bae4d064025..51e610661393ce4349ddd95a8bd8a40d0bb29633 100644 --- a/cosmogramme/tests/php/classes/unimarc_lollipop.txt +++ b/cosmogramme/tests/php/classes/unimarc_lollipop.txt @@ -1 +1 @@ -01178cam 22003251i 450 0010009000000050017000090100034000260350026000600390015000860730018001011000041001191010013001601020007001731050018001801060006001982000036002042100035002402150064002752250020003393300219003594100020005787000053005987020045006518010033006968010025007298300028007548520058007829900006008409930006008461/12139420110914113217.0 a2-211-03401-2bRel.d9.80 EUR aELC737022z8745000116 a0638020148 0a9782211034012 a20110703d1987 | |0fre|0103||||ba1 afrecger aFR a 0||y| ar1 aLollipopfChristian Nöstlinger aPariscEcole des loisirsd1987 a1 vol. (121 p.)cillustrations en noir et blancd22 x 16 cm2 aNeufx0295-7191 aL'histoire d'un petit garçon qui s'est choisi comme nom Lollipop (qui signifie sucette en américain). Quand Lollipop regarde à travers une sucette presque tous ses problèmes sont résolus. A partir de neuf ans. 0tNeufx0295-7191 1112012357aNöstlingerbChristinef1936-....4070 1112072714aFriotbBernardf1951-....4730 3aFRbElectrec20110703gAFNOR 0bplivbd_11jan2011.xls aELECTREElectre 20110914 aMOULqMOJEf0638020148g0638020148kJR NOSrLFJn0u1 a1 a1 +01209cam 22003371i 450 0010009000000050017000090100034000260350026000600390015000860730018001011000041001191010013001601020007001731050018001801060006001982000036002042100035002402150064002752250020003393300219003594100020005787000053005987020045006518010033006968010025007298300028007548520058007829900006008409930006008469950019008521/12139420110914113217.0 a2-211-03401-2bRel.d9.80 EUR aELC737022z8745000116 a0638020148 0a9782211034012 a20110703d1987 | |0fre|0103||||ba1 afrecger aFR a 0||y| ar1 aLollipopfChristian Nöstlinger aPariscEcole des loisirsd1987 a1 vol. (121 p.)cillustrations en noir et blancd22 x 16 cm2 aNeufx0295-7191 aL'histoire d'un petit garçon qui s'est choisi comme nom Lollipop (qui signifie sucette en américain). Quand Lollipop regarde à travers une sucette presque tous ses problèmes sont résolus. A partir de neuf ans. 0tNeufx0295-7191 1112012357aNöstlingerbChristinef1936-....4070 1112072714aFriotbBernardf1951-....4730 3aFRbElectrec20110703gAFNOR 0bplivbd_11jan2011.xls aELECTREElectre 20110914 aMOULqMOJEf0638020148g0638020148kJR NOSrLFJn0u1 a1 a1 f37701005785598 \ No newline at end of file diff --git a/cosmogramme/tests/php/classes/unimarc_martial_solal.txt b/cosmogramme/tests/php/classes/unimarc_martial_solal.txt new file mode 100644 index 0000000000000000000000000000000000000000..d1f9adb47d480ad2b64783a84453036a47748f7e --- /dev/null +++ b/cosmogramme/tests/php/classes/unimarc_martial_solal.txt @@ -0,0 +1 @@ +01891njm0 22002773 450 00100060000007300240000609000100003009900350004010000410007510100080011620000680012421000210019221500090021322500300022230000490025233000200030133007610032134500170108246403270109961000330142668600060145970000330146580100350149895900710153399500090160492893 a608917132724d17.99 a92893 tCDc2018-07-31d2018-08-03x16 a20180731d2018 u||y0frey50 ba afre aMy One and Only LovefMartial SolaleLive at Theater Gütersloh cIntuition d2018 a1 CD aEuropean Jazz Legendsv15 aEnregistré en public à Güterlosch en 2017 a- jazz, piano - a“Martial Solal possède, en abondance, ce qui est indispensable aux musiciens : sensibilité, créativité, et technique prodigieuse. Et surtout, il rayonne ! “ Ces mots de louange ont été écrit par son “frère d’âme†Duke Ellington pour le premier disque de Solal aux USA, enregistré à Newport en 1963 avec la section rythmique de Bill Evans, Paul Motian à la batterie et Teddy Kotick à la basse. Plus d’un demi-siècle plus tard, le légendaire pianiste et compositeur français, qui a excellé dans les musiques de film, les orchestres, les big bands et ses propres groupes, en même temps que des duos avec des grands du jazz, de Lee Konitz à Dave Liebman, prouve encore une fois pourquoi Duke l’aimait tant." in francemusique.fr b608917132724 tHave You Met Miss Jones t Medley: Caravan / Prelude to a Kiss / Sophisticated Lady / Satin Doll / Take the A Train tSir JacktComing YesterdaytKöln DuettMy One and Only LovetBody and SoultNight and Day tMarche TurquetAll the Things You AretNight in TunisiatTea for TwotSir Jack IItInterview with Martial Solal 984388aEuropean Jazz Legends a1 aSolalbMartialppiano946833 aFRbCaluire-et-Cuirec20180731 3https://static.qobuz.com/images/covers/ma/5x/jl3o227ln5xma_300.jpg f1234 \ No newline at end of file diff --git a/cosmogramme/tests/php/classes/unimarc_zone_214.txt b/cosmogramme/tests/php/classes/unimarc_zone_214.txt index 0570116cd50f467c52fec9a26b3c6d6f54a54c1c..5ddb4bb41dd7b2b3cb0265ca58e34923070e1c01 100644 --- a/cosmogramme/tests/php/classes/unimarc_zone_214.txt +++ b/cosmogramme/tests/php/classes/unimarc_zone_214.txt @@ -1 +1 @@ -01370cam 2200337 450 001002100000003004700021010003800068020001700106073001800123100004100141101000800182102000700190105001800197106000600215181001900221181002400240182001000264182002000274200014800294214002900442214002100471215004100492606005500533608004800588676001800636686007000654702005700724710006600781801007000847930011500917FRBNF46505891000000Xhttp://catalogue.bnf.fr/ark:/12148/cb46505891q a979-10-271-0348-5bbr.d12,95 EUR aFRb02005560 0a9791027103485 a20200123d2019 a y0frey50 ba0 afre aFR a||||z 00|y| ar 0601ai bxxxe 602ctxt2rdacontent 0601an 602cn2rdamedia1 aProtÂegeons l'eau !bTexte imprimÂeemanuel de l'apprenti Âecoloftexte, Water familygillustrations, Nicolas TrÁevegprÂeface, Roland Jourdain 0a[Paris]cVagnondDL 2019 3aimpr. en Espagne a1 vol. (95 p.)cill. en coul.d22 cm 311979093aEauxConservation des ressources2rameau 312042408aOuvrages pour la jeunesse2rameau a553.708 3v23 a5502Cadre de classement de la Bibliographie nationale franÐcaise |316169492oISNI0000000076504142aTrÁevebNicolas4440||317865912aWater familycBiarritz, PyrÂenÂees-Atlantiques4070 0aFRbFR-751131015c20200123gAFNORhFRBNF46505891000000X2intermrc 5FR-751131010:46505891001001a2020-15583b759999999cTolbiac - Rez de Jardin - LittÂerature et art - MagasindO \ No newline at end of file +01401cam 2200349 450 001002100000003004700021010003800068020001700106073001800123100004100141101000800182102000700190105001800197106000600215181001900221181002400240182001000264182002000274200014800294214002900442214002100471215004100492606005500533608004800588676001800636686007000654702005700724710006600781801007000847930011500917995001901032FRBNF46505891000000Xhttp://catalogue.bnf.fr/ark:/12148/cb46505891q a979-10-271-0348-5bbr.d12,95 EUR aFRb02005560 0a9791027103485 a20200123d2019 a y0frey50 ba0 afre aFR a||||z 00|y| ar 0601ai bxxxe 602ctxt2rdacontent 0601an 602cn2rdamedia1 aProtÂegeons l'eau !bTexte imprimÂeemanuel de l'apprenti Âecoloftexte, Water familygillustrations, Nicolas TrÁevegprÂeface, Roland Jourdain 0a[Paris]cVagnondDL 2019 3aimpr. en Espagne a1 vol. (95 p.)cill. en coul.d22 cm 311979093aEauxConservation des ressources2rameau 312042408aOuvrages pour la jeunesse2rameau a553.708 3v23 a5502Cadre de classement de la Bibliographie nationale franÐcaise |316169492oISNI0000000076504142aTrÁevebNicolas4440||317865912aWater familycBiarritz, PyrÂenÂees-Atlantiques4070 0aFRbFR-751131015c20200123gAFNORhFRBNF46505891000000X2intermrc 5FR-751131010:46505891001001a2020-15583b759999999cTolbiac - Rez de Jardin - LittÂerature et art - MagasindO f37701005785598 \ No newline at end of file diff --git a/library/Class/Album/Authors.php b/library/Class/Album/Authors.php index 5d7e78a03ca22fc7209996a8183505b3ac125b0e..83d7b180d1d8739e7072d49bcaafb6b43f612bf5 100644 --- a/library/Class/Album/Authors.php +++ b/library/Class/Album/Authors.php @@ -24,7 +24,7 @@ class Class_Album_Authors extends Class_Authors { protected $_zones = '701'; - public function addAuthorOrLabel($author, $responsibility = '') { + public function addAuthorOrLabel($author, string $responsibility = '') { if (!$author) return null; @@ -40,14 +40,8 @@ class Class_Album_Authors extends Class_Authors { return []; return $this->_authors - ->collect(function ($author) - { - return $author->getLabelForAlbum(); - }) - ->reject(function ($label) - { - return !$label; - }) + ->collect(fn($author) => $author->getLabelForAlbum()) + ->reject(fn($label) => !$label) ->getArrayCopy(); } @@ -60,7 +54,7 @@ class Class_Album_Authors extends Class_Authors { } - protected function _initAuthor($item) { + protected function _initAuthor(array $item) { if (!isset($item['a'])) return $this; diff --git a/library/Class/Authors.php b/library/Class/Authors.php index c0b04f9c2a24ddc900875b2d5edff7fbf3e3ee5b..523237009d4e1ecdd7c1d7d6e1a4759e6cb1705b 100644 --- a/library/Class/Authors.php +++ b/library/Class/Authors.php @@ -24,24 +24,19 @@ abstract class Class_Authors { protected $_authors; - public function __construct($record) { + public function __construct($record_or_album) { $this->_authors = new Storm_Collection(); - $this->_init($record); + $this->_init($record_or_album); } + public function getAuthorPrincipal() { - return $this->_getPrincipalWith(function ($author) - { - return $author->getName(); - }); + return $this->_getPrincipalWith(fn($author) => $author->getName()); } public function getCodifAuthorPrincipal() { - return $this->_getPrincipalWith(function ($author) - { - return $author->getCodifAuthor(); - }); + return $this->_getPrincipalWith(fn($author) => $author->getCodifAuthor()); } @@ -58,18 +53,9 @@ abstract class Class_Authors { return []; return $this->_authors - ->select(function ($author) use ($zones) - { - return in_array($author->getZone(), $zones); - }) - ->collect(function ($author) - { - return $author->getLabel(); - }) - ->reject(function ($label) - { - return !$label; - }) + ->select(fn($author) => in_array($author->getZone(), $zones)) + ->collect(fn($author) => $author->getLabel()) + ->reject(fn($label) => !$label) ->getArrayCopy(); } @@ -148,5 +134,5 @@ abstract class Class_Authors { } - abstract protected function _init($record); + abstract protected function _init($record_or_album); } diff --git a/library/Class/Cosmogramme/Integration/PhaseSerialArticlesIndex.php b/library/Class/Cosmogramme/Integration/PhaseSerialArticlesIndex.php index 17ce3171c26426cd84b23d04abbf4511a8f65031..38301cac882957a5eec774df587be75c42360d0e 100644 --- a/library/Class/Cosmogramme/Integration/PhaseSerialArticlesIndex.php +++ b/library/Class/Cosmogramme/Integration/PhaseSerialArticlesIndex.php @@ -136,12 +136,18 @@ class Class_Cosmogramme_Integration_PhaseSerialArticlesIndex protected function _handleAuthors($record, $issue, $facets) { - $authors = $record->getAllAuthors(); - foreach($authors as $author) + $authors_article = $record->getAllAuthors(); + + foreach($authors_article as $author) $this->_injectCodifFacetIn($author, '_getCodifAuthorFor', $facets); - $authors[] = $issue->getAuteurs(); - $issue->setAuteurs($this->_indexation->getFulltext($authors)); + $issue_authors = $issue->getAuteurs(); + + $authors_to_add = array_filter(array_map(fn($author) => $this->_indexation->getFulltextAuthor([$author]), + $authors_article), + fn($author_fulltext) => false === strpos($issue_authors, $author_fulltext)); + + $issue->setAuteurs(trim($issue_authors . ' ' . implode(' ', $authors_to_add))); return $this; } @@ -152,8 +158,9 @@ class Class_Cosmogramme_Integration_PhaseSerialArticlesIndex foreach($subjects as $subject) $this->_injectCodifFacetIn($subject, '_getCodifSubjectFor', $facets); - $subjects[] = $issue->getMatieres(); - $issue->setMatieres($this->_indexation->getFulltext($subjects)); + $issue->setMatieres($this->_mergeFacets($issue->getMatieres(), + $this->_indexation + ->getFulltext($subjects))); return $this; } @@ -161,13 +168,18 @@ class Class_Cosmogramme_Integration_PhaseSerialArticlesIndex protected function _handleTitles($record, $issue) { $titles = $record->getZonesTitre(); - $titles[] = $issue->getTitres(); - $issue->setTitres($this->_indexation->getFulltext($titles)); + $issue->setTitres($this->_mergeFacets($issue->getTitres(), + $this->_indexation->getFulltext($titles))); return $this; } + protected function _mergeFacets(string $facets_a, string $facets_b) : string { + return implode(' ', array_filter(array_unique(array_merge(explode(' ', $facets_a), explode(' ', $facets_b))))); + } + + protected function _injectCodifFacetIn($label, $method, $facets) { if (!$codif = call_user_func([$this, $method], $label)) return $this; diff --git a/library/Class/Cosmogramme/Integration/Record/Authority.php b/library/Class/Cosmogramme/Integration/Record/Authority.php index 52a13ce6106f162afb69f675076c90b262634fcd..5944349cb914566f4626658688bc15389a2b6917 100644 --- a/library/Class/Cosmogramme/Integration/Record/Authority.php +++ b/library/Class/Cosmogramme/Integration/Record/Authority.php @@ -82,7 +82,7 @@ class Class_Cosmogramme_Integration_Record_Authority { ['unimarc' => $marc, 'type' => Class_Notice::TYPE_AUTHORITY_PARTIAL, 'type_doc' => $relation->authorityType(), - 'titres' => $this->_indexation->getFulltext($relation->label()), + 'titres' => $this->_indexation->getFulltext([$relation->label()]), 'alpha_titre' => $this->_indexation->codeAlphaTitre($relation->label())]); $this->_saveCodifFor($relation->authorityType(), $relation->label()); @@ -152,14 +152,14 @@ class Class_Cosmogramme_Integration_Record_Authority { } - protected function _addRejectsTo($title) { + protected function _addRejectsTo($title) : array { $parts = [$title]; $rejects = $this->_authority_type->valuesFrom('4', 'a', $this->_reader); foreach($rejects as $reject) $parts[] = $reject; - return implode(' ', $parts); + return $parts; } diff --git a/library/Class/Cosmogramme/Integration/Record/BibliographicDynamicFacets.php b/library/Class/Cosmogramme/Integration/Record/BibliographicDynamicFacets.php index 078684c3fdb269d0962d03f4b6bea27fe533bcbd..947496a8340a425376abe9690f65dc4f39add50f 100644 --- a/library/Class/Cosmogramme/Integration/Record/BibliographicDynamicFacets.php +++ b/library/Class/Cosmogramme/Integration/Record/BibliographicDynamicFacets.php @@ -133,7 +133,7 @@ class Class_Cosmogramme_Integration_Record_BibliographicDynamicFacets_Authority protected function _zoneDatas($marc_zone, $label, $id) { - $values = ['heading' => null, 'record_id' => null]; + $values = ['heading' => '', 'record_id' => null]; $fields = $this->_reader->decoupe_bloc_champ($marc_zone); foreach($fields as $field) { diff --git a/library/Class/Indexation.php b/library/Class/Indexation.php index 79b2c79f0987ae9faf6150c283ebd914aae2d56a..e7ce06a5d3ee5e61a93eb8fe2d39eaae7f682194 100644 --- a/library/Class/Indexation.php +++ b/library/Class/Indexation.php @@ -20,6 +20,7 @@ */ class Class_Indexation { + protected static $_instance, $_alpha_maj_cache = [], @@ -37,7 +38,7 @@ class Class_Indexation { $_inclu = ['AN','AS','OR','U2','AI','LU','XO','DO','RE','MI','FA','SI','AC','DC','XX','B','C','D','E','F','G','H','I','J','K','M','P','Q','R','S','T','V','W','X','Y','Z','L','YU','UT','LI','OC','PI','ZU','WU','TO','OZ','ZZ','XX', 'PC', 'DS'], - $_exclu = ['L','LE','LA','LES','UN','UNE','LES','DES','MES','TES','CES'], + $_exclu = ['L','LE','LA','LES','UN','UNE','LES','DES','MES','TES','CES','DE', 'D', 'Y'], $_pluriel = [ ['AIL','AULX'], ['AVAL','AVALS'], @@ -276,37 +277,66 @@ class Class_Indexation { } + public function getMotsRechercheExacte(string $chaine) : array { + $chaine = $this->stripSpecialCharacters($chaine); + return array_filter(explode(' ', $this->alphaMaj($chaine))); + } + + + public function getMainWordsWith($value_or_array) : string { + if (!$value_or_array) + return ''; + + if (!is_array($value_or_array)) + $value_or_array = $this->getMotsRechercheExacte($value_or_array); + + return implode(' ', + array_map(fn($word) => 'P_' . $word, + $value_or_array)); + } + + // Decoupe une expression en mots en tenant compte des exclusions / inclusions - public function getMots( $chaine ) { - $new = []; + public function getMots(?string $chaine) : array { + $chaine = $this->alphaMaj($chaine); - $chaine = trim($this->alphaMaj($chaine)); - $words = explode(' ', $chaine); + return array_filter(array_map(fn($word) => $this->_filterWord($word), + explode(' ', $chaine))); + } - foreach($words as $word) { - if(strlen($word) < 3 && intVal($word) == false) { - if(false == in_array($word, static::$_inclu)) - continue; - if( 1 == strlen($word)) - $word .= '00'; - } + protected function _filterWord(string $word) : string { + $is_article = strlen($word) < 3 && !$this->_hasANumeric($word); + if ($is_article && !in_array($word, static::$_inclu)) + return ''; - if(true == in_array($word, static::$_exclu)) - continue; + if (in_array($word, static::$_exclu)) + return ''; - $new[] = $word; - } + return $word; + } - return $new; + + protected function _hasANumeric(string $word) : bool { + return preg_match('/[0-9]/', $word); } - public function getFulltext($data) { + public function getFulltext(array $data) : string { return (new Class_Indexation_Fulltext($this))->fromDatas($data); } + public function getFulltextOtherTerms(array $other_terms, array $exlusions) : string { + return (new Class_Indexation_Fulltext($this))->fromDatasExclude($other_terms, $exlusions); + } + + + public function getFulltextAuthor(array $data) : string { + return (new Class_Indexation_FulltextAuthor($this))->fromDatas($data); + } + + // Rend le mot au singulier et au pluriel public function getPluriel( $mot ) { @@ -314,7 +344,7 @@ class Class_Indexation { if(!trim($mot)) return false; foreach(static::$_pluriel as $regle) { - if(strLeft($regle[0],1) != '*') + if(substr($regle[0],0,1) != '*') { if($mot==$regle[0] or $mot==$regle[1]) return $regle; else continue; @@ -345,16 +375,16 @@ class Class_Indexation { return in_array($mot, static::$_inclu); } -// --------------------------------------------------- -// Othographe approchante -// --------------------------------------------------- - function phonetix($sIn) { - if (strlen($sIn)<4 || is_numeric($sIn)) - return false; + + public function phonetix(string $sIn) : string { + if (strlen($sIn) < 4 || is_numeric($sIn)) + return ''; + return $this->phonetixCompute($sIn); } - function phonetixCompute($sIn) { + + function phonetixCompute($sIn) : string { $sIn = strtr( $sIn, static::$_accents); // minuscules accentuées ou composées en majuscules simples $sIn = strtr( $sIn, static::$_min2maj); // majuscules accentuées ou composées en majuscules simples $sIn = strtoupper( $sIn ); // on passe tout le reste en majuscules diff --git a/library/Class/Indexation/Fulltext.php b/library/Class/Indexation/Fulltext.php index dfe47761a659110c6be81b7f11fd57ef84936015..d610e3e868845cfac64a3f35e60ec43ba271387f 100644 --- a/library/Class/Indexation/Fulltext.php +++ b/library/Class/Indexation/Fulltext.php @@ -21,6 +21,7 @@ class Class_Indexation_Fulltext { + protected $_indexation, $_terms; @@ -30,53 +31,94 @@ class Class_Indexation_Fulltext { } - public function fromDatas($datas) { - if (!is_array($datas)) - $datas = [$datas]; + public function fromDatas(array $datas) : string { + return $this->_withDatas($datas); + } + + + public function fromDatasExclude(array $datas, array $exclusions) : string { + $exclusions_expressions = implode(' - ', $exclusions); + + return $this->_withDatas($datas, + fn($expression) => $expression + && false === strpos($exclusions_expressions, + $expression)); + } + + + protected function _withDatas(array $datas, $callback = null) : string { + if (!$datas) + return ''; + + $datas = array_map(fn($expression) => implode(' ', array_filter($this->_wordsFrom($expression))), + array_unique($datas)); + $datas = $callback ? array_filter($datas, $callback) : array_filter($datas); + if (!$datas) + return ''; $this->_terms = new Storm_Collection; - foreach($datas as $data) - $this->_handleString($data); + $this->_handleString(implode(' ', $this->_deduplicateExpressions($datas))); return implode(' ', $this->_terms - ->select(function($term) { return '' != $term; }) + ->select(fn($term) => '' != $term) ->getArrayCopy()); } - protected function _handleString($value) { - if (!$value || !$words = array_filter($this->_wordsFrom($value))) + /** + * @param $datas : [0 => 'ASTERIX', 1 => 'ASTERIX ET OBELIX'] + */ + protected function _deduplicateExpressions(array $datas) : array { + // Trier les expressions par les plus longues en premier tout en conservant leurs positions + $datas = array_flip($datas); + uksort($datas, fn($a, $b) => strlen($b) - strlen($a)); + + // Filtrer les expressions contenues dans les précédentes (plus longues) + $fulltext = []; + foreach($datas as $data => $pos) + if (false === strpos(implode(' ', $fulltext), $data)) + $fulltext [$pos] = $data; + + // Remettre dans l'ordre des positions + uksort($fulltext, fn($pos_a, $pos_b) => $pos_a > $pos_b ? 1 : -1); + return $fulltext; + } + + + protected function _handleString(string $value) : self { + if (empty($value)) return $this; - foreach($words as $word) - $this->_handleWord($word); + $terms_phonetix = new Storm_Collection; + foreach(explode(' ', $value) as $word) + $this->_handleWord($word, $terms_phonetix); + $this->_terms->addAll(array_diff(array_unique($terms_phonetix->getArrayCopy()), + $this->_terms->getArrayCopy())); return $this; } - protected function _wordsFrom($value) { - return $this->_indexation->getMotsRecherche($value); + protected function _wordsFrom(string $value) : array { + return $this->_indexation->getMotsRechercheExacte($value); } - protected function _handleWord($word) { - if (!$word || $this->_terms->includes($word)) + protected function _handleWord(string $word, + Storm_Collection $terms_phonetix) : self { + if (!$word) return $this; $this->_terms->add($word); - - foreach(array_filter(explode(' ', $this->_phonetix($word))) as $phonem) - if (!$this->_terms->includes($phonem)) - $this->_terms->add($phonem); + $terms_phonetix->addAll($this->_phonetix($word)); return $this; } - protected function _phonetix($word) { - return $this->_indexation->phonetix($word); + protected function _phonetix(string $word) : array { + return array_filter(explode(' ', $this->_indexation->phonetix($word))); } -} \ No newline at end of file +} diff --git a/library/Class/Indexation/FulltextAuthor.php b/library/Class/Indexation/FulltextAuthor.php new file mode 100644 index 0000000000000000000000000000000000000000..72210ebfd2ef97f11f49bcfabe10f6e01ec369d9 --- /dev/null +++ b/library/Class/Indexation/FulltextAuthor.php @@ -0,0 +1,39 @@ +<?php +/** + * Copyright (c) 2012-2022, 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_Indexation_FulltextAuthor extends Class_Indexation_Fulltext { + + public static function authorNameThenFirstnameThenName(string $author) : string { + $parts = array_filter(explode('|', $author, 2)); + return count($parts) < 2 + ? $author + : $parts[0] . ' ' . $parts[1] . ' ' . $parts[0]; + } + + + public function fromDatas(array $datas) : string { + $authors = array_map(fn($author) => static::authorNameThenFirstnameThenName($author), + $datas); + + return parent::fromDatas($authors); + } +} diff --git a/library/Class/Indexation/PseudoNotice.php b/library/Class/Indexation/PseudoNotice.php index 35ab81e7a443042404d2e7b61d58979b5a710b1b..3585a9835aa1cdbb4beb01d1facdaebf0e39bbac 100644 --- a/library/Class/Indexation/PseudoNotice.php +++ b/library/Class/Indexation/PseudoNotice.php @@ -206,17 +206,9 @@ class Class_Indexation_PseudoNotice { } - public function getAuthorsNames() { - $names = []; - foreach($authors = $this->extractAuthors() as $author) - $names[] = $author->getName(); - - return implode('-', $names); - } - - - public function getEditorsNames() { - return implode('-', $this->extractEditors()); + public function getAuthorsNames() : array { + return array_map(fn($author) => $author->getAuthorLabelForFullText(), + $this->extractAuthors()); } @@ -229,17 +221,15 @@ class Class_Indexation_PseudoNotice { ->updateAttributes($data) ->setUnimarc($unimarc); - $authors = $this->getAuthorsNames(); - $indexation = Class_Indexation::getInstance(); $this->_notice - ->setMatieres($indexation->getfullText($this->extractMatieres())) + ->setMatieres($this->extractMatieres()) ->setAlphaTitre($indexation->codeAlphaTitre($this->_datas["titre"])) ->setClefAlpha($this->_model->getAlphaKey()) ->setClefOeuvre($this->_model->getWorkKey()) ->setTitres($indexation->getfullText($this->extractTitles())) - ->setAuteurs($indexation->getfullText($authors)) + ->setAuteurs($indexation->getFullTextAuthor($this->getAuthorsNames())) ->setResume($this->_datas["resume"]) ->setAlphaAuteur($indexation->alphaMaj(implode(' ', $this->extractAuthors()))) ->setOtherTerms($indexation->getfullText($this->extractOtherTerms())) @@ -301,7 +291,7 @@ class Class_Indexation_PseudoNotice { } - public function extractEditors() { + public function extractEditors() : array { if (!$this->dataExist('editeur', $this->_datas)) return []; @@ -313,12 +303,10 @@ class Class_Indexation_PseudoNotice { public function extractMatieres() { $matieres = $this->_notice->getMatieresLabels(); + $matieres [] = $this->extractFullTextFromCodif('matiere', + Class_CodifMatiere::class); - return Class_Indexation::getInstance() - ->getfullText(implode(' ', $matieres) - . ' ' - . $this->extractFullTextFromCodif('matiere', - 'Class_CodifMatiere')); + return Class_Indexation::getInstance()->getfullText($matieres); } @@ -330,8 +318,11 @@ class Class_Indexation_PseudoNotice { } - protected function extractTitles() { - return $this->_datas['titre'] . ' ' . implode(' ', $this->_notice->getZonesTitre()); + protected function extractTitles() : array { + $titres = $this->_notice->getZonesTitre(); + array_unshift($titres, $this->_datas['titre']); + + return $titres; } @@ -356,7 +347,7 @@ class Class_Indexation_PseudoNotice { $dewey = $this->extractFullTextFromCodif('dewey', 'Class_CodifDewey'); - $data["dewey"] = Class_Indexation::getInstance()->getfullText($pcdm4 . ' ' . $dewey); + $data["dewey"] = Class_Indexation::getInstance()->getfullText([$pcdm4, $dewey]); return $data; } @@ -481,7 +472,7 @@ class Class_Indexation_PseudoNotice_Album extends Class_Indexation_PseudoNotice{ $model = $this->_model; $this->_datas['notes'] = $model->getNotesForPseudoNotice(); $this->_datas['created_at'] = $model->getCreatedAt(); - $this->_datas['editeur'] = $this->getEditorsNames(); + $this->_datas['editeur'] = $this->extractEditors(); } @@ -517,7 +508,7 @@ class Class_Indexation_PseudoNotice_Album extends Class_Indexation_PseudoNotice{ } - public function extractEditors() { + public function extractEditors() : array { $editors = parent::extractEditors(); if(empty($editors)) $editors = []; @@ -534,12 +525,12 @@ class Class_Indexation_PseudoNotice_Album extends Class_Indexation_PseudoNotice{ } - protected function extractTitles() { - $titles = [parent::extractTitles()]; - foreach($this->_model->getRessources() as $ressource) { - $titles[] = $ressource->findTitle(); - } - return implode(' ', $titles); + protected function extractTitles() : array { + $titles = parent::extractTitles(); + foreach ($this->_model->getRessources() as $ressource) + $titles [] = $ressource->findTitle(); + + return $titles; } diff --git a/library/Class/MoteurRecherche.php b/library/Class/MoteurRecherche.php index c04160c0625f58d5a9c082958fb3fbcb69b94404..81905415ea3f0305892179a36ba33a2391f7d42b 100644 --- a/library/Class/MoteurRecherche.php +++ b/library/Class/MoteurRecherche.php @@ -154,8 +154,10 @@ class Class_MoteurRecherche { return; $terms = (new Class_MoteurRecherche_Terms())->analyse($expression); + if ($terms->isExactSearch()) + $this->beNotExtensible(); - $this->nb_mots = $terms->termsCount(); + $this->nb_mots = $terms->wordsCount(); if (!$against = $terms->asWhereAgainst($pertinence)) { $this->setErreur("Il n'y aucun mot assez significatif pour la recherche"); return; @@ -163,28 +165,30 @@ class Class_MoteurRecherche { $axes = ['titres', 'auteurs', 'editeur', 'collection', 'matieres', 'dewey', 'other_terms']; - $quoted_expression = Zend_Db_Table_Abstract::getDefaultAdapter()->quote($expression); $match_condition = 'MATCH(' . implode(', ', $axes) . ')' . $against; - if ($in_files) + if ($in_files) { + $quoted_expression = Zend_Db_Table_Abstract::getDefaultAdapter()->quote($expression); $match_condition = '(' . $match_condition . ' OR MATCH(file_content) AGAINST(' . $quoted_expression .' IN BOOLEAN MODE))'; + } $this->setCondition($match_condition); - if (($tri and $tri !== '*') and !$pertinence) + if ($tri && $tri !== '*' && !$pertinence) return; - $against_titre = $terms->asSelectAgainst(); - - $match_weights = ['titres' => '1.5', - 'auteurs' => '1']; - $match_weights_string = []; - foreach($match_weights as $axe => $weight) - $match_weights_string []= 'MATCH(' . $axe . ') ' . $against_titre . ( $weight === '1' ? '' :' * ' . $weight); + $match_string = array_filter([$terms->asSelectAgainstExact('titres, auteurs'), + $terms->asSelectAgainstExact('editeur, collection, matieres, dewey, other_terms'), + $terms->asSelectAgainstMainTerms('auteurs'), + $terms->asSelectAgainstMainTerms('titres'), + $terms->asSelectAgainst('titres'), + $terms->asSelectAgainst('auteurs'), + $in_files ? 'MATCH(file_content) AGAINST('. $quoted_expression . ')' : null, + 'date_creation' + ]); - if ($in_files) - $match_weights_string[] = 'MATCH(file_content) AGAINST('. $quoted_expression . ') * 0.5'; - - $this->order_by = 'order by (' . implode(') + (', $match_weights_string) . ') desc'; + $this->order_by = 'order by ' . implode(', ', + array_map(fn($match) => $match . ' desc', + $match_string)); } @@ -343,7 +347,7 @@ class Class_MoteurRecherche { // Type de recherche $condition = ($type_recherche == 'fulltext') - ? "MATCH(".$name.") AGAINST('".$recherche."' IN BOOLEAN MODE)" + ? "MATCH(".$name.") AGAINST(" . $recherche . " IN BOOLEAN MODE)" : $name . " like '" . $recherche . "%'"; $this->_with_operator_conditions []= ['operator' => strtolower($operateur), @@ -355,12 +359,9 @@ class Class_MoteurRecherche { if ('commence' == $type) return trim($this->ix->alphaMaj($value)); - $terms = ''; - foreach($this->ix->getMots($value) as $term) - if ($term = $this->ix->getExpressionRecherche($term)) - $terms .= ' ' . (($by_relevancy) ? '' : '+') . $term; - - return trim($terms); + return (new Class_MoteurRecherche_Terms()) + ->analyse($value) + ->exactTermsBeforePhonetic($by_relevancy); } diff --git a/library/Class/MoteurRecherche/Terms.php b/library/Class/MoteurRecherche/Terms.php index 1baf6a28d15ae8fe3d634c80d324f36ec5d6efb2..1ffc61572e420aec2962bdcb3ecb5ab51ba127dc 100644 --- a/library/Class/MoteurRecherche/Terms.php +++ b/library/Class/MoteurRecherche/Terms.php @@ -21,27 +21,43 @@ class Class_MoteurRecherche_Terms { + protected - $_expression, - $_raws = [], - $_terms = []; + $_all_words = [], + $_terms = [], + $_exact_terms = [], + $_expression; - public function analyse($expression) { - $ix = Class_Indexation::getInstance(); - $this->_expression = $expression; - $this->_raws = []; + public function analyse(string $expression) { $this->_terms = []; + $this->_expression = $expression; + + preg_match_all('/"([^"]+)"/', $expression, $matches); + $this->_all_words = $this->_extractTermsFromExpression(str_replace($matches[0], '', $expression)); + foreach ($matches[1] as $exact_expression) + $this->_all_words = array_merge($this->_extractTermsFromExactExpression($exact_expression), + $this->_all_words); + + return $this; + } + - foreach ($ix->getMotsRecherche($this->_expression) as $token) { - $this->_raws[] = $token; - $term = new Class_MoteurRecherche_Term($token); - if ($term->isValid()) - $this->_terms[] = $term; - } + protected function _extractTermsFromExpression(string $expression) : array { + $tokens = Class_Indexation::getInstance()->getMotsRecherche($expression); + $this->_terms = array_filter(array_map(fn($token) => new Class_MoteurRecherche_Term($token), + $tokens), + fn($term) => $term->isValid()); (new Class_MoteurRecherche_PhonetixCollector())->clean($this->_terms); + return $tokens; + } - return $this; + + protected function _extractTermsFromExactExpression(string $expression) : array { + $tokens = Class_Indexation::getInstance()->getMotsRechercheExacte($expression); + + $this->_exact_terms [] = implode(' ', $tokens); + return $tokens; } @@ -112,28 +128,41 @@ class Class_MoteurRecherche_Terms { } - public function termsCount() { - return count($this->_terms); + public function wordsCount() { + return count($this->_all_words); } public function isEmpty() { - return empty($this->_terms); + return empty($this->_terms) && empty($this->_exact_terms); + } + + + public function isExactSearch() : bool { + return !empty($this->_exact_terms); } - public function asWhereAgainst($is_extended) { + public function asWhereAgainst(bool $is_extended) : string { if ($this->isEmpty()) return ''; - $against = array_map( - function($term) use ($is_extended) { - return $term->asAgainstClause($is_extended); - }, + return " AGAINST(" . $this->exactTermsBeforePhonetic($is_extended) + . ($is_extended ? '' : ' IN BOOLEAN MODE') . ')'; + } + + + public function exactTermsBeforePhonetic(bool $is_extended = false) : string { + $against_exact = array_map(fn($expr) => '+"' . $expr . '"', + $this->_exact_terms); + + $against = array_map(fn($term) => $term->asAgainstClause($is_extended), $this->_terms); - return " AGAINST('". implode(' ', $against) ."'" - . ($is_extended ? '' : ' IN BOOLEAN MODE') . ')'; + $againsts = [implode(' ', $against_exact), + implode(' ', $against)]; + + return $this->_quote(trim(implode(' ', array_filter($againsts)))); } @@ -150,8 +179,41 @@ class Class_MoteurRecherche_Terms { } - public function asSelectAgainst() { - return 'AGAINST(\' ' . implode(' ', $this->_raws) . '\')'; + public function asSelectAgainst(string $axe) : string { + return $this->_selectAgainst($axe, implode(' ', $this->_all_words)); + } + + + public function asSelectAgainstMainTerms(string $axe) : string { + return $this->_selectAgainst($axe, + Class_Indexation::getInstance() + ->getMainWordsWith($this->_all_words)); + } + + + protected function _selectAgainst(string $axe, string $all_words) : string { + return sprintf('MATCH(%s) AGAINST(\'%s\')', $axe, $all_words); + } + + + public function asSelectAgainstExact(string $axe) : string { + if (!empty($this->_exact_terms) || $this->wordsCount() < 2) + return ''; + + return $this->_selectAgainstExact($axe, + implode(' ', Class_Indexation::getInstance()->getMotsRechercheExacte($this->_expression))); + } + + + protected function _selectAgainstExact(string $axe, string $exact_words) : string { + return sprintf('MATCH(%s) AGAINST(%s IN BOOLEAN MODE)', + $axe, + $this->_quote('"' . $exact_words . '"')); + } + + + protected function _quote(string $expression) : string { + return Zend_Db_Table_Abstract::getDefaultAdapter()->quote($expression); } } @@ -249,4 +311,4 @@ class Class_MoteurRecherche_PhonetixCollector { } } -?> \ No newline at end of file +?> diff --git a/library/Class/Notice.php b/library/Class/Notice.php index 46477234bed179c2ab88d99342c685e7638c8edb..425be833281c55cca34253848412b71a0182019e 100644 --- a/library/Class/Notice.php +++ b/library/Class/Notice.php @@ -346,6 +346,11 @@ class Class_Notice extends Storm_Model_Abstract { } + public function getMentionEdition() { + return $this->_getTitles()->getTitlesInZones(['205a']); + } + + public function setAvis($list_avis) { $this->_avis = $list_avis; } @@ -775,21 +780,7 @@ class Class_Notice extends Storm_Model_Abstract { public function getTitreChapeau() { - $titre = ''; - - if ($data = $this->get_subfield("461", "t")) { - return $this->filtreTitre($data[0]); - } - - if ($data = $this->get_subfield("463", "t")) { - return $this->filtreTitre(end($data)); - } - - if ($titres = $this->get_subfield('200', 'a')) - $titre = trim($titres[0]); - // On cherche le chapeau et le n° - return $this->filtreTitre($titre); - + return $this->_getTitles()->getParentTitle(); } @@ -799,28 +790,9 @@ class Class_Notice extends Storm_Model_Abstract { public function getTitrePrincipal($separator = BR) { - $record_title = $this->filtreTitre($this->getRecordTitle()); - - $titles = []; - $volumes =[]; - foreach($this->get_subfield(461, 't', 'v') as $title_volume) { - $title = $this->filtreTitre($title_volume['t']); - $titles []= $title ? $title : $record_title; - $volumes []= $title_volume['v']; - } - - if (!in_array($record_title, $titles)) { - $titles []= $record_title; - $volumes []= ''; - } - - $titles_volumes = []; - foreach($titles as $i => $title) - $titles_volumes []= implode($this->_(' n° '), - array_filter([$title, $volumes[$i]])); - - return implode($separator, - array_filter($titles_volumes)); + return $this->_getTitles() + ->getAllTitles($separator, + $this->isAuthority() ? $this->getRecordTitle() : null); } @@ -844,31 +816,7 @@ class Class_Notice extends Storm_Model_Abstract { public function getSubtitle() { - $zones = Class_Profil::getCurrentProfil()->getZonesTitre(); - if (!count($zones)) - return ''; - - $subtitles = []; - foreach($zones as $zone) { - $data = $this->get_subfield(substr($zone, 0, 3), substr($zone, 4, 1)); - $subtitles[] = $this->filtreTitre(reset($data)); - } - - return implode(' : ', array_filter($subtitles)); - } - - - public function getLabelSonore() { - $bloc=$this->get_subfield('071'); - if(!count($bloc)) return; - $data=$this->decoupe_bloc_champ($bloc[0]); - foreach($data as $champ) - { - if($champ['code']=='a') $num=$this->filtreTitre($champ['valeur']); - if($champ['code']=='b') $label=$this->filtreTitre($champ['valeur']); - } - $ret=$label." ; ".$num; - return $ret; + return $this->_getTitles()->getSubtitle(); } @@ -900,87 +848,18 @@ class Class_Notice extends Storm_Model_Abstract { } -// ---------------------------------------------------------------- -// Complément du titre (1er seulement) -// ---------------------------------------------------------------- - public function getComplementTitre() - { - if (!$titre = $this->get_subfield("200", "e")) - return ''; - $titre = $this->filtreTitre($titre[0]); - return trim($titre); - } - - -// ---------------------------------------------------------------- -// Mention d'edition -// ---------------------------------------------------------------- - public function getMentionEdition() : string { - $titre = $this->get_subfield("205", "a"); - return trim($this->filtreTitre($titre[0] ?? '')); + public function getComplementTitre() : string { + return $this->_getTitles()->getTitleSupplement(); } - /** - * @return array - */ - public function getZonesTitre() { - $zones = Class_CosmoVar::get('unimarc_zone_titre'); - $zones = array_filter(explode(';', trim($zones))); - return $this->_getTitresDansZones($zones); - } - - public function getTitresDansZones($zones) { - return $this->_getTitresDansZones($zones); + public function getZonesTitre() : array { + return $this->_getTitles()->getTitles(); } - /** - * @param $zones array of string ex:200$a - * @return array - */ - protected function _getTitresDansZones($zones) { - if (!is_array($zones) || empty($zones)) - return []; - - $titres = []; - foreach ($zones as $elem) { - $zone = substr($elem,0,3); - $champ = strRight($elem, 1); - $data = $this->get_subfield($zone); - foreach ($data as $items) { - $sous_champs = $this->decoupe_bloc_champ($items); - foreach ($sous_champs as $item) { - if ($item['code'] == $champ) { - $item = $this->filtreTitre($item['valeur']); - if ($item) $titres[] = $item; - } - } - } - } - return $titres; - } - - - private function filtreTitre($titre) { - $titre = str_replace([BR , '[' , ']' , '<' , '>' , ' '], - ["#BR# ", ' ' , '' , ' ' , ' ' , ' '], - $titre); - - if (substr($titre, 0, 1) == '?') { - $deb = substr($titre, 0, 6); - $titre = str_replace('?', '', $deb) . substr($titre, 6); - } - - // filtrage caractères terminaux - $filtre = ["/", ";", ",", ":"]; - foreach($filtre as $car) { - if (substr($titre,-1,1) == $car) - $titre = substr($titre, 0, strlen($titre)-1); - } - - $titre = str_replace("#BR#",BR, $titre); - return trim($titre); + protected function _getTitles() : Class_Notice_Titles { + return new Class_Notice_Titles($this->getNoticeUnimarc()); } @@ -1102,7 +981,7 @@ class Class_Notice extends Storm_Model_Abstract { $notice_editeur = $this->_getNoticeEditeur(); $editeur = $notice_editeur->getFirstEditeur(); if ($data = $notice_editeur->getFirstTown()) - $editeur .= ' (' . $this->filtreTitre($data) . ')'; + $editeur .= ' (' . str_replace(['[', ']'], '', $data) . ')'; return $editeur; } @@ -1333,8 +1212,7 @@ class Class_Notice extends Storm_Model_Abstract { public function acceptVisitor($visitor) { $indexation = new Class_Indexation(); $visitor->visitClefAlpha($this->getClefAlpha()); - $visitor->visitSerialTitle($this->_getTitresDansZones(['461$t'])); - $visitor->visitTitres($this->_getTitresDansZones(['200$a', '200$e'])); + $this->_getTitles()->acceptVisitor($visitor); $visitor->visitAuteurs($this->getAllAuthorsFromZones(['700', '701'])); $visitor->visitContributeurs($this->getAllAuthorsFromZones(['702'])); diff --git a/library/Class/Notice/Author.php b/library/Class/Notice/Author.php index 73ef0abddd1ecfe42dad79f0f9dab099b97404f1..d7554ea5479f94942aa08cfb32662eeed1ddd1bb 100644 --- a/library/Class/Notice/Author.php +++ b/library/Class/Notice/Author.php @@ -187,6 +187,11 @@ class Class_Notice_Author { } + public function getAuthorLabelForFullText() : string { + return implode(static::SEP_NAMES, array_filter([$this->_last_name, $this->_first_name])); + } + + protected function _getAuthorLabel() { return implode(' ', array_filter([$this->_first_name, $this->_last_name])); } diff --git a/library/Class/Notice/AuthorityIndexSystem.php b/library/Class/Notice/AuthorityIndexSystem.php index 6db3099dfb0d7c449f3d444a91d56a06cb071b17..40dd1301413bcd6b54b0df31114d9ff6908c1e44 100644 --- a/library/Class/Notice/AuthorityIndexSystem.php +++ b/library/Class/Notice/AuthorityIndexSystem.php @@ -88,7 +88,7 @@ class Class_Notice_AuthorityIndexSystem { } - public function ensureRecordForThesaurus($heading, $id, $thesaurus, $int_bib, $child) { + public function ensureRecordForThesaurus(string $heading, $id, $thesaurus, $int_bib, $child) { if (!$thesaurus || !$int_bib || !$child) return; @@ -114,7 +114,7 @@ class Class_Notice_AuthorityIndexSystem { $record = Class_Notice::newInstance(['unimarc' => $marc, 'type' => Class_Notice::TYPE_AUTHORITY, 'type_doc' => $this->_default_type, - 'titres' => $indexation->getFulltext($heading), + 'titres' => $indexation->getFulltext([$heading]), 'alpha_titre' => $indexation->codeAlphaTitre($heading), 'date_maj' => $this->getTimeSource()->dateDayAndHours()]) ->updateFacette($thesaurus_facet . ' ' . $child->getFacetCode()); diff --git a/library/Class/Notice/Authors.php b/library/Class/Notice/Authors.php index 43db09a8204c1ff49e99b2f6b005552dac8a74d7..4142ae46cb62ecc7502c37779af422e93b4ddd5d 100644 --- a/library/Class/Notice/Authors.php +++ b/library/Class/Notice/Authors.php @@ -25,45 +25,51 @@ class Class_Notice_Authors extends Class_Authors { protected $_zones = ['700', '710', '720', '730', '701', '702', '711', '712', '721', '722']; - public function getAllAuthors($with_fonction) { + public function getAllAuthors(bool $with_fonction = false) : array { if ($this->_authors->isEmpty()) return []; return $this->_authors - ->collect(function ($author) use ($with_fonction) - { - return $with_fonction - ? $author->getLabelWithFonction() - : $author->getLabel(); - }) - ->reject(function ($label) - { - return !$label; - }) + ->collect(fn($author) => $with_fonction + ? $author->getLabelWithFonction() + : $author->getLabel()) + ->reject(fn($label) => !$label) ->getArrayCopy(); } + public function getRenvois(Class_Notice $record) : array { + $fields = array_map(fn($zone) => [$zone, '8'], + $this->_zones); + return $record->getAllStringsInFields($fields); + } + + + public function getTitleResponsibilities(Class_Notice $record) : array { + return $record->get_subfield('200', 'f'); + } + + public function displayAllAuthors() : array { - return array_map(function($element){return $element->getLabel();}, + return array_map(fn($element) => $element->getLabel(), $this->getAllAuthors(true)); } - protected function _init($record) { + protected function _init($record_or_unimarc) { foreach ($this->_zones as $zone) - $this->_getAuthorsInZone($record, $zone); + $this->_getAuthorsInZone($record_or_unimarc, $zone); return $this; } - protected function _getAuthorsInZone($record, $zone) { - $data = $record->get_subfield($zone); + protected function _getAuthorsInZone($record_or_unimarc, string $zone) : self { + $data = $record_or_unimarc->get_subfield($zone); $break = false; foreach ($data as $items) { - $fields = $record->decoupe_bloc_champ($items); + $fields = $record_or_unimarc->decoupe_bloc_champ($items); $author = $this->_getAuthorInSubfield($zone, $fields); if ($author->isValid()) @@ -74,7 +80,8 @@ class Class_Notice_Authors extends Class_Authors { } - protected function _getAuthorInSubfield($zone, $data) { + protected function _getAuthorInSubfield(string $zone, + array $data) : Class_Notice_Author { $author = new Class_Notice_Author(''); $author->setZone($zone); diff --git a/library/Class/Notice/Indexation.php b/library/Class/Notice/Indexation.php new file mode 100644 index 0000000000000000000000000000000000000000..80be9b077bbd5284f4b246217506c140837c2d64 --- /dev/null +++ b/library/Class/Notice/Indexation.php @@ -0,0 +1,119 @@ +<?php +/** + * Copyright (c) 2012-2022, 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_Notice_Indexation { + use Trait_CodifProviderAware; + + protected Class_Notice $_record; + protected Class_Indexation $_indexation; + + public function __construct(Class_Notice $record) { + $this->_record = $record; + $this->_indexation = Class_Indexation::getInstance(); + } + + + public function indexAndSave() : self { + $this->_record + ->setTitres(trim($this->_getFullTextTitles())) + ->setAuteurs(trim($this->_getFullTextAuthors())) + ->setEditeur($this->_getEditeur()) + ->setCollection($this->_getCollection()) + ->setOtherTerms($this->_getOtherTerms()) + ->save(); + + return $this; + } + + + protected function _getCollection() : string { + if (!$data = $this->_record->get_subfield(225, 'a')) + $data = $this->_record->get_subfield(410, 't'); + + return $this->_indexation->getFulltext($data); + } + + + protected function _getOtherTerms() : string { + return $this->_indexation + ->getFulltextOtherTerms($this->_record->getOtherIndexedTerms(), + [$this->_record->getTitres(), + $this->_record->getAuteurs(), + $this->_record->getEditeur(), + $this->_record->getCollection(), + $this->_record->getMatieres()]); + } + + + protected function _getEditeur() : string { + $publisher = (new Class_Notice_Editeur($this->_record->getNoticeUnimarc())) + ->getFirstEditeur(); + + return $publisher ? $this->_indexation->getFulltext([$publisher]) : ''; + } + + + protected function _getFullTextTitles() : string { + return + $this->_indexation->getMainWordsWith($this->_getRecordTitle()) + . ' ' + . $this->_indexation->getfullText([...$this->_record->getZonesTitre(), + $this->_record->getClefChapeau(), + $this->_record->getTomeAlpha()]); + } + + + protected function _getRecordTitle() : string { + return (new Class_Notice_Titles($this->_record->getNoticeUnimarc())) + ->getMainTitle(); + } + + + protected function _getFullTextAuthors() : string { + $authors = new Class_Notice_Authors($this->_record->getNoticeUnimarc()); + + if (!$all_authors = $authors->getAllAuthors()) + return $this->_indexation + ->getFulltextAuthor($authors->getTitleResponsibilities($this->_record)); + + $main_authors = $this->_indexation + ->getMainWordsWith(implode(' ', + $authors->getAllAuthorsFromZones(['700']))); + + return + $main_authors + . ' ' + . $this->_indexation + ->getFulltextAuthor([...$all_authors, + ...$authors->getRenvois($this->_record), + ...$this->_getCodifAuteurRenvois($all_authors)]); + } + + + protected function _getCodifAuteurRenvois(array $all_authors) : array { + return array_filter(array_map(fn($author) => ($codif = $this->_getCodifAuthorFor($author)) + && $codif->hasMotsRenvois() + ? $codif->getMotsRenvois() + : '', + $all_authors)); + } +} diff --git a/library/Class/Notice/Titles.php b/library/Class/Notice/Titles.php new file mode 100644 index 0000000000000000000000000000000000000000..26610f12154f8aa3c9d0a5d4cc253e5b9010d859 --- /dev/null +++ b/library/Class/Notice/Titles.php @@ -0,0 +1,202 @@ +<?php +/** + * Copyright (c) 2012-2022, 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_Notice_Titles { + use Trait_Translator; + + const + MAIN_TITLE = '200a', + OTHER_TITLE = '200e', + SET_TITLE = '461t', + PIECE_TITLE = '463t'; + + protected Class_NoticeUnimarc $_unimarc; + + public function __construct(Class_NoticeUnimarc $unimarc) { + $this->_unimarc = $unimarc; + } + + + public function getMainTitle() : string { + return $this + ->_filter(implode(' ', + array_unique($this->_getSubfield(static::MAIN_TITLE)))); + } + + + public function getParentTitle() : string { + if ($data = $this->_getSubfield(static::SET_TITLE)) + return $this->_filter($data[0]); + + if ($data = $this->_getSubfield(static::PIECE_TITLE)) + return $this->_filter(end($data)); + + if ($data = $this->_getSubfield(static::MAIN_TITLE)) + return $this->_filter($data[0]); + + return ''; + } + + + public function getAllTitles(string $separator = BR, + ?string $main_title = null) : string { + $record_title = $main_title + ? $this->_filter($main_title) + : $this->_getFirstSubfield(static::MAIN_TITLE); + + $titles = []; + $volumes = []; + foreach($this->_unimarc->get_subfield(461, 't', 'v') as $title_volume) { + $title = $this->_filter($title_volume['t']); + $titles []= $title ? $title : $record_title; + $volumes []= $title_volume['v']; + } + + if (!in_array($record_title, $titles)) { + $titles []= $record_title; + $volumes []= ''; + } + + $titles_volumes = []; + foreach($titles as $i => $title) + $titles_volumes []= implode($this->_(' n° '), + array_filter([$title, $volumes[$i]])); + + return implode($separator, + array_filter($titles_volumes)); + } + + + public function getSubtitle() : string { + $zones = Class_Profil::getCurrentProfil()->getZonesTitre(); + + return implode(' : ', $this->_getFirstTitlesInZones($zones)); + } + + + protected function _filter(string $titre) : string { + $chars = [ + BR => "#BR# ", + '[' => ' ', + ']' => '', + '<' => ' ', + '>' => ' ', + ' ' => ' ' + ]; + $titre = str_replace(array_keys($chars), + array_values($chars), + trim($titre)); + + $non_sortings_chars = [ + chr(0xc2) . chr(0x88), + chr(0xc2) . chr(0x89), + chr(0xc2) . chr(0x98), + chr(0xc2) . chr(0x9c) + ]; + $titre = str_replace($non_sortings_chars, '', $titre); + + if ('?' == substr($titre, 0, 1)) { + $deb = substr($titre, 0, 6); + $titre = str_replace('?', '', $deb) . substr($titre, 6); + } + + // filtrage caractères terminaux + $filtre = ['/', ';', ',', ':', '-', '.']; + foreach($filtre as $car) + if (substr($titre, -1) == $car) + $titre = substr($titre, 0, strlen($titre) - 1); + + $titre = str_replace("#BR#", BR, $titre); + return trim($titre); + } + + + public function getTitles() : array { + return ($zones = Class_CosmoVar::getValueOf('unimarc_zone_titre')) + ? $this->getTitlesInZones(array_filter(explode(';', trim($zones)))) + : []; + } + + + public function getTitleSupplement() : string { + return ($titre = $this->_getSubfield(static::OTHER_TITLE)) + ? $this->_filter($titre[0]) + : ''; + } + + + public function getTitleSerial() : string { + return ($titre = $this->_getSubfield(static::SET_TITLE)) + ? $this->_filter($titre[0]) + : ''; + } + + + /** + * @param $visitor use Trait_NoticeVisitor + */ + public function acceptVisitor($visitor) : self { + $visitor->visitSerialTitle($this->getTitlesInZones([static::SET_TITLE])); + $visitor->visitTitres($this->getTitlesInZones([static::MAIN_TITLE, + static::OTHER_TITLE])); + + return $this; + } + + + public function getTitlesInZones(array $zones) : array { + $titres = new Storm_Collection; + foreach ($zones as $field_description) + $titres->addAll(array_map(fn($value) => $this->_filter($value), + $this->_getSubfield($field_description))); + + return $titres + ->select(fn($value) => $value) + ->getArrayCopy(); + } + + + protected function _getFirstTitlesInZones(array $zones) : array { + $titres = new Storm_Collection; + foreach ($zones as $field_description) + $titres->add($this->_getFirstSubfield($field_description)); + + return $titres + ->select(fn($value) => $value) + ->getArrayCopy(); + } + + + protected function _getFirstSubfield(string $field_description) : string { + return ($values = $this->_getSubfield($field_description)) + ? $this->_filter(reset($values)) + : ''; + } + + + protected function _getSubfield(string $field_description) : array { + $zone = substr($field_description, 0, 3); + $field = substr($field_description, -1); + + return $this->_unimarc->get_subfield($zone, $field); + } +} diff --git a/library/Class/Notice/ZoteroMetaData.php b/library/Class/Notice/ZoteroMetaData.php index 5cb3e85dd885e1dc87ff775feaf92023232a71ca..e95659d4d667c82a9288784e821d19e9463f63fc 100644 --- a/library/Class/Notice/ZoteroMetaData.php +++ b/library/Class/Notice/ZoteroMetaData.php @@ -73,7 +73,7 @@ class Class_Notice_ZoteroMetaData { public function getMapping() : array { return [ 'type' => fn($record) => ($record->getZoteroLabel() ? $record->getZoteroLabel() : 'book'), - 'title' => fn($record) => (implode(' : ', $record->getTitresDansZones(['200$a', '200$e', '200$h', '200$i']))), + 'title' => fn($record) => (implode(' : ', (new Class_Notice_Titles($record->getNoticeUnimarc()))->getTitlesInZones(['200$a', '200$e', '200$h', '200$i']))), 'abstractNote' => 'Resume', 'series' => fn($record) => array_filter([$record->getCollections(true), $record->getSerieTitle()]), diff --git a/library/Class/NoticeUnimarc.php b/library/Class/NoticeUnimarc.php index 667bc5cd3b671c41654deeac190b9490aed4e9a3..624220d5aac795861c67a8929d58312d2c7eff34 100644 --- a/library/Class/NoticeUnimarc.php +++ b/library/Class/NoticeUnimarc.php @@ -166,15 +166,8 @@ class Class_NoticeUnimarc { return new Storm_Collection([]); return (new Storm_Collection($subfields)) - ->select(function ($bloc) use($subfield) - { - return $subfield == $bloc['code']; - }) - ->collect(function ($bloc) - { - return $bloc['valeur']; - } - ); + ->select(fn($bloc) => $subfield == $bloc['code']) + ->collect(fn($bloc) => $bloc['valeur']); } protected function _getSubfieldContent($content, &$subfields, &$result) { @@ -266,7 +259,7 @@ class Class_NoticeUnimarc { } - public function getOtherIndexedTerms() { + public function getOtherIndexedTerms() : array { return $this->getAllStringsInFields(Class_CosmoVar::getAsFields('other_index_fields')); } @@ -292,23 +285,20 @@ class Class_NoticeUnimarc { /** - * Concatenate all values founds in $fields + * Return all values founds in $fields * @param $fields array of ['zone', 'field'] like: * [ ['200', 'a'], ['330', 'a'], ['461', 't'] ] - * @return string + * @return array */ - public function getAllStringsInFields($fields) { + public function getAllStringsInFields($fields) : array { if (!$fields) - return ''; - - $datas = array_map( - function($field) { - return implode(' ', - call_user_func_array([$this, 'get_subfield'], - $field)); }, - $fields); + return []; - return implode(' ', $datas); + return array_map(fn($field) => implode(' ', + call_user_func_array([$this, + 'get_subfield'], + $field)), + $fields); } diff --git a/library/digital_resources/Artips/tests/ArtipsTest.php b/library/digital_resources/Artips/tests/ArtipsTest.php index 5f0d17abfcb14344a82a230ef1c64a481ba4218d..973335fef2a0033c9d8c19a2598fef7cfe78ec80 100644 --- a/library/digital_resources/Artips/tests/ArtipsTest.php +++ b/library/digital_resources/Artips/tests/ArtipsTest.php @@ -86,7 +86,7 @@ class ArtipsHarvestTest extends ArtipsActivatedTestCase { public function getNoticeAttribs() { return [ ['getTitrePrincipal', 'Les présidents de la Ve République'], - ['getSubtitle', 'Découvrez l’œuvre et l’héritage politique des chefs d’État français de 1958 à nos jours.'], + ['getSubtitle', 'Découvrez l’œuvre et l’héritage politique des chefs d’État français de 1958 à nos jours'], ['getResume', 'Comment de Gaulle a-t-il fondé la Ve République ? Quels sont les secrets du Président Mitterrand ? Comment fonctionne le Conseil constitutionnel ? Quels rôles ont joué les "Premières dames" dans la politique française ?<br><br>Découvrez les coulisses de l’Élysée, la vie et les grandes réformes des huit présidents de la Ve République. Révisez aussi le fonctionnement des grandes institutions et le jeu des partis politiques, du général de Gaulle jusqu’à Emmanuel Macron.'], ['getAuteurPrincipal', 'Artly Production'], ]; diff --git a/library/digital_resources/ToutApprendre/tests/ToutApprendreTest.php b/library/digital_resources/ToutApprendre/tests/ToutApprendreTest.php index 1c199a77ce32145f5f0f49c2573b4b10cb01a1e4..8b124d79e9f4956c3e782acb3f35e9d3a143006a 100644 --- a/library/digital_resources/ToutApprendre/tests/ToutApprendreTest.php +++ b/library/digital_resources/ToutApprendre/tests/ToutApprendreTest.php @@ -368,7 +368,7 @@ class ToutApprendreHarvestIndexationTest extends ToutApprendreHarvestTestCase { /** @test */ public function recordFullTextEditeurShouldBePhoneticToutApprendreEduPerformance() { - $this->assertEquals('TOUTAPPRENDRECOM TOUTAPRANDREKON EDUPERFORMANCE EDUPERFORMANS', + $this->assertEquals('TOUTAPPRENDRECOM EDUPERFORMANCE TOUTAPRANDREKON EDUPERFORMANS', Class_Notice::find(1)->getEditeur()); } } diff --git a/library/templates/Intonation/Library/Widget/Search/View.php b/library/templates/Intonation/Library/Widget/Search/View.php index 7906c80735ee2f00e9ffb0bd5354e70090eded36..980276c2864b5ac8e04f61dafa25506848ca4c26 100644 --- a/library/templates/Intonation/Library/Widget/Search/View.php +++ b/library/templates/Intonation/Library/Widget/Search/View.php @@ -180,8 +180,8 @@ abstract class IntonationSearchRenderAbstract { $action_url = array_merge($action_url, $url_params); - if (isset($action_url['expressionRecherche'])) - unset($action_url['expressionRecherche']); + unset($action_url['expressionRecherche']); + unset($action_url['pertinence']); if ($doc_type = $this->_settings->getTypeDoc()) $action_url['facette'] = Class_TypeDoc::CODE_FACETTE . $doc_type; diff --git a/scripts/reindex_local_unimarc.php b/scripts/reindex_local_unimarc.php index de3ed3af92e18d1a62b03404cb925e1cd4cefc5e..c3d711cb5c5d96167fe00f5774df5913c455d85a 100644 --- a/scripts/reindex_local_unimarc.php +++ b/scripts/reindex_local_unimarc.php @@ -3,25 +3,19 @@ error_reporting(E_ERROR | E_PARSE); require(__DIR__.'/../console.php'); -echo "\n\nWelcome to the iReindex Other Terms 2000 X tool by @lla & @patbator, proudly RTed by @ghislo \n\n"; +echo "\n\nWelcome to the iReindex Other Terms 2000 X tool by @lla & @patbator, proudly RTed by @ghislo, remastered in 2022 by @lla & @seb \n\n"; $page = 1; -$other_index_fields = Class_CosmoVar::getAsFields('other_index_fields'); -if (!$other_index_fields) { - echo "nothing to do .....\n"; - exit; -} while ($records = Class_Notice::findAllBy(['limitPage' => [$page, 1000]])) { echo "\npage: $page\n"; $page ++; - array_map(function($record) use ($other_index_fields) { - $other_terms = $record->getAllStringsInFields($other_index_fields); - $record->setOtherTerms(Class_Indexation::getInstance()->getFullText($other_terms)); - $record->save(); - echo '.'; - }, - $records); + array_map(function($record) { + (new Class_Notice_Indexation($record))->indexAndSave(); + $record->save(); + echo '.'; + }, + $records); Storm_Model_Abstract::unsetLoaders(); Storm_Model_Loader::resetCache(); @@ -29,4 +23,4 @@ while ($records = Class_Notice::findAllBy(['limitPage' => [$page, 1000]])) { } echo "\n\nDONE !!!!\n\n"; -?> \ No newline at end of file +?> diff --git a/tests/application/modules/admin/controllers/AlbumControllerExportEadGallicaTest.php b/tests/application/modules/admin/controllers/AlbumControllerExportEadGallicaTest.php index 193156449d4360e0cafaacc34c95e30f28fcaf12..0950628e29276d49ab95e3c8b764388687efdb94 100644 --- a/tests/application/modules/admin/controllers/AlbumControllerExportEadGallicaTest.php +++ b/tests/application/modules/admin/controllers/AlbumControllerExportEadGallicaTest.php @@ -635,7 +635,7 @@ class Admin_AlbumControllerExportEadGallicaAlbumWithRecordFRBRTest $this->_xpath ->assertXPathContentContains($this->_xml, '//ead:archdesc//ead:did/ead:unittitle', - 'Arthur Watkins, entraîneur public à Chantilly. : Les sports. Nos entraîneurs.'); + 'Arthur Watkins, entraîneur public à Chantilly : Les sports. Nos entraîneurs'); } @@ -722,4 +722,4 @@ class Admin_AlbumControllerExportEadGallicaAlbumWithRecordFRBRTest } -} \ No newline at end of file +} diff --git a/tests/application/modules/opac/controllers/RechercheControllerAtomTest.php b/tests/application/modules/opac/controllers/RechercheControllerAtomTest.php index 3aff712f67cf48e639a46fa107e1e24e6d589970..c17ebfe25223c35a0730bc5ea8e8d5f7f61f87c0 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerAtomTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerAtomTest.php @@ -86,13 +86,13 @@ class RechercheControllerAtomEmptyTest extends RechercheControllerAtomTestCase { protected function _prepareSql($sql) { $sql->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(HARRY HARRYS ARI) +(POTTER POTTERS POT)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+S1 +G123' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' HARRY POTTER') * 1.5) + (MATCH(auteurs) AGAINST(' HARRY POTTER')) desc", + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(HARRY HARRYS ARI) +(POTTER POTTERS POT)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+S1 +G123' IN BOOLEAN MODE)) and type=1 order by MATCH(titres, auteurs) AGAINST('\\\"HARRY POTTER\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"HARRY POTTER\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_HARRY P_POTTER') desc, MATCH(titres) AGAINST('P_HARRY P_POTTER') desc, MATCH(titres) AGAINST('HARRY POTTER') desc, MATCH(auteurs) AGAINST('HARRY POTTER') desc, date_creation desc", true, false) ->answers([]) ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST(' (HARRY HARRYS ARI) (POTTER POTTERS POT)') and MATCH(facettes) AGAINST('+S1 +G123' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' HARRY POTTER') * 1.5) + (MATCH(auteurs) AGAINST(' HARRY POTTER')) desc", + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('(HARRY HARRYS ARI) (POTTER POTTERS POT)') and MATCH(facettes) AGAINST('+S1 +G123' IN BOOLEAN MODE)) and type=1 order by MATCH(titres, auteurs) AGAINST('\\\"HARRY POTTER\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"HARRY POTTER\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_HARRY P_POTTER') desc, MATCH(titres) AGAINST('P_HARRY P_POTTER') desc, MATCH(titres) AGAINST('HARRY POTTER') desc, MATCH(auteurs) AGAINST('HARRY POTTER') desc, date_creation desc", true, false) ->answers([]) @@ -487,4 +487,3 @@ class RechercheControllerAtomWithAdvancedSearchTest extends RechercheControllerA } } -?> diff --git a/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php b/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php index e4d5d4e989366e09c4b9da5cc8efbdcb1f6df61d..b2cdefb310910fc33bf107ede78ef29ea84401a4 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerPrintActionTest.php @@ -78,7 +78,7 @@ class RechercheControllerPrintActionWithRecordsTest extends AbstractControllerTe $mock_sql = $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(POMME POMMES POM)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+T3' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' POMME') * 1.5) + (MATCH(auteurs) AGAINST(' POMME')) desc", + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(POMME POMMES POM)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+T3' IN BOOLEAN MODE)) and type=1 order by MATCH(auteurs) AGAINST('P_POMME') desc, MATCH(titres) AGAINST('P_POMME') desc, MATCH(titres) AGAINST('POMME') desc, MATCH(auteurs) AGAINST('POMME') desc, date_creation desc", true, false) ->answers([ @@ -244,4 +244,4 @@ class RechercheControllerPrintActionWithUnknownIdTest extends AbstractController public function shouldDisplayNoDataToPrint() { $this->assertXPathContentContains('//div', 'Aucune donnée à imprimer'); } -} \ No newline at end of file +} diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index 2283e888b82822dd3e7c8d27eef416411383cabc..4f5217995b132c17a324c49e935377d95b39a51a 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -20,7 +20,6 @@ */ abstract class RechercheControllerNoticeTestCase extends AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); @@ -179,7 +178,7 @@ class RechercheControllerPagerTest extends RechercheControllerNoticeTestCase { $records = array_map(function($i) { return [$i, ''];}, range(1, 45) ); $this->mock_sql ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(POMME POMMES POM)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+T3' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' POMME') * 1.5) + (MATCH(auteurs) AGAINST(' POMME')) desc", + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(POMME POMMES POM)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+T3' IN BOOLEAN MODE)) and type=1 order by MATCH(auteurs) AGAINST('P_POMME') desc, MATCH(titres) AGAINST('P_POMME') desc, MATCH(titres) AGAINST('POMME') desc, MATCH(auteurs) AGAINST('POMME') desc, date_creation desc", true, false) ->answers($records) @@ -998,13 +997,16 @@ class RechercheControllerVignetteEmptyTest extends AbstractControllerTestCase { -class RechercheControllerViewNoticeClefAlphaTest extends RechercheControllerNoticeTestCase { + +class RechercheControllerViewNoticeClefAlphaTest + extends RechercheControllerNoticeTestCase { + public function setUp() { parent::setUp(); $this->mock_sql ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(MILLENIUM MILLENIUMS MILENIUM)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' MILLENIUM') * 1.5) + (MATCH(auteurs) AGAINST(' MILLENIUM')) desc", true, null) + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(MILLENIUM MILLENIUMS MILENIUM)' IN BOOLEAN MODE)) and type=1 order by MATCH(auteurs) AGAINST('P_MILLENIUM') desc, MATCH(titres) AGAINST('P_MILLENIUM') desc, MATCH(titres) AGAINST('MILLENIUM') desc, MATCH(auteurs) AGAINST('MILLENIUM') desc, date_creation desc", true, null) ->answers([ [10, ''], [99, ''], @@ -1015,12 +1017,12 @@ class RechercheControllerViewNoticeClefAlphaTest extends RechercheControllerNoti [4, ''] ]); - $this->onLoaderOfModel('Class_Notice') + $this->onLoaderOfModel(Class_Notice::class) ->whenCalled('findAllBy') ->with(['clef_alpha' => 'TESTINGALPHAKEY---101']) ->answers([$this->notice]); - $this->dispatch('recherche/viewnotice/clef/TESTINGALPHAKEY---101/expressionRecherche/Millenium', true); + $this->dispatch('recherche/viewnotice/clef/TESTINGALPHAKEY---101/expressionRecherche/Millenium'); } @@ -1036,12 +1038,15 @@ class RechercheControllerViewNoticeClefAlphaTest extends RechercheControllerNoti 'Retour à la liste'); } + /** @test */ public function resultatSuivantShouldLinkToNavigationSuivant() { + xdebug_break(); $this->assertXPathContentContains('//div//a[contains(@href, "/recherche/viewnotice/expressionRecherche/Millenium/clef/TESTINGALPHAKEY---101/id/345/navigation/suivant")]', 'Document suivant'); } + /** @test */ public function resultatPrecedentShouldLinkToNavigationPrecedent() { $this->assertXPathContentContains('//div//a[contains(@href, "/recherche/viewnotice/expressionRecherche/Millenium/clef/TESTINGALPHAKEY---101/id/345/navigation/precedent")]', @@ -4013,7 +4018,7 @@ class RechercheControllerNoExtensionTest extends AbstractControllerTestCase { $this->mock_sql = $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(VIE VIES) +(GEEK GEEKS JEK)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' VIE GEEKS') * 1.5) + (MATCH(auteurs) AGAINST(' VIE GEEKS')) desc", true, false) + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(VIE VIES) +(GEEK GEEKS JEK)' IN BOOLEAN MODE)) and type=1 order by MATCH(titres, auteurs) AGAINST('\\\"LA VIE DES GEEKS\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"LA VIE DES GEEKS\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_VIE P_GEEKS') desc, MATCH(titres) AGAINST('P_VIE P_GEEKS') desc, MATCH(titres) AGAINST('VIE GEEKS') desc, MATCH(auteurs) AGAINST('VIE GEEKS') desc, date_creation desc", true, false) ->answers([[1, '']]) ->beStrict(); @@ -4070,7 +4075,7 @@ class RechercheControllerSimpleAccentsSpeciauxTest extends AbstractControllerTes $this->mock()->beStrict() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(DVORAK DVORAKS DVORAK)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' DVORAK') * 1.5) + (MATCH(auteurs) AGAINST(' DVORAK')) desc", true, false) + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(DVORAK DVORAKS DVORAK)' IN BOOLEAN MODE)) and type=1 order by MATCH(auteurs) AGAINST('P_DVORAK') desc, MATCH(titres) AGAINST('P_DVORAK') desc, MATCH(titres) AGAINST('DVORAK') desc, MATCH(auteurs) AGAINST('DVORAK') desc, date_creation desc", true, false) ->answers([[1, '']]); Zend_Registry::set('sql', $this->mock_sql); diff --git a/tests/application/modules/opac/controllers/RecordCustomLinksTest.php b/tests/application/modules/opac/controllers/RecordCustomLinksTest.php index 81713a2a70a3c5faf20b235122be282c2cd94898..576ddaa4e877c1452f528b9c887114f657bed6b3 100644 --- a/tests/application/modules/opac/controllers/RecordCustomLinksTest.php +++ b/tests/application/modules/opac/controllers/RecordCustomLinksTest.php @@ -138,7 +138,7 @@ class RecordCustomLinksRechercheControllerWithBrazilTest extends RecordCustomLin Zend_Registry::set('sql', $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(BRAZIL BRAZILS BRAZIL)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' BRAZIL') * 1.5) + (MATCH(auteurs) AGAINST(' BRAZIL')) desc", true, false) + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(BRAZIL BRAZILS BRAZIL)' IN BOOLEAN MODE)) and type=1 order by MATCH(auteurs) AGAINST('P_BRAZIL') desc, MATCH(titres) AGAINST('P_BRAZIL') desc, MATCH(titres) AGAINST('BRAZIL') desc, MATCH(auteurs) AGAINST('BRAZIL') desc, date_creation desc", true, false) ->answers([[888, '']])); $this->dispatch('/opac/recherche/simple/expressionRecherche/brazil'); diff --git a/tests/fixtures/unimarc_droit_administratif.txt b/tests/fixtures/unimarc_droit_administratif.txt new file mode 100644 index 0000000000000000000000000000000000000000..1c2e6d51a5769c5c5eaf98cbc9f8a5a7005a8ad9 --- /dev/null +++ b/tests/fixtures/unimarc_droit_administratif.txt @@ -0,0 +1 @@ +01798cam0 2200505 450 00100060000000300300000600500170003600900100005301000310006303500210009403500220011503500220013703500230015903500220018207300180020409000100022209900180023210000410025010100080029110200070029910500180030610600060032418100250033018100200035518200210037518200110039618300250040720000840043221000530051621500270056922500430059632000570063941000650069660601100076160601580087167600110102967600150104067600150105568000110107068600130108170000750109480100300116991500310119993000620123052899http://www.sudoc.fr/06072870120210602021143.0060728701 a2-13-050700-Xbbr.d28 EUR a(OCoLC)422168958 aDYNIX_BUPTP_96106 aDYNIX_BUCAY_61039 aDYNIX_BUNAN_487237 5384212201a765060 1a9782130507000 a52899 touvrages0x3 a20020430h20022002k y0frey50 ba0 afre aFR ay a 001yy ar 6z01ctxt2rdacontent 16z01ai#bxxxe## 6z01cn2rdamedia 16z01an 16z01anga2rdacarrier1 aIntroduction historique au droit administratif depuis 1789fGrégoire Bigot,... aPariscPresses universitaires de FrancedDL 2002 a1 vol. (390 p.)d22 cm2 aDroit fondamentaliDroit administratif aBibliogr. en fin de chapitres. Notes bibliogr. Index 0001029398tDroit fondamental. Droit administratifx0760-9949 9121548730277414277ba0yba0yaDroit administratif9121540530275371612rameau7ba0yba0yaSourcesxSources 9121548730277414277ba0yba0yaDroit administratif9121498630272267947ba0yba0yaFranceyFrance91215125302726470X2rameau7ba0yba0yaHistoirexHistoire a342.06 a340.09v21 a342.06v21 aJN2725 aJC/(HIS) 1305039568840707ba0yba0yaBigotbGrégoiref1969-....cjuriste9929974 3aFRbAbesc20180627gAFNOR 5384212201:338651527a18230 5384212201:338651527b384212201disoa342.09 BIG MANUELjg \ No newline at end of file diff --git a/tests/fixtures/unimarc_justice_laicite.txt b/tests/fixtures/unimarc_justice_laicite.txt new file mode 100644 index 0000000000000000000000000000000000000000..ef7ee21ed36a801bfaca1aafae5280c77aafba42 --- /dev/null +++ b/tests/fixtures/unimarc_justice_laicite.txt @@ -0,0 +1 @@ +01942cam0 2200541 450 00100060000000300300000600500170003600900100005301000300006303500200009303500150011303500160012803500130014407300180015709000100017509800150018509900270020010000410022710100130026810200070028110500180028810600060030618100250031218100200033718200210035718200110037818300230038920001110041221400500052321500270057330200380060030501050063832000380074346100530078160600400083460600790087460600800095367500100103370100560104371001070109980100300120680100210123680100200125780100140127780100270129191500340131893000480135244637http://www.sudoc.fr/04710380920211116021814.0047103809 a2-8413-3069-9bbr.d100 F a(OCoLC)42968816 asib1359068 aocm42968816 alm133987 0a9782841330690 a44637 e2021-11-16 touvrages0e2021-11-16 a19990514h19981998k y0frey50 ba0 afredeng aFR ay z 000yy ar 6z01ctxt2rdacontent 16z01ai#bxxxe## 6z01cn2rdamedia 16z01an 6z01anga2rdamedia1 aJustice et laïcitéfUniversité de Caen, sciences de l'éducationf[rédacteur en chef, Alain Vergnioux] 0aCaencPresses universitaires de CaendDL 1998 a1 vol. (127 p.)d24 cm aRésumés des articles en anglais aNuméro de la revue "Télémaque : philosophie, éducation, société", ISSN 1263-588X, n° 14, 1998 aNotes bibliogr. en fin d'articles 0040414019tLe Télémaque (Dijon)x1263-588Xv14 302726224391213928aJustice2rameau 302822873191218310aÉquité302722744891219904yFrancexHistoire2rameau 302726412291019312aLaïcité302722744891219904yFrancexHistoire2rameau a211.5 130319947099658857aVergniouxbAlainf1946-....46510230309308399213269aCentre d'études et de recherche en sciences de l'éducationcCaenc1985?-20164340 3aFRbAbesc20211115gAFNOR 3aFRbSFc19000120 1aUSbOCLCgAACR2 2aFRbAUROC 0aFRbSCD Le MansgAFNOR 5384212201:107618362aAO 65938 5384212201:107618362b384212201aAO 65938jg diff --git a/tests/fixtures/unimarc_parties_democracy.txt b/tests/fixtures/unimarc_parties_democracy.txt new file mode 100644 index 0000000000000000000000000000000000000000..047892e9b34d752cb2c7c22a63de5e0a31916e9e --- /dev/null +++ b/tests/fixtures/unimarc_parties_democracy.txt @@ -0,0 +1 @@ +01520cam0 2200469 450 00100060000000300300000600500170003600900100005301000360006302000160009902000170011503500210013203500150015303500160016809000100018409900150019410000410020910100080025010200110025810500180026910600060028718100250029318100200031818200210033818200110035918300250037020001220039521400520051721500300056932000260059960600440062560600600066960600820072967600100081170000620082180100300088380100210091380100200093480100140095491500340096893000480100244613http://www.sudoc.fr/04703867520210705021000.0047038675 a0-631-20930-1bbr. : alk. paper aUSb9849541 aGBb99-65507 a(OCoLC)490300614 asib1349593 aocm40249807 a44613 touvrages0 a19990429d1998 k y0frey50 ba0 aeng aGBaUS ay a 001yy ar 6z01ctxt2rdacontent 16z01ai#bxxxe## 6z01cn2rdamedia 16z01an 16z01anga2rdacarrier1 aParties and democracyeparty structure and party performance in old and new democraciesfEdited by Richard Hofferbert 0aOxfordaMalden (MA)cBlackwell publishersd1998 a1 vol. (VI-254 p.)d24 cm aNotes bibliogr. Index 302735805491221134aDémocratie2rameau 30272458297ba0yba0yaPartis politiques2rameau91219949 30274684377ba0yba0yaScience politiquexÉtudes comparatives2rameau91219124 a324.2 130337151149221626aHofferbertbRichard I.f1937-....4651 3aFRbAbesc20200429gAFNOR 3aFRbSFc19000120 1aUSbOCLCgAACR2 2aFRbAUROC 5384212201:107487187aAO 64949 5384212201:107487187b384212201aAO 64949jg \ No newline at end of file diff --git a/tests/library/Class/Cosmogramme/Integration/PhaseSerialArticlesIndexTest.php b/tests/library/Class/Cosmogramme/Integration/PhaseSerialArticlesIndexTest.php index 3adf4dc675794217c4ec244e22625d31bdc8ccf6..32eadecbcf18523216e3048cf8548a46f3367c47 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhaseSerialArticlesIndexTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhaseSerialArticlesIndexTest.php @@ -177,20 +177,20 @@ class Class_Cosmogramme_Integration_PhaseSerialArticlesIndexTest /** @test */ public function issueTitlesShouldContainsXMenAndIronManTerms() { - $this->assertContains('IRON MAN X00 MEN', $this->_issue->getTitres()); + $this->assertContains('LES X MEN IRON MAN', $this->_issue->getTitres()); } /** @test */ public function issueMatieresShouldContainsXMenAndIronManSubjectsTerms() { - $this->assertEquals('ARMURE ARMUR JAUNE JON ROUGE ROUJ BLING SLIPS SLIP CAPES KAP MOULANTS MOULAN COLLANTS KOLAN', + $this->assertEquals('SLIPS CAPES MOULANTS COLLANTS SLIP KAP MOULAN KOLAN ARMURE JAUNE ROUGE BLING ARMUR JON ROUJ', $this->_issue->getMatieres()); } /** @test */ public function issueAuteursShouldContainsXMenAndIronManAuthorsTerms() { - $this->assertEquals('LEE STAN LIEBER LIEB LARRY LARI HECK EK DON KIRBY KIRBI JACK JAK', + $this->assertEquals('LEE STAN LEE KIRBY JACK KIRBY KIRBI JAK LIEBER LARRY LIEBER LIEB LARI HECK DON HECK EK', $this->_issue->getAuteurs()); } diff --git a/tests/library/Class/Indexation/PseudoNoticeTest.php b/tests/library/Class/Indexation/PseudoNoticeTest.php index 830a9c0cf1650b180ebd729cf8963df15873352f..fed08c60ac12c449309b0eff6e1b52bf91cc4bfb 100644 --- a/tests/library/Class/Indexation/PseudoNoticeTest.php +++ b/tests/library/Class/Indexation/PseudoNoticeTest.php @@ -58,14 +58,14 @@ class Class_Indexation_PseudoNoticeWithSubtitleAndIndexationConfigTest extends M /** @test */ - public function titresShouldContainsTroisContesPetitsCochons() { - $this->assertEquals('TROIS TROI CONTES KONT PETITS PETI COCHONS KOCHON', $this->record->getTitres()); + public function titresShouldContainsTroisContesLesTroisPetitsCochons() { + $this->assertEquals('TROIS CONTES LES TROIS PETITS COCHONS TROI KONT PETI KOCHON', $this->record->getTitres()); } /** @test */ public function otherTermsShouldContainsGustaveFlaubert() { - $this->assertEquals('GUSTAVE GUSTAV FLAUBERT FLOBER', + $this->assertEquals('GUSTAVE FLAUBERT GUSTAV FLOBER', $this->record->getOtherTerms()); } @@ -215,10 +215,12 @@ class Class_Indexation_PseudoNoticeAlbumTest extends ModelTestCase { + class Class_Indexation_PseudoNoticeSitothequeFromRawSQLTest extends ModelTestCase { - protected $_sito; - protected $_notice; + protected + $_sito, + $_notice; public function setUp() { parent::setUp(); @@ -233,6 +235,7 @@ class Class_Indexation_PseudoNoticeSitothequeFromRawSQLTest extends ModelTestCas $this->_notice = Class_Notice::find(1); } + /** @test */ public function titleShouldBeIndexed() { $this->assertEquals('Thot cursus', $this->_notice->getTitrePrincipal()); @@ -543,6 +546,13 @@ class Class_Indexation_PseudoNoticeAlbumSummaryTest extends ModelTestCase { public function pseudoNoticeInteretShoudBeWorldAndVersailles() { $this->assertEquals(['world', 'versailles'], Class_Notice::find(1)->getCentreInteret()); } + + + /** @test */ + public function pseudoNoticeAuthorShouldBeJacquesAlainDeSedouy() { + $this->assertEquals('JACQUES ALAIN DE SEDOUY JAK ALIN SEDOUI', + Class_Notice::find(1)->getAuteurs()); + } } @@ -646,7 +656,7 @@ class Class_Indexation_PseudoNoticeArticleUpdateTest /** @test */ public function recordShouldHaveBeenUpdated() { - $this->assertEquals('SHOULD CHOUL UPDATE UPDAT RECORD REKOR WITH OUI 15', + $this->assertEquals('SHOULD UPDATE RECORD WITH ID 15 CHOUL UPDAT REKOR OUI', Class_Notice::find(16)->getTitres()); } @@ -734,7 +744,7 @@ class Class_Indexation_PseudoNoticeRssUpdateTest extends ModelTestCase { /** @test */ public function recordShouldHaveBeenUpdated() { - $this->assertEquals('SHOULD CHOUL UPDATE UPDAT RECORD REKOR WITH OUI 15', + $this->assertEquals('SHOULD UPDATE RECORD WITH ID 15 CHOUL UPDAT REKOR OUI', Class_Notice::find(15)->getTitres()); } @@ -772,7 +782,7 @@ class Class_Indexation_PseudoNoticeSitothequeUpdateTest extends ModelTestCase { /** @test */ public function sitoGetNoticeShouldNotBeNull() { - $this->assertEquals('SHOULD CHOUL UPDATE UPDAT RECORD REKOR WITH OUI 15', + $this->assertEquals('SHOULD UPDATE RECORD WITH ID 15 CHOUL UPDAT REKOR OUI', $this->_sito->getNotice()->getTitres()); } @@ -859,7 +869,7 @@ class Class_Indexation_PseudoNoticeAlbumUpdateTest extends ModelTestCase { /** @test */ public function recordShouldHaveBeenUpdated() { - $this->assertEquals('SHOULD CHOUL UPDATE UPDAT RECORD REKOR WITH OUI THIS TI NEW TITLE TITL', + $this->assertEquals('SHOULD UPDATE RECORD WITH THIS NEW TITLE CHOUL UPDAT REKOR OUI TI TITL', Class_Notice::find(15)->getTitres()); } diff --git a/tests/library/Class/MoteurRechercheTest.php b/tests/library/Class/MoteurRechercheTest.php index 2e4e762aa3c51d28bd945c490c5f8c97f81d3657..f2869086c8d1068bc98c2e5eefd78734488310a3 100644 --- a/tests/library/Class/MoteurRechercheTest.php +++ b/tests/library/Class/MoteurRechercheTest.php @@ -97,6 +97,24 @@ class MoteurRechercheAvanceeTest extends MoteurRechercheTestCase { $list_sql = 'select id_notice, facettes from notices Where %s order by %s'; return [ + [['rech_titres' => '"nouveaux chiens" garde', + 'operateur_titres' => 'and', + 'tri' => 'alpha_titre'], + 'req_notices' => $this->listSqlWith("(MATCH(titres) AGAINST('+\\\"NOUVEAUX CHIENS\\\" +(GARDE GARDES GARD)' IN BOOLEAN MODE))", + 'alpha_titre')], + + [['rech_titres' => 'Les nouveaux chiens de garde', + 'operateur_titres' => 'and', + 'rech_editeur' => 'Raisons d\'agir', + 'operateur_editeur' => 'or', + 'selection_bib'=> 4, + 'nouveaute' => '3', + 'type_recherche' => 'nimportequoi', + 'pertinence' => false, + 'tri' => 'alpha_titre'], + 'req_notices' => $this->listSqlWith("date_creation >'2012-02-03' and (MATCH(titres) AGAINST('+(NOUVEAU NOUVEAUX NOUVO) +(CHIEN CHIENS CHIN) +(GARDE GARDES GARD)' IN BOOLEAN MODE) or MATCH(editeur) AGAINST('+(RAISON RAISONS RAISON) +(AGIR AGIRS AJIR)' IN BOOLEAN MODE)) and MATCH(facettes) AGAINST('+(B4)' IN BOOLEAN MODE)", + 'alpha_titre')], + [['rech_auteurs' => 'Foucault', 'operateur_auteurs' => 'and', 'type_recherche' => 'fulltext', @@ -154,20 +172,9 @@ class MoteurRechercheAvanceeTest extends MoteurRechercheTestCase { 'type_recherche' => '', 'pertinence' => true, 'tri' => 'alpha_titre'] , - 'req_notices' => $this->listSqlWith("(MATCH(matieres) AGAINST('(PC PC )' IN BOOLEAN MODE))", + 'req_notices' => $this->listSqlWith("(MATCH(matieres) AGAINST('(PC PC)' IN BOOLEAN MODE))", "alpha_titre")], - [['rech_titres' => 'Les nouveaux chiens de garde', - 'operateur_titres' => 'and', - 'rech_editeur' => 'Raisons d\'agir', - 'operateur_editeur' => 'or', - 'selection_bib'=> 4, - 'nouveaute' => '3', - 'type_recherche' => 'nimportequoi', - 'pertinence' => false, - 'tri' => 'alpha_titre'], - 'req_notices' => $this->listSqlWith("date_creation >'2012-02-03' and (MATCH(titres) AGAINST('+(NOUVEAU NOUVEAUX NOUVO) +(CHIEN CHIENS CHIN) +(GARDE GARDES GARD)' IN BOOLEAN MODE) or MATCH(editeur) AGAINST('+(RAISON RAISONS RAISON) +(D00 D00S ) +(AGIR AGIRS AJIR)' IN BOOLEAN MODE)) and MATCH(facettes) AGAINST('+(B4)' IN BOOLEAN MODE)", - 'alpha_titre')], [['rech_auteurs' => 'Stiegler', 'operateur_auteurs' => 'and', @@ -208,7 +215,7 @@ class MoteurRechercheAvanceeTest extends MoteurRechercheTestCase { 'tri' => 'alpha_titre'], 'req_notices' => $this->listSqlWith("(auteurs like 'STIEGLER%') and MATCH(facettes) AGAINST('+YMED1 +G23 +A345 +(T1 Tbokeh_page) +(YTUN YTAP) +(S1 S12 S9) +(B3)' IN BOOLEAN MODE)", 'alpha_titre')] - ]; + ]; } @@ -253,19 +260,43 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { public function expectedSql() { $match_axes = 'MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms)'; - return [ + [['expressionRecherche' => '2G FO U2', + 'tri' => 'alpha_titre'], + 'nb_mots' => 2, + 'req_liste' => $this->listSqlWith($match_axes . " AGAINST('+(2G 2GS) +(U2 U2S)' IN BOOLEAN MODE)", + 'alpha_titre')], + + [['expressionRecherche' => '"Gilets jaunes" canard bleu "chapeau rouge"'], + 'nb_mots' => 6, + 'req_liste' => $this->listSqlWith("MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+\\\"GILETS JAUNES\\\" +\\\"CHAPEAU ROUGE\\\" +(CANARD CANARDS KANAR) +(BLEU BLEUS BL)' IN BOOLEAN MODE)", + "MATCH(auteurs) AGAINST('P_CHAPEAU P_ROUGE P_GILETS P_JAUNES P_CANARD P_BLEU') desc, MATCH(titres) AGAINST('P_CHAPEAU P_ROUGE P_GILETS P_JAUNES P_CANARD P_BLEU') desc, MATCH(titres) AGAINST('CHAPEAU ROUGE GILETS JAUNES CANARD BLEU') desc, MATCH(auteurs) AGAINST('CHAPEAU ROUGE GILETS JAUNES CANARD BLEU') desc, date_creation desc")], + + [['expressionRecherche' => '"Gilets jaunes"'], + 'nb_mots' => 2, + 'req_liste' => $this->listSqlWith("MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+\\\"GILETS JAUNES\\\"' IN BOOLEAN MODE)", + "MATCH(auteurs) AGAINST('P_GILETS P_JAUNES') desc, MATCH(titres) AGAINST('P_GILETS P_JAUNES') desc, MATCH(titres) AGAINST('GILETS JAUNES') desc, MATCH(auteurs) AGAINST('GILETS JAUNES') desc, date_creation desc")], + + [['expressionRecherche' => 'Gilets jaunes'], + 'nb_mots' => 2, + 'req_liste' => $this->listSqlWith("MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(GILET GILETS JIL) +(JAUNE JAUNES JON)' IN BOOLEAN MODE)", + "MATCH(titres, auteurs) AGAINST('\\\"GILETS JAUNES\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"GILETS JAUNES\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_GILETS P_JAUNES') desc, MATCH(titres) AGAINST('P_GILETS P_JAUNES') desc, MATCH(titres) AGAINST('GILETS JAUNES') desc, MATCH(auteurs) AGAINST('GILETS JAUNES') desc, date_creation desc")], + + [['expressionRecherche' => 'take the a train'], + 'nb_mots' => 3, + 'req_liste' => $this->listSqlWith("MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(TAKE TAKES TAK) +(THE THES) +(TRAIN TRAINS TRIN)' IN BOOLEAN MODE)", + "MATCH(titres, auteurs) AGAINST('\\\"TAKE THE A TRAIN\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"TAKE THE A TRAIN\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_TAKE P_THE P_TRAIN') desc, MATCH(titres) AGAINST('P_TAKE P_THE P_TRAIN') desc, MATCH(titres) AGAINST('TAKE THE TRAIN') desc, MATCH(auteurs) AGAINST('TAKE THE TRAIN') desc, date_creation desc")], + [['expressionRecherche' => 'Bakounine'], 'nb_mots' => 1, - 'req_liste' => $this->listSqlWith($match_axes ." AGAINST('+(BAKOUNINE BAKOUNINES BAKOUNIN)' IN BOOLEAN MODE)", - "(MATCH(titres) AGAINST(' BAKOUNINE') * 1.5) + (MATCH(auteurs) AGAINST(' BAKOUNINE')) desc")], + 'req_liste' => $this->listSqlWith($match_axes . " AGAINST('+(BAKOUNINE BAKOUNINES BAKOUNIN)' IN BOOLEAN MODE)", + "MATCH(auteurs) AGAINST('P_BAKOUNINE') desc, MATCH(titres) AGAINST('P_BAKOUNINE') desc, MATCH(titres) AGAINST('BAKOUNINE') desc, MATCH(auteurs) AGAINST('BAKOUNINE') desc, date_creation desc")], [['expressionRecherche' => 'Bakounine', 'in_files' => 1], 'nb_mots' => 1, - 'req_liste' => $this->listSqlWith('(' . $match_axes ." AGAINST('+(BAKOUNINE BAKOUNINES BAKOUNIN)' IN BOOLEAN MODE) OR MATCH(file_content) AGAINST('Bakounine' IN BOOLEAN MODE))", - "(MATCH(titres) AGAINST(' BAKOUNINE') * 1.5) + (MATCH(auteurs) AGAINST(' BAKOUNINE')) + (MATCH(file_content) AGAINST('Bakounine') * 0.5) desc")], - + 'req_liste' => $this->listSqlWith('(' . $match_axes . " AGAINST('+(BAKOUNINE BAKOUNINES BAKOUNIN)' IN BOOLEAN MODE) OR MATCH(file_content) AGAINST('Bakounine' IN BOOLEAN MODE))", + "MATCH(auteurs) AGAINST('P_BAKOUNINE') desc, MATCH(titres) AGAINST('P_BAKOUNINE') desc, MATCH(titres) AGAINST('BAKOUNINE') desc, MATCH(auteurs) AGAINST('BAKOUNINE') desc, MATCH(file_content) AGAINST('Bakounine') desc, date_creation desc")], [['expressionRecherche' => 'Slavoj Zizek', 'tri' => 'alpha_titre'] , @@ -273,6 +304,12 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { 'req_liste' => $this->listSqlWith($match_axes . " AGAINST('+(SLAVOJ SLAVOJS SLAVOJ) +(ZIZEK ZIZEKS ZIZEK)' IN BOOLEAN MODE)", 'alpha_titre')], + [['expressionRecherche' => 'L\'amour y\'est dans le pré', + 'tri' => 'alpha_titre'] , + 'nb_mots' => 4, + 'req_liste' => $this->listSqlWith($match_axes . " AGAINST('+(AMOUR AMOURS AMOUR) +(EST ESTS) +(DAN DANS) +(PRE PRES)' IN BOOLEAN MODE)", + 'alpha_titre')], + [['expressionRecherche' => 'La commune de Paris', 'annexe' => 'MED1', 'selection_annexe' => 'TUN;TAP', @@ -304,7 +341,7 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { 'tri' => 'alpha_titre'], 'nb_mots'=> 1, 'req_liste' => $this->listSqlWith($match_axes . " AGAINST('+(POMME POMMES POM)' IN BOOLEAN MODE) and type_doc in('per_art','per_title')", - 'alpha_titre')], + 'alpha_titre')], [['expressionRecherche' => '9782742761579', 'selection_bib'=> 1], @@ -318,13 +355,13 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { 'selection_sections' => '1;12;9'], 'nb_mots'=> 1, 'req_liste' => $this->listSqlWith($match_axes . " AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+YMED1 +M52291 +A15067 +(YTUN YTAP) +(S1 S12 S9)' IN BOOLEAN MODE)", - "(MATCH(titres) AGAINST(' LOGO') * 1.5) + (MATCH(auteurs) AGAINST(' LOGO')) desc")], + "MATCH(auteurs) AGAINST('P_LOGO') desc, MATCH(titres) AGAINST('P_LOGO') desc, MATCH(titres) AGAINST('LOGO') desc, MATCH(auteurs) AGAINST('LOGO') desc, date_creation desc")], [['expressionRecherche' => 'logo', 'multifacets' => 'Tper_title'], 'nb_mots'=> 1, 'req_liste' => $this->listSqlWith($match_axes . " AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+(Tper_title)' IN BOOLEAN MODE)", - "(MATCH(titres) AGAINST(' LOGO') * 1.5) + (MATCH(auteurs) AGAINST(' LOGO')) desc")], + "MATCH(auteurs) AGAINST('P_LOGO') desc, MATCH(titres) AGAINST('P_LOGO') desc, MATCH(titres) AGAINST('LOGO') desc, MATCH(auteurs) AGAINST('LOGO') desc, date_creation desc")], [['expressionRecherche' => 'security', 'annexe' => 'MED(")', @@ -336,20 +373,18 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { 'selection_sections' => '1;goup<ip;9'], 'nb_mots'=> 1, 'req_liste' => $this->listSqlWith($match_axes . " AGAINST('+(SECURITY SECURITYS SEKURITI)' IN BOOLEAN MODE) and type_doc in('1','2') and MATCH(facettes) AGAINST('+(Y8) +(S1 S9) +(E34) +(B12)' IN BOOLEAN MODE)", - "(MATCH(titres) AGAINST(' SECURITY') * 1.5) + (MATCH(auteurs) AGAINST(' SECURITY')) desc")], + "MATCH(auteurs) AGAINST('P_SECURITY') desc, MATCH(titres) AGAINST('P_SECURITY') desc, MATCH(titres) AGAINST('SECURITY') desc, MATCH(auteurs) AGAINST('SECURITY') desc, date_creation desc")], [['expressionRecherche' => '', 'digital_lib' => '1'], 'nb_mots'=> 0, - 'req_liste' => $this->listSqlWith("(type_doc in ('100','101','102','103','104','105','109','110','111','112','113','115','116','117','119','Arkhenum','ArteCampus','Artips','Assimil','Bacon','Cvs','DiMusic','Kidilangues','LaSourisQuiRaconte','Lekiosk','LesYeuxDoc','MaPetiteMediatheque','Mobidys','Musicme','Numilog','Omeka','Skilleos','StoryPlayR','ToutApprendre','Whisperies'))")], [['expressionRecherche' => 'logo', 'digital_lib' => '1'], 'nb_mots'=> 1, - 'req_liste' => $this->listSqlWith($match_axes . " AGAINST('+(LOGO LOGOS LOGO)' IN BOOLEAN MODE) and (type_doc in ('100','101','102','103','104','105','109','110','111','112','113','115','116','117','119','Arkhenum','ArteCampus','Artips','Assimil','Bacon','Cvs','DiMusic','Kidilangues','LaSourisQuiRaconte','Lekiosk','LesYeuxDoc','MaPetiteMediatheque','Mobidys','Musicme','Numilog','Omeka','Skilleos','StoryPlayR','ToutApprendre','Whisperies'))", - "(MATCH(titres) AGAINST(' LOGO') * 1.5) + (MATCH(auteurs) AGAINST(' LOGO')) desc")], + "MATCH(auteurs) AGAINST('P_LOGO') desc, MATCH(titres) AGAINST('P_LOGO') desc, MATCH(titres) AGAINST('LOGO') desc, MATCH(auteurs) AGAINST('LOGO') desc, date_creation desc")], [['expressionRecherche' => '', 'id_panier' => 4], @@ -357,11 +392,10 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { 'req_liste' => $this->listSqlWith("notices.clef_alpha in('BATMAN', 'STARWARS', 'INDIANAJONES', 'SPIDERMAN')", "FIELD(notices.clef_alpha, 'BATMAN', 'STARWARS', 'INDIANAJONES', 'SPIDERMAN')")], - [['expressionRecherche' => '', 'tri' => 'alpha_auteur', 'id_panier' => 4], - 'nb_mots'=> 0, + 'nb_mots'=> 0, 'req_liste' => $this->listSqlWith("notices.clef_alpha in('BATMAN', 'STARWARS', 'INDIANAJONES', 'SPIDERMAN')", "alpha_auteur")], @@ -374,7 +408,8 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { [['expressionRecherche' => 'coeur cabossés', 'tri' => 'alpha_titre'], 'nb_mots' => 2, - 'req_liste' => $this->listSqlWith("MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(COEUR COEURS KER) +(CABOSSE CABOSSES KABOS)' IN BOOLEAN MODE)",'alpha_titre') + 'req_liste' => $this->listSqlWith("MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(COEUR COEURS KER) +(CABOSSE CABOSSES KABOS)' IN BOOLEAN MODE)", + 'alpha_titre') ], [['expressionRecherche' => 'cÅ“ur cabossés', @@ -386,21 +421,24 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { [['expressionRecherche' => 'oh læticia', 'tri' => 'alpha_titre'], 'nb_mots' => 1, - 'req_liste' => $this->listSqlWith("MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(LAETICIA LAETICIAS LETISIA)' IN BOOLEAN MODE)",'alpha_titre') + 'req_liste' => $this->listSqlWith("MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(LAETICIA LAETICIAS LETISIA)' IN BOOLEAN MODE)", + 'alpha_titre') ], [['expressionRecherche' => 'Dvořák AntonÃn Malø', 'tri' => 'alpha_titre'], 'nb_mots' => 3, - 'req_liste' => $this->listSqlWith("MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(DVORAK DVORAKS DVORAK) +(ANTONIN ANTONINS ANTONIN) +(MALO MALOS MALO)' IN BOOLEAN MODE)",'alpha_titre') + 'req_liste' => $this->listSqlWith("MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(DVORAK DVORAKS DVORAK) +(ANTONIN ANTONINS ANTONIN) +(MALO MALOS MALO)' IN BOOLEAN MODE)", + 'alpha_titre') ], [['expressionRecherche' => 'Dvorak Antonin Malo', 'tri' => 'alpha_titre', 'limit' => 10], 'nb_mots' => 3, - 'req_liste' => $this->listSqlWith("MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(DVORAK DVORAKS DVORAK) +(ANTONIN ANTONINS ANTONIN) +(MALO MALOS MALO)' IN BOOLEAN MODE)",'alpha_titre limit 10') - ] + 'req_liste' => $this->listSqlWith("MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(DVORAK DVORAKS DVORAK) +(ANTONIN ANTONINS ANTONIN) +(MALO MALOS MALO)' IN BOOLEAN MODE)", + 'alpha_titre limit 10') + ], ]; } @@ -448,7 +486,7 @@ class MoteurRechercheSimpleWithOtherIndexFieldsTest extends MoteurRechercheSimpl [['expressionRecherche' => 'Bakounine'], 'nb_mots' => 1, 'req_liste' => $this->listSqlWith($match_axes ." AGAINST('+(BAKOUNINE BAKOUNINES BAKOUNIN)' IN BOOLEAN MODE)", - "(MATCH(titres) AGAINST(' BAKOUNINE') * 1.5) + (MATCH(auteurs) AGAINST(' BAKOUNINE')) desc")], + "MATCH(auteurs) AGAINST('P_BAKOUNINE') desc, MATCH(titres) AGAINST('P_BAKOUNINE') desc, MATCH(titres) AGAINST('BAKOUNINE') desc, MATCH(auteurs) AGAINST('BAKOUNINE') desc, date_creation desc")], ]; } } @@ -907,7 +945,7 @@ class MoteurRecherchePhonetixCollisionTest extends MoteurRechercheTestCase { $this->mock_sql ->whenCalled('fetchAll') ->with($this->listSqlWith("MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(JEAN JEANS) +(GENET GENETS) +(PARCOUR PARCOURS PARKOUR)' IN BOOLEAN MODE)", - "(MATCH(titres) AGAINST(' JEAN GENET PARCOURS') * 1.5) + (MATCH(auteurs) AGAINST(' JEAN GENET PARCOURS')) desc"), + "MATCH(titres, auteurs) AGAINST('\\\"JEAN GENET PARCOURS\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"JEAN GENET PARCOURS\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_JEAN P_GENET P_PARCOURS') desc, MATCH(titres) AGAINST('P_JEAN P_GENET P_PARCOURS') desc, MATCH(titres) AGAINST('JEAN GENET PARCOURS') desc, MATCH(auteurs) AGAINST('JEAN GENET PARCOURS') desc, date_creation desc"), true, false) ->answers( [ @@ -1127,7 +1165,15 @@ class MoteurRechercheExtendingTest extends MoteurRechercheTestCase { ->answers(0) ->whenCalled('execute') - ->answers(true); + ->answers(true) + + ->whenCalled('fetchAll') + ->with($this->listSqlWith("MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(VIE VIES) +(GEEK GEEKS JEK)' IN BOOLEAN MODE)", + "MATCH(titres, auteurs) AGAINST('\\\"LA VIE DES GEEKS\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"LA VIE DES GEEKS\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_VIE P_GEEKS') desc, MATCH(titres) AGAINST('P_VIE P_GEEKS') desc, MATCH(titres) AGAINST('VIE GEEKS') desc, MATCH(auteurs) AGAINST('VIE GEEKS') desc, date_creation desc"), + true, + false) + ->answers([]) + ->beStrict(); $this->_engine = new Class_MoteurRecherche(); } @@ -1137,25 +1183,15 @@ class MoteurRechercheExtendingTest extends MoteurRechercheTestCase { public function withoutResultShouldExtend() { $this->mock_sql ->whenCalled('fetchAll') - ->with($this->listSqlWith("MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(VIE VIES) +(GEEK GEEKS JEK)' IN BOOLEAN MODE)", - "(MATCH(titres) AGAINST(' VIE GEEKS') * 1.5) + (MATCH(auteurs) AGAINST(' VIE GEEKS')) desc"), - true, - false) - ->answers([]) - - ->whenCalled('fetchAll') - ->with($this->listSqlWith("MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST(' (VIE VIES) (GEEK GEEKS JEK)')", - "(MATCH(titres) AGAINST(' VIE GEEKS') * 1.5) + (MATCH(auteurs) AGAINST(' VIE GEEKS')) desc"), + ->with($this->listSqlWith("MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('(VIE VIES) (GEEK GEEKS JEK)')", + "MATCH(titres, auteurs) AGAINST('\\\"LA VIE DES GEEKS\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"LA VIE DES GEEKS\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_VIE P_GEEKS') desc, MATCH(titres) AGAINST('P_VIE P_GEEKS') desc, MATCH(titres) AGAINST('VIE GEEKS') desc, MATCH(auteurs) AGAINST('VIE GEEKS') desc, date_creation desc"), true, false) ->answers([ [ 1, '' ] - ]) - - ->beStrict(); - + ]); $result = $this->_engine ->lancerRecherche((new Class_CriteresRecherche()) @@ -1166,16 +1202,25 @@ class MoteurRechercheExtendingTest extends MoteurRechercheTestCase { /** @test */ - public function withoutResultWithNoExtensionParamShouldNotExtend() { + public function exactsearchWithoutResultShouldNotExtend() { $this->mock_sql ->whenCalled('fetchAll') - ->with($this->listSqlWith("MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(VIE VIES) +(GEEK GEEKS JEK)' IN BOOLEAN MODE)", - "(MATCH(titres) AGAINST(' VIE GEEKS') * 1.5) + (MATCH(auteurs) AGAINST(' VIE GEEKS')) desc"), + ->with($this->listSqlWith("MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+\\\"LA VIE DES GEEKS\\\"' IN BOOLEAN MODE)", + "MATCH(auteurs) AGAINST('P_LA P_VIE P_DES P_GEEKS') desc, MATCH(titres) AGAINST('P_LA P_VIE P_DES P_GEEKS') desc, MATCH(titres) AGAINST('LA VIE DES GEEKS') desc, MATCH(auteurs) AGAINST('LA VIE DES GEEKS') desc, date_creation desc"), true, false) - ->answers([]) - ->beStrict(); + ->answers([]); + + $result = $this->_engine + ->lancerRecherche((new Class_CriteresRecherche()) + ->setParams(['expressionRecherche' => '"La vie des geeks"'])); + + $this->assertEquals(0, $result->getRecordsCount()); + } + + /** @test */ + public function withoutResultWithNoExtensionParamShouldNotExtend() { $criteria = (new Class_CriteresRecherche()) ->setParams(['expressionRecherche' => 'La vie des geeks', 'no_extension' => '1']); diff --git a/tests/library/Class/Notice/DublinCoreVisitorTest.php b/tests/library/Class/Notice/DublinCoreVisitorTest.php index 01ecad5d080d7963515d6e11ee07e6d71ab34d7d..2a78e06b8d21ab4a9e33de1ab927923a0a806e31 100644 --- a/tests/library/Class/Notice/DublinCoreVisitorTest.php +++ b/tests/library/Class/Notice/DublinCoreVisitorTest.php @@ -30,11 +30,12 @@ abstract class DublinCoreVisitorTestCase extends ModelTestCase { Class_CosmoVar::newInstanceWithId('nature_docs', ['liste' => "1:Collection\r\n20:Manuscrit"]); - } } + + class DublinCoreVisitorPotterTest extends DublinCoreVisitorTestCase { protected $_summary; @@ -44,29 +45,36 @@ class DublinCoreVisitorPotterTest extends DublinCoreVisitorTestCase { Class_CosmoVar::setValueOf('unimarc_zone_matiere', '610$a'); + $unimarc = (new Class_NoticeUnimarc_Fluent) + ->zoneWithChildren('200', ['a' => 'Harry Potter a l\'ecole des sorciers', + 'e' => 'Potter est un coquin', + 'f' => 'Joanne K. Rowling', + 'h' => 'T.4'], + '1 ') + ->zoneWithChildren('200', ['b' => 'Manuscrit']) + ->zoneWithChildren('200', ['b' => 'Collection']) + ->zoneWithChildren('200', ['b' => 'Parchemin']) + ->zoneWithChildren('210', ['a' => 'Londres', 'c' => 'Bloomsbury Publishing']) + ->zoneWithChildren('215', ['a' => '636 p.', 'd' => '22 cm'], ' 1') + ->zoneWithChildren('610', ['a' => 'Potions'], ' 1') + ->zoneWithChildren('610', ['a' => 'Etude des runes'], ' 1') + ->zoneWithChildren('700', ['a' => 'Rowling', 'b' => 'Joanne Kathleen'], ' 1') + ->zoneWithChildren('700', ['a' => 'Rowling', 'b' => 'Bebop a lula'], ' 1') + ->zoneWithChildren('702', ['a' => 'Couton', 'b' => 'Patrick'], ' 1') + ->zoneWithChildren('801', ['b' => 'Castagnera']) + ->zoneWithChildren('852', ['k' => 'LV/R ROW']) + ; + $potter = Class_Notice::newInstanceWithId(4) ->setClefAlpha('harrypotter-sorciers') ->setDateMaj('2012-04-23') ->setAnnee('2012') ->setResume($this->_summary) - ->setLangueCodes(array('fr', 'eng')) + ->setLangueCodes(['fr', 'eng']) ->setIsbn('978-2-07-054127-0') ->setEan('') ->setTypeDoc(1) - ->setNoticeUnimarc(DublinCoreNoticeUnimarcTesting::newInstance() - ->subfieldWillReturn(['215'], [' 1a636 p.d22 cm']) - ->subfieldWillReturn(['200'], ['1 aHarry Potter a l\'ecole des sorciersePotter est un coquinfJoanne K. RowlinghT.4']) - ->subfieldWillReturn(['700'], [' 1aRowlingbJoanne Kathleen', - ' 1aRowlingbBebop a lula']) - ->subfieldWillReturn(['702'], [' 1aCoutonbPatrick']) - ->subfieldWillReturn(['210', 'c'], ['Bloomsbury Publishing']) - ->subfieldWillReturn(['210', 'a'], ['Londres']) - ->subfieldWillReturn(['200', 'b'], ['Manuscrit', - 'Collection', - 'Parchemin']) - ->subfieldWillReturn(['610'], [' 1aPotionsaEtude des runes']) - ->subfieldWillReturn(['801', 'b'], ['Castagnera']) - ->subfieldWillReturn(['852', 'k'], ['LV/R ROW'])); + ->setUnimarc($unimarc->render()); $this->_dublin_core_visitor->visit($potter); } @@ -244,7 +252,6 @@ class DublinCoreVisitorPotterTest extends DublinCoreVisitorTestCase { } - /** @test */ public function shouldHaveTypeParchemin() { $this->_xpath->assertXPathContentContains($this->_dublin_core_visitor->xml(), @@ -253,18 +260,16 @@ class DublinCoreVisitorPotterTest extends DublinCoreVisitorTestCase { } - /** @test */ public function shouldHaveTypeCollection() { $this->_xpath->assertXPathContentContains($this->_dublin_core_visitor->xml(), '//oai_dc:dc/dc:type[@xml:lang="eng"]', 'Collection'); } +} -} - class DublinCoreVisitorSouvignyTest extends DublinCoreVisitorTestCase { public function setUp() { @@ -275,26 +280,19 @@ class DublinCoreVisitorSouvignyTest extends DublinCoreVisitorTestCase { ->setDateMaj('2012-04-23') ->setUrlVignette('http://server.fr/vignette.png') ->setIsbn('') - ->setExemplaires([$exemplaire = Class_Exemplaire::newInstanceWithId(22, ['id_origine' => 33])]) + ->setExemplaires([$this->fixture(Class_Exemplaire::class, + ['id' => 22, + 'id_origine' => 33])]) ->setEan('4719-5120-0288-9') ->setUrlImage('http://server.fr/vignette.png') ->beLivreNumerique(); - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Exemplaire') - ->whenCalled('findFirstBy') - ->with(['id_notice' => 5]) - ->answers($exemplaire); - - - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_TypeDoc') - ->whenCalled('find') - ->with(Class_TypeDoc::LIVRE_NUM) - ->answers(Class_TypeDoc::newInstanceWithId(Class_TypeDoc::LIVRE_NUM) - ->setLabel('livre numerise')); - - Class_Album::newInstanceWithId(33, ['droits' => 'domaine public', - 'description' => '']); + $this->fixture(Class_Album::class, + ['id' => 33, + 'titre' => 'c\'est un peu con', + 'droits' => 'domaine public', + 'description' => '']); $oldServerName = $_SERVER['SERVER_NAME']; $_SERVER['SERVER_NAME'] = 'moulins.fr'; @@ -344,7 +342,7 @@ class DublinCoreVisitorSouvignyTest extends DublinCoreVisitorTestCase { public function shouldHaveTypeLivreNumerise() { $this->_xpath->assertXPathContentContains($this->_dublin_core_visitor->xml(), '//oai_dc:dc/dc:type', - 'livre numerise'); + 'Livres numérisés'); } @@ -371,31 +369,3 @@ class DublinCoreVisitorSouvignyTest extends DublinCoreVisitorTestCase { 'domaine public'); } } - - -class DublinCoreNoticeUnimarcTesting extends Class_NoticeUnimarc { - protected $_subfields = []; - - public static function newInstance() { - return new self(); - } - - - public function subfieldWillReturn($call_params, $return) { - $this->_subfields[$this->_getKeyForParams($call_params)] = $return; - return $this; - } - - - public function get_subfield() { - if (array_key_exists($key = $this->_getKeyForParams(func_get_args()), $this->_subfields)) - return $this->_subfields[$key]; - return call_user_func_array(['parent', 'get_subfield'], func_get_args()); - } - - - private function _getKeyForParams($params) { - return md5(serialize($params)); - } -} -?> \ No newline at end of file diff --git a/tests/library/Class/Notice/IndexationTest.php b/tests/library/Class/Notice/IndexationTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d0884daf8df3c9fc69afbbdf2594019e27c25def --- /dev/null +++ b/tests/library/Class/Notice/IndexationTest.php @@ -0,0 +1,139 @@ +<?php +/** + * Copyright (c) 2012-2022, 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 IndexationTest extends ModelTestCase { + + public function setUp() { + parent::setUp(); + Class_CosmoVar::setValueOf('unimarc_zone_titre', '200$a;200$e;200$d;200$i;215$a;225$a;225$i;327$a;464$t;200$c;200$h;304$a;412$t;413$t;421$t;422$t;423$t;424$t;425$t;430$t;431$t;432$t;433$t;434$t;435$t;436$t;437$t;440$t;441$t;442$t;443$t;444$t;445$t;446$t;447$t;448$t;451$t;452$t;453$t;454$t;455$t;456$t;461$t;463$t;470$t;481$t;482$t;488$t;500ahi;503$a;510aehi;512aehi;513aehi;514aehi;515aehi;516aehi;517aehi;518aehi;520aehi;530$a;531$a;532$a;540aehi;541aehi;545aehi'); + + Class_CosmoVar::setValueOf('other_index_fields', '200$a;200$f'); + + $this->fixture(Class_Notice::class, + ['id' => 1, + 'type_doc' => 1, + 'alpha_titre' => 'PARTIES AND DEMOCRACY', + 'alpha_auteur' => 'HOFFERBERT RICHARD I', + 'titres' => 'PARTIES AND DEMOCRACY PARTY STRUCTURE AND PARTY PERFORMANCE IN OLD AND NEW DEMOCRACIES 1 VOL VI 254 P PARTI DEMOKRASI STRUKTUR PERFORMANS', + 'auteurs' => 'HOFFERBERT RICHARD I HOFFERBERT OFERBER RICHAR', + 'editeur' => 'BLACKWELL BLAKWEL PUBLISHERS PUBLICHER', + 'collection' => '', + 'matieres' => 'DEMOCRATIE DEMOKRASI PARTIS PARTI POLITIQUES POLITIK SCIENCE SIANS ETUDES ETUD COMPARATIVES KONPARATIV', + 'dewey' => 'PARTIS PARTI POLITIQUES POLITIK', + 'facettes' => 'D3242 A36436 M6982 M12946 M10357 Leng T1 B1 E2 YIEPG HNRNR0001', + 'cote' => 'AO 64949', + 'isbn' => '0-631-20930-1', + 'ean' => null, + 'clef_alpha' => 'PARTIESANDDEMOCRACY-PARTYSTRUCTUREANDPAR-HOFFERBERTR--BLACKWELLPUBLISHERS-1998-1', + 'clef_oeuvre' => 'PARTIESANDDEMOCRACY-PARTYSTRUCTUREANDPAR-HOFFERBERTR-', + 'clef_chapeau' => '', + 'tome_alpha' => '', + 'annee' => '1998', + 'qualite' => 5, + 'unimarc' => file_get_contents(ROOT_PATH . '/tests/fixtures/unimarc_parties_democracy.txt'), + 'other_terms' => 'EDITED BY RICHARD HOFFERBERT BLACKWELL PUBLISHERS 631 20930 1 EDIT RICHAR OFERBER BLAKWEL PUBLICHER', + 'type' => 1]); + + $this->fixture(Class_Notice::class, + ['id' => 2, + 'type_doc' => 1, + 'alpha_titre' => 'JUSTICE ET LAICITE 14', + 'alpha_auteur' => 'CENTRE D ETUDES ET DE RECHERCHE EN SCIENCES DE L E', + 'titres' => 'P_JUSTICE P_ET P_LAICITE JUSTICE ET LAICITE 1 VOL 127 P LE TELEMAQUE DIJON TELEMAQUE DIJON 14 JUSTIS LAISIT TELEMAK', + 'auteurs' => 'P_CENTRE P_D P_ETUDES P_ET P_DE P_RECHERCHE P_EN P_SCIENCES P_DE P_L P_EDUCATION CENTRE D ETUDES ET DE RECHERCHE EN SCIENCES DE L EDUCATION VERGNIOUX ALAIN VERGNIOUX SANTR ETUD RECHERCH SIANS EDUKASION VERNIOU ALIN', + 'editeur' => 'PRESSES UNIVERSITAIRES DE CAEN PRES UNIVERSITAIR KAN', + 'collection' => '', + 'matieres' => 'JUSTICE EQUITE FRANCE HISTOIRE LAICITE FRANCE HISTOIRE JUSTIS EKIT FRANS ISTOIR LAISIT', + 'dewey' => '', + 'facettes' => 'A42951 A49736 M1279 M205215 M30317 Lfre T1 B1 E2 YIEPG HNRNR0001', + 'cote' => 'AO 65938', + 'isbn' => '2-8413-3069-9', + 'ean' => '', + 'clef_alpha' => 'JUSTICEETLAICITE--CENTREDETUDESETDERECHERCHEENSCIENCESDELEDUCATION-14-PRESSESUNIVERSITAIRESDECAEN-1998-1', + 'clef_oeuvre' => 'JUSTICEETLAICITE--CENTREDETUDESETDERECHERCHEENSCIENCESDELEDUCATION-14', + 'clef_chapeau' => 'TELEMAQUE DIJON', + 'tome_alpha' => '14', + 'annee' => '1998', + 'qualite' => 5, + 'unimarc' => file_get_contents(ROOT_PATH . '/tests/fixtures/unimarc_justice_laicite.txt'), + 'other_terms' => 'UNIVERSITE DE CAEN SCIENCES DE L EDUCATION REDACTEUR EN CHEF ALAIN VERGNIOUX PRESSES UNIVERSITAIRES DE CAEN 2 8413 3069 9 UNIVERSIT KAN SIANS EDUKASION REDAKTER CH ALIN VERNIOU PRES UNIVERSITAIR', + 'type' => 1 + ]); + + $this->fixture(Class_Notice::class, + ['id' => 3, + 'unimarc' => file_get_contents(ROOT_PATH . 'tests/fixtures/unimarc_droit_administratif.txt')]); + + array_map(fn($n) => (new Class_Notice_Indexation($n))->indexAndSave(), + Class_Notice::findAll()); + } + + + /** @test */ + public function titresForRecordIdOneShouldBeIndexedWithMainWords() { + $this->assertEquals('P_PARTIES P_AND P_DEMOCRACY PARTIES AND DEMOCRACY PARTY STRUCTURE AND PARTY PERFORMANCE IN OLD AND NEW DEMOCRACIES 1 VOL VI 254 P PARTI DEMOKRASI STRUKTUR PERFORMANS', Class_Notice::find(1)->getTitres()); + } + + + /** @test */ + public function auteursForRecordOneShouldBeIndexedWithMainWords() { + $this->assertEquals('P_HOFFERBERT P_RICHARD P_I HOFFERBERT RICHARD I HOFFERBERT OFERBER RICHAR', Class_Notice::find(1)->getAuteurs()); + } + + + /** @test */ + public function editeurForRecordOneShouldBeBLACKWELL_PUBLISHERS_BLAKWEL_PUBLICHER() { + $this->assertEquals('BLACKWELL PUBLISHERS BLAKWEL PUBLICHER', + Class_Notice::find(1)->getEditeur()); + } + + + /** @test */ + public function otherTermsForRecordOneShouldBe_EDITED_BY_RICHARD_HOFFERBERT() { + $this->assertEquals('EDITED BY RICHARD HOFFERBERT EDIT RICHAR OFERBER', + Class_Notice::find(1)->getOtherTerms()); + } + + + /** @test */ + public function titresForRecordId2ShouldContainsClefChapeau_TomeAlpha() { + $this->assertEquals('P_JUSTICE P_ET P_LAICITE JUSTICE ET LAICITE 1 VOL 127 P LE TELEMAQUE DIJON 14 JUSTIS LAISIT TELEMAK', Class_Notice::find(2)->getTitres()); + } + + + /** @test */ + public function auteursForRecordId2ShouldBeIndexedWithoutMainWordsAsNoMainAuthor() { + $this->assertEquals('CENTRE D ETUDES ET DE RECHERCHE EN SCIENCES DE L EDUCATION VERGNIOUX ALAIN VERGNIOUX SANTR ETUD RECHERCH SIANS EDUKASION VERNIOU ALIN', Class_Notice::find(2)->getAuteurs()); + } + + + /** @test */ + public function thirdRecordTitlesShouldBe() { + $this->assertEquals('P_INTRODUCTION P_HISTORIQUE P_AU P_DROIT P_ADMINISTRATIF P_DEPUIS P_1789 INTRODUCTION HISTORIQUE AU DROIT ADMINISTRATIF DEPUIS 1789 1 VOL 390 P DROIT FONDAMENTAL INTRODUKSION ISTORIK DROI DEPUI FONDAMANTAL', Class_Notice::find(3)->getTitres()); + } + + + /** @test */ + public function thirdRecordCollectionShouldBeDroitFondamental() { + $this->assertEquals('DROIT FONDAMENTAL DROI FONDAMANTAL', Class_Notice::find(3)->getCollection()); + } +} diff --git a/tests/scenarios/AuthorPage/AuthorPageTest.php b/tests/scenarios/AuthorPage/AuthorPageTest.php index 9bf33525013f09072cfdeaa9b6564b1546890cab..ab4b526755b3114cb8315466ccf65ec4d71668e2 100644 --- a/tests/scenarios/AuthorPage/AuthorPageTest.php +++ b/tests/scenarios/AuthorPage/AuthorPageTest.php @@ -21,9 +21,8 @@ abstract class AuthorPageTestCase extends AbstractControllerTestCase { - protected - $_storm_default_to_volatile = true, - $_http_client; + + protected $_http_client; public function setUp() { parent::setUp(); @@ -66,23 +65,23 @@ abstract class AuthorPageTestCase extends AbstractControllerTestCase { 'url_vignette' => 'paris.jpg']); - $this->fixture('Class_CodifAuteur', + $this->fixture(Class_CodifAuteur::class, ['id' => 2408, 'libelle' => 'Victor Hugo']); - $this->fixture('Class_CodifAuteur', + $this->fixture(Class_CodifAuteur::class, ['id' => 3, 'libelle' => 'Robert Hossein']); - $this->fixture('Class_CodifAuteur', + $this->fixture(Class_CodifAuteur::class, ['id' => 4, 'libelle' => 'Marcus %s \Mill']); - $this->fixture('Class_CodifGenre', + $this->fixture(Class_CodifGenre::class, ['id' => 4, 'libelle' => 'Romans']); - $this->fixture('Class_CodifMatiere', + $this->fixture(Class_CodifMatiere::class, ['id' => 6, 'libelle' => '19e siècle']); @@ -130,8 +129,10 @@ abstract class AuthorPageTestCase extends AbstractControllerTestCase { class AuthorPageViewAuthorWithDisabledBiography extends AuthorPageTestCase { + public function setUp() { parent::setUp(); + $this->_http_client ->whenCalled('open_url') ->with('http://cache.org?auteur=Victor+Hugo&clef_oeuvre=GAVROCHE--HUGOV-5&language=fr' @@ -172,8 +173,10 @@ class AuthorPageViewAuthorWithDisabledBiography extends AuthorPageTestCase { class AuthorPageViewAuthorWithoutBiography extends AuthorPageTestCase { + public function setUp() { parent::setUp(); + $this->_http_client ->whenCalled('open_url') ->with('http://cache.org?auteur=Victor+Hugo&clef_oeuvre=GAVROCHE--HUGOV-5&language=fr' @@ -207,8 +210,10 @@ class AuthorPageViewAuthorWithoutBiography extends AuthorPageTestCase { class AuthorPageViewAuthorWithoutRecord extends AuthorPageTestCase { + public function setUp() { parent::setUp(); + $this->mock_sql->whenCalled('fetchAll') ->with("select id_notice, facettes from notices Where (MATCH(facettes) AGAINST('+A2408' IN BOOLEAN MODE)) and type=1", true, false) ->answers([]); @@ -233,9 +238,10 @@ class AuthorPageViewAuthorWithoutRecord extends AuthorPageTestCase { class AuthorPageViewAuthorWithoutRecordTest extends AuthorPageTestCase { + /** @test */ public function pageShouldHaveH1WithSuperCanard() { - $this->fixture('Class_CodifAuteur', + $this->fixture(Class_CodifAuteur::class, ['id' => 666, 'libelle' => 'Super canard']); @@ -252,8 +258,10 @@ class AuthorPageViewAuthorWithoutRecordTest extends AuthorPageTestCase { class AuthorPageViewByIdWithInspectorGadgetTest extends AuthorPageTestCase { + public function setUp() { parent::setUp(); + $this->dispatch('/author/view/id/2408/inspector_gadget/1'); } @@ -287,8 +295,10 @@ class AuthorPageViewByIdWithInspectorGadgetTest extends AuthorPageTestCase { class AuthorPageViewByIdTest extends AuthorPageTestCase { + public function setUp() { parent::setUp(); + Class_AdminVar_Cookies::setManager(new Class_Cookies_TarteAuCitron()); $this->dispatch('/author/view/id/2408'); } @@ -305,6 +315,7 @@ class AuthorPageViewByIdTest extends AuthorPageTestCase { $this->assertEquals('UC1l7wYrva1qCH-wgqcHaaRg', Class_CodifAuteur::find(2408)->getYoutubeChannelId()); } + /** @test */ public function authorISNIShouldBe0000000078391751() { $this->assertEquals('0000 0000 7839 1751', Class_CodifAuteur::find(2408)->getIsni()); @@ -478,6 +489,7 @@ class AuthorPageViewByIdTest extends AuthorPageTestCase { class AuthorPageViewByIdWithNoImageTest extends AuthorPageTestCase { + public function setUp() { parent::setUp(); @@ -518,6 +530,7 @@ class AuthorPageViewByIdWithNoImageTest extends AuthorPageTestCase { class AuthorPagePhoneTest extends AuthorPageTestCase { + public function setUp() { parent::setUp(); @@ -552,6 +565,7 @@ class AuthorPagePhoneTest extends AuthorPageTestCase { class AuthorPageViewByNameTest extends AuthorPageTestCase { + /** @test */ public function searchVictorHugoShouldShowVictorHugo() { $this->onLoaderOfModel('Class_CodifAuteur') @@ -585,6 +599,7 @@ class AuthorPageViewByNameTest extends AuthorPageTestCase { class AuthorPageViewRecordDetailTest extends AuthorPageTestCase { + public function setUp() { parent::setUp(); @@ -611,8 +626,10 @@ class AuthorPageViewRecordDetailTest extends AuthorPageTestCase { class AuthorPageViewRecordWithAuthorTest extends AuthorPageTestCase { + public function setUp() { parent::setUp(); + $this->mock_sql->whenCalled('fetchOne') ->answers(true) ->whenCalled('fetchAll') @@ -637,6 +654,7 @@ class AuthorPageViewRecordWithAuthorTest extends AuthorPageTestCase { class AuthorPageViewRecordWithoutAuthorTest extends AuthorPageTestCase { + public function setUp() { parent::setUp(); @@ -666,8 +684,10 @@ class AuthorPageViewRecordWithoutAuthorTest extends AuthorPageTestCase { class AuteurPageNoticeAjaxRenderYoutubeChannelTest extends AuthorPageTestCase { + public function setUp() { parent::setUp(); + Class_CodifAuteur::find(2408) ->setYoutubeChannelId('UC1l7wYrva1qCH-wgqcHaaRg') ->assertSave(); @@ -714,9 +734,12 @@ class AuteurPageNoticeAjaxRenderYoutubeChannelTest extends AuthorPageTestCase { -class AuteurPageNoticeAjaxRenderYoutubeChannelTarteAuCitronTest extends AuthorPageTestCase { +class AuteurPageNoticeAjaxRenderYoutubeChannelTarteAuCitronTest + extends AuthorPageTestCase { + public function setUp() { parent::setUp(); + Class_AdminVar_Cookies::setManager(new Class_Cookies_TarteAuCitron()); Class_CodifAuteur::find(2408) diff --git a/tests/scenarios/Authorities/AuthoritiesTest.php b/tests/scenarios/Authorities/AuthoritiesTest.php index 50c2e13e97b07ed26241b140037876acef422c99..80184903dbd17ec5e27782af15ebd1d3b7cd6fe8 100644 --- a/tests/scenarios/Authorities/AuthoritiesTest.php +++ b/tests/scenarios/Authorities/AuthoritiesTest.php @@ -214,7 +214,7 @@ class AuthoritiesAuthoritySearchControllerWithExpressionLocalAndAResultTest Zend_Registry::set('sql', $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(LOCAL LOCAUX LOKAL)' IN BOOLEAN MODE)) and type=2 order by (MATCH(titres) AGAINST(' LOCAL') * 1.5) + (MATCH(auteurs) AGAINST(' LOCAL')) desc", true, false) + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(LOCAL LOCAUX LOKAL)' IN BOOLEAN MODE)) and type=2 order by MATCH(auteurs) AGAINST('P_LOCAL') desc, MATCH(titres) AGAINST('P_LOCAL') desc, MATCH(titres) AGAINST('LOCAL') desc, MATCH(auteurs) AGAINST('LOCAL') desc, date_creation desc", true, false) ->answers([[1, '']])); $this->dispatch('/opac/authority-search/index/expressionRecherche/local'); @@ -265,7 +265,7 @@ class AuthoritiesAuthoritySearchControllerWithExpressionLocalLimitedToFacetHMOTS Zend_Registry::set('sql', $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(LOCAL LOCAUX LOKAL)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+HMOTS' IN BOOLEAN MODE)) and type=2 order by (MATCH(titres) AGAINST(' LOCAL') * 1.5) + (MATCH(auteurs) AGAINST(' LOCAL')) desc", true, false) + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(LOCAL LOCAUX LOKAL)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+HMOTS' IN BOOLEAN MODE)) and type=2 order by MATCH(auteurs) AGAINST('P_LOCAL') desc, MATCH(titres) AGAINST('P_LOCAL') desc, MATCH(titres) AGAINST('LOCAL') desc, MATCH(auteurs) AGAINST('LOCAL') desc, date_creation desc", true, false) ->answers([[1, '']])); $this->dispatch('/authority-search/index/facettes/HMOTS/expressionRecherche/local'); diff --git a/tests/scenarios/SearchByWork/SearchResultByWorkTest.php b/tests/scenarios/SearchByWork/SearchResultByWorkTest.php index bc52ff2d0b9083e62e2b84b2676500eae6527b7c..523f5371d01cec6337eda54f9fe0b8544ba8ea44 100644 --- a/tests/scenarios/SearchByWork/SearchResultByWorkTest.php +++ b/tests/scenarios/SearchByWork/SearchResultByWorkTest.php @@ -114,7 +114,7 @@ class SearchResultByWorkWithoutTemplatingTest extends SearchResultByWorkTestCase Zend_Registry::set('sql', $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(LAPIN LAPINS LAPIN)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' LAPIN') * 1.5) + (MATCH(auteurs) AGAINST(' LAPIN')) desc", + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(LAPIN LAPINS LAPIN)' IN BOOLEAN MODE)) and type=1 order by MATCH(auteurs) AGAINST('P_LAPIN') desc, MATCH(titres) AGAINST('P_LAPIN') desc, MATCH(titres) AGAINST('LAPIN') desc, MATCH(auteurs) AGAINST('LAPIN') desc, date_creation desc", true, false) ->answers([[1, '']])); @@ -145,7 +145,7 @@ class SearchResultByWorkWithTemplatingTest extends SearchResultByWorkTestCase { Zend_Registry::set('sql', $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes, clef_oeuvre from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(LAPIN LAPINS LAPIN)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' LAPIN') * 1.5) + (MATCH(auteurs) AGAINST(' LAPIN')) desc", + ->with("select id_notice, facettes, clef_oeuvre from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(LAPIN LAPINS LAPIN)' IN BOOLEAN MODE)) and type=1 order by MATCH(auteurs) AGAINST('P_LAPIN') desc, MATCH(titres) AGAINST('P_LAPIN') desc, MATCH(titres) AGAINST('LAPIN') desc, MATCH(auteurs) AGAINST('LAPIN') desc, date_creation desc", true, false) ->answers([[1, 'T1', 'ACCROCDUROC-PRATCHETTT'], @@ -223,7 +223,7 @@ abstract class SearchResultByWorkWithTemplatingWorkTestCase extends SearchResult ->answers(1) ->whenCalled('fetchAll') - ->with("select id_notice, facettes, clef_oeuvre from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(LAPIN LAPINS LAPIN)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' LAPIN') * 1.5) + (MATCH(auteurs) AGAINST(' LAPIN')) desc", + ->with("select id_notice, facettes, clef_oeuvre from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(LAPIN LAPINS LAPIN)' IN BOOLEAN MODE)) and type=1 order by MATCH(auteurs) AGAINST('P_LAPIN') desc, MATCH(titres) AGAINST('P_LAPIN') desc, MATCH(titres) AGAINST('LAPIN') desc, MATCH(auteurs) AGAINST('LAPIN') desc, date_creation desc", true, false) ->answers([[1, 'T1', 'ACCROCDUROC-PRATCHETTT'], diff --git a/tests/scenarios/SearchResult/SearchResultTest.php b/tests/scenarios/SearchResult/SearchResultTest.php index 1a8eef473f3c609523c79f88b4eeea6419ee4969..f8cf836be4358d48e6a92858fb4be353b8d17c1d 100644 --- a/tests/scenarios/SearchResult/SearchResultTest.php +++ b/tests/scenarios/SearchResult/SearchResultTest.php @@ -131,13 +131,13 @@ class SearhResultFilterDomainsFromProfilTest extends AbstractControllerTestCase $sql = $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(TROLL TROLLS TROL) +(TROY TROYS TROI)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+(T2) +(HCCCC0001 HCCCC0002)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' TROLLS TROY') * 1.5) + (MATCH(auteurs) AGAINST(' TROLLS TROY')) desc", true, false) - ->answers([ ['1' , 'T1 T2']]) + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(TROLL TROLLS TROL) +(TROY TROYS TROI)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+(T2) +(HCCCC0001 HCCCC0002)' IN BOOLEAN MODE)) and type=1 order by MATCH(titres, auteurs) AGAINST('\\\"TROLLS DE TROY\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"TROLLS DE TROY\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_TROLLS P_TROY') desc, MATCH(titres) AGAINST('P_TROLLS P_TROY') desc, MATCH(titres) AGAINST('TROLLS TROY') desc, MATCH(auteurs) AGAINST('TROLLS TROY') desc, date_creation desc", true, false) + ->answers([ ['1', 'T1 T2']]) ->beStrict(); Zend_Registry::set('sql', $sql); - $this->dispatch('/opac/recherche/trolls+de+troy', true); + $this->dispatch('/opac/recherche/trolls+de+troy'); } @@ -162,12 +162,12 @@ class SearchResultFilterFromProfilTest extends AbstractControllerTestCase { $sql = $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(TROLL TROLLS TROL) +(TROY TROYS TROI)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+(T2)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' TROLLS TROY') * 1.5) + (MATCH(auteurs) AGAINST(' TROLLS TROY')) desc", true, false) + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(TROLL TROLLS TROL) +(TROY TROYS TROI)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+(T2)' IN BOOLEAN MODE)) and type=1 order by MATCH(titres, auteurs) AGAINST('\\\"TROLLS DE TROY\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"TROLLS DE TROY\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_TROLLS P_TROY') desc, MATCH(titres) AGAINST('P_TROLLS P_TROY') desc, MATCH(titres) AGAINST('TROLLS TROY') desc, MATCH(auteurs) AGAINST('TROLLS TROY') desc, date_creation desc", true, false) ->answers([ ['1' , 'T1 T2']]); Zend_Registry::set('sql', $sql); - $this->dispatch('/opac/recherche/trolls+de+troy', true); + $this->dispatch('/opac/recherche/trolls+de+troy'); } diff --git a/tests/scenarios/Security/SearchTest.php b/tests/scenarios/Security/SearchTest.php index 1e516969eaa44932caeadb2bbd176e20124ae6b5..cb015c06a0395dbc667ad5c1f63cd5c77f6da2e1 100644 --- a/tests/scenarios/Security/SearchTest.php +++ b/tests/scenarios/Security/SearchTest.php @@ -133,6 +133,13 @@ class Security_SearchTest extends AbstractControllerTestCase { } + /** @test */ + public function expressionRechercheWithDoubleQuoteShouldNotBeXssable() { + $this->dispatch('/recherche/simple?' . http_build_query(['expressionRecherche' => '1 "<script>_q_q=random()</script>"'])); + $this->assertNotContains('=random()</script>', $this->_response->getBody()); + } + + /** @test */ public function mysqlShouldNotCrashOnInvalidSectionId() { $this->fixture('Class_CodifSection', diff --git a/tests/scenarios/Templates/ChiliTest.php b/tests/scenarios/Templates/ChiliTest.php index f72abc34841459cc577c149d0f3c8c451743e533..929d0dff09cab78aac9a0511b8c171ecd08503e7 100644 --- a/tests/scenarios/Templates/ChiliTest.php +++ b/tests/scenarios/Templates/ChiliTest.php @@ -281,7 +281,7 @@ class ChiliTemplateSearchResultMoreOptionsTest extends ChiliTemplateTestCase { $sql = $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(JARDIN JARDINS JARDIN)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' JARDIN') * 1.5) + (MATCH(auteurs) AGAINST(' JARDIN')) desc", + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(JARDIN JARDINS JARDIN)' IN BOOLEAN MODE)) and type=1 order by MATCH(auteurs) AGAINST('P_JARDIN') desc, MATCH(titres) AGAINST('P_JARDIN') desc, MATCH(titres) AGAINST('JARDIN') desc, MATCH(auteurs) AGAINST('JARDIN') desc, date_creation desc", true, false) ->answers([[89, ''], [99, '']]) @@ -595,7 +595,7 @@ abstract class ChiliSearchResultWithFacetsTestCase extends ChiliTemplateTestCase $sql = $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(POMME POMMES POM)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+T1 +B1' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' POMME') * 1.5) + (MATCH(auteurs) AGAINST(' POMME')) desc", + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(POMME POMMES POM)' IN BOOLEAN MODE) and MATCH(facettes) AGAINST('+T1 +B1' IN BOOLEAN MODE)) and type=1 order by MATCH(auteurs) AGAINST('P_POMME') desc, MATCH(titres) AGAINST('P_POMME') desc, MATCH(titres) AGAINST('POMME') desc, MATCH(auteurs) AGAINST('POMME') desc, date_creation desc", true, false) ->answers([[15, 'T1 B1'], [20, 'T1 B1']]) @@ -1203,7 +1203,7 @@ abstract class ChiliSearchResultPageTestCase extends ChiliTemplateTestCase { ['id' => 20])]; $sql = $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(POMME POMMES POM)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' POMME') * 1.5) + (MATCH(auteurs) AGAINST(' POMME')) desc", + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(POMME POMMES POM)' IN BOOLEAN MODE)) and type=1 order by MATCH(auteurs) AGAINST('P_POMME') desc, MATCH(titres) AGAINST('P_POMME') desc, MATCH(titres) AGAINST('POMME') desc, MATCH(auteurs) AGAINST('POMME') desc, date_creation desc", true, false) ->answers([[15], @@ -1362,7 +1362,7 @@ class ChiliSearchWithSuggestEnabledTest extends AbstractControllerTestCase { $sql = $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(MAUPASSANT MAUPASSANTS MOPASAN)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' MAUPASSANT') * 1.5) + (MATCH(auteurs) AGAINST(' MAUPASSANT')) desc", + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(MAUPASSANT MAUPASSANTS MOPASAN)' IN BOOLEAN MODE)) and type=1 order by MATCH(auteurs) AGAINST('P_MAUPASSANT') desc, MATCH(titres) AGAINST('P_MAUPASSANT') desc, MATCH(titres) AGAINST('MAUPASSANT') desc, MATCH(auteurs) AGAINST('MAUPASSANT') desc, date_creation desc", true, false) ->answers([[89, 'A43'], [99, 'A43']]); diff --git a/tests/scenarios/Templates/MuscleTemplateTest.php b/tests/scenarios/Templates/MuscleTemplateTest.php index a48f84023c189a0120f6affcfe15890dd0fdf597..56ea385d347a3ef55a7042bbb048b1549836d68e 100644 --- a/tests/scenarios/Templates/MuscleTemplateTest.php +++ b/tests/scenarios/Templates/MuscleTemplateTest.php @@ -351,7 +351,7 @@ class MuscleTemplateSearchResultMoreOptionsTest extends MuscleTemplateTestCase { $sql = $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(JARDIN JARDINS JARDIN)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' JARDIN') * 1.5) + (MATCH(auteurs) AGAINST(' JARDIN')) desc", + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(JARDIN JARDINS JARDIN)' IN BOOLEAN MODE)) and type=1 order by MATCH(auteurs) AGAINST('P_JARDIN') desc, MATCH(titres) AGAINST('P_JARDIN') desc, MATCH(titres) AGAINST('JARDIN') desc, MATCH(auteurs) AGAINST('JARDIN') desc, date_creation desc", true, false) ->answers([[89, ''], [99, '']]) @@ -596,4 +596,4 @@ class MuscleTemplateNotLoggedTest extends MuscleTemplateTestCase { public function inputLoginShouldBeHydratedWithOrder3() { $this->assertXPath('//form/input[@id="login"][@class= "zendafi_form_login_login btn btn-sm btn-primary order-3 my-3"]'); } -} \ No newline at end of file +} diff --git a/tests/scenarios/Templates/MyBibAppTemplateTest.php b/tests/scenarios/Templates/MyBibAppTemplateTest.php index 4ff031bd0c828420e0bf46330fd37a324e3ff76a..f75ee8226e81e9f1e4f3ad6b35ad970045609579 100644 --- a/tests/scenarios/Templates/MyBibAppTemplateTest.php +++ b/tests/scenarios/Templates/MyBibAppTemplateTest.php @@ -367,7 +367,7 @@ class MyBibAppTemplateReadedInSerieTest extends MyBibAppTemplateTestCase { $sql = $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(TROLL TROLLS TROL)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' TROLLS') * 1.5) + (MATCH(auteurs) AGAINST(' TROLLS')) desc", + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(TROLL TROLLS TROL)' IN BOOLEAN MODE)) and type=1 order by MATCH(auteurs) AGAINST('P_TROLLS') desc, MATCH(titres) AGAINST('P_TROLLS') desc, MATCH(titres) AGAINST('TROLLS') desc, MATCH(auteurs) AGAINST('TROLLS') desc, date_creation desc", true, false) ->answers([[12, ''], [15, '']]) diff --git a/tests/scenarios/Templates/TemplatesAbonneTest.php b/tests/scenarios/Templates/TemplatesAbonneTest.php index ed7b7f84f1e30dd273eac49e1ced0a8bd32803c5..30490574d77be36a074dca4bc4cdf94959439edf 100644 --- a/tests/scenarios/Templates/TemplatesAbonneTest.php +++ b/tests/scenarios/Templates/TemplatesAbonneTest.php @@ -254,14 +254,17 @@ abstract class TemplatesIntonationAccountTestCase extends TemplatesIntonationTes ->with('select user_id as id from user_group_memberships where user_group_id=' . Class_Newsletter::find(45)->getDedicatedGroup()->getId()) ->answers([['id' => $current_user->getId()]]) + ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(HARRY HARRYS ARI) +(POTTER POTTERS POT)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' HARRY POTTER') * 1.5) + (MATCH(auteurs) AGAINST(' HARRY POTTER')) desc",true,false) + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(HARRY HARRYS ARI) +(POTTER POTTERS POT)' IN BOOLEAN MODE)) and type=1 order by MATCH(titres, auteurs) AGAINST('\\\"HARRY POTTER\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"HARRY POTTER\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_HARRY P_POTTER') desc, MATCH(titres) AGAINST('P_HARRY P_POTTER') desc, MATCH(titres) AGAINST('HARRY POTTER') desc, MATCH(auteurs) AGAINST('HARRY POTTER') desc, date_creation desc",true,false) ->answers([]) + ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST(' (HARRY HARRYS ARI) (POTTER POTTERS POT)')) and type=1 order by (MATCH(titres) AGAINST(' HARRY POTTER') * 1.5) + (MATCH(auteurs) AGAINST(' HARRY POTTER')) desc",true,false) + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('(HARRY HARRYS ARI) (POTTER POTTERS POT)')) and type=1 order by MATCH(titres, auteurs) AGAINST('\\\"HARRY POTTER\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"HARRY POTTER\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_HARRY P_POTTER') desc, MATCH(titres) AGAINST('P_HARRY P_POTTER') desc, MATCH(titres) AGAINST('HARRY POTTER') desc, MATCH(auteurs) AGAINST('HARRY POTTER') desc, date_creation desc",true,false) ->answers([]) + ->whenCalled('fetchAll') ->with("select id_notice, facettes from notices Where type=1 limit 10000", true, false) ->answers([]) diff --git a/tests/scenarios/Templates/TemplatesRecordsTest.php b/tests/scenarios/Templates/TemplatesRecordsTest.php index 3741dad486878d2d6a2804bef6bc9b8a0f5779ea..aa1a35ea62493be95db99f8721667dc100a6cce8 100644 --- a/tests/scenarios/Templates/TemplatesRecordsTest.php +++ b/tests/scenarios/Templates/TemplatesRecordsTest.php @@ -1551,4 +1551,4 @@ class TemplatesRecordsPaginationTest extends AbstractControllerTestCase { $this->assertXPathContentContains('//div[@class="bokeh_jumbotron bokeh_jumbotron_with_both_pagination jumbotron jumbotron-fluid w-100 py-3 mb-3"]//div[@class= "rich_content_row_actions back_to_search_result col col-lg-12 pt-1 mt-1 mr-1 pr-1 w-s_nowrap"]//a[contains(@href, "/recherche/simple/id_catalogue/22#456")]', 'Recherche'); } -} \ No newline at end of file +} diff --git a/tests/scenarios/Templates/TemplatesSearchSettingsTest.php b/tests/scenarios/Templates/TemplatesSearchSettingsTest.php index d3f28d1f4611ff58ea793b1908408361b92f98e2..90b933e9d045d19efc92bcd84dbe1a01baee9be5 100644 --- a/tests/scenarios/Templates/TemplatesSearchSettingsTest.php +++ b/tests/scenarios/Templates/TemplatesSearchSettingsTest.php @@ -49,7 +49,7 @@ class TemplatesSearchSettingsResultWithSearchTermHighLightedTest ->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(ERO EROS) +(ODIAR ODIARS ODIAR)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' ERO ODIAR') * 1.5) + (MATCH(auteurs) AGAINST(' ERO ODIAR')) desc", + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(ERO EROS) +(ODIAR ODIARS ODIAR)' IN BOOLEAN MODE)) and type=1 order by MATCH(titres, auteurs) AGAINST('\\\"ERO ODIAR\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"ERO ODIAR\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_ERO P_ODIAR') desc, MATCH(titres) AGAINST('P_ERO P_ODIAR') desc, MATCH(titres) AGAINST('ERO ODIAR') desc, MATCH(auteurs) AGAINST('ERO ODIAR') desc, date_creation desc", true, false) ->answers([[1, '']]) @@ -179,7 +179,7 @@ abstract class TemplatesSearchSettingsTestCase extends AbstractControllerTestCas $sql = $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(PETIT PETITS PETI) +(CAHIER CAHIERS KAI)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' PETITS CAHIERS') * 1.5) + (MATCH(auteurs) AGAINST(' PETITS CAHIERS')) desc", + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(PETIT PETITS PETI) +(CAHIER CAHIERS KAI)' IN BOOLEAN MODE)) and type=1 order by MATCH(titres, auteurs) AGAINST('\\\"LES PETITS CAHIERS\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"LES PETITS CAHIERS\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_PETITS P_CAHIERS') desc, MATCH(titres) AGAINST('P_PETITS P_CAHIERS') desc, MATCH(titres) AGAINST('PETITS CAHIERS') desc, MATCH(auteurs) AGAINST('PETITS CAHIERS') desc, date_creation desc", true, false) ->answers([[345, '']]) diff --git a/tests/scenarios/Templates/TemplatesSearchTest.php b/tests/scenarios/Templates/TemplatesSearchTest.php index d3ba67f84d35311276b822426112d7c236ee14f6..20ef761e58bb2b3721f85acff81160845ce783a6 100644 --- a/tests/scenarios/Templates/TemplatesSearchTest.php +++ b/tests/scenarios/Templates/TemplatesSearchTest.php @@ -916,7 +916,7 @@ class TemplatesSearchDispatchWithNouveauteNowParamTest extends AbstractControlle $sql = $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(POMME POMMES POM)' IN BOOLEAN MODE) and date_creation >'2021-01-13') and type=1 order by (MATCH(titres) AGAINST(' POMME') * 1.5) + (MATCH(auteurs) AGAINST(' POMME')) desc", + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(POMME POMMES POM)' IN BOOLEAN MODE) and date_creation >'2021-01-13') and type=1 order by MATCH(auteurs) AGAINST('P_POMME') desc, MATCH(titres) AGAINST('P_POMME') desc, MATCH(titres) AGAINST('POMME') desc, MATCH(auteurs) AGAINST('POMME') desc, date_creation desc", true, false) ->answers([[89 ]]) @@ -991,7 +991,7 @@ abstract class TemplatesSearchWithUserSettingsEnabledTestCase extends AbstractCo $sql = $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(FRANCE FRANCES FRANS)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' FRANCE') * 1.5) + (MATCH(auteurs) AGAINST(' FRANCE')) desc", + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(FRANCE FRANCES FRANS)' IN BOOLEAN MODE)) and type=1 order by MATCH(auteurs) AGAINST('P_FRANCE') desc, MATCH(titres) AGAINST('P_FRANCE') desc, MATCH(titres) AGAINST('FRANCE') desc, MATCH(auteurs) AGAINST('FRANCE') desc, date_creation desc", true, false) ->answers([[89, 'B1']]); @@ -1109,7 +1109,6 @@ class TemplatesSearchCollectionWithoutSerie extends AbstractControllerTestCase { class TemplatesSearchDispatchWallModeRenderingInChiliTest extends TemplatesSearchDispatchTest { - public function setUp() { parent::setUp(); $this->dispatch('/opac/recherche/simple/expressionRecherche/pomme/id_profil/5/liste_format/4'); @@ -1165,7 +1164,7 @@ class TemplatesSearchResultWithSearchTermHighLightedTest extends AbstractControl ->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(ERO EROS) +(ODIAR ODIARS ODIAR)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' ERO ODIAR') * 1.5) + (MATCH(auteurs) AGAINST(' ERO ODIAR')) desc", + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(ERO EROS) +(ODIAR ODIARS ODIAR)' IN BOOLEAN MODE)) and type=1 order by MATCH(titres, auteurs) AGAINST('\\\"ERO ODIAR\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"ERO ODIAR\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_ERO P_ODIAR') desc, MATCH(titres) AGAINST('P_ERO P_ODIAR') desc, MATCH(titres) AGAINST('ERO ODIAR') desc, MATCH(auteurs) AGAINST('ERO ODIAR') desc, date_creation desc", true, false) ->answers([[1, '']]) @@ -1282,7 +1281,7 @@ class TemplatesSearchHighlightCollectionTest extends AbstractControllerTestCase $sql = $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(PETIT PETITS PETI) +(CAHIER CAHIERS KAI)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' PETITS CAHIERS') * 1.5) + (MATCH(auteurs) AGAINST(' PETITS CAHIERS')) desc", + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(PETIT PETITS PETI) +(CAHIER CAHIERS KAI)' IN BOOLEAN MODE)) and type=1 order by MATCH(titres, auteurs) AGAINST('\\\"LES PETITS CAHIERS\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"LES PETITS CAHIERS\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_PETITS P_CAHIERS') desc, MATCH(titres) AGAINST('P_PETITS P_CAHIERS') desc, MATCH(titres) AGAINST('PETITS CAHIERS') desc, MATCH(auteurs) AGAINST('PETITS CAHIERS') desc, date_creation desc", true, false) ->answers([[345, '']]) @@ -1375,4 +1374,4 @@ class TemplatesSearchWithDomainIdsSettingsFromIndexPageTest extends Admin_Abstr public function expressionRecherchePlaceHolderShouldBePommePoire() { $this->assertXPath('//input[@name="expressionRecherche"][@placeholder="Pomme, poire"]'); } -} \ No newline at end of file +} diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php index c43379059c09e7aa8f6ec5e49f931ec82b93a914..33a83d71f0a7047e0b5a43b09d380d8e1a239403 100644 --- a/tests/scenarios/Templates/TemplatesTest.php +++ b/tests/scenarios/Templates/TemplatesTest.php @@ -1916,7 +1916,8 @@ class TemplatesDispatchEditAllActionsTest extends TemplatesIntonationTestCase { class TemplatesSearchInSessionTest extends TemplatesIntonationTestCase { public function setUp() { parent::setUp(); - Zend_Registry::get('session')->last_search = ['expressionRecherche' => 'trolls de troy']; + Zend_Registry::get('session')->last_search = ['expressionRecherche' => 'trolls de troy', + 'pertinence' => 1]; } @@ -1927,6 +1928,12 @@ class TemplatesSearchInSessionTest extends TemplatesIntonationTestCase { } + /** @test */ + public function searchFormActionShouldNotContainsPertinence() { + $this->dispatch('/opac/index/index/id_profil/72'); + $this->assertNotXPath('//form[contains(@action, "pertinence")]'); + } + /** @test */ public function searchWidgetShouldNotContainsTrollDeTroy() { diff --git a/tests/scenarios/Templates/TerreDuMilieuTemplateTest.php b/tests/scenarios/Templates/TerreDuMilieuTemplateTest.php index ccca95a320b9fc50c591c3282eb14df21f65a16d..72d020c0189358ebc6d32187c7da1286146da93f 100644 --- a/tests/scenarios/Templates/TerreDuMilieuTemplateTest.php +++ b/tests/scenarios/Templates/TerreDuMilieuTemplateTest.php @@ -408,7 +408,7 @@ class TerreDuMilieuTemplateSearchResultMoreOptionsTest extends TerreDuMilieuTemp $sql = $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(JARDIN JARDINS JARDIN)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' JARDIN') * 1.5) + (MATCH(auteurs) AGAINST(' JARDIN')) desc", + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(JARDIN JARDINS JARDIN)' IN BOOLEAN MODE)) and type=1 order by MATCH(auteurs) AGAINST('P_JARDIN') desc, MATCH(titres) AGAINST('P_JARDIN') desc, MATCH(titres) AGAINST('JARDIN') desc, MATCH(auteurs) AGAINST('JARDIN') desc, date_creation desc", true, false) ->answers([[89, ''], [99, '']]); diff --git a/tests/scenarios/bookmarks/SearchTest.php b/tests/scenarios/bookmarks/SearchTest.php index c29d6857096b27eb3eeb57b812fd0fc8596b373a..8f77227b78ef0c6671c7d6f922b02eb1b08537df 100644 --- a/tests/scenarios/bookmarks/SearchTest.php +++ b/tests/scenarios/bookmarks/SearchTest.php @@ -499,7 +499,7 @@ class Bookmarks_SearchCosmogrammePhaseTest Zend_Registry::set('sql', $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(HARRY HARRYS ARI) +(POTTER POTTERS POT)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' HARRY POTTER') * 1.5) + (MATCH(auteurs) AGAINST(' HARRY POTTER')) desc", true, false) + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(HARRY HARRYS ARI) +(POTTER POTTERS POT)' IN BOOLEAN MODE)) and type=1 order by MATCH(titres, auteurs) AGAINST('\\\"HARRY POTTER\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"HARRY POTTER\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_HARRY P_POTTER') desc, MATCH(titres) AGAINST('P_HARRY P_POTTER') desc, MATCH(titres) AGAINST('HARRY POTTER') desc, MATCH(auteurs) AGAINST('HARRY POTTER') desc, date_creation desc", true, false) ->answers($result) ->beStrict()); @@ -669,7 +669,7 @@ class Bookmarks_SearchMailWithArticlePhaseTest Zend_Registry::set('sql', $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(HARRY HARRYS ARI) +(POTTER POTTERS POT)' IN BOOLEAN MODE)) and type=1 order by (MATCH(titres) AGAINST(' HARRY POTTER') * 1.5) + (MATCH(auteurs) AGAINST(' HARRY POTTER')) desc", true, false) + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(HARRY HARRYS ARI) +(POTTER POTTERS POT)' IN BOOLEAN MODE)) and type=1 order by MATCH(titres, auteurs) AGAINST('\\\"HARRY POTTER\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"HARRY POTTER\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_HARRY P_POTTER') desc, MATCH(titres) AGAINST('P_HARRY P_POTTER') desc, MATCH(titres) AGAINST('HARRY POTTER') desc, MATCH(auteurs) AGAINST('HARRY POTTER') desc, date_creation desc", true, false) ->answers($result) ->beStrict()); @@ -821,7 +821,7 @@ class Bookmarks_SearchDiffLoggedTest extends AbstractControllerTestCase { Zend_Registry::set('sql', $this->mock() ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(HARRY HARRYS ARI) +(POTTER POTTERS POT)' IN BOOLEAN MODE) and clef_alpha in ('DROITDEVANT--ODAEIICHIRO-15-GLENAT-2013-1')) and type=1 order by (MATCH(titres) AGAINST(' HARRY POTTER') * 1.5) + (MATCH(auteurs) AGAINST(' HARRY POTTER')) desc", true, false) + ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(HARRY HARRYS ARI) +(POTTER POTTERS POT)' IN BOOLEAN MODE) and clef_alpha in ('DROITDEVANT--ODAEIICHIRO-15-GLENAT-2013-1')) and type=1 order by MATCH(titres, auteurs) AGAINST('\\\"HARRY POTTER\\\"' IN BOOLEAN MODE) desc, MATCH(editeur, collection, matieres, dewey, other_terms) AGAINST('\\\"HARRY POTTER\\\"' IN BOOLEAN MODE) desc, MATCH(auteurs) AGAINST('P_HARRY P_POTTER') desc, MATCH(titres) AGAINST('P_HARRY P_POTTER') desc, MATCH(titres) AGAINST('HARRY POTTER') desc, MATCH(auteurs) AGAINST('HARRY POTTER') desc, date_creation desc", true, false) ->answers([[1888, '']]) ->beStrict());