aboutsummaryrefslogtreecommitdiffstats
path: root/include/items.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-06-12 20:46:30 -0700
committerfriendica <info@friendica.com>2012-06-12 20:46:30 -0700
commit920ea2e1c759b96bbcad246422b33d7f2c8fc552 (patch)
tree2286c33dbccab5d0ea3ede5999f8ec20226374e0 /include/items.php
parent832d9eeaaf7c439f3f8802d35e0e4a40509bddf5 (diff)
downloadvolse-hubzilla-920ea2e1c759b96bbcad246422b33d7f2c8fc552.tar.gz
volse-hubzilla-920ea2e1c759b96bbcad246422b33d7f2c8fc552.tar.bz2
volse-hubzilla-920ea2e1c759b96bbcad246422b33d7f2c8fc552.zip
archive widget
Diffstat (limited to 'include/items.php')
-rwxr-xr-xinclude/items.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/include/items.php b/include/items.php
index bb81d1a45..8a655594e 100755
--- a/include/items.php
+++ b/include/items.php
@@ -3390,3 +3390,50 @@ function drop_item($id,$interactive = true) {
}
}
+
+
+function first_post_date($uid,$wall = false) {
+ $r = q("select created from item
+ where uid = %d and wall = %d and deleted = 0 and visible = 1 AND moderated = 0
+ order by created asc limit 1",
+ intval($uid),
+ intval($wall ? 1 : 0)
+ );
+ if(count($r))
+ return substr($r[0]['created'],0,10);
+ return false;
+}
+
+function posted_dates($uid,$wall) {
+ $dnow = datetime_convert('','','now','Y-m-d');
+
+ $dthen = first_post_date($uid,$wall);
+ if(! $dthen)
+ return array();
+
+ $ret = array();
+ while($dnow >= $dthen) {
+ $start_month = datetime_convert('','','first day of ' . $dnow,'Y-m-d');
+ $end_month = datetime_convert('','','last day of ' . $dnow,'Y-m-d');
+ $str = day_translate(datetime_convert('','',$dnow,'F Y'));
+ $ret[] = array($str,$end_month,$start_month);
+ $dnow = datetime_convert('','',$dnow . ' -1 month', 'Y-m-d');
+ }
+ return $ret;
+}
+
+
+function posted_date_widget($url,$uid,$wall) {
+ $o = '';
+ $ret = posted_dates($uid,$wall);
+ if(! count($ret))
+ return $o;
+
+ $o = replace_macros(get_markup_template('posted_date_widget.tpl'),array(
+ '$title' => t('Archives'),
+ '$size' => ((count($ret) > 6) ? 6 : count($ret)),
+ '$url' => $url,
+ '$dates' => $ret
+ ));
+ return $o;
+} \ No newline at end of file