WebsiteBaker Support (2.13.x) > Hilfe & Support (deutsch)
ProCalendar, Eventlist, falsches Datenformat
hgs:
Ok, Grundlagenabfragen
WebsiteBaker-Version= ?
php-Version = ?
ProCalendar-Version = ?
Und mit welchem Aufruf wird das Droplet eingebunden
Bei mir sieht es ja so aus
--- Code: ---[[eventlist?section_id=xx&flags=5&days=14]]
--- End code ---
FrankHA:
WebsiteBaker-Version= 2.13.3 r166
php-Version= 8.1
ProCalendar-Version=v1.8.0
--- Code: ---[[eventlist?section_id=12&max=5]]
--- End code ---
sternchen8875:
Zeig mal bitte diese Zeile 20 des Droplets oder die Zeilen drum herum auch
hgs:
Zum vergleichen hier schon mal meins
--- Code: ---$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 link
if ($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 items
if (!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>";
--- End code ---
hgs:
--- Quote from: FrankHA on February 02, 2023, 02:54:39 PM ---WebsiteBaker-Version= 2.13.3 r166
php-Version= 8.1
ProCalendar-Version=v1.8.0
--- Code: ---[[eventlist?section_id=12&max=5]]
--- End code ---
--- End quote ---
Ich habe jetzt mal deinen Aufruf mit meiner sid ins Template eingefügt.
Das läuft ohne Fehlermeldungen und ich sehe nur noch 5 Termine mit Jahreszahl
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version