当前位置: 首页>>代码示例>>PHP>>正文


PHP Calendar::calculateSpan方法代码示例

本文整理汇总了PHP中Calendar::calculateSpan方法的典型用法代码示例。如果您正苦于以下问题:PHP Calendar::calculateSpan方法的具体用法?PHP Calendar::calculateSpan怎么用?PHP Calendar::calculateSpan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Calendar的用法示例。


在下文中一共展示了Calendar::calculateSpan方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     $this->Template->event = '';
     $this->Template->referer = 'javascript:history.go(-1)';
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     // Get the current event
     $objEvent = \CalendarEventsModel::findPublishedByParentAndIdOrAlias(\Input::get('events'), $this->cal_calendar);
     if (null === $objEvent) {
         /** @var \PageError404 $objHandler */
         $objHandler = new $GLOBALS['TL_PTY']['error_404']();
         $objHandler->generate($objPage->id);
     }
     // Overwrite the page title (see #2853 and #4955)
     if ($objEvent->title != '') {
         $objPage->pageTitle = strip_tags(strip_insert_tags($objEvent->title));
     }
     // Overwrite the page description
     if ($objEvent->teaser != '') {
         $objPage->description = $this->prepareMetaDescription($objEvent->teaser);
     }
     $intStartTime = $objEvent->startTime;
     $intEndTime = $objEvent->endTime;
     $span = \Calendar::calculateSpan($intStartTime, $intEndTime);
     // Do not show dates in the past if the event is recurring (see #923)
     if ($objEvent->recurring) {
         $arrRange = deserialize($objEvent->repeatEach);
         if (is_array($arrRange) && isset($arrRange['unit']) && isset($arrRange['value'])) {
             while ($intStartTime < time() && $intEndTime < $objEvent->repeatEnd) {
                 $intStartTime = strtotime('+' . $arrRange['value'] . ' ' . $arrRange['unit'], $intStartTime);
                 $intEndTime = strtotime('+' . $arrRange['value'] . ' ' . $arrRange['unit'], $intEndTime);
             }
         }
     }
     $strDate = \Date::parse($objPage->dateFormat, $intStartTime);
     if ($span > 0) {
         $strDate = \Date::parse($objPage->dateFormat, $intStartTime) . ' – ' . \Date::parse($objPage->dateFormat, $intEndTime);
     }
     $strTime = '';
     if ($objEvent->addTime) {
         if ($span > 0) {
             $strDate = \Date::parse($objPage->datimFormat, $intStartTime) . ' – ' . \Date::parse($objPage->datimFormat, $intEndTime);
         } elseif ($intStartTime == $intEndTime) {
             $strTime = \Date::parse($objPage->timeFormat, $intStartTime);
         } else {
             $strTime = \Date::parse($objPage->timeFormat, $intStartTime) . ' – ' . \Date::parse($objPage->timeFormat, $intEndTime);
         }
     }
     $until = '';
     $recurring = '';
     // Recurring event
     if ($objEvent->recurring) {
         $arrRange = deserialize($objEvent->repeatEach);
         if (is_array($arrRange) && isset($arrRange['unit']) && isset($arrRange['value'])) {
             $strKey = 'cal_' . $arrRange['unit'];
             $recurring = sprintf($GLOBALS['TL_LANG']['MSC'][$strKey], $arrRange['value']);
             if ($objEvent->recurrences > 0) {
                 $until = sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], \Date::parse($objPage->dateFormat, $objEvent->repeatEnd));
             }
         }
     }
     /** @var \FrontendTemplate|object $objTemplate */
     $objTemplate = new \FrontendTemplate($this->cal_template);
     $objTemplate->setData($objEvent->row());
     $objTemplate->date = $strDate;
     $objTemplate->time = $strTime;
     $objTemplate->datetime = $objEvent->addTime ? date('Y-m-d\\TH:i:sP', $intStartTime) : date('Y-m-d', $intStartTime);
     $objTemplate->begin = $intStartTime;
     $objTemplate->end = $intEndTime;
     $objTemplate->class = $objEvent->cssClass != '' ? ' ' . $objEvent->cssClass : '';
     $objTemplate->recurring = $recurring;
     $objTemplate->until = $until;
     $objTemplate->locationLabel = $GLOBALS['TL_LANG']['MSC']['location'];
     $objTemplate->details = '';
     $objTemplate->hasDetails = false;
     $objTemplate->hasTeaser = false;
     // Clean the RTE output
     if ($objEvent->teaser != '') {
         $objTemplate->hasTeaser = true;
         if ($objPage->outputFormat == 'xhtml') {
             $objTemplate->teaser = \StringUtil::toXhtml($objEvent->teaser);
         } else {
             $objTemplate->teaser = \StringUtil::toHtml5($objEvent->teaser);
         }
         $objTemplate->teaser = \StringUtil::encodeEmail($objTemplate->teaser);
     }
     // Display the "read more" button for external/article links
     if ($objEvent->source != 'default') {
         $objTemplate->details = true;
         $objTemplate->hasDetails = true;
     } else {
         $id = $objEvent->id;
         $objTemplate->details = function () use($id) {
             $strDetails = '';
             $objElement = \ContentModel::findPublishedByPidAndTable($id, 'tl_calendar_events');
             if ($objElement !== null) {
//.........这里部分代码省略.........
开发者ID:eknoes,项目名称:core,代码行数:101,代码来源:ModuleEventReader.php

示例2: prepareWidgetOptions


//.........这里部分代码省略.........
                 $sqlLookupWhere = !empty($strLookupWhere) ? "(" . $strLookupWhere . ")" : "";
                 $strReferer = $this->getReferer();
                 // If form is placed on an events detail page, automatically add restriction to event(s)
                 if (strlen(\Input::get('events'))) {
                     if (is_numeric(\Input::get('events'))) {
                         $sqlLookupWhere .= (!empty($sqlLookupWhere) ? " AND " : "") . " tl_calendar_events.id=" . intval(\Input::get('events')) . " ";
                     } elseif (is_string(\Input::get('events'))) {
                         $sqlLookupWhere .= (!empty($sqlLookupWhere) ? " AND " : "") . " tl_calendar_events.alias='" . \Input::get('events') . "' ";
                     }
                 }
                 // If linked from event reader page
                 if (strpos($strReferer, 'event-reader/events/') || strpos($strReferer, '&events=')) {
                     if (strpos($strReferer, 'events/')) {
                         $strEvents = substr($strReferer, strrpos($strReferer, '/') + 1);
                     } elseif (strpos($strReferer, '&events=')) {
                         $strEvents = substr($strReferer, strpos($strReferer, '&events=') + strlen('&events='));
                     }
                     if (is_numeric($strEvents)) {
                         $sqlLookupWhere .= (strlen($sqlLookupWhere) ? " AND " : "") . " tl_calendar_events.id=" . intval($strEvents) . " ";
                     } elseif (is_string($strEvents)) {
                         $strEvents = str_replace('.html', '', $strEvents);
                         $sqlLookupWhere .= (!empty($sqlLookupWhere) ? " AND " : "") . " tl_calendar_events.alias='" . $strEvents . "' ";
                     }
                 }
                 $sqlLookup = "SELECT tl_calendar_events.* FROM tl_calendar_events, tl_calendar WHERE (tl_calendar.id=tl_calendar_events.pid) " . (!empty($sqlLookupWhere) ? " AND (" . $sqlLookupWhere . ")" : "") . (strlen($sqlLookupOrder) ? " ORDER BY " . $sqlLookupOrder : "");
                 $objEvents = \Database::getInstance()->prepare($sqlLookup)->execute();
                 $arrEvents = array();
                 if ($objEvents->numRows) {
                     while ($arrEvent = $objEvents->fetchAssoc()) {
                         $intDate = $arrEvent['startDate'];
                         $intStart = time();
                         $intEnd = time() + 60 * 60 * 24 * 178;
                         // max. half year
                         $span = \Calendar::calculateSpan($arrEvent['startTime'], $arrEvent['endTime']);
                         $strTime = '';
                         $strTime .= date($GLOBALS['TL_CONFIG']['dateFormat'], $arrEvent['startDate']);
                         if ($arrEvent['addTime']) {
                             if ($span > 0) {
                                 $strTime .= ' ' . date($GLOBALS['TL_CONFIG']['timeFormat'], $arrEvent['startTime']) . ' - ' . date($GLOBALS['TL_CONFIG']['dateFormat'], $arrEvent['endTime']) . ' ' . date($GLOBALS['TL_CONFIG']['timeFormat'], $arrEvent['endTime']);
                             } elseif ($arrEvent['startTime'] == $arrEvent['endTime']) {
                                 $strTime .= ' ' . date($GLOBALS['TL_CONFIG']['timeFormat'], $arrEvent['startTime']);
                             } else {
                                 $strTime .= ' ' . date($GLOBALS['TL_CONFIG']['timeFormat'], $arrEvent['startTime']) . ' - ' . date($GLOBALS['TL_CONFIG']['timeFormat'], $arrEvent['endTime']);
                             }
                         } else {
                             if ($span > 1) {
                                 $strTime .= ' - ' . date($GLOBALS['TL_CONFIG']['dateFormat'], $arrEvent['endTime']);
                             }
                         }
                         if ($sqlLookupValField) {
                             // $arrEvents[$arrEvent[$sqlLookupValField].'@'.$strTime] = $arrEvent[$arrLookupField[1]] . (strlen($strTime) ? ', ' . $strTime : '');
                             if (count($arrSortKeys) >= 2) {
                                 $arrEvents[$arrEvent[$arrSortKeys[0]['field']]][$arrEvent[$arrSortKeys[1]['field']]][] = array('value' => $arrEvent[$sqlLookupValField] . '@' . $strTime, 'label' => $arrEvent[$arrLookupField[1]] . (strlen($strTime) ? ', ' . $strTime : ''));
                             } else {
                                 $arrEvents[$arrEvent[$arrSortKeys[0]['field']]][$arrEvent['startTime']][] = array('value' => $arrEvent[$sqlLookupValField] . '@' . $strTime, 'label' => $arrEvent[$arrLookupField[1]] . (strlen($strTime) ? ', ' . $strTime : ''));
                             }
                         } else {
                             // $arrEvents[$arrEvent['id'].'@'.$strTime] = $arrEvent[$arrLookupField[1]] . (strlen($strTime) ? ', ' . $strTime : '');
                             if (count($arrSortKeys) >= 2) {
                                 $arrEvents[$arrEvent[$arrSortKeys[0]['field']]][$arrEvent[$arrSortKeys[1]['field']]][] = array('value' => $arrEvent[$sqlLookupValField] . '@' . $strTime, 'label' => $arrEvent[$arrLookupField[1]] . (strlen($strTime) ? ', ' . $strTime : ''));
                             } else {
                                 $arrEvents[$arrEvent[$arrSortKeys[0]['field']]][$arrEvent['startTime']][] = array('value' => $arrEvent[$sqlLookupValField] . '@' . $strTime, 'label' => $arrEvent[$arrLookupField[1]] . (strlen($strTime) ? ', ' . $strTime : ''));
                             }
                         }
                         // Recurring events
                         if ($arrEvent['recurring']) {
开发者ID:Jobu,项目名称:core,代码行数:67,代码来源:Formdata.php

示例3: compile

 protected function compile()
 {
     global $objPage;
     $this->Template->event = '';
     $this->Template->referer = 'javascript:history.go(-1)';
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     if ($this->objEvent === null) {
         // Do not index or cache the page
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         // Send a 404 header
         header('HTTP/1.1 404 Not Found');
         $this->Template->event = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('events')) . '</p>';
         // remove page from search index
         if ($this->cal_showInModal) {
             \HeimrichHannot\SearchPlus\Search::removePageFromIndex(\Environment::get('request'));
         }
         return;
     }
     // Overwrite the page title (see #2853 and #4955)
     if ($this->objEvent->title != '') {
         $objPage->pageTitle = strip_tags(strip_insert_tags($this->objEvent->title));
     }
     // Overwrite the page description
     if ($this->objEvent->teaser != '') {
         $objPage->description = $this->prepareMetaDescription($this->objEvent->teaser);
     }
     $strUrl = '';
     $objCalendar = \CalendarModel::findByPk($this->objEvent->pid);
     // Get the current "jumpTo" page
     if ($objCalendar !== null && $objCalendar->jumpTo && ($objTarget = $objCalendar->getRelated('jumpTo')) !== null) {
         $strUrl = $this->generateFrontendUrl($objTarget->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/events/%s');
     }
     $intStartTime = $this->objEvent->startTime;
     $intEndTime = $this->objEvent->endTime;
     $span = \Calendar::calculateSpan($intStartTime, $intEndTime);
     // Do not show dates in the past if the event is recurring (see #923)
     if ($this->objEvent->recurring) {
         $arrRange = deserialize($this->objEvent->repeatEach);
         while ($intStartTime < time() && $intEndTime < $this->objEvent->repeatEnd) {
             $intStartTime = strtotime('+' . $arrRange['value'] . ' ' . $arrRange['unit'], $intStartTime);
             $intEndTime = strtotime('+' . $arrRange['value'] . ' ' . $arrRange['unit'], $intEndTime);
         }
     }
     $objEvent = (object) $this->getEventDetails($this->objEvent, $intStartTime, $intEndTime, $strUrl, $intStartTime, $this->objEvent->pid);
     $arrSubEvents = array();
     if (!$this->cal_ungroupSubevents) {
         $objChildEvents = CalendarPlusEventsModel::findPublishedSubEvents($objEvent->id);
         if ($objChildEvents !== null) {
             while ($objChildEvents->next()) {
                 $arrSubEvents[$objChildEvents->id] = $this->addSingleEvent($objChildEvents, $intStartTime);
             }
         }
     }
     if ($objPage->outputFormat == 'xhtml') {
         $strTimeStart = '';
         $strTimeEnd = '';
         $strTimeClose = '';
     } else {
         $strTimeStart = '<time datetime="' . date('Y-m-d\\TH:i:sP', $intStartTime) . '">';
         $strTimeEnd = '<time datetime="' . date('Y-m-d\\TH:i:sP', $intEndTime) . '">';
         $strTimeClose = '</time>';
     }
     // Get date
     if ($span > 0) {
         $date = $strTimeStart . \Date::parse($objEvent->addTime ? $objPage->datimFormat : $objPage->dateFormat, $intStartTime) . $strTimeClose . ' - ' . $strTimeEnd . \Date::parse($objEvent->addTime ? $objPage->datimFormat : $objPage->dateFormat, $intEndTime) . $strTimeClose;
     } elseif ($intStartTime == $intEndTime) {
         $date = $strTimeStart . \Date::parse($objPage->dateFormat, $intStartTime) . ($objEvent->addTime ? ' (' . \Date::parse($objPage->timeFormat, $intStartTime) . ')' : '') . $strTimeClose;
     } else {
         $date = $strTimeStart . \Date::parse($objPage->dateFormat, $intStartTime) . ($objEvent->addTime ? ' (' . \Date::parse($objPage->timeFormat, $intStartTime) . $strTimeClose . ' - ' . $strTimeEnd . \Date::parse($objPage->timeFormat, $intEndTime) . ')' : '') . $strTimeClose;
     }
     $until = '';
     $recurring = '';
     // Recurring event
     if ($objEvent->recurring) {
         $arrRange = deserialize($objEvent->repeatEach);
         $strKey = 'cal_' . $arrRange['unit'];
         $recurring = sprintf($GLOBALS['TL_LANG']['MSC'][$strKey], $arrRange['value']);
         if ($objEvent->recurrences > 0) {
             $until = sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], \Date::parse($objPage->dateFormat, $objEvent->repeatEnd));
         }
     }
     // Override the default image size
     if ($this->imgSize != '') {
         $size = deserialize($this->imgSize);
         if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) {
             $objEvent->size = $this->imgSize;
         }
     }
     $imgSize = false;
     // Override the default image size
     if ($this->imgSize != '') {
         $size = deserialize($this->imgSize);
         if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) {
             $imgSize = $this->imgSize;
         }
     }
     $objTemplate = new \FrontendTemplate($this->cal_template);
     $objTemplate->setData((array) $objEvent);
     $objTemplate->nav = $this->generateArrowNavigation($objEvent, $strUrl);
//.........这里部分代码省略.........
开发者ID:heimrichhannot,项目名称:contao-calendar_plus,代码行数:101,代码来源:ModuleEventReaderPlus.php

示例4: unregisterUser

 protected function unregisterUser($objEvent)
 {
     \Database::getInstance()->prepare("DELETE FROM tl_event_registrations WHERE pid=? AND userId=?")->execute($objEvent->id, $this->User->id);
     $objMailerText = \Database::getInstance()->prepare("SELECT ser_cancel_subject AS subject, ser_cancel_text AS text, ser_cancel_html AS html FROM tl_calendar WHERE id=?")->execute($objEvent->pid);
     // Send notification
     $objEmail = new \Email();
     $strFrom = $GLOBALS['TL_CONFIG']['adminEmail'];
     $strNotify = $objEvent->ser_email != "" ? $objEvent->ser_email : $GLOBALS['TL_CONFIG']['adminEmail'];
     $span = \Calendar::calculateSpan($objEvent->startTime, $objEvent->endTime);
     // Get date
     if ($span > 0) {
         $objEvent->date = \Date::parse($GLOBALS['TL_CONFIG'][$objEvent->addTime ? 'datimFormat' : 'dateFormat'], $objEvent->startTime) . ' - ' . \Date::parse($GLOBALS['TL_CONFIG'][$objEvent->addTime ? 'datimFormat' : 'dateFormat'], $objEvent->endTime);
     } elseif ($objEvent->startTime == $objEvent->endTime) {
         $objEvent->date = \Date::parse($GLOBALS['TL_CONFIG']['dateFormat'], $objEvent->startTime) . ($objEvent->addTime ? ' (' . \Date::parse($GLOBALS['TL_CONFIG']['timeFormat'], $objEvent->startTime) . ')' : '');
     } else {
         $objEvent->date = \Date::parse($GLOBALS['TL_CONFIG']['dateFormat'], $objEvent->startTime) . ($objEvent->addTime ? ' (' . \Date::parse($GLOBALS['TL_CONFIG']['timeFormat'], $objEvent->startTime) . ' - ' . \Date::parse($GLOBALS['TL_CONFIG']['timeFormat'], $objEvent->endTime) . ')' : '');
     }
     $notifyText = $this->replaceInserts($objEvent, $GLOBALS['TL_LANG']['MSC']['ser_unregister_mail']);
     $notifySubject = $GLOBALS['TL_LANG']['MSC']['ser_unregister_subject'];
     $messageText = $this->replaceInserts($objEvent, html_entity_decode($objMailerText->text));
     $messageHTML = $this->replaceInserts($objEvent, html_entity_decode($objMailerText->html));
     $objEmail->from = $strFrom;
     $objEmail->subject = $this->replaceInserts($objEvent, html_entity_decode($objMailerText->subject));
     $objEmail->text = $messageText;
     $objEmail->html = $messageHTML;
     $objEmail->sendTo($this->User->email);
     $objEmail->subject = $this->replaceInserts($objEvent, html_entity_decode($notifySubject));
     $objEmail->text = $notifyText;
     $objEmail->html = nl2br($notifyText);
     $objEmail->sendTo($strNotify);
     $_SESSION['TL_SER_UNREGISTERED'] = true;
     $this->reload();
 }
开发者ID:felixpfeiffer,项目名称:contao-simple-event-registration,代码行数:33,代码来源:ModuleSimpleEventRegistration.php

示例5: addEvent

 /**
  * Add an event to the array of active events
  * @param Database_Result
  * @param integer
  * @param integer
  * @param string
  * @param integer
  * @param integer
  * @param integer
  */
 protected function addEvent(Database_Result $objEvents, $intStart, $intEnd, $strUrl, $intBegin, $intLimit, $intCalendar)
 {
     global $objPage;
     $intDate = $intStart;
     $intKey = date('Ymd', $intStart);
     $span = Calendar::calculateSpan($intStart, $intEnd);
     $strDate = $this->parseDate($objPage->dateFormat, $intStart);
     $strDay = $GLOBALS['TL_LANG']['DAYS'][date('w', $intStart)];
     $strMonth = $GLOBALS['TL_LANG']['MONTHS'][date('n', $intStart) - 1];
     if ($span > 0) {
         $strDate = $this->parseDate($objPage->dateFormat, $intStart) . ' - ' . $this->parseDate($objPage->dateFormat, $intEnd);
         $strDay = '';
     }
     $strTime = '';
     if ($objEvents->addTime) {
         if ($span > 0) {
             $strDate = $this->parseDate($objPage->datimFormat, $intStart) . ' - ' . $this->parseDate($objPage->datimFormat, $intEnd);
         } elseif ($intStart == $intEnd) {
             $strTime = $this->parseDate($objPage->timeFormat, $intStart);
         } else {
             $strTime = $this->parseDate($objPage->timeFormat, $intStart) . ' - ' . $this->parseDate($objPage->timeFormat, $intEnd);
         }
     }
     // Store raw data
     $arrEvent = $objEvents->row();
     // Overwrite some settings
     $arrEvent['time'] = $strTime;
     $arrEvent['date'] = $strDate;
     $arrEvent['day'] = $strDay;
     $arrEvent['month'] = $strMonth;
     $arrEvent['parent'] = $intCalendar;
     $arrEvent['link'] = $objEvents->title;
     $arrEvent['target'] = '';
     $arrEvent['title'] = specialchars($objEvents->title, true);
     $arrEvent['href'] = $this->generateEventUrl($objEvents, $strUrl);
     $arrEvent['class'] = $objEvents->cssClass != '' ? ' ' . $objEvents->cssClass : '';
     $arrEvent['details'] = $this->String->encodeEmail($objEvents->details);
     $arrEvent['start'] = $intStart;
     $arrEvent['end'] = $intEnd;
     // Override the link target
     if ($objEvents->source == 'external' && $objEvents->target) {
         $arrEvent['target'] = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"';
     }
     // Clean the RTE output
     if ($arrEvent['teaser'] != '') {
         if ($objPage->outputFormat == 'xhtml') {
             $arrEvent['teaser'] = $this->String->toXhtml($arrEvent['teaser']);
         } else {
             $arrEvent['teaser'] = $this->String->toHtml5($arrEvent['teaser']);
         }
     }
     // Display the "read more" button for external/article links
     if ($objEvents->source != 'default' && $objEvents->details == '') {
         $arrEvent['details'] = true;
     } else {
         if ($objPage->outputFormat == 'xhtml') {
             $arrEvent['details'] = $this->String->toXhtml($arrEvent['details']);
         } else {
             $arrEvent['details'] = $this->String->toHtml5($arrEvent['details']);
         }
     }
     // Get todays start and end timestamp
     if ($this->intTodayBegin === null) {
         $this->intTodayBegin = strtotime('00:00:00');
     }
     if ($this->intTodayEnd === null) {
         $this->intTodayEnd = strtotime('23:59:59');
     }
     // Mark past and upcoming events (see #3692)
     if ($intEnd < $this->intTodayBegin) {
         $arrEvent['class'] .= ' bygone';
     } elseif ($intStart > $this->intTodayEnd) {
         $arrEvent['class'] .= ' upcoming';
     } else {
         $arrEvent['class'] .= ' current';
     }
     $this->arrEvents[$intKey][$intStart][] = $arrEvent;
     // Multi-day event
     for ($i = 1; $i <= $span && $intDate <= $intLimit; $i++) {
         // Only show first occurrence
         if ($this->cal_noSpan && $intDate >= $intBegin) {
             break;
         }
         $intDate = strtotime('+ 1 day', $intDate);
         $intNextKey = date('Ymd', $intDate);
         $this->arrEvents[$intNextKey][$intDate][] = $arrEvent;
     }
 }
开发者ID:jens-wetzel,项目名称:use2,代码行数:98,代码来源:Events.php

示例6: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $this->Template->event = '';
     $this->Template->referer = 'javascript:history.go(-1)';
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     // Get the current event
     $objEvent = \CalendarEventsModel::findPublishedByParentAndIdOrAlias(\Input::get('events'), $this->cal_calendar);
     if ($objEvent === null) {
         // Do not index or cache the page
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         // Send a 404 header
         header('HTTP/1.1 404 Not Found');
         $this->Template->event = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('events')) . '</p>';
         return;
     }
     // Overwrite the page title
     if ($objEvent->title != '') {
         $objPage->pageTitle = strip_insert_tags($objEvent->title);
     }
     // Overwrite the page description
     if ($objEvent->teaser != '') {
         $objPage->description = $this->prepareMetaDescription($objEvent->teaser);
     }
     $span = \Calendar::calculateSpan($objEvent->startTime, $objEvent->endTime);
     if ($objPage->outputFormat == 'xhtml') {
         $strTimeStart = '';
         $strTimeEnd = '';
         $strTimeClose = '';
     } else {
         $strTimeStart = '<time datetime="' . date('Y-m-d\\TH:i:sP', $objEvent->startTime) . '">';
         $strTimeEnd = '<time datetime="' . date('Y-m-d\\TH:i:sP', $objEvent->endTime) . '">';
         $strTimeClose = '</time>';
     }
     // Get date
     if ($span > 0) {
         $date = $strTimeStart . $this->parseDate($objEvent->addTime ? $objPage->datimFormat : $objPage->dateFormat, $objEvent->startTime) . $strTimeClose . ' - ' . $strTimeEnd . $this->parseDate($objEvent->addTime ? $objPage->datimFormat : $objPage->dateFormat, $objEvent->endTime) . $strTimeClose;
     } elseif ($objEvent->startTime == $objEvent->endTime) {
         $date = $strTimeStart . $this->parseDate($objPage->dateFormat, $objEvent->startTime) . ($objEvent->addTime ? ' (' . $this->parseDate($objPage->timeFormat, $objEvent->startTime) . ')' : '') . $strTimeClose;
     } else {
         $date = $strTimeStart . $this->parseDate($objPage->dateFormat, $objEvent->startTime) . ($objEvent->addTime ? ' (' . $this->parseDate($objPage->timeFormat, $objEvent->startTime) . $strTimeClose . ' - ' . $strTimeEnd . $this->parseDate($objPage->timeFormat, $objEvent->endTime) . ')' : '') . $strTimeClose;
     }
     $until = '';
     $recurring = '';
     // Recurring event
     if ($objEvent->recurring) {
         $arrRange = deserialize($objEvent->repeatEach);
         $strKey = 'cal_' . $arrRange['unit'];
         $recurring = sprintf($GLOBALS['TL_LANG']['MSC'][$strKey], $arrRange['value']);
         if ($objEvent->recurrences > 0) {
             $until = sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], $this->parseDate($objPage->dateFormat, $objEvent->repeatEnd));
         }
     }
     // Override the default image size
     if ($this->imgSize != '') {
         $size = deserialize($this->imgSize);
         if ($size[0] > 0 || $size[1] > 0) {
             $objEvent->size = $this->imgSize;
         }
     }
     $objTemplate = new \FrontendTemplate($this->cal_template);
     $objTemplate->setData($objEvent->row());
     $objTemplate->date = $date;
     $objTemplate->start = $objEvent->startTime;
     $objTemplate->end = $objEvent->endTime;
     $objTemplate->class = $objEvent->cssClass != '' ? ' ' . $objEvent->cssClass : '';
     $objTemplate->recurring = $recurring;
     $objTemplate->until = $until;
     // Clean the RTE output
     if ($objPage->outputFormat == 'xhtml') {
         $objEvent->details = \String::toXhtml($objEvent->details);
     } else {
         $objEvent->details = \String::toHtml5($objEvent->details);
     }
     $objTemplate->details = \String::encodeEmail($objEvent->details);
     $objTemplate->addImage = false;
     // Add an image
     if ($objEvent->addImage && $objEvent->singleSRC != '') {
         if (!is_numeric($objEvent->singleSRC)) {
             $objTemplate->details = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>';
         } else {
             $objModel = \FilesModel::findByPk($objEvent->singleSRC);
             if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
                 $objEvent->singleSRC = $objModel->path;
                 $this->addImageToTemplate($objTemplate, $objEvent->row());
             }
         }
     }
     $objTemplate->enclosure = array();
     // Add enclosures
     if ($objEvent->addEnclosure) {
         $this->addEnclosuresToTemplate($objTemplate, $objEvent->row());
     }
     $this->Template->event = $objTemplate->parse();
     // HOOK: comments extension required
     if ($objEvent->noComments || !in_array('comments', $this->Config->getActiveModules())) {
//.........这里部分代码省略.........
开发者ID:rikaix,项目名称:core,代码行数:101,代码来源:ModuleEventReader.php

示例7: handleEvent

 /**
  * Render a calendar event.
  *
  * @param GetCalendarEventEvent    $event           The event.
  *
  * @param string                   $eventName       The event name.
  *
  * @param EventDispatcherInterface $eventDispatcher The event dispatcher.
  *
  * @return void
  *
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  * @SuppressWarnings(PHPMD.Superglobals)
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function handleEvent(GetCalendarEventEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
 {
     if ($event->getCalendarEventHtml()) {
         return;
     }
     $calendarCollection = \CalendarModel::findAll();
     if (!$calendarCollection) {
         return;
     }
     $calendarIds = $calendarCollection->fetchEach('id');
     $eventModel = \CalendarEventsModel::findPublishedByParentAndIdOrAlias($event->getCalendarEventId(), $calendarIds);
     if (!$eventModel) {
         return;
     }
     $calendarModel = $eventModel->getRelated('pid');
     $objPage = \PageModel::findWithDetails($calendarModel->jumpTo);
     if ($event->getDateTime()) {
         $selectedStartDateTime = clone $event->getDateTime();
         $selectedStartDateTime->setTime(date('H', $eventModel->startTime), date('i', $eventModel->startTime), date('s', $eventModel->startTime));
         $secondsBetweenStartAndEndTime = $eventModel->endTime - $eventModel->startTime;
         $intStartTime = $selectedStartDateTime->getTimestamp();
         $intEndTime = $intStartTime + $secondsBetweenStartAndEndTime;
     } else {
         $intStartTime = $eventModel->startTime;
         $intEndTime = $eventModel->endTime;
     }
     $span = \Calendar::calculateSpan($intStartTime, $intEndTime);
     // Do not show dates in the past if the event is recurring (see #923).
     if ($eventModel->recurring) {
         $arrRange = deserialize($eventModel->repeatEach);
         while ($intStartTime < time() && $intEndTime < $eventModel->repeatEnd) {
             $intStartTime = strtotime('+' . $arrRange['value'] . ' ' . $arrRange['unit'], $intStartTime);
             $intEndTime = strtotime('+' . $arrRange['value'] . ' ' . $arrRange['unit'], $intEndTime);
         }
     }
     if ($objPage->outputFormat == 'xhtml') {
         $strTimeStart = '';
         $strTimeEnd = '';
         $strTimeClose = '';
     } else {
         $strTimeStart = '';
         $strTimeEnd = '';
         $strTimeClose = '';
         // @codingStandardsIgnoreStart
         /*
         TODO $this->date and $this->time is used in the <a> title attribute and cannot contain HTML!
         $strTimeStart = '<time datetime="' . date('Y-m-d\TH:i:sP', $intStartTime) . '">';
         $strTimeEnd   = '<time datetime="' . date('Y-m-d\TH:i:sP', $intEndTime) . '">';
         $strTimeClose = '</time>';
         */
         // @codingStandardsIgnoreEnd
     }
     // Get date.
     if ($span > 0) {
         $date = $strTimeStart . \Date::parse($eventModel->addTime ? $objPage->datimFormat : $objPage->dateFormat, $intStartTime) . $strTimeClose . ' - ' . $strTimeEnd . \Date::parse($eventModel->addTime ? $objPage->datimFormat : $objPage->dateFormat, $intEndTime) . $strTimeClose;
     } elseif ($intStartTime == $intEndTime) {
         $date = $strTimeStart . \Date::parse($objPage->dateFormat, $intStartTime) . ($eventModel->addTime ? ' (' . \Date::parse($objPage->timeFormat, $intStartTime) . ')' : '') . $strTimeClose;
     } else {
         $date = $strTimeStart . \Date::parse($objPage->dateFormat, $intStartTime) . ($eventModel->addTime ? ' (' . \Date::parse($objPage->timeFormat, $intStartTime) . $strTimeClose . ' - ' . $strTimeEnd . \Date::parse($objPage->timeFormat, $intEndTime) . ')' : '') . $strTimeClose;
     }
     $until = '';
     $recurring = '';
     // Recurring event.
     if ($eventModel->recurring) {
         $arrRange = deserialize($eventModel->repeatEach);
         $strKey = 'cal_' . $arrRange['unit'];
         $recurring = sprintf($GLOBALS['TL_LANG']['MSC'][$strKey], $arrRange['value']);
         if ($eventModel->recurrences > 0) {
             $until = sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], \Date::parse($objPage->dateFormat, $eventModel->repeatEnd));
         }
     }
     // Override the default image size.
     // This is always false.
     if ($this->imgSize != '') {
         $size = deserialize($this->imgSize);
         if ($size[0] > 0 || $size[1] > 0) {
             $eventModel->size = $this->imgSize;
         }
     }
     $objTemplate = new \FrontendTemplate($event->getTemplate());
     $objTemplate->setData($eventModel->row());
     $objTemplate->date = $date;
