Commit ab7a0fb2 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge "Altering comment display on blogpost artefact (Bug #1037531)"

parents ef80238b e30c2b8b
......@@ -42,17 +42,28 @@ class PluginBlocktypeBlogpost extends PluginBlocktype {
$configdata = $instance->get('configdata');
$result = '';
if (!empty($configdata['artefactid'])) {
$artefactid = isset($configdata['artefactid']) ? $configdata['artefactid'] : null;
if ($artefactid) {
require_once(get_config('docroot') . 'artefact/lib.php');
$blogpost = $instance->get_artefact_instance($configdata['artefactid']);
$artefact = $instance->get_artefact_instance($artefactid);
$configdata['hidetitle'] = true;
$configdata['countcomments'] = true;
$configdata['viewid'] = $instance->get('view');
$result = $blogpost->render_self($configdata);
$result = $artefact->render_self($configdata);
$result = $result['html'];
require_once(get_config('docroot') . 'artefact/comment/lib.php');
require_once(get_config('docroot') . 'lib/view.php');
$view = new View($configdata['viewid']);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'));
}
return $result;
$smarty = smarty_core();
if ($artefactid) {
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
}
$smarty->assign('html', $result);
return $smarty->fetch('blocktype:blogpost:blogpost.tpl');
}
/**
......
{$html|safe}
{if $commentcount || $commentcount === 0}
{$comments|safe}
{/if}
\ No newline at end of file
......@@ -639,16 +639,6 @@ class ArtefactTypeBlogPost extends ArtefactType {
if (isset($options['viewid'])) {
safe_require('artefact', 'file');
$postcontent = ArtefactTypeFolder::append_view_url($postcontent, $options['viewid']);
if (isset($options['countcomments']) && $this->allowcomments) {
safe_require('artefact', 'comment');
require_once(get_config('docroot') . 'lib/view.php');
$view = new View($options['viewid']);
$commentoptions = ArtefactTypeComment::get_comment_options();
$commentoptions->view = $view;
$commentoptions->artefact = $this;
$comments = ArtefactTypeComment::get_comments($commentoptions);
$smarty->assign('commentcount', isset($comments->count) ? $comments->count : 0);
}
}
$smarty->assign('artefactdescription', $postcontent);
$smarty->assign('artefact', $this);
......
......@@ -37,5 +37,4 @@
{$license|safe}
</div>
{/if}
{if isset($commentcount) && $artefact->get('allowcomments')}<div class="postdetails"><a href="{$artefacturl}">{str tag=Comments section=artefact.comment} ({$commentcount})</a></div>{/if}
</div>
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