/**
  * Create's new rss feed for the calendar module
  * 
  * @global array $_CONFIG
  * @global object $objDatabase
  */
 function creatFeed()
 {
     global $_CONFIG, $objDatabase;
     parent::getFrontendLanguages();
     parent::getSettings();
     $this->objEventManager->getEventlist();
     foreach ($this->arrFrontendLanguages as $langKey => $arrFrontendLanguage) {
         $objRSSWriter = new \RSSWriter();
         $objRSSWriter->characterEncoding = CONTREXX_CHARSET;
         $objRSSWriter->channelTitle = contrexx_raw2xml($this->arrSettings['rssFeedTitle']);
         $objRSSWriter->channelLink = contrexx_raw2xml($this->domainUrl . 'index.php?section=' . $this->moduleName);
         $objRSSWriter->channelDescription = contrexx_raw2xml($this->arrSettings['rssFeedDescription']);
         $objRSSWriter->channelLanguage = contrexx_raw2xml($arrFrontendLanguage['lang']);
         $objRSSWriter->channelCopyright = contrexx_raw2xml('Copyright ' . date('Y') . ', ' . $this->domainUrl);
         if (!empty($this->arrSettings['rssFeedImage'])) {
             $objRSSWriter->channelImageUrl = $this->arrSettings['rssFeedImage'];
             $objRSSWriter->channelImageTitle = $objRSSWriter->channelTitle;
             $objRSSWriter->channelImageLink = $objRSSWriter->channelLink;
         }
         $objRSSWriter->channelWebMaster = $_CONFIG['coreAdminEmail'];
         $objRSSWriter->channelLastBuildDate = date('r', mktime());
         foreach ($this->objEventManager->eventList as $eventKey => $objEvent) {
             $objFWUser = \FWUser::getFWUserObject();
             $showIn = explode(',', $objEvent->showIn);
             if (in_array($arrFrontendLanguage['id'], $showIn)) {
                 $itemTitle = contrexx_raw2xml(html_entity_decode($objEvent->arrData['title'][$arrFrontendLanguage['id']], ENT_QUOTES, CONTREXX_CHARSET));
                 $itemLink = $objEvent->type == 0 ? $this->domainUrl . $this->objEventManager->_getDetailLink($objEvent) : $objEvent->arrData['redirect'][$arrFrontendLanguage['id']];
                 $itemLink = contrexx_raw2xml(html_entity_decode($itemLink));
                 $itemDescription = contrexx_raw2xml($objEvent->arrData['description'][$arrFrontendLanguage['id']]);
                 if ($objUser = $objFWUser->objUser->getUser(intval($objEvent->author))) {
                     $itemAuthor = $objUser->getEmail();
                 } else {
                     $itemAuthor = "unknown";
                 }
                 $itemAuthor = contrexx_raw2xml($itemAuthor);
                 $itemCategory = array();
                 $itemComments = null;
                 $itemEnclosure = array();
                 $itemGuid = array();
                 $itemPubDate = contrexx_raw2xml($objEvent->startDate);
                 $itemSource = array();
                 $objRSSWriter->addItem($itemTitle, $itemLink, $itemDescription, $itemAuthor, $itemCategory, $itemComments, $itemEnclosure, $itemGuid, $itemPubDate, $itemSource);
             }
         }
         $objRSSWriter->feedType = 'xml';
         $objRSSWriter->xmlDocumentPath = \Env::get('cx')->getWebsiteFeedPath() . '/calendar_all_' . $arrFrontendLanguage['lang'] . '.' . $objRSSWriter->feedType;
         $objRSSWriter->write();
     }
 }
 /**
  * Sets the placeholders used for the event list view
  * 
  * @param object  $objTpl Template object
  * @param integer $type   Event type
  * 
  * @return null
  */
 function showEventList($objTpl, $type = '')
 {
     global $objInit, $_ARRAYLANG, $_LANGID;
     parent::getFrontendLanguages();
     //if($objInit->mode == 'backend') {
     $i = 0;
     foreach ($this->eventList as $key => $objEvent) {
         $objCategory = new \Cx\Modules\Calendar\Controller\CalendarCategory(intval($objEvent->catId));
         $showIn = explode(",", $objEvent->showIn);
         $languages = '';
         if (count(\FWLanguage::getActiveFrontendLanguages()) > 1) {
             $langState = array();
             foreach ($this->arrFrontendLanguages as $langKey => $arrLang) {
                 if (in_array($arrLang['id'], $showIn)) {
                     $langState[$langKey] = 'active';
                 }
             }
             $languages = \Html::getLanguageIcons($langState, 'index.php?cmd=Calendar&act=modify_event&id=' . $objEvent->id . '&langId=%1$d' . ($type == 'confirm' ? "&confirm=1" : ""));
             if ($type == 'confirm' && $objTpl->blockExists('txt_languages_block_confirm_list')) {
                 $objTpl->touchBlock('txt_languages_block_confirm_list');
             } elseif ($objTpl->blockExists('txt_languages_block')) {
                 $objTpl->touchBlock('txt_languages_block');
             }
         } else {
             if ($type == 'confirm' && $objTpl->blockExists('txt_languages_block_confirm_list')) {
                 $objTpl->hideBlock('txt_languages_block_confirm_list');
             } elseif ($objTpl->blockExists('txt_languages_block')) {
                 $objTpl->hideBlock('txt_languages_block');
             }
         }
         list($priority, $priorityImg) = $this->getPriorityImage($objEvent);
         $plainDescription = contrexx_html2plaintext($objEvent->description);
         if (strlen($plainDescription) > 100) {
             $points = '...';
         } else {
             $points = '';
         }
         $parts = explode("\n", wordwrap($plainDescription, 100, "\n"));
         $attachNamePos = strrpos($objEvent->attach, '/');
         $attachNamelength = strlen($objEvent->attach);
         $attachName = substr($objEvent->attach, $attachNamePos + 1, $attachNamelength);
         if ($objEvent->external) {
             $objHost = new \Cx\Modules\Calendar\Controller\CalendarHost($objEvent->hostId);
             if (substr($objHost->uri, -1) != '/') {
                 $hostUri = $objHost->uri . '/';
             } else {
                 $hostUri = $objHost->uri;
             }
             if (substr($hostUri, 0, 7) != 'http://') {
                 $hostUri = "http://" . $hostUri;
             }
         }
         $copyLink = '';
         if ($objInit->mode == 'backend') {
             $editLink = 'index.php?cmd=' . $this->moduleName . '&act=modify_event&id=' . $objEvent->id . ($type == 'confirm' ? "&confirm=1" : "");
             $copyLink = $editLink . "&copy=1";
         } else {
             $editLink = CONTREXX_DIRECTORY_INDEX . '?section=' . $this->moduleName . '&cmd=edit&id=' . $objEvent->id;
         }
         $picThumb = file_exists(\Env::get('cx')->getWebsitePath() . "{$objEvent->pic}.thumb") ? "{$objEvent->pic}.thumb" : ($objEvent->pic != '' ? $objEvent->pic : '');
         $placeLink = $objEvent->place_link != '' ? "<a href='" . $objEvent->place_link . "' target='_blank' >" . $objEvent->place_link . "</a>" : "";
         $placeLinkSource = $objEvent->place_link;
         if ($this->arrSettings['placeData'] > 1 && $objEvent->locationType == 2) {
             $objEvent->loadPlaceFromMediadir($objEvent->place_mediadir_id, 'place');
             list($placeLink, $placeLinkSource) = $objEvent->loadPlaceLinkFromMediadir($objEvent->place_mediadir_id, 'place');
         }
         $hostLink = $objEvent->org_link != '' ? "<a href='" . $objEvent->org_link . "' target='_blank' >" . $objEvent->org_link . "</a>" : "";
         $hostLinkSource = $objEvent->org_link;
         if ($this->arrSettings['placeDataHost'] > 1 && $objEvent->hostType == 2) {
             $objEvent->loadPlaceFromMediadir($objEvent->host_mediadir_id, 'host');
             list($hostLink, $hostLinkSource) = $objEvent->loadPlaceLinkFromMediadir($objEvent->host_mediadir_id, 'host');
         }
         $objTpl->setVariable(array($this->moduleLangVar . '_EVENT_ROW' => $i % 2 == 0 ? 'row1' : 'row2', $this->moduleLangVar . '_EVENT_LED' => $objEvent->status == 0 ? 'red' : 'green', $this->moduleLangVar . '_EVENT_STATUS' => $objEvent->status == 0 ? $_ARRAYLANG['TXT_CALENDAR_INACTIVE'] : $_ARRAYLANG['TXT_CALENDAR_ACTIVE'], $this->moduleLangVar . '_EVENT_ID' => $objEvent->id, $this->moduleLangVar . '_EVENT_TITLE' => $objEvent->title, $this->moduleLangVar . '_EVENT_PICTURE' => $objEvent->pic != '' ? '<img src="' . $objEvent->pic . '" alt="' . $objEvent->title . '" title="' . $objEvent->title . '" />' : '', $this->moduleLangVar . '_EVENT_PICTURE_SOURCE' => $objEvent->pic, $this->moduleLangVar . '_EVENT_THUMBNAIL' => $objEvent->pic != '' ? '<img src="' . $picThumb . '" alt="' . $objEvent->title . '" title="' . $objEvent->title . '" />' : '', $this->moduleLangVar . '_EVENT_PRIORITY' => $priority, $this->moduleLangVar . '_EVENT_PRIORITY_IMG' => $priorityImg, $this->moduleLangVar . '_EVENT_PLACE' => $objEvent->place, $this->moduleLangVar . '_EVENT_DESCRIPTION' => $objEvent->description, $this->moduleLangVar . '_EVENT_SHORT_DESCRIPTION' => $parts[0] . $points, $this->moduleLangVar . '_EVENT_LINK' => $objEvent->link ? "<a href='" . $objEvent->link . "' target='_blank' >" . $objEvent->link . "</a>" : "", $this->moduleLangVar . '_EVENT_LINK_SOURCE' => $objEvent->link, $this->moduleLangVar . '_EVENT_ATTACHMENT' => $objEvent->attach != '' ? '<a href="' . $hostUri . $objEvent->attach . '" target="_blank" >' . $attachName . '</a>' : '', $this->moduleLangVar . '_EVENT_ATTACHMENT_SOURCE' => $objEvent->attach, $this->moduleLangVar . '_EVENT_START' => date(parent::getDateFormat() . " H:i", $objEvent->startDate), $this->moduleLangVar . '_EVENT_END' => date(parent::getDateFormat() . " H:i", $objEvent->endDate), $this->moduleLangVar . '_EVENT_DATE' => date(parent::getDateFormat(), $objEvent->startDate), $this->moduleLangVar . '_EVENT_START_DATE' => date(parent::getDateFormat(), $objEvent->startDate), $this->moduleLangVar . '_EVENT_START_TIME' => date("H:i", $objEvent->startDate), $this->moduleLangVar . '_EVENT_END_DATE' => date(parent::getDateFormat(), $objEvent->endDate), $this->moduleLangVar . '_EVENT_END_TIME' => date("H:i", $objEvent->endDate), $this->moduleLangVar . '_EVENT_LANGUAGES' => $languages, $this->moduleLangVar . '_EVENT_CATEGORY' => $objCategory->name, $this->moduleLangVar . '_EVENT_DETAIL_LINK' => $objEvent->type == 0 ? self::_getDetailLink($objEvent) : $objEvent->arrData['redirect'][$_LANGID], $this->moduleLangVar . '_EVENT_EDIT_LINK' => $editLink, $this->moduleLangVar . '_EVENT_COPY_LINK' => $copyLink, $this->moduleLangVar . '_EVENT_DETAIL_TARGET' => $objEvent->type == 0 ? '_self' : '_blank', $this->moduleLangVar . '_EVENT_SERIES' => $objEvent->seriesStatus == 1 ? '<img src="' . ASCMS_MODULE_WEB_PATH . '/' . $this->moduleName . '/View/Media/Repeat.png" border="0"/>' : '<i>' . $_ARRAYLANG['TXT_CALENDAR_NO_SERIES'] . '</i>', $this->moduleLangVar . '_EVENT_FREE_PLACES' => $objEvent->freePlaces, $this->moduleLangVar . '_EVENT_ACCESS' => $_ARRAYLANG['TXT_CALENDAR_EVENT_ACCESS_' . $objEvent->access]));
         $hasPlaceMap = !empty($objEvent->place_map) && file_exists(\Env::get('cx')->getWebsitePath() . $objEvent->place_map);
         if ($hasPlaceMap) {
             $arrInfo = getimagesize(\Env::get('cx')->getWebsitePath() . $objEvent->place_map);
             $picWidth = $arrInfo[0] + 20;
             $picHeight = $arrInfo[1] + 20;
         }
         $map_thumb_name = file_exists(\Env::get('cx')->getWebsitePath() . $objEvent->place_map . ".thumb") ? $objEvent->place_map . ".thumb" : $objEvent->place_map;
         $objTpl->setVariable(array($this->moduleLangVar . '_EVENT_LOCATION_PLACE' => $objEvent->place, $this->moduleLangVar . '_EVENT_LOCATION_ADDRESS' => $objEvent->place_street, $this->moduleLangVar . '_EVENT_LOCATION_ZIP' => $objEvent->place_zip, $this->moduleLangVar . '_EVENT_LOCATION_CITY' => $objEvent->place_city, $this->moduleLangVar . '_EVENT_LOCATION_COUNTRY' => $objEvent->place_country, $this->moduleLangVar . '_EVENT_LOCATION_LINK' => $placeLink, $this->moduleLangVar . '_EVENT_LOCATION_LINK_SOURCE' => $placeLinkSource, $this->moduleLangVar . '_EVENT_LOCATION_MAP_LINK' => $hasPlaceMap ? '<a href="' . $objEvent->place_map . '" onClick="window.open(this.href,\'\',\'resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,width=' . $picWidth . ',height=' . $picHeight . ',status\'); return false">' . $_ARRAYLANG['TXT_CALENDAR_MAP'] . '</a>' : "", $this->moduleLangVar . '_EVENT_LOCATION_MAP_THUMBNAIL' => $hasPlaceMap ? '<a href="' . $objEvent->place_map . '" onClick="window.open(this.href,\'\',\'resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,width=' . $picWidth . ',height=' . $picHeight . ',status\'); return false"><img src="' . $map_thumb_name . '" border="0" alt="' . $objEvent->place_map . '" /></a>' : "", $this->moduleLangVar . '_EVENT_LOCATION_MAP_SOURCE' => $hasPlaceMap ? $objEvent->place_map : '', $this->moduleLangVar . '_EVENT_HOST' => $objEvent->org_name, $this->moduleLangVar . '_EVENT_HOST_ADDRESS' => $objEvent->org_street, $this->moduleLangVar . '_EVENT_HOST_ZIP' => $objEvent->org_zip, $this->moduleLangVar . '_EVENT_HOST_CITY' => $objEvent->org_city, $this->moduleLangVar . '_EVENT_HOST_COUNTRY' => $objEvent->org_country, $this->moduleLangVar . '_EVENT_HOST_LINK' => $hostLink, $this->moduleLangVar . '_EVENT_HOST_LINK_SOURCE' => $hostLinkSource, $this->moduleLangVar . '_EVENT_HOST_EMAIL' => $objEvent->org_email != '' ? "<a href='mailto:" . $objEvent->org_email . "' >" . $objEvent->org_email . "</a>" : "", $this->moduleLangVar . '_EVENT_HOST_EMAIL_SOURCE' => $objEvent->org_email));
         if ($objInit->mode == 'backend') {
             $objTpl->setVariable(array($this->moduleLangVar . '_EVENT_COUNT_REG' => $objEvent->registrationCount, $this->moduleLangVar . '_EVENT_COUNT_DEREG' => $objEvent->cancellationCount, $this->moduleLangVar . '_EVENT_COUNT_WAITLIST' => $objEvent->waitlistCount));
         }
         $i++;
         // show date block
         if ($objTpl->blockExists('calendarDateList')) {
             $showStartDateList = $objEvent->useCustomDateDisplay ? $objEvent->showStartDateList : $this->arrSettings['showStartDateList'] == 1;
             $showEndDateList = $objEvent->useCustomDateDisplay ? $objEvent->showEndDateList : $this->arrSettings['showEndDateList'] == 1;
             $showStartTimeList = $objEvent->all_day ? false : ($objEvent->useCustomDateDisplay ? $objEvent->showStartTimeList : $this->arrSettings['showStartTimeList'] == 1);
             $showEndTimeList = $objEvent->all_day ? false : ($objEvent->useCustomDateDisplay ? $objEvent->showEndTimeList : $this->arrSettings['showEndTimeList'] == 1);
             $showTimeTypeList = $objEvent->useCustomDateDisplay ? $objEvent->showTimeTypeList : 1;
             // get date for several days format > show starttime with startdate and endtime with enddate > only if several days event and all values (dates/times) are displayed
             if (date(parent::getDateFormat(), $objEvent->startDate) != date(parent::getDateFormat(), $objEvent->endDate) && ($showStartDateList && $showEndDateList && $showStartTimeList && $showEndTimeList)) {
                 //part 1
                 $part = 1;
                 $this->getMultiDateBlock($objEvent, $this->arrSettings['separatorDateTimeList'], $this->arrSettings['separatorSeveralDaysList'], $this->arrSettings['showClockList'] == 1, $part);
                 $objTpl->setVariable(array($this->moduleLangVar . '_DATE_LIST' => $this->date, $this->moduleLangVar . '_SEP_DATE_TIME_LIST' => $this->sepDateTime, $this->moduleLangVar . '_TIME_LIST' => $this->time, 'TXT_' . $this->moduleLangVar . '_CLOCK_LIST' => $this->clock));
                 $objTpl->parse('calendarDateList');
                 //part 2
                 $part = 2;
                 $this->getMultiDateBlock($objEvent, $this->arrSettings['separatorDateTimeList'], $this->arrSettings['separatorSeveralDaysList'], $this->arrSettings['showClockList'] == 1, $part);
                 $objTpl->setVariable(array($this->moduleLangVar . '_DATE_LIST' => $this->date, $this->moduleLangVar . '_SEP_DATE_TIME_LIST' => $this->sepDateTime, $this->moduleLangVar . '_TIME_LIST' => $this->time, 'TXT_' . $this->moduleLangVar . '_CLOCK_LIST' => $this->clock));
                 $objTpl->parse('calendarDateList');
             } else {
                 // get date for single day format
                 $this->getSingleDateBlock($objEvent, $showStartDateList, $showEndDateList, $this->arrSettings['separatorDateList'], $showTimeTypeList, $showStartTimeList, $showEndTimeList, $this->arrSettings['separatorDateTimeList'], $this->arrSettings['separatorTimeList'], $this->arrSettings['showClockList'] == 1);
                 $objTpl->setVariable(array($this->moduleLangVar . '_DATE_LIST' => $this->date, $this->moduleLangVar . '_SEP_DATE_TIME_LIST' => $this->sepDateTime, $this->moduleLangVar . '_TIME_LIST' => $this->time, 'TXT_' . $this->moduleLangVar . '_CLOCK_LIST' => $this->clock));
                 $objTpl->parse('calendarDateList');
             }
         }
         if ($type == 'confirm') {
             if ($objTpl->blockExists('eventConfirmList')) {
                 $objTpl->parse('eventConfirmList');
             }
         } else {
             if ($objTpl->blockExists('eventList')) {
                 $objTpl->parse('eventList');
             }
             if ($objTpl->blockExists('calendar_headlines_row')) {
                 $objTpl->parse('calendar_headlines_row');
             }
         }
     }
     if (count($this->eventList) == 0 && $type != 'confirm') {
         $objTpl->hideBlock('eventList');
         $objTpl->setVariable(array('TXT_' . $this->moduleLangVar . '_NO_EVENTS' => $_ARRAYLANG['TXT_CALENDAR_EVENTS_NO']));
         $objTpl->parse('emptyEventList');
     }
     //}
 }
 /**
  * Return's the mailing template list drop down
  * 
  * @param integer $selectedId Template list to be selected
  * @param action  $actionId   Action id
  * 
  * @return string Html drop down with the mail templates
  */
 function getTemplateDropdown($selectedId = null, $actionId = null, $languageId = null)
 {
     global $_ARRAYLANG;
     parent::getSettings();
     parent::getFrontendLanguages();
     if (empty($selectedId)) {
         if (empty($this->templateList[$actionId][$languageId])) {
             // if no templates are available in associated language (or template is deactivated), select default template
             foreach ($this->arrFrontendLanguages as $lang_id => $lang) {
                 foreach ($this->templateList[$actionId][$lang_id] as $objMail) {
                     if ($objMail->is_default) {
                         $selectedId = $objMail->id;
                         break;
                     }
                 }
                 if (!empty($selectedId)) {
                     break;
                 }
             }
         } else {
             // if default template is set for associated language, select default template
             foreach ($this->templateList[$actionId][$languageId] as $objMail) {
                 if ($objMail->is_default) {
                     $selectedId = $objMail->id;
                     break;
                 }
             }
             // if templates are available in associated language, select first template of own language
             if (empty($selectedId)) {
                 $mail = reset($this->templateList[$actionId][$languageId]);
                 $selectedId = $mail->id;
             }
         }
     }
     $options = '';
     foreach ($this->arrFrontendLanguages as $lang_id => $lang) {
         if (!empty($this->templateList[$actionId][$lang_id])) {
             $options .= '<optgroup label="' . $lang['name'] . '">';
             foreach ($this->templateList[$actionId][$lang_id] as $objMail) {
                 $options .= "<option value='{$objMail->id}'\r\n                                    " . ($selectedId == $objMail->id ? "selected='selected'" : '') . "\r\n                                    style='" . (!$objMail->status ? "color : #A0A0A0;" : '') . "'\r\n                                 >\r\n                                    {$objMail->title}\r\n                                   " . ($objMail->is_default ? " (" . $_ARRAYLANG["TXT_{$this->moduleLangVar}_DEFAULT"] . ")" : '') . "\r\n                                   " . (!$objMail->status ? " (" . $_ARRAYLANG["TXT_{$this->moduleLangVar}_INACTIVE"] . ")" : '') . "\r\n                                 </option>";
             }
             $options .= '</optgroup>';
         }
     }
     return $options;
 }
 /**
  * Constructor
  */
 function __construct()
 {
     parent::getFrontendLanguages();
 }
 /**
  * Export the registered userd of the given event
  *      
  * @param integer $eventId          Event id
  * @param integer $registrationType Registration type
  * 
  * @return mixed csv file with registered users list
  */
 function exportRegistrations($eventId, $registrationType)
 {
     global $_ARRAYLANG, $_LANGID;
     if (empty($eventId)) {
         \Cx\Core\Csrf\Controller\Csrf::header("Location: index.php?cmd=" . $this->moduleName);
         return;
     }
     switch ($registrationType) {
         case 'r':
             $getRegistrations = true;
             $getDeregistrations = false;
             $getWaitlist = false;
             break;
         case 'd':
             $getRegistrations = false;
             $getDeregistrations = true;
             $getWaitlist = false;
             break;
         case 'w':
             $getRegistrations = false;
             $getDeregistrations = false;
             $getWaitlist = true;
             break;
         default:
             $getRegistrations = true;
             $getDeregistrations = true;
             $getWaitlist = true;
             break;
     }
     parent::getFrontendLanguages();
     $objEvent = new \Cx\Modules\Calendar\Controller\CalendarEvent($eventId);
     $filename = urlencode($objEvent->title) . ".csv";
     $objRegistrationManager = new \Cx\Modules\Calendar\Controller\CalendarRegistrationManager($eventId, $getRegistrations, $getDeregistrations, $getWaitlist);
     $objRegistrationManager->getRegistrationList();
     if (!empty($objRegistrationManager->registrationList)) {
         header("Content-Type: text/comma-separated-values; charset=" . CONTREXX_CHARSET, true);
         header("Content-Disposition: attachment; filename=\"{$filename}\"", true);
         print $_ARRAYLANG['TXT_CALENDAR_FIRST_EXPORT'] . $this->csvSeparator;
         print $_ARRAYLANG['TXT_CALENDAR_TYPE'] . $this->csvSeparator;
         print $_ARRAYLANG['TXT_CALENDAR_EVENT'] . $this->csvSeparator;
         print $_ARRAYLANG['TXT_CALENDAR_LANG'] . $this->csvSeparator;
         $firstKey = key($objRegistrationManager->registrationList);
         foreach ($objRegistrationManager->registrationList[$firstKey]->fields as $id => $arrField) {
             if ($arrField['type'] != 'fieldset') {
                 print self::escapeCsvValue(html_entity_decode($arrField['name'], ENT_QUOTES)) . $this->csvSeparator;
             }
         }
         print "\r\n";
         foreach ($objRegistrationManager->registrationList as $key => $objRegistration) {
             if (intval($objRegistration->firstExport) == 0) {
                 $objRegistration->tagExport();
             }
             print date(parent::getDateFormat(), $objRegistration->firstExport) . $this->csvSeparator;
             if ($objRegistration->type == '1') {
                 print $_ARRAYLANG['TXT_CALENDAR_REG_REGISTRATION'] . $this->csvSeparator;
             } else {
                 if ($objRegistration->type == '2') {
                     print $_ARRAYLANG['TXT_CALENDAR_WAITLIST'] . $this->csvSeparator;
                 } else {
                     print $_ARRAYLANG['TXT_CALENDAR_REG_SIGNOFF'] . $this->csvSeparator;
                 }
             }
             print html_entity_decode($objEvent->title, ENT_QUOTES) . " - " . date(parent::getDateFormat(), $objRegistration->eventDate) . $this->csvSeparator;
             if ($objRegistration->langId == null) {
                 print $this->arrFrontendLanguages[$_LANGID]['name'] . $this->csvSeparator;
             } else {
                 print $this->arrFrontendLanguages[$objRegistration->langId]['name'] . $this->csvSeparator;
             }
             foreach ($objRegistration->fields as $id => $arrField) {
                 $output = array();
                 switch ($arrField['type']) {
                     case 'inputtext':
                     case 'mail':
                     case 'textarea':
                     case 'seating':
                     case 'firstname':
                     case 'lastname':
                         print self::escapeCsvValue(html_entity_decode($arrField['value'], ENT_QUOTES)) . $this->csvSeparator;
                         break;
                     case 'salutation':
                     case 'select':
                     case 'radio':
                     case 'checkbox':
                         $options = explode(",", $arrField['default']);
                         $values = explode(",", $arrField['value']);
                         foreach ($values as $key => $value) {
                             $arrValue = explode('[[', $value);
                             $value = $arrValue[0];
                             $input = str_replace(']]', '', $arrValue[1]);
                             if (!empty($input)) {
                                 $arrOption = explode('[[', $options[$value - 1]);
                                 $output[] = $arrOption[0] . ": " . $input;
                             } else {
                                 if ($options[0] == '' && $value == 1) {
                                     $options[$value - 1] = '1';
                                 }
                                 $output[] = $options[$value - 1];
                             }
                         }
                         print html_entity_decode(self::escapeCsvValue(join(", ", $output)), ENT_QUOTES) . $this->csvSeparator;
                         break;
                     case 'agb':
                         print ($arrField['value'] ? $_ARRAYLANG["TXT_{$this->moduleLangVar}_YES"] : $_ARRAYLANG["TXT_{$this->moduleLangVar}_NO"]) . $this->csvSeparator;
                         break;
                 }
             }
             print "\r\n";
         }
         exit;
     } else {
         \Cx\Core\Csrf\Controller\Csrf::header("Location: index.php?cmd=" . $this->moduleName);
         return;
     }
 }
 /**
  * Sets placeholders for the form view.
  *      
  * @param object $objTpl         Template object
  * @param integer $formId        Form id
  * @param integer $intView       request mode frontend or backend
  * @param integer $arrNumSeating number of seating
  * 
  * @return null
  */
 function showForm($objTpl, $formId, $intView, $ticketSales = false)
 {
     global $_ARRAYLANG, $_LANGID;
     $objForm = new \Cx\Modules\Calendar\Controller\CalendarForm(intval($formId));
     if (!empty($formId)) {
         $this->formList[$formId] = $objForm;
     }
     switch ($intView) {
         case 1:
             parent::getFrontendLanguages();
             $objTpl->setGlobalVariable(array($this->moduleLangVar . '_FORM_ID' => !empty($formId) ? $objForm->id : '', $this->moduleLangVar . '_FORM_TITLE' => !empty($formId) ? $objForm->title : ''));
             $i = 0;
             $formFields = array();
             if (!empty($formId)) {
                 foreach ($objForm->inputfields as $key => $arrInputfield) {
                     $i++;
                     $fieldValue = array();
                     $defaultFieldValue = array();
                     foreach ($this->arrFrontendLanguages as $key => $arrLang) {
                         $fieldValue[$arrLang['id']] = $arrInputfield['name'][$arrLang['id']];
                         $defaultFieldValue[$arrLang['id']] = $arrInputfield['default_value'][$arrLang['id']];
                     }
                     $formFields[] = array('type' => $arrInputfield['type'], 'id' => $arrInputfield['id'], 'row' => $i % 2 == 0 ? 'row2' : 'row1', 'order' => $arrInputfield['order'], 'name_master' => $arrInputfield['name'][0], 'default_value_master' => $arrInputfield['default_value'][0], 'required' => $arrInputfield['required'], 'affiliation' => $arrInputfield['affiliation'], 'field_value' => json_encode($fieldValue), 'default_field_value' => json_encode($defaultFieldValue));
                 }
             }
             foreach ($this->arrFrontendLanguages as $key => $arrLang) {
                 $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_LANG_ID' => $arrLang['id'], $this->moduleLangVar . '_INPUTFIELD_LANG_NAME' => $arrLang['name'], $this->moduleLangVar . '_INPUTFIELD_LANG_SHORTCUT' => $arrLang['lang']));
                 $objTpl->parse('inputfieldNameList');
                 $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_LANG_ID' => $arrLang['id'], $this->moduleLangVar . '_INPUTFIELD_LANG_NAME' => $arrLang['name'], $this->moduleLangVar . '_INPUTFIELD_LANG_SHORTCUT' => $arrLang['lang']));
                 $objTpl->parse('inputfieldDefaultValueList');
                 $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_LANG_NAME' => $arrLang['name']));
                 $objTpl->parse('inputfieldLanguagesList');
             }
             foreach ($this->arrInputfieldTypes as $fieldType) {
                 $objTpl->setVariable(array($this->moduleLangVar . '_FORM_FIELD_TYPE' => $fieldType, 'TXT_' . $this->moduleLangVar . '_FORM_FIELD_TYPE' => $_ARRAYLANG['TXT_CALENDAR_FORM_FIELD_' . strtoupper($fieldType)]));
                 $objTpl->parse('inputfieldTypes');
             }
             foreach ($this->arrRegistrationFields as $fieldType) {
                 $objTpl->setVariable(array($this->moduleLangVar . '_FORM_FIELD_TYPE' => $fieldType, 'TXT_' . $this->moduleLangVar . '_FORM_FIELD_TYPE' => $_ARRAYLANG['TXT_CALENDAR_FORM_FIELD_' . strtoupper($fieldType)]));
                 $objTpl->parse('inputRegfieldTypes');
             }
             /* foreach ($this->arrInputfieldAffiliations as $strAffiliation) {
                    $objTpl->setVariable(array(
                        $this->moduleLangVar.'_FORM_FIELD_TYPE'        =>  $strAffiliation,
                        'TXT_'.$this->moduleLangVar.'_FORM_FIELD_TYPE' =>  $_ARRAYLANG['TXT_CALENDAR_FORM_FIELD_AFFILIATION_'.strtoupper($strAffiliation)],
                    ));
                    $objTpl->parse('fieldAfflications');
                }*/
             $objTpl->setVariable(array($this->moduleLangVar . '_FORM_DATA' => json_encode($formFields), $this->moduleLangVar . '_FRONTEND_LANG_COUNT' => count($this->arrFrontendLanguages), $this->moduleLangVar . '_INPUTFIELD_LAST_ID' => $objForm->getLastInputfieldId(), $this->moduleLangVar . '_INPUTFIELD_LAST_ROW' => $i % 2 == 0 ? "'row2'" : "'row1'", $this->moduleLangVar . '_DISPLAY_EXPAND' => count($this->arrFrontendLanguages) > 1 ? "block" : "none"));
             break;
         case 2:
             $objFieldTemplate = new \Cx\Core\Html\Sigma('.');
             $objFieldTemplate->setTemplate(self::frontendFieldTemplate, true, true);
             $objFieldTemplate->setVariable(array('TXT_' . $this->moduleLangVar . '_FIELD_NAME' => $_ARRAYLANG['TXT_CALENDAR_TYPE'] . '<font class="calendarRequired"> *</font>', $this->moduleLangVar . '_FIELD_INPUT' => '<select class="calendarSelect affiliateForm" name="registrationType"><option value="1" selected="selected"/>' . $_ARRAYLANG['TXT_CALENDAR_REG_REGISTRATION'] . '</option><option value="0"/>' . $_ARRAYLANG['TXT_CALENDAR_REG_SIGNOFF'] . '</option></select>', $this->moduleLangVar . '_FIELD_CLASS' => 'affiliationForm'));
             $objTpl->setVariable($this->moduleLangVar . '_REGISTRATION_FIELD', $objFieldTemplate->get());
             $objTpl->parse('calendarRegistrationField');
             // $selectBillingAddressStatus = false;
             foreach ($objForm->inputfields as $key => $arrInputfield) {
                 $objFieldTemplate->setTemplate(self::frontendFieldTemplate, true, true);
                 $options = array();
                 $options = explode(',', $arrInputfield['default_value'][$_LANGID]);
                 $inputfield = null;
                 $hide = false;
                 $optionSelect = true;
                 if (isset($_POST['registrationField'][$arrInputfield['id']])) {
                     $value = $_POST['registrationField'][$arrInputfield['id']];
                 } elseif (\FWUser::getFWUserObject()->objUser->login() && in_array($arrInputfield['type'], array('mail', 'firstname', 'lastname'))) {
                     $value = '';
                     switch ($arrInputfield['type']) {
                         case 'mail':
                             $value = \FWUser::getFWUserObject()->objUser->getEmail();
                             break;
                         case 'firstname':
                             $value = \FWUser::getFWUserObject()->objUser->getProfileAttribute('firstname');
                             break;
                         case 'lastname':
                             $value = \FWUser::getFWUserObject()->objUser->getProfileAttribute('lastname');
                             break;
                         default:
                             $value = $arrInputfield['default_value'][$_LANGID];
                             break;
                     }
                 } else {
                     $value = $arrInputfield['default_value'][$_LANGID];
                 }
                 $affiliationClass = 'affiliation' . ucfirst($arrInputfield['affiliation']);
                 switch ($arrInputfield['type']) {
                     case 'inputtext':
                     case 'mail':
                     case 'firstname':
                     case 'lastname':
                         $inputfield = '<input type="text" class="calendarInputText" name="registrationField[' . $arrInputfield['id'] . ']" value="' . $value . '" /> ';
                         break;
                     case 'textarea':
                         $inputfield = '<textarea class="calendarTextarea" name="registrationField[' . $arrInputfield['id'] . ']">' . $value . '</textarea>';
                         break;
                     case 'seating':
                         if (!$ticketSales) {
                             $hide = true;
                         }
                         $optionSelect = false;
                     case 'select':
                     case 'salutation':
                         $inputfield = '<select class="calendarSelect" name="registrationField[' . $arrInputfield['id'] . ']">';
                         $selected = empty($_POST) ? 'selected="selected"' : '';
                         $inputfield .= $optionSelect ? '<option value="" ' . $selected . '>' . $_ARRAYLANG['TXT_CALENDAR_PLEASE_CHOOSE'] . '</option>' : '';
                         foreach ($options as $key => $name) {
                             $selected = $key + 1 == $value ? 'selected="selected"' : '';
                             $inputfield .= '<option value="' . intval($key + 1) . '" ' . $selected . '>' . $name . '</option>';
                         }
                         $inputfield .= '</select>';
                         break;
                     case 'radio':
                         foreach ($options as $key => $name) {
                             $checked = $key + 1 == $value || empty($_POST) && $key == 0 ? 'checked="checked"' : '';
                             $textValue = isset($_POST["registrationFieldAdditional"][$arrInputfield['id']][$key]) ? $_POST["registrationFieldAdditional"][$arrInputfield['id']][$key] : '';
                             $textfield = '<input type="text" class="calendarInputCheckboxAdditional" name="registrationFieldAdditional[' . $arrInputfield['id'] . '][' . $key . ']" value="' . contrexx_input2xhtml($textValue) . '" />';
                             $name = str_replace('[[INPUT]]', $textfield, $name);
                             $inputfield .= '<input type="radio" class="calendarInputCheckbox" name="registrationField[' . $arrInputfield['id'] . ']" value="' . intval($key + 1) . '" ' . $checked . '/>&nbsp;' . $name . '<br />';
                         }
                         break;
                     case 'checkbox':
                         foreach ($options as $key => $name) {
                             $textValue = isset($_POST["registrationFieldAdditional"][$arrInputfield['id']][$key]) ? $_POST["registrationFieldAdditional"][$arrInputfield['id']][$key] : '';
                             $textfield = '<input type="text" class="calendarInputCheckboxAdditional" name="registrationFieldAdditional[' . $arrInputfield['id'] . '][' . $key . ']" value="' . contrexx_input2xhtml($textValue) . '" />';
                             $name = str_replace('[[INPUT]]', $textfield, $name);
                             $checked = in_array($key + 1, $_POST['registrationField'][$arrInputfield['id']]) ? 'checked="checked"' : '';
                             $inputfield .= '<input ' . $checked . ' type="checkbox" class="calendarInputCheckbox" name="registrationField[' . $arrInputfield['id'] . '][]" value="' . intval($key + 1) . '" />&nbsp;' . $name . '<br />';
                         }
                         break;
                     case 'agb':
                         $inputfield = '<input class="calendarInputCheckbox" type="checkbox" name="registrationField[' . $arrInputfield['id'] . '][]" value="1" />&nbsp;' . $_ARRAYLANG['TXT_CALENDAR_AGB'] . '<br />';
                         break;
                         /* case 'selectBillingAddress':
                                                     if(!$selectBillingAddressStatus) {
                                                         if($_REQUEST['registrationField'][$arrInputfield['id']] == 'deviatesFromContact') {
                                                             $selectDeviatesFromContact = 'selected="selected"';
                                                         } else {
                                                             $selectDeviatesFromContact = '';
                                                         }
                         
                                                         $inputfield = '<select id="calendarSelectBillingAddress" class="calendarSelect" name="registrationField['.$arrInputfield['id'].']">';
                                                         $inputfield .= '<option value="sameAsContact">'.$_ARRAYLANG['TXT_CALENDAR_SAME_AS_CONTACT'].'</option>';    
                                                         $inputfield .= '<option value="deviatesFromContact" '.$selectDeviatesFromContact.'>'.$_ARRAYLANG['TXT_CALENDAR_DEVIATES_FROM_CONTACT'].'</option>';    
                                                         $inputfield .= '</select>'; 
                                                         $selectBillingAddressStatus = true;
                                                     } 
                                                     break; */
                     /* case 'selectBillingAddress':
                                                 if(!$selectBillingAddressStatus) {
                                                     if($_REQUEST['registrationField'][$arrInputfield['id']] == 'deviatesFromContact') {
                                                         $selectDeviatesFromContact = 'selected="selected"';
                                                     } else {
                                                         $selectDeviatesFromContact = '';
                                                     }
                     
                                                     $inputfield = '<select id="calendarSelectBillingAddress" class="calendarSelect" name="registrationField['.$arrInputfield['id'].']">';
                                                     $inputfield .= '<option value="sameAsContact">'.$_ARRAYLANG['TXT_CALENDAR_SAME_AS_CONTACT'].'</option>';    
                                                     $inputfield .= '<option value="deviatesFromContact" '.$selectDeviatesFromContact.'>'.$_ARRAYLANG['TXT_CALENDAR_DEVIATES_FROM_CONTACT'].'</option>';    
                                                     $inputfield .= '</select>'; 
                                                     $selectBillingAddressStatus = true;
                                                 } 
                                                 break; */
                     case 'fieldset':
                         $inputfield = null;
                         break;
                 }
                 $field = '';
                 if ($arrInputfield['type'] == 'fieldset') {
                     $field = '</fieldset><fieldset><legend>' . $arrInputfield['name'][$_LANGID] . '</legend>';
                     $hide = true;
                 } else {
                     $required = $arrInputfield['required'] == 1 ? '<font class="calendarRequired"> *</font>' : '';
                     $label = $arrInputfield['name'][$_LANGID] . $required;
                 }
                 if (!$hide) {
                     $objFieldTemplate->setVariable(array('TXT_' . $this->moduleLangVar . '_FIELD_NAME' => $label, $this->moduleLangVar . '_FIELD_INPUT' => $inputfield, $this->moduleLangVar . '_FIELD_CLASS' => $affiliationClass));
                     $field = $objFieldTemplate->get();
                 }
                 $objTpl->setVariable($this->moduleLangVar . '_REGISTRATION_FIELD', $field);
                 $objTpl->parse('calendarRegistrationField');
             }
             break;
     }
 }