Skip to content
Snippets Groups Projects
Commit 83943db8 authored by efalcy's avatar efalcy
Browse files

dev #65273: export agenda ICAL : add dates, location, summary, description

parent e4749f7f
Branches
Tags
3 merge requests!2409Master,!2399Dev#65273 s91 contractuel cavy export des articles agenda en json,!2392Dev#65273 s91 contractuel cavy export des articles agenda en json
Pipeline #2787 failed with stage
in 21 minutes and 15 seconds
'65273' =>
['Label' => $this->_('[CONTRACTUEL CAVY] Export des articles agenda en ICAL'),
'Desc' => '',
'Image' => '',
'Video' => '',
'Category' => '',
'Right' => function($feature_description, $user) {return true;},
'Wiki' => '',
'Test' => '',
'Date' => '2017-11-07'],
\ No newline at end of file
- ticket #65273 : Export des articles agenda en format ICAL
\ No newline at end of file
......@@ -170,7 +170,7 @@ class CmsController extends ZendAfi_Controller_Action {
public function icalAction() {
$id_profil = (int)$this->_getParam('id_profil');
$id_profil = (int)$this->_getParam('id_profil',1);
$id_module = (int)$this->_getParam('id_module');
$this->_helper->renderIcal($id_profil, $id_module, $this->view);
}
......
......@@ -34,6 +34,7 @@ class ZendAfi_Controller_Action_Helper_RenderIcal
return $this->_render();
$articles = Class_Calendar::getAllNextEventsByPref($preferences);
$this->_render($articles);
}
......@@ -62,10 +63,13 @@ class ZendAfi_Controller_Action_Helper_RenderIcal
protected function _eventFrom($article, $vCalendar) {
$vEvent = new \Eluceo\iCal\Component\Event(Class_Url::absolute([], null, true) . '//' . $article->getId());
$vEvent->setDtStart(new DateTime($article->getDebut()));
$vEvent->setDtEnd(new DateTime($article->getFin()));
$vEvent->setDtStart(new DateTime($article->getEventsDebut()));
$vEvent->setDtEnd(new DateTime($article->getEventsFin()));
$vEvent->setSummary($article->getTitre());
//$vEvent->setCategories(['holidays']);
$vEvent->setCategories($article->getCategorieLibelle());
$vEvent->setLocation($article->getLieuLibelle());
$vEvent->setDescription($article->getFullContent());
$vEvent->setUseTimezone(true);
......
......@@ -63,6 +63,44 @@ abstract class CmsControllerCalendarActionTestCase extends AbstractControllerTes
->answers([$this->_nanook2]);
}
public function setupCustomFields() {
Class_CustomField_Meta::beVolatile();
$theme = $this->fixture('Class_CustomField',
['id' => 2,
'priority' => 3,
'label' => 'Theme',
'field_type' => Class_CustomField_Meta::SELECT,
'options_list' => 'sigb;opac',
'model' => 'Article']);
$multi_options = $this->fixture('Class_CustomField',
['id' => 20,
'priority' => 3,
'label' => 'Options',
'field_type' => Class_CustomField_Meta::MULTI_CHECKBOX,
'options_list' => 'wifi;restauration;projection',
'model' => 'Article']);
$this->fixture('Class_CustomField_Value',
['id' => 59,
'custom_field_id' => $theme->getId(),
'model_id' => $this->_nanook2->getId(),
'value' => 'sigb']);
$this->fixture('Class_CustomField_Value',
['id' => 5,
'custom_field_id' => $multi_options->getId(),
'model_id' => $this->_nanook2->getId(),
'value' => 'wifi;restauration']);
$this->fixture('Class_CustomField_Value',
['id' => 2,
'custom_field_id' => $theme->getId(),
'model_id' => $this->_opac4->getId(),
'value' => 'opac']);
}
function tearDown() {
Class_AdminVar::getLoader()->find('CACHE_ACTIF')->setValeur('0');
......@@ -252,44 +290,6 @@ class CmsControllerCalendarActionWithFiltersTest extends CmsControllerCalendarAc
protected $_opac4;
protected $_date;
public function setupCustomFields() {
Class_CustomField_Meta::beVolatile();
$theme = $this->fixture('Class_CustomField',
['id' => 2,
'priority' => 3,
'label' => 'Theme',
'field_type' => Class_CustomField_Meta::SELECT,
'options_list' => 'sigb;opac',
'model' => 'Article']);
$multi_options = $this->fixture('Class_CustomField',
['id' => 20,
'priority' => 3,
'label' => 'Options',
'field_type' => Class_CustomField_Meta::MULTI_CHECKBOX,
'options_list' => 'wifi;restauration;projection',
'model' => 'Article']);
$this->fixture('Class_CustomField_Value',
['id' => 59,
'custom_field_id' => $theme->getId(),
'model_id' => $this->_nanook2->getId(),
'value' => 'sigb']);
$this->fixture('Class_CustomField_Value',
['id' => 5,
'custom_field_id' => $multi_options->getId(),
'model_id' => $this->_nanook2->getId(),
'value' => 'wifi;restauration']);
$this->fixture('Class_CustomField_Value',
['id' => 2,
'custom_field_id' => $theme->getId(),
'model_id' => $this->_opac4->getId(),
'value' => 'opac']);
}
public function setUp() {
parent::setUp();
$this->_opac4 = $this->fixture('Class_Article',
......@@ -625,7 +625,84 @@ class CmsControllerCalendarActionAjaxLinkTest extends AbstractControllerTestCase
}
class CmsControllerCalendarActionIcalExportTest extends CmsControllerCalendarActionTestCase {
protected $_opac4;
public function setUp() {
parent::setUp();
$annecy = $this->fixture('Class_Lieu',
['id' => '41',
'libelle' => 'Annecy',
'adresse' => 'Rue des tomates',
'code_postal' => '74000']);
$this->_opac4 = $this->fixture('Class_Article',
['id' => 5,
'titre' => 'OPAC 4 en prod !',
'contenu' => 'youpi !',
'lieu' => $annecy,
'categorie' => $this->fixture('Class_ArticleCategorie',
['id' => 12,
'libelle' => 'Evenement']),
'events_debut' => '2018-02-17',
'events_fin' => '2018-02-22']);
$this->setupCustomFields();
$common_preferences = ['display_order' => 'EventDebut',
'id_categorie' => '',
'events_only' => true,
'id_bib' => 0,
'id_lieu' => '',
'custom_fields' => [2 =>[0 => 'opac']],
'published' => true];
$time_source = new TimeSourceForTest('2017-11-06 14:14:14');
ZendAfi_View_Helper_CalendarContent::setTimeSource($time_source);
ZendAfi_View_Helper_Calendar_Months::setTimeSource($time_source);
Class_Article::getLoader()
->whenCalled('getArticlesByPreferences')
->answers([$this->_opac4]);
$this->dispatch('/cms/ical');
}
/** @test */
public function exportShouldContainsBeginVcalendar() {
$this->assertContains("BEGIN:VCALENDAR",$this->_response->getBody());
}
/** @test */
public function exportShouldContainsStartDate() {
$this->assertContains("DTSTART;TZID=Europe/Paris:20180217T00000",$this->_response->getBody());
}
/** @test */
public function exportShouldContainsEndDate() {
$this->assertContains("DTEND;TZID=Europe/Paris:20180222T00000",$this->_response->getBody());
}
/** @test */
public function exportShouldContainsLocation() {
$this->assertContains("LOCATION:Annecy",$this->_response->getBody());
}
/** @test */
public function exportShouldContainsDescription() {
$this->assertContains("DESCRIPTION:youpi !",$this->_response->getBody());
}
/** @test */
public function exportShouldContainsSummary() {
$this->assertContains("SUMMARY:OPAC 4 en prod !",$this->_response->getBody());
}
}
class CmsControllerCalendarActionWithOutDateTest extends AbstractControllerTestCase {
public function setUp() {
......
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