From fe8fbac3cf9af0464d2b0990c88631ff9fd803ac Mon Sep 17 00:00:00 2001 From: rvelices Date: Wed, 22 Feb 2006 01:00:39 +0000 Subject: calendar redesign: monthly and weekly styles + list/calendar views for monthly git-svn-id: http://piwigo.org/svn/trunk@1050 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/calendar_weekly.class.php | 95 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 include/calendar_weekly.class.php (limited to 'include/calendar_weekly.class.php') diff --git a/include/calendar_weekly.class.php b/include/calendar_weekly.class.php new file mode 100644 index 000000000..4ae65e076 --- /dev/null +++ b/include/calendar_weekly.class.php @@ -0,0 +1,95 @@ +url_base = $url_base; + + assert($view_type==CAL_VIEW_LIST); + + $this->build_nav_bar($view_type, $requested, 0, 'YEAR'); // years + if (count($requested)>0) + $this->build_nav_bar($view_type, $requested, 1, 'WEEK', '+1' ); // month + if (count($requested)>1) + $this->build_nav_bar($view_type, $requested, 2, 'DAYOFWEEK', '-1', + $lang['day'] ); // days + return false; +} + + +/** + * Returns a sql where subquery for the date field + * @param array requested selected levels for this calendar + * (e.g. 2005,42,1 for 41st week of 2005, Monday) + * @param int max_levels return the where up to this level + * (e.g. 2=only year and week in year) + * @return string + */ +function get_date_where($requested, $max_levels=3) +{ + while (count($requested)>$max_levels) + { + array_pop($requested); + } + $res = ''; + if (isset($requested[0]) and $requested[0]!='any') + { + $y = $requested[0]; + $res = " AND $this->date_field BETWEEN '$y-01-01' AND '$y-12-31'"; + } + + if (isset($requested[1]) and $requested[1]!='any') + { + $res .= ' AND WEEK('.$this->date_field.')+1='.$requested[1]; + } + if (isset($requested[2]) and $requested[2]!='any') + { + $res .= ' AND DAYOFWEEK('.$this->date_field.')-1='.$requested[2]; + } + if (empty($res)) + { + $res = ' AND '.$this->date_field.' IS NOT NULL'; + } + return $res; +} + +} + +?> \ No newline at end of file -- cgit v1.2.3