17 include_once (
"FDL/Lib.Dir.php");
24 $docid =
$usage->addRequiredParameter(
"id",
"id of the current document");
25 $usage->setStrictMode(
false);
28 $action->parent->AddJsRef($action->GetParam(
"CORE_PUBURL") .
"/FDL/Layout/common.js");
29 $action->parent->AddJsRef($action->GetParam(
"CORE_JSURL") .
"/subwindow.js");
33 if (
$doc->locked == - 1) {
36 $idocid =
$doc->initid;
39 $rdoc->sinitid = $idocid;
41 $action->lay->set(
"Title",
$doc->getHTMLTitle());
43 $relationsFrom = array();
44 $relationsTo = array();
46 $i18nFolder = _(
"folder");
48 $trel = $rdoc->getIRelations(
"",
"", $limit);
49 foreach ($trel as $currentResult) {
50 $relationsFrom[$currentResult[
"sinitid"]] = array(
51 "iconsrc" =>
$doc->getIcon($currentResult[
"sicon"]) ,
52 "initid" => $currentResult[
"sinitid"],
53 "title" => $currentResult[
"stitle"],
54 "url" =>
"?app=FDL&action=OPENDOC&mode=view&id=" . $currentResult[
"sinitid"],
55 "attributeId" => $currentResult[
"type"]
59 $trel = $rdoc->getRelations(
"",
"", $limit);
60 foreach ($trel as $currentResult) {
61 $relationsTo[$currentResult[
"cinitid"]] = array(
62 "iconsrc" =>
$doc->getIcon($currentResult[
"cicon"]) ,
63 "initid" => $currentResult[
"cinitid"],
64 "title" => $currentResult[
"ctitle"],
65 "url" =>
"?app=FDL&action=OPENDOC&mode=view&id=" . $currentResult[
"sinitid"],
66 "attributeId" => $currentResult[
"type"]
71 $attributesId = array_unique(array_merge(array_map(
function (
$value)
73 return $value[
"attributeId"];
75 , $relationsFrom) , array_map(
function (
$value)
77 return $value[
"attributeId"];
80 $attributesId = array_filter($attributesId);
81 if (!empty($attributesId)) {
84 $queryResults =
$query->Query(0, 0,
"TABLE");
86 $attributesValues = array();
87 foreach ($queryResults as $currentResult) {
88 $attributesValues[$currentResult[
"id"]] = $currentResult[
"labeltext"];
90 foreach ($relationsFrom as & $currentRelation) {
91 if (isset($attributesValues[$currentRelation[
"attributeId"]])) {
92 $currentRelation[
"attributeLabel"] = $attributesValues[$currentRelation[
"attributeId"]] !=
"folder" ? $attributesValues[$currentRelation[
"attributeId"]] : $i18nFolder;
95 foreach ($relationsTo as & $currentRelation) {
96 if (isset($attributesValues[$currentRelation[
"attributeId"]])) {
97 $currentRelation[
"attributeLabel"] = $attributesValues[$currentRelation[
"attributeId"]] !=
"folder" ? $attributesValues[$currentRelation[
"attributeId"]] : $i18nFolder;
103 $tids = array_unique(array_merge(array_map(
function (
$value)
105 if (!empty(
$value[
"initid"])) {
111 , $relationsFrom) , array_map(
function (
$value)
113 if (!empty(
$value[
"initid"])) {
120 $tids = array_filter($tids);
123 $tids = array_map(
function (
$value)
130 $filtersOnlyVisible =
function (
$value) use ($tids)
132 return in_array(
$value[
"initid"], $tids);
135 $relationsFrom = array_filter($relationsFrom, $filtersOnlyVisible);
136 $relationsTo = array_filter($relationsTo, $filtersOnlyVisible);
139 "currentDocument" => array(
141 "title" =>
$doc->getHTMLTitle()
143 "relationsTo" => $relationsTo,
144 "relationsFrom" => $relationsFrom
147 if ($onlyGetResult) {
152 "view document" => _(
"view document") ,
153 "noone document" => _(
"noone document") ,
154 "referenced from" => _(
"Referenced from") ,
155 "referenced" => _(
"Reference")
157 'core_stand_url' =>
getParam(
"CORE_STANDURL") ,
158 'initial_data' => $results
160 $action->lay->set(
"init_data", json_encode($initData, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP));
161 $action->lay->set(
"RNAVIGATE_JS", $action->parent->getJsLink(
"FREEDOM:rnavigate.js"));
177 catch(Exception $e) {
178 $return[
"success"] =
false;
179 $return[
"error"][] = $e->getMessage();
180 unset($return[
"data"]);
183 $action->lay->template = json_encode($return);
185 header(
'Content-type: application/json');
getParam($name, $def="")
must be in core or global type
Verify arguments for action function.
new_Doc($dbaccess, $id= '', $latest=false)
GetSqlCond($Table, $column, $integer=false)
if(($docid!==0)&&(!is_numeric($docid))) $query
rnavigate(Action &$action, $onlyGetResult=false)
getVisibleDocsFromIds($dbaccess, $ids, $userid)