diff options
Diffstat (limited to 'mod/blog/views/default/object/blog.php')
| -rw-r--r-- | mod/blog/views/default/object/blog.php | 158 |
1 files changed, 67 insertions, 91 deletions
diff --git a/mod/blog/views/default/object/blog.php b/mod/blog/views/default/object/blog.php index fc88eea25..4403a6006 100644 --- a/mod/blog/views/default/object/blog.php +++ b/mod/blog/views/default/object/blog.php @@ -5,119 +5,95 @@ * @package Blog */ -$full = (isset($vars['full'])) ? $vars['full'] : FALSE; -$blog = (isset($vars['entity'])) ? $vars['entity'] : FALSE; +$full = elgg_extract('full_view', $vars, FALSE); +$blog = elgg_extract('entity', $vars, FALSE); if (!$blog) { - return ''; + 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); +$owner = $blog->getOwnerEntity(); +$container = $blog->getContainerEntity(); +$categories = elgg_view('output/categories', $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 = ""; +if (!$excerpt) { + $excerpt = elgg_get_excerpt($blog->description); } -$date = elgg_view_friendly_time($blog->publish_date); + +$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); // The "on" status changes for comments, so best to check for !Off if ($blog->comments_on != 'Off') { - $comments_count = elgg_count_comments($blog); + $comments_count = $blog->countComments(); //only display if there are commments - if($comments_count != 0){ - $comments_link = "<a href=\"{$blog->getURL()}#annotations\">" . elgg_echo("comments") . " (". $comments_count .")</a>"; - }else{ + if ($comments_count != 0) { + $text = elgg_echo("comments") . " ($comments_count)"; + $comments_link = elgg_view('output/url', array( + 'href' => $blog->getURL() . '#blog-comments', + 'text' => $text, + 'is_trusted' => true, + )); + } else { $comments_link = ''; } } else { $comments_link = ''; } -// links to delete or edit. - -// access is always shown. -$edit = elgg_view('output/access', array('entity' => $vars['entity'])); +$metadata = elgg_view_menu('entity', array( + 'entity' => $vars['entity'], + 'handler' => 'blog', + 'sort_by' => 'priority', + 'class' => 'elgg-menu-hz', +)); -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>'; +$subtitle = "$author_text $date $comments_link $categories"; - $delete_url = elgg_get_site_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"; +// do not show the metadata and controls in widget view +if (elgg_in_context('widgets')) { + $metadata = ''; } - // 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 clearfloat"> - <div id="content_header" class="clearfloat"> - <div class="content_header_title"><h2>{$blog->title}</h2></div> - </div> - <div class="clearfloat"> - <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; + $body = elgg_view('output/longtext', array( + 'value' => $blog->description, + 'class' => 'blog-post', + )); + + $params = array( + 'entity' => $blog, + 'title' => false, + 'metadata' => $metadata, + 'subtitle' => $subtitle, + ); + $params = $params + $vars; + $summary = elgg_view('object/elements/summary', $params); + + echo elgg_view('object/elements/full', array( + 'summary' => $summary, + 'icon' => $owner_icon, + 'body' => $body, + )); } else { - echo <<<___END -<div class="blog $status_class entity_listing clearfloat"> - <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; + // brief view + + $params = array( + 'entity' => $blog, + 'metadata' => $metadata, + 'subtitle' => $subtitle, + 'content' => $excerpt, + ); + $params = $params + $vars; + $list_body = elgg_view('object/elements/summary', $params); + + echo elgg_view_image_block($owner_icon, $list_body); } |
