From: rabuzarus <> Date: Mon, 18 May 2015 23:03:08 +0000 (+0200) Subject: port of red matrix archive-widget X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=30348a1bc0b52c5b4cbfd2843214c53c9278111c;p=friendica.git port of red matrix archive-widget --- diff --git a/include/items.php b/include/items.php index 5a0aa9ed51..85d02ab60d 100644 --- a/include/items.php +++ b/include/items.php @@ -4858,6 +4858,37 @@ function first_post_date($uid,$wall = false) { return false; } +/* modified posted_dates() {below} to arrange the list in years */ +function list_post_dates($uid, $wall) { + $dnow = datetime_convert('',date_default_timezone_get(),'now','Y-m-d'); + + $dthen = first_post_date($uid, $wall); + if(! $dthen) + return array(); + + // Set the start and end date to the beginning of the month + $dnow = substr($dnow,0,8).'01'; + $dthen = substr($dthen,0,8).'01'; + + $ret = array(); + + // Starting with the current month, get the first and last days of every + // month down to and including the month of the first post + while(substr($dnow, 0, 7) >= substr($dthen, 0, 7)) { + $dyear = intval(substr($dnow,0,4)); + $dstart = substr($dnow,0,8) . '01'; + $dend = substr($dnow,0,8) . get_dim(intval($dnow),intval(substr($dnow,5))); + $start_month = datetime_convert('','',$dstart,'Y-m-d'); + $end_month = datetime_convert('','',$dend,'Y-m-d'); + $str = day_translate(datetime_convert('','',$dnow,'F')); + if(! $ret[$dyear]) + $ret[$dyear] = array(); + $ret[$dyear][] = array($str,$end_month,$start_month); + $dnow = datetime_convert('','',$dnow . ' -1 month', 'Y-m-d'); + } + return $ret; +} + function posted_dates($uid,$wall) { $dnow = datetime_convert('',date_default_timezone_get(),'now','Y-m-d'); @@ -4895,16 +4926,28 @@ function posted_date_widget($url,$uid,$wall) { /* if($wall && intval(get_pconfig($uid,'system','no_wall_archive_widget'))) return $o;*/ - - $ret = posted_dates($uid,$wall); + + $visible_years = get_pconfig($uid,'system','archive_visible_years'); + if(! $visible_years) + $visible_years = 5; + + $ret = list_post_dates($uid,$wall); + if(! count($ret)) return $o; + $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, - '$dates' => $ret + '$dates' => $ret, + '$showmore' => t('show more') + )); return $o; } diff --git a/view/templates/posted_date_widget.tpl b/view/templates/posted_date_widget.tpl index 009fa60a65..878b1d3605 100644 --- a/view/templates/posted_date_widget.tpl +++ b/view/templates/posted_date_widget.tpl @@ -1,9 +1,47 @@ + + +

{{$title}}

- - -
+ + + + + {{/if}} + + \ No newline at end of file diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css index 1b20042a5d..024e63f5f6 100644 --- a/view/theme/duepuntozero/style.css +++ b/view/theme/duepuntozero/style.css @@ -2026,11 +2026,11 @@ a.mail-list-link { margin-top: 10px; } -.nets-ul, .fileas-ul, .categories-ul { +.nets-ul, .fileas-ul, .categories-ul, .datebrowse-ul { list-style-type: none; } -.nets-ul li, .fileas-ul li, .categories-ul li { +.nets-ul li, .fileas-ul li, .categories-ul li, .datebrowse-ul li { margin-top: 10px; } diff --git a/view/theme/frost/style.css b/view/theme/frost/style.css index aed0dc0ab1..74ae6c90aa 100644 --- a/view/theme/frost/style.css +++ b/view/theme/frost/style.css @@ -2327,11 +2327,11 @@ a.mail-list-link { margin-top: 10px; } -.nets-ul, .fileas-ul, .categories-ul { +.nets-ul, .fileas-ul, .categories-ul, .datebrowse-ul { list-style-type: none; } -.nets-ul li, .fileas-ul li, .categories-ul li { +.nets-ul li, .fileas-ul li, .categories-ul li, .datebrowse-ul li { margin-top: 10px; } diff --git a/view/theme/quattro/dark/style.css b/view/theme/quattro/dark/style.css index 5f4b005c8e..a1555565d2 100644 --- a/view/theme/quattro/dark/style.css +++ b/view/theme/quattro/dark/style.css @@ -840,6 +840,9 @@ aside #dfrn-request-link:hover { aside #profiles-menu { width: 20em; } +aside .posted-date-selector-months { + margin-left: 10px; +} #contact-block { overflow: auto; height: auto; diff --git a/view/theme/quattro/green/style.css b/view/theme/quattro/green/style.css index c2826a3c0c..ef6b16aad3 100644 --- a/view/theme/quattro/green/style.css +++ b/view/theme/quattro/green/style.css @@ -840,6 +840,9 @@ aside #dfrn-request-link:hover { aside #profiles-menu { width: 20em; } +aside .posted-date-selector-months { + margin-left: 10px; +} #contact-block { overflow: auto; height: auto; diff --git a/view/theme/quattro/lilac/style.css b/view/theme/quattro/lilac/style.css index 28c5cd47a9..2d4f7cec6c 100644 --- a/view/theme/quattro/lilac/style.css +++ b/view/theme/quattro/lilac/style.css @@ -840,6 +840,9 @@ aside #dfrn-request-link:hover { aside #profiles-menu { width: 20em; } +aside .posted-date-selector-months { + margin-left: 10px; +} #contact-block { overflow: auto; height: auto; diff --git a/view/theme/smoothly/style.css b/view/theme/smoothly/style.css index d9dba9818c..46d8902aeb 100644 --- a/view/theme/smoothly/style.css +++ b/view/theme/smoothly/style.css @@ -945,13 +945,14 @@ ul .sidebar-group-li .icon { width: 12px; } -.nets-ul, .fileas-ul, .categories-ul { +.nets-ul, .fileas-ul, .categories-ul, .datebrowse-ul { list-style-type: none; } .nets-ul li, .fileas-ul li, -.categories-ul li { +.categories-ul li, +.datebrowse-link { } .nets-link { @@ -4605,10 +4606,6 @@ div #datebrowse-sidebar.widget { #id_npassword {} -#posted-date-selector { - margin-left: 33px; -} - #hide-comments-page-widget { margin-left: 40px; } diff --git a/view/theme/vier/style.css b/view/theme/vier/style.css index 779a194dd8..e75934c8c5 100644 --- a/view/theme/vier/style.css +++ b/view/theme/vier/style.css @@ -427,12 +427,16 @@ a.sidebar-group-element { color: #737373; } -#follow-sidebar form, #peoplefind-sidebar form, #netsearch-box form, #posted-date-selector { +#follow-sidebar form, #peoplefind-sidebar form, #netsearch-box form { margin-left: 10px; margin-top: 3px; margin-bottom: 3px; } +.posted-date-selector-months { + margin-left: 10px; +} + #sidebar-ungrouped, .side-link { padding-top: 5px; }