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

Merged 1199a6fddccac1c72f1697de0cba55db3073721

parent 65d4aa4b
......@@ -222,9 +222,8 @@ class ArtefactTypeBlog extends ArtefactType {
$smarty->assign('artefact', $this);
$smarty->assign('blockid', $blockid);
$smarty->assign_by_ref('options', $options);
$smarty->assign_by_ref('javascript', $javascript);
return array('html' => $smarty->fetch('artefact:blog:render/blog_listchildren.tpl'),
'javascript' => null);
'javascript' => $javascript);
}
......@@ -264,9 +263,8 @@ class ArtefactTypeBlog extends ArtefactType {
}
$smarty->assign('blockid', $blockid);
$smarty->assign_by_ref('options', $options);
$smarty->assign_by_ref('javascript', $javascript);
return array('html' => $smarty->fetch('artefact:blog:render/blog_renderfull.tpl'),
'javascript' => null);
'javascript' => $javascript);
}
protected function get_metadata($options = array()) {
......
......@@ -2,10 +2,6 @@
* This smarty template renders a list of a blog's children.
*}
<script type="text/javascript">
{$javascript}
</script>
<table id="blog_listchildren{$blockid}">
<thead></thead>
<tbody></tbody>
......
......@@ -2,10 +2,6 @@
* This smarty template renders a list of a blog's children.
*}
<script type="text/javascript">
{$javascript}
</script>
<h2>{$artefacttitle}</h2>
<table id="blog_renderfull{$blockid}">
......
......@@ -48,6 +48,7 @@ if (!$renderedartefact) {
$result = array(
'data' => $renderedartefact['html'],
'javascript' => $renderedartefact['javascript'],
'error' => false,
'message' => false // No message for successful artefact rendering
);
......
......@@ -533,9 +533,9 @@ function template_render($template, $mode, $data=array(), $view_id=null) {
sendjsonrequest('{$wwwroot}json/renderartefact.php', render_options, 'GET', function (response) {
if (!response.error) {
real_target.innerHTML = response.data;
forEach(getElementsByTagAndClassName('script', null, real_target), function(script) {
eval(script.innerHTML);
});
if (response.javascript) {
eval(response.javascript);
}
if(format == 'listself') {
appendChildNodes(real_target, A({ href: '', onclick: 'removeListItem(this); return false;' }, '[x]'));
}
......@@ -677,6 +677,9 @@ function template_render_artefact_block($blockname, $artefact, $format, $options
if ($artefact instanceof ArtefactType) {
$rendered = $artefact->render($format, $options);
if (!empty($rendered['javascript'])) {
$block .= '<script type="text/javascript">' . $rendered['javascript'] . '</script>';
}
$block .= $rendered['html'];
if ($mode == TEMPLATE_RENDER_EDITMODE) {
$block .= '<input type="hidden" name="template[' . $blockname . '][id]" value="' . hsc($artefact->get('id')) . '">';
......@@ -692,6 +695,9 @@ function template_render_artefact_block($blockname, $artefact, $format, $options
$block .= '<li>';
$instance = artefact_instance_from_id($id);
$rendered = $instance->render($format, $options);
if (!empty($rendered['javascript'])) {
$block .= '<script type="text/javascript">' . $rendered['javascript'] . '</script>';
}
$block .= $rendered['html'];
if ($mode == TEMPLATE_RENDER_EDITMODE) {
$block .= '<a href="" onclick="removeListItem(this);return false;">[x]</a>';
......@@ -709,6 +715,9 @@ function template_render_artefact_block($blockname, $artefact, $format, $options
$artefact = artefact_instance_from_id($artefact);
$rendered = $artefact->render($format, $options);
if (!empty($rendered['javascript'])) {
$block .= '<script type="text/javascript">' . $rendered['javascript'] . '</script>';
}
$block .= $rendered['html'];
if ($mode == TEMPLATE_RENDER_EDITMODE) {
$block .= '<input type="hidden" name="template[' . $blockname . '][id]" value="' . hsc($artefact->get('id')) . '">';
......
......@@ -55,7 +55,11 @@ if ($artefactid) {
else {
$rendered = $artefact->render(FORMAT_ARTEFACT_RENDERMETADATA, $options);
}
$content = $rendered['html'];
$content = '';
if (!empty($rendered['javascript'])) {
$content = '<script type="text/javascript">' . $rendered['javascript'] . '</script>';
}
$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