aboutsummaryrefslogtreecommitdiff
path: root/mod/blog/views/default/object/blog.php
blob: eaf25d726b93774a1f9b17a35e99786baf2626bb (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
<?php
/**
 * View for blog objects
 *
 * @package Blog
 */

$full = (isset($vars['full'])) ? $vars['full'] : FALSE;
$blog = (isset($vars['entity'])) ? $vars['entity'] : FALSE;

if (!$blog) {
	return '';
}

$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->username\">{$owner->name}</a>";
$author_text = sprintf(elgg_echo('blog:author_by_line'), $owner_blog_link);
if($blog->tags){
	$tags = "<p class=\"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){
		$comments_link = "<a href=\"{$blog->getURL()}#annotations\">" . elgg_echo("comments") . " (". $comments_count .")</a>";
	}else{
		$comments_link = '';
	}
} else {
	$comments_link = '';
}

// links to delete or edit.

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

if ($blog->canEdit()) {
	$edit_url = elgg_get_site_url()."pg/blog/{$owner->username}/edit/{$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) . // include likes
			$edit;

if ($full) {

echo <<<___END
<div class="blogpost clearfix">
	<div id="content_header" class="clearfix">
		<div class="content_header_title"><h2>{$blog->title}</h2></div>
	</div>
	<div class="clearfix">
	<div class="entity_listing_icon">
		$owner_icon
	</div>
	<div class="entity_listing_info">
		<div class="entity_metadata">$edit</div>
		<p class="entity_subtext">
			$author_text
			$date
			$categories
			$comments_link
		</p>
		$tags
	</div>
	</div>
	<div class='blog_post'>$body</div>
</div>

___END;

} else {
	echo <<<___END
<div class="blog $status_class entity_listing clearfix">
	<div class="entity_listing_icon">
		$owner_icon
	</div>
	<div class="entity_listing_info">
		<div class="entity_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>
</div>

___END;
}