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

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