From 4f8eed9fcd38db8d274ce6bdcf8d9939e749e743 Mon Sep 17 00:00:00 2001 From: Robert Lyon Date: Fri, 6 Sep 2019 09:46:55 +1200 Subject: [PATCH] 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 --- .../file/blocktype/filedownload/lib.php | 34 +++++++++++++++---- .../templates/filedownload_pdfexport.tpl | 33 ++++++++++++++++++ 2 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 htdocs/theme/raw/plugintype/artefact/file/blocktype/filedownload/templates/filedownload_pdfexport.tpl diff --git a/htdocs/artefact/file/blocktype/filedownload/lib.php b/htdocs/artefact/file/blocktype/filedownload/lib.php index 3dff93eea9..8c01c52798 100644 --- a/htdocs/artefact/file/blocktype/filedownload/lib.php +++ b/htdocs/artefact/file/blocktype/filedownload/lib.php @@ -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() { diff --git a/htdocs/theme/raw/plugintype/artefact/file/blocktype/filedownload/templates/filedownload_pdfexport.tpl b/htdocs/theme/raw/plugintype/artefact/file/blocktype/filedownload/templates/filedownload_pdfexport.tpl new file mode 100644 index 0000000000..3a7fba9042 --- /dev/null +++ b/htdocs/theme/raw/plugintype/artefact/file/blocktype/filedownload/templates/filedownload_pdfexport.tpl @@ -0,0 +1,33 @@ + + -- GitLab