Ejemplo n.º 1
0
 function countevents($events, $start, $end)
 {
     $eventscount = 0;
     foreach ($events as $event) {
         $startday = xetadodb_date("d", $event['Time']);
         $startmonth = xetadodb_date("m", $event['Time']);
         $startyear = xetadodb_date("Y", $event['Time']);
         $starthour = xetadodb_date("H", $event['Time']);
         $startminute = xetadodb_date("i", $event['Time']);
         $endday = xetadodb_date("d", $event['Timeend']);
         $endmonth = xetadodb_date("m", $event['Timeend']);
         $endyear = xetadodb_date("Y", $event['Timeend']);
         $endhour = xetadodb_date("H", $event['Timeend']);
         $endminute = xetadodb_date("i", $event['Timeend']);
         $eventstart = xetadodb_mktime($starthour, $startminute, 0, $startmonth, $startday, $startyear);
         $eventend = xetadodb_mktime($endhour, $endminute, 0, $endmonth, $endday, $endyear);
         if ($eventstart <= $start && $eventend >= $start || $eventstart >= $start && $eventstart <= $end || $eventend >= $start && $eventend <= $end) {
             $eventscount++;
         }
     }
     return $eventscount;
 }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
function xetadodb_strftime($fmt, $ts = false, $is_gmt = false)
{
    global $xetadodb_DATE_LOCALE;
    if (!defined('xetadodb_TEST_DATES')) {
        if (abs($ts) <= 0x7fffffff) {
            // check if number in 32-bit signed range
            if (!defined('xetadodb_NO_NEGATIVE_TS') || $ts >= 0) {
                // if windows, must be +ve integer
                return $is_gmt ? @gmstrftime($fmt, $ts) : @strftime($fmt, $ts);
            }
        }
    }
    if (empty($xetadodb_DATE_LOCALE)) {
        /*
        	$tstr = strtoupper(gmstrftime('%c',31366800)); // 30 Dec 1970, 1 am
        	$sep = substr($tstr,2,1);
        	$hasAM = strrpos($tstr,'M') !== false;
        */
        # see http://phplens.com/lens/lensforum/msgs.php?id=14865 for reasoning, and changelog for version 0.24
        $dstr = gmstrftime('%x', 31366800);
        // 30 Dec 1970, 1 am
        $sep = substr($dstr, 2, 1);
        $tstr = strtoupper(gmstrftime('%X', 31366800));
        // 30 Dec 1970, 1 am
        $hasAM = strrpos($tstr, 'M') !== false;
        $xetadodb_DATE_LOCALE = array();
        $xetadodb_DATE_LOCALE[] = strncmp($tstr, '30', 2) == 0 ? 'd' . $sep . 'm' . $sep . 'y' : 'm' . $sep . 'd' . $sep . 'y';
        $xetadodb_DATE_LOCALE[] = $hasAM ? 'h:i:s a' : 'H:i:s';
    }
    $inpct = false;
    $fmtdate = '';
    for ($i = 0, $max = strlen($fmt); $i < $max; $i++) {
        $ch = $fmt[$i];
        if ($ch == '%') {
            if ($inpct) {
                $fmtdate .= '%';
                $inpct = false;
            } else {
                $inpct = true;
            }
        } else {
            if ($inpct) {
                $inpct = false;
                switch ($ch) {
                    case '0':
                    case '1':
                    case '2':
                    case '3':
                    case '4':
                    case '5':
                    case '6':
                    case '7':
                    case '8':
                    case '9':
                    case 'E':
                    case 'O':
                        /* ignore format modifiers */
                        $inpct = true;
                        break;
                    case 'a':
                        $fmtdate .= 'D';
                        break;
                    case 'A':
                        $fmtdate .= 'l';
                        break;
                    case 'h':
                    case 'b':
                        $fmtdate .= 'M';
                        break;
                    case 'B':
                        $fmtdate .= 'F';
                        break;
                    case 'c':
                        $fmtdate .= $xetadodb_DATE_LOCALE[0] . $xetadodb_DATE_LOCALE[1];
                        break;
                    case 'C':
                        $fmtdate .= '\\C?';
                        break;
                        // century
                    // century
                    case 'd':
                        $fmtdate .= 'd';
                        break;
                    case 'D':
                        $fmtdate .= 'm/d/y';
                        break;
                    case 'e':
                        $fmtdate .= 'j';
                        break;
                    case 'g':
                        $fmtdate .= '\\g?';
                        break;
                        //?
                    //?
                    case 'G':
                        $fmtdate .= '\\G?';
                        break;
                        //?
                    //?
                    case 'H':
                        $fmtdate .= 'H';
                        break;
                    case 'I':
                        $fmtdate .= 'h';
                        break;
                    case 'j':
                        $fmtdate .= '?z';
                        $parsej = true;
                        break;
                        // wrong as j=1-based, z=0-basd
                    // wrong as j=1-based, z=0-basd
                    case 'm':
                        $fmtdate .= 'm';
                        break;
                    case 'M':
                        $fmtdate .= 'i';
                        break;
                    case 'n':
                        $fmtdate .= "\n";
                        break;
                    case 'p':
                        $fmtdate .= 'a';
                        break;
                    case 'r':
                        $fmtdate .= 'h:i:s a';
                        break;
                    case 'R':
                        $fmtdate .= 'H:i:s';
                        break;
                    case 'S':
                        $fmtdate .= 's';
                        break;
                    case 't':
                        $fmtdate .= "\t";
                        break;
                    case 'T':
                        $fmtdate .= 'H:i:s';
                        break;
                    case 'u':
                        $fmtdate .= '?u';
                        $parseu = true;
                        break;
                        // wrong strftime=1-based, date=0-based
                    // wrong strftime=1-based, date=0-based
                    case 'U':
                        $fmtdate .= '?U';
                        $parseU = true;
                        break;
                        // wrong strftime=1-based, date=0-based
                    // wrong strftime=1-based, date=0-based
                    case 'x':
                        $fmtdate .= $xetadodb_DATE_LOCALE[0];
                        break;
                    case 'X':
                        $fmtdate .= $xetadodb_DATE_LOCALE[1];
                        break;
                    case 'w':
                        $fmtdate .= '?w';
                        $parseu = true;
                        break;
                        // wrong strftime=1-based, date=0-based
                    // wrong strftime=1-based, date=0-based
                    case 'W':
                        $fmtdate .= '?W';
                        $parseU = true;
                        break;
                        // wrong strftime=1-based, date=0-based
                    // wrong strftime=1-based, date=0-based
                    case 'y':
                        $fmtdate .= 'y';
                        break;
                    case 'Y':
                        $fmtdate .= 'Y';
                        break;
                    case 'Z':
                        $fmtdate .= 'T';
                        break;
                }
            } else {
                if ('A' <= $ch && $ch <= 'Z' || 'a' <= $ch && $ch <= 'z') {
                    $fmtdate .= "\\" . $ch;
                } else {
                    $fmtdate .= $ch;
                }
            }
        }
    }
    //echo "fmt=",$fmtdate,"<br>";
    if ($ts === false) {
        $ts = time();
    }
    $ret = xetadodb_date($fmtdate, $ts, $is_gmt);
    return $ret;
}