//.........这里部分代码省略.........
开发者ID:ContaoBlackForest-archive,项目名称:events-contao-bindings,代码行数:101,代码来源:CalendarSubscriber.php

示例8: getAllEventsExt


//.........这里部分代码省略.........
                     }
                     // reset this values...
                     $objEvents->moveReason = NULL;
                     $objEvents->oldDate = NULL;
                     $objEvents->oldStartTime = NULL;
                     $objEvents->oldEndTime = NULL;
                     // in case of a move we have to reset the original date
                     if ($oldDate) {
                         $objEvents->startTime = $oldDate['startTime'];
                         $objEvents->endTime = $oldDate['endTime'];
                     }
                 }
             }
         }
     }
     // run thru all holiday calendars
     foreach ($arrHolidays as $id) {
         $strUrl = $this->strUrl;
         $objAE = $this->Database->prepare("SELECT allowEvents FROM tl_calendar WHERE id = ?")->limit(1)->execute($id);
         $allowEvents = $objAE->allowEvents == 1 ? true : false;
         $strUrl = $this->strUrl;
         $objCalendar = \CalendarModel::findByPk($id);
         // Get the current "jumpTo" page
         if ($objCalendar !== null && $objCalendar->jumpTo && ($objTarget = $objCalendar->getRelated('jumpTo')) !== null) {
             $strUrl = $this->generateFrontendUrl($objTarget->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/events/%s');
         }
         // Get the events of the current period
         $objEvents = \CalendarEventsModel::findCurrentByPid($id, $intStart, $intEnd);
         if ($objEvents === null) {
             continue;
         }
         while ($objEvents->next()) {
             // at last we add the free multi-day / holiday or what ever kind of event
             $this->addEvent($objEvents, $objEvents->startTime, $objEvents->endTime, $strUrl, $intStart, $intEnd, $id);
             /**
              * Multi-day event
              * first we have to find all free days
              */
             $span = Calendar::calculateSpan($objEvents->startTime, $objEvents->endTime);
             // unset the first day of the multi-day event
             $intDate = $objEvents->startTime;
             $key = date('Ymd', $intDate);
             // check all events if the calendar allows events on free days
             if ($this->arrEvents[$key]) {
                 foreach ($this->arrEvents[$key] as $k1 => $events) {
                     foreach ($events as $k2 => $event) {
                         // do not remove events from any holiday calendar
                         $isHolidayEvent = array_search($event['pid'], $arrHolidays);
                         // unset the event if showOnFreeDay is not set
                         if ($allowEvents === false) {
                             if ($isHolidayEvent === false) {
                                 unset($this->arrEvents[$key][$k1][$k2]);
                             }
                         } else {
                             if ($isHolidayEvent === false && !$event['showOnFreeDay'] == 1) {
                                 unset($this->arrEvents[$key][$k1][$k2]);
                             }
                         }
                     }
                 }
             }
             // unset all the other days of the multi-day event
             for ($i = 1; $i <= $span && $intDate <= $intEnd; $i++) {
                 $intDate = strtotime('+ 1 day', $intDate);
                 $key = date('Ymd', $intDate);
                 // check all events if the calendar allows events on free days
                 if ($this->arrEvents[$key]) {
                     foreach ($this->arrEvents[$key] as $k1 => $events) {
                         foreach ($events as $k2 => $event) {
                             // do not remove events from any holiday calendar
                             $isHolidayEvent = array_search($event['pid'], $arrHolidays);
                             // unset the event if showOnFreeDay is not set
                             if ($allowEvents === false) {
                                 if ($isHolidayEvent === false) {
                                     unset($this->arrEvents[$key][$k1][$k2]);
                                 }
                             } else {
                                 if ($isHolidayEvent === false && !$event['showOnFreeDay'] == 1) {
                                     unset($this->arrEvents[$key][$k1][$k2]);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // Sort the array
     foreach (array_keys($this->arrEvents) as $key) {
         ksort($this->arrEvents[$key]);
     }
     // HOOK: modify the result set
     if (isset($GLOBALS['TL_HOOKS']['getAllEvents']) && is_array($GLOBALS['TL_HOOKS']['getAllEvents'])) {
         foreach ($GLOBALS['TL_HOOKS']['getAllEvents'] as $callback) {
             $this->import($callback[0]);
             $this->arrEvents = $this->{$callback}[0]->{$callback}[1]($this->arrEvents, $arrCalendars, $intStart, $intEnd, $this);
         }
     }
     return $this->arrEvents;
 }
开发者ID:rolandschuetz,项目名称:calendar_extended,代码行数:101,代码来源:EventsExt.php

示例9: addEvent

 /**
  * Add an event to the array of active events
  *
  * @param \CalendarEventsModel $objEvents
  * @param integer              $intStart
  * @param integer              $intEnd
  * @param string               $strUrl
  * @param integer              $intBegin
  * @param integer              $intLimit
  * @param integer              $intCalendar
  */
 protected function addEvent($objEvents, $intStart, $intEnd, $strUrl, $intBegin, $intLimit, $intCalendar)
 {
     /** @var \PageModel $objPage */
     global $objPage;
     $span = \Calendar::calculateSpan($intStart, $intEnd);
     // Adjust the start time of a multi-day event (see #6802)
     if ($this->cal_noSpan && $span > 0 && $intStart < $intBegin && $intBegin < $intEnd) {
         $intStart = $intBegin;
     }
     $intDate = $intStart;
     $intKey = date('Ymd', $intStart);
     $strDate = \Date::parse($objPage->dateFormat, $intStart);
     $strDay = $GLOBALS['TL_LANG']['DAYS'][date('w', $intStart)];
     $strMonth = $GLOBALS['TL_LANG']['MONTHS'][date('n', $intStart) - 1];
     if ($span > 0) {
         $strDate = \Date::parse($objPage->dateFormat, $intStart) . ' - ' . \Date::parse($objPage->dateFormat, $intEnd);
         $strDay = '';
     }
     $strTime = '';
     if ($objEvents->addTime) {
         if ($span > 0) {
             $strDate = \Date::parse($objPage->datimFormat, $intStart) . ' - ' . \Date::parse($objPage->datimFormat, $intEnd);
         } elseif ($intStart == $intEnd) {
             $strTime = \Date::parse($objPage->timeFormat, $intStart);
         } else {
             $strTime = \Date::parse($objPage->timeFormat, $intStart) . ' - ' . \Date::parse($objPage->timeFormat, $intEnd);
         }
     }
     // Store raw data
     $arrEvent = $objEvents->row();
     // Overwrite some settings
     $arrEvent['time'] = $strTime;
     $arrEvent['date'] = $strDate;
     $arrEvent['day'] = $strDay;
     $arrEvent['month'] = $strMonth;
     $arrEvent['parent'] = $intCalendar;
     $arrEvent['calendar'] = $objEvents->getRelated('pid');
     $arrEvent['link'] = $objEvents->title;
     $arrEvent['target'] = '';
     $arrEvent['title'] = specialchars($objEvents->title, true);
     $arrEvent['href'] = $this->generateEventUrl($objEvents, $strUrl);
     $arrEvent['class'] = $objEvents->cssClass != '' ? ' ' . $objEvents->cssClass : '';
     $arrEvent['begin'] = $intStart;
     $arrEvent['end'] = $intEnd;
     $arrEvent['details'] = '';
     // Override the link target
     if ($objEvents->source == 'external' && $objEvents->target) {
         $arrEvent['target'] = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"';
     }
     // Clean the RTE output
     if ($arrEvent['teaser'] != '') {
         if ($objPage->outputFormat == 'xhtml') {
             $arrEvent['teaser'] = \String::toXhtml($arrEvent['teaser']);
         } else {
             $arrEvent['teaser'] = \String::toHtml5($arrEvent['teaser']);
         }
     }
     // Display the "read more" button for external/article links
     if ($objEvents->source != 'default') {
         $arrEvent['details'] = true;
     } else {
         $id = $objEvents->id;
         $arrEvent['details'] = function () use($id) {
             $strDetails = '';
             $objElement = \ContentModel::findPublishedByPidAndTable($id, 'tl_calendar_events');
             if ($objElement !== null) {
                 while ($objElement->next()) {
                     $strDetails .= $this->getContentElement($objElement->current());
                 }
             }
             return $strDetails;
         };
     }
     // Get todays start and end timestamp
     if ($this->intTodayBegin === null) {
         $this->intTodayBegin = strtotime('00:00:00');
     }
     if ($this->intTodayEnd === null) {
         $this->intTodayEnd = strtotime('23:59:59');
     }
     // Mark past and upcoming events (see #3692)
     if ($intEnd < $this->intTodayBegin) {
         $arrEvent['class'] .= ' bygone';
     } elseif ($intStart > $this->intTodayEnd) {
         $arrEvent['class'] .= ' upcoming';
     } else {
         $arrEvent['class'] .= ' current';
     }
     $this->arrEvents[$intKey][$intStart][] = $arrEvent;
//.........这里部分代码省略.........
开发者ID:juergen83,项目名称:contao,代码行数:101,代码来源:Events.php

示例10: listEvents

 /**
  * Add the type of input field
  * @param array
  * @return string
  */
 public function listEvents($arrRow)
 {
     $span = Calendar::calculateSpan($arrRow['startTime'], $arrRow['endTime']);
     if ($span > 0) {
         $date = $this->parseDate($GLOBALS['TL_CONFIG'][$arrRow['addTime'] ? 'datimFormat' : 'dateFormat'], $arrRow['startTime']) . ' - ' . $this->parseDate($GLOBALS['TL_CONFIG'][$arrRow['addTime'] ? 'datimFormat' : 'dateFormat'], $arrRow['endTime']);
     } elseif ($arrRow['startTime'] == $arrRow['endTime']) {
         $date = $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $arrRow['startTime']) . ($arrRow['addTime'] ? ' ' . $this->parseDate($GLOBALS['TL_CONFIG']['timeFormat'], $arrRow['startTime']) : '');
     } else {
         $date = $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $arrRow['startTime']) . ($arrRow['addTime'] ? ' ' . $this->parseDate($GLOBALS['TL_CONFIG']['timeFormat'], $arrRow['startTime']) . '-' . $this->parseDate($GLOBALS['TL_CONFIG']['timeFormat'], $arrRow['endTime']) : '');
     }
     return '<div class="tl_content_left">' . $arrRow['title'] . ' <span style="color:#b3b3b3;padding-left:3px">[' . $date . ']</span></div>';
 }
开发者ID:rburch,项目名称:core,代码行数:17,代码来源:tl_calendar_events.php

示例11: exportRegisteredUsers

 /**
  * Return a form to choose a CSV file and import it
  * @param object
  * @return string
  */
 public function exportRegisteredUsers(DataContainer $dc)
 {
     $strRedirectUrl = ampersand(str_replace('&key=serexport', '', $this->Environment->request));
     if ($this->Input->get('key') != 'serexport') {
         $this->redirect($strRedirectUrl);
     }
     $pid = $this->Input->get('id');
     $objUsers = $this->Database->prepare("SELECT * FROM tl_event_registrations WHERE pid=? AND ( userId!=0 OR (anonym=1 AND lastname != ''))")->execute($pid);
     if ($objUsers->numRows == 0) {
         $this->redirect($strRedirectUrl);
     }
     $fields = $GLOBALS['BE_MOD']['content']['calendar']['serexportfields'];
     $strUserfields = implode(',', $fields['user']);
     // get records
     $arrExport = array();
     $objEventRow = $this->Database->prepare("SELECT *, (SELECT jumpTo FROM tl_calendar WHERE tl_calendar.id=tl_calendar_events.pid) AS jumpTo, (SELECT id FROM tl_page WHERE tl_page.id=jumpTo) AS pageId, (SELECT alias FROM tl_page WHERE tl_page.id=jumpTo) AS pageAlias FROM tl_calendar_events WHERE id=?")->execute($pid);
     $span = Calendar::calculateSpan($objEventRow->startTime, $objEventRow->endTime);
     // Get date
     if ($span > 0) {
         $objEventRow->date = \Date::parse($GLOBALS['TL_CONFIG'][$objEventRow->addTime ? 'datimFormat' : 'dateFormat'], $objEventRow->startTime) . ' - ' . \Date::parse($GLOBALS['TL_CONFIG'][$objEventRow->addTime ? 'datimFormat' : 'dateFormat'], $objEventRow->endTime);
     } elseif ($objEventRow->startTime == $objEventRow->endTime) {
         $objEventRow->date = \Date::parse($GLOBALS['TL_CONFIG']['dateFormat'], $objEventRow->startTime) . ($objEventRow->addTime ? ' (' . \Date::parse($GLOBALS['TL_CONFIG']['timeFormat'], $objEventRow->startTime) . ')' : '');
     } else {
         $objEventRow->date = \Date::parse($GLOBALS['TL_CONFIG']['dateFormat'], $objEventRow->startTime) . ($objEventRow->addTime ? ' (' . \Date::parse($GLOBALS['TL_CONFIG']['timeFormat'], $objEventRow->startTime) . ' - ' . \Date::parse($GLOBALS['TL_CONFIG']['timeFormat'], $objEventRow->endTime) . ')' : '');
     }
     $objEventRow->url = $this->generateEventUrl($objEventRow, $this->generateFrontendUrl(array('id' => $objEventRow->pageId, 'alias' => $objEventRow->pageAlias), 'events/%s'));
     $arrEvents = array();
     foreach ($fields['event'] as $value) {
         $arrEvents[] = $objEventRow->{$value};
     }
     while ($objUsers->next()) {
         if ($objUsers->anonym == 0) {
             $objUserRow = $this->Database->prepare("SELECT " . $strUserfields . " FROM tl_member WHERE id=?")->execute($objUsers->userId);
             $arrValues = $objUserRow->row();
         } else {
             foreach ($fields['anuser'] as $v) {
                 $arrValues[$v] = $objUsers->{$v};
             }
         }
         $arrExport[] = array_merge($arrValues, $arrEvents);
     }
     $fieldlabels = array();
     $this->loadLanguageFile('tl_member');
     $this->loadLanguageFile('tl_calendar_events');
     foreach ($fields['user'] as $value) {
         $fieldlabels[] = $GLOBALS['TL_LANG']['tl_member'][$value][0] != "" ? $GLOBALS['TL_LANG']['tl_member'][$value][0] : $value;
     }
     foreach ($fields['event'] as $value) {
         $fieldlabels[] = $GLOBALS['TL_LANG']['tl_calendar_events'][$value][0] != "" ? $GLOBALS['TL_LANG']['tl_calendar_events'][$value][0] : $value;
     }
     // start output
     $exportFile = 'simple_event_register_' . date("Ymd-Hi");
     header('Content-Type: application/csv');
     header('Content-Transfer-Encoding: binary');
     header('Content-Disposition: attachment; filename="' . $exportFile . '.csv"');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Pragma: public');
     header('Expires: 0');
     $output = '';
     $output .= html_entity_decode(utf8_decode('"' . join('";"', $fieldlabels) . '"' . "\n"));
     foreach ($arrExport as $export) {
         $export['gender'] = $GLOBALS['TL_LANG']['MSC'][$export['gender']];
         $output .= html_entity_decode(utf8_decode('"' . join('";"', $export) . '"' . "\n"));
     }
     echo $output;
     exit;
 }
开发者ID:felixpfeiffer,项目名称:contao-simple-event-registration,代码行数:72,代码来源:tl_event_registrations.php

示例12: prepareDcaOptions


//.........这里部分代码省略.........
                 $sqlLookupWhere = strlen($strLookupWhere) ? "(" . $strLookupWhere . ")" : "";
                 $strReferer = $this->getReferer();
                 // if form is placed on an events detail page, automatically add restriction to event(s)
                 if (strlen($this->Input->get('events'))) {
                     if (is_numeric($this->Input->get('events'))) {
                         $sqlLookupWhere .= (strlen($sqlLookupWhere) ? " AND " : "") . " tl_calendar_events.id=" . intval($this->Input->get('events')) . " ";
                     } elseif (is_string($this->Input->get('events'))) {
                         $sqlLookupWhere .= (strlen($sqlLookupWhere) ? " AND " : "") . " tl_calendar_events.alias='" . $this->Input->get('events') . "' ";
                     }
                 }
                 // if linked from event reader page
                 if (strpos($strReferer, 'event-reader/events/') || strpos($strReferer, '&events=')) {
                     if (strpos($strReferer, 'events/')) {
                         $strEvents = substr($strReferer, strrpos($strReferer, '/') + 1);
                     } elseif (strpos($strReferer, '&events=')) {
                         $strEvents = substr($strReferer, strpos($strReferer, '&events=') + strlen('&events='));
                     }
                     if (is_numeric($strEvents)) {
                         $sqlLookupWhere .= (strlen($sqlLookupWhere) ? " AND " : "") . " tl_calendar_events.id=" . intval($strEvents) . " ";
                     } elseif (is_string($strEvents)) {
                         $strEvents = str_replace('.html', '', $strEvents);
                         $sqlLookupWhere .= (strlen($sqlLookupWhere) ? " AND " : "") . " tl_calendar_events.alias='" . $strEvents . "' ";
                     }
                 }
                 $sqlLookup = "SELECT tl_calendar_events.* FROM tl_calendar_events, tl_calendar WHERE (tl_calendar.id=tl_calendar_events.pid) " . (strlen($sqlLookupWhere) ? " AND (" . $sqlLookupWhere . ")" : "") . (strlen($sqlLookupOrder) ? " ORDER BY " . $sqlLookupOrder : "");
                 $objEvents = $this->Database->prepare($sqlLookup)->execute();
                 $arrEvents = array();
                 if ($objEvents->numRows) {
                     while ($arrEvent = $objEvents->fetchAssoc()) {
                         $intDate = $arrEvent['startDate'];
                         $intStart = time();
                         $intEnd = time() + 60 * 60 * 24 * 178;
                         // max. 1/2 Jahr
                         $span = Calendar::calculateSpan($arrEvent['startTime'], $arrEvent['endTime']);
                         $strTime = '';
                         $strTime .= date($GLOBALS['TL_CONFIG']['dateFormat'], $arrEvent['startDate']);
                         if ($arrEvent['addTime']) {
                             if ($span > 0) {
                                 $strTime .= ' ' . date($GLOBALS['TL_CONFIG']['timeFormat'], $arrEvent['startTime']) . ' - ' . date($GLOBALS['TL_CONFIG']['dateFormat'], $arrEvent['endTime']) . ' ' . date($GLOBALS['TL_CONFIG']['timeFormat'], $arrEvent['endTime']);
                             } elseif ($arrEvent['startTime'] == $arrEvent['endTime']) {
                                 $strTime .= ' ' . date($GLOBALS['TL_CONFIG']['timeFormat'], $arrEvent['startTime']);
                             } else {
                                 $strTime .= ' ' . date($GLOBALS['TL_CONFIG']['timeFormat'], $arrEvent['startTime']) . ' - ' . date($GLOBALS['TL_CONFIG']['timeFormat'], $arrEvent['endTime']);
                             }
                         } else {
                             if ($span > 1) {
                                 $strTime .= ' - ' . date($GLOBALS['TL_CONFIG']['dateFormat'], $arrEvent['endTime']);
                             }
                         }
                         if ($sqlLookupValField) {
                             //$arrEvents[$arrEvent[$sqlLookupValField].'@'.$strTime] = $arrEvent[$arrLookupField[1]] . (strlen($strTime) ? ', ' . $strTime : '');
                             if (count($arrSortKeys) >= 2) {
                                 $arrEvents[$arrEvent[$arrSortKeys[0]['field']]][$arrEvent[$arrSortKeys[1]['field']]][] = array('value' => $arrEvent[$sqlLookupValField] . '@' . $strTime, 'label' => $arrEvent[$arrLookupField[1]] . (strlen($strTime) ? ', ' . $strTime : ''));
                             } else {
                                 $arrEvents[$arrEvent[$arrSortKeys[0]['field']]][$arrEvent['startTime']][] = array('value' => $arrEvent[$sqlLookupValField] . '@' . $strTime, 'label' => $arrEvent[$arrLookupField[1]] . (strlen($strTime) ? ', ' . $strTime : ''));
                             }
                         } else {
                             //$arrEvents[$arrEvent['id'].'@'.$strTime] = $arrEvent[$arrLookupField[1]] . (strlen($strTime) ? ', ' . $strTime : '');
                             if (count($arrSortKeys) >= 2) {
                                 $arrEvents[$arrEvent[$arrSortKeys[0]['field']]][$arrEvent[$arrSortKeys[1]['field']]][] = array('value' => $arrEvent[$sqlLookupValField] . '@' . $strTime, 'label' => $arrEvent[$arrLookupField[1]] . (strlen($strTime) ? ', ' . $strTime : ''));
                             } else {
                                 $arrEvents[$arrEvent[$arrSortKeys[0]['field']]][$arrEvent['startTime']][] = array('value' => $arrEvent[$sqlLookupValField] . '@' . $strTime, 'label' => $arrEvent[$arrLookupField[1]] . (strlen($strTime) ? ', ' . $strTime : ''));
                             }
                         }
                         // Recurring events
                         if ($arrEvent['recurring']) {
开发者ID:jens-wetzel,项目名称:use2,代码行数:67,代码来源:FormData.php

示例13: addEvent

 /**
  * Add an event to the array of active events
  * @param object
  * @param integer
  * @param integer
  * @param string
  * @param integer
  * @param integer
  * @param integer
  */
 protected function addEvent($objEvents, $intStart, $intEnd, $strUrl, $intBegin, $intLimit, $intCalendar)
 {
     $span = \Calendar::calculateSpan($intStart, $intEnd);
     // Adjust the start time of a multi-day event (see #6802)
     if ($this->cal_noSpan && $span > 0 && $intStart < $intBegin && $intBegin < $intEnd) {
         $intStart = $intBegin;
     }
     $intDate = $intStart;
     $intKey = date('Ymd', $intStart);
     $arrEvent = $this->getEventDetails($objEvents, $intStart, $intEnd, $strUrl, $intBegin, $intCalendar);
     $this->arrEvents[$intKey][$intStart][] = $arrEvent;
     // Multi-day event
     for ($i = 1; $i <= $span && $intDate <= $intLimit; $i++) {
         // Only show first occurrence
         if ($this->cal_noSpan && $intDate >= $intBegin) {
             break;
         }
         $intDate = strtotime('+ 1 day', $intDate);
         $intNextKey = date('Ymd', $intDate);
         $this->arrEvents[$intNextKey][$intDate][] = $arrEvent;
     }
 }
开发者ID:heimrichhannot,项目名称:contao-calendar_plus,代码行数:32,代码来源:EventsPlus.php

示例14: listEvents

 /**
  * Add the type of input field
  *
  * @param array $arrRow
  *
  * @return string
  */
 public function listEvents($arrRow)
 {
     $span = Calendar::calculateSpan($arrRow['startTime'], $arrRow['endTime']);
     if ($span > 0) {
         $date = Date::parse(Config::get($arrRow['addTime'] ? 'datimFormat' : 'dateFormat'), $arrRow['startTime']) . ' – ' . Date::parse(Config::get($arrRow['addTime'] ? 'datimFormat' : 'dateFormat'), $arrRow['endTime']);
     } elseif ($arrRow['startTime'] == $arrRow['endTime']) {
         $date = Date::parse(Config::get('dateFormat'), $arrRow['startTime']) . ($arrRow['addTime'] ? ' ' . Date::parse(Config::get('timeFormat'), $arrRow['startTime']) : '');
     } else {
         $date = Date::parse(Config::get('dateFormat'), $arrRow['startTime']) . ($arrRow['addTime'] ? ' ' . Date::parse(Config::get('timeFormat'), $arrRow['startTime']) . ' – ' . Date::parse(Config::get('timeFormat'), $arrRow['endTime']) : '');
     }
     return '<div class="tl_content_left">' . $arrRow['title'] . ' <span style="color:#b3b3b3;padding-left:3px">[' . $date . ']</span></div>';
 }
开发者ID:bytehead,项目名称:contao-core,代码行数:19,代码来源:tl_calendar_events.php

示例15: addEvent

 /**
  * Add an event to the array of active events
  *
  * @param CalendarEventsModel $objEvents
  * @param integer             $intStart
  * @param integer             $intEnd
  * @param integer             $intBegin
  * @param integer             $intLimit
  * @param integer             $intCalendar
  */
 protected function addEvent($objEvents, $intStart, $intEnd, $intBegin, $intLimit, $intCalendar)
 {
     /** @var PageModel $objPage */
     global $objPage;
     // Backwards compatibility (4th argument was $strUrl)
     if (func_num_args() > 6) {
         @trigger_error('Calling Events::addEvent() with 7 arguments has been deprecated and will no longer work in Contao 5.0. Do not pass $strUrl as 4th argument anymore.', E_USER_DEPRECATED);
         $intBegin = func_get_arg(4);
         $intLimit = func_get_arg(5);
         $intCalendar = func_get_arg(6);
     }
     $span = \Calendar::calculateSpan($intStart, $intEnd);
     // Adjust the start time of a multi-day event (see #6802)
     if ($this->cal_noSpan && $span > 0 && $intStart < $intBegin && $intBegin < $intEnd) {
         $intStart = $intBegin;
     }
     $intDate = $intStart;
     $intKey = date('Ymd', $intStart);
     $strDate = \Date::parse($objPage->dateFormat, $intStart);
     $strDay = $GLOBALS['TL_LANG']['DAYS'][date('w', $intStart)];
     $strMonth = $GLOBALS['TL_LANG']['MONTHS'][date('n', $intStart) - 1];
     if ($span > 0) {
         $strDate = \Date::parse($objPage->dateFormat, $intStart) . ' – ' . \Date::parse($objPage->dateFormat, $intEnd);
         $strDay = '';
     }
     $strTime = '';
     if ($objEvents->addTime) {
         if ($span > 0) {
             $strDate = \Date::parse($objPage->datimFormat, $intStart) . ' – ' . \Date::parse($objPage->datimFormat, $intEnd);
         } elseif ($intStart == $intEnd) {
             $strTime = \Date::parse($objPage->timeFormat, $intStart);
         } else {
             $strTime = \Date::parse($objPage->timeFormat, $intStart) . ' – ' . \Date::parse($objPage->timeFormat, $intEnd);
         }
     }
     $until = '';
     $recurring = '';
     // Recurring event
     if ($objEvents->recurring) {
         $arrRange = deserialize($objEvents->repeatEach);
         $strKey = 'cal_' . $arrRange['unit'];
         $recurring = sprintf($GLOBALS['TL_LANG']['MSC'][$strKey], $arrRange['value']);
         if ($objEvents->recurrences > 0) {
             $until = sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], \Date::parse($objPage->dateFormat, $objEvents->repeatEnd));
         }
     }
     // Store raw data
     $arrEvent = $objEvents->row();
     // Overwrite some settings
     $arrEvent['date'] = $strDate;
     $arrEvent['time'] = $strTime;
     $arrEvent['datetime'] = $objEvents->addTime ? date('Y-m-d\\TH:i:sP', $intStart) : date('Y-m-d', $intStart);
     $arrEvent['day'] = $strDay;
     $arrEvent['month'] = $strMonth;
     $arrEvent['parent'] = $intCalendar;
     $arrEvent['calendar'] = $objEvents->getRelated('pid');
     $arrEvent['link'] = $objEvents->title;
     $arrEvent['target'] = '';
     $arrEvent['title'] = specialchars($objEvents->title, true);
     $arrEvent['href'] = $this->generateEventUrl($objEvents);
     $arrEvent['class'] = $objEvents->cssClass != '' ? ' ' . $objEvents->cssClass : '';
     $arrEvent['recurring'] = $recurring;
     $arrEvent['until'] = $until;
     $arrEvent['begin'] = $intStart;
     $arrEvent['end'] = $intEnd;
     $arrEvent['details'] = '';
     $arrEvent['hasDetails'] = false;
     $arrEvent['hasTeaser'] = false;
     // Override the link target
     if ($objEvents->source == 'external' && $objEvents->target) {
         $arrEvent['target'] = ' target="_blank"';
     }
     // Clean the RTE output
     if ($arrEvent['teaser'] != '') {
         $arrEvent['hasTeaser'] = true;
         $arrEvent['teaser'] = \StringUtil::toHtml5($arrEvent['teaser']);
         $arrEvent['teaser'] = \StringUtil::encodeEmail($arrEvent['teaser']);
     }
     // Display the "read more" button for external/article links
     if ($objEvents->source != 'default') {
         $arrEvent['details'] = true;
         $arrEvent['hasDetails'] = true;
     } else {
         $id = $objEvents->id;
         $arrEvent['details'] = function () use($id) {
             $strDetails = '';
             $objElement = \ContentModel::findPublishedByPidAndTable($id, 'tl_calendar_events');
             if ($objElement !== null) {
                 while ($objElement->next()) {
                     $strDetails .= $this->getContentElement($objElement->current());
//.........这里部分代码省略.........
开发者ID:burguin,项目名称:test02,代码行数:101,代码来源:Events.php


注:本文中的Calendar::calculateSpan方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。