" * @param $first_child is this the first child ? * @param $last_child is this the last child ? */ protected function draw_dn($dn,$level=0,$first_child=true,$last_child=true) { if (DEBUG_ENABLED) debug_log('Entered with (%s,%s)',33,__FILE__,__LINE__,__METHOD__,$dn,$level); $ldapserver = $this->getLdapServer(); # level pre-treatment $code = ''; if (is_string($level)) { for ($i=0; $i 0) { $code = '0' * $level; } $level = strlen($code); # get entry to display as node $entry = $this->getEntry($dn); if (! $entry) { $this->addEntry($dn); $entry = $this->getEntry($dn); } if (! $entry) return ''; # some informations $rdn = $entry->getRdn(); $encoded_dn = rawurlencode($dn); $formatted_dn = $this->get_formatted_dn($entry,$level-1); $child_count = $this->get_children_number($entry); $nb = 0; if ($first_child) $nb += 1; if ($last_child) $nb += 2; # informations array[$nb] # nb == 1 => the node is the first child # nb == 2 => the node is the last child # nb == 3 => the node is the unique child # nb == 0 => the node is a child $expand_imgs = array('js/phplayersmenu/menuimages/tree_expand.png', 'js/phplayersmenu/menuimages/tree_expand.png', 'js/phplayersmenu/menuimages/tree_expand_corner.png', ($level > 0) ? 'js/phplayersmenu/menuimages/tree_expand_corner.png' : 'js/phplayersmenu/menuimages/tree_expand_corner_first.png'); $collapse_imgs = array('js/phplayersmenu/menuimages/tree_collapse.png', 'js/phplayersmenu/menuimages/tree_collapse.png', 'js/phplayersmenu/menuimages/tree_collapse_corner.png', ($level > 0) ? 'js/phplayersmenu/menuimages/tree_collapse_corner.png' : 'js/phplayersmenu/menuimages/tree_collapse_corner_first.png'); $tree_imgs = array('js/phplayersmenu/menuimages/tree_split.png', 'js/phplayersmenu/menuimages/tree_split.png', 'js/phplayersmenu/menuimages/tree_corner.png', 'js/phplayersmenu/menuimages/tree_corner.png'); $new_code = array('1', '1', '0', '0'); # links $edit_href_params = htmlspecialchars(sprintf('cmd=template_engine&server_id=%s&dn=%s',$this->server_id,$encoded_dn)); $edit_href = "cmd.php?$edit_href_params"; $openclose_params = htmlspecialchars(sprintf('server_id=%s&dn=%s&code=%s',$this->server_id,$encoded_dn,$code.$new_code[$nb])); # each node has a unique id based on dn $node_id = 'node'.base64_encode($ldapserver->server_id.'-'.$dn); $node_id = str_replace('=','_',$node_id); if ($level == 0) printf('',$this->getDepth()+3-1); printf('
',$node_id); echo $this->get_indentation($code); if ($entry->isOpened()) { if (! $child_count) { echo '--'; } else { echo ''; echo '+-'; echo ''; } } else { if (($child_count !== false) && (!$child_count)/* && (!$ldapserver->isShowCreateEnabled())*/) { echo '--'; } else { echo ''; echo '+-'; echo ''; } } echo ''; printf('->',$node_id,IMGDIR,$entry->getIcon($ldapserver)); echo ''; echo ' '; echo ''; echo $formatted_dn; echo ($child_count ? ' ('.$child_count.')' : ''); echo ''; echo '
'; echo '
'; if ($entry->isOpened()) { $this->draw_children($entry,$code.$new_code[$nb]); } echo '
'; if ($level == 0) { echo ''; } } public function draw_children($parent_entry,$code) { if (DEBUG_ENABLED) debug_log('Entered with (%s,%s)',33,__FILE__,__LINE__,__METHOD__,$parent_entry,$code); $children = array(); foreach($parent_entry->getChildren() as $childDn) $children[] = $this->getEntry($childDn); $first_child = $this->get_plm_before_first_child($parent_entry,$code); $last_child = $this->get_plm_after_last_child($parent_entry,$code); # If compression is on, we need to compress this output - but only if called by draw_tree_node if (function_exists('isCompress') && isCompress() && get_request('cmd','REQUEST') == 'draw_tree_node') ob_start(); echo $first_child; for ($i=0; $idraw_dn($children[$i]->getDn(),$code,$first,$last); } echo $last_child; # If compression is on, we need to compress this output if (function_exists('isCompress') && isCompress() && get_request('cmd','REQUEST') == 'draw_tree_node') { $output = ob_get_clean(); echo gzencode($output); } } /** * return the indentation bafore a node * @param $code a string of 0 and 1 ; $code == "000101" will return " | |" */ protected function get_indentation($code) { $indent = ''; for ($i=0; $i '; } protected function get_plm_before_first_child($entry,$level) { if (strlen($level) == 0) return ''; $ldapserver = $this->getLdapServer(); $output = ''; if (!$ldapserver->isReadOnly() && ($entry->getChildrenNumber() > 10) && ($ldapserver->isShowCreateEnabled())) { $encoded_dn = rawurlencode($entry->getDn()); $href = sprintf('cmd.php?cmd=template_engine&server_id=%s&container=%s',$ldapserver->server_id,$encoded_dn); $output .= $this->get_indentation($level); $output .= '--'; $output .= ''; $output .= sprintf('->',IMGDIR); $output .= ''; $output .= ' '; $output .= ''; $output .= _('Create new entry here'); $output .= ''; } return $output; } protected function get_plm_after_last_child($entry,$level) { if (strlen($level) == 0) return ''; $ldapserver = $this->getLdapServer(); $output = ''; if (!$ldapserver->isReadOnly() && !$entry->isLeaf() && $ldapserver->isShowCreateEnabled()) { $encoded_dn = rawurlencode($entry->getDn()); $href = sprintf('cmd.php?cmd=template_engine&server_id=%s&container=%s',$ldapserver->server_id,$encoded_dn); $output .= $this->get_indentation($level); $output .= '--'; $output .= ''; $output .= sprintf('->',IMGDIR); $output .= ''; $output .= ' '; $output .= ''; $output .= _('Create new entry here'); $output .= ''; } return $output; } } ?>