aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2009-03-03 02:05:35 +0000
committerrvelices <rv-github@modusoptimus.com>2009-03-03 02:05:35 +0000
commit781ec8d7c4989b39dd289071e16f156857b6acfb (patch)
tree8c0b321c3c55de2042d30193b0843b56e6665094
parent54902df0a4d0c9cd0c93bc285c7388f6c9e5205e (diff)
- 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
Diffstat (limited to '')
-rw-r--r--include/calendar_base.class.php49
-rw-r--r--include/calendar_monthly.class.php8
-rw-r--r--template/yoga/calendar_navbar.tpl13
-rw-r--r--template/yoga/month_calendar.tpl43
4 files changed, 52 insertions, 61 deletions
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'])<count($this->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;
diff --git a/template/yoga/calendar_navbar.tpl b/template/yoga/calendar_navbar.tpl
deleted file mode 100644
index 8e35c766b..000000000
--- a/template/yoga/calendar_navbar.tpl
+++ /dev/null
@@ -1,13 +0,0 @@
-
-{foreach from=$datas item=data}
- <span class="{$data.classname}">
- {if isset($data.url) and $data.url!=""}
- <a href="{$data.url}">{$data.label}</a>
- {else}
- {$data.label}
- {/if}
- {if isset($data.nb_images) and $data.nb_images!=""}
- ({$data.nb_images})
- {/if}
- </span>
-{/foreach} \ No newline at end of file
diff --git a/template/yoga/month_calendar.tpl b/template/yoga/month_calendar.tpl
index 410824b23..8fd0eb25f 100644
--- a/template/yoga/month_calendar.tpl
+++ b/template/yoga/month_calendar.tpl
@@ -3,17 +3,25 @@
{if !empty($chronology_navigation_bars) }
{foreach from=$chronology_navigation_bars item=bar}
<div class="calendarBar">
- {if isset($bar.previous)}
- <div style="float:left">&laquo; <a href="{$bar.previous.URL}">{$bar.previous.LABEL}</a></div>
- {/if}
- {if isset($bar.next)}
- <div style="float:right"><a href="{$bar.next.URL}">{$bar.next.LABEL}</a> &raquo;</div>
- {/if}
- {if isset($bar.CONTENT)}
- {$bar.CONTENT}
- {else}
- &nbsp;
- {/if}
+ {if isset($bar.previous)}
+ <div style="float:left">&laquo; <a href="{$bar.previous.URL}">{$bar.previous.LABEL}</a></div>
+ {/if}
+ {if isset($bar.next)}
+ <div style="float:right"><a href="{$bar.next.URL}">{$bar.next.LABEL}</a> &raquo;</div>
+ {/if}
+ {if empty($bar.items)}
+ &nbsp;
+ {else}
+ {foreach from=$bar.items item=item}
+ <span class="calItem{if !isset($item.URL)}Empty{/if}" {if isset($item.NB_IMAGES)}title="{$pwg->l10n_dec('%d element', '%d elements', $item.NB_IMAGES)}"{/if}>
+ {if isset($item.URL)}
+ <a href="{$item.URL}">{$item.LABEL}</a>
+ {else}
+ {$item.LABEL}
+ {/if}
+ </span>
+ {/foreach}
+ {/if}
</div>
{/foreach}
{/if}
@@ -21,8 +29,17 @@
{if !empty($chronology_calendar.calendar_bars) }
{foreach from=$chronology_calendar.calendar_bars item=bar}
<div class="calendarCalBar">
- <span class="calCalHead"><a href="{$bar.U_HEAD}">{$bar.HEAD_LABEL}</a> ({$bar.NB_IMAGES})</span><br/>
- {$bar.NAV_BAR}
+ <span class="calCalHead"><a href="{$bar.U_HEAD}">{$bar.HEAD_LABEL}</a> ({$bar.NB_IMAGES})</span><br/>
+ {foreach from=$bar.items item=item}
+ <span class="calCal{if !isset($item.URL)}Empty{/if}">
+ {if isset($item.URL)}
+ <a href="{$item.URL}">{$item.LABEL}</a>
+ {else}
+ {$item.LABEL}
+ {/if}
+ {if isset($item.NB_IMAGES)}({$item.NB_IMAGES}){/if}
+ </span>
+ {/foreach}
</div>
{/foreach}
{/if}