Permalink
Browse files

Init NodesList with a rootPath, set parent label empty to avoid gui r…

…eplacement.
  • Loading branch information...
1 parent fa484eb commit 357349eaf0766c7a04801f1c58bdc59128a8b3e0 @cdujeu cdujeu committed Jul 13, 2016
Showing with 20 additions and 4 deletions.
  1. +20 −4 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]);
}
/**
@@ -83,6 +85,16 @@ public function getChildren(){
}
/**
+ * @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
* @param $totalPages
@@ -146,19 +158,22 @@ 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;
}
/**
* @param string $messageId
* @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;
}

0 comments on commit 357349e

Please sign in to comment.