From 13824ed233a3835450c6834b4dc6fe8b92a7e2f9 Mon Sep 17 00:00:00 2001 From: Ghislain Loas <ghislo@sandbox.pergame.net> Date: Fri, 25 Mar 2016 17:34:32 +0100 Subject: [PATCH] dev #35088 implementing POST --- .../controllers/DataProfileController.php | 7 +- .../controllers/DataProfileControllerTest.php | 64 ++++++--- library/Class/IntProfilDonnees.php | 42 ++++-- library/Class/ProfilePrefs.php | 132 +++++++++++++++--- library/Class/ProfileSerializer.php | 107 ++++++++++++++ library/ZendAfi/Form/Cosmo/DataProfile.php | 86 +++++++++--- 6 files changed, 363 insertions(+), 75 deletions(-) create mode 100644 library/Class/ProfileSerializer.php diff --git a/cosmogramme/cosmozend/application/modules/cosmo/controllers/DataProfileController.php b/cosmogramme/cosmozend/application/modules/cosmo/controllers/DataProfileController.php index f1a0a3c136e..47a21166ff4 100644 --- a/cosmogramme/cosmozend/application/modules/cosmo/controllers/DataProfileController.php +++ b/cosmogramme/cosmozend/application/modules/cosmo/controllers/DataProfileController.php @@ -45,7 +45,7 @@ class Cosmo_DataProfileController extends ZendAfi_Controller_Action { if (!$this->_request->isPost()) return false; - $values = $form->getValues(); + $values = $this->_getPost(); $attributes_values = $this->_extractAttributesFrom($values); $model->updateAttributes($attributes_values); @@ -69,8 +69,8 @@ class Cosmo_DataProfileController extends ZendAfi_Controller_Action { protected function _extractProfilePrefsFrom($values) { - $prefs = array_diff_key(Class_IntProfilDonnees::getClassVar('_default_attribute_values'), $values); - return 'a:3:{i:0;a:1:{s:8:"type_doc";a:0:{}}i:1;a:0:{}i:2;a:0:{}}'; + $prefs = array_diff_key($values, Class_IntProfilDonnees::getClassVar('_default_attribute_values')); + return (new Class_ProfileSerializer($prefs))->serializeDatas(); } @@ -78,6 +78,5 @@ class Cosmo_DataProfileController extends ZendAfi_Controller_Action { return sprintf('/cosmo/%s/edit/id/%s', $this->_request->getControllerName(), $model->getId()); } - } ?> \ No newline at end of file diff --git a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php index 822f86c9c3c..ed314b736bc 100644 --- a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php +++ b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php @@ -144,12 +144,6 @@ class Cosmo_DataProfileControllerEditUnimarcKohaFileFormatTest extends Cosmo_Dat } - /** @test */ - public function fieldIdSubscribersShouldBeEmpty() { - $this->assertXPath('//form//input[@id="subscribers"][@value=""]'); - } - - /** @test */ public function loanFieldIdAbonShouldBeDraggable() { $this->assertXPathContentContains('//form//ul//li', 'id abonné', $this->_response->getBody()); @@ -157,44 +151,50 @@ class Cosmo_DataProfileControllerEditUnimarcKohaFileFormatTest extends Cosmo_Dat /** @test */ - public function inputXmlBaliseAbonneShouldBePresent() { - $this->assertXPath('//form//input[@id="xml_balise_abonne"]'); + public function inputXmlBaliseAbonneShouldBeSubscribers() { + $this->assertXPath('//form//input[@id="xml_balise_abonne"][@value="subscribers"]'); } /** @test */ public function inputXmlBaliseIDABONShouldBePresent() { - $this->assertXPath('//form//input[@id="xml_abonne_IDABON"]'); + $this->assertXPath('//form//input[@id="xml_abonne_IDABON"][@value="id_abon"]', $this->_response->getBody()); } /** @test */ public function inputXmlBaliseDateDebutShouldBePresent() { - $this->assertXPath('//form//input[@id="xml_abonne_DATE_DEBUT"]'); + $this->assertXPath('//form//input[@id="xml_abonne_DATE_DEBUT"][@value="subscription_date"]'); + } + + + /** @test */ + public function subscribersShouldBePrenomAndNaissance() { + $this->assertXPath('//form//input[@name="subscribers"][@value="PRENOM; NAISSANCE"]'); } /** @test */ public function fieldIdLoansShouldBeEmpty() { - $this->assertXPath('//form//input[@id="loans"][@value=""]'); + $this->assertXPath('//form//input[@id="loans"][@value="PRENOM; NAISSANCE"]'); } /** @test */ public function fieldIdHoldsShouldBeEmpty() { - $this->assertXPath('//form//input[@id="holds"][@value=""]'); + $this->assertXPath('//form//input[@id="holds"][@value="PRENOM; NAISSANCE"]'); } /** @test */ public function fieldIdCartShouldBeEmpty() { - $this->assertXPath('//form//input[@id="carts"][@value=""]'); + $this->assertXPath('//form//input[@id="carts"][@value="PRENOM; NAISSANCE"]'); } /** @test */ public function fieldIdLightRecordsShouldBeEmpty() { - $this->assertXPath('//form//input[@id="light_records"][@value=""]'); + $this->assertXPath('//form//input[@id="light_records"][@value="PRENOM; NAISSANCE"]'); } @@ -288,12 +288,24 @@ class Cosmo_DataProfileControllerEditUnimarcKohaFileFormatTest extends Cosmo_Dat } + /** @test */ + public function itemUrlShouldBe995AndI() { + $this->assertXPathContentContains('//script', 'values:{"url_zone":["995"],"url_champ":["i"]}'); + } + + /** @test */ public function multiInputInteretZoneShouldBePresent() { $this->assertXPath('//form//div[@id="multi_inputs_interet_zone"]'); } + /** @test */ + public function interestShouldBeTakeIn995AndZ() { + $this->assertXPathContentContains('//script', 'values:{"interest_zone":["995"],"interest_champ":["z"]}'); + } + + /** @test */ public function selectRejetPeriodiquesShoudBePresent() { $this->assertXPath('//form//select[@id="rejet_periodiques"]/option[@value="0"][@selected]'); @@ -320,7 +332,7 @@ class Cosmo_DataProfileControllerEditUnimarcKohaFileFormatTest extends Cosmo_Dat /** @test */ public function docTypeBookShouldBeAmNaLivLivjLivaDocManuel() { - $this->assertXPathContentContains('//script', 'values:{"item_doc_type_label":["am","na"],"item_doc_type_zone":["LIV","LIVJ","LIVA","DOC","MANUEL"]}'); + $this->assertXPathContentContains('//script', 'values:{"1_label":["am","na"],"1_zone":["LIV","LIVJ","LIVA","DOC","MANUEL"]}', $this->_response->getBody()); } } @@ -338,10 +350,6 @@ class Cosmo_DataProfileControllerPostEditUnimarcKohaFileFormatTest extends Cosmo 'format' => Class_IntProfilDonnees::FORMAT_CSV, 'xml_balise_abonne' => 'subscribers', 'xml_abonne_IDABON' => 'id', - 'subscribers' => 'ORDREABON; ORDREABON', - 'loans' => 'ID_PERGAME; ID_PERGAME', - 'holds' => 'SUPPORT; SUPPORT', - 'light_records' => 'ean;ean', 'champ_code_barres'=> 'f', 'champ_cote' => 'k', 'champ_type_doc' => 'x', @@ -354,6 +362,16 @@ class Cosmo_DataProfileControllerPostEditUnimarcKohaFileFormatTest extends Cosmo 'id_article_periodique' => 1, 'nouveaute_format' => 4, 'nouveaute_jours' => 80, + 'nouveaute_zone' => [0 => '', + 1 => '932', + 2 => ''], + 'nouveaute_champ' => [0 => '', + 1 => 'a', + 2 => ''], + 'subscribers' => 'ORDREABON; ORDREABON', + 'loans' => 'ID_PERGAME; ID_PERGAME', + 'holds' => 'SUPPORT; SUPPORT', + 'light_records' => 'ean;ean', 'carts' => 'LIBELLE; ROLE']; $this->postDispatch('cosmo/data-profile/edit/id/1', $post, true); @@ -376,4 +394,10 @@ class Cosmo_DataProfileControllerPostEditUnimarcKohaFileFormatTest extends Cosmo public function accentsShouldBeISO2709() { $this->assertEquals(Class_IntProfilDonnees::ENCODING_ISO2709, Class_IntProfilDonnees::find(1)->getAccents()); } -} + + + /** @test */ + public function xmlBaliseAbonneShouldBeSubscribers() { + $this->assertEquals('subscribers', Class_IntProfilDonnees::find(1)->getXmlBaliseAbonne()); + } +} \ No newline at end of file diff --git a/library/Class/IntProfilDonnees.php b/library/Class/IntProfilDonnees.php index d0cf79384d7..4d2437de917 100644 --- a/library/Class/IntProfilDonnees.php +++ b/library/Class/IntProfilDonnees.php @@ -162,13 +162,15 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { FIELD_ITEM_ANNEXE = 'champ_annexe', FIELD_ITEM_AVAILABILITY = 'champ_availability', FIELD_ITEM_URL = 'champ_url', - PROFILE_PREFS_ITEMS = 0, - PROFILE_PREFS_ITEMS_NEWS_DATE = 1, + PROFILE_FIELDS = 'champs', + PROFILE_NOVELTY = 'jours', PROFILE_DOC_TYPES = 'type_doc', - NEWS_ZONE = 'zone', - NEWS_FIELD = 'champ', - NEWS_FORMAT = 'format', - NEWS_VALEURS = 'valeurs'; + NOVELTY_ZONE = 'zone', + NOVELTY_FIELD = 'champ', + NOVELTY_FORMAT = 'format', + NOVELTY_VALEURS = 'valeurs', + XML_SUBSCRIBER_FIELD = 'xml_balise_abonne', + XML_SUBSCRIBER_FIELDS = 'xml_champs_abonne'; protected $_table_name = 'profil_donnees', @@ -179,8 +181,8 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { 'rejet_periodiques' => 0, 'id_article_periodique' => 0, 'type_fichier' => 0, - 'format' => 0, - 'attributs' => 'a:3:{i:0;a:1:{s:8:"type_doc";a:0:{}}i:1;a:0:{}i:2;a:0:{}}']; + 'format' => 0]; + protected $_profile_prefs; public static function forNanook() { @@ -373,13 +375,21 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { self::FIELD_ITEM_GENRE => '', self::FIELD_ITEM_SECTION => 'q', self::FIELD_ITEM_EMPLACEMENT => 'e', - self::FIELD_ITEM_ANNEXE => 'b' + self::FIELD_ITEM_ANNEXE => 'b', + self::FIELD_ITEM_URL => ['zone' => '995', + 'champ' => 'i'] ], ['zone' => '801', 'champ' => 'c', 'format' => self::NOVELTY_DATE_FORMAT_AAAA_MM_JJ, 'jours' => '90', - 'valeurs' => 'nouveau;new'] + 'valeurs' => 'nouveau;new'], + ['xml_balise_abonne' => 'subscribers', + 'xml_champs_abonne' => ['IDABON' => 'id_abon', + 'DATE_DEBUT' => 'subscription_date'], + 'champs' => 'PRENOM; NAISSANCE'], + ['zone' => '995', + 'champ' => 'z'] ] ] ); @@ -694,6 +704,18 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract { public function getFiletypeLabel() { return $this->getLoader()->getFileTypes()[$this->getTypeFichier()]; } + + + public function getXmlBaliseAbonne() { + return $this->getProfilePrefs()->getSubscriberXmlField(); + } + + + 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 0d4b729dda5..48fd06b4548 100644 --- a/library/Class/ProfilePrefs.php +++ b/library/Class/ProfilePrefs.php @@ -21,6 +21,7 @@ class Class_ProfilePrefs extends Class_Entity { + public function getItemBarCode() { return $this->getItemPrefs()[Class_IntProfilDonnees::FIELD_ITEM_BARCODE]; } @@ -61,51 +62,120 @@ class Class_ProfilePrefs extends Class_Entity { } - public function getItemNewsZoneAndField() { - $zone_value = $this->getItemNewsZone(); - $champ_value = $this->getItemNewsField(); + public function getSubscriberXmlField() { + return $this->getPrefsXml()[Class_IntProfilDonnees::XML_SUBSCRIBER_FIELD]; + } + + + public function getSubscriberFields() { + return $this->getPrefsXml()[Class_IntProfilDonnees::PROFILE_FIELDS]; + } + + + public function getSubscriberXmlFieldValue($key) { + return $this->getPrefsXmlFields()[$key]; + } + + + public function getPrefsXmlFields() { + return $this->getPrefsXml()[Class_IntProfilDonnees::XML_SUBSCRIBER_FIELDS]; + } + + + public function getItemNoveltyZoneAndField() { + $zone_value = $this->getItemNoveltyZone(); + $champ_value = $this->getItemNoveltyField(); return ['nouveaute_zone' => [$zone_value], 'nouveaute_champ' => [$champ_value]]; } - public function getItemNewsZone() { - return $this->getItemNewsPrefs()[Class_IntProfilDonnees::NEWS_ZONE]; + public function getItemNoveltyZone() { + return $this->getItemNoveltyPrefs()[Class_IntProfilDonnees::NOVELTY_ZONE]; } - public function getItemNewsField() { - return $this->getItemNewsPrefs()[Class_IntProfilDonnees::NEWS_FIELD]; + public function getItemNoveltyField() { + return $this->getItemNoveltyPrefs()[Class_IntProfilDonnees::NOVELTY_FIELD]; } - public function getItemNewsFormat() { - return $this->getItemNewsPrefs()[Class_IntProfilDonnees::NEWS_FORMAT]; + public function getInterests() { + $interet_prefs = $this->getInterestPrefs(); + $interet_zone = $interet_prefs['zone']; + $interet_champ = $interet_prefs['champ']; + + return ['interest_zone' => [$interet_zone], + 'interest_champ' => [$interet_champ]]; + } + + + public function getInterestPrefs() { + if(!$prefs = $this->getPrefs()) + return []; + + foreach($prefs as $pref) { + if((!$pref) || (!is_array($pref))) + return []; + + if(array_key_exists('zone', $pref) && array_key_exists('champ', $pref) && (2 == count($pref))) + return $pref; + } + } + + + public function getItemUrl() { + $url_zone = $this->getItemUrlZone(); + $url_champ = $this->getItemUrlChamp(); + + return ['url_zone' => [$url_zone], + 'url_champ' => [$url_champ]]; } - public function getItemNewsValeurs() { - $valeurs = $this->getItemNewsPrefs()[Class_IntProfilDonnees::NEWS_VALEURS]; + public function getItemUrlZone() { + return $this->getItemUrlPrefs()['zone']; + } + + + public function getItemUrlChamp() { + return $this->getItemUrlPrefs()['champ']; + } + + + public function getItemNoveltyFormat() { + return $this->getItemNoveltyPrefs()[Class_IntProfilDonnees::NOVELTY_FORMAT]; + } + + + public function getItemNoveltyValeurs() { + $valeurs = $this->getItemNoveltyPrefs()[Class_IntProfilDonnees::NOVELTY_VALEURS]; $valeurs = array_filter(explode(';', $valeurs)); return ['nouveaute_valeurs' => $valeurs]; } public function getItemDocTypeSettings($id) { - $all_doc_types = $this->getDocTypesPrefs(); + if(!$all_doc_types = $this->getDocTypesPrefs()) + return [$id . '_label' => [], + $id . '_zone' => []]; + foreach($all_doc_types as $doc_type_pref) { if($id == $doc_type_pref['code']) return $this->_buildDocTypeForMultiInput($doc_type_pref); } - return ['item_doc_type_label' => [], - 'item_doc_type_zone' => []]; } protected function _buildDocTypeForMultiInput($pref) { - return ['item_doc_type_label' => array_filter(explode(';', $pref['label'])), - 'item_doc_type_zone' => array_filter(explode(';', $pref['zone_995']))]; + return [$pref['code'] . '_label' => array_filter(explode(';', $pref['label'])), + $pref['code'] . '_zone' => array_filter(explode(';', $pref['zone_995']))]; + } + + + public function getUnknownFields() { + return $this->getPrefsFor(Class_IntProfilDonnees::PROFILE_FIELDS)[Class_IntProfilDonnees::PROFILE_FIELDS]; } @@ -114,13 +184,37 @@ class Class_ProfilePrefs extends Class_Entity { } + public function getItemUrlPrefs() { + return $this->getItemPrefs()[Class_IntProfilDonnees::FIELD_ITEM_URL]; + } + + + public function getPrefsXML() { + return $this->getPrefsFor(Class_IntProfilDonnees::XML_SUBSCRIBER_FIELD); + } + + public function getItemPrefs() { - return $this->getPrefs()[Class_IntProfilDonnees::PROFILE_PREFS_ITEMS]; + return $this->getPrefsFor(Class_IntProfilDonnees::PROFILE_DOC_TYPES); } - public function getItemNewsPrefs() { - return $this->getPrefs()[Class_IntProfilDonnees::PROFILE_PREFS_ITEMS_NEWS_DATE]; + public function getItemNoveltyPrefs() { + return $this->getPrefsFor(Class_IntProfilDonnees::PROFILE_NOVELTY); + } + + + public function getPrefsFor($included_key) { + if(!$prefs = $this->getPrefs()) + return []; + + foreach($prefs as $pref) { + if((!$pref) || (!is_array($pref))) + return []; + + if(array_key_exists($included_key, $pref)) + return $pref; + } } diff --git a/library/Class/ProfileSerializer.php b/library/Class/ProfileSerializer.php new file mode 100644 index 00000000000..6ed39c03d71 --- /dev/null +++ b/library/Class/ProfileSerializer.php @@ -0,0 +1,107 @@ +<?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_ProfileSerializer { + protected $_datas; + + + public function __construct($datas) { + $this->_datas = $datas; + } + + public function serializeDatas() { + $data = []; + $data[] = $this->extractRecords(); + $data[] = $this->extractSubscribers(); + $data[] = $this->extractCarts(); + $data[] = $this->extractLoans(); + $data[] = $this->extractHolds(); + + return serialize($data); + } + + + public function extractRecords() { + return [$this->extractDocTypes(), + $this->extractItemFields(), + $this->extractSerialFields(), + $this->extractInterestFields(), + $this->extractNoveltyfields()]; + } + + + public function extractDocTypes() { + + } + + + public function extractItemFields() { + + } + + + public function extractSerialFields() { + + } + + + public function extractInterestFields() { + + } + + + public function extractNoveltyFields() { + + } + + + public function extractSubscribers() { + return [$this->extractXmlSubscriber(), + $this->extractSubscriberFields()]; + } + + + public function extractCarts() { + + } + + + public function extractLoans() { + + } + + + public function extractHolds() { + + } + + + public function extractXmlSubscriber() { + + } + + + public function extractSubscriberFields() { + + } +} +?> \ No newline at end of file diff --git a/library/ZendAfi/Form/Cosmo/DataProfile.php b/library/ZendAfi/Form/Cosmo/DataProfile.php index f25cb70f64f..fe8be9f58b0 100644 --- a/library/ZendAfi/Form/Cosmo/DataProfile.php +++ b/library/ZendAfi/Form/Cosmo/DataProfile.php @@ -35,10 +35,14 @@ class ZendAfi_Form_Cosmo_DataProfile extends ZendAfi_Form { ->populateItemEmplacement() ->populateItemAnnexe() ->populateItemAvailability() - ->populateItemNewsZoneAndField() - ->populateItemNewsFormat() - ->populateItemNewsValeurs() - ->populateItemDocTypes(); + ->populateItemNoveltyZoneAndField() + ->populateItemNoveltyFormat() + ->populateItemNoveltyValeurs() + ->populateItemDocTypes() + ->populateItemUrl() + ->populateXmlSubribers() + ->populateFields() + ->populateInterest(); return $form; } @@ -109,7 +113,7 @@ class ZendAfi_Form_Cosmo_DataProfile extends ZendAfi_Form { $fields = Class_IntProfilDonnees::getSubscriberFields(); foreach($fields as $key => $field) { - $id = 'xml_abonne_' . strtoupper($key); + $id = 'xml_abonne_' . trim(strtoupper($key)); $this->addElement('text', $id, ['label' => $field]); @@ -119,7 +123,7 @@ class ZendAfi_Form_Cosmo_DataProfile extends ZendAfi_Form { return $this ->addElement('text', 'xml_balise_abonne', - ['label' => $this->_('Balise abonné (sans les crochets')]) + ['label' => $this->_('Balise abonné (sans les crochets)')]) ->_addDraggable('subscribers', Class_IntProfilDonnees::getSubscriberFields()) @@ -154,7 +158,7 @@ class ZendAfi_Form_Cosmo_DataProfile extends ZendAfi_Form { ->_recordItemDocType() ->_recordItemSerial() ->_recordItemInterest() - ->_recordNewsDate(); + ->_recordNoveltyDate(); } @@ -177,8 +181,8 @@ class ZendAfi_Form_Cosmo_DataProfile extends ZendAfi_Form { return $this->addElement('multiInput', $id, ['label' => $doc_type->getLabel(), - 'fields' => [['name' => 'item_doc_type_label', 'label' => $this->_('label')], - ['name' => 'item_doc_type_zone', 'label' => $this->_('Zone')]]]); + 'fields' => [['name' => $doc_type->getId() . '_label', 'label' => $this->_('label')], + ['name' => $doc_type->getId() . '_zone', 'label' => $this->_('Zone')]]]); } @@ -204,10 +208,10 @@ class ZendAfi_Form_Cosmo_DataProfile extends ZendAfi_Form { return $this->addElement('multiInput', 'interet_zone', ['label' => $this->_('Prendre la zone centre d\'intérêts en'), - 'fields' => [['name' => 'nouveaute_zone', 'label' => $this->_('Zone')], - ['name' => 'nouveaute_champ', 'label' => $this->_('champ')]], - 'values' => ['nouveaute_zone' => ['932'], - 'nouveaute_champ' => ['a']], + 'fields' => [['name' => 'interest_zone', 'label' => $this->_('Zone')], + ['name' => 'interest_champ', 'label' => $this->_('champ')]], + 'values' => ['interest_zone' => ['932'], + 'interest_champ' => ['a']], 'fixed' => true]) ->addDisplayGroup(['interet_zone'], @@ -237,8 +241,8 @@ class ZendAfi_Form_Cosmo_DataProfile extends ZendAfi_Form { ->addElement('multiInput', 'item_url', ['label' => $this->_('Prendre l\'url en'), - 'fields' => [['name' => 'nouveaute_zone', 'label' => $this->_('Zone')], - ['name' => 'nouveaute_champ', 'label' => $this->_('champ')]], + 'fields' => [['name' => 'url_zone', 'label' => $this->_('Zone')], + ['name' => 'url_champ', 'label' => $this->_('champ')]], 'fixed' => true]) ->_addElementsWithAllFields($elements_with_all_fields) @@ -262,7 +266,7 @@ class ZendAfi_Form_Cosmo_DataProfile extends ZendAfi_Form { } - protected function _recordNewsDate() { + protected function _recordNoveltyDate() { return $this->addElement('text', 'nouveaute_jours', ['label' => 'Ajouter des jours']) @@ -351,20 +355,20 @@ class ZendAfi_Form_Cosmo_DataProfile extends ZendAfi_Form { } - public function populateItemNewsZoneAndField() { - $this->nouveaute_zone_champ->setValues($this->_profile_prefs->getItemNewsZoneAndField()); + public function populateItemNoveltyZoneAndField() { + $this->nouveaute_zone_champ->setValues($this->_profile_prefs->getItemNoveltyZoneAndField()); return $this; } - public function populateItemNewsFormat() { - $this->nouveaute_format->setValue($this->_profile_prefs->getItemNewsFormat()); + public function populateItemNoveltyFormat() { + $this->nouveaute_format->setValue($this->_profile_prefs->getItemNoveltyFormat()); return $this; } - public function populateItemNewsValeurs() { - $this->nouveaute_valeurs->setValues($this->_profile_prefs->getItemNewsValeurs()); + public function populateItemNoveltyValeurs() { + $this->nouveaute_valeurs->setValues($this->_profile_prefs->getItemNoveltyValeurs()); return $this; } @@ -381,6 +385,44 @@ class ZendAfi_Form_Cosmo_DataProfile extends ZendAfi_Form { } + public function populateXmlSubribers() { + $this->xml_balise_abonne->setValue($this->_profile_prefs->getSubscriberXmlField()); + $this->subscribers->setValue($this->_profile_prefs->getSubscriberFields()); + + $xml_fields = Class_IntProfilDonnees::getSubscriberFields(); + + foreach($xml_fields as $key => $field) { + $key = trim(strtoupper($key)); + $element_id = 'xml_abonne_' . $key; + $this->$element_id->setValue($this->_profile_prefs->getSubscriberXmlFieldValue($key)); + } + + return $this; + } + + + public function populateFields() { + $unknown_fields = $this->_profile_prefs->getUnknownFields(); + $this->loans->setValue($unknown_fields); + $this->holds->setValue($unknown_fields);; + $this->light_records->setValue($unknown_fields); + $this->carts->setValue($unknown_fields); + return $this; + } + + + public function populateItemUrl() { + $this->item_url->setValues($this->_profile_prefs->getItemUrl()); + return $this; + } + + + public function populateInterest() { + $this->interet_zone->setValues($this->_profile_prefs->getInterests()); + return $this; + } + + public function setProfilePrefs($preferences) { $this->_profile_prefs = $preferences; } -- GitLab