function getdatas() { global $modx; $resource_id = $modx->resource->get('id'); $month = abs($this->bloxconfig['month']); $year = $this->bloxconfig['year']; $monthcount = 3; for ($i = 0; $i < $monthcount; $i++) { $workingmonth = $month + $i; $timestart = xetadodb_mktime(0, 0, 0, $workingmonth, 01, $year); $timeend = $this->xettcal->get_ts_monthend($timestart); $timestampstart = strftime('%Y-%m-%d %H:%M:%S', $timestart); //umwandlung zu mysql-dateformat $timestampend = strftime('%Y-%m-%d %H:%M:%S', $timeend); $category = $this->bloxconfig['custom']['category']; //Monatsevents laden $limit = 0; $events = $this->getEvents($timestampstart, $timestampend, $limit, $category); //$events = addCustomFields($mxCalApp, $events); $cal = $this->xettcal->getMonthCal($year, $workingmonth); $datas = $this->xettcal->makeMonthArray($this->bloxconfig, $cal, array(), $events); $bloxdatas['innerrows']['month'][] = $datas['innerrows']['month'][0]; } //$bloxdatas['innerrows']['month'][0]['innerrows']['monthevents'] = $events; //echo '<pre>' . print_r($this->bloxconfig, true) . '</pre>'; //echo '<pre>' . print_r($bloxdatas, true) . '</pre>'; if ($this->bloxconfig['debug']) { echo '<pre>' . print_r($bloxdatas, true) . '</pre>'; echo '---------------------------------------'; echo '<pre>' . print_r($rows, true) . '</pre>'; } return $bloxdatas; }
$doc->Set('cacheable', '0'); $doc->Set('hidemenu', '1'); $doc->Set('published', $row['`published`']); $doc->Set('isfolder', '0'); $doc->Set('createdby', $createdby); $doc->Set('tvEasyEvents_HideTime', $row['`hide_time`']); $doc->Set('tvEasyEvents_Start', xetadodb_strftime("%d-%m-%Y %H:%M:%S", $row['`Time`'])); $doc->Set('tvEasyEvents_End', xetadodb_strftime("%d-%m-%Y %H:%M:%S", $row['`Timeend`'])); $doc->Save(); $parent = $doc->fields['id']; $tsmonth = xetadodb_mktime(0, 0, 0, xetadodb_strftime("%m", $row['`Time`']), 01, xetadodb_strftime("%Y", $row['`Time`'])); $monthend = xetadodb_mktime(0, 0, 0, xetadodb_strftime("%m", $row['`Timeend`']), 01, xetadodb_strftime("%Y", $row['`Timeend`'])); $oldtsmonth = xetadodb_mktime(0, 0, 0, xetadodb_strftime("%m", $_POST['oldTime']), 01, xetadodb_strftime("%Y", $_POST['oldTime'])); $oldmonthend = xetadodb_mktime(0, 0, 0, xetadodb_strftime("%m", $_POST['oldTimeend']), 01, xetadodb_strftime("%Y", $_POST['oldTimeend'])); if (isset($_POST['oldTime'])) { $tsmonth = $oldtsmonth < $tsmonth ? $oldtsmonth : $tsmonth; $monthend = $oldmonthend > $monthend ? $oldmonthend : $monthend; } $i = 1; while ($tsmonth <= $monthend) { $month = xetadodb_strftime("%m", $tsmonth); $year = xetadodb_strftime("%Y", $tsmonth); $cachename = 'month_' . $year . '_' . $month . '_1.cache.php'; $this->cache->deleteCache($cachename); $cachename = 'month_' . $year . '_' . $month . '_.cache.php'; $this->cache->deleteCache($cachename); $tsmonth = xetadodb_mktime(0, 0, 0, xetadodb_strftime("%m", $row['`Time`']) + $i, 01, xetadodb_strftime("%Y", $row['`Time`'])); $i++; } } $this->messages[] = $message;
function getinputTime($date, $time) { //Todo validate Date and Time $dateformatarr = explode(',', $this->bloxconfig['date_format']); $datearr = explode($this->bloxconfig['date_divider'], $date); $key = array_search('d', $dateformatarr); $day = $datearr[$key]; $key = array_search('m', $dateformatarr); $month = $datearr[$key]; $key = array_search('y', $dateformatarr); $year = $datearr[$key]; $timearr = explode(':', $time); $hour = $timearr[0]; $minute = $timearr[1]; return xetadodb_mktime($hour, $minute, 0, $month, $day, $year); }
<?php global $modx; $firstmonth = abs($this->bloxconfig['month']); $year = $this->bloxconfig['year']; $timestampfirstday = xetadodb_mktime(0, 0, 0, $firstmonth, 01, $year); $cal = $this->xettcal->getMonthDays($year, $firstmonth); //print_r($cal); $timestampday = xetadodb_strftime("%d", $this->bloxconfig['nowtimestamp']); $timestampmonth = xetadodb_strftime("%m", $this->bloxconfig['nowtimestamp']); $timestampyear = xetadodb_strftime("%Y", $this->bloxconfig['nowtimestamp']); $monthlist = array(); for ($monthcount = 1; $monthcount <= 12; $monthcount++) { $monthlist[$monthcount]['tsmonth'] = xetadodb_mktime(0, 0, 0, $timestampmonth + $monthcount - 1, 01, $timestampyear); } //Caching for template monthTpl $cachename = 'month_' . $year . '_' . $this->bloxconfig['month'] . '_' . $this->bloxconfig['canedit'] . '.cache.php'; if (($cacheoutput = $this->cache->readCache($cachename)) === false) { $cacheaction = '1'; //render new and save cachefile } else { $cacheaction = '2'; //use cached output } if ($cacheaction !== '2') { $roomsparent = $this->bloxconfig['custom']['docids']['rooms']; // Wohnungen suchen $tablename1 = $modx->getFullTableName('site_content') . ' sc'; $query = "select sc.id as room_ID,sc.pagetitle as room_title"; $query .= " from " . $tablename1; $query .= " where parent= " . $roomsparent;
function makeevents() { $rows = $this->getformfields(); foreach ($rows as $row) { if ($this->xetconfig['lasthour'] == '' || $this->xetconfig['lastminute'] == '') { $this->xetconfig['lasthour'] = $this->xetconfig['starthour']; $this->xetconfig['lastminute'] = $this->xetconfig['startminute']; } if ($this->xetconfig['lastday'] == '' || $this->xetconfig['lastmonth'] == '' || $this->xetconfig['lastyear'] == '') { $this->xetconfig['lastday'] = $this->xetconfig['startday']; $this->xetconfig['lastmonth'] = $this->xetconfig['startmonth']; $this->xetconfig['lastyear'] = $this->xetconfig['startyear']; } $starttimestamp = $row['`Time`']; if (isset($_POST['lastdate']) || isset($_POST['lasttime'])) { $dateformatarr = explode(',', $this->xetconfig['date_format']); $datearr = explode($this->xetconfig['date_divider'], $_POST['lastdate']); $key = array_search('d', $dateformatarr); $this->xetconfig['lastday'] = $datearr[$key]; $key = array_search('m', $dateformatarr); $this->xetconfig['lastmonth'] = $datearr[$key]; $key = array_search('y', $dateformatarr); $this->xetconfig['lastyear'] = $datearr[$key]; $timearr = explode(':', $_POST['lasttime']); $this->xetconfig['lasthour'] = $timearr[0]; $this->xetconfig['lastminute'] = $timearr[1]; } $lasttimestamp = xetadodb_mktime($this->xetconfig['lasthour'], $this->xetconfig['lastminute'], 0, $this->xetconfig['lastmonth'], $this->xetconfig['lastday'], $this->xetconfig['lastyear']); $adddays = 0; $thetime = $starttimestamp; $theDate = $thetime; while ($thetime <= $lasttimestamp) { $theday = xetadodb_strftime("%d", $theDate); $theyear = xetadodb_strftime("%Y", $theDate); $themonth = xetadodb_strftime("%m", $theDate); $lasttime = xetadodb_mktime($this->xetconfig['lasthour'], $this->xetconfig['lastminute'], 0, $themonth, $theday, $theyear); $i = 0; $thetime = $theDate; while ($thetime <= $lasttime) { $Time = $thetime; $fields = $row; $fields['`Time`'] = $Time; if (isset($_POST['lenminutes']) || isset($_POST['lenhours']) || isset($_POST['lendays'])) { $datelen = $_POST['lenminutes'] * 60 + $_POST['lenhours'] * 3600 + $_POST['lendays'] * 86400; $fields['`Timeend`'] = $Time + $datelen; } else { $fields['`Timeend`'] = $row['`Timeend`']; } $this->dbinsert($fields); $i++; if (isset($_POST['shiftminutes']) || isset($_POST['shifthours']) || isset($_POST['shiftdays'])) { $timeshift = $_POST['shiftminutes'] * 60 + $_POST['shifthours'] * 3600 + $_POST['shiftdays'] * 86400; } else { $timeshift = $this->xetconfig['timeshift']; } $addtime = $i * $timeshift; $thetime = $theDate + $addtime; } $adddays++; $theDate = $starttimestamp + $adddays * 86400; } } return; }
function getdatas() { global $modx; $resource_id = $modx->resource->get('id'); $now = time(); $month = abs($this->bloxconfig['month']); $year = $this->bloxconfig['year']; $timestart = xetadodb_mktime(0, 0, 0, $month, 01, $year); $timeend = $this->xettcal->get_ts_monthend($timestart); $timestampstart = strftime('%Y-%m-%d %H:%M:%S', $timestart); //umwandlung zu mysql-dateformat $timestampend = strftime('%Y-%m-%d %H:%M:%S', $timeend); $category = $this->bloxconfig['custom']['category']; $sync_list = isset($_REQUEST['sync_list']) ? $_REQUEST['sync_list'] : 0; unset($_GET['sync_list']); if ($sync_list) { $_GET['tsmonth'] = $timestart; unset($_GET['tsday']); unset($_GET['tsweek']); } $listmode = 'upcoming'; if (isset($_GET['tsday'])) { $listmode = 'dayevents'; unset($_GET['tsmonth']); unset($_GET['tsweek']); } if (isset($_GET['tsmonth'])) { $listmode = 'monthevents'; unset($_GET['tsday']); unset($_GET['tsweek']); } if (isset($_GET['tsweek'])) { $listmode = 'weekevents'; unset($_GET['tsday']); unset($_GET['tsmonth']); } $listmode = isset($_REQUEST['listmode']) ? $_REQUEST['listmode'] : $listmode; unset($_GET['listmode']); //Monatsevents laden $limit = 0; $events = $this->getEvents($timestampstart, $timestampend, $limit, $category); //$events = addCustomFields($mxCalApp, $events); $timestampfirstday = xetadodb_mktime(0, 0, 0, $month, 01, $year); $limit = 0; switch ($listmode) { case 'dayevents': $timestamp = (int) $_GET['tsday']; $d = xetadodb_date("d", $timestamp); $m = xetadodb_date("m", $timestamp); $y = xetadodb_date("Y", $timestamp); $tseventlist = xetadodb_mktime(0, 0, 0, $m, $d, $y); $timestampend = $this->xettcal->get_ts_dayend($tseventlist); break; case 'weekevents': $timestamp = (int) $_GET['tsweek']; $tseventlist = $this->xettcal->get_ts_weekstart($timestamp); $timestampend = $this->xettcal->get_ts_weekend($tseventlist); break; case 'monthevents': $timestamp = (int) $_GET['tsmonth']; $d = xetadodb_date("d", $timestamp); $m = xetadodb_date("m", $timestamp); $y = xetadodb_date("Y", $timestamp); $tseventlist = xetadodb_mktime(0, 0, 0, $m, '01', $y); $timestampend = $this->xettcal->get_ts_monthend($tseventlist); break; case 'upcoming': default: $timestamp = $now; $d = xetadodb_date("d", $timestamp); $m = xetadodb_date("m", $timestamp); $y = xetadodb_date("Y", $timestamp); $tseventlist = xetadodb_mktime(0, 0, 0, $m, $d, $y); $timestampend = xetadodb_mktime(0, 0, 0, $m, $d, $y + 1); $limit = array('limit' => $this->bloxconfig['limit'], 'offset' => $this->bloxconfig['offset']); break; } $timestampstart = strftime('%Y-%m-%d %H:%M:%S', $tseventlist); //umwandlung zu mysql-dateformat $timestampend = strftime('%Y-%m-%d %H:%M:%S', $timestampend); $listevents = $this->getEvents($timestampstart, $timestampend, $limit, $category); $numRows = $modx->getPlaceholder('total'); //Kategorien laden $cat_rows = array(); $c = $modx->newQuery('migxCalendarCategories'); $c->where(array('published' => 1)); if ($collection = $modx->getCollection('migxCalendarCategories', $c)) { foreach ($collection as $object) { $cat_row = $object->toArray(); $cat_rows[] = $cat_row; } } $cat_row = array(); $cat_row['id'] = '0'; $cat_row['name'] = 'Alle'; $cat_rows[] = $cat_row; $categories = array(); foreach ($cat_rows as $category) { $link['category'] = $modx->getOption('id', $category, 0); $category['cat_link'] = $this->helpers->smartModxUrl($resource_id, null, $link); $current = (int) $modx->getOption('category', $_GET, 0); $category['active_class'] = $current == $link['category'] ? 'active' : ''; $categories[] = $category; } $cal = $this->xettcal->getMonthCal($year, $month); $bloxdatas = $this->xettcal->makeMonthArray($this->bloxconfig, $cal, array(), $events); //$bloxdatas['innerrows']['month'][0]['innerrows']['monthevents'] = $events; $bloxdatas['innerrows']['eventlist'] = $listevents; $bloxdatas['innerrows']['category'] = $categories; //echo '<pre>' . print_r($this->bloxconfig, true) . '</pre>'; //echo '<pre>' . print_r($bloxdatas, true) . '</pre>'; unset($_GET['tsmonth']); unset($_GET['tsweek']); unset($_GET['tsday']); $link = array(); $link['tsday'] = time(); $bloxdatas['link_today'] = $this->helpers->smartModxUrl($resource_id, null, $link); $link = array(); $link['tsweek'] = time(); $bloxdatas['link_thisweek'] = $this->helpers->smartModxUrl($resource_id, null, $link); $link = array(); $link['tsmonth'] = time(); $bloxdatas['link_thismonth'] = $this->helpers->smartModxUrl($resource_id, null, $link); $link = array(); $link['listmode'] = 'upcoming'; $bloxdatas['link_upcoming'] = $this->helpers->smartModxUrl($resource_id, null, $link); require_once $this->bloxconfig['absolutepath'] . 'inc/Pagination.php'; $p = new Pagination(array('per_page' => $this->bloxconfig['limit'], 'num_links' => $this->bloxconfig['numLinks'], 'cur_page' => $this->bloxconfig['page'], 'total_rows' => $numRows, 'page_query_string' => $this->bloxconfig['pageVarKey'], 'use_page_numbers' => true)); $bloxdatas['pagination'] = $p->create_links(); //$bloxdatas['innerrows']['row'] = $rows; if ($this->bloxconfig['debug']) { //echo '<pre>' . print_r($bloxdatas, true) . '</pre>'; //echo '---------------------------------------'; //echo '<pre>' . print_r($rows, true) . '</pre>'; } return $bloxdatas; }
<?php $timestampstart = $this->xettcal->get_ts_daystart($row['tsday']); $timestampend = $this->xettcal->get_ts_dayend($row['tsday']); $startDate = xetadodb_strftime("%Y-%m-%d", $timestampstart); $endDate = xetadodb_strftime("%Y-%m-%d", $timestampend); $contentFields = 'id,pagetitle,description'; $limit = 0; // Include Easy Events class and instantiate object include_once $modx->config['base_path'] . 'assets/snippets/EasyEvents/EasyEvents.class.php'; $ee = new EasyEvents($row['room_ID']); $easyevents = $ee->getEvents($startDate, $endDate, $contentFields, $limit); $events = array(); if (count($easyevents) > 0) { foreach ($easyevents as $event) { $eedate = $ee->getDateFromTV($event['startDate']); $eetime = $ee->getTimeFromTV($event['startDate']); $arrdate = explode('-', $eedate); $arrtime = explode(':', $eetime); $event['Time'] = xetadodb_mktime($arrtime[0], $arrtime[1], $arrtime[2], $arrdate[1], $arrdate[2], $arrdate[0]); $eedate = $ee->getDateFromTV($event['endDate']); $eetime = $ee->getTimeFromTV($event['endDate']); $arrdate = explode('-', $eedate); $arrtime = explode(':', $eetime); $event['Timeend'] = xetadodb_mktime($arrtime[0], $arrtime[1], $arrtime[2], $arrdate[1], $arrdate[2], $arrdate[0]); //array_push($events, $event); $events[] = $event; } } $xettdatas = $events[0]; $xettdatas['groupeventscount'] = count($easyevents);
//$eetime=$ee->getTimeFromTV($event['startDate']); $arrdate = explode('-', $eedate); //$arrtime=explode(':',$eetime); $timestamp_high = xetadodb_mktime(00, 00, 00, $arrdate[1], $arrdate[2], $arrdate[0]); } $event['range_high'] = xetadodb_strftime("%Y-%m-%d", $timestamp_high); //////////////////////////// //find prev reservation //////////////////////////// $timestamp_low = $event['Time'] - 86400 * 30; $timestampend = xetadodb_mktime(00, 00, 00, $startdate[1], $startdate[2] - 1, $startdate[0]); $startDate = xetadodb_strftime("%Y-%m-%d", $timestamp_low); $endDate = xetadodb_strftime("%Y-%m-%d", $timestampend); $contentFields = 'id,pagetitle,description'; $limit = 1; // Include Easy Events class and instantiate object $easyevents = $this->xettcal->getEvents($startDate, $endDate, $contentFields, $limit, 'DESC', $room_id); //parameter orderDir added in getEvents - function (EasyEvents.class.php) if (count($easyevents) > 0) { $tmpevent = $easyevents[0]; $eedate = $this->xettcal->getDateFromTV($tmpevent['endDate']); //$eetime=$ee->getTimeFromTV($event['endDate']); $arrdate = explode('-', $eedate); //$arrtime=explode(':',$eetime); //$event['Timeend']=adodb_mktime(00, 00, 00, $arrdate[1], $arrdate[2], $arrdate[0]); $timestamp_low = xetadodb_mktime(00, 00, 00, $arrdate[1], $arrdate[2], $arrdate[0]); } $event['range_low'] = xetadodb_strftime("%Y-%m-%d", $timestamp_low); $xettdatas = $event; unset($easyevents); unset($tmpevent);
$query .= " where room_ID= " . $room_ID; $query .= " and Time >= '{$timestampstart}' "; $query .= " and published = '1' "; $query .= " order by Time limit 1"; $rs = $modx->db->query($query); $events = $modx->db->makeArray($rs); if (count($events) > 0) { $tmpevent = $events[0]; $timestamp_high = $tmpevent['Time']; } $event['range_high'] = xetadodb_strftime("%Y-%m-%d", $timestamp_high); //////////////////////////// //find prev reservation //////////////////////////// $timestamp_low = $now - 86400 * 30; $timestampend = xetadodb_mktime(00, 00, 00, $getmonth, $getday, $getyear); $query = "select *"; $query .= " from " . $tablename; $query .= " where room_ID= " . $room_ID; $query .= " and Timeend <= '{$timestampstart}' "; $query .= " and published = '1' "; $query .= " order by Time DESC limit 1"; $rs = $modx->db->query($query); $events = $modx->db->makeArray($rs); if (count($events) > 0) { $tmpevent = $events[0]; $timestamp_low = $tmpevent['Timeend']; } $event['range_low'] = xetadodb_strftime("%Y-%m-%d", $timestamp_low); $xettdatas = $event; unset($easyevents);
function tsmonth($timestamp, $useadodbtime, $dateoptions) { $timeshift = isset($dateoptions[1]) ? $dateoptions[1] : '-0'; $day = $useadodbtime == '1' ? xetadodb_date("d", $timestamp) : date("d", $timestamp); $month = $this->month($timestamp, $useadodbtime, $dateoptions) + $timeshift; $year = $this->year($timestamp, $useadodbtime, $dateoptions); if (substr($timeshift, 0, 1) == '-') { return $useadodbtime == '1' ? xetadodb_mktime(0, 0, 0, $month, $day, $year) : mktime(0, 0, 0, $month, $day, $year); } else { return $useadodbtime == '1' ? xetadodb_mktime(23, 59, 59, $month, $day, $year) : mktime(23, 59, 59, $month, $day, $year); } }
<?php global $modx; $roomsparent = $this->xetconfig['docids']['rooms']; // Wohnungen suchen $tablename1 = $modx->getFullTableName('site_content') . ' sc'; $query = "select sc.id as room_ID,sc.pagetitle as room_title"; $query .= " from " . $tablename1; $query .= " where id= " . $modx->documentIdentifier; $query .= " and description <> 'noroom' "; $rs = $modx->db->query($query); $rooms = $modx->db->makearray($rs); //$innerdatas['rooms']=$tmpevents; $events = array(); $room = $rooms[0]; $room_id = $room['room_ID']; $room['getDatasOnRender'] = '1'; $events[$room_id]['groupdatas'] = $room; //$events=array(); $firstmonth = abs($this->xetconfig['month']); $year = $this->xetconfig['year']; $timestampfirstday = xetadodb_mktime(0, 0, 0, $firstmonth, 01, $year); $this->xettcal->events_grouped = '1'; $cal = $this->xettcal->getMonthCal($year, $firstmonth); $outerdata = $this->xettcal->makeMonthArray($this->xetconfig, $cal, array(), $events); $outerdata['tsconfig'] = $timestampfirstday; $xettdatas = $outerdata;
/** Returns a timestamp given a GMT/UTC time. Note that $is_dst is not implemented and is ignored. */ function xetadodb_gmmktime($hr, $min, $sec, $mon = false, $day = false, $year = false, $is_dst = false) { return xetadodb_mktime($hr, $min, $sec, $mon, $day, $year, $is_dst, true); }
<?php global $modx; $firstmonth = abs($this->xetconfig['month']); $year = $this->xetconfig['year']; $timestampfirstday = xetadodb_mktime(0, 0, 0, $firstmonth, 01, $year); $cal = $this->xettcal->getMonthDays($year, $firstmonth); //print_r($cal); $monthlist = array(); for ($monthcount = 1; $monthcount <= 12; $monthcount++) { $monthlist[$monthcount]['tsmonth'] = xetadodb_mktime(0, 0, 0, $this->xetconfig['nowmonth'] + $monthcount - 1, 01, $this->xetconfig['nowyear']); } //Caching for template monthTpl $cachename = 'month_' . $year . '_' . $this->xetconfig['month'] . '_' . $this->xetconfig['canedit'] . '.cache.php'; if (($cacheoutput = $this->cache->readCache($cachename)) === false) { $cacheaction = '1'; //render new and save cachefile } else { $cacheaction = '2'; //use cached output } if ($cacheaction !== '2') { $roomsparent = $this->xetconfig['docids']['rooms']; // Wohnungen suchen $tablename1 = $modx->getFullTableName('site_content') . ' sc'; $query = "select sc.id as room_ID,sc.pagetitle as room_title"; $query .= " from " . $tablename1; $query .= " where parent= " . $roomsparent; $query .= " and description <> 'noroom' "; $query .= " order by room_title "; $rows = $this->getevents($query);