Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Init NodesList with a rootPath, set parent label empty to avoid gui r…
Browse files Browse the repository at this point in the history
…eplacement.
  • Loading branch information
cdujeu committed Jul 13, 2016
1 parent fa484eb commit 357349e
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions core/src/plugins/core.access/src/Model/NodesList.php
Expand Up @@ -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]);
}

/**
Expand All @@ -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
Expand Down Expand Up @@ -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'][] = [
Expand All @@ -167,6 +182,7 @@ public function appendColumn($messageId, $attributeName, $sortType='String', $wi
'sortType' => $sortType,
'width' => $width
];
return $this;
}

/**
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit 357349e

Please sign in to comment.