]> git.mxchange.org Git - friendica.git/commitdiff
port of red matrix archive-widget
authorrabuzarus <>
Mon, 18 May 2015 23:03:08 +0000 (01:03 +0200)
committerrabuzarus <>
Mon, 18 May 2015 23:03:08 +0000 (01:03 +0200)
include/items.php
view/templates/posted_date_widget.tpl
view/theme/duepuntozero/style.css
view/theme/frost/style.css
view/theme/quattro/dark/style.css
view/theme/quattro/green/style.css
view/theme/quattro/lilac/style.css
view/theme/smoothly/style.css
view/theme/vier/style.css

index 5a0aa9ed51649921a2206ebdc4512946dce8f82e..85d02ab60d55ef4a1eba1e3c392ed38c7c001bab 100644 (file)
@@ -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;
 }
index 009fa60a657068f0d778ffb58b616981f2c088c3..878b1d3605ec9147e673773490354b48b5934d0d 100644 (file)
@@ -1,9 +1,47 @@
+<script>
+
+function showHideDates() {
+        if( $('#posted-date-dropdown').is(':visible')) {
+                $('#posted-date-dropdown').hide();
+                $('#posted-date-collapse').html(window.showMore);
+                
+        }
+        else {
+                $('#posted-date-dropdown').show();
+                $('#posted-date-collapse').html(window.showFewer);
+            }
+        }
+</script>              
+
+
 <div id="datebrowse-sidebar" class="widget">
        <h3>{{$title}}</h3>
-<script>function dateSubmit(dateurl) { window.location.href = dateurl; } </script>
-<select id="posted-date-selector" name="posted-date-select" onchange="dateSubmit($(this).val());" size="{{$size}}">
-{{foreach $dates as $d}}
-<option value="{{$url}}/{{$d.1}}/{{$d.2}}" >{{$d.0}}</option>
-{{/foreach}}
-</select>
-</div>
+       <script>function dateSubmit(dateurl) { window.location.href = dateurl; } </script>
+       <ul id="posted-date-selector" class="datebrowse-ul">
+               {{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="datebrowse-ul">
+               {{/if}} 
+               <li id="posted-date-selector-year-{{$y}}" class="tool">
+                       <a class="datebrowse-link" href="#" onclick="openClose('posted-date-selector-{{$y}}'); return false;">{{$y}}</a>
+               </li>
+               <div id="posted-date-selector-{{$y}}" style="display: none;">
+                       <ul class="posted-date-selector-months datebrowse-ul">
+                               {{foreach $arr as $d}}
+                               <li class="tool">
+                                       <a class="datebrowse-link" href="#" onclick="dateSubmit('{{$url}}/{{$d.1}}/{{$d.2}}'); return false;">{{$d.0}}</a></li>
+                               </li>
+                               {{/foreach}}
+                       </ul>
+               </div>
+               {{/foreach}}
+               {{if $cutoff}}
+               </div>
+                <ul class="datebrowse-ul">
+               <li onclick="showHideDates(); return false;" id="posted-date-collapse" class="fakelink tool">{{$showmore}}</li>
+                </ul>
+               {{/if}}
+       </ul>
+</div>
\ No newline at end of file
index 1b20042a5dbea2ba06c2187e12d8f0438887ee1f..024e63f5f69fb9682211c4c0f8e350744cceec08 100644 (file)
@@ -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;
 }
 
index aed0dc0ab1e2fc302d897e030d239efe24a6823e..74ae6c90aa710f0a52639d217ba797b803be91cc 100644 (file)
@@ -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;
 }
 
index 5f4b005c8e6d5c771ab8bdff82b04c9ad62284b6..a1555565d2179c24c15e5ff829d984e2f0acb80b 100644 (file)
@@ -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;
index c2826a3c0cdfbc61406a5b1a7300beeb43bf86bc..ef6b16aad3891173c9627ced3dad8f4577b03451 100644 (file)
@@ -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;
index 28c5cd47a97ced0774cd15ca5d338316be52d70d..2d4f7cec6c41176041b738079f202414501a539b 100644 (file)
@@ -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;
index d9dba9818c4404d2f807ee573e134e46416567db..46d8902aebd9efc51ad76fe8a961fce5684e5b67 100644 (file)
@@ -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;
 }
index 779a194dd8cc506e195e62dd93ce41d43a4237fc..e75934c8c5822472cee90c82fd94b3d27d7c592f 100644 (file)
@@ -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;
 }