Location: PHPKode > projects > Content*Builder > modules/menu2/menu_nestedSet_dhtml.php
<?php
	$tpl->assign("MODULE_IMG_DIR", $location."templates/images/");
	
	require_once("HTML/TreeMenu.php");
	
	/* alles ausgeben 
	if(empty($COLUMN_restriction)) {
		$nav->getMenu();
	} else {
		$base = $COLUMN_select->fid;
		$restrictStatus = $COLUMN_select->status;
		$nav->setStartLevel($COLUMN_select->status);
		$children = $nav->folder[$restrictStatus][$base]['children'];
		$nav->getChildren($children, ($restrictStatus + 1), $base);
	}
	*/
	
	/*
	* Ermittlung der Default Sprache ... wird leider noch als article Option gesetzt
	*/
	$dlQuery = mysql_fetch_array(mysql_query("SELECT * FROM ".TABLE."_options WHERE name = 'default_lang' AND module = 'art'"));
	$defaultLanguage = $dlQuery[value];
	
	/*
	* Wenn im Cookie ne andere Sprache steht, diese nehmen
	*/
	if(!empty($_COOKIE['main_language'])) {
		if(ereg("^[0-9]*$", $_COOKIE['main_language'])) {
			$defaultLanguage = $_COOKIE['main_language'];
		}
	}
	
	// Article Liste laden
	if($archive == 1) { 
		$artAmount = 10000; 
	} else { 
		if(!$cbOption->getSingleOption("artAmount")) {
			$artAmount = 10;
		} else {
			$artAmount = $cbOption->getSingleOption("artAmount");
		}
	}
	
	if(!is_object($artOption)) {
		//Ableitung des Article Option Objektes
		$artOption = new CBOption();
		$artOption->setModule("art");
		$artOption->getOptionList();
	}
	
	if($load == "article2") {
		/* Implementation of stage rules in module article2 */
		$today = date( "Ymd", time() );
		if($cbOption->getSingleOption("timepost")) {
			if(!$preview) {
				$stageStatement = "AND general.stage = '3' AND general.publishfrom <= '".$today."' AND (general.publishto >= '".$today."' OR general.publishto = '00000000')";
			} else {
				$stageStatement = "";
			}
		} else {
			$stageStatement = "AND general.stage = '3'";
		}
		
		/*
		* Sortier Methode
		*/
		$sortMethod = $artOption->getSingleOption("sortMethod");
		switch($sortMethod){
			case ART_SORT_NUMERIC: 
				 $sortMethodString = "ORDER BY general.order_num ASC";
				 break;
			default:
				 $sortMethodString = "ORDER BY general.datetime DESC";
		} // switch
		
		$contentWhere = "WHERE content.ide = general.ide AND ((relFolder.folderID = '$openfolder' AND relFolder.articleID = general.ide) OR general.folderID = '$openfolder') $stageStatement AND content.language = '$defaultLanguage'";
		
		$query = "SELECT content.ide, content.language, content.title, general.datetime FROM ".TABLE."_art_content AS content, ".TABLE."_art_general AS general LEFT JOIN ".TABLE."_art_folder AS relFolder ON general.ide = relFolder.articleID $contentWhere GROUP BY general.ide $sortMethodString LIMIT 0,$artAmount";
		$result = mysql_query($query);
		
		$noArticles = true;
		while($artData = mysql_fetch_object($result)) {
			$title = substr($artData->title, 0, 20);
			if(strlen($artData->title > 20)) {
				$title .= "...";
			}
			$artTitle[]		= $title;
			$artIde[]		= $artData->ide;
			$artFolderId[]	= $generalFolderID[$artData->ide];
			$noArticles = false;
		}
		
		$artType        = "article2";		
	} else {
		$query = mysql_query("SELECT title, ide, folder FROM ".TABLE."_article WHERE folder = '$openfolder' AND stage = '3' ORDER BY datum DESC LIMIT 0,$artAmount");
		$artTitle = array();
		$artIde = array();
		$artFolderId = array();
		
		$noArticles = true;
		while($articles = mysql_fetch_array($query)) {
			$title = substr($articles[title], 0, 20);
			if(strlen($articles[title]) > 20) {
				$title .= "...";
			}
			$artTitle[]		= $title;
			$artIde[]		= $articles[ide];
			$artFolderId[]	= $articles[folder];
			$noArticles = false;
		}
		unset($articles);
		$artType        = "article";
			
	}
	
	/* 
	* Initialisierung der NeSet Array's für das 
	* Folder Nested Set Objekt 
	*/
	$folderParams = array (
		'table'  => TABLE.'_columns',
		'id'     => 'fid',
		'parent' => 'mfolder',
		'root'   => 'rootID',
		'l'      => 'leftID',
		'r'      => 'rightID',
		'level'  => 'level',
		'norder' => 'order_num'
	);
	
	$folderAdditional = array (
		'name'          => 'fname',
		'status'        => 'status',
		'writestatus'   => 'writestatus',
		'description'   => 'describt',
		'loadurl'       => 'loadurl',
		'usersallowed'  => 'usersallowed',
		'groupsAllowed' => 'groupsAllowed',
		'skin'          => 'skin'
	);
	
	$nestedSet = CB_NestedSet::factory($folderParams, $folderAdditional);
	
	$additionalSQL = array (
		"field" => ", lang.text, lang.languageID",
		"join"  => "LEFT JOIN ".TABLE."_language AS lang ON lang.typeID = n.fid AND lang.type = 'column' AND lang.languageID = '$defaultLanguage'"
	);
	
	$folderMenuAllNodes = $nestedSet->getAllNodes($openfolder, true, $additionalSQL);
	
	class CB_TreeMenu_DHTML extends HTML_TreeMenu_DHTML {
		/**
	    * Prints the HTML generated by the toHTML() method.
	    * toHTML() must therefore be defined by the derived
	    * class.
	    *
	    * @access public
	    * @param  array  Options to set. Any options taken by
	    *                the presentation class can be specified
	    *                here.
	    */
	    function printMenu($options = array())
	    {
	        foreach ($options as $option => $value) {
	            $this->$option = $value;
	        }
	
	        return $this->toHTML();
	    }
	}
	
	if($folderMenuAllNodes != false) {
		$thisRoot = $folderMenuAllNodes[$openfolder][root];
		
		$folderTreeMenu =& new HTML_TreeMenu();
		foreach($folderMenuAllNodes as $v) {
			$_fStatus = false;
            if($v[root] == $GLOBALS[openfolderData][root] && $v[l] <= $GLOBALS[openfolderData][l] && $v[r] >= $GLOBALS[openfolderData][r]) {
		        $_fStatus = true;
		    }
			
			if($v['loadurl'] != "") {
				if(!ereg("^http://", $v['loadurl'])) {
					$_link = $rel."index.php"."?openfolder=".$v[id]."&load=".$v['loadurl'];
				} else {
					$_link = $v['loadurl'];
				}
			} else {
				$_link = $rel."index.php"."?openfolder=".$v[id];
			}
						
			$_fName = $v[name];
			if($v[text] != "") {
				$_fName = $v[text];
			}
						
			$icon         = 'folder.gif';
			$expandedIcon = 'folder-expanded.gif';

			$nodeName  = "node".$v[id];
			$$nodeName = & new HTML_TreeNode(array('text' => $_fName, 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'link' => $_link, 'expanded' => $_fStatus));
			
			if($v[id] != $v[root]) {
				$nodeNameParent  = "node".$v['parent'];
				$$nodeNameParent->addItem(&$$nodeName);
			} else {
				$folderTreeMenu->addItem(&$$nodeName);
			}
			
			if($v[id] == $openfolder) {
				if(!$noArticles) {
					foreach($artIde as $k => $artID) {
						$$nodeName->addItem(new HTML_TreeNode(array('text' => $artTitle[$k], 'link' => $rel.$PHP_SELF."?openfolder=".$v[id]."&sub=full&id=".$artID)));
					}
				}
			}
		}
		
		// Create the presentation class
		$_imageDir = $location."templates/imagesTreeAlt/";
		$folderTreeMenuObject = &new CB_TreeMenu_DHTML($folderTreeMenu, array('images' => $_imageDir, 'defaultClass' => 'treeMenuDefault'));
		$folderTreeMenuContent = $folderTreeMenuObject->printMenu();
		$tpl->assign("folderTreeMenu", $folderTreeMenuContent);
	}
	$tpl->display("menu_dhtml.template");
?>
Return current item: Content*Builder