From 781ec8d7c4989b39dd289071e16f156857b6acfb Mon Sep 17 00:00:00 2001 From: rvelices Date: Tue, 3 Mar 2009 02:05:35 +0000 Subject: - improvement: show the number of images in the chronology upper navigation bar on mouseover (title element); git-svn-id: http://piwigo.org/svn/trunk@3168 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/calendar_base.class.php | 49 ++++++++++++++------------------------ include/calendar_monthly.class.php | 8 +++---- 2 files changed, 22 insertions(+), 35 deletions(-) (limited to 'include') diff --git a/include/calendar_base.class.php b/include/calendar_base.class.php index 619d909ca..a0b90ba05 100644 --- a/include/calendar_base.class.php +++ b/include/calendar_base.class.php @@ -127,14 +127,13 @@ class CalendarBase * * @param array date_components * @param array items - hash of items to put in the bar (e.g. 2005,2006) - * @param string class_prefix - html class attribute prefix for span elements * @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($date_components, $items, - $class_prefix, $show_any, + $show_any, $show_empty=false, $labels=null) { global $conf, $page, $template; @@ -163,8 +162,7 @@ class CalendarBase if ($nb_images==-1) { $tmp_datas=array( - 'classname' => $class_prefix."Empty", - 'label'=> $label + 'LABEL'=> $label ); } else @@ -174,17 +172,16 @@ class CalendarBase array( 'start' ) ); $tmp_datas=array( - 'classname' => $class_prefix, - 'label'=> $label, - 'url' => $url + 'LABEL'=> $label, + 'URL' => $url ); } if ($nb_images > 0) { - $tmp_datas['nb_images']=$nb_images; + $tmp_datas['NB_IMAGES']=$nb_images; } $nav_bar_datas[]=$tmp_datas; - + } if ($conf['calendar_show_any'] and $show_any and count($items)>1 and @@ -195,15 +192,12 @@ class CalendarBase array( 'start' ) ); $nav_bar_datas[]=array( - 'label' => l10n('calendar_any'), - 'classname' => $class_prefix, - 'url' => $url + 'LABEL' => l10n('calendar_any'), + 'URL' => $url ); } - $template->set_filenames( array( 'nav_bar' => 'calendar_navbar.tpl',)); - $template->assign('datas', $nav_bar_datas); - return($template->parse('nav_bar', true)); + return $nav_bar_datas; } /** @@ -217,20 +211,14 @@ class CalendarBase global $template, $conf, $page; $query = ' -SELECT DISTINCT('.$this->calendar_levels[$level]['sql'] - .') as period'; - $query.= $this->inner_sql; - $query.= $this->get_date_where($level); - $query.= ' +SELECT DISTINCT('.$this->calendar_levels[$level]['sql'].') as period, + COUNT(DISTINCT id) as nb_images'. +$this->inner_sql. +$this->get_date_where($level).' GROUP BY period ;'; - $level_items = array(); - $result = pwg_query($query); - while ($row = mysql_fetch_array($result)) - { - $level_items[$row['period']] = 0; - } + $level_items = simple_hash_from_query($query, 'period', 'nb_images'); if ( count($level_items)==1 and count($page['chronology_date'])calendar_levels)-1) @@ -257,7 +245,6 @@ SELECT DISTINCT('.$this->calendar_levels[$level]['sql'] $nav_bar = $this->get_nav_bar_from_items( $dates, $level_items, - 'calItem', true, true, isset($labels) ? $labels : $this->calendar_levels[$level]['labels'] @@ -266,7 +253,7 @@ SELECT DISTINCT('.$this->calendar_levels[$level]['sql'] $template->append( 'chronology_navigation_bars', array( - 'CONTENT' => $nav_bar, + 'items' => $nav_bar, ) ); } @@ -312,7 +299,7 @@ GROUP BY period'; $current_rank = $upper_items_rank[$current]; $tpl_var = array(); - + if ( $current_rank>0 ) { // has previous $prev = $upper_items[$current_rank-1]; @@ -325,7 +312,7 @@ GROUP BY period'; ) ); } - + if ( $current_rank < count($upper_items)-1 ) { // has next $next = $upper_items[$current_rank+1]; @@ -338,7 +325,7 @@ GROUP BY period'; ) ); } - + if ( !empty($tpl_var) ) { $existing = & $template->get_template_vars('chronology_navigation_bars'); diff --git a/include/calendar_monthly.class.php b/include/calendar_monthly.class.php index 8d58833c0..4a25e0ee4 100644 --- a/include/calendar_monthly.class.php +++ b/include/calendar_monthly.class.php @@ -257,14 +257,14 @@ function build_global_calendar(&$tpl_var) $url = duplicate_index_url( array('chronology_date'=>$chronology_date) ); $nav_bar = $this->get_nav_bar_from_items( $chronology_date, - $year_data['children'], 'calCal', false, false, $lang['month'] ); + $year_data['children'], false, false, $lang['month'] ); $tpl_var['calendar_bars'][] = array( 'U_HEAD' => $url, 'NB_IMAGES' => $year_data['nb_images'], 'HEAD_LABEL' => $year, - 'NAV_BAR' => $nav_bar, + 'items' => $nav_bar, ); } return true; @@ -307,14 +307,14 @@ function build_year_calendar(&$tpl_var) $url = duplicate_index_url( array('chronology_date'=>$chronology_date) ); $nav_bar = $this->get_nav_bar_from_items( $chronology_date, - $month_data['children'], 'calCal', false ); + $month_data['children'], false ); $tpl_var['calendar_bars'][] = array( 'U_HEAD' => $url, 'NB_IMAGES' => $month_data['nb_images'], 'HEAD_LABEL' => $lang['month'][$month], - 'NAV_BAR' => $nav_bar, + 'items' => $nav_bar, ); } return true; -- cgit v1.2.3