1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
public function getListHtmlDFA($array=array(), $parent=0, $level=0){
$html = "";
$prevLevel = 0;
if (!$niveau && !$prevLevel) $html.= "<ul>" ;
if(is_array($array)){
foreach ($array AS $key => $value) {
$order = $prevLevel != $parent ? 1 : $order+1;
$href = $this->action != '' ? "{$this->action}{$value->id}" : "" ;
if ($parent == $value->parent) {
if ($prevLevel < $niveau) $html .= "<ul>";
if(!$this->languages || !(is_array($this->languages) && count($this->languages)) || (is_array($this->languages) && count($this->languages)==0)){
$html .= "<li> ";
$html .= "<input type='hidden' value='{$value->id}'/>";
$html .= "<input type='hidden' value='{$parent}'/>";
$html .= "<input type='hidden' value='{$order}'/>";
if(count($this->getUrlCible())){
foreach($this->getUrlCible() as $urlCible){
$id = isset($urlCible['useId']) && $urlCible['useId'] == true ? $value->id : "" ;
$html.= "<span onclick=window.location='{$urlCible['url']}{$id}'>{$urlCible['label']}</span> ";
}
}
}else{
$html .= "<li id='lst_{$level}{$value->id}'><a>{$value->name}</a> ";
$html .= "<input type='hidden' name='domaine_{$value->id}' value='{$value->id}'/>";
$html .= "<input type='hidden' name='parent_{$parent}_{$value->id}_{$order}' value='{$parent}'/>";
$html .= "<input type='hidden' name='order_{$parent}_{$value->id}_{$order}' value='{$order}'/>";
if(is_array($this->languages) && count($this->languages)){
foreach($this->languages as $language){
$html .= "</span> ";
}
if(count($this->getUrlCible())){
foreach($this->getUrlCible() as $urlCible){
$id = isset($urlCible['useId']) && $urlCible['useId'] == true ? $value->id : "" ;
$html .= "<span class='link' onclick=window.location='{$urlCible['url']}{$id}'>{$urlCible['label']}</span> ";
}
}
}
}
$prevLevel = $niveau;
$html .= $this->getListHtmlDFA($array, $value->id, ($niveau + 1));
}
}
}
if (($prevLevel == $niveau) && ($prevLevel != 0)) $html .= "</ul></li>";
else if ($prevLevel == $niveau) $html .= "</ul>";
else $html .= "</li>";
return $html;
} |
Partager