Commit 68ebdd9d authored by Robert Lyon's avatar Robert Lyon

Bug 1826284: My views block renders export different for pdf

It now references the file pdfs that are exported as part of full pdf
export. This should work as we can't export a profile page on it's own

behatnotneeded

Change-Id: I7a9e21961791052ef66466fe61976dcb037787d7
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 1a7efc06
......@@ -386,6 +386,7 @@ $string['filetypenotallowed'] = 'Files with extension "%s" are not allowed.';
$string['filetypenotmatchingmimetype'] = 'File extension does not match file mimetype "%s".';
$string['validfiletypes'] = 'You can upload the following file types:';
$string['notrendertopdf'] = 'This block can not be rendered normally in the PDF export.';
$string['notrendertopdfview'] = 'The portfolio %s has been added as:';
$string['notrendertopdffiles'] = array(
'The file has been added to: ',
'The files have been added to: ',
......
......@@ -37,6 +37,30 @@ class PluginBlocktypeMyviews extends MaharaCoreBlocktype {
return array('profile', 'dashboard');
}
public static function render_instance_export(BlockInstance $instance, $editing=false, $versioning=false, $exporting=null) {
if ($exporting != 'pdf') {
return self::render_instance($instance, $editing, $versioning);
}
$userid = $instance->get_view()->get('owner');
if (!$userid) {
return '';
}
// Get viewable views
$views = View::view_search(null, null, (object) array('owner' => $userid), null,
0, 0, true, null, array('portfolio'), null, null, null, null, null, true);
$views = (array)$views;
foreach ($views['data'] as $k => $view) {
$views['data'][$k]['fileurl'] = './' . $view['id'] . '_' . $view['urlid'] . '.pdf';
}
$smarty = smarty_core();
$smarty->assign('options', array());
$smarty->assign('items', $views['data']);
$views['tablerows'] = $smarty->fetch('blocktype:myviews:myviews_pdfexport.tpl');
return $views['tablerows'];
}
/**
* This function renders a list of items views as html
*
......
<div class="text-midtone">{str tag='notrendertopdf' section='artefact.file'}</div>
{foreach from=$items item=view}
<div class="list-group-item">
<h4 class="title list-group-item-heading text-inline">
{str tag='notrendertopdfview' section='artefact.file' arg1=$view.title} <a href="{$view.fileurl}">{$view.title}</a>
</h4>
{if $view.collid}
<span class="text-small text-midtone">
({str tag=nviews section=view arg1=$view.numpages})
</span>
{/if}
{if $view.description}
<div class="list-group-item-text text-small">
{$view.description|str_shorten_html:100:true|strip_tags|safe}
</div>
{/if}
{if $item.tags}
<div class="tags">
<strong>{str tag=tags}:</strong> {list_tags owner=$view.owner tags=$view.tags}
</div>
{/if}
</div>
{/foreach}
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