diff --git a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php index c69b3915a301f0f6a253bf71ba3087740d09917f..28540fe8eabab55d10228055e3bdadfb6ecebb5e 100644 --- a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php +++ b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php @@ -243,6 +243,12 @@ class Cosmo_DataProfileControllerEditUnimarcKohaFileFormatTest extends Cosmo_Dat } + /** @test */ + public function noveltyDaysShouldBe90() { + $this->assertXPath('//form//input[@name="nouveaute_jours"][@value="90"]'); + } + + /** @test */ public function itemCodebarreShouldBePresent() { $this->assertXPath('//form//select[@id="champ_code_barres"]/option[@value="f"][@selected]'); @@ -383,6 +389,8 @@ class Cosmo_DataProfileControllerPostEditUnimarcKohaFileFormatTest extends Cosmo 'nouveaute_champ' => [0 => '', 1 => 'a', 2 => ''], + 'nouveaute_valeurs' => ['nouveau', + 'new'], 'subscribers' => 'ORDREABON; ORDREABON', 'loans' => 'ID_PERGAME; ID_PERGAME', 'holds' => 'SUPPORT; SUPPORT', @@ -448,4 +456,39 @@ class Cosmo_DataProfileControllerPostEditUnimarcKohaFileFormatTest extends Cosmo $this->assertEquals('n', $this->_koha->getUrlField()); } + + /** @test */ + public function serialsRejectShouldBeOne() { + $this->assertEquals(1, $this->_koha->getRejetPeriodiques()); + } + + + /** @test */ + public function noveltyFormatShouldBe4() { + $this->assertEquals(4, $this->_koha->getNoveltyFormat()); + } + + + /** @test */ + public function noveltyDaysShouldBe80() { + $this->assertEquals(80, $this->_koha->getNoveltyDays()); + } + + + /** @test */ + public function noveltyLabelShouldBe932() { + $this->assertEquals(932, $this->_koha->getNoveltyLabel()); + } + + + /** @test */ + public function noveltyFieldShouldBeA() { + $this->assertEquals('a', $this->_koha->getNoveltyField()); + } + + + /** @test */ + public function noveltyValeursShouldBeNouveauAndNew() { + $this->assertEquals('nouveau;new', $this->_koha->getNoveltyValues()); + } } \ No newline at end of file diff --git a/library/Class/IntProfilDonnees.php b/library/Class/IntProfilDonnees.php index 6438adb4c5002d49e3b50507498d423cad9db54e..11891ad117da7aefa65047f15debab56222885f5 100644 --- a/library/Class/IntProfilDonnees.php +++ b/library/Class/IntProfilDonnees.php @@ -176,12 +176,12 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { FIELD_ITEM_AVAILABILITY = 'champ_availability', FIELD_ITEM_URL = 'champ_url', PROFILE_FIELDS = 'champs', - PROFILE_NOVELTY = 'jours', PROFILE_DOC_TYPES = 'type_doc', + PROFILE_NOVELTY = 'jours', NOVELTY_ZONE = 'zone', NOVELTY_FIELD = 'champ', NOVELTY_FORMAT = 'format', - NOVELTY_VALEURS = 'valeurs', + NOVELTY_VALUES = 'valeurs', XML_SUBSCRIBER_FIELD = 'xml_balise_abonne', XML_SUBSCRIBER_FIELDS = 'xml_champs_abonne'; @@ -739,11 +739,45 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { } + public function getUrlLabel() { + return $this->getProfilePrefs()->getItemUrl()['url_zone'][0]; + } + + + public function getUrlField() { + return $this->getProfilePrefs()->getItemUrl()['url_champ'][0]; + } + + + public function getNoveltyFormat() { + return $this->getProfilePrefs()->getItemNoveltyFormat(); + } + + + public function getNoveltyDays() { + return $this->getProfilePrefs()->getItemNoveltyDays(); + } + + + public function getNoveltyLabel() { + return $this->getProfilePrefs()->getItemNoveltyZoneAndField()['nouveaute_zone'][0]; + } + + + public function getNoveltyField() { + return $this->getProfilePrefs()->getItemNoveltyZoneAndField()['nouveaute_champ'][0]; + } + + + public function getNoveltyValues() { + return $this->getProfilePrefs()->getItemNoveltyPrefs()[Class_IntProfilDonnees::NOVELTY_VALUES]; + } + + public function getProfilePrefs() { if(!$this->_profile_prefs) $this->_profile_prefs = (new Class_ProfilePrefs())->setDatas($this->toArray()); return $this->_profile_prefs; } } - ?> \ No newline at end of file diff --git a/library/Class/ProfilePrefs.php b/library/Class/ProfilePrefs.php index 48fd06b4548c709d98737993144ba1d21136e4e3..54729df3ea082a688723c9987f18d9314f5f6989 100644 --- a/library/Class/ProfilePrefs.php +++ b/library/Class/ProfilePrefs.php @@ -149,8 +149,13 @@ class Class_ProfilePrefs extends Class_Entity { } + public function getItemNoveltyDays() { + return $this->getItemNoveltyPrefs()[Class_IntProfilDonnees::PROFILE_NOVELTY]; + } + + public function getItemNoveltyValeurs() { - $valeurs = $this->getItemNoveltyPrefs()[Class_IntProfilDonnees::NOVELTY_VALEURS]; + $valeurs = $this->getItemNoveltyPrefs()[Class_IntProfilDonnees::NOVELTY_VALUES]; $valeurs = array_filter(explode(';', $valeurs)); return ['nouveaute_valeurs' => $valeurs]; } @@ -210,11 +215,13 @@ class Class_ProfilePrefs extends Class_Entity { foreach($prefs as $pref) { if((!$pref) || (!is_array($pref))) - return []; + continue; if(array_key_exists($included_key, $pref)) return $pref; } + + return []; } diff --git a/library/Class/ProfileSerializer.php b/library/Class/ProfileSerializer.php index 61d77c4b22c0c0d2fae4a1e2ee5a642da20eecf3..00e763afea7734f679df7010eb7dd45b97c9ec68 100644 --- a/library/Class/ProfileSerializer.php +++ b/library/Class/ProfileSerializer.php @@ -30,26 +30,19 @@ class Class_ProfileSerializer { } public function serializeDatas() { - $data = []; - $data[] = $this->extractRecords(); - $data[] = $this->extractSubscribers(); - $data[] = $this->extractCarts(); - $data[] = $this->extractLoans(); - $data[] = $this->extractHolds(); - - return serialize($data); + $datas = [$this->extractRecords(), + $this->extractNovelty(), + $this->extractSubscribers(), + $this->extractCarts(), + $this->extractLoans(), + $this->extractHolds()]; + + return serialize($datas); } public function extractRecords() { - $datas = array_merge($this->extractDocTypes(), $this->extractItemFields(), $this->extractItemUrl()); - return $datas; - -/* $this->extractDocTypes(), */ -/* $this->extractItemFields(), */ -/* $this->extractSerialFields(), */ -/* $this->extractInterestFields(), */ -/* $this->extractNoveltyfields()]; */ + return array_merge($this->extractDocTypes(), $this->extractItemFields(), $this->extractItemUrl()); } @@ -59,29 +52,38 @@ class Class_ProfileSerializer { public function extractItemUrl() { - return [Class_IntProfilDonnees::FIELD_ITEM_URL => []]; + return [Class_IntProfilDonnees::FIELD_ITEM_URL => ['zone' => $this->_datas['url_zone'][1], + 'champ' => $this->_datas['url_champ'][1]]]; } public function extractItemFields() { - $datas = array_intersect_key($this->_datas, Class_IntProfilDonnees::getItemFields()); - xdebug_break(); - return $datas; + return array_intersect_key($this->_datas, Class_IntProfilDonnees::getItemFields()); } - public function extractSerialFields() { + public function extractInterestFields() { } - public function extractInterestFields() { - + public function extractNovelty() { + return [Class_IntProfilDonnees::PROFILE_NOVELTY => $this->_datas['nouveaute_jours'], + Class_IntProfilDonnees::NOVELTY_ZONE => $this->_datas['nouveaute_zone'][1], + Class_IntProfilDonnees::NOVELTY_FIELD => $this->_datas['nouveaute_champ'][1], + Class_IntProfilDonnees::NOVELTY_FORMAT => $this->_datas['nouveaute_format'], + Class_IntProfilDonnees::NOVELTY_VALUES => $this->extractNoveltyValues()]; } - public function extractNoveltyFields() { + public function extractNoveltyValues() { + if(!isset($this->_datas['nouveaute_valeurs'])) + return []; + + if(!is_array($this->_datas['nouveaute_valeurs'])) + return []; + return implode(';', $this->_datas['nouveaute_valeurs']); } diff --git a/library/ZendAfi/Form/Cosmo/DataProfile.php b/library/ZendAfi/Form/Cosmo/DataProfile.php index fe8be9f58b034e707ae1c06cf2b0d9707463332a..e48bb963f217e5a6861cdcb622a90d4f0e31a25b 100644 --- a/library/ZendAfi/Form/Cosmo/DataProfile.php +++ b/library/ZendAfi/Form/Cosmo/DataProfile.php @@ -37,6 +37,7 @@ class ZendAfi_Form_Cosmo_DataProfile extends ZendAfi_Form { ->populateItemAvailability() ->populateItemNoveltyZoneAndField() ->populateItemNoveltyFormat() + ->populateItemNoveltyDays() ->populateItemNoveltyValeurs() ->populateItemDocTypes() ->populateItemUrl() @@ -367,6 +368,12 @@ class ZendAfi_Form_Cosmo_DataProfile extends ZendAfi_Form { } + public function populateItemNoveltyDays() { + $this->nouveaute_jours->setValue($this->_profile_prefs->getItemNoveltyDays()); + return $this; + } + + public function populateItemNoveltyValeurs() { $this->nouveaute_valeurs->setValues($this->_profile_prefs->getItemNoveltyValeurs()); return $this;