Last active
November 3, 2021 14:39
-
-
Save dawoodman71/5250759 to your computer and use it in GitHub Desktop.
PHP Solution for adding a Google Calendar, injecting styles and changing options dynamically.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.dp-cur, .chip dt, .te, .te-t, .te-rev-s, .rb-n, .rb-i, .agenda, .event-title{ | |
white-space:normal !important; | |
} | |
#calendarTitle, | |
.tab-name, | |
img[title="Print my calendar (shows preview)"], | |
.footer img, | |
.details .links a:last-child, | |
.event-links a:last-child | |
{display:none;} | |
.mv-event-container | |
{border-color:#999;} | |
.navBack, | |
.navForward | |
{ background-image: url(images/combined_v22.png); } | |
.agenda-more | |
{ color:#0D75BB; } | |
.agenda .date-label | |
{ padding:5px 0px; } | |
.dp-popup | |
{background:#fff;} | |
.view-cap, .view-container-border, | |
.mv-daynames-table, | |
.ui-rtsr-selected, | |
.wk-weektop, | |
.wk-dummyth, | |
.date-picker-arrow-on, | |
.dp-weekend-selected | |
{ background-color:#dfdfdf; } | |
.ui-rtsr-unselected, | |
.mv-daynames-table, | |
.wk-daynames, | |
.wk-dayname, | |
.dp-prev, | |
.dp-cur, | |
.dp-next | |
{ color:#666; } | |
.ui-rtsr-unselected | |
{ background-color:transparent;} | |
.dp-weekday-selected, | |
.agenda .date-label | |
{background-color:#efefef;} | |
.dp-today-selected | |
{background-color:#fad163;} | |
.mv-daynames-table, | |
.wk-daynames | |
{height:30px; font-size:14px;} | |
.mv-event-container | |
{ top:30px;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- by default the iframe shows the month view --> | |
<iframe id="googleCalendar" style="border: 0;" | |
src="google_calendar.php" | |
height="600" width="100%" | |
frameborder="0" scrolling="no"></iframe> | |
<!-- add ?v=[VIEW] to the path to force a view --> | |
<!-- views include month, week, agenda --> | |
<iframe id="googleCalendar?v=agenda" style="border: 0;" | |
src="google_calendar.php" | |
height="300" width="400" | |
frameborder="0" scrolling="no"></iframe> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// determine path, css filename and view mode | |
$calendarpath="https://www.google.com/calendar/embed?src=[YOUR GOOGLE CALENDAR ID]&ctz=America/New_York"; | |
$newcss="google_calendar.css"; | |
$defaultview=($_GET["v"]) ? $_GET["v"] : "month"; | |
// import the contents of the Google Calendar page into a string | |
$contents = file_get_contents($calendarpath); | |
// add secure Google address to root relative links | |
$contents = str_replace('<link type="text/css" rel="stylesheet" href="', '<link type="text/css" rel="stylesheet" href="https://www.google.com/calendar/', $contents ); | |
$contents = str_replace('<script type="text/javascript" src="', '<script type="text/javascript" src="https://www.google.com/calendar/' , $contents ); | |
// inject css file reference | |
$contents = str_replace('<script>function _onload()', '<link rel="stylesheet" type="text/css" href="'.$newcss.'" /><script>function _onload()', $contents ); | |
// update settings found in javascript _onload() function | |
$contents = str_replace('"view":"month"', '"view":"'.$defaultview.'"', $contents); | |
$contents = str_replace('"showCalendarMenu":true', '"showCalendarMenu":false', $contents); | |
if($defaultview == "month") $contents = str_replace('"showDateMarker":true', '"showDateMarker":false', $contents); | |
if($defaultview != "month") $contents = str_replace('"showTabs":true', '"showTabs":false', $contents); | |
echo $contents; | |
?> |
` $newcss = 'g_calender.css'; $f = file_get_contents('https://calendar.google.com/calendar/embed?src=[calender_id]&ctz=Asia/Taipei'); $f = str_replace('//calendar.google.com','https://calendar.google.com',$f); $f = str_replace('/calendar/_','https://calendar.google.com/calendar/_',$f); $f = str_replace('<script>function _onload()', '<script>function _onload()', $f );
echo $f; `
this works perfectly
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I insert this three lines
And now everything works with curl.
My Complete Code is
@GuitarAndi
Ich glaub du sprichst deutsch wenn ich mir den Kalender so anschaue. Früher mit der alten restylegc.php stand es immer so drin
URL for overriding stylesheet
The best way to create this stylesheet is to
browser,
the address bar so that it reads similar to:
"http://www.google.com/calendar/d003e2eff7c42eebf779ecbd527f1fe0embedcompiled.css"
Edit this new file to change the style of the calendar.
As an alternative method, take the URL you copied in Step 3, and paste it
in the URL field at http://mabblog.com/cssoptimizer/uncompress.html.
That site will automatically format the CSS so that it's easier to edit.
Dann suchst dir einfach die jeweiligen Klassen raus und änderst sie. In deinem Fall z.b.
dort steht bei mir als Änderung
und
und das dritte wenn ich es richtig verstanden habe willst du das nicht anzeigen
Bei mir sieht das so aus....