Commit 9b29d17e authored by Robert Lyon's avatar Robert Lyon Committed by Cecilia Vela Gurovic

Bug 1698699: Rewrite path to PDF in HTML export

This patch rewrites the path to the html export version of the PDF file

behatnotneeded

Change-Id: I8d534af41258d219046e5f3586bf904777242cb9
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
(cherry picked from commit d094f841)
parent 883bb2cb
......@@ -732,6 +732,13 @@ class HtmlExportOutputFilter {
$html
);
// Links to pdf block files
$html = preg_replace_callback(
'#(?<=[\'"])(' . $wwwroot . ')?/?artefact/file/blocktype/pdf/viewer\.php\?.*?file=(\d+)(?:&amp;|&|%26).*?(?=[\'"])#',
array($this, 'replace_pdf_link'),
$html
);
// Thumbnails
require_once('file.php');
$html = preg_replace_callback(
......@@ -828,6 +835,28 @@ class HtmlExportOutputFilter {
return $this->get_export_path_for_file($artefact, $options);
}
/**
* Callback to replace links to artefact/file/blocktype/pdf/viewer.php to point to the
* correct file in the HTML export
*/
private function replace_pdf_link($matches) {
$artefactid = $matches[2];
try {
$artefact = artefact_instance_from_id($artefactid);
}
catch (ArtefactNotFoundException $e) {
return '';
}
// If artefact type not something that would be served by download.php,
// replace link with nothing
if ($artefact->get_plugin_name() != 'file') {
return '';
}
return $this->get_export_path_for_file($artefact, array());
}
/**
* Callback to replace links to thumb.php to point to the correct file in
* the HTML export
......
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