Permalink
Browse files

feature(views): added a generic by_line page element for content objects

  • Loading branch information...
jdalsem committed Jul 2, 2015
1 parent 20e606b commit 1a5bcb64666aac545c3f42a0ec0fabc5afa40ec3
View
@@ -1259,6 +1259,7 @@
*/
'byline' => 'By %s',
+ 'byline:ingroup' => 'in the group %s',
'entity:default:strapline' => 'Created %s by %s',
'entity:default:missingsupport:popup' => 'This entity cannot be displayed correctly. This may be because it requires support provided by a plugin that is no longer installed.',
@@ -20,13 +20,9 @@
}
$owner_icon = elgg_view_entity_icon($owner, 'tiny');
-$owner_link = elgg_view('output/url', array(
- 'href' => "blog/owner/$owner->username",
- 'text' => $owner->name,
- 'is_trusted' => true,
-));
-$author_text = elgg_echo('byline', array($owner_link));
-$date = elgg_view_friendly_time($blog->time_created);
+
+$vars['owner_url'] = "blog/owner/$owner->username";
+$by_line = elgg_view('page/elements/by_line', $vars);
// The "on" status changes for comments, so best to check for !Off
if ($blog->comments_on != 'Off') {
@@ -46,7 +42,7 @@
$comments_link = '';
}
-$subtitle = "$author_text $date $comments_link $categories";
+$subtitle = "$by_line $comments_link $categories";
$metadata = '';
if (!elgg_in_context('widgets')) {
@@ -19,14 +19,8 @@
$link = elgg_view('output/url', array('href' => $bookmark->address));
$description = elgg_view('output/longtext', array('value' => $bookmark->description, 'class' => 'pbl'));
-$owner_link = elgg_view('output/url', array(
- 'href' => "bookmarks/owner/$owner->username",
- 'text' => $owner->name,
- 'is_trusted' => true,
-));
-$author_text = elgg_echo('byline', array($owner_link));
-
-$date = elgg_view_friendly_time($bookmark->time_created);
+$vars['owner_url'] = "bookmarks/owner/$owner->username";
+$by_line = elgg_view('page/elements/by_line', $vars);
$comments_count = $bookmark->countComments();
//only display if there are commments
@@ -41,7 +35,7 @@
$comments_link = '';
}
-$subtitle = "$author_text $date $comments_link $categories";
+$subtitle = "$by_line $comments_link $categories";
$metadata = '';
if (!elgg_in_context('widgets') && !elgg_in_context('gallery')) {
@@ -22,15 +22,10 @@
$excerpt = elgg_get_excerpt($topic->description);
$poster_icon = elgg_view_entity_icon($poster, 'tiny');
-$poster_link = elgg_view('output/url', array(
- 'href' => $poster->getURL(),
- 'text' => $poster->name,
- 'is_trusted' => true,
-));
-$poster_text = elgg_echo('groups:started', array($poster->name));
+
+$by_line = elgg_view('page/elements/by_line', $vars);
$tags = elgg_view('output/tags', array('tags' => $topic->tags));
-$date = elgg_view_friendly_time($topic->time_created);
$replies_link = '';
$reply_text = '';
@@ -79,7 +74,7 @@
}
if ($full) {
- $subtitle = "$poster_text $date $replies_link";
+ $subtitle = "$by_line $replies_link";
$params = array(
'entity' => $topic,
@@ -104,7 +99,7 @@
} else {
// brief view
- $subtitle = "$poster_text $date $replies_link <span class=\"float-alt\">$reply_text</span>";
+ $subtitle = "$by_line $replies_link <span class=\"float-alt\">$reply_text</span>";
$params = array(
'entity' => $topic,
@@ -14,18 +14,9 @@
$owner = $file->getOwnerEntity();
$categories = elgg_view('output/categories', $vars);
-$excerpt = elgg_get_excerpt($file->description);
-$mime = $file->mimetype;
-$base_type = substr($mime, 0, strpos($mime,'/'));
-$owner_link = elgg_view('output/url', array(
- 'href' => "file/owner/$owner->username",
- 'text' => $owner->name,
- 'is_trusted' => true,
-));
-$author_text = elgg_echo('byline', array($owner_link));
-
-$date = elgg_view_friendly_time($file->time_created);
+$vars['owner_url'] = "file/owner/$owner->username";
+$by_line = elgg_view('page/elements/by_line', $vars);
$comments_count = $file->countComments();
//only display if there are commments
@@ -40,7 +31,7 @@
$comments_link = '';
}
-$subtitle = "$author_text $date $comments_link $categories";
+$subtitle = "$by_line $comments_link $categories";
$metadata = '';
if (!elgg_in_context('widgets') && !elgg_in_context('gallery')) {
@@ -54,6 +45,8 @@
}
if ($full && !elgg_in_context('gallery')) {
+ $mime = $file->mimetype;
+ $base_type = substr($mime, 0, strpos($mime,'/'));
$extra = '';
if (elgg_view_exists("file/specialcontent/$mime")) {
@@ -91,6 +84,7 @@
echo '</div>';
} else {
// brief view
+ $excerpt = elgg_get_excerpt($file->description);
$file_icon = elgg_view_entity_icon($file, 'small');
@@ -0,0 +1,37 @@
+<?php
+
+$entity = elgg_extract('entity', $vars);
+if (!($entity instanceof ElggEntity)) {
+ return;
+}
+
+$by_line = [];
+
+$owner = $entity->getOwnerEntity();
+if ($owner instanceof ElggEntity) {
+ $owner_url = elgg_extract('owner_url', $vars, $owner->getURL());
+
+ $owner_link = elgg_view('output/url', [
+ 'href' => $owner_url,
+ 'text' => $owner->name,
+ 'is_trusted' => true,
+ ]);
+
+ $by_line[] = elgg_echo('byline', array($owner_link));
+}
+
+$by_line[] = elgg_view_friendly_time($entity->time_created);
+
+$container_entity = $entity->getContainerEntity();
+if ($container_entity instanceof ElggGroup && ($container_entity->getGUID() !== elgg_get_page_owner_guid())) {
+ $group_link = elgg_view('output/url', [
+ 'href' => $container_entity->getURL(),
+ 'text' => $container_entity->name,
+ 'is_trusted' => true,
+ ]);
+ $by_line[] = elgg_echo("byline:ingroup", [$group_link]);
+}
+
+if (!empty($by_line)) {
+ echo implode(' ', $by_line);
+}

0 comments on commit 1a5bcb6

Please sign in to comment.