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

Don't expand the comment lists on page edit screen (Bug #1317343)

This was causing some problems with tagged posts
- also hiding the 'add comment' link on page edit screen.

And making the comments info show when no comments were on item and
allow comments for artefact was enabled. This is an issue with newer
versions of php.

Also placing some of the template files in the new correct location

Change-Id: I599e16b0899559a3ebcdf68cff53220b1d83f2d6
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 66136667
......@@ -73,6 +73,7 @@ class PluginBlocktypeBlog extends PluginBlocktype {
);
}
$configdata['blockid'] = $instance->get('id');
$configdata['editing'] = $editing;
ArtefactTypeBlogpost::render_posts($posts, $template, $configdata, $pagination);
$smarty = smarty_core();
......
......@@ -54,7 +54,7 @@ class PluginBlocktypeBlogpost extends PluginBlocktype {
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'));
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
}
$smarty = smarty_core();
......
......@@ -509,11 +509,12 @@ class ArtefactTypeComment extends ArtefactType {
* @param object $view The view on which the artefact appears
* @param int $blockid The id of the block instance that connects the artefact to the view
* @param bool $html Whether to return the information rendered as html or not
* @param bool $editing Whether we are view edit mode or not
*
* @return array $commentcount, $comments The count of comments and either the comments
* or the html to render them.
*/
public function get_artefact_comments_for_view($artefact, $view, $blockid, $html = true) {
public function get_artefact_comments_for_view($artefact, $view, $blockid, $html = true, $editing = false) {
if (!is_object($artefact) || !is_object($view)) {
throw new MaharaException('we do not have the right information to display the comments');
}
......@@ -533,6 +534,7 @@ class ArtefactTypeComment extends ArtefactType {
$smarty->assign('blockid', $blockid);
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
$smarty->assign('editing', $editing);
$smarty->assign('allowcomments', $artefact->get('allowcomments'));
$render = $smarty->fetch('artefact/artefactcommentsview.tpl');
return array($commentcount, $render);
......
......@@ -56,7 +56,7 @@ class PluginBlocktypeFolder extends PluginBlocktype {
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'));
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
}
$smarty = smarty_core();
if ($artefactid) {
......
......@@ -408,8 +408,7 @@ class PluginBlocktypeGallery extends PluginBlocktype {
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'));
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
}
......
......@@ -43,7 +43,7 @@ class PluginBlocktypeHtml extends PluginBlocktype {
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'));
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
}
$smarty = smarty_core();
......
......@@ -54,7 +54,7 @@ class PluginBlocktypeImage extends PluginBlocktype {
require_once(get_config('docroot') . 'artefact/comment/lib.php');
require_once(get_config('docroot') . 'lib/view.php');
$view = new View($viewid);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'));
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
$smarty = smarty_core();
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
......
......@@ -63,7 +63,7 @@ class PluginBlocktypeInternalmedia extends PluginBlocktype {
require_once(get_config('docroot') . 'artefact/comment/lib.php');
require_once(get_config('docroot') . 'lib/view.php');
$view = new View($viewid);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'));
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
}
$smarty = smarty_core();
if ($artefactid) {
......
......@@ -59,7 +59,9 @@ class PluginBlocktypePdf extends PluginBlocktype {
. '" width="100%" height="500" frameborder="0"></iframe>';
require_once(get_config('docroot') . 'artefact/comment/lib.php');
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'));
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'), true, $editing);
}
$smarty = smarty_core();
if ($artefactid) {
......
......@@ -61,7 +61,7 @@ class PluginBlocktypeTextbox extends PluginBlocktype {
}
require_once(get_config('docroot') . 'lib/view.php');
$view = new View($viewid);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'));
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
return $smarty->fetch('blocktype:textbox:content.tpl');
......
{$html|safe}
{if $commentcount || $commentcount === 0}
{if $commentcount || $commentcount === '0'}
{$comments|safe}
{/if}
\ No newline at end of file
......@@ -23,13 +23,15 @@
{if $post->commentcount != null}
<div class="comments">
{if $post->commentcount > 0}
<a id="block_0{$post->id}{$blockid}" class="commentlink" href="{$WWWROOT}artefact/artefact.php?artefact={$post->id}&view={$view}">{str tag=Comments section=artefact.comment} ({$post->commentcount})</a>
{if !$editing}<a id="block_0{$post->id}{$blockid}" class="commentlink" href="{$WWWROOT}artefact/artefact.php?artefact={$post->id}&view={$view}">{/if}
{str tag=Comments section=artefact.comment} ({$post->commentcount})
{if !$editing}</a>{/if}
{else}
{if $post->allowcomments}
<span class="nocomments">{str tag=Comments section=artefact.comment} ({$post->commentcount})</span>
{/if}
{/if}
{if $post->allowcomments}
{if $post->allowcomments && !$editing}
<a class="addcomment bar-before" href="{$WWWROOT}artefact/artefact.php?artefact={$post->id}&view={$view}">{str tag=addcomment section=artefact.comment}</a>
{/if}
</div>
......
......@@ -35,10 +35,12 @@
</tbody>
</table>
{/if}
{if $options.viewid && ($post->commentcount || $post->commentcount === 0)}
{if $options.viewid && ($post->commentcount || $post->commentcount === '0')}
<div class="comments">
{if $post->commentcount > 0}
<a id="block_0{$post->id}{$options.blockid}" class="commentlink" href="{$WWWROOT}artefact/artefact.php?artefact={$post->id}&view={$options.viewid}">{str tag=Comments section=artefact.comment} ({$post->commentcount})</a>
{if !$options.editing}<a id="block_0{$post->id}{$options.blockid}" class="commentlink" href="{$WWWROOT}artefact/artefact.php?artefact={$post->id}&view={$options.viewid}">{/if}
{str tag=Comments section=artefact.comment} ({$post->commentcount})
{if !$options.editing}</a>{/if}
{else}
{if $post->allowcomments}
<span class="nocomments">{str tag=Comments section=artefact.comment} ({$post->commentcount})</span>
......
{$html|safe}
{if $commentcount || $commentcount === 0}
{if $commentcount || $commentcount === '0'}
{$comments|safe}
{/if}
......@@ -33,6 +33,6 @@ $j(function() {
{else}
{str tag=noimagesfound section=artefact.file}
{/if}
{if $commentcount || $commentcount === 0}
{if $commentcount || $commentcount === '0'}
{$comments|safe}
{/if}
......@@ -27,6 +27,6 @@ $j(function() {
});
</script>
{if isset($copyright)}<div class="cb" id="lbBottom">{$copyright|safe}</div>{/if}
{if $commentcount || $commentcount === 0}
{if $commentcount || $commentcount === '0'}
{$comments|safe}
{/if}
......@@ -27,6 +27,6 @@ $j(function() {
});
</script>
{if isset($copyright)}<div class="cb" id="lbBottom">{$copyright|safe}</div>{/if}
{if $commentcount || $commentcount === 0}
{if $commentcount || $commentcount === '0'}
{$comments|safe}
{/if}
{$html|safe}
{if $commentcount || $commentcount === 0}
{if $commentcount || $commentcount === '0'}
{$comments|safe}
{/if}
<div class="center imageblock" itemscope itemtype="http://schema.org/ImageObject">
<div class="image"><a href="{$url}"><img src="{$src}" alt="{$description}" itemprop="contentURL"></a></div>
{if $showdescription}<div class="detail" itemprop="description">{$description}</div>{/if}
{if $commentcount || $commentcount === 0}
{if $commentcount || $commentcount === '0'}
{$comments|safe}
{/if}
</div>
{$html|safe}
{if $commentcount || $commentcount === 0}
{if $commentcount || $commentcount === '0'}
{$comments|safe}
{/if}
{$html|safe}
{if $commentcount || $commentcount === 0}
{if $commentcount || $commentcount === '0'}
{$comments|safe}
{/if}
......@@ -23,7 +23,7 @@
</table>
{if $artefact->get('tags')}<div class="tags">{str tag=tags}: {list_tags owner=$artefact->get('owner') tags=$artefact->get('tags')}</div>{/if}
{/if}
{if $commentcount || $commentcount === 0}
{if $commentcount || $commentcount === '0'}
{$comments|safe}
{/if}
<div class="comments">
{if $commentcount > 0}
<a class="commentlink" id="block_{$blockid}" href="{$artefacturl}">{str tag=Comments section=artefact.comment} ({$commentcount})</a>
{if !$editing}<a class="commentlink" id="block_{$blockid}" href="{$artefacturl}">{/if}
{str tag=Comments section=artefact.comment} ({$commentcount})
{if !$editing}</a>{/if}
{else}
{if $allowcomments}
<span id='block_{$blockid}' class="nocomments">{str tag=Comments section=artefact.comment} ({$commentcount})</span>
{/if}
{/if}
{if $allowcomments}
{if !$editing}
<a class="addcomment bar-before" href="{$artefacturl}">{str tag=addcomment section=artefact.comment}</a>
{/if}
{/if}
</div>
<div class="feedbacktablewrapper">
......
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