Beispiel #1
0
 /**
  * Get the next events
  *
  * @param string $table
  * @param int $uid
  * @param int $limit
  *
  * @return array|NULL
  */
 public function getNextEvents($table, $uid, $limit = 5)
 {
     $databaseConnection = HelperUtility::getDatabaseConnection();
     $now = DateTimeUtility::getNow();
     $now->setTime(0, 0, 0);
     return $databaseConnection->exec_SELECTgetRows('*', self::TABLE_NAME, 'start_date >= ' . $now->getTimestamp() . ' AND foreign_table=' . $databaseConnection->fullQuoteStr($table, self::TABLE_NAME) . ' AND foreign_uid=' . (int) $uid, '', 'start_date ASC, start_time ASC', $limit);
 }
 /**
  * Modify the given times via the configuration
  *
  * @param array         $times
  * @param Configuration $configuration
  *
  * @return void
  */
 public function handleConfiguration(array &$times, Configuration $configuration)
 {
     $url = $configuration->getExternalIcsUrl();
     if (!GeneralUtility::isValidUrl($url)) {
         HelperUtility::createFlashMessage('Configuration with invalid ICS URL: ' . $url, 'Index ICS URL', FlashMessage::ERROR);
         return;
     }
     $events = $this->icsReaderService->toArray($url);
     foreach ($events as $event) {
         /** @var $event ICalEvent */
         $startTime = DateTimeUtility::getDaySecondsOfDateTime($event->getStart());
         $endTime = DateTimeUtility::getDaySecondsOfDateTime($event->getEnd());
         if ($endTime === self::DAY_END) {
             $endTime = 0;
         }
         $entry = ['pid' => 0, 'start_date' => $event->getStart(), 'end_date' => $event->getEnd() ?: $event->getStart(), 'start_time' => $startTime, 'end_time' => $endTime, 'all_day' => $endTime === 0];
         $times[] = $entry;
     }
 }
 /**
  * Get the configuration
  *
  * @param int       $pid
  * @param \DateTime $startDate
  * @param \DateTime $endDate
  *
  * @return Configuration
  */
 protected function getConfiguration($pid, \DateTime $startDate, \DateTime $endDate)
 {
     $configuration = new Configuration();
     $configuration->setPid($pid);
     $configuration->setType(Configuration::TYPE_TIME);
     $configuration->setFrequency(Configuration::FREQUENCY_NONE);
     $configuration->setAllDay(true);
     $startTime = clone $startDate;
     $configuration->setStartDate(DateTimeUtility::resetTime($startDate));
     $endTime = $endDate;
     $configuration->setEndDate(DateTimeUtility::resetTime($endDate));
     $startTime = DateTimeUtility::getDaySecondsOfDateTime($startTime);
     if ($startTime > 0) {
         $configuration->setStartTime($startTime);
         $configuration->setEndTime(DateTimeUtility::getDaySecondsOfDateTime($endTime));
         $configuration->setAllDay(false);
     }
     return $configuration;
 }
