diff --git a/config.php b/config.php new file mode 100644 index 0000000..cb63b2c --- /dev/null +++ b/config.php @@ -0,0 +1,12 @@ + diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..164cbec Binary files /dev/null and b/favicon.ico differ diff --git a/index.php b/index.php new file mode 100644 index 0000000..3a4c836 --- /dev/null +++ b/index.php @@ -0,0 +1,249 @@ + + + + + + + + + + + + <? echo(NAME_OF_CHURCH); ?> – Nächste Termine + + + + + + + + + + + + +
+

+ – Nächste Termine

+ +
+ + + startDateForm: $startDateForm\n"); + } + + $startDateCleaned = str_replace(" ", "", $startDateForm); + // $startDateCleaned = str_replace(".", " ", $startDateForm); + list($day, $month, $year) = explode(".", trim($startDateCleaned)); + + if(defined('DEBUG')) { + echo("
startDateCleaned: $startDateCleaned
\n"); + echo("
Day, Month, Year: $day, $month, $year
\n"); + } + + + if(isset($_GET['timeSpan'])) { + $timeSpan = $_GET['timeSpan']; + } + else{ + $timeSpan = "1week"; + } + + if(defined('DEBUG')) { + echo("
timeSpan: $timeSpan
\n"); + } + + + if($timeSpan == "1week"){ + $timeSpanDays = 7; + $mode = "weeks"; + } + elseif($timeSpan == "2weeks"){ + $timeSpanDays = 14; + $mode = "weeks"; + } + elseif($timeSpan == "3weeks"){ + $timeSpanDays = 21; + $mode = "weeks"; + } + elseif($timeSpan == "4weeks"){ + $timeSpanDays = 28; + $mode = "weeks"; + } + elseif($timeSpan == "16weeks"){ + $timeSpanDays = 28*4; + $mode = "weeks"; + } + elseif($timeSpan == "nextmonth" or $timeSpan == "afternextmonth"){ + $mode = "months"; + } + else{ + die("Unbekannte Angabe für timeSpan!"); + } + + + + if(defined('DEBUG')) { + echo("
mode: $mode
\n"); + } + + + if($mode == "weeks"){ + $timeSpanSeconds = 3600 * 24 * $timeSpanDays; + // print_r($dateParts); + + // echo("
" . $dateParts[1] . " " . $dateParts[2]); + + // $startDate = strptime($dateParts[1] . " " . $dateParts[2], " %e. %m"); + // $startDate = mktime(0, 0, 0, $monthDE[$dateParts[2]], $dateParts[1], date("Y")); + $startDate = mktime(0, 0, 0, $month, $day, $year); + + // echo("
Start: $startDate
"); + // echo("
Start: ". strftime("%c", $startDate) . "
"); + $startDateIcs = strftime("%Y%m%dT000000Z", $startDate); + // echo("startDateIcs: ". $startDateIcs . "
"); + $endDateIcs = strftime("%Y%m%dT235959Z", $startDate + $timeSpanSeconds); + // echo("endDateIcs: ". $endDateIcs . "

