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
125
126
127
128
129
130
131
132
133
134
135
|
<?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 = $blog->getOwnerEntity();
$container = $blog->getContainerEntity();
$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_link = elgg_view('output/url', array(
'href' => "pg/blog/owner/$owner->username",
'text' => $owner->name,
));
$author_text = elgg_echo('blog:author_by_line', array($owner_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 = elgg_view('output/url', array(
'href' => $blog->getURL() . '#blog-comments',
'text' => $text,
));
} else {
$comments_link = '';
}
} else {
$comments_link = '';
}
// access is always shown.
$metadata = '<ul class="elgg-list-metadata">';
$metadata .= '<li>' . elgg_view('output/access', array('entity' => $blog)) . '</li>';
$likes = elgg_view_likes($blog);
$metadata .= "<li>$likes</li>";
// pass <li>your data</li> back from the view
$metadata .= elgg_view("entity/metadata", array('entity' => $blog));
// links to delete or edit.
if ($blog->canEdit()) {
$status = '';
if ($blog->status != 'published') {
$status_text = elgg_echo("blog:status:{$blog->status}");
$metadata .= "<li>$status_text</li>";
}
$edit_url = elgg_get_site_url() . "pg/blog/edit/{$blog->getGUID()}/";
$edit_link = elgg_view('output/url', array(
'href' => $edit_url,
'text' => elgg_echo('edit'),
));
$metadata .= "<li>$edit_link</li>";
$delete_url = "action/blog/delete?guid={$blog->getGUID()}";
$delete_link = elgg_view('output/confirmlink', array(
'href' => $delete_url,
'text' => '<span class="elgg-icon elgg-icon-delete"></span>',
'title' => elgg_echo('delete'),
'confirm' => elgg_echo('deleteconfirm'),
'text_encode' => false,
));
$metadata .= "<li>$delete_link</li>";
}
$metadata .= '</ul>';
$subtitle = "$author_text $date $categories $comments_link";
// do not show the metadata and controls in widget view
if (elgg_in_context('widgets')) {
$metadata = '';
}
if ($full) {
$header = elgg_view_title($blog->title);
$params = array(
'entity' => $blog,
'title' => false,
'metadata' => $metadata,
'subtitle' => $subtitle,
'tags' => $tags,
);
$list_body = elgg_view('layout/objects/list/body', $params);
$blog_info = elgg_view_image_block($owner_icon, $list_body);
echo <<<HTML
$header
$blog_info
<div class="blog-post elgg-content">
$body
</div>
HTML;
} else {
// brief view
$params = array(
'entity' => $blog,
'metadata' => $metadata,
'subtitle' => $subtitle,
'tags' => $tags,
'content' => $excerpt,
);
$list_body = elgg_view('layout/objects/list/body', $params);
echo elgg_view_image_block($owner_icon, $list_body);
}
|