diff --git a/core/src/plugins/core.access/src/Model/NodesList.php b/core/src/plugins/core.access/src/Model/NodesList.php index 6c22f1f81b..a2da38e875 100644 --- a/core/src/plugins/core.access/src/Model/NodesList.php +++ b/core/src/plugins/core.access/src/Model/NodesList.php @@ -54,9 +54,11 @@ class NodesList implements XMLDocSerializableResponseChunk, JSONSerializableResp /** * NodesList constructor. + * @param string $rootPath */ - public function __construct(){ - $this->parentNode = new AJXP_Node("/"); + public function __construct($rootPath = "/"){ + // Create a fake parent node by default, without label + $this->parentNode = new AJXP_Node($rootPath, ["text" => "", "is_file" => false]); } /** @@ -82,6 +84,16 @@ public function getChildren(){ return $this->children; } + /** + * @param $path + * @return AJXP_Node + */ + public function findChildByPath( $path ){ + return array_shift(array_filter($this->children, function($child) use ($path){ + return ($child instanceof AJXP_Node && $child->getPath() == $path); + })); + } + /** * @param $count * @param $currentPage @@ -146,12 +158,14 @@ public function toXML() * @param string $switchGridMode * @param string $switchDisplayMode * @param string $templateName + * @return $this */ public function initColumnsData($switchGridMode='', $switchDisplayMode='', $templateName=''){ $this->columnsDescription = [ 'description' => ['switchGridMode' => $switchGridMode, 'switchDisplayMode' => $switchDisplayMode, 'template_name' => $templateName], 'columns' => [] ]; + return $this; } /** @@ -159,6 +173,7 @@ public function initColumnsData($switchGridMode='', $switchDisplayMode='', $temp * @param string $attributeName * @param string $sortType * @param string $width + * @return $this */ public function appendColumn($messageId, $attributeName, $sortType='String', $width=''){ $this->columnsDescription['columns'][] = [ @@ -167,6 +182,7 @@ public function appendColumn($messageId, $attributeName, $sortType='String', $wi 'sortType' => $sortType, 'width' => $width ]; + return $this; } /** @@ -234,7 +250,7 @@ public function render($output) // Prepare Headers if(isSet($this->columnsDescription["columns"])){ $messages = LocaleService::getMessages(); - foreach($this->columnsDescription as $column){ + foreach($this->columnsDescription["columns"] as $column){ $colTitle = $messages[$column["messageId"]]; $collAttr = $column["attributeName"]; $headers[$collAttr] = $colTitle; @@ -259,7 +275,7 @@ public function render($output) foreach($this->children as $child){ $row = []; foreach($headers as $attName => $label){ - if($attName === "text") $row[] = $child->getLabel(); + if($attName === "text" || $attName === "ajxp_label") $row[] = $child->getLabel(); else if($attName === "is_file") $row[] = $child->isLeaf() ? "True" : "False"; else $row[] = $child->$attName; }