//set startDate, endDate, eventParams
$now = new DateTime('NOW');
$clone = clone $now;
$clone = date_modify($clone, '+1 month');
$startDate = date_format($now, DateTime::W3C);
$endDate = date_format($clone, DateTime::W3C);
$eventParams = array(
'timeMin' => $startDate,
'timeMax' => $endDate,
'singleEvents' => 'true');
//set startDate, endDate, eventParams
$now = new DateTime('NOW');
$clone = clone $now;
$clone = date_modify($clone, '+'.$this->config['number_of_days'].' day');
$startDate = date_format($now, DateTime::W3C);
$endDate = date_format($clone, DateTime::W3C);
$eventParams = array(
'timeMin' => $startDate,
'timeMax' => $endDate,
'singleEvents' => 'true');
PHP Parse error: syntax error, unexpected 'private' (T_PRIVATE) in /var/www/kalender/plugins/CalendarPlugin.php on line 338, referer: http://fhem.local/kalender/index.php
public function doOutput($image, $style, $updateData, &$yoffset) {
if ($updateData)
$this->doUpdate();
$query = "SELECT * FROM `if_calendar` WHERE (`end` > NOW()) ORDER BY `begin` ASC";
$result = mysql_query($query, $this->dbconn);
if (mysql_num_rows($result) > 0) {
// define styles
$opt_header = array(
'width' => imagesx($image)-290,
'line_height' => 18,
'align' => ALIGN_LEFT
);
$opt_day = array(
'width' => imagesx($image)-290,
'height' => 14,
'line_height' => 14,
'align' => ALIGN_LEFT
);
$opt_entry = array(
'width' => imagesx($image)-290,
'height' => 12,
'line_height' => 12,
'align' => ALIGN_LEFT,
'word_wrap_hyphen' => '...',
'aggressive_word_wrap' => true,
);
// print header
imagettftextboxopt($image, 18, 0, 50, $yoffset, $style['textcolor'], $style['font'], "Nächste Termine", $opt_header);
$icon = ImageCreateFromPNG ( 'resources/icons/clock.png' );
ImageCopy($image, $icon, 20, $yoffset-3, 0, 0, imagesx($icon), imagesy($icon));
ImageDestroy($icon);
$yoffset += 26;
// print calendar
$counter = 0;
$formatDate = "%d.%m.%Y";
$formatTime = "%H:%M";
$today = strftime( $formatDate );
$tomorrow = strftime( $formatDate, strtotime("+1 day", time() ) );
$currently_displayed_day = 0;
while ($row = mysql_fetch_assoc($result)) {
$counter++;
// if end of screen is reached and more than one items left -> cut off and show hint "x more appointments..."
$rest = (mysql_num_rows($result) - $counter) + 1;
if (($yoffset >= (imagesy($image) - 36)) && ($rest > 1)) {
$text = "... $rest weitere Termine";
imagettftextboxopt($image, 14, 0, 24, $yoffset, $style['textcolor'], $style['fontb'], $text, $opt_entry);
$yoffset += 20;
break;
}
// print day name
$begin_date = strftime( $formatDate, strtotime($row['begin']));
// if begin day is before today set begin to today
if (strtotime($begin_date) < strtotime($today))
$begin_date = $today;
// now if begin is after $currently_displayed_day update $currently_displayed_day
if (strtotime($begin_date) > $currently_displayed_day) {
// update currently_displayed_day
$currently_displayed_day = strtotime($begin_date);
// print day name
if( $begin_date == $today )
$dayname = "Heute";
else if( $begin_date == $tomorrow )
$dayname = "Morgen";
else
$dayname = strftime("%A, ".$formatDate, strtotime($begin_date));
imagettftextboxopt($image, 14, 0, 50, $yoffset+4, $style['textcolor'], $style['fontb'], $dayname, $opt_day);
$yoffset += 22;
}
// build appointment time text
$end_date = strftime( $formatDate, strtotime($row['end']));
$begin_time = strftime( $formatTime, strtotime($row['begin']));
$end_time = strftime( $formatTime, strtotime($row['end']));
$text = $row['title'];
if ($row['location'] != null)
$text = $text . ", " . $row['location'];
if (($begin_time == "00:00") && ($end_time == "00:00")) {
// all day event (substract 1 second to get the real end date at 23:59)
$end_date = strftime( $formatDate, strtotime($row['end'])-1);
// if all day event is longer than one day -> print end date
if (strtotime($end_date) != $currently_displayed_day)
$text = $text." (bis ".$end_date.")";
} else {
// normal event with start and end time
$text = $text." (".$begin_time." - ";
// if event ends not this day -> display end date additionally to time
if (strtotime($end_date) != $currently_displayed_day)
$text = $text.$end_date.", ";
$text = $text.$end_time.")";
}
// ------------------------------------------- Müllabfuhr----------------------------------------
if (($row['color']) == "#f83a22") {
if (strpos($row['title'], 'Papierbehaelter') !== false)
$icon = ImageCreateFromPNG ( 'resources/icons/tonne_blau.png' );
if (strpos($row['title'], 'Bioabfallbehaelter') !== false)
$icon = ImageCreateFromPNG ( 'resources/icons/tonne_gruen.png' );
if (strpos($row['title'], 'Wertstofftonne') !== false)
$icon = ImageCreateFromPNG ( 'resources/icons/gelber_sack.png' );
if (strpos($row['title'], 'Restabfallbehaelter') !== false)
$icon = ImageCreateFromPNG ( 'resources/icons/tonne_schwarz.png' );
if (strpos($row['title'], 'Strauchgutabfuhr') !== false)
$icon = ImageCreateFromPNG ( 'resources/icons/strauch.png' );
ImageCopy($image, $icon, 23, $yoffset-6, 0, 0, imagesx($icon), imagesy($icon));
ImageDestroy($icon);
} else {
// ------------------------------------------- Geburtstag ----------------------------------------
if (($row['color']) == "#b3dc6c"){
$icon = ImageCreateFromPNG ( 'resources/icons/birth.png' );
ImageCopy($image, $icon, 23, $yoffset+0, 0, 0, imagesx($icon), imagesy($icon));
ImageDestroy($icon);
} else{
// ------------------------------------------- Bereitschaft ----------------------------------------
if (($row['color']) == "#16a765"){
$icon = ImageCreateFromPNG ( 'resources/icons/blaulicht.png' );
ImageCopy($image, $icon, 23, $yoffset+0, 0, 0, imagesx($icon), imagesy($icon));
ImageDestroy($icon);
} else {
// determine button color
$colorArray = htmlColorToRgb($row['color']);
$color = ImageColorAllocate ($image, $colorArray[0], $colorArray[1], $colorArray[2]);
// print appointment text and button
drawGlassButton($image, $color, 32, $yoffset+8);
}
}
imagettftextboxopt($image, 12, 0, 50, $yoffset, $style['textcolor'], $style['font'], $text, $opt_entry);
$yoffset += 18;
}
$yoffset += 26;
}
mysql_free_result($result);
}
// ------------------------------------------- Bereitschaft ----------------------------------------
if (($row['color']) == "#16a765"){
$icon = ImageCreateFromPNG ( 'resources/icons/blaulicht.png' );
ImageCopy($image, $icon, 23, $yoffset+0, 0, 0, imagesx($icon), imagesy($icon));
ImageDestroy($icon);
} else {
public function doOutput($image, $style, $updateData, &$yoffset) {
if ($updateData)
$this->doUpdate();
$query = "SELECT * FROM `if_calendar` WHERE (`end` > NOW()) ORDER BY `begin` ASC";
$result = mysql_query($query, $this->dbconn);
if (mysql_num_rows($result) > 0) {
// define styles
$opt_header = array(
'width' => imagesx($image)-290,
'line_height' => 18,
'align' => ALIGN_LEFT
);
$opt_day = array(
'width' => imagesx($image)-290,
'height' => 14,
'line_height' => 14,
'align' => ALIGN_LEFT
);
$opt_entry = array(
'width' => imagesx($image)-290,
'height' => 12,
'line_height' => 12,
'align' => ALIGN_LEFT,
'word_wrap_hyphen' => '...',
'aggressive_word_wrap' => true,
);
// print header
imagettftextboxopt($image, 18, 0, 50, $yoffset, $style['textcolor'], $style['font'], "Nächste Termine", $opt_header);
$icon = ImageCreateFromPNG ( 'resources/icons/clock.png' );
ImageCopy($image, $icon, 20, $yoffset-3, 0, 0, imagesx($icon), imagesy($icon));
ImageDestroy($icon);
$yoffset += 26;
// print calendar
$counter = 0;
$formatDate = "%d.%m.%Y";
$formatTime = "%H:%M";
$today = strftime( $formatDate );
$tomorrow = strftime( $formatDate, strtotime("+1 day", time() ) );
$currently_displayed_day = 0;
while ($row = mysql_fetch_assoc($result)) {
$counter++;
// if end of screen is reached and more than one items left -> cut off and show hint "x more appointments..."
$rest = (mysql_num_rows($result) - $counter) + 1;
if (($yoffset >= (imagesy($image) - 36)) && ($rest > 1)) {
$text = "... $rest weitere Termine";
imagettftextboxopt($image, 14, 0, 24, $yoffset, $style['textcolor'], $style['fontb'], $text, $opt_entry);
$yoffset += 20;
break;
}
// print day name
$begin_date = strftime( $formatDate, strtotime($row['begin']));
// if begin day is before today set begin to today
if (strtotime($begin_date) < strtotime($today))
$begin_date = $today;
// now if begin is after $currently_displayed_day update $currently_displayed_day
if (strtotime($begin_date) > $currently_displayed_day) {
// update currently_displayed_day
$currently_displayed_day = strtotime($begin_date);
// print day name
if( $begin_date == $today )
$dayname = "Heute";
else if( $begin_date == $tomorrow )
$dayname = "Morgen";
else
$dayname = strftime("%A, ".$formatDate, strtotime($begin_date));
imagettftextboxopt($image, 14, 0, 50, $yoffset+4, $style['textcolor'], $style['fontb'], $dayname, $opt_day);
$yoffset += 22;
}
// build appointment time text
$end_date = strftime( $formatDate, strtotime($row['end']));
$begin_time = strftime( $formatTime, strtotime($row['begin']));
$end_time = strftime( $formatTime, strtotime($row['end']));
$text = $row['title'];
if ($row['location'] != null)
$text = $text . ", " . $row['location'];
if (($begin_time == "00:00") && ($end_time == "00:00")) {
// all day event (substract 1 second to get the real end date at 23:59)
$end_date = strftime( $formatDate, strtotime($row['end'])-1);
// if all day event is longer than one day -> print end date
if (strtotime($end_date) != $currently_displayed_day)
$text = $text." (bis ".$end_date.")";
} else {
// normal event with start and end time
$text = $text." (".$begin_time." - ";
// if event ends not this day -> display end date additionally to time
if (strtotime($end_date) != $currently_displayed_day)
$text = $text.$end_date.", ";
$text = $text.$end_time.")";
}
// ------------------------------------------- Müllabfuhr----------------------------------------
if (($row['color']) == "#f83a22") {
if (strpos($row['title'], 'Papierbehaelter') !== false)
$icon = ImageCreateFromPNG ( 'resources/icons/tonne_blau.png' );
if (strpos($row['title'], 'Bioabfallbehaelter') !== false)
$icon = ImageCreateFromPNG ( 'resources/icons/tonne_gruen.png' );
if (strpos($row['title'], 'Wertstofftonne') !== false)
$icon = ImageCreateFromPNG ( 'resources/icons/gelber_sack.png' );
if (strpos($row['title'], 'Restabfallbehaelter') !== false)
$icon = ImageCreateFromPNG ( 'resources/icons/tonne_schwarz.png' );
if (strpos($row['title'], 'Strauchgutabfuhr') !== false)
$icon = ImageCreateFromPNG ( 'resources/icons/strauch.png' );
ImageCopy($image, $icon, 23, $yoffset-6, 0, 0, imagesx($icon), imagesy($icon));
ImageDestroy($icon);
} else {
// ------------------------------------------- Geburtstag ----------------------------------------
if (($row['color']) == "#b3dc6c"){
$icon = ImageCreateFromPNG ( 'resources/icons/birth.png' );
ImageCopy($image, $icon, 23, $yoffset+0, 0, 0, imagesx($icon), imagesy($icon));
ImageDestroy($icon);
} else{
// ------------------------------------------- Bereitschaft ----------------------------------------
if (($row['color']) == "#16a765"){
$icon = ImageCreateFromPNG ( 'resources/icons/blaulicht.png' );
ImageCopy($image, $icon, 23, $yoffset+0, 0, 0, imagesx($icon), imagesy($icon));
ImageDestroy($icon);
} else {
// determine button color
$colorArray = htmlColorToRgb($row['color']);
$color = ImageColorAllocate ($image, $colorArray[0], $colorArray[1], $colorArray[2]);
// print appointment text and button
drawGlassButton($image, $color, 32, $yoffset+8);
}
}
}
imagettftextboxopt($image, 12, 0, 50, $yoffset, $style['textcolor'], $style['font'], $text, $opt_entry);
$yoffset += 18;
}
$yoffset += 26;
}
mysql_free_result($result);
}
if ($updateData)
$this->doUpdate();
$query = "SELECT * FROM `if_calendar`
WHERE `end` > NOW()
AND (`begin` <= ADDDATE(NOW(), INTERVAL ".$this->config['number_of_days']." DAY))
ORDER BY `begin` ASC";
$result = mysqli_query($this->dbconn, $query);
if ($updateData)
$this->doUpdate();
$query = "SELECT * FROM `if_calendar`
WHERE `end` > NOW()
AND (`begin` <= ADDDATE(NOW(), INTERVAL ".$this->config['number_of_days']." DAY))
ORDER BY `begin` ASC";
$result = mysql_query( $query, $this->dbconn);
im CalenderPlugin.php direkt unter
"public function doOutput($image, $style, $updateData, &$yoffset) {"
brauchst nur die $query Anweisung mit der neuen $query Anweisung ersetzen.
Beachte: Die neue Anweisung ist leserlichkeitshalber auf 4 Zeilen aufgeteilt!
$query = "SELECT * FROM `if_calendar` WHERE (`end` > NOW()) ORDER BY `begin` ASC";
$query = "SELECT * FROM `if_calendar` WHERE `end` > NOW() AND (`begin` <= ADDDATE(NOW(), INTERVAL ".$this->config['number_of_days']." DAY)) ORDER BY `begin` ASC";
@ Orca
-- SNIP --
du hast eine klammer unter "drawGlasbutton" vergessen, da du noch ein else statement eingefügt hast.
Aber ganz korrekt ist der code so auch nicht. sollte aber funzen
// ------------------------------------------- Bereitschaft ----------------------------------------
if ( $row['title'] == "Bereitschaft" ) {
$icon = ImageCreateFromPNG ( 'resources/icons/blaulicht.png' );
ImageCopy($image, $icon, 23, $yoffset+0, 0, 0, imagesx($icon), imagesy($icon));
ImageDestroy($icon);
} else {
// ------------------------------------------- Geburtstag ----------------------------------------
if (strpos($row['title'], 'Geburtstag') !== false) {
$icon = ImageCreateFromPNG ( 'resources/icons/birth.png' );
ImageCopy($image, $icon, 23, $yoffset+0, 0, 0, imagesx($icon), imagesy($icon));
ImageDestroy($icon);
// ------------------------------------------- Bereitschaft ----------------------------------------
} elseif (strpos($row['title'], 'Bereitschaft') !== false) {
$icon = ImageCreateFromPNG ( 'resources/icons/blaulicht.png' );
ImageCopy($image, $icon, 23, $yoffset+0, 0, 0, imagesx($icon), imagesy($icon));
ImageDestroy($icon);
} else {
// ---------------------------- kein Treffer im Titel, also wird ein button in der farbe des Kalender als Icon gezeichnet
$colorArray = htmlColorToRgb($row['color']);
$color = ImageColorAllocate ($image, $colorArray[0], $colorArray[1], $colorArray[2]);
// print appointment text and button
drawGlassButton($image, $color, 32, $yoffset+8);
}
imagettftextboxopt($image, 12, 0, 50, $yoffset, $style['textcolor'], $style['font'], $text, $opt_entry);
Wenn die Titel immer gleich sind, kannst du natürlich auch einfach mit:
die Eintrag aus der Spalte "title" filtern.. So kanst du die Kalender zusammenfügen.PHP:// ------------------------------------------- Bereitschaft ---------------------------------------- if ( $row['title'] == "Bereitschaft" ) { $icon = ImageCreateFromPNG ( 'resources/icons/blaulicht.png' ); ImageCopy($image, $icon, 23, $yoffset+0, 0, 0, imagesx($icon), imagesy($icon)); ImageDestroy($icon); } else {
Bei deinem Code wird, wenn du einen Eintrag in einem Kalender hast, der nicht durch die Farbangabe gefiltert wird, kein Icon - auch kein "drawClassbutton" - angezeigt. Lediglich der Eintrag, also "$text" wird ausgegeben.
"kind": "calendar#calendarListEntry",
"etag": "\"0\"",
"id": "de.german#[email protected]",
"summary": "Feiertage in Deutschland",
"description": "Feier- und Gedenktage in Deutschland",
"timeZone": "Europe/Berlin",
"colorId": "23",
"backgroundColor": "#cd74e6",
"foregroundColor": "#000000",
"selected": true,
"accessRole": "reader",
$calendarList = $service->calendarList->listCalendarList();