WebsiteBaker 2.13.9 R22 is now available!
R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WBhttps://forum.websitebaker.org/index.php/topic,32355.0.html
[[eventlist?section_id=xx&flags=5&days=14]]
$dateformat = ($dateformat ?? 'd.m H:i'); // Standard php date formats 'd-m-Y'
$dateformat = ($dateformat ?? 'd.m.Y H:i'); // Standard php date formats 'd-m-Y'
[[eventlist?section_id=12&max=5]]
$oReg = bin\WbAdaptor::getInstance();$database = $oDb = $oReg->getDatabase();$wb = $oReg->getApplication();$oTrans = $oReg->getTranslate();$oTrans->enableAddon('modules\\procalendar');if (!defined('PHP_TAB')){define("PHP_TAB", "\t");}if (!defined('PHP_TAB2')){define("PHP_TAB2", "\t\t");}if (!defined('PHP_TAB3')){define("PHP_TAB3", "\t\t\t");}if (!function_exists('fillActionArray')){require(WB_PATH."/modules/procalendar/functions.php");}$page_id = 0;$page_link = '';$eventlist = '';$sOldMonth = 0;$sNewMonth = 0;$year = ((isset($year) && $year) ? intval($year) : date('Y'));$month = ((isset($month) && $month) ? intval($month) : 1);$days = ((isset($days) && $days) ? intval($days) : 0);$flags = ((isset($flags) && $flags) ? $flags : 1);// Set dateformat to suit your needs, add timeformat if needed$dateformat = ($dateformat ?? 'd.m.y H:i'); // Standard php date formats 'd-m-Y'$startnow = $flags & 1; // BIT #0 = 1$bTimeEnd = $flags & 2; // BIT #1 = 2$bMonthHeading = $flags & 4; // BIT #2 = 4$iDateWidth = ($bTimeEnd ? 140 : 90);if (isset($year) && $year) {// $month = ((isset($month) && empty($month)) ? '1' : $month); $t1 = (($year > date('Y')) ? strtotime($year.'-'.$month.'-01') : time());// $t1 = strtotime($year.'-'.$month.'-01'); $t2 = strtotime($year.'-12-31'); $diff = (floor(abs($t2-$t1))); $divisor = 86400; # a day has 24*60*60 sec $days = isset($days) && $days ? $days : (floor($diff / $divisor));// $time = time (); date('Y-n-j',$t2)// $part = $time - $time % $divisor; $aTimeDiff = [ 'year'=> $year, 'month'=> $month, 'act_year'=> date('Y'), 'start_date'=> date('Y-m-d',$t1), 'end_date'=> date('Y-m-d',$t2), 'days'=> $days, ];}$fixdays = isset($days);//$startnow = isset($startnow) ? intval($startnow) : 0;$max = isset($max) && $max ? intval($max) : 1000;//$section_id = isset($section_id) ? intval($section_id) : 0 ;// Fetch base page linkif ($section_id != 0) { $sql = 'SELECT `p`.`link` FROM `'.TABLE_PREFIX.'sections` `s` ' . 'INNER JOIN `'.TABLE_PREFIX.'pages` `p` ON (`s`.`page_id` = `p`.`page_id`) ' . 'WHERE `s`.`section_id` = '.$section_id.' '; if (($link = $oDb->get_one($sql))){ $page_link = $wb->page_link($link); }}// Set start- and end date for query$datestart = ($startnow ? date('Y-m-d') : $year.'-'.$month.'-1');$sParm1 = date('Y-m-d', strtotime("+".($days-1)." day"));$sParm2 = date('Y-n-j', strtotime($datestart." + ".($days-1)." day"));$sRequest1 = ("$year-$month-".($days < cal_days_in_month(CAL_GREGORIAN, $month,$year)));$sParam3 = cal_days_in_month(CAL_GREGORIAN, $month,$year);$dateend = ($startnow ? $sParm1 : ($fixdays ? $sParm2 : ($sRequest1 ? $days : $sParam3)));/* */if (isset($archive)) { $dateend = date('Y-n-j'); $datestart = date('Y-n-j', strtotime(" ".($days-1)." day"));}$aDebug = [ 'year' => $year, 'month' => $month, 'days' => $days, 'datestart' => $datestart, 'dateend' => $dateend, 'date_start' => date('Y-n-j', strtotime(" ".($days-1)." day")), 'date_end' => date('Y-n-j'), ];$eventlist .= '<div class="info_body" style="text-align:left;font-family:sans-serif,monospace;">';// Fetch the itemsif (!isset($actions) || (isset($actions) && empty($actions))){ $actions = fillActionArray($datestart, $dateend, $section_id);}if (is_array($actions) && sizeof($actions)){ $eventlist .= '<ul class="event-list w3-ul" style="margin-left:0;padding-left:0;list-style-type: none !important;">'.PHP_EOL; $sOldMonth = strtotime($datestart); $sNewMonth = 0; if ($bMonthHeading && ($year) || ($bMonthHeading && (date('m',$sNewMonth) != date('m',$sOldMonth)))){ $iMonth = date('n',$sOldMonth); $sTmpMonat = "monthnames_".$iMonth; $sMonthName = $oTrans->$sTmpMonat; $eventlist .= '<li class="event-header"><h4>'.$sMonthName.' '.date('Y',$sOldMonth).'</h4></li>'.PHP_EOL; } foreach($actions as $row){ if ($max > 0) { if (!isset($kat) || (isset($kat) && in_array($row["acttype"], explode(',',$kat)))) { $max--; $ds = ($row['date_start'].' '.$row['time_start']); $de = ($row['date_end'] .' '.$row['time_end']); $sNewMonth = strtotime($ds); if ($bMonthHeading && (date('m',$sNewMonth) != date('m',$sOldMonth))){ $sOldMonth = strtotime($ds); $iMonth = date('n',$sOldMonth); $sTmpMonat = "monthnames_".$iMonth; $sMonthName = $oTrans->$sTmpMonat; $eventlist .= '<li class="event-header"><h4>'.$sMonthName.' '.date('Y',$sOldMonth).'</h4></li>'.PHP_EOL; } // Build url like : pages/kalendar.php?year=1900&month=01&day=03&id=2&detail=1 $page_url = $page_link.'?year='.(substr($ds,0,4)).'&month='.(substr($ds,5,2)).'&day='.(substr($ds,8,2)).'&id='.$row['id'].'&detail=1'; $datetime_start = mktime(substr($ds,11,2),substr($ds,14,2),0,substr($ds,5,2),substr($ds,8,2),substr($ds,0,4)); $datetime_end = mktime(substr($de,11,2),substr($de,14,2),0,substr($de,5,2),substr($de,8,2),substr($de,0,4)); $time_end = ($bTimeEnd ? ' - '.(substr($de,11,2).':'.substr($de,14,2)) : ''); $eventlist .= '<li class="eventlist" style="padding:4px 0;">'.PHP_EOL; $eventlist .= PHP_TAB.'<div class="w3-display-container">'.PHP_EOL; if ($bTimeEnd && ($datetime_start != $datetime_end)) { $eventlist .= PHP_TAB2.'<span style="width:'.$iDateWidth.'px;" class="c_date1 w3-display-topleft" >'.date($dateformat,$datetime_start).' -'.date('H:i',$datetime_end).'</span>'.PHP_EOL; } else { $eventlist .= PHP_TAB2.'<span style="width:'.$iDateWidth.'px;" class="c_date2 w3-display-topleft" >'.date($dateformat,$datetime_start).$time_end.'</span>'.PHP_EOL; } $eventlist .= PHP_TAB.'<span style="margin:0px;display:inline-block;">'.PHP_EOL.PHP_TAB2.'<a href="'.$page_url.'">'.PHP_EOL.PHP_TAB3.'<span class="c_name"><b>'.$row["name"].'</b></span>'.PHP_EOL.PHP_TAB2.'</a>'.PHP_EOL.PHP_TAB.'</span>'.PHP_EOL; $eventlist .= PHP_TAB.'</div>'.PHP_EOL; if ($row["custom1"]) { $eventlist .= PHP_TAB.'<div class="c_desc">'.$row["custom1"].'</div>'.PHP_EOL; } $eventlist .= '</li>'.PHP_EOL; } } } // end for $eventlist .= '</ul>';}return $eventlist .= "</div>";
WebsiteBaker-Version= 2.13.3 r166php-Version= 8.1ProCalendar-Version=v1.8.0Code: [Select][[eventlist?section_id=12&max=5]]
$dateformat = ($dateformat ?? 'd.m.y H:i');
[[eventlist?section_id=XX&flags=X&days=XX&dateformat='F j, Y, g:i a'&year=23&month=02]]
[[eventlist?section_id=XX&flags=X&days=XX&dateformat=d.m.Y&year=23&month=02]]
In den Beispielen des letzten Beitrages sind die Ausgabedarstellung des ersten Beispiels unter den zweiten Aufruf gerutscht und lassen sich auf Grund der Zeitsperre nicht mehr korrigieren, darum noch einmal korrektDer Droplet-Call mit dieser DatumsformatierungCode: [Select][[eventlist?section_id=XX&flags=X&days=XX&dateformat='F j, Y, g:i a'&year=23&month=02]]ergibt diese Datumsausgabe -> March 10, 2001, 5:16 pmdas zweite BeispielCode: [Select][[eventlist?section_id=XX&flags=X&days=XX&dateformat=d.m.Y&year=23&month=02]]ergibt die in Deutschland eher gebräuchliche Datumsausgabe -> 02.02.2022