Skip to content
Snippets Groups Projects
Commit 5a1d3105 authored by Laurent's avatar Laurent
Browse files

Merge branch 'hotline#115625_moissonnage_openagenda_mel_manque_des_champs' into 'hotline'

hotline#115625: External : Import openAgenda improvements : registration informations

See merge request !3631
parents 5e42aed8 ac2acf9d
Branches
Tags
1 merge request!3631hotline#115625: External : Import openAgenda improvements : registration informations
Pipeline #11087 passed with stage
in 46 minutes and 3 seconds
- ticket #115625 : Moissonnage Openagenda MEL : Manque des champs
\ No newline at end of file
......@@ -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 '';
......
......@@ -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());
}
......
......@@ -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",
......
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