various UI issues related to having an enormous number of entries in the posted_date selector including years/months that had no posts
This commit is contained in:
parent
ac858f4bd4
commit
a6d8c3193a
@ -4128,10 +4128,13 @@ function first_post_date($uid,$wall = false) {
|
||||
* current flat list of all representative dates.
|
||||
*/
|
||||
|
||||
function list_post_dates($uid,$wall) {
|
||||
function list_post_dates($uid,$wall,$mindate) {
|
||||
$dnow = datetime_convert('',date_default_timezone_get(),'now','Y-m-d');
|
||||
|
||||
$dthen = first_post_date($uid,$wall);
|
||||
if($mindate)
|
||||
$dthen = datetime_convert('',date_default_timezone_get(),$mindate);
|
||||
else
|
||||
$dthen = first_post_date($uid,$wall);
|
||||
if(! $dthen)
|
||||
return array();
|
||||
|
||||
|
@ -330,19 +330,32 @@ function widget_archive($arr) {
|
||||
|
||||
$wall = ((array_key_exists('wall', $arr)) ? intval($arr['wall']) : 0);
|
||||
$style = ((array_key_exists('style', $arr)) ? $arr['style'] : 'select');
|
||||
$showend = ((get_pconfig($uid,'system','archive_show_end_date')) ? true : false);
|
||||
$mindate = get_pconfig($uid,'system','archive_mindate');
|
||||
$visible_years = get_pconfig($uid,'system','archive_visible_years');
|
||||
if(! $visible_years)
|
||||
$visible_years = 5;
|
||||
|
||||
|
||||
$url = z_root() . '/' . $a->cmd;
|
||||
|
||||
|
||||
$ret = list_post_dates($uid,$wall);
|
||||
$ret = list_post_dates($uid,$wall,$mindate);
|
||||
|
||||
if(! count($ret))
|
||||
return '';
|
||||
|
||||
$cutoff_year = intval(datetime_convert('',date_default_timezone_get(),'now','Y')) - $visible_years;
|
||||
$cutoff = ((array_key_exists($cutoff_year,$ret))? true : false);
|
||||
|
||||
$o = replace_macros(get_markup_template('posted_date_widget.tpl'),array(
|
||||
'$title' => t('Archives'),
|
||||
'$size' => ((count($ret) > 6) ? 6 : count($ret)),
|
||||
'$size' => $visible_years,
|
||||
'$cutoff_year' => $cutoff_year,
|
||||
'$cutoff' => $cutoff,
|
||||
'$url' => $url,
|
||||
'$style' => $style,
|
||||
'$showend' => $showend,
|
||||
'$dates' => $ret
|
||||
));
|
||||
return $o;
|
||||
|
@ -1,8 +1,30 @@
|
||||
<script>
|
||||
|
||||
function toggle_posted_date_button() {
|
||||
if($('#posted-date-dropdown').is(':visible')) {
|
||||
$('#posted-date-icon').removeClass('icon-caret-up');
|
||||
$('#posted-date-icon').addClass('icon-caret-down');
|
||||
$('#posted-date-dropdown').hide();
|
||||
}
|
||||
else {
|
||||
$('#posted-date-icon').addClass('icon-caret-up');
|
||||
$('#posted-date-icon').removeClass('icon-caret-down');
|
||||
$('#posted-date-dropdown').show();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<div id="datebrowse-sidebar" class="widget">
|
||||
<h3>{{$title}}</h3>
|
||||
<script>function dateSubmit(dateurl) { window.location.href = dateurl; } </script>
|
||||
<ul id="posted-date-selector" class="nav nav-pills nav-stacked">
|
||||
{{foreach $dates as $y => $arr}}
|
||||
{{if $y == $cutoff_year}}
|
||||
</ul>
|
||||
<div id="posted-date-dropdown" style="display: none;">
|
||||
<ul id="posted-date-selector-drop" class="nav nav-pills nav-stacked">
|
||||
{{/if}}
|
||||
<li id="posted-date-selector-year-{{$y}}">
|
||||
<a href="#" onclick="openClose('posted-date-selector-{{$y}}'); return false;">{{$y}}</a>
|
||||
</li>
|
||||
@ -10,11 +32,15 @@
|
||||
<ul class="posted-date-selector-months nav nav-pills nav-stacked">
|
||||
{{foreach $arr as $d}}
|
||||
<li>
|
||||
<a href="#" onclick="dateSubmit('{{$url}}?f=&dend={{$d.1}}&dbegin={{$d.2}}'); return false;">{{$d.0}}</a>
|
||||
<a href="#" onclick="dateSubmit('{{$url}}?f=&dend={{$d.1}}{{if $showend}}&dbegin={{$d.2}}{{/if}}'); return false;">{{$d.0}}</a>
|
||||
</li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
</div>
|
||||
{{/foreach}}
|
||||
{{if $cutoff}}
|
||||
</div>
|
||||
<button class="btn btn-default btn-sm" onclick="toggle_posted_date_button(); return false;"><i id="posted-date-icon" class="icon-caret-down"></i></button>
|
||||
{{/if}}
|
||||
</ul>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user