5 * * Building a tree menu out of some tree nodes * */ function mar($margin){ $chl='   '; $chp=''; $s=''; $m= ($margin/10); for ($i=0;$i<=$m;$i++){ if (fmod($i,3)==0){$s.=$chp;} $s.=$chl; } return $s; } class TreeMenu{ //image directory //image names // on changing this names var $IMAGE_DIR_OPEN = "openb.gif"; var $IMAGE_DIR_CLOSE = "closeb.gif"; var $IMAGE_PLUS = "plus.gif"; var $IMAGE_MIN = "min.gif"; var $nodes=array(); var $tree=""; var $treeNumber=0; function __construct(){ $this->treeNumber=1; } function resetTree(){ $this->treeNumber++; $this->tree = ""; } /** * Making tree nodes * * @param string $name (node name) * @param string $parent (parent node) * @param string $text (displayed text) * @param string $link * @param bool $active (visibile child nodes on start) * @param string $image (image name) */ function node($name,$parent,$text,$link=false,$active=true,$image="item.gif"){ $this->nodes[]=array("name"=>$name ,"ref"=>$parent ,"text"=>$text ,"link"=>$link ,"active"=>$active ,"image"=>$image ); } /** * Recursive function * Making a string of all implied nodes * * @param bool $active (state of the nodes on start collapsed/open) * @param string $node (name of the starting parent node, could be any node in the tree * @param int $margin (indent of the tree node */ function makeTree($active=true,$node='start',$margin=0){ $class = " class=\"treemenu\""; $mrg=mar($margin); foreach ($this->nodes as $v){ if($v['name'] == $node){ if($v['link']){ $link = "{$v['text']}"; }else{ $link = $v['text']; } $link='  '.$link; //Walk through all nodes looking for a child $child=false; foreach ($this->nodes as $v2){ if($v2['ref'] == $node){ $child=true; } } //als het een child node heeft dan... if($child){ $stylei = " class=\"actn\""; $styleb = " class=\"actm\""; $id = " id=\"node_{$node}{$this->treeNumber}\""; $idt = " id=\"tnode_{$node}{$this->treeNumber}\""; $onclick = " onclick=\"treemenu('tnode_{$node}{$this->treeNumber}'". ",'node_{$node}{$this->treeNumber}'". ",'node_{$node}Blok{$this->treeNumber}'". ",'".$this->IMAGE_DIR."'". ",'".$this->IMAGE_MIN."'". ",'".$this->IMAGE_PLUS."'". ",'".$this->IMAGE_DIR_OPEN."'". ",'".$this->IMAGE_DIR_CLOSE."');\""; if($active){//child nodes of this node are visible on start //add to treemenu string $this->tree.= $mrg."". "IMAGE_DIR.$this->IMAGE_MIN."\">". "IMAGE_DIR.$this->IMAGE_DIR_OPEN."\"{$class}>". "".$link. "
\n"; }else{//child nodes of this nodes are not visible on start //add to treemenu string $this->tree.= $mrg."". "IMAGE_DIR.$this->IMAGE_PLUS."\">". "IMAGE_DIR.$this->IMAGE_DIR_CLOSE."\"{$class}>". "".$link. "
\n"; } }else{//node with no child node //add to treemenu string $this->tree.= mar($margin)."". "IMAGE_DIR."{$v['image']}\"{$class}>". "".$link. "
\n"; } } } if($active){ //visible child node block on start $this->tree.= "
treeNumber}\" class=\"divs\">\n"; }else{ //hidden child node block on start $this->tree.= "
treeNumber}\" class=\"divn\">\n"; } //adding the child nodes from this the parent node foreach ($this->nodes as $v){ if($v['ref'] == $node){ //recursive function call $this->makeTree($v['active'],$v['name'],($margin+20)); } } //end child node block $this->tree.= "
\n"; } function makeTable($node='start',$margin=0){ $class = " class=\"tablemenu\""; $mrg=mar($margin); foreach ($this->nodes as $v){ if($v['name'] == $node){ if($v['link']) $link = "{$v['text']}"; else $link = $v['text']; $link='  '.$link; $child=false; foreach ($this->nodes as $v2) if($v2['ref'] == $node) $child=true; if($child) $this->tree.= "$mrg $link\n"; else $this->tree.= "$mrg $link\n"; } } //adding the child nodes from this the parent node foreach ($this->nodes as $v){ if($v['ref'] == $node){ //recursive function call $this->makeTable($v['name'],($margin+20)); } } //end child node block } function makeCheckTree($node='start',$active=false){ if ($node=='start') $this->tree.= ""; } function makeTreeTable($node='start',$nm="",$margin=0,$c=0,$header=""){ if ($node=='start') $this->tree.= " \n".$header; //adding the child nodes from this the parent node $id = $nm."_".$c; $c=0; foreach ($this->nodes as $v){ if($v['ref'] == $node){ //recursive function call $this->makeTreeTable($v['name'],$id,($margin+20),$c); $c++; } } //end child node block $mrg=""; //$mrg=mar($margin); foreach ($this->nodes as $v){ if($v['name'] == $node){ $ar=explode("~~",$v['text']); if($v['link']){ $link = "{$ar[0]}"; }else{ $link = $ar[0]; } //Walk through all nodes looking for a child $child=false; foreach ($this->nodes as $v2){ if($v2['ref'] == $node){ $child=true; } } //als het een child node heeft dan... if($child){ $this->tree.= ""; for($i=1;$itree.= ""; $this->tree.= ""; } else{//node with no child node //add to treemenu string $this->tree.= ""; for($i=1;$itree.= ""; $this->tree.= ""; } } } if ($node=='start') $this->tree.= "
$mrg IMAGE_DIR.$this->IMAGE_DIR_OPEN."\" class=\"button\" />$link".$ar[$i]."
$mrg $link".$ar[$i]."
"; } /** * returning the menu tree in html code * * @return string */ function printTree(){ return $this->tree; } } ?> سامانه مصاحبه دکتری

_


فراموشي کلمه عبور

لطفا ايميل ثبت نامي خود را وارد نماييد. پس از ثبت براي شما ايميلي حاوي لينک بازنشاني کلمه عبور ارسال مي شود.

ايميل کاربر:



[یکشنبه، 6 اسفند، 1396]