Skip to content
Snippets Groups Projects
Commit 772755b1 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

hotline #23080 fix overwrite of note by description (resume) at album indexation

parent 7615d4d6
Branches
Tags
4 merge requests!896Master,!811Stable,!808Stable,!801Hotline #23080 fix duplication note and resume at album indexation
......@@ -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
*/
class Class_Indexation_PseudoNotice {
......@@ -45,8 +45,8 @@ class Class_Indexation_PseudoNotice {
public static function newWith($type_doc, $datas) {
// types simples
$mapping = [self::TYPE_CMS => 'Cms',
self::TYPE_RSS => 'Rss',
$mapping = [self::TYPE_CMS => 'Cms',
self::TYPE_RSS => 'Rss',
self::TYPE_SITO=> 'Sito'];
if (array_key_exists($type_doc, $mapping)) {
......@@ -64,7 +64,7 @@ class Class_Indexation_PseudoNotice {
$this->_type_doc = (int)$type_doc;
$this->_indexation = new Class_Indexation();
$this->_datas = array_change_key_case($datas, CASE_LOWER);
$this->_model = call_user_func_array([$this->_model_name, 'find'],
$this->_model = call_user_func_array([$this->_model_name, 'find'],
[$this->_datas[$this->_id]]);
}
......@@ -147,21 +147,21 @@ class Class_Indexation_PseudoNotice {
$this->_notice->updateAttributes($data);
$authors = $this->_getAuthorNames();
$this->_notice
->setMatieres($this->extractFullTextFromCodif($data,
'matiere',
->setMatieres($this->extractFullTextFromCodif($data,
'matiere',
'Class_CodifMatiere'))
->setAlphaTitre($this->_indexation->codeAlphaTitre($this->_datas["titre"]))
->setClefAlpha($this->_indexation->getClefAlpha($this->_notice->getTypeDoc(),
$this->_datas["titre"],
'',
->setClefAlpha($this->_indexation->getClefAlpha($this->_notice->getTypeDoc(),
$this->_datas["titre"],
'',
implode('-', $authors),
'',
$this->_datas["editeur"],
$this->_datas["annee"]))
->setClefOeuvre($this->_indexation->getClefOeuvre($this->_datas["titre"],
'',
'',
$this->_datas["auteur"],
''))
->setTitres($this->_indexation->getfullText($this->extractTitles()))
......@@ -175,7 +175,7 @@ class Class_Indexation_PseudoNotice {
->setDateMaj(date('Y-m-d H:i:s'));
if ($this->_dataExist("editeur"))
if ($this->_dataExist("editeur"))
$this->_notice->setEditeur($this->_indexation->getfullText($this->_datas["editeur"]));
if ($this->_dataExist("fichier") && !empty($this->_datas['fichier'])) {
......@@ -200,7 +200,7 @@ class Class_Indexation_PseudoNotice {
$cote = '';
if ($this->_dataExist("cote"))
$cote = $this->_datas["cote"];
$this->_exemplaire
->setGenre($genre)
->setCote($cote)
......@@ -235,26 +235,26 @@ class Class_Indexation_PseudoNotice {
protected function extractFullTextFromCodif($data, $field, $codif_class) {
if (!$this->_dataExist($field))
if (!$this->_dataExist($field))
return '';
$ids = array_filter(array_map('trim', explode(';', $this->_datas[$field])));
$fulltext = [];
foreach($ids as $id) {
if ($model = $codif_class::find($id))
$fulltext[] = $model->getLibelle();
}
return $this->_indexation->getfullText(implode(' ', $fulltext));
}
protected function indexDeweyAndPCDM4($data) {
$pcdm4 = $this->extractFullTextFromCodif($data,
'pcdm4',
$pcdm4 = $this->extractFullTextFromCodif($data,
'pcdm4',
'Class_CodifPcdm4');
$dewey = $this->extractFullTextFromCodif($data,
'dewey',
$dewey = $this->extractFullTextFromCodif($data,
'dewey',
'Class_CodifDewey');
$data["dewey"] = implode(' ', array_filter([$pcdm4, $dewey]));
......@@ -267,9 +267,9 @@ class Class_Indexation_PseudoNotice {
return $this->url_site;
$adresse = Class_CosmoVar::get('url_site');
if (strtolower(substr($adresse, 0, 7)) != 'http://')
if (strtolower(substr($adresse, 0, 7)) != 'http://')
$adresse = 'http://' . $adresse;
if (substr($adresse, -1, 1) != '/')
if (substr($adresse, -1, 1) != '/')
$adresse .= '/';
return $this->url_site = $adresse;
}
......@@ -321,8 +321,9 @@ class Class_Indexation_PseudoNotice {
return $visitor->getUnimarc();
}
protected function _getCodeBarres() {
return str_repeat('0', (4 - strlen($this->_datas['id_bib'])))
return str_repeat('0', (4 - strlen($this->_datas['id_bib'])))
. $this->_datas['id_bib'] . '-' . $this->_notice->getId();
}
......@@ -350,7 +351,7 @@ class Class_Indexation_PseudoNotice_Album extends Class_Indexation_PseudoNotice{
parent::_prepare();
if ($this->_datas['id_origine'])
$this->_datas['url'] = $this->getUrlSite() . 'bib-numerique/notice/ido/'
$this->_datas['url'] = $this->getUrlSite() . 'bib-numerique/notice/ido/'
. $this->_datas['id_origine'];
if ($poster = $this->_model->getPoster())
......@@ -361,7 +362,7 @@ class Class_Indexation_PseudoNotice_Album extends Class_Indexation_PseudoNotice{
protected function _modelIdAcceptVisitor($visitor) {}
/** @return array */
protected function extractAuthors() {
$authors = parent::extractAuthors();
......@@ -374,23 +375,23 @@ class Class_Indexation_PseudoNotice_Album extends Class_Indexation_PseudoNotice{
return array_unique($authors);
}
protected function _addAuthorArrayAsNoticeAuthor($datas, &$authors) {
foreach($datas as $data)
$authors []= new Class_Notice_Author($data['a'],
$authors []= new Class_Notice_Author($data['a'],
isset($data['4']) ? $data['4'] : '');
}
protected function extractEditors() {
return array_unique(array_merge(parent::extractEditors(),
return array_unique(array_merge(parent::extractEditors(),
$this->_model->getEditors()));
}
/** @return array */
protected function extractCollections() {
return array_unique(array_merge(parent::extractCollections(),
return array_unique(array_merge(parent::extractCollections(),
$this->_model->getCollections()));
}
......@@ -418,13 +419,21 @@ class Class_Indexation_PseudoNotice_Album extends Class_Indexation_PseudoNotice{
->visitGenre($this->getValuesFromModel('genre'))
->visitPcdm4($this->getValuesFromModel('pcdm4'));
foreach ($this->_model->getRessources() as $ressource)
foreach ($this->_model->getRessources() as $ressource)
$visitor->visitRessource($ressource);
}
public function isValid() {
return null != $this->_model && $this->_model->isVisible();
}
protected function _getUnimarc() {
$visitor = new Class_Indexation_PseudoNotice_AlbumVisitor();
$this->acceptVisitor($visitor);
return $visitor->getUnimarc();
}
}
......
<?php
/**
* Copyright (c) 2012-2014, 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_PseudoNotice_AlbumVisitor extends Class_Indexation_PseudoNotice_UnimarcVisitor {
public function visitDescription($description) {
return $this;
}
}
?>
\ No newline at end of file
<?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 ZendAfi_View_Helper_Notice_EnteteTest extends ViewHelperTestCase {
protected $_html;
public function setUp() {
parent::setUp();
Storm_Model_Loader::defaultToVolatile();
$this->_helper = new ZendAfi_View_Helper_Notice_Entete();
$this->_helper->setView(new ZendAfi_Controller_Action_Helper_View());
$this->_view = new ZendAfi_Controller_Action_Helper_View();
$this->fixture('Class_IntBib',
['id' => 1]);
Class_Album::newInstanceWithId(999)
->beDiaporama()
->setTitre('Plein de medias')
->setNoticeId(500)
->setIdOrigine("A888")
->setCote('50')
->setDateMaj('2012-02-17 10:00:00')
->setDescription('<p>pour passer la soirée</p>')
->setNotes(['305$a' => 'XXe siècle',
'200$b' => 'Parchemin',
'316$a' => 'Reliure restaurée en 1980 par la BN.'])
->setIdLang('lat')
->setRessources([Class_AlbumRessource::newInstanceWithId(2)
->setFichier('mimi_jolie.mp3')
->setTitre('Emilie jolie')
->setOrdre(1)
->setPoster('mimi_jolie.png'),
Class_AlbumRessource::newInstanceWithId(4)
->setFichier('dark_night.mp4')
->setTitre('Batman Dark Knight')
->setPoster('batman.jpg')
->setOrdre(2)
->setDuration('00:02:30')
->setDescription('Une nouvelle aventure du justicier noir'),
Class_AlbumRessource::newInstanceWithId(5)
->setUrl('http://progressive.totaleclips.com.edgesuite.net/107/e107950_227.mp4')
->setTitre('Hunger Games')
->setOrdre(3)
->setPoster('hunger.jpg'),
Class_AlbumRessource::newInstanceWithId(6)
->setFichier('Monsieur l\'escargot.mp3')
->setTitre('Monsieur l\'escargot')
->setOrdre(4)
->setPoster('l\'escargot.jpg')])
->index();
$notice = Class_Notice::find(1);
$this->_html = $this->_helper->Notice_Entete($notice, ['entete' => Class_Codification::CHAMPS]);
}
public function tearDown() {
Storm_Model_Loader::defaultToDb();
parent::tearDown();
}
/** @test */
public function notesShouldContainsRestoredByBNF() {
$this->assertXPathContentContains($this->_html, '//dl//dd', utf8_encode('<div>XXe siècle</div><div>Reliure restaurée en 1980 par la BN.</div>'), $this->_html);
}
/** @test */
public function resumeShouldCOntainsForTheEvening() {
$this->assertXPathContentContains($this->_html, '//dl//dd', utf8_encode('<p>pour passer la soirée</p>'), $this->_html);
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment