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

Use get_artefact_hierarchy() for artefact ancestor links

parent 996b4440
...@@ -30,33 +30,33 @@ require(get_config('libroot') . 'view.php'); ...@@ -30,33 +30,33 @@ require(get_config('libroot') . 'view.php');
$viewid = param_integer('view'); $viewid = param_integer('view');
$artefactid = param_integer('artefact', null); $artefactid = param_integer('artefact', null);
$ancestors = param_variable('artefactlist', null);
$view = new View($viewid);
if (!can_view_view($viewid)) { if (!can_view_view($viewid)) {
throw new AccessDeniedException(); throw new AccessDeniedException();
} }
// if ($artefactid && !artefact_in_view($viewid, $artefactid)) {
// throw new AccessDeniedException("Artefact $artefactid not in View $viewid");
// }
$getstring = quotestrings(array('message', 'makepublic', 'placefeedback', $view = new View($viewid);
'cancel', 'complaint', 'notifysiteadministrator',
'addtowatchlist', 'nopublicfeedback',
'reportobjectionablematerial', 'print'));
if ($artefactid) { if ($artefactid) {
// Link parent artefacts back to the view
$hierarchy = $view->get_artefact_hierarchy();
log_debug($hierarchy);
$artefact = $hierarchy['refs'][$artefactid];
$ancestorid = $artefact->parent;
$links = array();
while ($ancestorid && isset($hierarchy['refs'][$ancestorid])) {
$ancestor = $hierarchy['refs'][$ancestorid];
$link = '<a href="view.php?view=' . $viewid . '&amp;artefact=' . $ancestorid . '">'
. $ancestor->title . "</a>\n";
array_unshift($links, $link);
$ancestorid = $ancestor->parent;
}
$javascript = 'var artefact = ' . $artefactid . ";\n"; $javascript = 'var artefact = ' . $artefactid . ";\n";
$artefact = get_record('artefact', 'id', $artefactid);
$title = '<div><a href="view.php?view=' . $viewid . '">' . $view->get('title') . "</a></div>\n"; $title = '<div><a href="view.php?view=' . $viewid . '">' . $view->get('title') . "</a></div>\n";
if ($ancestors) { $title .= implode(' | ', $links);
$alist = explode(',',$ancestors);
$links = array();
for ($i = 0; $i < count($alist); $i++) {
$atitle = get_field('artefact', 'title', 'id', $alist[$i]);
$links[] = '<a href="view.php?view=' . $viewid . '&amp;artefact=' . $alist[$i]
. ($i ? '&amp;artefactlist=' . implode(',',array_slice($alist,0,$i)) : '')
. '">' . $atitle . "</a>";
}
$title .= '<div>' . implode(' | ', $links) . "</div>\n";
}
$title .= "<h3>$artefact->title</h3>"; $title .= "<h3>$artefact->title</h3>";
} }
else { else {
...@@ -65,7 +65,12 @@ else { ...@@ -65,7 +65,12 @@ else {
$content = $view->render(); $content = $view->render();
} }
$javascript .= <<<JAVASCRIPT $getstring = quotestrings(array('message', 'makepublic', 'placefeedback',
'cancel', 'complaint', 'notifysiteadministrator',
'addtowatchlist', 'nopublicfeedback',
'reportobjectionablematerial', 'print'));
$javascript .= <<<EOF
var view = {$viewid}; var view = {$viewid};
...@@ -169,7 +174,7 @@ feedbacklist.emptycontent = {$getstring['nopublicfeedback']}; ...@@ -169,7 +174,7 @@ feedbacklist.emptycontent = {$getstring['nopublicfeedback']};
feedbacklist.updateOnLoad(); feedbacklist.updateOnLoad();
JAVASCRIPT; EOF;
$smarty = smarty(array('tablerenderer')); $smarty = smarty(array('tablerenderer'));
//$smarty->clear_assign('MAINNAV'); //$smarty->clear_assign('MAINNAV');
......
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