source: trunk/include/calendar_weekly.class.php @ 1050

Last change on this file since 1050 was 1050, checked in by rvelices, 18 years ago

calendar redesign: monthly and weekly styles + list/calendar views for monthly

File size: 3.5 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
5// +-----------------------------------------------------------------------+
6// | branch        : BSF (Best So Far)
7// | file          : $RCSfile$
8// | last update   : $Date: 2006-01-27 02:11:43 +0100 (ven, 27 jan 2006) $
9// | last modifier : $Author: rvelices $
10// | revision      : $Revision: 1014 $
11// +-----------------------------------------------------------------------+
12// | This program is free software; you can redistribute it and/or modify  |
13// | it under the terms of the GNU General Public License as published by  |
14// | the Free Software Foundation                                          |
15// |                                                                       |
16// | This program is distributed in the hope that it will be useful, but   |
17// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
18// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
19// | General Public License for more details.                              |
20// |                                                                       |
21// | You should have received a copy of the GNU General Public License     |
22// | along with this program; if not, write to the Free Software           |
23// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
24// | USA.                                                                  |
25// +-----------------------------------------------------------------------+
26
27include_once(PHPWG_ROOT_PATH.'include/calendar_base.class.php');
28
29/**
30 * Weekly calendar style (composed of years/week in years and days in week)
31 */
32class Calendar extends CalendarBase
33{
34
35/**
36 * Generate navigation bars for category page
37 * @return boolean false to indicate that thumbnails where not included here
38 */
39function generate_category_content($url_base, $view_type, &$requested)
40{
41  global $lang;
42
43  $this->url_base = $url_base;
44
45  assert($view_type==CAL_VIEW_LIST);
46
47  $this->build_nav_bar($view_type, $requested, 0, 'YEAR'); // years
48  if (count($requested)>0)
49    $this->build_nav_bar($view_type, $requested, 1, 'WEEK', '+1' ); // month
50  if (count($requested)>1)
51    $this->build_nav_bar($view_type, $requested, 2, 'DAYOFWEEK', '-1',
52                         $lang['day'] ); // days
53  return false;
54}
55
56
57/**
58 * Returns a sql where subquery for the date field
59 * @param array requested selected levels for this calendar
60 * (e.g. 2005,42,1 for 41st week of 2005, Monday)
61 * @param int max_levels return the where up to this level
62 * (e.g. 2=only year and week in year)
63 * @return string
64 */
65function get_date_where($requested, $max_levels=3)
66{
67  while (count($requested)>$max_levels)
68  {
69    array_pop($requested);
70  }
71  $res = '';
72  if (isset($requested[0]) and $requested[0]!='any')
73  {
74    $y = $requested[0];
75    $res = " AND $this->date_field BETWEEN '$y-01-01' AND '$y-12-31'";
76  }
77
78  if (isset($requested[1]) and $requested[1]!='any')
79  {
80    $res .= ' AND WEEK('.$this->date_field.')+1='.$requested[1];
81  }
82  if (isset($requested[2]) and $requested[2]!='any')
83  {
84    $res .= ' AND DAYOFWEEK('.$this->date_field.')-1='.$requested[2];
85  }
86  if (empty($res))
87  {
88    $res = ' AND '.$this->date_field.' IS NOT NULL';
89  }
90  return $res;
91}
92
93}
94
95?>
Note: See TracBrowser for help on using the repository browser.