Commit 65d4aa4b authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Merged 5cde915ef2405fb9dc71d9110f6ee51e252f0374

parent 6e12f347
......@@ -223,7 +223,8 @@ class ArtefactTypeBlog extends ArtefactType {
$smarty->assign('blockid', $blockid);
$smarty->assign_by_ref('options', $options);
$smarty->assign_by_ref('javascript', $javascript);
return $smarty->fetch('artefact:blog:render/blog_listchildren.tpl');
return array('html' => $smarty->fetch('artefact:blog:render/blog_listchildren.tpl'),
'javascript' => null);
}
......@@ -264,7 +265,8 @@ class ArtefactTypeBlog extends ArtefactType {
$smarty->assign('blockid', $blockid);
$smarty->assign_by_ref('options', $options);
$smarty->assign_by_ref('javascript', $javascript);
return $smarty->fetch('artefact:blog:render/blog_renderfull.tpl');
return array('html' => $smarty->fetch('artefact:blog:render/blog_renderfull.tpl'),
'javascript' => null);
}
protected function get_metadata($options = array()) {
......@@ -286,7 +288,8 @@ class ArtefactTypeBlog extends ArtefactType {
protected function render_metadata($options) {
$smarty = smarty();
$smarty->assign('PROPERTIES', $this->get_metadata($options));
return $smarty->fetch('artefact:blog:render/blog_rendermetadata.tpl');
return array('html' => $smarty->fetch('artefact:blog:render/blog_rendermetadata.tpl'),
'javascript' => null);
}
......@@ -498,14 +501,16 @@ class ArtefactTypeBlogPost extends ArtefactType {
require_once('artefact.php');
foreach ($attachments as &$attachment) {
$f = artefact_instance_from_id($attachment->id);
$attachment->content = $f->render(FORMAT_ARTEFACT_LISTSELF, $options);
$rf = $f->render(FORMAT_ARTEFACT_LISTSELF, $options);
$attachment->content = $rf['html'];
}
$smarty->assign('attachments', $attachments);
}
$smarty->assign('postedbyon', get_string('postedbyon', 'artefact.blog',
display_name($this->owner),
format_date($this->ctime)));
return $smarty->fetch('artefact:blog:render/blogpost_renderfull.tpl');
return array('html' => $smarty->fetch('artefact:blog:render/blogpost_renderfull.tpl'),
'javascript' => null);
}
public function attachment_id_list() {
......@@ -553,7 +558,8 @@ class ArtefactTypeBlogPost extends ArtefactType {
protected function render_metadata($options) {
$smarty = smarty();
$smarty->assign('PROPERTIES', $this->get_metadata());
return $smarty->fetch('artefact:blog:render/blog_rendermetadata.tpl');
return array('html' => $smarty->fetch('artefact:blog:render/blog_rendermetadata.tpl'),
'javascript' => null);
}
......
......@@ -38,7 +38,7 @@ var blog_listchildren{$blockid} = new TableRenderer(
[
function(r) {
var td = TD();
td.innerHTML = r.content;
td.innerHTML = r.content.html;
return td;
}
]
......
......@@ -38,7 +38,7 @@ var blog_renderfull{$blockid} = new TableRenderer(
[
function(r) {
var td = TD();
td.innerHTML = r.content;
td.innerHTML = r.content.html;
return td;
}
]
......
......@@ -418,7 +418,8 @@ class ArtefactTypeFileBase extends ArtefactType {
protected function render_metadata($options) {
$smarty = smarty();
$smarty->assign('PROPERTIES', $this->get_metadata());
return $smarty->fetch('artefact:file:file_render_metadata.tpl');
return array('html' => $smarty->fetch('artefact:file:file_render_metadata.tpl'),
'javascript' => null);
}
......@@ -711,13 +712,15 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
require_once('artefact.php');
foreach ($childrecords as &$child) {
$c = artefact_instance_from_id($child->id);
$child->title = $c->render(FORMAT_ARTEFACT_LISTSELF, $options);
$rc = $c->render(FORMAT_ARTEFACT_LISTSELF, $options);
$child->title = $rc['html'];
$child->date = format_date(strtotime($child->mtime), 'strfdaymonthyearshort');
$child->iconsrc = theme_get_url('images/' . $child->artefacttype . '.gif');
}
$smarty->assign('children', $childrecords);
}
return $smarty->fetch('artefact:file:folder_renderfull.tpl');
return array('html' => $smarty->fetch('artefact:file:folder_renderfull.tpl'),
'javascript' => null);
}
public function listchildren($options) {
......@@ -729,11 +732,13 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
require_once('artefact.php');
foreach ($childrecords as $child) {
$c = artefact_instance_from_id($child->id);
$children[] = $c->render(FORMAT_ARTEFACT_LISTSELF, $options);
$rc = $c->render(FORMAT_ARTEFACT_LISTSELF, $options);
$children[] = $rc['html'];
}
$smarty->assign('children', $children);
}
return $smarty->fetch('artefact:file:folder_listchildren.tpl');
return array('html' => $smarty->fetch('artefact:file:folder_listchildren.tpl'),
'javascript' => null);
}
public function describe_size() {
......@@ -909,7 +914,8 @@ class ArtefactTypeImage extends ArtefactTypeFile {
$smarty->assign('url', $url);
}
$smarty->assign('height', $height ? $height : '');
return $smarty->fetch('artefact:file:image_renderfull.tpl');
return array('html' => $smarty->fetch('artefact:file:image_renderfull.tpl'),
'javascript' => null);
}
public static function get_render_list() {
......
......@@ -139,11 +139,9 @@ class ArtefactTypeProfile extends ArtefactType {
return parent::set($field, $value);
}
public function render($format, $options) {
if ($format == FORMAT_ARTEFACT_RENDERFULL) {
return $this->title;
}
return parent::render($format, $options);
public function render_full($options) {
return array('html' => $this->title,
'javascript' => null);
}
public function get_icon() {
......@@ -433,12 +431,23 @@ class ArtefactTypeEmail extends ArtefactTypeProfileField {
class ArtefactTypeStudentid extends ArtefactTypeProfileField {}
class ArtefactTypeIntroduction extends ArtefactTypeProfileField {}
class ArtefactTypeWebAddress extends ArtefactTypeProfileField {
public function render($format, $options) {
if (($format == FORMAT_ARTEFACT_LISTSELF || $format == FORMAT_ARTEFACT_RENDERFULL)
&& $options['link'] == true) {
return make_link($this->title);
public function listself($options) {
if ($options['link'] == true) {
$html = make_link($this->title);
}
else {
$html = $this->title;
}
return parent::render($format, $options);
return array('html' => $html, 'javascript' => null);
}
public function render_full($options) {
if ($options['link'] == true) {
$html = make_link($this->title);
}
else {
$html = $this->title;
}
return array('html' => $html, 'javascript' => null);
}
}
class ArtefactTypeOfficialwebsite extends ArtefactTypeWebAddress {}
......@@ -448,12 +457,13 @@ class ArtefactTypeAddress extends ArtefactTypeProfileField {}
class ArtefactTypeTown extends ArtefactTypeProfileField {}
class ArtefactTypeCity extends ArtefactTypeProfileField {}
class ArtefactTypeCountry extends ArtefactTypeProfileField {
public function render($format, $options) {
if ($format == FORMAT_ARTEFACT_LISTSELF || $format == FORMAT_ARTEFACT_RENDERFULL) {
$countries = getoptions_country();
return $countries[$this->title];
}
return parent::render($format, $options);
public function listself($options) {
$countries = getoptions_country();
return array('html' => $countries[$this->title], 'javascript' => null);
}
public function render_full($options) {
$countries = getoptions_country();
return array('html' => $countries[$this->title], 'javascript' => null);
}
}
class ArtefactTypeHomenumber extends ArtefactTypeProfileField {}
......
......@@ -484,7 +484,8 @@ abstract class ArtefactType {
$smarty->assign('nicectime', format_date($this->get('ctime')));
$smarty->assign('nicemtime', format_date($this->get('mtime')));
return $smarty->fetch('artefact/render_metadata.tpl');
return array('html' => $smarty->fetch('artefact/render_metadata.tpl'),
'javascript' => null);
}
......@@ -510,11 +511,15 @@ abstract class ArtefactType {
if (in_array(FORMAT_ARTEFACT_LISTCHILDREN, $this->get_render_list())) {
$html = '<ul>';
$js = '';
foreach ($this->get_children_instances() as $child) {
$html .= '<li>' . $child->render(FORMAT_ARTEFACT_LISTSELF, $options) . "</li>\n";
$renderedchild = $child->render(FORMAT_ARTEFACT_LISTSELF, $options);
$html .= '<li>' . $renderedchild['html'] . "</li>\n";
$js .= $renderedchild['javascript'] . "\n";
}
$html .= '</ul>';
return $html;
return array('html' => $html,
'javascript' => $js);
}
throw new Exception('This artefact cannot render to this format.');
......@@ -545,7 +550,8 @@ abstract class ArtefactType {
if (!empty($options['link']) && method_exists($this, 'linkself')) {
$title .= ' (' . $this->linkself() . ')';
}
return $title;
return array('html' => $title,
'javascript' => null);
}
/**
......
......@@ -47,7 +47,7 @@ if (!$renderedartefact) {
}
$result = array(
'data' => $renderedartefact,
'data' => $renderedartefact['html'],
'error' => false,
'message' => false // No message for successful artefact rendering
);
......
......@@ -676,7 +676,8 @@ function template_render_artefact_block($blockname, $artefact, $format, $options
$options['blockid'] = $blockname;
if ($artefact instanceof ArtefactType) {
$block .= $artefact->render($format, $options);
$rendered = $artefact->render($format, $options);
$block .= $rendered['html'];
if ($mode == TEMPLATE_RENDER_EDITMODE) {
$block .= '<input type="hidden" name="template[' . $blockname . '][id]" value="' . hsc($artefact->get('id')) . '">';
$block .= '<input type="hidden" name="template[' . $blockname . '][format]" value="' . hsc($format) . '">';
......@@ -690,7 +691,8 @@ function template_render_artefact_block($blockname, $artefact, $format, $options
foreach ($artefact as $id) {
$block .= '<li>';
$instance = artefact_instance_from_id($id);
$block .= $instance->render($format, $options);
$rendered = $instance->render($format, $options);
$block .= $rendered['html'];
if ($mode == TEMPLATE_RENDER_EDITMODE) {
$block .= '<a href="" onclick="removeListItem(this);return false;">[x]</a>';
$block .= '<input type="hidden" name="template[' . $blockname . '][id][]" value="' . hsc($instance->get('id')) . '">';
......@@ -706,7 +708,8 @@ function template_render_artefact_block($blockname, $artefact, $format, $options
}
$artefact = artefact_instance_from_id($artefact);
$block .= $artefact->render($format, $options);
$rendered = $artefact->render($format, $options);
$block .= $rendered['html'];
if ($mode == TEMPLATE_RENDER_EDITMODE) {
$block .= '<input type="hidden" name="template[' . $blockname . '][id]" value="' . hsc($artefact->get('id')) . '">';
$block .= '<input type="hidden" name="template[' . $blockname . '][format]" value="' . hsc($format) . '">';
......
......@@ -87,7 +87,8 @@ if ($viewdata) {
$classname = generate_artefact_class_name($artefactrec->artefacttype);
$artefactobj = new $classname(0, array('title' => $artefactrec->title));
$artefactobj->set('dirty', false);
$artname = $artefactobj->render(FORMAT_ARTEFACT_LISTSELF, array('link' => false));
$ra = $artefactobj->render(FORMAT_ARTEFACT_LISTSELF, array('link' => false));
$artname = $ra['html'];
$data[$index[$artefactrec->view]]['artefacts'][] = array('id' => $artefactrec->artefact,
'title' => $artname);
}
......
......@@ -50,11 +50,12 @@ if ($artefactid) {
$options = array('viewid' => $viewid,
'path' => $path);
if (in_array(FORMAT_ARTEFACT_RENDERFULL, $artefact->get_render_list())) {
$content = $artefact->render(FORMAT_ARTEFACT_RENDERFULL, $options);
$rendered = $artefact->render(FORMAT_ARTEFACT_RENDERFULL, $options);
}
else {
$content = $artefact->render(FORMAT_ARTEFACT_RENDERMETADATA, $options);
$rendered = $artefact->render(FORMAT_ARTEFACT_RENDERMETADATA, $options);
}
$content = $rendered['html'];
$viewhref = 'view.php?view=' . $viewid;
$navlist = array('<a href="' . $viewhref . '">' . $view->get('title') . '</a>');
......
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