Beispiel #4
0
 /**
  * find Week
  *
  * @param int $year
  * @param int $week
  *
  * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface
  */
 public function findWeek($year, $week)
 {
     $firstDay = DateTimeUtility::convertWeekYear2DayMonthYear($week, $year);
     $timeStampStart = $firstDay->getTimestamp();
     return $this->findByTimeSlot($timeStampStart, $timeStampStart + DateTimeUtility::SECONDS_WEEK - 1);
 }
 /**
  * Get a normalize date time object
  *
  * @param int|null|string|\DateTime $dateInformation
  *
  * @return \DateTime
  */
 public static function normalizeDateTimeSingle($dateInformation)
 {
     if ($dateInformation instanceof \DateTime) {
         return $dateInformation;
     } elseif (MathUtility::canBeInterpretedAsInteger($dateInformation)) {
         $dateInformation = '@' . $dateInformation;
     } elseif (!is_string($dateInformation)) {
         return self::getNow();
     }
     return new \DateTime($dateInformation, DateTimeUtility::getTimeZone());
 }
 /**
  * Render the search view
  *
  * @param \DateTime $startDate
  * @param \DateTime $endDate
  * @param array     $customSearch
  *
  * @ignorevalidation $startDate
  * @ignorevalidation $endDate
  * @ignorevalidation $customSearch
  */
 public function searchAction(\DateTime $startDate = NULL, \DateTime $endDate = NULL, array $customSearch = array())
 {
     if (!$startDate instanceof \DateTime) {
         $startDate = new \DateTime('now', DateTimeUtility::getTimeZone());
     }
     if (!$endDate instanceof \DateTime) {
         $endDate = new \DateTime('+1 month', DateTimeUtility::getTimeZone());
     }
     $this->view->assignMultiple(array('startDate' => $startDate, 'endDate' => $endDate, 'customSearch' => $customSearch, 'configurations' => $this->getCurrentConfigurations()));
 }
 /**
  * Render the view helper
  *
  * Note: You have to wrap this view helper in an f:if ViewHelper.
  * This VH just return a boolean evaluation value
  *
  * @param string|\DateTime $base
  * @param string|\DateTime $check
  *
  * @return string
  */
 public function render($base, $check)
 {
     $base = DateTimeUtility::normalizeDateTimeSingle($base);
     $check = DateTimeUtility::normalizeDateTimeSingle($check);
     return $base > $check;
 }
 /**
  * Render the search view
  *
  * @param \DateTime $startDate
  * @param \DateTime $endDate
  * @param array     $customSearch
  *
  * @ignorevalidation $startDate
  * @ignorevalidation $endDate
  * @ignorevalidation $customSearch
  */
 public function searchAction(\DateTime $startDate = null, \DateTime $endDate = null, array $customSearch = [])
 {
     $baseDate = DateTimeUtility::getNow();
     if (!$startDate instanceof \DateTime) {
         $startDate = clone $baseDate;
     }
     if (!$endDate instanceof \DateTime) {
         $baseDate->modify('+1 month');
         $endDate = $baseDate;
     }
     $this->slotExtendedAssignMultiple(['startDate' => $startDate, 'endDate' => $endDate, 'customSearch' => $customSearch, 'configurations' => $this->getCurrentConfigurations()], __CLASS__, __FUNCTION__);
 }
 /**
  * Get a normalize date time object
  *
  * @param int|null|\DateTime $dateTimeOrString
  *
  * @return \DateTime
  */
 public static function normalizeDateTimeSingle($dateTimeOrString)
 {
     if ($dateTimeOrString instanceof \DateTime) {
         return $dateTimeOrString;
     } elseif (!is_string($dateTimeOrString)) {
         $dateTimeOrString = 'now';
     }
     return new \DateTime($dateTimeOrString, DateTimeUtility::getTimeZone());
 }
 /**
  * find Week
  *
  * @param int $year
  * @param int $week
  *
  * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface
  */
 public function findWeek($year, $week)
 {
     $query = $this->createQuery();
     $constraints = $this->getDefaultConstraints($query);
     $firstDay = DateTimeUtility::convertWeekYear2DayMonthYear($week, $year);
     $timeStampStart = $firstDay->getTimestamp();
     $firstDay->modify('+1 week');
     $timeStampEnd = $firstDay->getTimestamp();
     $this->addTimeFrameConstraints($constraints, $query, $timeStampStart, $timeStampEnd);
     $query->matching($query->logicalAnd($constraints));
     return $query->execute();
 }
Beispiel #11
0
 /**
  * Get the complete end date
  *
  * @return \DateTime
  */
 public function getEndDateComplete()
 {
     $date = $this->getEndDate();
     if (!$this->isAllDay()) {
         $time = DateTimeUtility::normalizeDateTimeSingle($this->getEndTime());
         $date->setTime($time->format('H'), $time->format('i'), 0);
     }
     return $date;
 }