Commit 1623f172 authored by Martyn Smith's avatar Martyn Smith Committed by Martyn Smith
Browse files

Fixed read only rendering of views

parent 6f6a21a8
......@@ -375,7 +375,7 @@ function template_render($template, $mode, $data=array()) {
$droplist[$t['id']]['format'] = FORMAT_ARTEFACT_LISTSELF;
}
$block .= template_render_artefact_block($t['id'], $data[$t['id']]['id'], $format, $options);
$block .= template_render_artefact_block($t['id'], $data[$t['id']]['id'], $format, $options, $mode);
}
else if ( isset($t['defaultartefacttype']) ) {
$artefact = null;
......@@ -392,7 +392,7 @@ function template_render($template, $mode, $data=array()) {
}
}
else {
$block .= template_render_artefact_block($t['id'], $artefact, $t['defaultformat'], $options);
$block .= template_render_artefact_block($t['id'], $artefact, $t['defaultformat'], $options, $mode);
}
}
else {
......@@ -659,15 +659,17 @@ function template_render_empty_artefact_block() {
*
* @return string html rendered data
*/
function template_render_artefact_block($blockname, $artefact, $format, $options = array()) {
function template_render_artefact_block($blockname, $artefact, $format, $options = array(), $mode) {
$block = '';
$options['blockid'] = $blockname;
if ($artefact instanceof ArtefactType) {
$block .= $artefact->render($format, $options);
$block .= '<input type="hidden" name="template[' . $blockname . '][id]" value="' . hsc($artefact->get('id')) . '">';
$block .= '<input type="hidden" name="template[' . $blockname . '][format]" value="' . hsc($format) . '">';
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) . '">';
}
}
else if ($format == FORMAT_ARTEFACT_LISTSELF) {
if (!is_array($artefact)) {
......@@ -678,9 +680,11 @@ function template_render_artefact_block($blockname, $artefact, $format, $options
$block .= '<li>';
$instance = artefact_instance_from_id($id);
$block .= $instance->render($format, $options);
$block .= '<a href="" onclick="removeListItem(this);return false;">[x]</a>';
$block .= '<input type="hidden" name="template[' . $blockname . '][id][]" value="' . hsc($instance->get('id')) . '">';
$block .= '<input type="hidden" name="template[' . $blockname . '][format]" value="' . hsc($format) . '">';
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')) . '">';
$block .= '<input type="hidden" name="template[' . $blockname . '][format]" value="' . hsc($format) . '">';
}
$block .= '</li>';
}
$block .= '</ul>';
......@@ -692,8 +696,10 @@ function template_render_artefact_block($blockname, $artefact, $format, $options
$artefact = artefact_instance_from_id($artefact);
$block .= $artefact->render($format, $options);
$block .= '<input type="hidden" name="template[' . $blockname . '][id]" value="' . hsc($artefact->get('id')) . '">';
$block .= '<input type="hidden" name="template[' . $blockname . '][format]" value="' . hsc($format) . '">';
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) . '">';
}
}
return $block;
......
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