Location: PHPKode > scripts > dyna_menue > dyna_menue/menuelist.class.inc
<?
// ----------------------------------------------------------------------
// GSIBC DATA CLASS SYSTEM
// Copyright (C) 2004 by gsibc.net.
// GSIBC.net stands behind the software with support, training, certification and consulting.
// ----------------------------------------------------------------------
// LICENSE

// This program is open source product; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Filename: menuelist.class.php
// Original  Author(s): Rafat Katta hide@address.com
// ----------------------------------------------------------------------//
//********************* I use extende script (I) *****************
include_once("abs.menue.class.inc");
class CMenueList extends CAbsMenue {
	var $oarrElement;
	var $strJavascript;
	var $strStyle;
	
	var $strfoldinglist='foldinglist';
	var $strfoldheader='foldheader';
		
	function CMenueList($bStatus){
		parent::CAbsMenue($bStatus);
		$this->setdefaultStyle();
		$this->setdefaultscript();
		
	}
	function setJavascript($strlongscript){$this->strJavascript=$strlongscript;}
	function getJavascript(){$this->strJavascript;}
	function setdefaultscript(){
	// **********I get this script from (I)*************
//Smart Folding Menu tree- By Dynamic Drive (rewritten 03/03/02)
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use

	$strJavascript=<<<END
<script language="JavaScript"><!--
var head="display:''"
img1=new Image()
img1.src="fold.gif"
img2=new Image()
img2.src="open.gif"
var ns6=document.getElementById&&!document.all
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1
function checkcontained(e){
var iscontained=0
cur=ns6? e.target : event.srcElement
i=0
if (cur.id=="foldheader")
iscontained=1
else
while (ns6&&cur.parentNode||(ie4&&cur.parentElement)){
if (cur.id=="foldheader"||cur.id=="foldinglist"){
iscontained=(cur.id=="foldheader")? 1 : 0
break
}
cur=ns6? cur.parentNode : cur.parentElement
}
if (iscontained){
var foldercontent=ns6? cur.nextSibling.nextSibling : cur.all.tags("UL")[0]
if (foldercontent.style.display=="none"){
foldercontent.style.display=""
cur.style.listStyleImage="url(open.gif)"
	}
	else{
		foldercontent.style.display="none"
		cur.style.listStyleImage="url(fold.gif)"
		}
	}
}
if (ie4||ns6)
document.onclick=checkcontained

//-->
</script>
END;
	$this->setJavascript($strJavascript);
	}
	function setdefaultStyle(){
	$this->strStyle=<<<END
	<style>
<!--
#foldheader{cursor:pointer;cursor:hand ; font-weight:bold ;
//list-style-image:url(fold.gif)}
#foldinglist{list-style-image:url(list.gif)}
//-->
</style>
END;
}
	function setStyle($strStyle){$this->strStyle=$strStyle;}
	function getStyle(){return $this->strStyle;}
	function setElement(&$oElement){ $this->oarrElement=$oElement;}
	function getElement(){return $this->oarrElement;}
	
 	function showHtml(){
 		echo $this->strStyle;
 		echo $this->strJavascript;
 		echo "<ul>\n";
  		while (list($key,$value)=each($this->oarrElement))
		 {
 	//	echo "<ul>\n"; //*****you can change the tree when you activate it ******
  		echo '<li id="'.$this->strfoldheader.'">'.$value->strMenueblockName."</li>\n";
 		echo  '<ul id="'.$this->strfoldinglist.'" style="display:'.$this->bStatus.'" style=&{head};>'."\n";
		 
		 $value->showHtml();
		 echo "\n";
		 //		echo "</ul>\n";		//*****you can change the tree when you activate it ******		 
 
 		echo "</ul>\n";	// ********* You can change the tree if you deactivate it *******
		 }
 		echo "</ul>\n";				 
	  }
}	 
 ?>
Return current item: dyna_menue