aboutsummaryrefslogtreecommitdiff
path: root/mod/blog/views/default/blog/sidebar/archives.php
blob: 3d8f28ca4c259eaddbc3e61da92e615fad13a3a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/**
 * Blog archives
 */

$loggedin_user = elgg_get_logged_in_user_entity();
$page_owner = elgg_get_page_owner_entity();

if (elgg_instanceof($page_owner, 'user')) {
	$url_segment = 'blog/archive/' . $page_owner->username;
} else {
	$url_segment = 'blog/group/' . $page_owner->getGUID() . '/archive';
}

// This is a limitation of the URL schema.
if ($page_owner && $vars['page'] != 'friends') {
	$dates = get_entity_dates('object', 'blog', $page_owner->getGUID());
	
	if ($dates) {
		$title = elgg_echo('blog:archives');
		$content = '<ul class="blog-archives">';
		foreach ($dates as $date) {
			$timestamplow = mktime(0, 0, 0, substr($date,4,2) , 1, substr($date, 0, 4));
			$timestamphigh = mktime(0, 0, 0, ((int) substr($date, 4, 2)) + 1, 1, substr($date, 0, 4));

			$link = elgg_get_site_url() . $url_segment . '/' . $timestamplow . '/' . $timestamphigh;
			$month = elgg_echo('date:month:' . substr($date, 4, 2), array(substr($date, 0, 4)));
			$content .= "<li><a href=\"$link\" title=\"$month\">$month</a></li>";
		}
		$content .= '</ul>';

		echo elgg_view_module('aside', $title, $content);
	}
}