Commit 8aae5935 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1870256: Allow files have the title of the file path



and correct name of the file:
- pdf block
- folder block

Change-Id: I81492dc2f5c2161318d4c1a5cdddcf2b1f968748
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 7e86a0f6
......@@ -48,6 +48,7 @@ class PluginBlocktypeFolder extends MaharaCoreBlocktype {
$configdata['viewid'] = $instance->get('view');
$configdata['simpledisplay'] = true;
$configdata['pdfexport'] = true; // pass down flag that we are in pdf export
$configdata['pdfexportfiledir'] = 'export_info/files/';
list($result, $commentcount, $comments) = self::render_instance_data($instance, $editing, $versioning, $configdata);
$smarty = smarty_core();
......
......@@ -59,7 +59,7 @@ class PluginBlocktypePdf extends MaharaCoreBlocktype {
$html .= '<br>' . get_string('notrendertopdffiles', 'artefact.file', 1);
// We need to add an <a> link so that the HTML export() sub-task makes a copy of the artefct for the export 'files/' directory
// We then override the link in the PDF pdf_view_export_data() function.
$html .= '<a href="' . $url . '">' . $artefact->get('title') . '</a>';
$html .= '<a href="' . $url . '">export_info/files/' . $artefact->get('id') . '_' . $artefact->get('title') . '</a>';
$html .= '</div>';
}
return $html;
......
......@@ -2205,6 +2205,14 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
$child->title = $child->hovertitle = $c->get('title');
$child->date = format_date(strtotime($child->mtime), 'strftimedaydatetime');
$child->iconsrc = call_static_method(generate_artefact_class_name($child->artefacttype), 'get_icon', array('id' => $child->id, 'viewid' => isset($options['viewid']) ? $options['viewid'] : 0));
if (!empty($options['pdfexportfiledir'])) {
if ($child->artefacttype == 'folder') {
$child->title = $child->title . ' [' . $options['pdfexportfiledir'] . $this->get('title') . '/' . $child->title . ']';
}
else {
$child->title = $child->title . ' [' . $options['pdfexportfiledir'] . $child->id . '-' . $child->title . ']';
}
}
$count = ArtefactTypeComment::count_comments(null, array($child->id));
if ($count) {
$child->commentcount = $count[$child->id]->comments;
......
......@@ -1028,6 +1028,8 @@ class PluginExportAll extends PluginExport {
$this->notify_progress_callback(95, get_string('creatingzipfile', 'export'));
try {
if ($this->pdfactive && isset($pdf) && !empty($pdf['dirs'])) {
// wait for 2 seconds
usleep(2000000);
create_zip_archive($this->exportdir, $this->zipfile, array_merge($html['dirs'], $leap['dirs'], $pdf['dirs']));
}
else {
......
......@@ -229,7 +229,7 @@ class PluginExportPdf extends PluginExportHtml {
if (preg_match('/var blocks = (\[.*?\]);/', $filedata, $matches)) {
$content = json_decode($matches[1]);
foreach ($content as $c) {
$c->content = preg_replace('/\<a href=\"\.\/(.*?)\".*?\>(.*?)\<\/a\>/s', "$1", $c->content); // $1 = url, $2 = name
$c->content = preg_replace('/\<a href=\"\.\/(.*?)\".*?\>(.*?)\<\\/a\>/s', "$1", $c->content); // $1 = url, $2 = name
// Strip other links out
$c->content = preg_replace('/\<a.*? href=.*?\>(.*?)\<\\/a\>/s', "$1", $c->content); // $1 = name
}
......@@ -259,7 +259,7 @@ class PluginExportPdf extends PluginExportHtml {
}
$page->pdf(['printBackground' => true,
'preferCSSPageSize' => true])->saveToFile($pdfname);
'preferCSSPageSize' => true])->saveToFile($pdfname, 60000); // 60s timeout
if (!file_exists($filename) || !is_readable($filename)) {
throw new SystemException("Could not read view page for creating pdf for $viewid");
......
......@@ -10,7 +10,7 @@
<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}
{$file.title} [export_info/files/{$file.id}-{$file.title}]
<span class="sr-only">
{str tag=Details section=artefact.file}
</span>
......
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