From d4646f39d2259d4b4ba619b8f2b8aa61f9be74b5 Mon Sep 17 00:00:00 2001 From: rvelices Date: Fri, 24 Feb 2006 05:58:48 +0000 Subject: calendar: added posted/created chronology calendar: added a where are we bar (like: created/2005/august) calendar: possibility to hide the All/Any buttons ($conf['calendar_show_any']) calendar: possibility to display a single navigation bar instead of several navigation bars ($conf['calendar_multi_bar']) calendar: tried to simplify code and improve readability (still requires a review) git-svn-id: http://piwigo.org/svn/trunk@1057 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/calendar_weekly.class.php | 87 +++++++++++++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 18 deletions(-) (limited to 'include/calendar_weekly.class.php') diff --git a/include/calendar_weekly.class.php b/include/calendar_weekly.class.php index 3e591eecd..5ab550e29 100644 --- a/include/calendar_weekly.class.php +++ b/include/calendar_weekly.class.php @@ -26,6 +26,10 @@ include_once(PHPWG_ROOT_PATH.'include/calendar_base.class.php'); +define ('CYEAR', 0); +define ('CWEEK', 1); +define ('CDAY', 2); + /** * Weekly calendar style (composed of years/week in years and days in week) */ @@ -36,52 +40,61 @@ class Calendar extends CalendarBase * Generate navigation bars for category page * @return boolean false to indicate that thumbnails where not included here */ -function generate_category_content($url_base, $view_type, &$requested) +function generate_category_content($url_base, $view_type) { - global $lang; + global $lang, $conf; $this->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', + if ( $conf['calendar_multi_bar'] or count($this->date_components)==0 ) + { + $this->build_nav_bar(CYEAR, 'YEAR'); // years + } + if ( count($this->date_components)>=1 and + ( $conf['calendar_multi_bar'] or count($this->date_components)==1 ) + ) + { + $this->build_nav_bar(CWEEK, 'WEEK', '+1' ); // month + } + if ( count($this->date_components)>=2 ) + { + $this->build_nav_bar(CDAY, '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) +function get_date_where($max_levels=3) { - while (count($requested)>$max_levels) + $date_components = $this->date_components; + while (count($date_components)>$max_levels) { - array_pop($requested); + array_pop($date_components); } $res = ''; - if (isset($requested[0]) and $requested[0]!='any') + if (isset($date_components[CYEAR]) and $date_components[CYEAR]!='any') { - $y = $requested[0]; + $y = $date_components[CYEAR]; $res = " AND $this->date_field BETWEEN '$y-01-01' AND '$y-12-31 23:59:59'"; } - if (isset($requested[1]) and $requested[1]!='any') + if (isset($date_components[CWEEK]) and $date_components[CWEEK]!='any') { - $res .= ' AND WEEK('.$this->date_field.')+1='.$requested[1]; + $res .= ' AND WEEK('.$this->date_field.')+1='.$date_components[CWEEK]; } - if (isset($requested[2]) and $requested[2]!='any') + if (isset($date_components[CDAY]) and $date_components[CDAY]!='any') { - $res .= ' AND DAYOFWEEK('.$this->date_field.')-1='.$requested[2]; + $res .= ' AND DAYOFWEEK('.$this->date_field.')-1=' + .$date_components[CDAY]; } if (empty($res)) { @@ -90,6 +103,44 @@ function get_date_where($requested, $max_levels=3) return $res; } +function get_display_name() +{ + global $conf,$lang; + $res = ''; + $url = $this->url_base; + if ( isset($this->date_components[CYEAR]) ) + { + $res .= $conf['level_separator']; + $url .= $this->date_components[CYEAR].'-'; + $res .= + '' + .$this->get_date_component_label($this->date_components[CYEAR]) + .''; + } + if ( isset($this->date_components[CWEEK]) ) + { + $res .= $conf['level_separator']; + $url .= $this->date_components[CWEEK].'-'; + $res .= + '' + .$this->get_date_component_label($this->date_components[CWEEK]) + .''; + } + if ( isset($this->date_components[CDAY]) ) + { + $res .= $conf['level_separator']; + $url .= $this->date_components[CDAY].'-'; + $res .= + '' + .$this->get_date_component_label( + $this->date_components[CDAY], + $lang['day'] + ) + .''; + } + return $res; +} + } ?> \ No newline at end of file -- cgit v1.2.3