Commit de7ca27f authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Link view child artefacts, but only when they're explicitly included in

the view themselves
parent c9198fed
......@@ -225,18 +225,11 @@ class ArtefactTypeBlog extends ArtefactType {
}
protected function listself($options) {
$smarty = smarty();
$smarty->assign('title', $this->get('title'));
if (isset($options['size']) && $options['size']) {
$smarty->assign('size', $this->count_children() . ' ' . get_string('posts', 'artefact.blog'));
}
return $smarty->fetch('artefact:blog:render/blog_listself.tpl');
public function describe_size() {
return $this->count_children() . ' ' . get_string('posts', 'artefact.blog');
}
/**
* This function implements the render_full functionality for blogs.
* Rendering full involves rendering blog posts with render_full, and
......@@ -443,21 +436,8 @@ class ArtefactTypeBlogPost extends ArtefactType {
parent::delete();
}
/**
* This function displays the blogpost in listself mode. We're overriding the
* default, which is to simply display the title, so we can include more
* data, and use a smarty template.
*
* @param array
*/
protected function listself($options) {
$smarty = smarty();
$smarty->assign('title', $this->get('title'));
if (isset($options['size']) && $options['size']) {
$smarty->assign('size', $this->count_attachments() . ' '
. get_string('attachments', 'artefact.blog'));
}
return $smarty->fetch('artefact:blog:render/blog_listself.tpl');
public function describe_size() {
return $this->count_attachments() . ' ' . get_string('attachments', 'artefact.blog');
}
/**
......
......@@ -483,18 +483,8 @@ class ArtefactTypeFile extends ArtefactTypeFileBase {
return get_config('wwwroot') . 'artefact/file/download.php?file=' . $this->get('id');
}
public function listself($options) {
$smarty = smarty();
if (isset($options['link']) && $options['link']) {
$smarty->assign('title', '<a href="' . $this->file_url() . '">' . $this->get('title') . '</a>');
}
else {
$smarty->assign('title', $this->get('title'));
}
if (isset($options['size']) && $options['size']) {
$smarty->assign('size', $this->describe_size());
}
return $smarty->fetch('artefact:file:file_listself.tpl');
public function linkself() {
return '<a href="' . $this->file_url() . '">' . get_string('download', 'artefact.file') . '</a>';
}
protected function get_metadata() {
......@@ -538,15 +528,7 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
require_once('artefact.php');
foreach ($childrecords as &$child) {
$c = artefact_instance_from_id($child->id);
if (isset($options['link']) && $options['link']) {
$child->title = $c->render(FORMAT_ARTEFACT_LISTSELF, array('link'=>true));
}
else {
$child->title = $c->render(FORMAT_ARTEFACT_LISTSELF, null);
}
if (isset($options['size']) && $options['size']) {
$child->size = $c->describe_size();
}
$child->title = $c->render(FORMAT_ARTEFACT_LISTSELF, $options);
$child->date = format_date(strtotime($child->mtime), 'strfdaymonthyearshort');
$child->iconsrc = get_config('themeurl') . 'images/' . $child->artefacttype . '.gif';
}
......@@ -574,15 +556,6 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
return $this->count_children() . ' ' . get_string('files', 'artefact.file');
}
public function listself($options) {
$smarty = smarty();
$smarty->assign('title', $this->get('title'));
if (isset($options['size']) && $options['size']) {
$smarty->assign('size', $this->describe_size());
}
return $smarty->fetch('artefact:file:folder_listself.tpl');
}
public function get_icon() {
}
......
......@@ -14,9 +14,6 @@
{/if}
<th>{str tag=name}</th>
<th>{str tag=description}</th>
{if (isset($options.size))}
<th>{str tag=size}</th>
{/if}
{if (isset($options.date))}
<th>{str tag=date}</th>
{/if}
......@@ -30,9 +27,6 @@
{/if}
<td>{$child->title}</td>
<td>{$child->description}</td>
{if (isset($options.size))}
<td>{$child->size}</td>
{/if}
{if (isset($options.date))}
<td>{$child->date}</td>
{/if}
......
......@@ -475,7 +475,23 @@ abstract class ArtefactType {
* @param array options
*/
protected function listself($options) {
return $this->title;
if (isset($options['viewid'])) {
require_once('artefact.php');
if (artefact_in_view($id = $this->get('id'), $options['viewid'])) {
$title = '<a href="' . get_config('wwwroot') . 'view/view.php?view=' . $options['viewid']
. '&artefact=' . $id . '">' . $this->title . '</a>';
}
}
if (!isset($title)) {
$title = $this->title;
}
if (!empty($options['size']) && method_exists($this, 'describe_size')) {
$title .= ' (' . $this->describe_size() . ')';
}
if (!empty($options['link']) && method_exists($this, 'linkself')) {
$title .= ' (' . $this->linkself() . ')';
}
return $title;
}
/**
......
......@@ -41,11 +41,12 @@ if ($artefactid) {
if (!artefact_in_view($artefactid, $viewid)) {
throw new AccessDeniedException("Artefact $artefactid not in View $viewid");
}
$options = array('viewid' => $viewid);
if (in_array(FORMAT_ARTEFACT_RENDERFULL, $artefact->get_render_list())) {
$content = $artefact->render(FORMAT_ARTEFACT_RENDERFULL, null);
$content = $artefact->render(FORMAT_ARTEFACT_RENDERFULL, $options);
}
else {
$content = $artefact->render(FORMAT_ARTEFACT_RENDERMETADATA, null);
$content = $artefact->render(FORMAT_ARTEFACT_RENDERMETADATA, $options);
}
// Link ancestral artefacts back to the view
......
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