Commit 4b7768ff authored by Son Nguyen's avatar Son Nguyen
Browse files

Refactor the tagged blogpost blocktype. Bug 1392700



- Use render_self() in full detail option
- Remove calls of $artefact->get() in template file

Change-Id: I6be321adfda07c7f3e7cb3ac4026894b081e131f
Signed-off-by: default avatarSon Nguyen <son.nguyen@catalyst.net.nz>
parent 5b6094f6
......@@ -91,22 +91,22 @@ class PluginBlocktypeTaggedposts extends SystemBlocktype {
);
require_once(get_config('docroot') . 'lib/view.php');
$viewobj = new View($view);
require_once(get_config('docroot') . 'artefact/lib.php');
safe_require('artefact', 'blog');
safe_require('artefact', 'comment');
foreach ($results as $result) {
$dataobject["artefact"] = $result->parent;
ensure_record_exists('view_artefact', $dataobject, $dataobject);
$result->postedbyon = get_string('postedbyon', 'artefact.blog', display_default_name($result->owner), format_date(strtotime($result->ctime)));
$result->displaydate= format_date(strtotime($result->ctime));
// get comments for this post
require_once(get_config('docroot') . 'artefact/blog/lib.php');
$artefact = new ArtefactTypeBlogpost($result->id);
// get comments for this post
$result->commentcount = count_records_select('artefact_comment_comment', "onartefact = {$result->id} AND private = 0 AND deletedby IS NULL");
$allowcomments = $artefact->get('allowcomments');
if (empty($result->commentcount) && empty($allowcomments)) {
$result->commentcount = null;
}
require_once(get_config('docroot') . 'artefact/comment/lib.php');
require_once(get_config('docroot') . 'artefact/blog/lib.php');
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $viewobj, null, false);
$result->comments = $comments;
......@@ -116,6 +116,13 @@ class PluginBlocktypeTaggedposts extends SystemBlocktype {
foreach ($taglist as $t) {
$result->taglist[] = $t->tag;
}
if ($full) {
$rendered = $artefact->render_self(array('viewid' => $view, 'details' => true));
$result->html = $rendered['html'];
if (!empty($rendered['javascript'])) {
$result->html .= '<script type="text/javascript">' . $rendered['javascript'] . '</script>';
}
}
}
// check if the user viewing the page is the owner of the selected tag
......
......@@ -650,7 +650,8 @@ class ArtefactTypeBlogPost extends ArtefactType {
$postcontent = ArtefactTypeFolder::append_view_url($postcontent, $options['viewid']);
}
$smarty->assign('artefactdescription', $postcontent);
$smarty->assign('artefact', $this);
$smarty->assign('artefacttags', $this->get('tags'));
$smarty->assign('artefactowner', $this->get('owner'));
if (!empty($options['details']) and get_config('licensemetadata')) {
$smarty->assign('license', render_license($this));
}
......
......@@ -21,10 +21,7 @@
<div id="postlist_{$blockid}" class="postlist fullwidth">
{foreach from=$results item=post}
<div class="post">
<h3 class="title"><a href="{$WWWROOT}artefact/artefact.php?artefact={$post->id}&view={$view}">{$post->title}</a></h3>
<div class="postdetails">{$post->postedbyon}</div>
<div class="detail">{$post->description|clean_html|safe}</div>
<div class="tags">{str tag=tags}: {list_tags owner=$post->owner tags=$post->taglist}</div>
{$post->html|safe}
{if $post->commentcount != null}
<div class="comments">
{if $post->commentcount > 0}
......
......@@ -6,7 +6,7 @@
<div class="postdetails">{$postedbyon}</div>
{$artefactdescription|clean_html|safe}
{if isset($attachments)}
{if $artefact->get('tags')}<div class="tags">{str tag=tags}: {list_tags owner=$artefact->get('owner') tags=$artefact->get('tags')}</div>{/if}
{if $artefacttags}<div class="tags">{str tag=tags}: {list_tags owner=$artefactowner tags=$artefacttags}</div>{/if}
<table class="cb attachments fullwidth">
<thead class="expandable-head">
<tr>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment