Commit d0b4135d authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files

Pass the array around all over the place for metadata, so that we can

build links to download files passing the correct view ID
parent 0a04677f
......@@ -267,8 +267,8 @@ class ArtefactTypeBlog extends ArtefactType {
'javascript' => $javascript);
}
protected function get_metadata($options = array()) {
$data = parent::get_metadata();
protected function get_metadata($options=array()) {
$data = parent::get_metadata($options);
$data['description'] = array('name' => get_string('description'),
'value' => $this->get('description'));
$data['type']['value'] = get_string($this->get('artefacttype'), 'artefact.blog');
......@@ -548,8 +548,8 @@ class ArtefactTypeBlogPost extends ArtefactType {
}
protected function get_metadata() {
$data = parent::get_metadata();
protected function get_metadata($options=array()) {
$data = parent::get_metadata($options);
unset($data['description']);
unset($data['size']);
$data['type']['value'] = get_string($this->get('artefacttype'), 'artefact.blog');
......@@ -560,9 +560,9 @@ class ArtefactTypeBlogPost extends ArtefactType {
}
protected function render_metadata($options) {
protected function render_metadata($options=array()) {
$smarty = smarty();
$smarty->assign('PROPERTIES', $this->get_metadata());
$smarty->assign('PROPERTIES', $this->get_metadata($options));
return array('html' => $smarty->fetch('artefact:blog:render/blog_rendermetadata.tpl'),
'javascript' => null);
}
......
......@@ -414,8 +414,8 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
return $filedata;
}
protected function get_metadata() {
$data = parent::get_metadata();
protected function get_metadata($options=array()) {
$data = parent::get_metadata($options);
$data['description'] = array('name' => get_string('description'),
'value' => $this->description);
$data['type']['value'] = get_string($this->get('artefacttype'), 'artefact.file');
......@@ -424,7 +424,7 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
protected function render_metadata($options) {
$smarty = smarty();
$smarty->assign('PROPERTIES', $this->get_metadata());
$smarty->assign('PROPERTIES', $this->get_metadata($options));
return array('html' => $smarty->fetch('artefact:file:file_render_metadata.tpl'),
'javascript' => null);
}
......@@ -675,20 +675,24 @@ class ArtefactTypeFile extends ArtefactTypeFileBase {
return floor(($bytes / 1048576) * 10 + 0.5) / 10 . 'M';
}
private function file_url() {
return get_config('wwwroot') . 'artefact/file/download.php?file=' . $this->get('id');
private function file_url($options) {
$result = get_config('wwwroot') . 'artefact/file/download.php?file=' . $this->get('id');
if (isset($options['viewid'])) {
$result .= '&view=' . $options['viewid'];
}
return $result;
}
public function linkself() {
return '<a href="' . $this->file_url() . '">' . get_string('download', 'artefact.file') . '</a>';
}
protected function get_metadata() {
$data = parent::get_metadata();
protected function get_metadata($options=array()) {
$data = parent::get_metadata($options);
$data['size'] = array('name' => get_string('size', 'artefact.file'),
'value' => $this->get('size') . ' ' . get_string('bytes', 'artefact.file'));
$data['download'] = array('name' => get_string('download', 'artefact.file'),
'value' => make_link($this->file_url()));
'value' => make_link($this->file_url($options)));
return $data;
}
......@@ -840,8 +844,8 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
return $record->id;
}
protected function get_metadata() {
$data = parent::get_metadata();
protected function get_metadata($options=array()) {
$data = parent::get_metadata($options);
$data['size'] = array('name' => get_string('size', 'artefact.file'),
'value' => $this->count_children() . ' ' . get_string('files', 'artefact.file'));
return $data;
......
......@@ -455,7 +455,7 @@ abstract class ArtefactType {
}
protected function get_metadata() {
protected function get_metadata($options) {
$data = array('title' => $this->get('title'),
'type' => get_string($this->get('artefacttype')),
'owner' => display_name(optional_userobj($this->get('owner'))),
......
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