|
|
@@ -265,7 +265,7 @@ public function objectStructView($item) {
|
|
|
}
|
|
|
}
|
|
|
$item = $acl->buildQuery($searchParams)->getItem($primaryKey);
|
|
|
- if (!$item) throw new \Exception("Item not found {$primaryKey}");
|
|
|
+ if (!$item) throw new Exception("Item not found {$primaryKey}");
|
|
|
// $item = Array( [ID] => 56977, [krs] => 0000080725 , ... )
|
|
|
// $item[default_db__x3A__BI_audit_MSIG_address:BI_audit_MSIG_address] => Array( [0] => [ 'xlink' => ${url} ] )
|
|
|
// $item[default_db__x3A__BI_audit_MSIG_address:BI_audit_MSIG_address] => Array( [11] => [ 'p5:links' => ${p5Links} ] )
|
|
|
@@ -325,6 +325,58 @@ public function objectStructView($item) {
|
|
|
$this->addChild($dataNode, $fieldName, "<!-- TODO: " . var_export($value, true) . " -->");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // add backRef links
|
|
|
+ $namespace = $acl->getNamespace();
|
|
|
+ $backRefList = ACL::getBackRefList($namespace);
|
|
|
+ DBG::log($backRefList, 'array', "\$backRefList for({$namespace};{$primaryKey})");
|
|
|
+ $backRefStats = array_map(function ($backRef) use ($namespace, $primaryKey) { // [ namespace, idInstance ], @returns { namespace, idInstance, label, shortName, total }
|
|
|
+ $label = $backRef['namespace']; // TODO: get DESC from Zasoby
|
|
|
+ $nameShort = explode("/", $label);
|
|
|
+ $nameShort = array_pop($nameShort);
|
|
|
+ $nameShort = (strlen($nameShort) > 20) ? substr($nameShort, 0, 20) . "..." : $nameShort;
|
|
|
+ $total = 0;
|
|
|
+ try {
|
|
|
+ $total = ACL::fetchBackRefs($namespace, $primaryKey, $backRef['namespace'], [ 'total' => true ]);
|
|
|
+ } catch (Exception $e) {
|
|
|
+ DBG::log($e);
|
|
|
+ }
|
|
|
+ return array_merge($backRef, [
|
|
|
+ 'primaryKey' => $primaryKey,
|
|
|
+ 'label' => $label,
|
|
|
+ 'shortName' => $nameShort,
|
|
|
+ 'total' => $total,
|
|
|
+ ]);
|
|
|
+ }, $backRefList);
|
|
|
+ DBG::log($backRefStats, 'array', "\$backRefStats for({$namespace};{$primaryKey})");
|
|
|
+ $foundBackRef = array_filter($backRefStats, function ($statsBackRef) {
|
|
|
+ return ($statsBackRef['total'] > 0);
|
|
|
+ });
|
|
|
+ DBG::log($foundBackRef, 'array', "\$foundBackRef for({$namespace};{$primaryKey})");
|
|
|
+ // $rowFunList[] = [
|
|
|
+ // 'ico' => 'glyphicon glyphicon-random',
|
|
|
+ // 'href' => Router::getRoute('ViewTableAjax')->getLink('', [
|
|
|
+ // 'namespace' => $backRef['namespace'],
|
|
|
+ // 'childRefNS' => $acl->getNamespace(),
|
|
|
+ // 'childRefPK' => $id,
|
|
|
+ // ]),
|
|
|
+ // 'title' => "Wyszukaj powiązania z '{$backRefLabel}'",
|
|
|
+ // 'label' => "Wyszukaj powiązania z '{$backRefShort}' <span class=\"badge\">{$totalBackRefs}</span>",
|
|
|
+ // ];
|
|
|
+ if (!empty($foundBackRef)) {
|
|
|
+ $p5LinkNode = $this->addChild($dataNode, 'p5:links');
|
|
|
+ foreach ($foundBackRef as $backRef) {
|
|
|
+ $linkBackRef = null; // TODO: generate back ref link
|
|
|
+ $p5BackRefNode = $this->addChild($p5LinkNode, 'p5:backRef', $linkBackRef);
|
|
|
+ $this->addAttribute($p5BackRefNode, "p5:total", $backRef['total']);
|
|
|
+ $this->addAttribute($p5BackRefNode, "p5:label", $backRef['label']);
|
|
|
+ $this->addAttribute($p5BackRefNode, "p5:shortName", $backRef['shortName']);
|
|
|
+ $this->addAttribute($p5BackRefNode, "p5:namespace", $backRef['namespace']);
|
|
|
+ $this->addAttribute($p5BackRefNode, "p5:primaryKey", $backRef['primaryKey']);
|
|
|
+ $this->addAttribute($p5BackRefNode, "p5:from", $namespace);
|
|
|
+ $this->addAttribute($p5BackRefNode, "p5:to", $backRef['namespace']);
|
|
|
+ }
|
|
|
+ }
|
|
|
} catch (Exception $e) {
|
|
|
DBG::log($e);
|
|
|
}
|