Commit 78b2ddef authored by Richard Mansfield's avatar Richard Mansfield
Browse files

In html export, only rewrite view links for views that are included in the export file


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 2432f934
......@@ -50,7 +50,7 @@ class HtmlExportBlog extends HtmlExportArtefactPlugin {
array('text' => $artefact->get('title'), 'path' => 'index.html'),
));
$rendered = $artefact->render_self(array('hidetitle' => true));
$outputfilter = new HtmlExportOutputFilter('../../../');
$outputfilter = new HtmlExportOutputFilter('../../../', $this->exporter);
$smarty->assign('rendered_blog', $outputfilter->filter($rendered['html']));
$content = $smarty->fetch('export:html/blog:index.tpl');
......
......@@ -47,7 +47,7 @@ class HtmlExportInternal extends HtmlExportArtefactPlugin {
if ($profileviewid == $viewid) {
$smarty->assign('breadcrumbs', array(array('text' => 'Profile page', 'path' => 'profilepage.html')));
$view = $this->exporter->get('user')->get_profile_view();
$outputfilter = new HtmlExportOutputFilter('../../');
$outputfilter = new HtmlExportOutputFilter('../../', $this->exporter);
$smarty->assign('view', $outputfilter->filter($view->build_columns()));
$content = $smarty->fetch('export:html/internal:profilepage.tpl');
......@@ -80,7 +80,7 @@ class HtmlExportInternal extends HtmlExportArtefactPlugin {
$artefact = artefact_instance_from_id($id);
$rendered = $artefact->render_self(array('link' => true));
if ($artefact->get('artefacttype') == 'introduction') {
$outputfilter = new HtmlExportOutputFilter('../../');
$outputfilter = new HtmlExportOutputFilter('../../', $this->exporter);
$rendered['html'] = $outputfilter->filter($rendered['html']);
}
$sections[$this->get_category_for_artefacttype($artefact->get('artefacttype'))][$artefact->get('artefacttype')] = array(
......@@ -113,7 +113,7 @@ class HtmlExportInternal extends HtmlExportArtefactPlugin {
public function get_summary() {
$smarty = $this->exporter->get_smarty();
$outputfilter = new HtmlExportOutputFilter('.');
$outputfilter = new HtmlExportOutputFilter('.', $this->exporter);
$smarty->assign('introduction', $outputfilter->filter(get_profile_field($this->exporter->get('user')->get('id'), 'introduction')));
$smarty->assign('profileviewexported', $this->profileviewexported);
$iconid = $this->exporter->get('user')->get('profileicon');
......
......@@ -322,7 +322,7 @@ class PluginExportHtml extends PluginExport {
}
}
$outputfilter = new HtmlExportOutputFilter($rootpath);
$outputfilter = new HtmlExportOutputFilter($rootpath, $this);
$smarty->assign('view', $outputfilter->filter($view->build_columns()));
$content = $smarty->fetch('export:html:view.tpl');
if (!file_put_contents("$directory/index.html", $content)) {
......@@ -461,12 +461,17 @@ class HtmlExportOutputFilter {
*/
private $htmlexportcopyproxy = null;
/**
*/
private $exporter = null;
/**
* @param string $basepath The relative path to the root of the generated export
*/
public function __construct($basepath) {
public function __construct($basepath, &$exporter=null) {
$this->basepath = preg_replace('#/$#', '', $basepath);
$this->htmlexportcopyproxy = HtmlExportCopyProxy::singleton();
$this->exporter = $exporter;
}
/**
......@@ -542,6 +547,10 @@ class HtmlExportOutputFilter {
*/
private function replace_view_link($matches) {
$viewid = $matches[1];
// Don't rewrite links to views that are not going to be included in the export
if (!isset($this->exporter->views[$viewid])) {
return $matches[0];
}
if (!isset($this->viewtitles[$viewid])) {
$this->viewtitles[$viewid] = PluginExportHtml::text_to_path(get_field('view', 'title', 'id', $viewid));
}
......
......@@ -97,7 +97,7 @@ abstract class PluginExport extends Plugin {
/**
* List of views to export. Set up by constructor.
*/
protected $views = array();
public $views = array();
/**
* User object for the user being exported.
......
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