Location: PHPKode > projects > Content*Builder > contentbuilder/plugins/media_manager/mediaTree.inc.php
<?php
	/**
	*@access		public
	*@author		Jörg Stöber <hide@address.com>
	*@version	 	1.0 17/08/2002 19:00
	**/
	$query    = mysql_query("SELECT * FROM ".TABLE."_user WHERE name = '$HTTP_SESSION_VARS[user]'");
	$result   = mysql_fetch_array($query);
	
	if(empty($_SESSION[mm_nodesOpen])) {
		$mm_nodesOpen = 0;
		session_register("mm_nodesOpen");
	}	
	if(isset($nodesOpen)) {
		$mm_nodesOpen = $nodesOpen;
		session_register("mm_nodesOpen");
	}
	
	// Ermittlung der Branch ID
	$noBranchID = false; 
	if(isset($bid) && ereg("(^[1-9]?[0-9]*$)", $bid))  { $branchID = $bid; } else { $noBranchID = true; }
	
	$myMedia = new MediaManagement();
	
	/*
	* Smarty Template für das Medien Management ableiten
	*/
	$mediaTPL = new Smarty;
	$mediaTPL->template_dir = CB_TEMPLATE_DIR;
	$mediaTPL->compile_dir  = CB_TEMPLATE_DIR."compiled/";
	
	$myMedia->mediaText = $media;
	$myMedia->setUserID($cbUserID);
	$myMedia->setBranchID($branchID);
	$myMedia->setOptionObject($cbOption);
	$myMedia->setTemplateObject($mediaTPL);
	
	$myMedia->tpl->assign("PHP_SELF", $PHP_SELF);
	$myMedia->tpl->assign("URLIDENT", $config['urlIdent']);
	$myMedia->tpl->assign("PLUGINLOCATION", $pluginLocation);
	$myMedia->tpl->assign("SID", "&".SID);
	$myMedia->tpl->assign("SUB", $sub);
	$myMedia->tpl->assign("BID", $branchID);
	
	// Funtkion zum Löschen von Kategorien
	if(isset( $_POST[delbox])) $myMedia->deleteBranch($_POST[delbox]);	
	// Funktion zum Umbenennen von Verzeichnissen
	if(!empty($MEDIA_renameStatus)) {
		$renameArr = array();
		$renameArr['branchID'] = $bid;
		$renameArr['newName']  = $MEDIA_branchName;
		$myMedia->renameBranch($renameArr);
	}
		
	$tpl->assign("BID", $branchID);
			
	// Including the fileTree class
	include($cbDirSystem."fileTree.class.php");
	class MyTree extends FileTree {
		
		var $nodeLevel, $nodeStatus, $nodeID, $nodeSpace, $nodeSort, $nodeMain = array();
		var $lastLevel  = 1;
		var $openNode;
		var $lastNode, $nextNode = array();
				
		function printTree($branchID, $name, $level) {
			$this->nodeName[] = $name;
			$this->nodeID[]	  = $branchID;
			if ($branchID == $this->openNode) { 
				$this->nodeMain[] = "1"; 
			} else { 
				$this->nodeMain[] = "0"; 
			}
			$this->nodeSpace[]  = 20 * ($level - 1); 
			$this->nodeLevel[]	= $level;
			$this->nodeSort[]	= $this->tree[$level][$branchID]['sort'];
		}
		
		function setOpenNode( $branchID ) {
			$this->openNode = $branchID;
		}
	}
	
	
	
	// Anzeige von Link Collapse all / Expand all
	if($mm_nodesOpen == 0) {
		$nodesText = $media["openAllNodes"];
		$nodesVal  = 1;
	} else {
		$nodesText = $media["collapseAllNodes"];
		$nodesVal  = 0;
	}
	
	if(isset($action)) {
		if($action == "moddetails") {
			$display = "details";
		} else {
			if(!ereg("(^[a-zA-Z0-9_]*$)", $_POST[module])) $_POST[module] = "";
			$_POST[description] = nl2br($_POST[description]);			
			$details = array(
				"name"        => $_POST[name],
				"description" => $_POST[description],
				"module"      => $_POST[module],
				"parameter"   => $_POST[parameter]
			);
			$myMedia->addDetails($details, $branchID);
			$display = "overview";
		}
	}
	
	/* Kategorie Erzeugung 
	*  Formular für die Kategorie Erzeugung
	*/
	if(isset($addBranch)) {
		if(($addBranch == "sub") && (!empty($subID))) {
			$query = mysql_query("SELECT * FROM ".TABLE."_mm_folder WHERE branchID = '$subID'");
			if(!$query) {
				$addBranch = "main";
				unset($subID);
			}
		}
		if(empty($MEDIA_addBranch_perform)) {
			$display = "addBranch";
		} else {
			if($addBranch == 'main') {
				$myMedia->addMainBranch($_POST['MEDIA_addBranchText'], $_POST['MEDIA_addBranchName']);
			} elseif($addBranch == 'sub') {
				$subID = $MEDIA_subID;
				$addSubArray       = array();
				$addSubBranchNames = array();
				
				/* Array's erzeugen, addSubBranch() akzeptiert nur Array's */
				$addSubBranchNames[]       = $_POST['MEDIA_addBranchName'];
				$addSubArray[$MEDIA_subID] = $_POST['MEDIA_addBranchText'];
				
				/* Einfügen des Zweiges */
				$myMedia->addSubBranch($addSubArray, $addSubBranchNames);
			}
			$display = "overview";
		}
	}
	
	if(empty($display)) {
		$display = "overview";
	}
	if($display == "overview") {
		$nav = new MyTree;
		$nav->setOpenNode($branchID);
		if($_SESSION[mm_nodesOpen] == 0) $nav->getOpennodes($branchID);
		$nav->getTree();
		
		$tpl->assign("overview",
			array(  "TXT_NODES"     => $nodesText,
					"NODES_VALUE"   => $nodesVal
			)
		);
	
		$tpl->assign("category_tree",
			array ( "TXT_ADD" => $media['add'],
					"NAME"    => $nav->nodeName,
					"ID"      => $nav->nodeID,
					"SPACE"   => $nav->nodeSpace,
					"SORT"    => $nav->nodeSort,
					"MAIN"    => $nav->nodeMain
			)
		);
	
		$tpl->assign("overview_set", "1");
	} elseif ($display == "details") {
		$dataQuery = mysql_fetch_object(mysql_query("SELECT * FROM ".TABLE."_mm_folder WHERE branchID = '$branchID'"));
		
		$tpl->assign("details_form",
			array(  "NAME"          => $dataQuery->name,
					"MODULE"        => $dataQuery->module,
					"PARAMETER"     => $dataQuery->parameter,
					"DESCRIPTION"   => $dataQuery->description,
					"BRANCHNAME"    => $dataQuery->branchName
			)
		);
		$tpl->assign("details_form_set", "1");
	} elseif ($display == "addBranch") {
		if($addBranch == "sub") {
			$bQuery = mysql_fetch_array(mysql_query("SELECT * FROM ".TABLE."_mm_folder WHERE branchID = '$subID'"));
			$dataArr['txt_add']     = $media['cataddsub'];
			$dataArr['name']        = $bQuery[name];
			$dataArr['bname']       = $bQuery[branchName];
			$dataArr['bid']         = $bQuery[branchID];
			$tpl->assign("addBranch_form_bInfo_set", "1");
		} else {
			$dataArr['txt_add']     = $media['cataddmain'];
		}
		
		$tpl->assign("addBranch_form",
			array(  "TYPE"			=> $addBranch,
					"SUBID"			=> $subID
			)
		);
		$tpl->assign("addBranch_form_bInfo",
			array(  "TXT_ADD"       => $dataArr[txt_add],
					"NAME"          => $dataArr[name],
					"DIRECTORY"     => $dataArr[bname],
					"BID"           => $dataArr[bid]
			)
		);
		$tpl->assign("addBranch_form_set", "1");
	}
	
	$mainPluginContent[]  = $tpl->fetch($config['templates']."mediaTree.template", null, "pluginMedia".$cbUserID);
	$mainMessageContent[] = $tpl->fetch($config['templates']."messages.template", null, "pluginMedia".$cbUserID);
?>
Return current item: Content*Builder