AbstractTree.class.php
gehe zur Dokumentation dieser Datei00001 <?php
00002 #
00003 # DaCMS Content Management System
00004 # Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
00005 #
00006 # This program is free software; you can redistribute it and/or
00007 # modify it under the terms of the GNU General Public License
00008 # as published by the Free Software Foundation; either version 2
00009 # of the License, or (at your option) any later version.
00010 #
00011 # This program is distributed in the hope that it will be useful,
00012 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014 # GNU General Public License for more details.
00015 #
00016 # You should have received a copy of the GNU General Public License
00017 # along with this program; if not, write to the Free Software
00018 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00019 #
00020
00028 class AbstractTree
00029 {
00033 var $elements = array();
00034
00035 var $tempElements = array();
00036 var $userIsAdmin = false;
00037
00038 var $autoOpen = array(0,1);
00039
00044 var $maxId;
00045
00046
00047 function AbstractTree()
00048 {
00049
00050 $user = Session::getUser();
00051 $this->userIsAdmin = $user->isAdmin;
00052
00053
00054 $this->root();
00055 $this->elements[0] = $this->tempElements[0];
00056 $this->tempElements = array();
00057 $this->maxId = 0;
00058
00059 foreach( $this->autoOpen as $openId )
00060 $this->open($openId);
00061 }
00062
00068 function open( $elementId )
00069 {
00070 $funcName = $this->elements[$elementId]->type;
00071 if ( empty($funcName) )
00072 return;
00073
00074 $this->$funcName( $this->elements[$elementId]->internalId );
00075
00076
00077 if ( count( $this->tempElements ) == 0 )
00078 $this->elements[$elementId]->type = '';
00079
00080 foreach( $this->tempElements as $treeElement )
00081 {
00082 $this->maxId++;
00083 $this->elements[$elementId]->subElementIds[] = $this->maxId;
00084 $this->elements[$this->maxId] = $treeElement;
00085 }
00086
00087 if ( count($this->tempElements)==1 )
00088 {
00089 $this->tempElements = array();
00090 $this->open($this->maxId);
00091 }
00092
00093 $this->tempElements = array();
00094 }
00095
00096
00102 function close( $elementId )
00103 {
00104 $this->elements[$elementId]->subElementIds = array();
00105 }
00106
00107
00112 function addTreeElement( $treeElement )
00113 {
00114 $this->tempElements[] = $treeElement;
00115 }
00116
00117
00118 }
00119
00120 ?>