diff --git a/VERSIONS_HOTLINE/118591 b/VERSIONS_HOTLINE/118591 new file mode 100644 index 0000000000000000000000000000000000000000..427aa81b2cdf5c0f0a2a94496a9edf1ae6c4bf0e --- /dev/null +++ b/VERSIONS_HOTLINE/118591 @@ -0,0 +1 @@ + - ticket #118591 : Vue Notice : Les liens de rebond, pour certains auteurs principaux avec un deuxième prénom constitué d'une seule lettre, ne fonctionnait pas \ No newline at end of file diff --git a/library/Class/Album.php b/library/Class/Album.php index 1c4e7e89c88ef9dcfe2294b735825ba47c922748..9d816acdf9852afc125fa504cdd1263a5e75bf10 100644 --- a/library/Class/Album.php +++ b/library/Class/Album.php @@ -176,11 +176,11 @@ class Class_Album extends Storm_Model_Abstract { /** @var Class_Upload */ protected $_uploadHandler = []; - protected $_marc; - - protected $path_flash; - - protected $_date_maj_enabled = true; + protected + $_marc, + $path_flash, + $_date_maj_enabled = true, + $_authors; public function __construct() { @@ -1571,43 +1571,20 @@ class Class_Album extends Storm_Model_Abstract { } - /** - * Main author - * @return string - */ public function getMainAuthorName() { - if (!$authors = $this->getAuthors()) - return ''; - - return array_shift($authors)->getName(); + return ($main_author = $this->_initAuthors()->getAuthorPrincipal()) + ? $main_author + : ''; } - /** - * Author names from unimarc container - * @return array - */ public function getAuthorsNames() { - $names = []; - foreach($this->getAuthors() as $author) - $names []= $author->getName(); - return $names; + return $this->_initAuthors()->getAllAuthors(); } - /** - * Author from unimarc container - * @return array - */ public function getAuthors() { - $authors = []; - foreach ($this->getMarc()->getDatasOfField(self::AUTHOR_FIELD) as $item) { - if (!isset($item['a'])) - continue; - $authors []= new Class_Notice_Author($item['a'], - isset($item['4']) ? $item['4'] : ''); - } - return $authors; + return $this->_initAuthors()->getArrayAuthors(); } @@ -1617,35 +1594,10 @@ class Class_Album extends Storm_Model_Abstract { * @param function string */ public function addAuthor($author, $responsibility = '') { - if (!$author) - return $this; - - if (is_string($author)) - $author = new Class_Notice_Author($author, $responsibility); - - $datas = ['a' => $author->getName()]; - if ($author->getResponsibility()) - $datas['4'] = $author->getResponsibility(); - - if (!in_array($author->getName(), $this->getAuthorsNames())) { - $this->getMarc()->addZone(self::AUTHOR_FIELD, $datas); - return $this; - } - - if (!$author->getResponsibility()) - return $this; - - $found = false; - - foreach($this->getAuthors() as $other) { - if ($author->getName() == $other->getName() && $author->getResponsibility() == $other->getResponsibility()) { - $found = true; - break; - } - } - - if (!$found) - $this->getMarc()->addZone(self::AUTHOR_FIELD, $datas); + if ($author = $this->_initAuthors() + ->addAuthorOrLabel($author, $responsibility)) + $this->getMarc() + ->addZone(static::AUTHOR_FIELD, $this->_getDatasFromAuthor($author)); return $this; } @@ -1747,4 +1699,20 @@ class Class_Album extends Storm_Model_Abstract { public function getRootCategoryId() { return $this->getRootCategory()->getId(); } + + + protected function _initAuthors() { + return $this->_authors + ? $this->_authors + : ($this->_authors = new Class_Album_Authors($this)); + } + + + protected function _getDatasFromAuthor($author) { + $datas = ['a' => $author->getName()]; + if ($author->getResponsibility()) + $datas['4'] = $author->getResponsibility(); + + return $datas; + } } diff --git a/library/Class/Album/Authors.php b/library/Class/Album/Authors.php new file mode 100644 index 0000000000000000000000000000000000000000..5d7e78a03ca22fc7209996a8183505b3ac125b0e --- /dev/null +++ b/library/Class/Album/Authors.php @@ -0,0 +1,77 @@ +<?php +/** + * Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Class_Album_Authors extends Class_Authors { + + protected $_zones = '701'; + + public function addAuthorOrLabel($author, $responsibility = '') { + if (!$author) + return null; + + if (is_string($author)) + $author = new Class_Notice_Author($author, $responsibility); + + return $this->addAuthor($author); + } + + + public function getAllAuthors() { + if ($this->_authors->isEmpty()) + return []; + + return $this->_authors + ->collect(function ($author) + { + return $author->getLabelForAlbum(); + }) + ->reject(function ($label) + { + return !$label; + }) + ->getArrayCopy(); + } + + + protected function _init($album) { + foreach ($album->getMarc()->getDatasOfField($this->_zones) as $item) + $this->_initAuthor($item); + + return $this; + } + + + protected function _initAuthor($item) { + if (!isset($item['a'])) + return $this; + + $author = new Class_Notice_Author(''); + $author->setZone('701'); + $author->visitAuthor('a', $item['a']); + if (isset($item['4'])) + $author->visitAuthor('4', $item['4']); + + $this->_authors->add($author); + + return $this; + } +} diff --git a/library/Class/AlbumCategorie/EadGallicaVisitor.php b/library/Class/AlbumCategorie/EadGallicaVisitor.php index 65674b97da11f75f46b9949de0b3c2c32a95d442..9e896702b63dc07f08a27d0ef33c6ddc2ccbbfa2 100644 --- a/library/Class/AlbumCategorie/EadGallicaVisitor.php +++ b/library/Class/AlbumCategorie/EadGallicaVisitor.php @@ -286,14 +286,9 @@ class Class_AlbumCategorie_EadGallicaVisitor_AlbumWrapper { protected function _initAuthors() { - if (!$authors = $this->_record->getAuteursUnimarc(false, true)) - return $this->_album->getAuthors(); - - return array_map(function($author) - { - return new Class_Notice_Author($author->getAuthorName(), $author->getFonction()); - }, - $authors); + return ($authors = $this->_record->getArrayAuthors()) + ? $authors + : $this->_album->getAuthors(); } @@ -405,4 +400,4 @@ class Class_AlbumCategorie_EadGallicaVisitor_AlbumWrapper { public function acceptEadVisitor($visitor) { return $this->_album->acceptEadVisitor($visitor); } -} \ No newline at end of file +} diff --git a/library/Class/Authors.php b/library/Class/Authors.php new file mode 100644 index 0000000000000000000000000000000000000000..f316f805f6cd608c29b94a51b6e1903424caf456 --- /dev/null +++ b/library/Class/Authors.php @@ -0,0 +1,107 @@ +<?php +/** + * Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +abstract class Class_Authors { + + protected $_authors; + + public function __construct($record) { + $this->_authors = new Storm_Collection(); + $this->_init($record); + } + + public function getAuthorPrincipal() { + return $this->_getPrincipalWith(function ($author) + { + return $author->getName(); + }); + } + + + public function getCodifAuthorPrincipal() { + return $this->_getPrincipalWith(function ($author) + { + return $author->getCodifAuthor(); + }); + } + + + public function getArrayAuthors() { + if ($this->_authors->isEmpty()) + return []; + + return $this->_authors->getArrayCopy(); + } + + + public function getAllAuthorsFromZones($zones) { + if ($this->_authors->isEmpty()) + 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; + }) + ->getArrayCopy(); + } + + + public function addAuthor($author) { + $existing = $this->_authors + ->detect(function ($current) use ($author) + { + if ($author->getName() !== $current->getName()) + return false; + + if (!$author->getResponsibility()) + return true; + + return $author->getResponsibility() === $current->getResponsibility(); + }); + + if (!$existing) { + $this->_authors->add($author); + return $author; + } + + return null; + } + + + protected function _getPrincipalWith($callback) { + return ($author = $this->_authors->first()) + ? $callback($author) + : null; + } + + + abstract protected function _init($record); +} diff --git a/library/Class/Autocomplete/IndexTitle.php b/library/Class/Autocomplete/IndexTitle.php index 03d49bfc7decd2d52372dfab313785c3c96ed343..edca6e6eafa7960767a9c93a8d2779146211e5d3 100644 --- a/library/Class/Autocomplete/IndexTitle.php +++ b/library/Class/Autocomplete/IndexTitle.php @@ -16,21 +16,20 @@ * * 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 */ class Class_Autocomplete_IndexTitle extends Class_Autocomplete_Index { use Trait_Translator; - - protected $file_name = 'titles'; - protected $model_name='Class_Notice'; + + protected $file_name = 'titles'; + protected $model_name = 'Class_Notice'; protected function getRecordData($record) { - $author = $record->getFirstAuthor() ; - if ($author) - $author = $this->_(' de ') .$author; + if ($author = $record->getFirstAuthor()) + $author = $this->_(' de ') . $author; + return str_replace('<br />', ': ', $record->getTitrePrincipal() . $author); } } -?> \ No newline at end of file diff --git a/library/Class/CodifAuteur.php b/library/Class/CodifAuteur.php index 1d85e44ecdcec32a0f1f7215d9f955f8250a9a3a..819c81bd5789d61ecf7b4630caaf5378d40200ee 100644 --- a/library/Class/CodifAuteur.php +++ b/library/Class/CodifAuteur.php @@ -227,7 +227,7 @@ class CodifAuteurLoader extends Storm_Model_Loader { public function findAllIdsByResponsibilitiesLabelsFromRecord($record, $responsibilities_labels) { - $authors = array_filter($record->getAuteursUnimarc(false, true), + $authors = array_filter($record->getAllAuthorsWithResponsibility(), function($author) use ($responsibilities_labels) { @@ -305,4 +305,4 @@ class Class_CodifAuteur extends Storm_Model_Abstract { && (false == strpos($this->getThumbnailUrl(), 'Defaut.svg')); } -} \ No newline at end of file +} diff --git a/library/Class/Cosmogramme/Integration/PhaseSerialArticlesIndex.php b/library/Class/Cosmogramme/Integration/PhaseSerialArticlesIndex.php index 66d940957ec3e06346a10de9b3cc6d59f0efc514..83742f78b6e7658e88f8763fe38f66a6ed06ce57 100644 --- a/library/Class/Cosmogramme/Integration/PhaseSerialArticlesIndex.php +++ b/library/Class/Cosmogramme/Integration/PhaseSerialArticlesIndex.php @@ -136,7 +136,7 @@ class Class_Cosmogramme_Integration_PhaseSerialArticlesIndex protected function _handleAuthors($record, $issue, $facets) { - $authors = $record->getAuteursUnimarc(); + $authors = $record->getAllAuthors(); foreach($authors as $author) $this->_injectCodifFacetIn($author, '_getCodifAuthorFor', $facets); diff --git a/library/Class/Migration/ArteVODAuthorsOrder.php b/library/Class/Migration/ArteVODAuthorsOrder.php index 4b3a201519e83b62de9cec60b9f3e73c948ff24d..4b3e118dda27a9e4b87274e0644c015c0bb69f43 100644 --- a/library/Class/Migration/ArteVODAuthorsOrder.php +++ b/library/Class/Migration/ArteVODAuthorsOrder.php @@ -24,50 +24,6 @@ class Class_Migration_ArteVODAuthorsOrder { use Trait_MemoryCleaner; public function updateAuthorsForAllAlbums($closure=null) { - try { - $page = 0; - while($albums = Class_Album::findAllBy(['type_doc_id' => Class_TypeDoc::ARTEVOD, - 'order' => 'id', - 'limitPage' => [$page, 500]])) { - $this->_runPage($albums, $closure); - $this->_cleanMemory(); - $page++; - } - } catch(Exception $e) { - return; - } - } - - - protected function _runPage($albums, $closure) { - foreach($albums as $album) { - $this->updateAuthors($album); - if ($closure) - $closure($album); - } - } - - - public function updateAuthors($album) { - $old_authors = new Storm_Collection($album->getAuthors()); - $album->getMarc()->clearZone('701'); - $this->addAuthorsTo($old_authors, function($author) - { - return $author->getResponsibility()=='300'; - }, $album); - $this->addAuthorsTo($old_authors, function($author) - { - return $author->getResponsibility()!='300'; - }, $album); - $album->index(); - } - - - protected function addAuthorsTo($authors, $closure, $album) { - $authors->select($closure) - ->eachDo(function ($author) use ($album) - { - $album->addAuthor($author); - }) ; + // Obsolète } } diff --git a/library/Class/Notice.php b/library/Class/Notice.php index d6106ae35acbab0ea829d8ecf56df078d9b740ab..bdfed845d960637fbc88fbec5a618c8356dd2f93 100644 --- a/library/Class/Notice.php +++ b/library/Class/Notice.php @@ -230,7 +230,8 @@ class Class_Notice extends Storm_Model_Abstract { $_data_map, $_collation, $_main_author_cache, - $_same_serie_records; + $_same_serie_records, + $_authors; protected $_default_attribute_values = ['type_doc' => 0, 'annee' => null, @@ -740,8 +741,8 @@ class Class_Notice extends Storm_Model_Abstract { if ($complement = $serial_article->getComplementTitre()) $article["titre"] .= " : " . $complement; - $auteurs = $serial_article->getAuteursUnimarc(true); - $article["auteur"] = isset($auteurs[0]) ? $auteurs[0] : ''; + $auteur = $serial_article->getFirstAuthor(); + $article["auteur"] = $auteur; $article["pagination"] = $serial_article->getCollation(); $note = $data = $serial_article->get_subfield("300", "a"); $article["note"] = isset($note[0]) ? trim($note[0]) : ''; @@ -1136,219 +1137,72 @@ class Class_Notice extends Storm_Model_Abstract { public function getAuteurPrincipal() { - if (!isset($this->_auteur_principal)) { - $this->_auteur_principal = ''; - if (!$this->_auteur_principal=$this->getFirstAuthor()){ - if ($data = $this->get_subfield("200", "f")) - $this->_auteur_principal = $data[0]; - } - } + if (isset($this->_auteur_principal)) + return $this->_auteur_principal; - return $this->_auteur_principal; - } + $this->_auteur_principal = $this->getFirstAuthor(); + if (!$this->_auteur_principal + && $data = $this->get_subfield('200', 'f')) + $this->_auteur_principal = $data[0]; + if (!$this->_auteur_principal) + $this->_auteur_principal = ''; - public function getFirstAuthor() { - if (!$auteurs = $this->getAuteursUnimarc(true)) - return ''; - return $auteurs[0]; + return $this->_auteur_principal; } - public function setAuteurPrincipal($auteur) { - $this->_auteur_principal = $auteur; - return $this; + public function getCodifAuthorPrincipal() { + return $this->_initAuthors()->getCodifAuthorPrincipal(); } - public function getUnimarcZone($zone) { - return $this->get_subfield($zone); + public function getFirstAuthor() { + return $this->_initAuthors()->getAuthorPrincipal(); } - public function getAuteursUnimarc($auteurPrincipal = false, $getFonction = false) { - $indexation = Class_Indexation::getInstance(); - $auteurs = []; - $zones = ['700', '710', '720', '730', '701', '702', '711', '712', '721', '722']; - - foreach ($zones as $zone) { - if ($auteurPrincipal - && $auteur = $this->_getPremierAuteurDansZone($zone, $indexation)) - return [$auteur]; - - $auteurs = array_merge($auteurs, $this->_getAuteursDansZone($zone, $indexation, $getFonction)); - } - - // Si fonctions on constitue une nouvelle matrice détaillée - if ($getFonction and 0 < count($auteurs)) - return $this->_getAuteursAvecFonctions($auteurs); - - return $auteurs; + public function getAllAuthors() { + return $this->_initAuthors()->getAllAuthors(false); } - /** - * @param $zone string - * @param $indexation Class_Indexation - * @return string - */ - protected function _getPremierAuteurDansZone($zone, $indexation) { - $data = $this->get_subfield($zone); - foreach ($data as $items) { - $auteur = $this->_getAuteurDansSousChamps($this->decoupe_bloc_champ($items)); - $libelle = $auteur->nom . '|' . $auteur->prenom; - - if ($this->_isAuteurDansZoneValide($libelle, $indexation)) { - return trim($auteur->prenom . ' ' . $auteur->nom); - } - } - return ''; + public function getAllAuthorsWithResponsibility() { + return $this->_initAuthors()->getAllAuthors(true); } - /** - * @param $zone string - * @param $indexation Class_Indexation - * @param $avec_fonction boolean - * @return array - */ - protected function _getAuteursDansZone($zone, $indexation, $avec_fonction = false) { - $auteurs = []; - $data = $this->get_subfield($zone); - foreach ($data as $items) { - $libelle = $this->_getAuteurDansZone($items, $avec_fonction); - - if ($this->_isAuteurDansZoneValide($libelle, $indexation)) { - $auteurs[] = $libelle; - } - } - - return $auteurs; + public function getAllAuthorsFromZones($zones) { + return $this->_initAuthors()->getAllAuthorsFromZones($zones); } - - protected function getNatureDocs() { - return $this->get_subfield('200','b'); - + public function getArrayAuthors() { + return $this->_initAuthors()->getArrayAuthors(); } - /** - * @param $data array - * @param $indexation Class_Indexation - * @param $avec_fonction boolean - * @return string - */ - protected function _getAuteurDansZone($data, $avec_fonction = false) { - $auteur = $this->_getAuteurDansSousChamps($this->decoupe_bloc_champ($data), $avec_fonction); - $libelle = $auteur->nom . '|' . $auteur->prenom; - if ($avec_fonction) - $libelle .= '|' . $auteur->fonction . '|' . $auteur->fonction_pergame; - - return $libelle; - } - - - /** - * @param $auteur string - * @param $indexation Class_Indexation - * @return boolean - */ - protected function _isAuteurDansZoneValide($auteur, $indexation) { - return (strlen($auteur) > 2 or $indexation->isMotInclu($auteur)) - and striPos($auteur, 'ANONYME') === false; + public function setAuteurPrincipal($auteur) { + $this->_auteur_principal = $auteur; + return $this; } - /** - * @param $data array - * @return stdClass - */ - protected function _getAuteurDansSousChamps($data, $avec_fonction = false) { - $auteur = new stdClass(); - - $fonction_pergame = $auteur->nom = $auteur->prenom = $auteur->fonction_pergame = ''; - $fonctions = $fonctions_nanook = []; - - foreach ($data as $item) { - $valeur = trim($item['valeur']); - - if ($item['code'] == 'a') { - $auteur->nom = $valeur; - continue; - } - if ($item['code'] == 'b') { - $auteur->prenom = $valeur; - continue; - } - - if (($item['code'] == '4') && $avec_fonction) { - $fonctions []= (is_numeric($valeur) && ($codif_fonction = Class_CodifAuteurFonction::find($valeur))) - ? $codif_fonction->getLibelle() - : $valeur; - continue; - } - - if ($item['code'] == 'g' && !$fonction_pergame) { - $fonction_pergame = $valeur; - continue; - } - - if ($item['code'] == '6') { - $fonctions_nanook []= $valeur; - } - } - - $auteur_sep = ', '; - $auteur->fonction = implode($auteur_sep, $fonctions); - $auteur->fonction_pergame = $fonctions_nanook - ? implode($auteur_sep, $fonctions_nanook) - : $fonction_pergame; - - return $auteur; + public function getUnimarcZone($zone) { + return $this->get_subfield($zone); } - /** - * @param $auteur array - * @return array - */ - protected function _getAuteursAvecFonctions($auteurs) { - if (!is_array($auteurs) || empty($auteurs)) - return []; - - $ix = Class_Indexation::getInstance(); - $result = []; - foreach ($auteurs as $auteur) { - $avec_fonction = $this->_getAuteurAvecFonction($auteur, $ix); - if (!empty($avec_fonction)) - $result[] = $avec_fonction; - } - - return $result; + protected function _initAuthors() { + return $this->_authors + ? $this->_authors + : ($this->_authors = new Class_Notice_Authors($this)); } - /** - * @param $auteur string formatted - * @see getAuteurs - */ - protected function _getAuteurAvecFonction($auteur, $indexation) { - $item = explode('|', $auteur); - $nom = $item[0]; - $prenom = $item[1]; - $fonction_pergame = $item[3]; - $fonction = $fonction_pergame ? $fonction_pergame : $item[2]; - - if (!$codif_auteur = Class_CodifAuteur::findByLastNameFirstName($nom, $prenom)) - return []; + protected function getNatureDocs() { + return $this->get_subfield('200','b'); - $label = trim($prenom . ' ' . $nom) . (($fonction) ? ' (' . $fonction . ')': ''); - return (new Class_Notice_FieldAuthor($codif_auteur)) - ->setLabel($label) - ->setFonction($fonction) - ->setAuthorName($codif_auteur->getLibelle()); } @@ -1620,9 +1474,8 @@ class Class_Notice extends Storm_Model_Abstract { $visitor->visitClefAlpha($this->getClefAlpha()); $visitor->visitSerialTitle($this->_getTitresDansZones(['461$t'])); $visitor->visitTitres($this->_getTitresDansZones(['200$a', '200$e'])); - $visitor->visitAuteurs(array_merge($this->_getAuteursDansZone('700', $indexation), - $this->_getAuteursDansZone('701', $indexation))); - $visitor->visitContributeurs($this->_getAuteursDansZone('702', $indexation)); + $visitor->visitAuteurs($this->getAllAuthorsFromZones(['700', '701'])); + $visitor->visitContributeurs($this->getAllAuthorsFromZones(['702'])); foreach ($this->getMatieresLabels() as $matiere) $visitor->visitMatiere($matiere); @@ -1831,7 +1684,7 @@ class Class_Notice extends Storm_Model_Abstract { public function getAuteurWith($codif_auteur_forme) { - if(!$auteurs = $this->getAuteursUnimarc()) + if (!$auteurs = $this->getAllAuthors()) return ''; foreach($auteurs as $auteur) { @@ -1990,11 +1843,8 @@ class Class_Notice extends Storm_Model_Abstract { if ($this->_main_author_cache) return $this->_main_author_cache; - if ( ! $main_author = $this->getAuteurPrincipal()) - return ''; - - if ( ! $codif = Class_CodifAuteur::findWithFullName($main_author)) - return $main_author; + if (!($codif = $this->getCodifAuthorPrincipal())) + return $this->getAuteurPrincipal(); $author_field = new Class_Notice_FieldAuthor($codif); diff --git a/library/Class/Notice/Author.php b/library/Class/Notice/Author.php index f2903593baf811e45b9409168aeaf7609b057bb8..73ef0abddd1ecfe42dad79f0f9dab099b97404f1 100644 --- a/library/Class/Notice/Author.php +++ b/library/Class/Notice/Author.php @@ -21,14 +21,26 @@ class Class_Notice_Author { + + const + SEP_NAMES = '|', + SEP_FONCTIONS = ', '; + protected $_name = '', $_responsibility = '', $_affiliation = '', - $_author_zone = 701; + $_zone = '701', + $_indexation = '', + $_codif_author = '', + $_first_name = '', + $_last_name = '', + $_fonction_pergame = '', + $_fonctions = [], + $_fonctions_nanook = []; public function __construct($name, $responsibility = '') { - $this->_name = $name; + $this->_last_name = $this->_name = $name; $this->_responsibility = $responsibility; } @@ -49,23 +61,22 @@ class Class_Notice_Author { public function beMainAuthor() { - $this->_author_zone = 700; - return $this; + return $this->setZone('700'); } public function addToUnimarc($unimarc) { - if (!$this->_name) + if (!$name = $this->getName()) return $this; - $fields = [['a', $this->_name]]; - if ($this->_responsibility) - $fields[] = ['4', $this->_responsibility]; + $fields = [['a', $name]]; + if ($responsibility = $this->getResponsibility()) + $fields[] = ['4', $responsibility]; if ($this->_affiliation) $fields[] = ['p', $this->_affiliation]; - $unimarc->add_field($this->_author_zone, + $unimarc->add_field($this->getZone(), ' ', $fields); return $this; @@ -73,18 +84,131 @@ class Class_Notice_Author { public function getName() { - return $this->_name; + if ($this->_name) + return $this->_name; + + return $this->_name = $this->_getAuthorLabel(); } public function getResponsibility() { - return $this->_responsibility; + if ($this->_responsibility) + return $this->_responsibility; + + return $this->_responsibility = $this->_getFonctions(); } public function __toString() { // note: used for array_unique (see array_unique doc and hell), so be careful when changing $this - return 'author: '.$this->_name; + return 'author: ' . $this->getName(); + } + + + public function isValid() { + $label = $this->getLabel(); + + return (strlen($label) > 2 || $this->_getIndexation()->isMotInclu($label)) + && striPos($label, 'ANONYME') === false; + } + + + public function visitAuthor($code, $value) { + if ('a' == $code) + $this->_last_name = $value; + + if ('b' == $code) + $this->_first_name = $value; + + if ('4' == $code) + $this->_fonctions [] = (is_numeric($value) && ($codif_fonction = Class_CodifAuteurFonction::find($value))) + ? $codif_fonction->getLibelle() + : $value; + + if ('g' == $code && !$this->_fonction_pergame) + $this->_fonction_pergame = $value; + + if ('6' == $code) + $this->_fonctions_nanook [] = $value; + + return $this; + } + + + public function getLabel() { + return $this->_last_name . static::SEP_NAMES . $this->_first_name; + } + + + public function getLabelForAlbum() { + return implode(static::SEP_NAMES, array_filter([$this->_last_name, + $this->_first_name])); + } + + + public function getLabelWithFonction() { + if (!$codif_auteur = $this->getCodifAuthor()) + return null; + + $label = $this->getName(); + if ($fonction = $this->_getFonctions()) + $label .= ' (' . $fonction . ')'; + + return (new Class_Notice_FieldAuthor($codif_auteur)) + ->setLabel($label) + ->setFonction($fonction) + ->setAuthorName($codif_auteur->getLibelle()); + } + + + public function getCodifAuthor() { + if ($this->_codif_author) + return $this->_codif_author; + + $code_alpha = str_replace(' ', + 'x', + $this->_getIndexation() + ->alphaMaj($this->_last_name + . static::SEP_NAMES + . $this->_first_name)); + + return ($this->_codif_author = Class_CodifAuteur::findByCodeAlpha($code_alpha)); + } + + + public function getZone() { + return $this->_zone; + } + + + public function setZone($zone) { + $this->_zone = $zone; + return $this; + } + + + protected function _getAuthorLabel() { + return implode(' ', array_filter([$this->_first_name, $this->_last_name])); + } + + + protected function _getIndexation() { + return $this->_indexation + ? $this->_indexation + : ($this->_indexation = Class_Indexation::getInstance()); + } + + + protected function _getFonctions() { + return ($fct_pergame = $this->_getFonctionPergame()) + ? $fct_pergame + : implode(static::SEP_FONCTIONS, $this->_fonctions); + } + + + protected function _getFonctionPergame() { + return $this->_fonctions_nanook + ? implode(static::SEP_FONCTIONS, $this->_fonctions_nanook) + : $this->_fonction_pergame; } } -?> \ No newline at end of file diff --git a/library/Class/Notice/Authors.php b/library/Class/Notice/Authors.php new file mode 100644 index 0000000000000000000000000000000000000000..ae1ce7313535058fed0af3a1e6b2b3abc627713d --- /dev/null +++ b/library/Class/Notice/Authors.php @@ -0,0 +1,80 @@ +<?php +/** + * Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Class_Notice_Authors extends Class_Authors { + + protected $_zones = + ['700', '710', '720', '730', '701', '702', '711', '712', '721', '722']; + + public function getAllAuthors($with_fonction) { + 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; + }) + ->getArrayCopy(); + } + + + protected function _init($record) { + foreach ($this->_zones as $zone) + $this->_getAuthorsInZone($record, $zone); + + return $this; + } + + + protected function _getAuthorsInZone($record, $zone) { + $data = $record->get_subfield($zone); + $break = false; + + foreach ($data as $items) { + $fields = $record->decoupe_bloc_champ($items); + $author = $this->_getAuthorInSubfield($zone, $fields); + + if ($author->isValid()) + $this->_authors->add($author); + } + + return $this; + } + + + protected function _getAuthorInSubfield($zone, $data) { + $author = new Class_Notice_Author(''); + $author->setZone($zone); + + foreach ($data as $item) + $author->visitAuthor($item['code'], trim($item['valeur'])); + + return $author; + } +} diff --git a/library/Class/Notice/DataMap/UnimarcBiblio.php b/library/Class/Notice/DataMap/UnimarcBiblio.php index 3a65394264cf306e4dc9721d18f3d12eeef43ec0..1d4eeca52d17b5624803d2f75382316459ced049 100644 --- a/library/Class/Notice/DataMap/UnimarcBiblio.php +++ b/library/Class/Notice/DataMap/UnimarcBiblio.php @@ -37,7 +37,7 @@ class Class_Notice_DataMap_UnimarcBiblio extends Class_Notice_DataMap_Abstract { return $this->_getReboundField($field, $facets); switch ($field) { - case Class_CodifAuteur::CODE_FACETTE: return $this->_record->getAuteursUnimarc(false, true); + case Class_CodifAuteur::CODE_FACETTE: return $this->_record->getAllAuthorsWithResponsibility(); case Class_Codification::CODE_TITRE: return $this->_record->getZonesTitre(); case Class_Codification::CODE_EDITEUR: return $this->_record->getEditeurs(); case Class_Codification::CODE_COLLECTION: return $this->_getReboundCollections(); @@ -142,4 +142,4 @@ class Class_Notice_DataMap_UnimarcBiblioZone214 return $view->notice_Zone214($this->_zone, $class); } -} \ No newline at end of file +} diff --git a/library/Class/Notice/MetaData.php b/library/Class/Notice/MetaData.php index 370319b3ee64ad9c7c491db6eb116a3c2f9233e0..e6a699e38549f2a3eba0c0f7bae20f50f54207a8 100644 --- a/library/Class/Notice/MetaData.php +++ b/library/Class/Notice/MetaData.php @@ -66,7 +66,7 @@ class Class_Notice_MetaData { $script_loader->addMeta('dc.subject', $matiere); $authors = array_map(function($name) { return str_replace('|', ', ', $name); }, - $this->_record->getAuteursUnimarc()); + $this->_record->getAllAuthors()); $this->_addAuthors($script_loader, $authors) ->_addType($script_loader) diff --git a/library/templates/Intonation/Library/View/Wrapper/Record.php b/library/templates/Intonation/Library/View/Wrapper/Record.php index 50bae44f2b58910d9b106d4a6b5a753744be994c..71d85f215b383c8a614205ef149f735b09a8303c 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record.php @@ -124,10 +124,10 @@ class Intonation_Library_View_Wrapper_Record extends Intonation_Library_View_Wra public function getSecondaryLink() { - if(!$author = $this->getSecondaryTitle()) + if (!$this->getSecondaryTitle()) return null; - if (!$facet = Class_CodifAuteur::findWithFullName($author)) + if (!$facet = $this->_model->getCodifAuthorPrincipal()) return null; $author_field = new Class_Notice_FieldAuthor($facet); diff --git a/scripts/artevod_update_authors.php b/scripts/artevod_update_authors.php deleted file mode 100644 index 192ba001ca559e62060ace69cf24c2f76dcbb860..0000000000000000000000000000000000000000 --- a/scripts/artevod_update_authors.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php -error_reporting(E_ERROR | E_PARSE); -require(__DIR__.'/../console.php'); - -(new Class_Migration_ArteVODAuthorsOrder()) - ->updateAuthorsForAllAlbums(function($album) { echo 'updated [ ' .$album->getTitre()." ]\n";}); diff --git a/tests/application/modules/admin/controllers/AlbumControllerTest.php b/tests/application/modules/admin/controllers/AlbumControllerTest.php index 33870361d476ee428e4494e7c417475f4f48ccf1..e7f63a3809e2acfd4b8bd483b33ea88347f7e268 100644 --- a/tests/application/modules/admin/controllers/AlbumControllerTest.php +++ b/tests/application/modules/admin/controllers/AlbumControllerTest.php @@ -2417,7 +2417,7 @@ class Admin_AlbumControllerAlbumHarlockPostRessourceOneActionTest extends Admin_ /** @test */ public function unimarcShouldNotHaveSameAuthorTwice() { - $authors = $this->ressource->getAlbum()->getNotice()->getAuteursUnimarc(); + $authors = $this->ressource->getAlbum()->getNotice()->getAllAuthors(); $this->assertEquals( count(array_unique($authors)), count($authors)); } diff --git a/tests/application/modules/admin/controllers/RecordsControllerTest.php b/tests/application/modules/admin/controllers/RecordsControllerTest.php index fe075f21ffc1d39e53f42ea8650a66ef669aa489..a7eabe8a5dfd12821e2ab3831dec00a0a1bd3830 100644 --- a/tests/application/modules/admin/controllers/RecordsControllerTest.php +++ b/tests/application/modules/admin/controllers/RecordsControllerTest.php @@ -298,14 +298,14 @@ class RecordsControllerThumbnailActionPostValidUrlForPeriodiqueTest extends Reco $this->_http_client ->whenCalled('open_url') ->with('http://cache.org?isbn=0123456789' - .'&type_doc=2' - .'&titre='.urlencode('Science et vie') - .'&image='.urlencode('http://upload.wikimedia.org/science_vie.jpg') - .'&numero=1118' - .'&clef_chapeau='.urlencode('SCIENCE VIE') - .'&src='.Class_WebService_AllServices::createSecurityKey() - .'&api=2.0' - .'&action=12') + . '&type_doc=2' + . '&titre=' . urlencode('Science et vie') + . '&image=' . urlencode('http://upload.wikimedia.org/science_vie.jpg') + . '&numero=1118' + . '&clef_chapeau=' . urlencode('SCIENCE VIE') + . '&src=' . Class_WebService_AllServices::createSecurityKey() + . '&api=2.0' + . '&action=12') ->answers(json_encode(['vignette' => 'http://cache.org/science_vie_thumb.jpg', 'image' => 'http://cache.org/science_vie.jpg', 'statut_recherche' => 2])) @@ -731,4 +731,4 @@ class RecordsControllerTrailerAdministrationTest extends RecordsControllerTestCa $this->dispatch('/admin/records/enable-trailer/id/12345'); $this->assertFlashMessengerContentContains('La bande-annonce a bien été activée.'); } -} \ No newline at end of file +} diff --git a/tests/library/Class/Cosmogramme/Integration/PhaseNoticeLomTest.php b/tests/library/Class/Cosmogramme/Integration/PhaseNoticeLomTest.php index a2752d3b4fc88ce2908b961f1e69b5a814570a10..5bf57c4c8be3f80bbb932de1d7261119287b5317 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhaseNoticeLomTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhaseNoticeLomTest.php @@ -191,7 +191,7 @@ class PhaseNoticeLomTest extends PhaseNoticeTestCase { /** @test */ public function thirdRecordAuthorCountShouldBe6() { - $this->assertCount(6, $this->_notice->getAuteursUnimarc()); + $this->assertCount(6, $this->_notice->getAllAuthors()); } diff --git a/tests/library/Class/DecodageUnimarcTest.php b/tests/library/Class/DecodageUnimarcTest.php index 3e112d56cd6dc9de3f01f87c89ed3ffa1835d3e8..42db0cc3685db719442d13222ce62ab1792145ab 100644 --- a/tests/library/Class/DecodageUnimarcTest.php +++ b/tests/library/Class/DecodageUnimarcTest.php @@ -64,23 +64,23 @@ class DecodageUnimarcDVDLaJeuneFilleTest extends ModelTestCase { public function testGetAuteursReturnsFourAuteurs() { - $this->assertEquals(4, count($this->dvd_jeune_fille->getAuteursUnimarc())); + $this->assertEquals(4, count($this->dvd_jeune_fille->getAllAuthors())); } public function testCoulibaliInAuteurs() { - $auteurs = $this->dvd_jeune_fille->getAuteursUnimarc(); + $auteurs = $this->dvd_jeune_fille->getAllAuthors(); $this->assertContains('Coulibali|Dounamba Dani', $auteurs); } public function testDiabateInAuteurs() { - $this->assertContains('Diabate|Fanta', $this->dvd_jeune_fille->getAuteursUnimarc()); + $this->assertContains('Diabate|Fanta', $this->dvd_jeune_fille->getAllAuthors()); } public function testDiarraInAuteurs() { - $this->assertContains('Diarra|Oumou', $this->dvd_jeune_fille->getAuteursUnimarc()); + $this->assertContains('Diarra|Oumou', $this->dvd_jeune_fille->getAllAuthors()); } @@ -282,7 +282,7 @@ class DecodageUnimarcConcertoAuteursTest extends PHPUnit_Framework_TestCase { Class_CodifAuteurFonction::newInstanceWithId('000', ['libelle' => 'On sait pas']); Class_CodifAuteurFonction::newInstanceWithId('545', ['libelle' => 'Zikos']); - $this->_authors = $this->concerto->getAuteursUnimarc(false, true); + $this->_authors = $this->concerto->getAllAuthorsWithResponsibility(); } @@ -347,7 +347,7 @@ class DecodageUnimarcDVDUnHerosTresDiscretTest extends ModelTestCase { ['id' => 10, 'unimarc' => $unimarc, 'exemplaires' => []]); - $this->_authors = $this->audiard->getAuteursUnimarc(false, true); + $this->_authors = $this->audiard->getAllAuthorsWithResponsibility(); } protected function createAuthors() { @@ -419,7 +419,7 @@ class DecodageUnimarcCDKayaTest extends ModelTestCase { ['id' => 11, 'unimarc' => $unimarc, 'exemplaires' => []]); - $this->_authors = $this->cd_kaya->getAuteursUnimarc(false, true); + $this->_authors = $this->cd_kaya->getAllAuthorsWithResponsibility(); } @@ -477,7 +477,7 @@ class DecodageUnimarcVieDAdeleTest extends ModelTestCase { ['id' => 11, 'unimarc' => file_get_contents( ROOT_PATH . 'tests/fixtures/vie_adele.uni'), 'exemplaires' => []]); - $this->_authors = $vie_adele->getAuteursUnimarc(false, true); + $this->_authors = $vie_adele->getAllAuthorsWithResponsibility(); } @@ -526,4 +526,4 @@ class DecodageUnimarcZoneNotesTest extends ModelTestCase { $this->assertContains('My blue note', Class_Notice::find(142)->getNotes()); } } -?> \ No newline at end of file +?> diff --git a/tests/library/Class/Migration/ArteVODAuthorsOrderTest.php b/tests/library/Class/Migration/ArteVODAuthorsOrderTest.php deleted file mode 100644 index 1d326c665a7183ca75ba077738ffc9e1a2738482..0000000000000000000000000000000000000000 --- a/tests/library/Class/Migration/ArteVODAuthorsOrderTest.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php -/** - * Copyright (c) 2012-2019, 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 ArteVodLinkUpdateAuthorTest extends ModelTestCase { - protected $_storm_default_to_volatile = true; - - - public function setUp() { - parent::setUp(); - $album = $this->fixture('Class_Album', - ['id' => 5, - 'titre' => 'Comme elle respire', - ]); - $album->beArteVOD() - ->setNotes([ - ['field' => '701', - 'data' => ['a' => 'Trintignant Marie', - '4' => '005']], - ['field' => '701', - 'data' => ['a' => 'Depardieu Guillaume', - '4' => '005']], - ['field' => '701', - 'data' => ['a' => 'Salvadori Pierre', - '4' => '300']], - ['field' => '701', - 'data' => ['a' => 'Zo', - '4' => '300']], - ['field' => '701', - 'data'=> ['a' => 'Jean-François Stévenin', - '4' => '005']], - ['field' => '701', - 'data' => ['a' => 'Mastroiani', - '4' => '300']], - ]) - ->setVisible(true) - ->setExternalUri("http://artevod/comme-elle-respire") - ->beValidated() - ->save(); - - (new Class_Migration_ArteVODAuthorsOrder()) - ->setMemoryCleaner(function() {}) - ->updateAuthorsForAllAlbums(); - } - - - /** @test */ - public function directorShouldBeSalvadori() { - $this->assertEquals('Salvadori Pierre' , - Class_Notice::findFirstBy([])->getAuteurPrincipal()); - } - - - /** @test */ - public function secondDirectorShouldBeZo() { - $this->assertEquals('Zo|' , - Class_Notice::findFirstBy([])->getAuteursUnimarc()[1]); - } - - - /** @test */ - public function thirdDirectorShouldBeMastroiani() { - $this->assertEquals('Mastroiani|' , - Class_Notice::findFirstBy([])->getAuteursUnimarc()[2]); - } - - - /** @test */ - public function firstActorShouldBeTrintignant() { - $this->assertEquals('Trintignant Marie|' , - Class_Notice::findFirstBy([])->getAuteursUnimarc()[3]); - } - - - /** @test */ - public function secondActorShouldBeDepardieu() { - $this->assertEquals('Depardieu Guillaume|' , - Class_Notice::findFirstBy([])->getAuteursUnimarc()[4]); - } - - - /** @test */ - public function thirdActorShouldBeDepardieu() { - $this->assertEquals('Jean-François Stévenin|' , - Class_Notice::findFirstBy([])->getAuteursUnimarc()[5]); - } - - - /** @test */ - public function externalUriShouldBeCommeElleRespire() { - $this->assertContains('http://artevod/comme-elle-respire', - implode(Class_Notice::findFirstBy([])->getUnimarcZone("856"))); - } -} \ No newline at end of file diff --git a/tests/scenarios/AlbumAudioRecord/AlbumAudioRecordTest.php b/tests/scenarios/AlbumAudioRecord/AlbumAudioRecordTest.php index f1519245b4b71d3c19276996663e860b72a74c82..17061b35b0422455cf6cb08eef76d3b2ce27738a 100644 --- a/tests/scenarios/AlbumAudioRecord/AlbumAudioRecordTest.php +++ b/tests/scenarios/AlbumAudioRecord/AlbumAudioRecordTest.php @@ -234,7 +234,7 @@ class AlbumAudioRecordViewNoticeTest extends AlbumAudioRecordTestCase { /** @test */ public function field701a4ShouldContainsBruceDickinsonAsChanteur() { - $bruce = $this->_notice->getAuteursUnimarc(false, true)[1]; + $bruce = $this->_notice->getAllAuthorsWithResponsibility()[1]; $this->assertEquals('Bruce Dickinson (Chanteur)', $bruce->getLabel()); $this->assertEquals(['controller' => 'recherche', 'action' => 'simple', @@ -245,7 +245,7 @@ class AlbumAudioRecordViewNoticeTest extends AlbumAudioRecordTestCase { /** @test */ public function field701a4ShouldContainsIronMaiden() { - $imaiden = $this->_notice->getAuteursUnimarc(false, true)[0]; + $imaiden = $this->_notice->getAllAuthorsWithResponsibility()[0]; $this->assertEquals('Iron Maiden', $imaiden->getLabel()); $this->assertEquals(['controller' => 'recherche', 'action' => 'simple', diff --git a/tests/scenarios/AuthorPage/AuthorWidgetTest.php b/tests/scenarios/AuthorPage/AuthorWidgetTest.php index ee812213022d0ff38d33914095c8749c393e19c6..309c0605d6767528520c758f9f5981e1e950a6a9 100644 --- a/tests/scenarios/AuthorPage/AuthorWidgetTest.php +++ b/tests/scenarios/AuthorPage/AuthorWidgetTest.php @@ -303,8 +303,8 @@ class AuthorWidgetOnPageFilteredByResponsibilityTest extends AuthorWidgetOnPageT ->answers(Class_Notice::findAll()); $this->onLoaderOfModel('Class_CodifAuteur') - ->whenCalled('findByLastNameFirstName') - ->with('Delannoy', 'Jean') + ->whenCalled('findByCodeAlpha') + ->with('DELANNOYxJEAN') ->answers(Class_CodifAuteur::find(5)); $this->dispatch('/'); diff --git a/tests/scenarios/Templates/118591_author_ClaireLEvans.mrc b/tests/scenarios/Templates/118591_author_ClaireLEvans.mrc new file mode 100644 index 0000000000000000000000000000000000000000..2792df820826ecfad4c62a05d7279a1496bdb431 --- /dev/null +++ b/tests/scenarios/Templates/118591_author_ClaireLEvans.mrc @@ -0,0 +1 @@ +01510cam0 2200457 450 001000700000003003000007005001700037009001000054010002800064010002700092035002200119073002400141073002300165090001100188098001500199099002700214100004100241101000800282102000700290105001800297106000600315181002500321181002000346182002100366182001100387183002500398200008500423214003800508214001100546215005400557320002600611606005900637606004100696606006200737606005500799606005600854700004600910801003000956901002000986930004601006162635http://www.sudoc.fr/23546829020210429021005.0235468290 a978-0-7352-1175-9brel. a978-0-593-32944-3bbr. a(OCoLC)1088603393 0a9780735211759brel. 0a9780593329443bbr. a162635 e2021-03-24 touvrages0e2021-03-24 a20190426d2018 k y0frey50 ba0 aeng aUS aa a 001yd ar 6z01ctxt2rdacontent 16z01ai#bxxxe## 6z01cn2rdamedia 16z01an 16z01anga2rdacarrier1 aBroad bandethe untold story of the women who made the InternetfClaire L. Evans 0aNew York, N.Y.cPortfolio/Penguin 4dC 2018 a1 vol. (278 p.)cill., couv. ill. en coul.d24 cm aNotes bibliogr. Index 302733043591215217aInnovations technologiques2rameau 303231746891220614aInternet2rameau 30357334387ba0yba0yaSociété numérique2rameau9692119 302773169391022576aÉtudes sur les femmes2rameau 30329204669219584aFemmes dans les sciences2rameau 1323546838X91233593aEvansbClaire L.4070 3aFRbAbesc20210323gAFNOR a1 vol. (278 p.) 5384212201:693020636b384212201aT 9260jg \ No newline at end of file diff --git a/tests/scenarios/Templates/TemplatesDigitalResourcesTest.php b/tests/scenarios/Templates/TemplatesDigitalResourcesTest.php index b9750fb4527d896459ca998a23b4a811b14fd3c7..4ea17880f1619f6af6c463fd961df43f44612e46 100644 --- a/tests/scenarios/Templates/TemplatesDigitalResourcesTest.php +++ b/tests/scenarios/Templates/TemplatesDigitalResourcesTest.php @@ -256,11 +256,7 @@ class TemplatesDigitalResourcesWrongIndexationTest extends AbstractControllerTes 'titre_principal' => 'Psycho', 'type_doc' => Class_TypeDoc::DISQUE, ]) - ->setAuteurPrincipal('M.'); - - $this->fixture('Class_CodifAuteur', - ['id' => 324, - 'libelle' => 'M']); + ->setAuteurPrincipal('M'); $mock = $this->mock() diff --git a/tests/scenarios/Templates/TemplatesRecordsTest.php b/tests/scenarios/Templates/TemplatesRecordsTest.php index e03c35e595c4de2519456538cc08a16eba1fa854..2bf15e16c9d3f3c1ed05e35aa43a7a366a84ccc3 100644 --- a/tests/scenarios/Templates/TemplatesRecordsTest.php +++ b/tests/scenarios/Templates/TemplatesRecordsTest.php @@ -692,3 +692,50 @@ class TemplatesRecordsAsPageTest extends AbstractControllerTestCase { $this->assertContains('div class="card', $this->_wrapper->asPage()); } } + + + + +/** Hotline #118591 */ +class TemplatesRecordsForPrincipalAuthorWithParticleTest + extends AbstractControllerTestCase { + + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + Class_AdminVar::set('AUTHOR_PAGE', 0); + + $this->_buildTemplateProfil(['id' => 1, + 'libelle' => 'My Beautiful Library']); + + $claire_l_evans = $this->fixture(Class_CodifAuteur::class, + ['id' => '9875', + 'libelle' => 'Claire L. Evans', + 'formes' => 'EVANSxCLAIRExL']); + + $this->onLoaderOfModel(Class_CodifAuteur::class) + ->whenCalled('findByCodeAlpha') + ->with('EVANSxCLAIRExL') + ->answers($claire_l_evans) + + ->whenCalled('findFirstBy') + ->with(['libelle' => 'CLAIRE L EVANS']) + ->answers(null); + + $this->fixture(Class_Notice::class, + ['id' => 222, + 'unimarc' => file_get_contents(__DIR__ . '/118591_author_ClaireLEvans.mrc'), + 'facettes' => 'A9875', + 'exemplaires' => []]); + + $this->dispatch('recherche/viewnotice/id/222'); + } + + + /** @test */ + public function enteteShouldDisplayRebondAuteurClaireEvans() { + $this->assertXPathContentContains('//div[contains(@class, "jumbotron_title")]//a[contains(@href, "/code_rebond/A9875")]', 'Claire L. Evans'); + } +}