"); + +// $startDMY = strftime("%d.%m.%Y", $startDate); + $startDMY = strftime("%d. ", $startDate) . $monthNamesShort[(strftime("%m", $startDate)-1)*1] . strftime(". %Y", $startDate); + +// $endDMY = strftime("%d.%m.%Y", $startDate + $timeSpanSeconds); + $endDMY = strftime("%d. ", $startDate + $timeSpanSeconds) . $monthNamesShort[(strftime("%m", $startDate + $timeSpanSeconds)-1)*1] . strftime(". %Y", $startDate + $timeSpanSeconds); + + $startDayFormated = strftime("%e.", $startDate); + // $startMonthFormated = $monthNamesShort[(strftime("%m", $startDate)-1)*1] . "."; + $startMonthFormated = $monthNames[(strftime("%m", $startDate)-1)*1]; + $startYearFormated = strftime("%Y", $startDate); + + $endDayFormated = strftime("%e.", $startDate + $timeSpanSeconds); + // $endMonthFormated = $monthNamesShort[(strftime("%m", $startDate + $timeSpanSeconds)-1)*1] . "."; + $endMonthFormated = $monthNames[(strftime("%m", $startDate + $timeSpanSeconds)-1)*1]; + $endYearFormated = strftime("%Y", $startDate + $timeSpanSeconds); + + + if ($startMonthFormated == $endMonthFormated) { # Start and end in same month + $formatedDateSpan = "$startDayFormated – $endDayFormated $endMonthFormated $endYearFormated"; + } + else if (($startDayFormated != $endDayFormated) && ($startYearFormated == $endYearFormated)) { // Start and end not in same month but same year + $formatedDateSpan = "$startDayFormated $startMonthFormated – $endDayFormated $endMonthFormated $endYearFormated"; + } + else { # Start and end not in same year + $formatedDateSpan = "$startDayFormated $startMonthFormated $startYearFormated – $endDayFormated $endMonthFormated $endYearFormated"; + } + + + + if(defined('DEBUG')) { + // echo("
Month: -" . $dateParts[2] . "- => " . $monthDE[$dateParts[2]] . "
\n"); + echo("
startDMY: $startDMY
\n"); + echo("
mktime(0, 0, 0, $month, $day, $year);
\n"); + echo("
endDMY: $endDMY
\n"); + } + + } + else{ //months + $firstDayOfCurrentMonth = date("Y-m-01"); //2017-07-01 + // $firstDayOfCurrentMonth = date("2016-12-1"); //test + // $firstDayOfCurrentMonth = date("2017-1-1"); //test + // $firstDayOfCurrentMonth = date("2017-2-1"); //test + if($timeSpan == "nextmonth"){ + $firstOfMonth = strtotime ( '+1 month' , strtotime ( $firstDayOfCurrentMonth ) ) ; + } + else{ //after next month + $firstOfMonth = strtotime ( '+2 month' , strtotime ( $firstDayOfCurrentMonth ) ) ; + } + + $lastDayOfMonth = strtotime ( '+1 month' , $firstOfMonth) - 1; //first day of next month minus 1 second + + $startDateIcs = strftime("%Y%m%dT000000Z", $firstOfMonth); + $endDateIcs = strftime("%Y%m%dT235959Z", $lastDayOfMonth); + + $monthNo = strftime("%m", $firstOfMonth); + $month = $monthNames[$monthNo-1]; + $year = strftime("%Y", $firstOfMonth); + + if(defined('DEBUG')) { + echo("
startDateIcs: $startDateIcs ($firstOfMonth)
"); + echo("
endDateIcs:  $endDateIcs ($lastDayOfMonth)
"); + echo("
firstOfMonth:  $firstOfMonth ($monthNo)
"); + } + + } + ?> + +
+ Nächster Sonntag
+ +
+
+
+
+
+ + + +
+ +
+ + + +
+ +
+ +
+ + Quelle:
+ Support: george[at]ruinelli.ch +
+ + diff --git a/info.txt b/info.txt new file mode 100644 index 0000000..f08cca0 --- /dev/null +++ b/info.txt @@ -0,0 +1 @@ +Bei Fragen bitte an George wenden. diff --git a/javascript.js b/javascript.js new file mode 100644 index 0000000..9b6f582 --- /dev/null +++ b/javascript.js @@ -0,0 +1,79 @@ +/* -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Copyright 2017 by George Ruinelli +Licence: GPL +Last Change: 13.10.2017 +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + +$(function() { + $('#datepicker').datepicker({ + prevText: '<zurück', prevStatus: '', + prevJumpText: '<<', prevJumpStatus: '', + nextText: 'Vor>', nextStatus: '', + nextJumpText: '>>', nextJumpStatus: '', + currentText: 'heute', currentStatus: '', + todayText: 'heute', todayStatus: '', + clearText: '-', clearStatus: '', + closeText: 'schließen', closeStatus: '', +// monthNames: ['Januar','Februar','März','April','Mai','Juni', 'Juli','August','September','Oktober','November','Dezember'], +// monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun', 'Jul','Aug','Sep','Okt','Nov','Dez'], +// dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'], +// dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'], +// dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'], + showMonthAfterYear: false, + firstDay: 1, + showOn: 'both', +// buttonImage: 'media/img/calendar.png', +// buttonImageOnly: true, + // http://keith-wood.name/datepick.HTML +// dateFormat:'D d. MM' + dateFormat:'dd.mm.yy' + } +); + +}); + + +function selectElementContents(el) { + var body = document.body, range, sel; + if (document.createRange && window.getSelection) { + range = document.createRange(); + sel = window.getSelection(); + sel.removeAllRanges(); + try { + range.selectNodeContents(el); + sel.addRange(range); + } catch (e) { + range.selectNode(el); + sel.addRange(range); + } + } else if (body.createTextRange) { + range = body.createTextRange(); + range.moveToElementText(el); + range.select(); + } + + + + // Use try & catch for unsupported browser + try { + + // The important part (copy selected text) + var successful = document.execCommand('copy'); + + if(successful) alert('Inhalt kopiert!'); + else alert('Kopieren nicht möglich!'); + } catch (err) { + alert('Unsupported Browser!'); + } +} + + +function reloadPage(date, timeSpan) { + url = "index.php?date=" + date + "&timeSpan=" + timeSpan; + console.log("Redirecting to " + url); + window.location.href=url; +} + +$( function() { + $( ".date_input" ).datepicker(); +} );