aboutsummaryrefslogtreecommitdiffstats
path: root/include/calendar_weekly.class.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2006-02-24 05:58:48 +0000
committerrvelices <rv-github@modusoptimus.com>2006-02-24 05:58:48 +0000
commitd4646f39d2259d4b4ba619b8f2b8aa61f9be74b5 (patch)
tree5e79d1234e3981ba449a6a9f85fd0c76565ba308 /include/calendar_weekly.class.php
parent3aff4f0bfec650d7a080b919b299ddcf6fc6ee59 (diff)
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
Diffstat (limited to 'include/calendar_weekly.class.php')
-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