Commit d5c331d5 authored by Robert Lyon's avatar Robert Lyon

Bug 1826284: Folder block renders different for PDF export

It uses it's own template file that has less stuff in it

behatnotneeded

Change-Id: I2c8a3a4b594eb82d2e3fd99916cce5ee84ca2d10
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 4f8eed9f
......@@ -38,6 +38,28 @@ class PluginBlocktypeFolder extends MaharaCoreBlocktype {
return array('fileimagevideo' => 4000);
}
public static function render_instance_export(BlockInstance $instance, $editing=false, $versioning=false, $exporting=null) {
if ($exporting != 'pdf') {
return self::render_instance($instance, $editing, $versioning);
}
// The exporting for pdf
require_once(get_config('docroot') . 'artefact/lib.php');
$configdata = $instance->get('configdata');
$configdata['viewid'] = $instance->get('view');
$configdata['simpledisplay'] = true;
$configdata['pdfexport'] = true; // pass down flag that we are in pdf export
list($result, $commentcount, $comments) = self::render_instance_data($instance, $editing, $versioning, $configdata);
$smarty = smarty_core();
if (isset($configdata['artefactid'])) {
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
}
$smarty = smarty_core();
$smarty->assign('html', $result);
return $smarty->fetch('blocktype:folder:folder.tpl');
}
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
$configdata = $instance->get('configdata');
......@@ -45,10 +67,23 @@ class PluginBlocktypeFolder extends MaharaCoreBlocktype {
$configdata['simpledisplay'] = true;
$configdata['blockid'] = $instance->get('id');
$configdata['editing'] = $editing;
list($result, $commentcount, $comments) = self::render_instance_data($instance, $editing, $versioning, $configdata);
$smarty = smarty_core();
if (isset($configdata['artefactid'])) {
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
}
$smarty->assign('html', $result);
return $smarty->fetch('blocktype:folder:folder.tpl');
}
private static function render_instance_data(BlockInstance $instance, $editing=false, $versioning=false, $configdata=array()) {
// This can be either an image or profileicon. They both implement
// render_self
$result = '';
$commentcount = 0;
$comments = null;
$artefactid = isset($configdata['artefactid']) ? $configdata['artefactid'] : null;
if ($artefactid) {
$artefact = $instance->get_artefact_instance($artefactid);
......@@ -60,9 +95,7 @@ class PluginBlocktypeFolder extends MaharaCoreBlocktype {
$view = new View($configdata['viewid']);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing, $versioning);
}
$smarty = smarty_core();
$smarty->assign('html', $result);
return $smarty->fetch('blocktype:folder:folder.tpl');
return array($result, $commentcount, $comments);
}
public static function has_config() {
......
......@@ -2213,8 +2213,8 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
if (isset($options['blockid'])) {
$smarty->assign('blockid', $options['blockid']);
}
$template = 'artefact:file:folder_render_self.tpl';
if (isset($options['modal'])) {
$template = !empty($options['pdfexport']) ? 'artefact:file:folder_render_self_pdfexport.tpl' : 'artefact:file:folder_render_self.tpl';
if (isset($options['modal']) && !isset($options['pdfexport'])) {
$smarty->assign('modal', $options['modal']);
$template = 'artefact:file:folder_render_in_modal.tpl';
}
......
{if $description}
<div class="content-text">
{$description}
</div>
{/if}
{if $tags}
<div class="tags">
<strong>{str tag=tags}</strong>:
{list_tags owner=$owner tags=$tags view=$viewid}
</div>
{/if}
<div id="commentfiles" class="folder-card">
{if (isset($children))}
<h4 class="sr-only">
{str tag=foldercontents section=artefact.file}:
</h4>
<div class="fullwidth">
<ul class="list-group">
{foreach from=$children item=child}
<li class="filedownload-item list-group-item">
{if $child->iconsrc}
<img src="{$child->iconsrc}" alt="{$child->artefacttype}" class="file-icon text-inline">
{else}
<span class="icon icon-{$child->artefacttype} icon-lg left" role="presentation" aria-hidden="true"></span>
{/if}
<h4 class="title list-group-item-heading text-inline">
<a href="{$WWWROOT}artefact/artefact.php?artefact={$child->id}&amp;view={$viewid}" class="inner-link" title="{$child->hovertitle}">
{$child->title}
</a>
<span class="filedate metadata">
{$child->date}
</span>
</h4>
{if $child->description}
<p class="file-description text-small text-midtone">
{$child->description|safe|clean_html}
</p>
{/if}
</li>
{/foreach}
</ul>
</div>
{else}
<span class="lead text-small">
{str tag=emptyfolder section=artefact.file}
</span>
{/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