00001 <?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
00027 class ProjectTree extends AbstractTree
00028 {
00029 var $projectId;
00030 var $userIsProjectAdmin = false;
00031
00032 function root()
00033 {
00034 $treeElement = new TreeElement();
00035 $treeElement->text = lang('GLOBAL_PROJECT');
00036 $treeElement->description = lang('GLOBAL_PROJECT');
00037 $treeElement->type = 'project';
00038 $treeElement->icon = 'project';
00039
00040 $this->addTreeElement( $treeElement );
00041 }
00042
00043
00044
00045 function pageelements( $id )
00046 {
00047 $page = new Page( $id );
00048 $page->load();
00049
00050 $template = new Template( $page->templateid );
00051
00052 foreach( $template->getElementIds() as $elementid )
00053 {
00054 $element = new Element( $elementid );
00055 $element->load();
00056
00057 if ( $element->isWritable() )
00058 {
00059 $treeElement = new TreeElement();
00060 $treeElement->text = $element->name;
00061 $treeElement->url = Html::url('main',
00062 'pageelement',
00063 $id,
00064 array('elementid'=>$elementid,
00065 REQ_PARAM_TARGETSUBACTION=>'edit'));
00066 $treeElement->icon = 'el_'.$element->type;
00067
00068 $treeElement->description = lang('EL_'.$element->type);
00069 if ( $element->desc != '' )
00070 $treeElement->description .= ' - '.Text::maxLaenge( 25,$element->desc );
00071 else
00072 $treeElement->description .= ' - '.lang('GLOBAL_NO_DESCRIPTION_AVAILABLE');
00073 $treeElement->target = 'cms_main';
00074
00075 if ( in_array($element->type,array('link','list','include') ) )
00076 {
00077 $treeElement->type = 'value';
00078 $value = new Value();
00079 $value->pageid = $page->pageid;
00080 $value->element = $element;
00081 $value->load();
00082 $treeElement->internalId = $value->valueid;
00083 }
00084
00085 $this->addTreeElement( $treeElement );
00086 }
00087 }
00088 }
00089
00090
00091 function value( $id )
00092 {
00093
00094 if ( $id != 0 )
00095 {
00096 $value = new Value();
00097 $value->loadWithId( $id );
00098
00099 $objectid = intval($value->linkToObjectId);
00100 if ( $objectid != 0 )
00101 {
00102 $object = new Object( $objectid );
00103 $object->load();
00104
00105 $treeElement = new TreeElement();
00106 $treeElement->text = $object->name;
00107 if ( in_array($object->getType(),array('page','folder')))
00108 {
00109 $treeElement->type = $object->getType();
00110 $treeElement->internalId = $object->objectid;
00111 }
00112 $treeElement->url = Html::url('main',$object->getType(),$objectid);
00113 $treeElement->icon = $object->getType();
00114
00115 $treeElement->description = lang('GLOBAL_'.$object->getType());
00116 if ( $object->desc != '' )
00117 $treeElement->description .= ' - '.Text::maxLaenge( 25,$object->desc );
00118 else
00119 $treeElement->description .= ' - '.lang('GLOBAL_NO_DESCRIPTION_AVAILABLE');
00120 $treeElement->target = 'cms_main';
00121
00122 $this->addTreeElement( $treeElement );
00123 }
00124 }
00125 }
00126
00127
00128 function link( $id )
00129 {
00130 $link = new Link( $id );
00131 $link->load();
00132
00133 if ( $link->isLinkToObject )
00134 {
00135 $o = new Object( $link->linkedObjectId );
00136 $o->load();
00137
00138 $treeElement = new TreeElement();
00139 $treeElement->internalId = $o->objectid;
00140 $treeElement->target = 'cms_main';
00141 $treeElement->text = Text::maxLaenge( 25,$o->name );
00142 $treeElement->description= lang( 'GLOBAL_'.$o->getType() ).' '.$id;
00143
00144 if ( $o->desc != '' )
00145 $treeElement->description .= ': '.$o->desc;
00146 else
00147 $treeElement->description .= ' - '.lang('GLOBAL_NO_DESCRIPTION_AVAILABLE');
00148
00149 $treeElement->url = Html::url('main',$o->getType(),$o->objectid );
00150 $treeElement->icon = $o->getType();
00151
00152
00153
00154 if ( $o->isPage )
00155 {
00156
00157
00158 if ( $o->hasRight( ACL_WRITE ) )
00159 $treeElement->type='pageelements';
00160 }
00161 $this->addTreeElement( $treeElement );
00162 }
00163 }
00164
00165
00170 function folder( $id )
00171 {
00172 global
00173 $SESS,
00174 $projectid;
00175
00176 $f = new Folder( $id );
00177 $t = time();
00178
00179 foreach( $f->getObjects() as $o )
00180 {
00181
00182 if ( !$o->hasRight( ACL_READ ) )
00183 continue;
00184
00185 $treeElement = new TreeElement();
00186 $treeElement->internalId = $o->objectid;
00187 $treeElement->target = 'cms_main';
00188 $treeElement->text = Text::maxLaenge( 25,$o->name );
00189 $treeElement->description= lang( 'GLOBAL_'.$o->getType() ).' '.$o->objectid;
00190
00191 if ( $o->desc != '' )
00192 $treeElement->description .= ': '.$o->desc;
00193 else
00194 $treeElement->description .= ' - '.lang('GLOBAL_NO_DESCRIPTION_AVAILABLE');
00195
00196 $treeElement->url = Html::url( 'main',$o->getType(),$o->objectid,array('readit'=>'__OID__'.$o->objectid.'__') );
00197 $treeElement->icon = $o->getType();
00198
00199
00200
00201 if ( $o->isLink )
00202 {
00203 $treeElement->type='link';
00204 }
00205
00206 if ( $o->isPage )
00207 {
00208
00209
00210 if ( $o->hasRight( ACL_WRITE ) )
00211 $treeElement->type='pageelements';
00212 }
00213
00214 if ( $o->isFile )
00215 {
00216 $file = new File( $o->objectid );
00217 $file->load();
00218
00219 if ( substr($file->mimeType(),0,6) == 'image/' )
00220 $treeElement->icon = 'image';
00221 else $treeElement->icon = 'file';
00222 }
00223
00224 if ( $o->isFolder )
00225 {
00226 $treeElement->type = 'folder';
00227 }
00228
00229
00230 $this->addTreeElement( $treeElement );
00231 }
00232 }
00233
00234
00235 function project()
00236 {
00237 $language = Session::getProjectLanguage();
00238 $model = Session::getProjectModel();
00239 $user = Session::getUser();
00240
00241 $project = Session::getProject();
00242 $this->projectid = $project->projectid;
00243
00244
00245 $f = new Folder();
00246 $f->projectid = $this->projectid;
00247 $folder = new Folder( $project->getRootObjectId() );
00248 unset( $f );
00249 $folder->load();
00250
00251
00252
00253
00254 if ( $folder->hasRight( ACL_PROP ) )
00255 $this->userIsProjectAdmin = true;
00256
00257 if ( $folder->hasRight( ACL_READ ) )
00258 {
00259 $treeElement = new TreeElement();
00260
00261 $treeElement->text = lang('FOLDER_ROOT');
00262 $treeElement->description = lang('FOLDER_ROOT_DESC');
00263 $treeElement->icon = 'folder';
00264 $treeElement->url = Html::url( 'main','folder',$folder->objectid );
00265 $treeElement->target = 'cms_main';
00266 $treeElement->type = 'folder';
00267 $treeElement->internalId = $folder->objectid;
00268 $this->addTreeElement( $treeElement );
00269 }
00270
00271
00272 if ( $this->userIsProjectAdmin )
00273 {
00274
00275 $treeElement = new TreeElement();
00276 $treeElement->text = lang('GLOBAL_TEMPLATES');
00277 $treeElement->url = Html::url('main','template',0,array(REQ_PARAM_TARGETSUBACTION=>'listing'));
00278 $treeElement->description= lang('GLOBAL_TEMPLATES_DESC');
00279 $treeElement->icon = 'template_list';
00280 $treeElement->target = 'cms_main';
00281 $treeElement->type = 'templates';
00282 $this->addTreeElement( $treeElement );
00283 }
00284
00285
00286
00287 $treeElement = new TreeElement();
00288 $treeElement->description= '';
00289 $treeElement->text = lang('GLOBAL_LANGUAGES');
00290 $treeElement->url = Html::url('main','language',0,array(REQ_PARAM_TARGETSUBACTION=>'listing'));
00291 $treeElement->icon = 'language_list';
00292 $treeElement->description= lang('GLOBAL_LANGUAGES_DESC');
00293 $treeElement->target = 'cms_main';
00294
00295
00296 if ( $this->userIsProjectAdmin )
00297 $treeElement->type = 'languages';
00298
00299 $this->addTreeElement( $treeElement );
00300
00301
00302
00303 $treeElement = new TreeElement();
00304 $treeElement->description= '';
00305
00306
00307 if ( $this->userIsProjectAdmin )
00308 $treeElement->type = 'models';
00309
00310 $treeElement->description= lang('GLOBAL_MODELS_DESC');
00311 $treeElement->text = lang('GLOBAL_MODELS');
00312 $treeElement->url = Html::url('main','model',0,array(REQ_PARAM_TARGETSUBACTION=>'listing'));
00313 $treeElement->icon = 'model_list';
00314 $treeElement->target = 'cms_main';
00315 $this->addTreeElement( $treeElement );
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327 $treeElement = new TreeElement();
00328 $treeElement->text = lang('GLOBAL_SEARCH');
00329 $treeElement->url = Html::url('main','search');
00330 $treeElement->icon = 'search';
00331 $treeElement->description = lang('GLOBAL_SEARCH_DESC');
00332 $treeElement->target = 'cms_main';
00333 $this->addTreeElement( $treeElement );
00334
00335 }
00336
00337
00338 function templates()
00339 {
00340 foreach( Template::getAll() as $id=>$name )
00341 {
00342 $treeElement = new TreeElement();
00343
00344 $t = new Template( $id );
00345 $t->load();
00346 $treeElement->text = $t->name;
00347 $treeElement->url = Html::url('main','template',$id,array(REQ_PARAM_TARGETSUBACTION=>'src'));
00348 $treeElement->icon = 'template';
00349 $treeElement->target = 'cms_main';
00350 $treeElement->internalId = $id;
00351 $treeElement->type = 'template';
00352 $treeElement->description = $t->name.' ('.lang('GLOBAL_TEMPLATE').' '.$id.'): '.htmlentities(Text::maxLaenge( 40,$t->src ));
00353 $this->addTreeElement( $treeElement );
00354 }
00355 }
00356
00357
00358 function template( $id )
00359 {
00360
00361 $t = new Template( $id );
00362 $t->load();
00363
00364
00365
00366 foreach( $t->getElementIds() as $elementid )
00367 {
00368 $e = new Element( $elementid );
00369 $e->load();
00370
00371
00372 if ( $e->type == 'code' && !$this->userIsAdmin )
00373 continue;
00374
00375 $treeElement = new TreeElement();
00376 $treeElement->text = $e->name;
00377 $treeElement->url = Html::url('main','element',$elementid );
00378 $treeElement->icon = 'el_'.$e->type;
00379
00380 if ( $e->desc == '' )
00381 $desc = lang('GLOBAL_NO_DESCRIPTION_AVAILABLE');
00382 else
00383 $desc = $e->desc;
00384 $treeElement->description = $e->name.' ('.lang('EL_'.$e->type).'): '.Text::maxLaenge( 40,$desc );
00385 $treeElement->target = 'cms_main';
00386 $this->addTreeElement( $treeElement );
00387 }
00388 }
00389
00390
00394 function languages()
00395 {
00396
00397
00398 $l = Session::getProjectLanguage();
00399 $languages = $l->getAll();
00400
00401 foreach( $languages as $languageid=>$name )
00402 {
00403 $treeElement = new TreeElement();
00404 $treeElement->text = $name;
00405 $treeElement->url = Html::url('main','language',$languageid,
00406 array(REQ_PARAM_TARGETSUBACTION=>'edit') );
00407 $treeElement->icon = 'language';
00408 $treeElement->description = '';
00409 $treeElement->target = 'cms_main';
00410 $this->addTreeElement( $treeElement );
00411 }
00412 }
00413
00414
00415
00416
00417 function models()
00418 {
00419 $m = Session::getProjectModel();
00420 $models = $m->getAll();
00421
00422 foreach( $models as $id=>$name )
00423 {
00424 $treeElement = new TreeElement();
00425 $treeElement->text = $name;
00426 $treeElement->url = Html::url('main','model',$id,
00427 array(REQ_PARAM_TARGETSUBACTION=>'edit'));
00428 $treeElement->icon = 'model';
00429 $treeElement->description = '';
00430 $treeElement->target = 'cms_main';
00431 $this->addTreeElement( $treeElement );
00432 }
00433 }
00434
00435
00436 function other()
00437 {
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452 $treeElement = new TreeElement();
00453 $treeElement->text = lang('GLOBAL_SEARCH');
00454 $treeElement->url = Html::url('main','search');
00455 $treeElement->icon = 'search';
00456 $treeElement->description = lang('GLOBAL_SEARCH_DESC');
00457 $treeElement->target = 'cms_main';
00458 $this->addTreeElement( $treeElement );
00459
00460
00461 $treeElement = new TreeElement();
00462 $treeElement->text = lang('USER_YOURPROFILE');
00463 $treeElement->url = Html::url('profile','edit');
00464 $treeElement->icon = 'user';
00465 $treeElement->description = lang('USER_PROFILE_DESC');
00466 $treeElement->target = 'cms_main_main';
00467 $this->addTreeElement( $treeElement );
00468
00469
00470 $treeElement = new TreeElement();
00471 $treeElement->text = lang('GLOBAL_PROJECTS');
00472 $treeElement->url = Html::url('index','projectmenu');
00473 $treeElement->icon = 'project';
00474 $treeElement->description = lang('GLOBAL_PROJECTS');
00475 $treeElement->target = 'parent';
00476 $this->addTreeElement( $treeElement );
00477 }
00478 }
00479
00480 ?>