Commit 0b68ff43 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 659664be
......@@ -89,7 +89,9 @@ class PluginBlocktypeTaggedposts extends SystemBlocktype {
'view' => $view,
'block' => $instance->get('id'),
);
require_once(get_config('docroot') . 'lib/view.php');
require_once(get_config('docroot') . 'artefact/lib.php');
safe_require('artefact', 'blog');
foreach ($results as $result) {
$dataobject["artefact"] = $result->parent;
ensure_record_exists('view_artefact', $dataobject, $dataobject);
......@@ -104,6 +106,14 @@ class PluginBlocktypeTaggedposts extends SystemBlocktype {
foreach ($taglist as $t) {
$result->taglist[] = $t->tag;
}
if ($full) {
$artefact = new ArtefactTypeBlogpost($result->id);
$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
......
......@@ -21,11 +21,10 @@
<div id="postlist_{$blockid}" class="postlist fullwidth">
{foreach from=$results item=post}
<div class="post">
<h3 class="title"><a href="{$WWWROOT}view/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>
{if $post->allowcomments}<div class="postdetails"><a href="{$WWWROOT}view/artefact.php?artefact={$post->id}&view={$view}">{str tag=Comments section=artefact.comment} ({$post->commentcount})</a></div>{/if}
{$post->html|safe}
{if $post->allowcomments}<div class="postdetails"><a href="{$WWWROOT}artefact/artefact.php?a
rtefact={$post->id}&view={$view}">{str tag=Comments section=artefact.comment} ({$post->commentcount}
)</a></div>{/if}
</div>
{/foreach}
</div>
......
......@@ -660,7 +660,8 @@ class ArtefactTypeBlogPost extends ArtefactType {
}
}
$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));
}
......
......@@ -7,7 +7,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