if( $date = gps('date') ) { $_GET['month'] = $date; } function smd_calendar($atts, $thing='') { global $pretext, $thisarticle, $variable, $prefs, $smd_cal_flag, $smd_date, $smd_calinfo, $smd_cal_ucls; extract(lAtts(array( 'time' => 'any', 'size' => 'large', 'expired' => '', 'category' => '', 'section' => '', 'author' => '', 'realname' => '', 'status' => 'live', 'showall' => '0', 'static' => '', 'form' => '', 'spanform' => 'SMD_SAME', 'recurform' => 'SMD_SAME', 'cellform' => '', 'stepfield' => '', 'skipfield' => '', 'omitfield' => '', 'extrafield' => '', 'extrastrict' => '0', 'datefields' => '', 'showskipped' => '0', 'showspanned' => '1', 'holidays' => '', 'holidayflags' => 'standard', 'classlevels' => 'cell, event', 'linkposted' => 'recur, multi, multiprev, multilast', 'classprefixes' => 'smd_cal_, smd_cal_ev_', 'class' => '', 'rowclass' => '', 'cellclass' => '', 'emptyclass' => 'empty', 'isoweekclass' => 'week', 'navclass' => 'navprev, navnext', 'navarrow' => '<, >', 'navid' => '', 'eventclasses' => 'category', 'eventwraptag' => 'span', 'select' => '', 'selectbtn' => '', 'myclass' => '', 'mywraptag' => '', 'id' => '', 'week' => '', 'month' => '', 'year' => '', 'remap' => '', 'yearwidth' => '0', 'isoweeks' => '', 'dayformat' => 'ABBR', 'monthformat' => 'FULL', 'firstday' => 0, 'maintain' => 'calid', 'nameval' => '', 'gmt' => 0, 'lang' => '', 'debug' => 0, ), $atts)); $future = ( $time != 'past' ) ? true : false; $status = ($status) ? $status : 'live'; $firstday = ($isoweeks == '') ? $firstday : 1; $spanform = ($spanform == 'SMD_SAME') ? $form : $spanform; $recurform = ($recurform == 'SMD_SAME') ? $form : $recurform; $cellform = (empty($cellform)) ? '' : fetch_form($cellform); $frontpage = ($section=='' && $pretext['s']=='default') ? true : false; $clevs = do_list($classlevels); $cls = do_list($classprefixes); $cls_pfx = $evc_pfx = $cls[0]; if (count($cls) > 1){ $evc_pfx = $cls[1]; } $maintain = do_list($maintain); $navarrow = do_list($navarrow); $navparr = $navarrow[0]; $navnarr = (count($navarrow) > 1) ? $navarrow[1] : $navarrow[0]; $navclass = do_list($navclass); $navpclass = $navclass[0]; $navnclass = (count($navclass) > 1) ? $navclass[1] : $navclass[0]; $fopts = array(); $catSQL = $secSQL = $authSQL = $fpSQL = ''; if($category) { $fopts['c'] = $category; $catSQL = doQuote(join("','", doSlash(do_list($category)))); $catSQL = " AND ( Category1 IN (".$catSQL.") OR Category2 IN (".$catSQL.") ) "; } if($section) { $secs = do_list($section); $smd_calinfo['s'] = $secs[0]; $secSQL = doQuote(join("','", doSlash($secs))); $secSQL = " AND Section IN (".$secSQL.") "; } if($realname) { $authors = safe_column('name', 'txp_users', 'RealName IN ('. doQuote(join("','", doArray(do_list($realname), 'urldecode'))) .')' ); $author = join(',', $authors); } if($author) { $fopts['author'] = htmlentities(gps('author')); $authSQL = doQuote(join("','", doSlash(do_list($author)))); $authSQL = " AND AuthorID IN (".$authSQL.") "; } if ($frontpage && !$showall) { $fpSQL = filterFrontPage(); } $smd_calinfo['artid'] = $thisarticle['thisid']; $smd_calinfo['artitle'] = $thisarticle['url_title']; $nameval = do_list($nameval); foreach ($nameval as $nv) { $nv = explode("=", $nv); if ($nv[0]) { $fopts[$nv[0]] = ((isset($nv[1])) ? $nv[1] : ''); } } $status = do_list($status); $stati = array(); foreach ($status as $stat) { if (empty($stat)) { continue; } else if (is_numeric($stat)) { $stati[] = $stat; } else { $stati[] = getStatusNum($stat); } } $stati = " Status IN (".join(',', $stati).")"; $expired = ($expired) ? $expired : $prefs['publish_expired_articles']; $expired = (($expired) ? '' : ' AND (now() <= Expires OR Expires = '.NULLDATETIME.')'); $eventclasses = do_list($eventclasses); $holidayflags = do_list($holidayflags); $linkposted = do_list($linkposted); $datefields = do_list($datefields); $filt = $stati . (($category) ? $catSQL : '') . (($section) ? $secSQL : '') . (($author) ? $authSQL : '') . $fpSQL; $earliest = safe_field('unix_timestamp(Posted) AS uPosted', 'textpattern', $filt .' ORDER BY Posted ASC LIMIT 0, 1', $debug); $lp = safe_field('unix_timestamp(Posted) AS uPosted', 'textpattern', $filt .' ORDER BY Posted DESC LIMIT 0, 1', $debug); $lm = safe_field('unix_timestamp(LastMod) AS uLastMod', 'textpattern', $filt .' ORDER BY LastMod DESC LIMIT 0, 1', $debug); $latest = ($time=="past") ? time() : (($lp > $lm) ? $lp : $lm); $yearwidth = do_list($yearwidth); $yearwidth[0] = (empty($yearwidth[0])) ? 0 : $yearwidth[0]; if (count($yearwidth) == 1) { $yearwidth[1] = $yearwidth[0]; } $usenow = array(false,false); foreach ($yearwidth as $yridx => $yritem) { if (strpos($yritem,"c") !== false) { $yearwidth[$yridx] = intval($yritem); $usenow[$yridx] = true; } } $remap = do_list($remap); $dmap = array("y" => "y", "m" => "m", "w" => "w"); foreach ($remap as $dpair) { $dpair = do_list($dpair, ':'); $dmap[$dpair[0]] = (isset($dpair[1])) ? $dpair[1] : $dpair[0]; } $earliest = date("Y", strtotime("-".$yearwidth[0]." year", ( (empty($earliest) || $usenow[0]==true) ? time() : $earliest) ) ); $latest = date("Y", strtotime("+".$yearwidth[1]." year", ( (empty($latest) || $usenow[1]==true) ? time() : $latest) ) ); $in_calid = gps('calid'); $in_year = (gps($dmap["y"]) and is_numeric(gps($dmap["y"]))) ? (int)gps($dmap["y"]) : ''; $in_month = (gps($dmap["m"]) and is_numeric(gps($dmap["m"]))) ? (int)gps($dmap["m"]) : ''; $in_week = (gps($dmap["w"]) and is_numeric(gps($dmap["w"]))) ? (int)gps($dmap["w"]) : ''; if($static) { if(!$year) { $year = safe_strftime('%Y'); } if(!$month) { $month = safe_strftime('%m'); } } else { if( $id == $in_calid ) { $year = ($in_year) ? $in_year : (($year) ? $year : safe_strftime('%Y')); $month = ($in_month) ? $in_month : (($month) ? $month : safe_strftime('%m')); $week = $in_week; if ($week) { $month = safe_strftime("%m", strtotime($year."W".str_pad($week, 2, '0', STR_PAD_LEFT))); } } else { if(!$year) { $year = safe_strftime('%Y'); } if(!$month) { $month = safe_strftime('%m'); } if($week) { $month = safe_strftime("%m", strtotime($year."W".str_pad($week, 2, '0', STR_PAD_LEFT))); } } } $smd_calinfo['id'] = ($in_calid) ? $in_calid : $id; $smd_date['y'] = $year; $smd_date['m'] = $month; $ts_first = mktime(0, 0, 0, $month, 1, $year); $ts_last = mktime(23, 59, 59, $month, date('t',$ts_first), $year); $extrasql = $catSQL . $secSQL . $authSQL . $fpSQL; switch($time) { case "any" : break; case "future" : $extrasql .= " AND Posted > CURDATE()"; break; default : $extrasql .= " AND Posted < CURDATE()"; break; } $holidays = do_list($holidays); $txphols = do_list($holidays[0], ":"); if ($txphols[0] == "txpvar") { $holidays = do_list($variable[$txphols[1]]); } foreach ($holidays as $key => $val) { if (empty($val)) continue; $numparts = preg_match('/^([\d\w]+).?([\d\w]+).?([\d\w]+)?$/', $val, $parts); if ($numparts) { if (count($parts) == 3) { $parts[3] = $year; } $val = str_pad($parts[1], 2, '0', STR_PAD_LEFT).'-'.str_pad($parts[2], 2, '0', STR_PAD_LEFT).'-'.$parts[3]; } $holidays[$key] = date("d-M-Y", strtotime($val)); } if ($debug > 0 && !empty($holidays) && $holidays[0] != '') { echo "++ HOLIDAYS ++ "; dmp($holidays); } $events = array(); $sql2 = $stati . " HAVING uPosted <= ".$ts_last . $expired . $extrasql ." ORDER BY Posted ASC"; $grabCols = '*, unix_timestamp(Posted) as uPosted, unix_timestamp(LastMod) as uLastMod, unix_timestamp(Expires) as uExpires'; $evlist = safe_rows($grabCols, 'textpattern', $sql2, $debug); article_push(); foreach ($evlist as $row) { $idx = 0; $start = (!empty($datefields[0]) && !empty($row[$datefields[0]]) && ($stdt = strtotime($row[$datefields[0]])) !== false) ? $stdt : $row['uPosted']; $start_date = date("Y-m-d", $start); $real_end = (isset($datefields[1]) && !empty($row[$datefields[1]]) && ($endt = strtotime($row[$datefields[1]])) !== false) ? $endt : $row['uExpires']; if ($real_end != 0 && $real_end <= $start) { $start = $row['uPosted']; $real_end = $row['uExpires']; trigger_error('Expiry cannot be before start date in "'.$row['Title'].'": ignored', E_USER_WARNING); } $end = ($real_end != 0 && $real_end < $ts_last) ? $real_end : $ts_last; $real_diff = ($real_end==0) ? 0 : $real_end - $start; $fake_diff = strtotime(date("Y-M-d", $real_end) . " 23:59:59"); $diff = ($real_end==0) ? 0 : $fake_diff - $start; $smd_cal_flag = $smd_cal_ucls = array(); if ($debug > 1) { echo '++ EVENT START // END // REAL END ++'; dmp($row['Title']); dmp(date('d-M-Y H:i:s', $start) .' // '. date('d-M-Y H:i:s', $end) .' // '. date('d-M-Y H:i:s', $real_end)); if ($debug > 2) { dmp($row); } } $multi = ($real_end > $start && $real_end > $ts_first && (date("d-m-Y", $real_end) != date("d-m-Y", $start))) ? true : false; $recur = (empty($row[$stepfield])) ? false : true; $hol_hit = in_array(date("d-M-Y", $start), $holidays); $evclasses = array(); foreach ($eventclasses as $evcls) { switch ($evcls) { case "": break; case "gcat": if (isset($pretext['c']) && !empty($pretext['c'])) { $evclasses[] = $evc_pfx.$pretext['c']; } break; case "category": if (isset($row['Category1']) && !empty($row['Category1'])) { $evclasses[] = $evc_pfx.$row['Category1']; } if (isset($row['Category2']) && !empty($row['Category2'])) { $evclasses[] = $evc_pfx.$row['Category2']; } break; case "section": if (isset($pretext['s']) && !empty($pretext['s'])) { $evclasses[] = $evc_pfx.$pretext['s']; } break; case "author": if (isset($pretext['author']) && !empty($pretext['author'])) { $evclasses[] = $evc_pfx.$pretext['author']; } break; default: if (isset($row[$evcls]) && !empty($row[$evcls])) { $evclasses[] = $evc_pfx.$row[$evcls]; } break; } } $evclasses = ($evclasses) ? ' '. join(' ', $evclasses) : ''; $ignore = $omit = $cflag = array(); if ($debug > 1 && $evclasses) { echo '++ EVENT CLASSES ++'; dmp($evclasses); } if ($start < $end && $start > $ts_first) { populateArticleData($row); if ($showspanned && $multi && !$recur) { $smd_cal_flag[] = 'multifirst'; } if ($recur) { $smd_cal_flag[] = 'recurfirst'; } if (!$smd_cal_flag) { $smd_cal_flag[] = 'standard'; } if ( ( $hol_hit && !in_array('multi',$holidayflags) && in_array('multifirst',$smd_cal_flag) ) || ( $hol_hit && !in_array('standard',$holidayflags) && in_array('standard',$smd_cal_flag) ) ) { $smd_cal_flag[] = 'cancel'; } foreach ($smd_cal_flag as $item) { $cflag[] = $cls_pfx.$item; } $idx = $smd_date['d'] = (int)strftime('%d', $start); $smd_date['w'] = strftime('%V', $start); $smd_date['iy'] = strftime('%G', $start); $op = ($thing) ? parse($thing) : (($form) ? parse_form($form) : (($size=="small") ? '' : href($row['Title'], permlinkurl($row), ' title="'.$row['Title'].'"')) ); $events[$idx][] = array('ev' => $op, 'flag' => $smd_cal_flag, 'classes' => (($cflag) ? join(' ',array_merge($cflag, $smd_cal_ucls)) : '').$evclasses, 'posted' => $start_date); $smd_cal_flag = $cflag = $smd_cal_ucls = array(); } if ($skipfield && $row[$skipfield] != '') { $ignores = do_list($row[$skipfield]); foreach ($ignores as $val) { $igrng = smd_expand_daterange($val); foreach ($igrng as $theval) { $ignore[] = date("d-M-Y", $theval); } } } if ($omitfield && $row[$omitfield] != '') { $omits = do_list($row[$omitfield]); foreach ($omits as $val) { $omrng = smd_expand_daterange($val); foreach ($omrng as $theval) { $omit[] = date("d-M-Y", $theval); } } } if ($debug > 1 && ($ignore || $omit)) { echo '++ OMITTED DATES ++'; dmp($omit); echo '++ CANCELLED DATES ++'; dmp($ignore); } if ($stepfield && $row[$stepfield] != '') { $freq = do_list($row[$stepfield]); foreach ($freq as $interval) { $max_loop = 99999; $origerval = $interval; $interval = str_replace("?month", date('F', gmmktime(0,0,0,$month,1)), $interval); $interval = str_replace("?year", $year, $interval); if (strpos($interval, "last") === 0) { $interval = date("l, F jS Y", strtotime($interval, mktime(12, 0, 0, date("n",mktime(0,0,0,$month,1,$year))+1, 1, $year))); $max_loop = 1; } else if (strpos($interval, "first") === 0) { $interval = date("l, F jS Y", strtotime($interval, mktime(12, 0, 0, (($month>1) ? $month-1 : 12), date("t",mktime(0,0,0,$month-1,1,(($month==1) ? $year-1: $year))), (($month==1) ? $year-1: $year)))); $max_loop = 1; } $ts_loop = 0; $ts_curr = $start; if (strpos($origerval, "?month") || strpos($origerval, "?year")) { $max_loop = 1; } while ($ts_curr < $end && $ts_loop < $max_loop) { if ($max_loop == 1) { $ts_curr = strtotime($interval); $ts_curr = ($ts_curr < $start || $ts_curr > $end) ? $start : $ts_curr; } else { $ts_curr = strtotime($interval, $ts_curr); } if ($ts_curr === false) { $ts_loop++; break; } else { if ($debug > 1) { dmp("INTERVAL: ". date('d-M-Y H:i:s', $ts_curr)); } if ($ts_curr < $end && $ts_curr >= $ts_first && $ts_curr != $start) { populateArticleData($row); $op = ''; $idx = (int)strftime('%d', $ts_curr); $smd_cal_flag[] = 'recur'; $thisdate = date("d-M-Y", $ts_curr); $omit_me = in_array($thisdate, $omit); $show_me = !in_array($thisdate, $ignore); $hol_hit = in_array($thisdate, $holidays); $show_hol = ($hol_hit && !in_array('recur',$holidayflags) ) ? false : true; if ( $omit_me ) { $smd_cal_flag[] = 'omit'; } if ( (!$show_me || !$show_hol) && !$omit_me ) { $smd_cal_flag[] = 'cancel'; } foreach ($smd_cal_flag as $item) { $cflag[] = $cls_pfx.$item; } if (!$omit_me) { if (($show_me && $show_hol) || $showskipped) { $smd_date['d'] = $idx; $smd_date['w'] = strftime('%V', $ts_curr); $smd_date['iy'] = strftime('%G', $ts_curr); $op = ($recurform) ? parse_form($recurform) : (($thing) ? parse($thing) : (($size=="small") ? '' : href($row['Title'], permlinkurl($row), ' title="'.$row['Title'].'"')) ); } } $used = array(); if (isset($events[$idx]) && $events[$idx] != NULL) { foreach ($events[$idx] as $ev) { $used[] = $ev['ev']; } } if (isset($events[$idx]) && $events[$idx] == NULL || !in_array($op, $used)) { $events[$idx][] = array('ev' => $op, 'flag' => $smd_cal_flag, 'classes' => (($cflag) ? join(' ',array_merge($cflag, $smd_cal_ucls)) : '').$evclasses, 'posted' => $start_date); } $smd_cal_flag = $cflag = $smd_cal_ucls = array(); } $ts_loop++; } } } } else if ($showspanned && $multi) { populateArticleData($row); $lastday = (int)strftime('%d', $end); $real_lastday = (int)strftime('%d', $real_end); while (++$idx <= $lastday) { $op = ''; $multiflag = ($idx==$real_lastday) ? 'multilast' : (($idx==1) ? 'multiprev' : 'multi'); $smd_cal_flag[] = $multiflag; $thistime = gmmktime(0, 0, 0, $month, $idx, $year); $thisdate = date("d-M-Y", $thistime); $omit_me = in_array($thisdate, $omit); $show_me = !in_array($thisdate, $ignore); $hol_hit = in_array($thisdate, $holidays); $show_hol = ($hol_hit && !in_array('multi',$holidayflags) ) ? false : true; if ( $omit_me ) { $smd_cal_flag[] = 'omit'; } if ( (!$show_me || !$show_hol) && !$omit_me ) { $smd_cal_flag[] = 'cancel'; } foreach ($smd_cal_flag as $item) { $cflag[] = $cls_pfx.$item; } if (!$omit_me) { if ( ($show_me && $show_hol) || $showskipped) { $smd_date['d'] = $idx; $smd_date['w'] = strftime('%V', $thistime); $smd_date['iy'] = strftime('%G', $thistime); $op = ($spanform) ? parse_form($spanform) : (($thing) ? parse($thing) : (($size=="small") ? '' : href('→', permlinkurl($row), ' title="'.$row['Title'].'"')) ); } } $events[$idx][] = array('ev' => $op, 'flag' => $smd_cal_flag, 'classes' => (($cflag) ? join(' ',array_merge($cflag, $smd_cal_ucls)) : '').$evclasses, 'posted' => $start_date); $smd_cal_flag = $cflag = $smd_cal_ucls = array(); } } if ($extrafield && $row[$extrafield] != '') { $xtra = do_list($row[$extrafield]); $ev_hr = date('H', $start); $ev_mn = date('i', $start); $ev_sc = date('s', $start); $stampoff = (int)(3600*$ev_hr) + (int)(60*$ev_mn) + (int)$ev_sc; foreach ($xtra as $val) { if (strpos($val, "+") === false) { $exrng = smd_expand_daterange($val); $val = date("Y-m-d", $exrng[0]); $spidth = count($exrng); $spex = 0; } else { $chk = $showspanned && !$recur; $spidth = $chk ? ceil($diff / (60*60*24)) : 1; $val = rtrim($val, '+'); $spex = $chk ? 1 : 0; } for ($jdx = 1; $jdx <= $spidth; $jdx++) { $tm = strtotime($val . (($jdx==1) ? '' : '+'.($jdx-1).' days')); if ($diff > 0 && $jdx == 1) { $expstamp = $tm+$stampoff+$real_diff; } $idx = $smd_date['d'] = (int)strftime('%d', $tm); $dt = date("Y-m-d", $tm); $lst = ($extrastrict) ? $end : $ts_last; if ($tm < $lst && $tm >= $ts_first) { $fakerow = $row; $fakerow['Posted'] = date("Y-m-d H:i:s", $tm+$stampoff); $fakerow['uPosted'] = $tm+$stampoff; if ($diff>0) { $fakerow['Expires'] = date("Y-m-d H:i:s", $expstamp); $fakerow['uExpires'] = $expstamp; } populateArticleData($fakerow); $smd_cal_flag[] = 'extra'; $cflag[] = $cls_pfx.'extra'; $omit_me = false; $show_me = $show_hol = true; if ($spex) { $multiflag = ($jdx==1) ? 'multifirst' : (($jdx==$spidth) ? 'multilast' : (($idx==1) ? 'multiprev' : 'multi')); $thisdate = date("d-M-Y", $tm); $omit_me = in_array($thisdate, $omit); $show_me = !in_array($thisdate, $ignore); $hol_hit = in_array($thisdate, $holidays); $show_hol = ($hol_hit && !in_array('multi',$holidayflags) ) ? false : true; if ($omit_me) { $smd_cal_flag[] = 'omit'; } if ( (!$show_me || !$show_hol) && !$omit_me ) { $smd_cal_flag[] = 'cancel'; } $smd_cal_flag[] = $multiflag; $cflag[] = $cls_pfx.$multiflag; } if (!$omit_me) { if ( ($show_me && $show_hol) || $showskipped) { $smd_date['w'] = strftime('%V', $tm); $smd_date['iy'] = strftime('%G', $tm); $op = ($spex && $spanform) ? parse_form($spanform) : (($thing) ? parse($thing) : (($form) ? parse_form($form) : (($size=="small") ? '' : href((($spex && $jdx>1) ? '→' : $row['Title']), permlinkurl($row), ' title="'.$row['Title'].'"')) )); $events[$idx][] = array('ev' => $op, 'flag' => $smd_cal_flag, 'classes' => (($cflag) ? join(' ',array_merge($cflag, $smd_cal_ucls)) : '').$evclasses, 'posted' => $dt); $smd_cal_flag = $cflag = $smd_cal_ucls = array(); } } } } } } } article_pop(); if ($debug > 1 && $events) { echo '++ ALL EVENTS ++'; dmp($events); } if( $size == "small" ) { $calendar = new SMD_Small_Calendar($year, $month, $events, $section, $category); } else { $calendar = new SMD_Calendar($year, $month, $events); } $calendar->setWeek($week); $calendar->setGMT($gmt); $calendar->setLang($lang); $calendar->setClassLevels($clevs); $calendar->setClassPrefix($cls_pfx); $calendar->setEventWraptag($eventwraptag); $calendar->setCellForm($cellform); $calendar->setMYWraptag($mywraptag); $calendar->setTableID($id); $calendar->setTableClass($class); $calendar->setRowClass($rowclass); $calendar->setCellClass($cellclass); $calendar->setEmptyClass($emptyclass); $calendar->setISOWeekClass($isoweekclass); $calendar->setNavInfo($navpclass,$navnclass,$navparr,$navnarr,$navid); $calendar->setNavKeep($maintain); $calendar->setMYClass($myclass); $calendar->setNameFormat($dayformat, "d"); $calendar->setNameFormat($monthformat, "m"); $calendar->setRemap($dmap); $calendar->setShowISOWeek($isoweeks); $calendar->setEYear($earliest); $calendar->setLYear($latest); $calendar->setFilterOpts($fopts); $calendar->setHolidays($holidays); $calendar->setSelectors(do_list($select), $selectbtn); $calendar->setFirstDayOfWeek($firstday); $calendar->setLinkPosted($linkposted); return $calendar->display($static, $future); } class SMD_Calendar extends SMD_Raw_Calendar { function SMD_Calendar($year,$month,$events) { $this->events = $events; $this->SMD_Raw_Calendar($year,$month); } function dspDayCell($theday) { global $smd_cal_flag, $smd_calinfo, $smd_cal_ucls, $smd_date; $smd_cal_flag = $smd_cal_ucls = array(); $hasarticle = isset($this->events[$theday]); $thedate = gmmktime(0, 0, 0, $this->month, $theday, $this->year); $hol_hit = in_array(date("d-M-Y", $thedate), $this->holidays); if ($hasarticle) { $smd_cal_flag[] = 'event'; } if ($hol_hit) { $smd_cal_flag[] = 'hols'; } $cflag = array(); foreach ($smd_cal_flag as $item) { $cflag[] = $this->cls_pfx.$item; } $tdclass = trim($this->cellclass . (($cflag) ? ' '.join(' ', $cflag) : '')); $runningclass = (in_array("cell", $this->cls_lev) || in_array("cellplus", $this->cls_lev)) ? explode(' ', $tdclass) : array(); if($this->year == date('Y',time()+tz_offset() ) and $this->month == date('n',time()+tz_offset() ) and $theday == date('j',time()+tz_offset()) ) { $smd_cal_flag[] = 'today'; $runningclass[] = $this->cls_pfx.'today'; } $out = $flags = array(); $fout = array('standard'=>array(),'recur'=>array(),'recurfirst'=>array(),'multifirst'=>array(),'multi'=>array(),'multiprev'=>array(),'multilast'=>array(),'cancel'=>array(),'extra'=>array()); if (empty($this->cellform)) { $out[] = hed($theday,4); } if( isset($this->events[$theday]) ) { $days_events = $this->events[$theday]; foreach($days_events as $ev) { $evclass = trim($ev['classes']); $flags = array_merge($flags, $ev['flag']); if (in_array("cellplus", $this->cls_lev)) { foreach (explode(' ', $evclass) as $evc) { $runningclass[]= $evc; } } $cls = ($evclass && in_array("event", $this->cls_lev)) ? ' class="'.trim($evclass).'"' : ''; $op = ($this->evwraptag) ? tag($ev['ev'], $this->evwraptag, $cls) : $ev['ev']; foreach ($ev['flag'] as $flev) { $fout[$flev][] = $op; } $out[] = $op; } } $runningclass = array_unique($runningclass); if (in_array("cellplus", $this->cls_lev)) { $smd_cal_flag = array_merge($smd_cal_flag, $flags); } if ($this->cellform) { $thistime = gmmktime(0, 0, 0, $this->month, $theday, $this->year); $smd_calinfo['id'] = $this->tableID; $smd_date['y'] = $this->year; $smd_date['m'] = $this->month; $smd_date['w'] = strftime("%V", $thistime); $smd_date['iy'] = strftime("%G", $thistime); $smd_date['d'] = $theday; $reps = array( '{standard}' => join('',$fout['standard']), '{recur}' => join('',$fout['recur']), '{recurfirst}' => join('',$fout['recurfirst']), '{allrecur}' => join('',array_merge($fout['recur'], $fout['recurfirst'])), '{multifirst}' => join('',$fout['multifirst']), '{multiprev}' => join('',$fout['multiprev']), '{multi}' => join('',$fout['multilast']), '{multilast}' => join('',$fout['multilast']), '{allmulti}' => join('',array_merge($fout['multifirst'],$fout['multi'],$fout['multiprev'],$fout['multilast'])), '{cancel}' => join('',$fout['cancel']), '{extra}' => join('',$fout['extra']), '{events}' => join('',$out), '{day}' => $theday, '{weekday}' => ((is_array($this->dayNameFmt)) ? $this->dayNames[date('w',$thistime)] : strftime($this->dayNameFmt, $thistime)), '{week}' => $smd_date['w'], '{month}' => $this->month, '{monthname}' => ((is_array($this->mthNameFmt)) ? $this->mthNames[date('n',$thistime)] : strftime($this->mthNameFmt, $thistime)), '{year}' => $this->year, '{shortyear}' => strftime("%y", $thistime), '{isoyear}' => $smd_date['iy'], '{shortisoyear}' => strftime("%g", $thistime), ); $cellout = parse(strtr($this->cellform, $reps)); $carray = array_merge($runningclass, $smd_cal_ucls); $smd_cal_ucls = array(); return doTag($cellout,'td',join(' ',$carray)); } else { return doTag(join('',$out),'td',join(' ',$runningclass)); } } function display($static=false, $future=false) { $id = ($this->tableID) ? ' id="'.$this->tableID.'"' : ''; $c[] = $this->dspHeader($static, $future); $c[] = $this->dspDayNames(); $c[] = $this->dspDayCells(); return doTag(join('',$c),'table',$this->tableclass,$id); } function dspHeader($static, $future) { global $pretext, $smd_calinfo; $currmo = $this->month; $curryr = $this->year; $navpclass = $this->getNavInfo("pc"); $navnclass = $this->getNavInfo("nc"); $navparrow = $this->getNavInfo("pa"); $navnarrow = $this->getNavInfo("na"); $navid = $this->getNavInfo("id"); $navpclass = ($navpclass) ? ' class="'.$navpclass.'"' : ''; $navnclass = ($navnclass) ? ' class="'.$navnclass.'"' : ''; $fopts = $this->fopts; $sec = (isset($smd_calinfo['s']) && !empty($smd_calinfo['s'])) ? $smd_calinfo['s'] : ''; foreach ($this->maintain as $col) { switch ($col) { case "section": $sec = ($pretext['s']) ? $pretext['s'] : $sec; break; case "article": if ($pretext['id']) { $fopts = array('id' => $pretext['id']) + $fopts; } break; case "category": if ($pretext['c']) { $fopts = array('c' => $pretext['c']) + $fopts; } break; case "author": if (gps('author')) { $fopts = array('author' => gps('author')) + $fopts; } break; case "pg": if ($pretext['pg']) { $fopts = array('pg' => $pretext['pg']) + $fopts; } break; case "calid": if ($this->tableID) { $fopts = array('calid' => $this->tableID) + $fopts; } break; default: if (gps($col)) { $fopts = array($col => gps($col)) + $fopts; } break; } } $fopts = array_unique($fopts); $filters = array(); $filterHid = array(); if (!$static) { foreach($fopts as $key => $val) { $filters[] = $key.'='.$val; $filterHid[] = hInput($key, $val); } } $filterURL = join(a, $filters); if ($this->useSelector('week') && !$static) { $currwk = ($this->week) ? $this->week : date('W', strtotime($curryr."-".$currmo."-1 12:00")); for ( $idx = 1; $idx <= 53; $idx++ ) { $tagatts = ' value="'.$idx.'"'; if ( $idx == $currwk ) $tagatts .= ' selected="selected"'; $optiontags[] = doTag($this->selpfx['week'].str_pad($idx, 2, '0', STR_PAD_LEFT).$this->selsfx['week'], 'option', '', $tagatts); } $selector[] = doTag(join(n, $optiontags), 'select', (($this->mywraptag) ? '' : $this->myclass), ' name="'.$this->remap['w'].'"'.(($this->selbtn) ? '' : ' onchange="submit()"'), '') . (($this->useSelector('year')) ? '' : hInput($this->remap['y'], $curryr)); $optiontags = array(); } if (!$this->useSelector('week')) { if ($this->useSelector('month') && !$static) { for ( $idx = 1; $idx <= 12; $idx++ ) { $tagatts = ' value="'.$idx.'"'; if ( $idx == $currmo ) $tagatts .= ' selected="selected"'; $optiontags[] = doTag($this->selpfx['month'].((is_array($this->mthNameFmt)) ? $this->mthNames[date('n',gmmktime(12,0,0,$idx,1))] : strftime($this->mthNameFmt, gmmktime(12,0,0,$idx,1))).$this->selsfx['month'], 'option', '', $tagatts); } $selector[] = doTag(join(n, $optiontags), 'select', (($this->mywraptag) ? '' : $this->myclass), ' name="'.$this->remap['m'].'"'.(($this->selbtn) ? '' : ' onchange="submit()"'), '') . (($this->useSelector('year')) ? '' : hInput($this->remap['y'], $curryr)); $optiontags = array(); } else { $selector[] = doTag($this->getMonthName(), 'span', (($this->mywraptag) ? '' : $this->myclass)); } } $y0 = $this->eyr; $y1 = $this->lyr; if ($this->useSelector('year') && ($y0 != $y1) && !$static) { for ( $idx = $y0; $idx <= $y1; $idx++ ) { $tagatts = ' value="'.$idx.'"'; if ( $idx == $curryr ) $tagatts .= ' selected="selected"'; $optiontags[] = doTag($this->selpfx['year'].$idx.$this->selsfx['year'], 'option', '', $tagatts); } $selector[] = doTag(join(n, $optiontags), 'select', (($this->mywraptag) ? '' : $this->myclass), ' name="'.$this->remap['y'].'"'.(($this->selbtn) ? '' : ' onchange="submit()"'), '') . (($this->useSelector('month') || $this->useSelector('week')) ? '' : hInput($this->remap['m'], $currmo)); } else { $selector[] = doTag($curryr, 'span', (($this->mywraptag) ? '' : $this->myclass)); } $extras = ''; if (!$static && ( $this->useSelector('month') || $this->useSelector('year') )) { if ($this->selbtn) { $extras .= doTag('', 'input', 'smd_cal_input', ' type="submit" value="'.$this->selbtn.'"'); } $extras .= join('', $filterHid); } $urlp = parse_url($pretext['request_uri']); $selector = '
'; $nav_back_link = $this->navigation($curryr, $currmo, '-', $filterURL, $sec); $nav_fwd_link = $this->navigation($curryr, $currmo, '+', $filterURL, $sec); $nav_back = (!$static && $nav_back_link) ? ''.$navparrow.'' : ' '; $nav_fwd = (!$static && $future && $nav_fwd_link) ? ''.$navnarrow.'' : ' '; $c[] = doTag($nav_back,'th'); $c[] = '