Commit 0e64bca3 authored by Laurent's avatar Laurent
Browse files

Merge branch...

Merge branch 'dev#134508_gpsea_ajouter_champ_centre_d_interet_dans_la_gestion_des_albums' into 'master'

dev#134508 : add album center of interest

See merge request afi/opacce!4138
parents d4fcf5a5 b4593852
- ticket #134508 : Administration des albums: Ajout du champ centre d'intérêt
\ No newline at end of file
<?php
$adapter = Zend_Db_Table::getDefaultAdapter();
try {
$adapter->query("alter table album add column interet TEXT");
} catch(Exception $e) {}
......@@ -171,7 +171,8 @@ class Class_Album extends Storm_Model_Abstract {
'status' => self::STATUS_DRAFT,
'pcdm4' => '',
'tags' => '',
'harvested_at' => ''];
'harvested_at' => '',
'interet' => ''];
/** @var Class_Upload */
protected $_uploadHandler = [];
......
......@@ -128,7 +128,8 @@ class Class_Indexation_PseudoNotice {
'isbn' => '',
'domaine_ids' => '',
'resume' => '',
'created_at' => null],
'created_at' => null,
'interet' => ''],
array_change_key_case($this->_datas));
}
......@@ -324,6 +325,7 @@ class Class_Indexation_PseudoNotice {
->visitTypeDoc($this->_type_doc)
->visitAuteur($this->extractAuthors())
->visitMatiere($this->_datas['matiere'])
->visitCenterOfInterest($this->_datas['interet'])
->visitDewey($this->_datas['dewey'])
->visitLangue($this->_datas['id_langue'])
->visitTagFacettes($this->_datas["tags"])
......
......@@ -37,6 +37,7 @@ class Class_Indexation_PseudoNotice_FacettesVisitor extends Class_Indexation_Pse
}
public function visitTypeDoc($type_doc) {
$this->_facettes []= 'T'.$type_doc;
return $this;
......@@ -44,30 +45,27 @@ class Class_Indexation_PseudoNotice_FacettesVisitor extends Class_Indexation_Pse
public function visitBibliotheques($bibs) {
$this->visitCodeFacetteWithValues('B',$bibs);
return $this;
return $this->visitCodeFacetteWithValues(Class_Bib::CODE_FACETTE, $bibs);
}
public function visitAnnexes($annexes) {
$this->visitCodeFacetteWithValues('Y',$annexes);
return $this;
return $this->visitCodeFacetteWithValues(Class_CodifAnnexe::CODE_FACETTE, $annexes);
}
public function visitSections($sections) {
$this->visitCodeFacetteWithValues('S',$sections);
return $this;
return $this->visitCodeFacetteWithValues(Class_CodifSection::CODE_FACETTE, $sections);
}
public function visitGenre($genre) {
$this->visitCodeFacetteWithValues('G',$genre);
return $this;
return $this->visitCodeFacetteWithValues(Class_CodifGenre::CODE_FACETTE, $genre);
}
public function visitPcdm4($pcdm4) {
$this->visitCodeFacetteWithValues('P',$pcdm4);
return $this;
return $this->visitCodeFacetteWithValues(Class_CodifPcdm4::CODE_FACETTE, $pcdm4);
}
......@@ -104,22 +102,23 @@ class Class_Indexation_PseudoNotice_FacettesVisitor extends Class_Indexation_Pse
public function visitDewey($dewey) {
$this->visitCodeFacetteWithValues('D',$dewey);
return $this;
return $this->visitCodeFacetteWithValues(Class_CodifDewey::CODE_FACETTE,$dewey);
}
public function visitMatiere($matiere) {
foreach(array_filter(explode(';', $matiere)) as $matiere)
$this->_facettes[]= 'M' . $matiere;
return $this->visitCodeFacetteWithValues(Class_CodifMatiere::CODE_FACETTE, $matiere);
}
return $this;
public function visitCenterOfInterest($interests) {
return $this->visitCodeFacetteWithValues(Class_CodifCentreInteret::CODE_FACETTE, $interests);
}
public function visitLangue($id_langue) {
if ($id_langue)
$this->_facettes[]='L' . $id_langue;
$this->_facettes[]=Class_CodifLangue::CODE_FACETTE . $id_langue;
return $this;
}
......@@ -175,4 +174,4 @@ class Class_Indexation_PseudoNotice_FacettesVisitor extends Class_Indexation_Pse
public function getFacettes() {
return $this->_facettes;
}
}
\ No newline at end of file
}
......@@ -201,16 +201,9 @@ class Class_Indexation_PseudoNotice_UnimarcVisitor extends Class_Indexation_Pseu
public function visitMatiere($matiere_ids) {
$matieres = explode(';', $matiere_ids);
foreach ($matieres as $matiere) {
if (!trim($matiere))
continue;
foreach (Class_CodifMatiere::findAllBy(['id_matiere' => explode(';',$matiere_ids) ]) as $matiere)
$this->addUnimarcField("610", "1 ", "a" . $matiere->getLibelle());
if (null === ($model = Class_CodifMatiere::find($matiere)))
continue;
$this->addUnimarcField("610", "1 ", "a" . $model->getLibelle());
}
return $this;
}
......@@ -221,6 +214,14 @@ class Class_Indexation_PseudoNotice_UnimarcVisitor extends Class_Indexation_Pseu
}
public function visitCenterOfInterest($interests) {
foreach(Class_CodifCentreInteret::findAllBy(['id_interet' => explode(';',$interests) ]) as $interest)
$this->addUnimarcField('932', '1 ', 'a'.$interest->getLibelle());
return $this;
}
public function visitSubjectCommonNames($subjects) {
foreach($subjects as $subject)
$this->addUnimarcField('606', '1 ', [['a', $subject]]);
......
......@@ -65,6 +65,7 @@ class ZendAfi_Form_Album extends ZendAfi_Form {
'pcdm4',
'dewey',
'genre',
'interet',
'tags'],
'album_metadata',
['legend' => $form->_('Metadonnées')])
......@@ -206,6 +207,11 @@ class ZendAfi_Form_Album extends ZendAfi_Form {
'style' => 'width:440px;',
'rows' => 2])
->addElement('listeSuggestion',
'interet',
['label' => $this->_("Centres d'intérêt"),
'rubrique' => 'interet'])
->addElement('multiInput', 'authors',
['label' => $this->_('Auteurs'),
'fields' => [['name' => 'author', 'label' => $this->_('Nom')],
......@@ -408,4 +414,4 @@ class ZendAfi_Form_Album extends ZendAfi_Form {
});
return parent::deleteUnchanged($post);
}
}
\ No newline at end of file
}
......@@ -1713,6 +1713,7 @@ class Admin_AlbumControllerEditAlbumMesRomans extends Admin_AlbumControllerTestC
$this->assertXPath("//input[@name='matiere'][@value='']");
}
/** @test */
function formShouldHaveAComboBoxForLangueSelection() {
$this->assertXPathContentContains("//select[@name='id_langue']//option[@value='cus']",
......@@ -1722,6 +1723,12 @@ class Admin_AlbumControllerEditAlbumMesRomans extends Admin_AlbumControllerTestC
$this->assertXPathContentContains("//select[@name='id_langue']//option[@value='dak']",
'dakota');
}
/** @test */
public function interetShouldBeDisplayed() {
$this->assertXPath('//input[@id="interet"]');
}
}
......@@ -1740,7 +1747,8 @@ class Admin_AlbumControllerPostEditAlbumMesBDTest extends Admin_AlbumControllerT
'error' => 4];
$this->bd = Class_Album::find(43);
Class_CodifCentreInteret::newInstance(['id' => 381, 'libelle' => 'histoire'])->assertSave();
Class_CodifCentreInteret::newInstance(['id' => 119, 'libelle' => 'comics'])->assertSave();
$this->bd->setNotice(
$this->fixture('Class_Notice',
['id' => 72,
......@@ -1770,6 +1778,7 @@ class Admin_AlbumControllerPostEditAlbumMesBDTest extends Admin_AlbumControllerT
'matiere' => '5;6',
'dewey' => '15',
'genre' => '12',
'interet' => '381;119',
'cote' => 'MS003',
'droits' => '2',
'droits_precision' => 'GNU AFERO',
......@@ -1798,6 +1807,12 @@ class Admin_AlbumControllerPostEditAlbumMesBDTest extends Admin_AlbumControllerT
}
/** @test */
public function centreInteretShouldBeComicsAndHistoire() {
$this->assertEquals('381;119', $this->bd->getInteret());
}
/** @test */
function anneeShouldBe1998() {
$this->assertSame('1998', $this->bd->getAnnee());
......@@ -3587,7 +3602,6 @@ class Admin_AbstractControllerAlbumDeleteVignetteTest extends Admin_AlbumControl
]);
$this->_album->index();
$this->_file_system = $this->mock()
->whenCalled('unlink')->answers(true);
Class_Album::setFileSystem($this->_file_system);
......
......@@ -3913,3 +3913,20 @@ class UpgradeDB_412_Test extends UpgradeDBTestCase {
$this->assertFieldType('codif_genre', 'libelle', 'varchar(255)');
}
}
class UpgradeDB_413_Test extends UpgradeDBTestCase {
public function prepare() {
$this->silentQuery("alter table alter drop column interet");
}
/**
* @test
*/
public function albumInteretShouldBeTypeText() {
$this->assertFieldType('album', 'interet', 'text');
}
}
......@@ -498,6 +498,9 @@ class Class_Indexation_PseudoNoticeAlbumSummaryTest extends ModelTestCase {
public function setUp() {
parent::setUp();
Class_CodifCentreInteret::newInstance(['id' => 1, 'libelle' => 'world'])->assertSave();
Class_CodifCentreInteret::newInstance(['id' => 2, 'libelle' => 'versailles'])->assertSave();
$this->_album = $this->fixture('Class_Album',
[
'id' => 45,
......@@ -506,6 +509,7 @@ class Class_Indexation_PseudoNoticeAlbumSummaryTest extends ModelTestCase {
'sous_titre' => 'Le traite de Versailles',
'annee'=> 2017,
'notes' => 'a:8:{i:0;a:2:{s:5:"field";s:3:"210";s:4:"data";a:2:{i:0;a:2:{i:0;s:1:"c";i:1;s:19:"Editions Tallandier";}i:1;a:2:{i:0;s:1:"c";i:1;s:19:"Editions Tallandier";}}}i:1;a:2:{s:5:"field";s:3:"701";s:4:"data";a:1:{s:1:"a";s:24:"Jacques-Alain de Sédouy";}}i:2;a:2:{s:5:"field";s:2:"10";s:4:"data";a:1:{s:1:"a";s:13:"9791021028951";}}i:3;a:2:{s:5:"field";s:3:"856";s:4:"data";a:2:{s:1:"x";s:6:"poster";s:1:"a";s:81:"https://assets.edenlivres.fr/medias/c8/47e13cfde4723155a1c74873402957b23ca057.jpg";}}i:4;a:2:{s:5:"field";s:3:"856";s:4:"data";a:2:{s:1:"x";s:6:"poster";s:1:"a";s:90:"https://assets.edenlivres.fr/medias/c8/47e13cfde4723155a1c74873402957b23ca057.jpg?h=-&w=65";}}i:5;a:2:{s:5:"field";s:3:"856";s:4:"data";a:2:{s:1:"x";s:6:"poster";s:1:"a";s:91:"https://assets.edenlivres.fr/medias/c8/47e13cfde4723155a1c74873402957b23ca057.jpg?h=-&w=200";}}i:6;a:2:{s:5:"field";s:3:"856";s:4:"data";a:2:{s:1:"x";s:6:"poster";s:1:"a";s:92:"https://assets.edenlivres.fr/medias/c8/47e13cfde4723155a1c74873402957b23ca057.jpg?h=-&w=1000";}}i:7;a:2:{s:5:"field";s:3:"856";s:4:"data";a:2:{s:1:"x";s:12:"external_uri";s:1:"a";s:34:"https://www.edenlivres.fr/p/282139";}}}',
'interet' => '1;2',
'visible'=> True,
'status' => Class_Album::STATUS_VALIDATED,
'notice_id' => 258178
......@@ -523,6 +527,18 @@ class Class_Indexation_PseudoNoticeAlbumSummaryTest extends ModelTestCase {
public function pseudoNoticeResumeShouldBeMonTexteDeDescription() {
$this->assertEquals('Mon texte de description',Class_Notice::find(1)->get_subfield('330','a')[0]);
}
/** @test */
public function pseudoNoticeInteretFacetteShouldBeOneAndTwo() {
$this->assertContains('F1 F2', Class_Notice::find(1)->getFacettes());
}
/** @test */
public function pseudoNoticeInteretShoudBeWorldAndVersailles() {
$this->assertEquals(['world', 'versailles'], Class_Notice::find(1)->getCentreInteret());
}
}
......
Markdown is supported
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