Commit 3ba72d71 authored by Yuliya Bozhko's avatar Yuliya Bozhko Committed by Robert Lyon
Browse files

Some artefact refactoring (Bug #1298646)



Fixes in this patch:

- Moved artefact.php to artefacts directory to separate it from pages.
- Fixed reference to a wrong 'artefactonlyviewableinview' string.
- Removed add_to_render_path() and its calls which have no purpose at all.
- Removed 'artefact_parent_cache' table.
- Removed cron jobs related to 'artefact_parent_cache' from DB.
- Added 'path' column in 'artefact' table to easier calculate hierarchy.
- Added ArtefactTest.php for artefacts unit tests

Change-Id: Ia14cd85b94c32a950354446ee3565bd2964c625c
Signed-off-by: default avatarYuliya Bozhko <yuliya.bozhko@totaralms.com>
parent b19a318b
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
define('INTERNAL', 1); define('INTERNAL', 1);
define('PUBLIC', 1); define('PUBLIC', 1);
define('SECTION_PLUGINTYPE', 'core'); define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'view'); define('SECTION_PLUGINNAME', 'core');
define('SECTION_PAGE', 'artefact'); define('SECTION_PAGE', 'artefact');
require(dirname(dirname(__FILE__)) . '/init.php'); require(dirname(dirname(__FILE__)) . '/init.php');
...@@ -22,8 +22,7 @@ safe_require('artefact', 'comment'); ...@@ -22,8 +22,7 @@ safe_require('artefact', 'comment');
$artefactid = param_integer('artefact'); $artefactid = param_integer('artefact');
$viewid = param_integer('view'); $viewid = param_integer('view');
$blockid = param_integer('block',null); $blockid = param_integer('block', null);
$path = param_variable('path', null);
$view = new View($viewid); $view = new View($viewid);
if (!can_view_view($view)) { if (!can_view_view($view)) {
...@@ -32,31 +31,35 @@ if (!can_view_view($view)) { ...@@ -32,31 +31,35 @@ if (!can_view_view($view)) {
require_once(get_config('docroot') . 'artefact/lib.php'); require_once(get_config('docroot') . 'artefact/lib.php');
$artefact = artefact_instance_from_id($artefactid); $artefact = artefact_instance_from_id($artefactid);
// Build the path to the artefact, through its parents
if (!$artefact->in_view_list()) {
throw new AccessDeniedException(get_string('artefactonlyviewableinview', 'error'));
}
// Build the path to the artefact through its parents.
$artefactpath = array(); $artefactpath = array();
$parent = $artefact->get('parent'); $ancestors = $artefact->get_item_ancestors();
$artefactok = false; $artefactok = false;
if (artefact_in_view($artefact->get('id'), $viewid)) {
if (artefact_in_view($artefact, $viewid)) {
$artefactok = true; $artefactok = true;
$baseobject = $artefact; $baseobject = $artefact;
} }
while ($parent !== null) {
// This loop could get expensive when there are a lot of parents. But at least
// it works, unlike the old attempt
$parentobj = artefact_instance_from_id($parent);
if (artefact_in_view($parent, $viewid)) {
array_unshift($artefactpath, array(
'url' => get_config('wwwroot') . 'view/artefact.php?artefact=' . $parent . '&view=' . $viewid,
'title' => $parentobj->display_title(),
));
}
$parent = $parentobj->get('parent'); if (!empty($ancestors)) {
if (artefact_in_view($parentobj->get('id'), $viewid)) { foreach ($ancestors as $ancestor) {
$artefactok = true; $pathitem = artefact_instance_from_id($ancestor);
$baseobject = $parentobj; if (artefact_in_view($pathitem, $viewid)) {
$artefactpath[] = array(
'url' => get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $pathitem->get('id') . '&view=' . $viewid,
'title' => $pathitem->display_title(),
);
$artefactok = true;
$baseobject = $pathitem;
}
} }
} }
if ($artefactok == false) { if ($artefactok == false) {
throw new AccessDeniedException(get_string('artefactnotinview', 'error', $artefactid, $viewid)); throw new AccessDeniedException(get_string('artefactnotinview', 'error', $artefactid, $viewid));
} }
...@@ -66,7 +69,6 @@ $limit = param_integer('limit', 10); ...@@ -66,7 +69,6 @@ $limit = param_integer('limit', 10);
$offset = param_integer('offset', 0); $offset = param_integer('offset', 0);
$showcomment = param_integer('showcomment', null); $showcomment = param_integer('showcomment', null);
if ($artefact && $viewid && $blockid) { if ($artefact && $viewid && $blockid) {
// use the block instance title rather than the artefact title if it exists // use the block instance title rather than the artefact title if it exists
$title = artefact_title_for_view_and_block($artefact, $viewid, $blockid); $title = artefact_title_for_view_and_block($artefact, $viewid, $blockid);
...@@ -74,9 +76,6 @@ if ($artefact && $viewid && $blockid) { ...@@ -74,9 +76,6 @@ if ($artefact && $viewid && $blockid) {
else { else {
$title = $artefact->display_title(); $title = $artefact->display_title();
} }
if (!$artefact->in_view_list()) {
throw new AccessDeniedException(get_string('artefactsonlyviewableinview', 'error'));
}
// Create the "make feedback private form" now if it's been submitted // Create the "make feedback private form" now if it's been submitted
if (param_variable('make_public_submit', null)) { if (param_variable('make_public_submit', null)) {
...@@ -91,19 +90,17 @@ define('TITLE', $title . ' ' . get_string('in', 'view') . ' ' . $view->get('titl ...@@ -91,19 +90,17 @@ define('TITLE', $title . ' ' . get_string('in', 'view') . ' ' . $view->get('titl
// Render the artefact // Render the artefact
$options = array( $options = array(
'viewid' => $viewid, 'viewid' => $viewid,
'path' => $path,
'details' => true, 'details' => true,
'metadata' => 1, 'metadata' => 1,
); );
if ($artefact->get('artefacttype') == 'folder') { if ($artefact->get('artefacttype') == 'folder') {
// get folder block sort order - returns the first instance of folder on view unless $blockid is set. // Get folder block sort order - returns the first instance of folder on view unless $blockid is set.
// Why you'd want more than one folder block on the same view is m̶a̶d̶n̶e̶s̶s̶ user preference. // TODO: get the clicking on a subfolder to carry the block id as well - that way we can get exact configdata.
// TO DO: get the clicking on a subfolder to carry the block id as well - that way we can get exact configdata
if ($block = get_records_sql_array('SELECT block FROM {view_artefact} WHERE view = ? AND artefact = ?', array($viewid, $baseobject->get('id')))) { if ($block = get_records_sql_array('SELECT block FROM {view_artefact} WHERE view = ? AND artefact = ?', array($viewid, $baseobject->get('id')))) {
require_once(get_config('docroot') . 'blocktype/lib.php'); require_once(get_config('docroot') . 'blocktype/lib.php');
$key = 0; $key = 0;
// If we have a $blockid then we will use that one's configdata // If we have a $blockid, then we will use block's configdata.
if ($blockid) { if ($blockid) {
foreach ($block as $k => $b) { foreach ($block as $k => $b) {
if ($b->block == $blockid) { if ($b->block == $blockid) {
...@@ -129,11 +126,6 @@ if (!empty($rendered['javascript'])) { ...@@ -129,11 +126,6 @@ if (!empty($rendered['javascript'])) {
} }
$content .= $rendered['html']; $content .= $rendered['html'];
$artefactpath[] = array(
'url' => '',
'title' => $title,
);
// Feedback // Feedback
$feedback = ArtefactTypeComment::get_comments($limit, $offset, $showcomment, $view, $artefact); $feedback = ArtefactTypeComment::get_comments($limit, $offset, $showcomment, $view, $artefact);
...@@ -181,10 +173,10 @@ else { ...@@ -181,10 +173,10 @@ else {
$hasfeed = false; $hasfeed = false;
$feedlink = ''; $feedlink = '';
// add a link to the ATOM feed in the header if the view is public // add a link to the ATOM feed in the header if the view is public
if($artefact->get('artefacttype') == 'blog' && $view->is_public()) { if ($artefact->get('artefacttype') == 'blog' && $view->is_public()) {
$hasfeed = true; $hasfeed = true;
$feedlink = get_config('wwwroot') . 'artefact/blog/atom.php?artefact=' . $feedlink = get_config('wwwroot') . 'artefact/blog/atom.php?artefact=' .
$artefactid . '&view=' . $viewid; $artefactid . '&view=' . $viewid;
$headers[] = '<link rel="alternate" type="application/atom+xml" href="' . $feedlink . '">'; $headers[] = '<link rel="alternate" type="application/atom+xml" href="' . $feedlink . '">';
} }
...@@ -195,7 +187,7 @@ $smarty = smarty( ...@@ -195,7 +187,7 @@ $smarty = smarty(
array( array(
'stylesheets' => $extrastylesheets, 'stylesheets' => $extrastylesheets,
'sidebars' => false, 'sidebars' => false,
'skin' => $skin, 'skin' => $skin,
) )
); );
...@@ -234,4 +226,4 @@ $smarty->assign('objectionform', $objectionform); ...@@ -234,4 +226,4 @@ $smarty->assign('objectionform', $objectionform);
$smarty->assign('notrudeform', $notrudeform); $smarty->assign('notrudeform', $notrudeform);
$smarty->assign('viewbeingwatched', $viewbeingwatched); $smarty->assign('viewbeingwatched', $viewbeingwatched);
$smarty->display('view/artefact.tpl'); $smarty->display('artefact/artefact.tpl');
...@@ -98,7 +98,7 @@ else { ...@@ -98,7 +98,7 @@ else {
'name' => implode(' ', array($owner[0]->firstname, $owner[0]->lastname)), 'name' => implode(' ', array($owner[0]->firstname, $owner[0]->lastname)),
'uri' => sanitize_url($personal_site), 'uri' => sanitize_url($personal_site),
); );
$link = get_config('wwwroot') . 'view/artefact.php?artefact=' . $link = get_config('wwwroot') . 'artefact/artefact.php?artefact=' .
$artefactid . '&view=' . $viewid; $artefactid . '&view=' . $viewid;
$selflink = get_config('wwwroot') . 'artefact/blog/atom.php?artefact=' . $selflink = get_config('wwwroot') . 'artefact/blog/atom.php?artefact=' .
$artefactid . '&view=' . $viewid; $artefactid . '&view=' . $viewid;
...@@ -176,7 +176,7 @@ else { ...@@ -176,7 +176,7 @@ else {
} }
$posts[] = array( $posts[] = array(
'title' => $post->get('title'), 'title' => $post->get('title'),
'link' => get_config('wwwroot') . 'view/artefact.php?artefact=' . 'link' => get_config('wwwroot') . 'artefact/artefact.php?artefact=' .
$post->get('id') . '&view=' . $viewid, $post->get('id') . '&view=' . $viewid,
'id' => implode(',', array(get_config('wwwroot'), $post->get('id'), $viewid)), 'id' => implode(',', array(get_config('wwwroot'), $post->get('id'), $viewid)),
'description' => $post->get('description'), 'description' => $post->get('description'),
......
...@@ -76,7 +76,7 @@ class PluginBlocktypeBlog extends PluginBlocktype { ...@@ -76,7 +76,7 @@ class PluginBlocktypeBlog extends PluginBlocktype {
$smarty = smarty_core(); $smarty = smarty_core();
if (isset($configdata['viewid'])) { if (isset($configdata['viewid'])) {
$artefacturl = get_config('wwwroot') . 'view/artefact.php?artefact=' . $blog->get('id') . '&view=' $artefacturl = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $blog->get('id') . '&view='
. $configdata['viewid']; . $configdata['viewid'];
$smarty->assign('artefacttitle', '<a href="' . $artefacturl . '">' . hsc($blog->get('title')) . '</a>'); $smarty->assign('artefacttitle', '<a href="' . $artefacturl . '">' . hsc($blog->get('title')) . '</a>');
if ($exporter && $posts['count'] > $limit) { if ($exporter && $posts['count'] > $limit) {
......
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
<ul class="recentblogpost"> <ul class="recentblogpost">
{foreach from=$mostrecent item=post} {foreach from=$mostrecent item=post}
<li> <li>
<strong><a href="{$WWWROOT}view/artefact.php?artefact={$post->id}&amp;view={$view}">{$post->title}</a></strong> <strong><a href="{$WWWROOT}artefact/artefact.php?artefact={$post->id}&amp;view={$view}">{$post->title}</a></strong>
{str tag='postedin' section='blocktype.blog/recentposts'} {str tag='postedin' section='blocktype.blog/recentposts'}
<a href="{$WWWROOT}view/artefact.php?artefact={$post->parent}&amp;view={$view}">{$post->parenttitle}</a> <a href="{$WWWROOT}artefact/artefact.php?artefact={$post->parent}&amp;view={$view}">{$post->parenttitle}</a>
{str tag='postedon' section='blocktype.blog/recentposts'} {str tag='postedon' section='blocktype.blog/recentposts'}
<span>{$post->displaydate}</span> <span>{$post->displaydate}</span>
</li> </li>
......
...@@ -21,11 +21,11 @@ ...@@ -21,11 +21,11 @@
<div id="postlist_{$blockid}" class="postlist fullwidth"> <div id="postlist_{$blockid}" class="postlist fullwidth">
{foreach from=$results item=post} {foreach from=$results item=post}
<div class="post"> <div class="post">
<h3 class="title"><a href="{$WWWROOT}view/artefact.php?artefact={$post->id}&view={$view}">{$post->title}</a></h3> <h3 class="title"><a href="{$WWWROOT}artefact/artefact.php?artefact={$post->id}&view={$view}">{$post->title}</a></h3>
<div class="postdetails">{$post->postedbyon}</div> <div class="postdetails">{$post->postedbyon}</div>
<div class="detail">{$post->description|clean_html|safe}</div> <div class="detail">{$post->description|clean_html|safe}</div>
<div class="tags">{str tag=tags}: {list_tags owner=$post->owner tags=$post->taglist}</div> <div class="tags">{str tag=tags}: {list_tags owner=$post->owner tags=$post->taglist}</div>
{if $post->allowcomments}<div class="postdetails"><a href="{$WWWROOT}view/artefact.php?artefact={$post->id}&view={$view}">{str tag=Comments section=artefact.comment} ({$post->commentcount})</a></div>{/if} {if $post->allowcomments}<div class="postdetails"><a href="{$WWWROOT}artefact/artefact.php?artefact={$post->id}&view={$view}">{str tag=Comments section=artefact.comment} ({$post->commentcount})</a></div>{/if}
</div> </div>
{/foreach} {/foreach}
</div> </div>
...@@ -33,10 +33,10 @@ ...@@ -33,10 +33,10 @@
{else}<ul class="taggedposts">{foreach from=$results item=post} {else}<ul class="taggedposts">{foreach from=$results item=post}
<li> <li>
<strong><a href="{$WWWROOT}view/artefact.php?artefact={$post->id}&view={$view}">{$post->title}</a></strong> <strong><a href="{$WWWROOT}artefact/artefact.php?artefact={$post->id}&view={$view}">{$post->title}</a></strong>
{str tag='postedin' section='blocktype.blog/taggedposts'} {str tag='postedin' section='blocktype.blog/taggedposts'}
{if $viewowner}{$post->parenttitle} {if $viewowner}{$post->parenttitle}
{else}<a href="{$WWWROOT}view/artefact.php?artefact={$post->parent}&view={$view}">{$post->parenttitle}</a>{/if} {else}<a href="{$WWWROOT}artefact/artefact.php?artefact={$post->parent}&view={$view}">{$post->parenttitle}</a>{/if}
<span class="postdetails">{str tag='postedon' section='blocktype.blog/taggedposts'} {$post->displaydate}</span> <span class="postdetails">{str tag='postedon' section='blocktype.blog/taggedposts'} {$post->displaydate}</span>
</li> </li>
{/foreach}</ul> {/foreach}</ul>
......
...@@ -194,8 +194,6 @@ class ArtefactTypeBlog extends ArtefactType { ...@@ -194,8 +194,6 @@ class ArtefactTypeBlog extends ArtefactType {
* @return array A two key array, 'html' and 'javascript'. * @return array A two key array, 'html' and 'javascript'.
*/ */
public function render_self($options) { public function render_self($options) {
$this->add_to_render_path($options);
if (!isset($options['limit'])) { if (!isset($options['limit'])) {
$limit = self::pagination; $limit = self::pagination;
} }
...@@ -216,7 +214,7 @@ class ArtefactTypeBlog extends ArtefactType { ...@@ -216,7 +214,7 @@ class ArtefactTypeBlog extends ArtefactType {
$template = 'artefact:blog:viewposts.tpl'; $template = 'artefact:blog:viewposts.tpl';
$baseurl = get_config('wwwroot') . 'view/artefact.php?artefact=' . $this->id; $baseurl = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $this->id;
if (!empty($options['viewid'])) { if (!empty($options['viewid'])) {
$baseurl .= '&view=' . $options['viewid']; $baseurl .= '&view=' . $options['viewid'];
} }
...@@ -231,7 +229,7 @@ class ArtefactTypeBlog extends ArtefactType { ...@@ -231,7 +229,7 @@ class ArtefactTypeBlog extends ArtefactType {
$smarty = smarty_core(); $smarty = smarty_core();
if (isset($options['viewid'])) { if (isset($options['viewid'])) {
$smarty->assign('artefacttitle', '<a href="' . get_config('wwwroot') . 'view/artefact.php?artefact=' $smarty->assign('artefacttitle', '<a href="' . get_config('wwwroot') . 'artefact/artefact.php?artefact='
. $this->get('id') . '&view=' . $options['viewid'] . $this->get('id') . '&view=' . $options['viewid']
. '">' . hsc($this->get('title')) . '</a>'); . '">' . hsc($this->get('title')) . '</a>');
} }
...@@ -622,7 +620,7 @@ class ArtefactTypeBlogPost extends ArtefactType { ...@@ -622,7 +620,7 @@ class ArtefactTypeBlogPost extends ArtefactType {
public function render_self($options) { public function render_self($options) {
$smarty = smarty_core(); $smarty = smarty_core();
$artefacturl = get_config('wwwroot') . 'view/artefact.php?artefact=' . $this->get('id'); $artefacturl = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $this->get('id');
if (isset($options['viewid'])) { if (isset($options['viewid'])) {
$artefacturl .= '&view=' . $options['viewid']; $artefacturl .= '&view=' . $options['viewid'];
} }
...@@ -660,13 +658,12 @@ class ArtefactTypeBlogPost extends ArtefactType { ...@@ -660,13 +658,12 @@ class ArtefactTypeBlogPost extends ArtefactType {
$attachments = $this->get_attachments(); $attachments = $this->get_attachments();
if ($attachments) { if ($attachments) {
$this->add_to_render_path($options);
require_once(get_config('docroot') . 'artefact/lib.php'); require_once(get_config('docroot') . 'artefact/lib.php');
foreach ($attachments as &$attachment) { foreach ($attachments as &$attachment) {
$f = artefact_instance_from_id($attachment->id); $f = artefact_instance_from_id($attachment->id);
$attachment->size = $f->describe_size(); $attachment->size = $f->describe_size();
$attachment->iconpath = $f->get_icon(array('id' => $attachment->id, 'viewid' => isset($options['viewid']) ? $options['viewid'] : 0)); $attachment->iconpath = $f->get_icon(array('id' => $attachment->id, 'viewid' => isset($options['viewid']) ? $options['viewid'] : 0));
$attachment->viewpath = get_config('wwwroot') . 'view/artefact.php?artefact=' . $attachment->id . '&view=' . (isset($options['viewid']) ? $options['viewid'] : 0); $attachment->viewpath = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $attachment->id . '&view=' . (isset($options['viewid']) ? $options['viewid'] : 0);
$attachment->downloadpath = get_config('wwwroot') . 'artefact/file/download.php?file=' . $attachment->id; $attachment->downloadpath = get_config('wwwroot') . 'artefact/file/download.php?file=' . $attachment->id;
if (isset($options['viewid'])) { if (isset($options['viewid'])) {
$attachment->downloadpath .= '&view=' . $options['viewid']; $attachment->downloadpath .= '&view=' . $options['viewid'];
...@@ -752,7 +749,11 @@ class ArtefactTypeBlogPost extends ArtefactType { ...@@ -752,7 +749,11 @@ class ArtefactTypeBlogPost extends ArtefactType {
if ($files) { if ($files) {
safe_require('artefact', 'file'); safe_require('artefact', 'file');
foreach ($files as &$file) { foreach ($files as &$file) {
$file->icon = call_static_method(generate_artefact_class_name($file->artefacttype), 'get_icon', array('id' => $file->attachment)); $params = array('id' => $file->attachment);
if (!empty($viewoptions['viewid'])) {
$params['viewid'] = $viewoptions['viewid'];
}
$file->icon = call_static_method(generate_artefact_class_name($file->artefacttype), 'get_icon', $params);
$data[$file->artefact]->files[] = $file; $data[$file->artefact]->files[] = $file;
} }
} }
......
...@@ -42,7 +42,7 @@ if ($blockid = param_integer('block', null)) { ...@@ -42,7 +42,7 @@ if ($blockid = param_integer('block', null)) {
ArtefactTypeBlogpost::render_posts($posts, $template, $configdata, $pagination); ArtefactTypeBlogpost::render_posts($posts, $template, $configdata, $pagination);
} }
else { else {
// No block, we're just rendering the blog by itself on view/artefact.php // No block, we're just rendering the blog by itself.
$limit = param_integer('limit', ArtefactTypeBlog::pagination); $limit = param_integer('limit', ArtefactTypeBlog::pagination);
$blogid = param_integer('artefact'); $blogid = param_integer('artefact');
$viewid = param_integer('view'); $viewid = param_integer('view');
...@@ -56,7 +56,7 @@ else { ...@@ -56,7 +56,7 @@ else {
$posts = ArtefactTypeBlogpost::get_posts($blogid, $limit, $offset, $options); $posts = ArtefactTypeBlogpost::get_posts($blogid, $limit, $offset, $options);
$template = 'artefact:blog:viewposts.tpl'; $template = 'artefact:blog:viewposts.tpl';
$baseurl = get_config('wwwroot') . 'view/artefact.php?artefact=' . $blogid . '&view=' . $viewid; $baseurl = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $blogid . '&view=' . $viewid;
$pagination = array( $pagination = array(
'baseurl' => $baseurl, 'baseurl' => $baseurl,
'id' => 'blogpost_pagination', 'id' => 'blogpost_pagination',
......
{foreach from=$posts item=post} {foreach from=$posts item=post}
<div class="post"> <div class="post">
<h3 class="title"><a href="{$WWWROOT}view/artefact.php?artefact={$post->id}&view={$options.viewid}">{$post->title}</a></h3> <h3 class="title"><a href="{$WWWROOT}artefact/artefact.php?artefact={$post->id}&view={$options.viewid}">{$post->title}</a></h3>
<div class="postdetails">{$post->postedby}</div> <div class="postdetails">{$post->postedby}</div>
<div>{$post->description|clean_html|safe} <div>{$post->description|clean_html|safe}
{if $post->tags} {if $post->tags}
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<td class="icon-container"><img src="{$file->icon}" alt=""></td> <td class="icon-container"><img src="{$file->icon}" alt=""></td>
<td> <td>
<h3 class="title"> <h3 class="title">
<a href="{$WWWROOT}view/artefact.php?artefact={$file->attachment}&view={$options.viewid}">{$file->title}</a> <a href="{$WWWROOT}artefact/artefact.php?artefact={$file->attachment}&view={$options.viewid}">{$file->title}</a>
<span class="description">({$file->size|display_size}) - <a href="{$WWWROOT}artefact/file/download.php?file={$file->attachment}&view={$options.viewid}">{str tag=Download section=artefact.file}</a></span> <span class="description">({$file->size|display_size}) - <a href="{$WWWROOT}artefact/file/download.php?file={$file->attachment}&view={$options.viewid}">{str tag=Download section=artefact.file}</a></span>
</h3> </h3>
<div class="detail">{$file->description}</div> <div class="detail">{$file->description}</div>
...@@ -35,6 +35,6 @@ ...@@ -35,6 +35,6 @@
</tbody> </tbody>
</table> </table>
{/if} {/if}
{if $options.viewid && $post->allowcomments}<div class="postdetails"><a href="{$WWWROOT}view/artefact.php?artefact={$post->id}&view={$options.viewid}">{str tag=Comments section=artefact.comment} ({$post->commentcount})</a></div>{/if} {if $options.viewid && $post->allowcomments}<div class="postdetails"><a href="{$WWWROOT}artefact/artefact.php?artefact={$post->id}&view={$options.viewid}">{str tag=Comments section=artefact.comment} ({$post->commentcount})</a></div>{/if}
</div> </div>
{/foreach} {/foreach}
...@@ -601,7 +601,7 @@ class ArtefactTypeComment extends ArtefactType { ...@@ -601,7 +601,7 @@ class ArtefactTypeComment extends ArtefactType {
$data->jsonscript = 'artefact/comment/comments.json.php'; $data->jsonscript = 'artefact/comment/comments.json.php';
if (!empty($data->artefact)) { if (!empty($data->artefact)) {
$data->baseurl = get_config('wwwroot') . 'view/artefact.php?view=' . $data->view . '&artefact=' . $data->artefact; $data->baseurl = get_config('wwwroot') . 'artefact/artefact.php?view=' . $data->view . '&artefact=' . $data->artefact;
$extradata['artefact'] = $data->artefact; $extradata['artefact'] = $data->artefact;
} }
else { else {
...@@ -751,7 +751,7 @@ class ArtefactTypeComment extends ArtefactType { ...@@ -751,7 +751,7 @@ class ArtefactTypeComment extends ArtefactType {
public function get_view_url($viewid, $showcomment=true, $full=true) { public function get_view_url($viewid, $showcomment=true, $full=true) {
if ($artefact = $this->get('onartefact')) { if ($artefact = $this->get('onartefact')) {
$url = 'view/artefact.php?view=' . $viewid . '&artefact=' . $artefact; $url = 'artefact/artefact.php?view=' . $viewid . '&artefact=' . $artefact;
} }
else { else {
$url = 'view/view.php?id=' . $viewid; $url = 'view/view.php?id=' . $viewid;
...@@ -959,7 +959,7 @@ function delete_comment_submit(Pieform $form, $values) { ...@@ -959,7 +959,7 @@ function delete_comment_submit(Pieform $form, $values) {
$viewid = $view->get('id'); $viewid = $view->get('id');
if ($artefact = $comment->get('onartefact')) { if ($artefact = $comment->get('onartefact')) {
$url = 'view/artefact.php?view=' . $viewid . '&artefact=' . $artefact; $url = 'artefact/artefact.php?view=' . $viewid . '&artefact=' . $artefact;
} }
else { else {
$url = $view->get_url(false); $url = $view->get_url(false);
...@@ -1254,7 +1254,7 @@ class ActivityTypeArtefactCommentFeedback extends ActivityTypePlugin { ...@@ -1254,7 +1254,7 @@ class ActivityTypeArtefactCommentFeedback extends ActivityTypePlugin {
$userid = $artefactinstance->get('owner'); $userid = $artefactinstance->get('owner');
} }
if (empty($this->url)) { if (empty($this->url)) {
$this->url = 'view/artefact.php?artefact=' . $onartefact . '&view=' . $this->viewid; $this->url = 'artefact/artefact.php?artefact=' . $onartefact . '&view=' . $this->viewid;
} }
} }
else { // feedback on view. else { // feedback on view.
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<h3 class="title"><a href="{$file.downloadurl}" target="_blank">{$file.title}</a></h3> <h3 class="title"><a href="{$file.downloadurl}" target="_blank">{$file.title}</a></h3>
{if $file.description}<div class="detail">{$file.description}</div>{/if} {if $file.description}<div class="detail">{$file.description}</div>{/if}
<div class="description">{$file.size|display_size} | {$file.ctime|format_date:'strftimedaydate'} <div class="description">{$file.size|display_size} | {$file.ctime|format_date:'strftimedaydate'}
| <a href="{$WWWROOT}view/artefact.php?artefact={$file.id}&view={$viewid}">{str tag=Details section=artefact.file}</a></div> | <a href="{$WWWROOT}artefact/artefact.php?artefact={$file.id}&view={$viewid}">{str tag=Details section=artefact.file}</a></div>
</div> </div>
</div> </div>
{/foreach} {/foreach}
...@@ -364,7 +364,7 @@ class PluginBlocktypeGallery extends PluginBlocktype { ...@@ -364,7 +364,7 @@ class PluginBlocktypeGallery extends PluginBlocktype {
$link = $src . '&maxwidth=' . get_config_plugin('blocktype', 'gallery', 'previewwidth'); $link = $src . '&maxwidth=' . get_config_plugin('blocktype', 'gallery', 'previewwidth');
} }
else { else {
$link = get_config('wwwroot') . 'view/artefact.php?artefact=' . $artefactid . '&view=' . $instance->get('view'); $link = get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $artefactid . '&view=' . $instance->get('view');
} }
// If the Thumbnails are Square or not... // If the Thumbnails are Square or not...
......
...@@ -51,7 +51,7 @@ class PluginBlocktypeImage extends PluginBlocktype { ...@@ -51,7 +51,7 @@ class PluginBlocktypeImage extends PluginBlocktype {
} }
$smarty = smarty_core(); $smarty = smarty_core();
$smarty->assign('url', $wwwroot . 'view/artefact.php?artefact=' . $id . '&view=' . $viewid); $smarty->assign('url', $wwwroot . 'artefact/artefact.php?artefact=' . $id . '&view=' . $viewid);
$smarty->assign('src', $src); $smarty->assign('src', $src);
$smarty->assign('description', $description); $smarty->assign('description', $description);
$smarty->assign('showdescription', !empty($configdata['showdescription']) && !empty($description)); $smarty->assign('showdescription', !empty($configdata['showdescription']) && !empty($description));
......
...@@ -33,18 +33,21 @@ else { ...@@ -33,18 +33,21 @@ else {
if ($viewid && $fileid) { if ($viewid && $fileid) {
$file = artefact_instance_from_id($fileid); $file = artefact_instance_from_id($fileid);
$parent = $file->get('parent');