function __construct($identifier)
 {
     $locale = eZLocale::instance();
     $format = OCCalendarData::FULLDAY_IDENTIFIER_FORMAT;
     $this->identifier = $identifier;
     $dateTime = DateTime::createFromFormat($format, $identifier, OCCalendarData::timezone());
     if (!$dateTime instanceof DateTime) {
         throw new Exception("{$identifier} in format '{$format}' is not a valid DateTime");
     }
     $dateTime->setTime(0, 0, 0);
     $this->day = $dateTime->format('j');
     $this->shortDayName = $locale->shortDayName($dateTime->format('w'));
     $this->longDayName = $locale->longDayName($dateTime->format('w'));
     $this->month = $dateTime->format('n');
     $this->longMonthName = $locale->longMonthName($this->month);
     $this->shortMonthName = $locale->shortMonthName($this->month);
     $this->year = $dateTime->format('Y');
     $this->urlSuffix = "/(day)/{$this->day}/(month)/{$this->month}/(year)/{$this->year}";
     $this->dayStartDateTime = clone $dateTime;
     $this->dayStartDateTime->setTime(0, 0, 0);
     $this->dayStartTimestamp = $this->dayStartDateTime->format('U');
     $today = mktime(0, 0, 0, date('n'), date('j'), date('Y'));
     $tomorrow = mktime(0, 0, 0, date('n'), date('j') + 1, date('Y'));
     $this->isToday = $this->dayStartTimestamp == $today;
     $this->isTomorrow = $this->dayStartTimestamp == $tomorrow;
     $this->isInWeek = date('W', $this->dayStartTimestamp) == date('W', $today);
     $this->isInMonth = date('n', $this->dayStartTimestamp) == date('n', $today);
     $this->dayEndDateTime = clone $dateTime;
     $this->dayEndDateTime->setTime(23, 59, 59);
     $this->dayEndTimestamp = $this->dayEndDateTime->format('U');
     $this->container = array();
 }
 public static function getEvents(eZContentObjectTreeNode $node, array $parameters)
 {
     $events = array();
     $base = array('name' => $node->attribute('name'), 'main_node_id' => $node->attribute('main_node_id'), 'main_url_alias' => $node->attribute('url_alias'), 'fields' => array('attr_from_time_dt' => 0, 'attr_to_time_dt' => 0));
     try {
         $startDate = new DateTime('now', OCCalendarData::timezone());
         $startDate->setDate(date('Y', $parameters['search_from_timestamp']), date('n', $parameters['search_from_timestamp']), date('j', $parameters['search_from_timestamp']));
         $endDate = clone $startDate;
         $endDate->add(new DateInterval($parameters['interval']));
         $byDayInterval = new DateInterval('P1D');
         /** @var DateTime[] $byDayPeriod */
         $byDayPeriod = new DatePeriod($startDate, $byDayInterval, $endDate);
         $timeTable = self::getTimeTableFromNode($node);
         foreach ($byDayPeriod as $date) {
             $weekDay = $date->format('w');
             if (isset($timeTable[$weekDay])) {
                 foreach ($timeTable[$weekDay] as $value) {
                     $newEvent = $base;
                     $date->setTime($value['from_time']['hour'], $value['from_time']['minute']);
                     $newEvent['fields']['attr_from_time_dt'] = $date->format('Y-m-d\\TH:i:s\\Z');
                     $date->setTime($value['to_time']['hour'], $value['to_time']['minute']);
                     $newEvent['fields']['attr_to_time_dt'] = $date->format('Y-m-d\\TH:i:s\\Z');
                     $item = OCCalendarItem::fromEzfindResultArray($newEvent);
                     $events[] = $item;
                 }
             }
         }
     } catch (Exception $e) {
         eZDebug::writeError($e->getMessage(), __METHOD__);
     }
     return $events;
 }
 protected static function getDateTime($string)
 {
     // '%Y-%m-%dT%H:%M:%SZ' -> Y-m-d\TH:i:s\Z
     $date = DateTime::createFromFormat('Y-m-d\\TH:i:s\\Z', $string, OCCalendarData::timezone());
     return $date;
 }
Beispiel #4
0
        if ($parameters['view'] == 'program') {
            $redirectSuffix = "#day-" . $dateTime->format(OCCalendarData::FULLDAY_IDENTIFIER_FORMAT);
        }
    }
}
if ($http->hasGetVariable('NextMonthCalendarButton')) {
    $dateTime = DateTime::createFromFormat(OCCalendarData::PICKER_DATE_FORMAT, $http->getVariable('SearchDate'), OCCalendarData::timezone());
    if ($dateTime instanceof DateTime) {
        $dateTime->add(new DateInterval('P1M'));
        $parameters['day'] = $dateTime->format(OCCalendarData::DAY_IDENTIFIER_FORMAT);
        $parameters['month'] = $dateTime->format(OCCalendarData::MONTH_IDENTIFIER_FORMAT);
        $parameters['year'] = $dateTime->format(OCCalendarData::YEAR_IDENTIFIER_FORMAT);
    }
}
if ($http->hasGetVariable('PrevMonthCalendarButton')) {
    $dateTime = DateTime::createFromFormat(OCCalendarData::PICKER_DATE_FORMAT, $http->getVariable('SearchDate'), OCCalendarData::timezone());
    if ($dateTime instanceof DateTime) {
        $dateTime->sub(new DateInterval('P1M'));
        $parameters['day'] = $dateTime->format(OCCalendarData::DAY_IDENTIFIER_FORMAT);
        $parameters['month'] = $dateTime->format(OCCalendarData::MONTH_IDENTIFIER_FORMAT);
        $parameters['year'] = $dateTime->format(OCCalendarData::YEAR_IDENTIFIER_FORMAT);
    }
}
if ($http->hasGetVariable('SearchBlockButton')) {
    $parameters['interval'] = $http->hasGetVariable('SearchBlockInterval') ? $http->getVariable('SearchBlockInterval') : 'P1M';
    // intervallo per la ricerca dal blocco: 1 anno di default
}
foreach (array_keys(OCCalendarData::defaultParameters()) as $key) {
    if ($http->hasGetVariable($key)) {
        $value = $http->getVariable($key);
        if (!empty($value)) {