From c91fc89b481dcebddfe06e5280c749d27762f42b Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 31 Mar 2015 13:12:20 +0000 Subject: [PATCH] * Calendar: automatic load new holidays, if there are no irregular ones for a given year, plus new Germany holidays for 2016 --- calendar/egroupware.org/holidays.DE.csv | 23 +++++++++++++++++ calendar/inc/class.boholiday.inc.php | 33 +++++++++++-------------- calendar/inc/class.uiholiday.inc.php | 1 + 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/calendar/egroupware.org/holidays.DE.csv b/calendar/egroupware.org/holidays.DE.csv index 48ca80e3ff..b2932c109b 100644 --- a/calendar/egroupware.org/holidays.DE.csv +++ b/calendar/egroupware.org/holidays.DE.csv @@ -256,3 +256,26 @@ DE 1. Advent 29 11 2015 0 0 DE 2. Advent 6 12 2015 0 0 DE 3. Advent 13 12 2015 0 0 DE 4. Advent 20 12 2015 0 0 + +Quellen: +http://de.wikipedia.org/wiki/Feiertage_in_Deutschland#Bewegliche_Feiertage +http://de.wikipedia.org/wiki/Karneval,_Fastnacht_und_Fasching#Termin.C3.BCbersicht +http://de.wikipedia.org/wiki/Advent#Datum_des_ersten_Adventssonntags_in_der_Lateinischen_Kirche + +2016: +DE Rosenmontag 8 2 2016 0 0 +DE Fastnacht 9 2 2016 0 0 +DE Aschermittwoch 10 2 2016 0 0 +DE Gründonnerstag 24 3 2016 0 0 +DE Karfreitag 25 3 2016 0 0 +DE Ostersonntag 27 3 2016 0 0 +DE Ostermontag 28 3 2016 0 0 +DE Christi Himmelfahrt 5 5 2016 0 0 +DE Pfingstsonntag 15 5 2016 0 0 +DE Pfingstmontag 16 5 2016 0 0 +DE Fronleichnam 26 6 2016 0 0 +DE Buß- und Bettag 16 11 2016 0 0 +DE 1. Advent 27 11 2016 0 0 +DE 2. Advent 4 12 2016 0 0 +DE 3. Advent 11 12 2016 0 0 +DE 4. Advent 18 12 2016 0 0 diff --git a/calendar/inc/class.boholiday.inc.php b/calendar/inc/class.boholiday.inc.php index 58be3188f0..a9adf0a982 100755 --- a/calendar/inc/class.boholiday.inc.php +++ b/calendar/inc/class.boholiday.inc.php @@ -245,15 +245,21 @@ { foreach($this->locales as $local) { - $this->auto_load_holidays($local); + $this->auto_load_holidays($local, $year); } } } - function auto_load_holidays($locale) + function auto_load_holidays($locale, $year=0) { - if($this->so->holiday_total($locale) == 0) + //error_log(__METHOD__."('$locale', $year)"); + if (!egw_cache::getInstance(__CLASS__, $locale.'-'.$year) && // check if autoload has been tried for this locale and year + (!($total_year = $this->so->holiday_total($locale, '', $year)) || + // automatic try load new holidays, if there are no irregular ones for queried year + $total_year == $this->so->holiday_total($locale, '', 1901))) { + //error_log(__METHOD__."('$locale', $year) attemption autoload ..."); + egw_cache::setInstance(__CLASS__, $locale.'-'.$year, true, 86400); // do NOT try again for 1 day @set_time_limit(0); /* get the file that contains the calendar events for your locale */ @@ -265,19 +271,9 @@ } else { - $pos = strpos(' '.$GLOBALS['egw_info']['server']['webserver_url'],$_SERVER['HTTP_HOST']); - if($pos == 0) + if ($GLOBALS['egw_info']['server']['webserver_url'][0] == '/') { - switch($_SERVER['SERVER_PORT']) - { - case 80: - $http_protocol = 'http://'; - break; - case 443: - $http_protocol = 'https://'; - break; - } - $server_host = $http_protocol.$_SERVER['HTTP_HOST'].$GLOBALS['egw_info']['server']['webserver_url']; + $server_host = ($_SERVER['HTTPS']?'https://':'http://').$_SERVER['HTTP_HOST'].$GLOBALS['egw_info']['server']['webserver_url']; } else { @@ -299,18 +295,17 @@ return false; } // reading the holidayfile from egroupware.org via network::gethttpsocketfile contains all the headers! - foreach($lines as $n => $line) + foreach($lines as $line) { $fields = preg_split("/[\t\n ]+/",$line); if ($fields[0] == 'charset' && $fields[1]) { - $lines = $GLOBALS['egw']->translation->convert($lines,$fields[1]); + $lines = translation::convert($lines,$fields[1]); break; } } - $c_lines = count($lines); - foreach ($lines as $i => $line) + foreach ($lines as $line) { // echo 'Line #'.$i.' : '.$lines[$i]."
\n"; $holiday = explode("\t",$line); diff --git a/calendar/inc/class.uiholiday.inc.php b/calendar/inc/class.uiholiday.inc.php index 853f328700..efb67faf1d 100755 --- a/calendar/inc/class.uiholiday.inc.php +++ b/calendar/inc/class.uiholiday.inc.php @@ -42,6 +42,7 @@ function uiholiday() { + egw_framework::csp_script_src_attrs('unsafe-inline'); $this->bo =& CreateObject('calendar.boholiday'); $this->bo->check_admin(); $this->base_url = $this->bo->base_url;