aboutsummaryrefslogtreecommitdiffstats
path: root/include/calendar_weekly.class.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/calendar_weekly.class.php87
1 files changed, 69 insertions, 18 deletions
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 .=
+ '<a href="'.$url.'">'
+ .$this->get_date_component_label($this->date_components[CYEAR])
+ .'</a>';
+ }
+ if ( isset($this->date_components[CWEEK]) )
+ {
+ $res .= $conf['level_separator'];
+ $url .= $this->date_components[CWEEK].'-';
+ $res .=
+ '<a href="'.$url.'">'
+ .$this->get_date_component_label($this->date_components[CWEEK])
+ .'</a>';
+ }
+ if ( isset($this->date_components[CDAY]) )
+ {
+ $res .= $conf['level_separator'];
+ $url .= $this->date_components[CDAY].'-';
+ $res .=
+ '<a href="'.$url.'">'
+ .$this->get_date_component_label(
+ $this->date_components[CDAY],
+ $lang['day']
+ )
+ .'</a>';
+ }
+ return $res;
+}
+
}
?> \ No newline at end of file