aboutsummaryrefslogtreecommitdiffstats
path: root/include/items.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-04-30 18:45:46 -0700
committerfriendica <info@friendica.com>2014-04-30 18:45:46 -0700
commitf96a81d274601d87e207dd97c2b9cc83a55a24d0 (patch)
tree16dadd42bbecd9f9b7ece416d5e6566e92a47e98 /include/items.php
parentc1f8eda71997ecb9a1c2923e1f979a43e8ea9599 (diff)
downloadvolse-hubzilla-f96a81d274601d87e207dd97c2b9cc83a55a24d0.tar.gz
volse-hubzilla-f96a81d274601d87e207dd97c2b9cc83a55a24d0.tar.bz2
volse-hubzilla-f96a81d274601d87e207dd97c2b9cc83a55a24d0.zip
posted_dates() needs a re-write so we can make a much prettier archive widget
Diffstat (limited to 'include/items.php')
-rwxr-xr-xinclude/items.php42
1 files changed, 41 insertions, 1 deletions
diff --git a/include/items.php b/include/items.php
index 4c7854bdf..ea6a7fcb9 100755
--- a/include/items.php
+++ b/include/items.php
@@ -3723,13 +3723,53 @@ function first_post_date($uid,$wall = false) {
intval($uid)
);
- if(count($r)) {
+ if($r) {
// logger('first_post_date: ' . $r[0]['id'] . ' ' . $r[0]['created'], LOGGER_DATA);
return substr(datetime_convert('',date_default_timezone_get(),$r[0]['created']),0,10);
}
return false;
}
+/**
+ * modified posted_dates() {below} to arrange the list in years, which we'll eventually
+ * use to make a menu of years with collapsible sub-menus for the months instead of the
+ * current flat list of all representative dates.
+ */
+
+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();
+
+ // If it's near the end of a long month, backup to the 28th so that in
+ // consecutive loops we'll always get a whole month difference.
+
+ if(intval(substr($dnow,8)) > 28)
+ $dnow = substr($dnow,0,8) . '28';
+ if(intval(substr($dthen,8)) > 28)
+ $dnow = substr($dthen,0,8) . '28';
+
+ $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');