Commit 4f8eed9f authored by Robert Lyon's avatar Robert Lyon

Bug 1826284: Files to download block renders different for PDF export

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

behatnotneeded

Change-Id: I2661864e7e5a747ce12721d498bc91a038005451
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent e8dc71d3
......@@ -25,7 +25,33 @@ class PluginBlocktypeFiledownload extends MaharaCoreBlocktype {
return array('fileimagevideo' => 3000);
}
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
$files = self::render_instance_data($instance, $editing, $versioning);
$smarty = smarty_core();
$smarty->assign('viewid', $instance->get('view'));
$smarty->assign('blockid', $instance->get('id'));
$smarty->assign('files', $files);
$smarty->assign('editing', $editing);
return $smarty->fetch('blocktype:filedownload:filedownload_pdfexport.tpl');
}
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
$files = self::render_instance_data($instance, $editing, $versioning);
$smarty = smarty_core();
$smarty->assign('viewid', $instance->get('view'));
$smarty->assign('blockid', $instance->get('id'));
$smarty->assign('files', $files);
$smarty->assign('editing', $editing);
return $smarty->fetch('blocktype:filedownload:filedownload.tpl');
}
private static function render_instance_data(BlockInstance $instance, $editing=false, $versioning=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
require_once(get_config('docroot') . 'artefact/comment/lib.php');
......@@ -73,13 +99,7 @@ class PluginBlocktypeFiledownload extends MaharaCoreBlocktype {
$files[] = $file;
}
}
$smarty = smarty_core();
$smarty->assign('viewid', $instance->get('view'));
$smarty->assign('blockid', $instance->get('id'));
$smarty->assign('files', $files);
$smarty->assign('editing', $editing);
return $smarty->fetch('blocktype:filedownload:filedownload.tpl');
return $files;
}
public static function has_instance_config() {
......
<ul class="list-group">
{foreach $files file}
<li class="filedownload-item list-group-item">
{if $file.iconsrc}
<img src="{$file.iconsrc}" alt="" class="file-icon text-inline" />
{else}
<span class="icon icon-{$file.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={$file.id}&view={$viewid}" class="inner-link">
{$file.title}
<span class="sr-only">
{str tag=Details section=artefact.file}
</span>
</a>
</h4>
<span class="text-small text-midtone"> -
{$file.ctime|format_date:'strftimedaydate'}
[{$file.size|display_size}]
</span>
{if $file.description}
<div class="file-description">
<p class="text-small">
{$file.description|safe|clean_html}
</p>
</div>
{/if}
</li>
{/foreach}
</ul>
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