Commit bee22be8 authored by Stacey Walker's avatar Stacey Walker
Browse files

add view id to links in the blogposts in views. fixes bug #2484

parent 0c9903fe
...@@ -425,7 +425,8 @@ class ArtefactTypeBlogPost extends ArtefactType { ...@@ -425,7 +425,8 @@ class ArtefactTypeBlogPost extends ArtefactType {
// We need to make sure that the images in the post have the right viewid associated with them // We need to make sure that the images in the post have the right viewid associated with them
$postcontent = $this->get('description'); $postcontent = $this->get('description');
if (isset($options['viewid'])) { if (isset($options['viewid'])) {
$postcontent = preg_replace('#(<img[^>]+src="[^>]+artefact/file/download\.php\?file=\d+)#', '\1&amp;view=' . $options['viewid'], $postcontent); safe_require('artefact', 'file');
$postcontent = ArtefactTypeFolder::append_view_url($postcontent, $options['viewid']);
} }
$smarty->assign('artefactdescription', $postcontent); $smarty->assign('artefactdescription', $postcontent);
$smarty->assign('artefact', $this); $smarty->assign('artefact', $this);
......
...@@ -881,6 +881,15 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase { ...@@ -881,6 +881,15 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
return $record->id; return $record->id;
} }
// append the view id to to the end of image and anchor urls so they are visible to logged out users also
public static function append_view_url($postcontent, $view_id) {
$postcontent = preg_replace('#(<a[^>]+href="[^>]+artefact/file/download\.php\?file=\d+)#', '\1&amp;view=' . $view_id , $postcontent);
$postcontent = preg_replace('#(<img[^>]+src="[^>]+artefact/file/download\.php\?file=\d+)#', '\1&amp;view=' . $view_id, $postcontent);
$postcontent = preg_replace('#(<img[^>]+src="([^>]+artefact/file/download\.php\?file=\d+&amp;view=\d+)"[^>]*>)#', '<a href="\2">\1</a>', $postcontent);
return $postcontent;
}
public static function get_links($id) { public static function get_links($id) {
$wwwroot = get_config('wwwroot'); $wwwroot = get_config('wwwroot');
......
...@@ -43,6 +43,8 @@ class PluginBlocktypeTextbox extends SystemBlocktype { ...@@ -43,6 +43,8 @@ class PluginBlocktypeTextbox extends SystemBlocktype {
public static function render_instance(BlockInstance $instance) { public static function render_instance(BlockInstance $instance) {
$configdata = $instance->get('configdata'); $configdata = $instance->get('configdata');
$text = (isset($configdata['text'])) ? $configdata['text'] : ''; $text = (isset($configdata['text'])) ? $configdata['text'] : '';
safe_require('artefact', 'file');
$text = ArtefactTypeFolder::append_view_url($text,$instance->get('view'));
return $text; return $text;
} }
......
Supports Markdown
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