diff options
author | rvelices <rv-github@modusoptimus.com> | 2006-02-28 04:28:06 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2006-02-28 04:28:06 +0000 |
commit | 97898b36858d5f187e9659d723c71eb04b2f0593 (patch) | |
tree | 363cfd342a409cc4f1109dbf1469c12e9090a6ff /include/calendar_base.class.php | |
parent | 4cd5b05d406a9820a0523ac26f254f4ce4fd5147 (diff) |
calendar improvements: week on weekly list starts on Monday,
ability to show grayed months/weeks/days (without any picture in it),
added icons for created/posted fields
language uniformization
calendar fixes: correct number of pictures in calendar view,
code simplification (I hope so)
git-svn-id: http://piwigo.org/svn/trunk@1059 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/calendar_base.class.php')
-rw-r--r-- | include/calendar_base.class.php | 107 |
1 files changed, 87 insertions, 20 deletions
diff --git a/include/calendar_base.class.php b/include/calendar_base.class.php index 1a7b54989..8f9ec4bb7 100644 --- a/include/calendar_base.class.php +++ b/include/calendar_base.class.php @@ -37,7 +37,8 @@ class CalendarBase var $url_base; // array of date components e.g. (2005,10,12) ... var $date_components; - + // + var $calendar_levels; /** * Initialize the calendar @@ -52,16 +53,45 @@ class CalendarBase $this->date_components = $date_components; } + function get_display_name() + { + global $conf; + $res = ''; + $url = $this->url_base; + + for ($i=0; $i<count($this->date_components); $i++) + { + $res .= $conf['level_separator']; + + $url .= $this->date_components[$i].'-'; + if ( isset($this->date_components[$i+1]) ) + { + $res .= + '<a href="'.$url.'">' + .$this->get_date_component_label($i, $this->date_components[$i]) + .'</a>'; + } + else + { + $res .= + '<span class="calInHere">' + .$this->get_date_component_label($i, $this->date_components[$i]) + .'</span>'; + } + } + return $res; + } + //--------------------------------------------------------- private members --- /** * Returns a display name for a date component optionally using labels */ - function get_date_component_label($date_component, $labels=null) + function get_date_component_label($level, $date_component) { $label = $date_component; - if (isset($labels[$date_component])) + if (isset($this->calendar_levels[$level]['labels'][$date_component])) { - $label = $labels[$date_component]; + $label = $this->calendar_levels[$level]['labels'][$date_component]; } elseif ($date_component == 'any' ) { @@ -69,7 +99,7 @@ class CalendarBase } return $label; } - + /** * Creates a calendar navigation bar. * @@ -77,15 +107,31 @@ class CalendarBase * @param array items - hash of items to put in the bar (e.g. 2005,2006) * @param array selected_item - item currently selected (e.g. 2005) * @param string class_prefix - html class attribute prefix for span elements - * @param bool allow_any - adds any to the end of the bar + * @param bool show_any - adds any link to the end of the bar + * @param bool show_empty - shows all labels even those without items * @param array labels - optional labels for items (e.g. Jan,Feb,...) * @return string the navigation bar */ function get_nav_bar_from_items($url_base, $items, $selected_item, - $class_prefix, $allow_any, $labels=null) + $class_prefix, $show_any, + $show_empty=false, $labels=null) { + global $conf; + $nav_bar = ''; - + + if ($conf['calendar_show_empty'] and $show_empty and !empty($labels) ) + { + foreach ($labels as $item => $label) + { + if ( ! isset($items[$item]) ) + { + $items[$item] = -1; + } + } + ksort($items); + } + foreach ($items as $item => $nb_images) { $label = $item; @@ -98,6 +144,11 @@ class CalendarBase $nav_bar .= '<span class="'.$class_prefix.'Sel">'; $nav_bar .= $label; } + elseif ($nb_images==-1) + { + $nav_bar .= '<span class="'.$class_prefix.'Empty">'; + $nav_bar .= $label; + } else { $nav_bar .= '<span class="'.$class_prefix.'">'; @@ -112,8 +163,8 @@ class CalendarBase } $nav_bar.= '</span>'; } - global $conf; - if ($conf['calendar_show_any'] and $allow_any and count($items) > 1) + + if ($conf['calendar_show_any'] and $show_any and count($items) > 1) { $label = l10n('calendar_any'); if (isset($selected_item) and 'any' == $selected_item) @@ -137,18 +188,15 @@ class CalendarBase /** * Creates a calendar navigation bar for a given level. * - * @param string sql_func - YEAR/MONTH/DAY/WEEK/DAYOFWEEK ... - * @param string sql_offset - (e.g. +1 for WEEK - first in year is 1) - * @param array labels - optional labels to show in the navigation bar + * @param int level - the level (0-year,1-month/week,2-day) * @return void */ - function build_nav_bar($level, $sql_func, - $sql_offset='', $labels=null) + function build_nav_bar($level, $labels=null) { - global $template; - + global $template, $conf; + $query = ' -SELECT DISTINCT('.$sql_func.'('.$this->date_field.')'.$sql_offset +SELECT DISTINCT('.$this->calendar_levels[$level]['sql'] .') as period'; $query.= $this->inner_sql; $query.= $this->get_date_where($level); @@ -163,6 +211,24 @@ SELECT DISTINCT('.$sql_func.'('.$this->date_field.')'.$sql_offset $level_items[$row['period']] = 0; } + if ( count($level_items)==1 ) + { + if ( ! isset($this->date_components[$level]) ) + { + list($key) = array_keys($level_items); + $this->date_components[$level] = (int)$key; + } + } + + if ( $conf['calendar_multi_bar']==false ) + { + if ( $level<count($this->date_components) and + $level!=count($this->calendar_levels)-1 ) + { + return; + } + } + $url_base = $this->url_base; for ($i=0; $i<$level; $i++) { @@ -180,9 +246,10 @@ SELECT DISTINCT('.$sql_func.'('.$this->date_field.')'.$sql_offset $url_base, $level_items, $selected, - 'cal', + 'calItem', + true, true, - $labels + isset($labels) ? $labels : $this->calendar_levels[$level]['labels'] ); $template->assign_block_vars( |