aboutsummaryrefslogtreecommitdiff
path: root/mod/blog/views/default/object/blog.php
blob: 776408cc5ff20ac95ab14980c9c516606a386a83 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/**
 * View for blog objects
 *
 * @package Blog
 */

$full = elgg_get_array_value('full', $vars, FALSE);
$blog = elgg_get_array_value('entity', $vars, FALSE);

if (!$blog) {
	return TRUE;
}

$owner = get_entity($blog->owner_guid);
$container = get_entity($blog->container_guid);
$linked_title = "<a href=\"{$blog->getURL()}\" title=\"" . htmlentities($blog->title) . "\">{$blog->title}</a>";
$categories = elgg_view('categories/view', $vars);
$excerpt = $blog->excerpt;

$body = autop($blog->description);
$owner_icon = elgg_view('profile/icon', array('entity' => $owner, 'size' => 'tiny'));
$owner_blog_link = "<a href=\"" . elgg_get_site_url() . "pg/blog/owner/$owner->username\">{$owner->name}</a>";
$author_text = elgg_echo('blog:author_by_line', array($owner_blog_link));
if ($blog->tags) {
	$tags = "<p class=\"elgg-tags\">" . elgg_view('output/tags', array('tags' => $blog->tags)) . "</p>";
} else {
	$tags = "";
}
$date = elgg_view_friendly_time($blog->publish_date);

// The "on" status changes for comments, so best to check for !Off
if ($blog->comments_on != 'Off') {
	$comments_count = elgg_count_comments($blog);
	//only display if there are commments
	if ($comments_count != 0) {
		$text = elgg_echo("comments") . " ($comments_count)";
		$comments_link = "<a href=\"{$blog->getURL()}#annotations\">$text</a>";
	} else {
		$comments_link = '';
	}
} else {
	$comments_link = '';
}

// access is always shown.
$edit = elgg_view('output/access', array('entity' => $vars['entity']));

// links to delete or edit.
if ($blog->canEdit()) {
	$edit_url = elgg_get_site_url()."pg/blog/edit/{$owner->username}/{$blog->getGUID()}/";
	$edit_link = "<span class='entity-edit'><a href=\"$edit_url\">" . elgg_echo('edit') . '</a></span>';

	$delete_url = "action/blog/delete?guid={$blog->getGUID()}";
	$delete_link = "<span class='delete-button'>" . elgg_view('output/confirmlink', array(
		'href' => $delete_url,
		'text' => elgg_echo('delete'),
		'confirm' => elgg_echo('deleteconfirm')
	)) . "</span>";

	$status = '';
	if ($blog->status != 'published') {
		$status_text = elgg_echo("blog:status:{$blog->status}");
		$status = "<span class='blog_status'>$status_text</span>";
	}

	$edit .= "$status $edit_link $delete_link";
}

// include a view for plugins to extend
$edit = elgg_view("blogs/options", array("object_type" => 'blog', 'entity' => $blog)) .
			elgg_view_likes($blog) . $edit;

if ($full) {

	$params = array(
		'title' => $blog->title,
		'buttons' => '',
	);
	$header = elgg_view('content/header', $params);

	$info = <<<HTML
<div class="entity-listing-info clearfix">
	<div class="entity-metadata">$edit</div>
	<p class="entity-subtext">
		$author_text
		$date
		$categories
		$comments_link
	</p>
	$tags
</div>
HTML;

	$blog_info = elgg_view_image_block($owner_icon, $info);

	echo <<<HTML
$header
$blog_info
<div class="blog_post elgg-content">
	$body
</div>
HTML;

} else {
	// brief view

	$body = <<<HTML
	<div class="entity-listing-info">
		<div class="elgg-metadata">$edit</div>
		<p class="entity-title">$linked_title</p>
		<p class="entity-subtext">
			$author_text
			$date
			$categories
			$comments_link
		</p>
		$tags
		<p>$excerpt</p>
	</div>
HTML;

	echo elgg_view_image_block($owner_icon, $body);
}