diff --git a/VERSIONS_HOTLINE/115625 b/VERSIONS_HOTLINE/115625 new file mode 100644 index 0000000000000000000000000000000000000000..4b79e5cf6608a39e8542075965048a9bce7d0a04 --- /dev/null +++ b/VERSIONS_HOTLINE/115625 @@ -0,0 +1 @@ + - ticket #115625 : Moissonnage Openagenda MEL : Manque des champs \ No newline at end of file diff --git a/library/Class/ExternalAgenda/OpenAgenda.php b/library/Class/ExternalAgenda/OpenAgenda.php index f5f3f7a2307438c90201b54543b3e62dfb997839..8f115612eb56ea3ad8fdd7b5c402c991042f859a 100644 --- a/library/Class/ExternalAgenda/OpenAgenda.php +++ b/library/Class/ExternalAgenda/OpenAgenda.php @@ -60,7 +60,10 @@ class Class_ExternalAgenda_OpenAgenda extends Class_ExternalAgenda_Provider { return $this->_external_agenda ->newEvent() ->setTitre($event->getString('title')) - ->setContenu($event->getImageTagWithCredits().$event->getHtml().$event->getInfosTag()) + ->setContenu($event->getImageTagWithCredits() + .$event->getHtml() + .$event->getInfosTag() + .$event->getInscriptionsTag()) ->setIdOrigine($event->get('uid') . '_' . base64_encode($timing['start'])) ->setDescription($event->getImageTag().'<p>'.$event->getString('description').'</p>') ->setTags(implode(';', $event->getKeywords())) @@ -112,7 +115,41 @@ class Class_ExternalAgenda_OpenAgenda_Event { return '<p>' . $this->_('Infos pratiques :') . '</p><dl>' . $infos . '</dl>'; } - protected function _addInfoElement($label, $description){ + + public function getInscriptionsTag() { + $contacts = []; + + $type_mapping = [ + 'email' => $this->_('Courriel'), + 'phone' => $this->_('Téléphone'), + 'lien' => $this->_('Site') + ]; + + foreach ($this->getArray('registration') as $registration){ + $type = in_array($registration['type'], array_keys($type_mapping)) + ? $registration['type'] + : 'email'; + + if (!isset($registration['value']) + || !($registration['value'])) + continue; + + $contacts []= $this->_renderDtDd($type_mapping[$type], + $registration['value']); + } + + if ($url = $this->getString('registrationUrl')) + $contacts []= $this->_renderDtDd($this->_('Lien'), + $url); + + if (!$contacts) + return ''; + + return '<p>' . $this->_('Pour s\'inscrire :') . '</p><dl>' . implode('', $contacts) . '</dl>'; + } + + + protected function _renderDtDd($label, $description){ return '<dt>' . $label . '</dt>' . '<dd>' . $description . '</dd>'; } @@ -129,26 +166,24 @@ class Class_ExternalAgenda_OpenAgenda_Event { protected function _prepareConditionsString() { return ($conditions = $this->getString('conditions')) - ? $this->_addInfoElement( - $this->_('Conditions'), - $conditions) - : ""; + ? $this->_renderDtDd( + $this->_('Conditions'), + $conditions) + : ''; } protected function _prepareAgeString() { return ($this->_event['age']) - ? $this->_addInfoElement( - $this->_('Âge'), - $this->_('de %s à %s ans', - $this->_event['age']['min'], - $this->_event['age']['max'])) - : ""; + ? $this->_renderDtDd( + $this->_('Âge'), + $this->_('de %s à %s ans', + $this->_event['age']['min'], + $this->_event['age']['max'])) + : ''; } - - public function getString($name){ if (!(isset($this->_event[$name]) && $this->_event[$name])) return ''; diff --git a/tests/scenarios/ExternalAgendas/ExternalAgendasOpenAgendaTest.php b/tests/scenarios/ExternalAgendas/ExternalAgendasOpenAgendaTest.php index 572c63b31f37ce4ec8e4cea0eca9585dfc870767..cc2d119d193b8fc5bb9b0b6406cec90a792808f9 100644 --- a/tests/scenarios/ExternalAgendas/ExternalAgendasOpenAgendaTest.php +++ b/tests/scenarios/ExternalAgendas/ExternalAgendasOpenAgendaTest.php @@ -207,7 +207,7 @@ class ExternalAgendasOpenAgendaAdminTest extends Admin_AbstractControllerTestCas /** @test */ public function firstArticleImageShouldContainsHTMLAndImage() { - $this->assertEquals('<figure><img src="https://cibul.s3.amazonaws.com/9c3729cce33140c5a011056c8168ec5b.base.image.jpg" alt=""/><figcaption>Credits : moi</figcaption></figure><p>Voyons ça dans une session de coding dojo</p><p>Infos pratiques :</p><dl><dt>Conditions</dt><dd>être geek</dd><dt>Âge</dt><dd>de 6 à 99 ans</dd></dl>', + $this->assertEquals('<figure><img src="https://cibul.s3.amazonaws.com/9c3729cce33140c5a011056c8168ec5b.base.image.jpg" alt=""/><figcaption>Credits : moi</figcaption></figure><p>Voyons ça dans une session de coding dojo</p><p>Infos pratiques :</p><dl><dt>Conditions</dt><dd>être geek</dd><dt>Âge</dt><dd>de 6 à 99 ans</dd></dl><p>Pour s\'inscrire :</p><dl><dt>Courriel</dt><dd>llaffont@afi-sa.fr</dd><dt>Téléphone</dt><dd>0123456789</dd><dt>Site</dt><dd>https://www.website.org</dd><dt>Lien</dt><dd>https://registration.website.org/</dd></dl>', Class_Article::find(1)->getContenu()); } diff --git a/tests/scenarios/ExternalAgendas/open-agenda-1.json b/tests/scenarios/ExternalAgendas/open-agenda-1.json index 0a3068dea7612375a3e52a7eec40b92bbd893b43..e1d0fe0468f95aa312093e6a40a01d50ef128afd 100644 --- a/tests/scenarios/ExternalAgendas/open-agenda-1.json +++ b/tests/scenarios/ExternalAgendas/open-agenda-1.json @@ -51,7 +51,7 @@ "conditions": { "fr": "être geek" }, - "registrationUrl": "llaffont@afi-sa.fr", + "registrationUrl": "https://registration.website.org/", "locationName": "San pedro chez HDL", "locationUid": 91517332, "address": "San-Pédro", @@ -115,6 +115,14 @@ "value": "llaffont@afi-sa.fr", "type": "email", "prefix": "mailto:" + }, + { + "value": "0123456789", + "type": "phone" + }, + { + "value": "https://www.website.org", + "type": "lien" } ], "firstDate": "2019-11-25",