00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00189 class FolderAction extends ObjectAction
00190 {
00191 var $defaultSubAction = 'show';
00192 var $folder;
00193
00194 function FolderAction()
00195 {
00196 if ( $this->getRequestId() != 0 )
00197 {
00198 $this->folder = new Folder( $this->getRequestId() );
00199 $this->folder->load();
00200 Session::setObject( $this->folder );
00201 }
00202 else
00203 {
00204 $this->folder = Session::getObject();
00205 }
00206
00207
00208 $this->lastModified( $this->folder->lastchangeDate );
00209 }
00210
00211
00212
00217 function createnew()
00218 {
00219 global $conf;
00220 $type = $this->getRequestVar('type' );
00221
00222 switch( $type )
00223 {
00224 case 'folder':
00225 $name = $this->getRequestVar('folder_name');
00226
00227 if ( !empty($name) )
00228 {
00229 $f = new Folder();
00230 $f->name = $name;
00231 $f->parentid = $this->folder->objectid;
00232 $f->add();
00233 $this->folder->setTimestamp();
00234 $this->addNotice('folder',$f->name,'ADDED','ok');
00235 }
00236 else
00237 {
00238 $this->addValidationError('folder_name');
00239 $this->callSubAction('create');
00240 }
00241 break;
00242
00243 case 'file':
00244 $upload = new Upload();
00245
00246 if ( !$upload->isValid() )
00247 {
00248 $this->addValidationError('file','COMMON_VALIDATION_ERROR',array(),$upload->error);
00249 $this->callSubAction('createfile');
00250 return;
00251 }
00252
00253 elseif ( $upload->size > $this->maxFileSize() )
00254 {
00255
00256 $this->addValidationError('file','MAX_FILE_SIZE_EXCEEDED');
00257 $this->callSubAction('createfile');
00258 return;
00259 }
00260 elseif( $upload->size > 0 )
00261 {
00262 $file = new File();
00263 $file->desc = '';
00264 $file->filename = $upload->filename;
00265 $file->name = $upload->filename;
00266 $file->extension = $upload->extension;
00267 $file->size = $upload->size;
00268 $file->parentid = $this->folder->objectid;
00269
00270 $file->value = $upload->value;
00271
00272 $file->add();
00273 $this->folder->setTimestamp();
00274 $this->addNotice('file',$file->name,'ADDED','ok');
00275 }
00276
00277 break;
00278
00279 case 'page':
00280
00281 $name = $this->getRequestVar('page_name');
00282 if ( !empty($name) )
00283 {
00284 $page = new Page();
00285 $page->name = $name;
00286 $page->templateid = $this->getRequestVar('page_templateid');
00287 $page->parentid = $this->folder->objectid;
00288 $page->add();
00289 $this->folder->setTimestamp();
00290
00291 $this->addNotice('page',$page->name,'ADDED','ok');
00292 }
00293 else
00294 {
00295 $this->addValidationError('page_name');
00296 $this->callSubAction('create');
00297 }
00298 break;
00299
00300 case 'link':
00301
00302 $name = $this->getRequestVar('link_name');
00303 if ( !empty($name) )
00304 {
00305 $link = new Link();
00306 $link->name = $name;
00307 $link->parentid = $this->folder->objectid;
00308
00309 $link->isLinkToObject = false;
00310 $link->url = $name;
00311
00312 $link->add();
00313 $this->folder->setTimestamp();
00314
00315 $this->addNotice('link',$link->name,'ADDED','ok');
00316 }
00317 else
00318 {
00319 $this->addValidationError('link_name');
00320 $this->callSubAction('create');
00321 }
00322
00323 break;
00324
00325 default:
00326 $this->addValidationError('type');
00327 $this->callSubAction('create');
00328
00329 }
00330
00331 }
00332
00333
00334
00335 function createnewfolder()
00336 {
00337 $type = $this->getRequestVar('type' );
00338 $name = $this->getRequestVar('name' );
00339 $filename = $this->getRequestVar('filename' );
00340 $description = $this->getRequestVar('description');
00341
00342 if ( !empty($name) )
00343 {
00344 $f = new Folder();
00345 $f->name = $name;
00346 $f->filename = $name;
00347 $f->desc = $description;
00348 $f->parentid = $this->folder->objectid;
00349
00350 $f->add();
00351 $this->addNotice('folder',$f->name,'ADDED','ok');
00352 }
00353 else
00354 {
00355 $this->addValidationError('name');
00356 $this->callSubAction('createfolder');
00357 }
00358
00359 $this->folder->setTimestamp();
00360 }
00361
00362
00363
00364 function createnewfile()
00365 {
00366 $type = $this->getRequestVar('type' );
00367 $name = $this->getRequestVar('name' );
00368 $filename = $this->getRequestVar('filename' );
00369 $description = $this->getRequestVar('description');
00370
00371 $file = new File();
00372
00373 if ( $this->hasRequestVar('url') )
00374 {
00375 $url = $this->getRequestVar('url');
00376 $http = new Http();
00377 $http->setUrl( $url );
00378
00379 $ok = $http->request();
00380
00381 if ( !$ok )
00382 {
00383 $this->addValidationError('url','COMMON_VALIDATION_ERROR',array(),$http->error);
00384 $this->callSubAction('createfile');
00385 return;
00386 }
00387
00388 $file->desc = $description;
00389 $file->filename = basename($url);
00390 $file->name = !empty($name)?$name:basename($url);
00391 $file->size = strlen($http->body);
00392 $file->value = $http->body;
00393 $file->parentid = $this->folder->objectid;
00394 }
00395 else
00396 {
00397 $upload = new Upload();
00398
00399 if ( !$upload->isValid() )
00400 {
00401 $this->addValidationError('file','COMMON_VALIDATION_ERROR',array(),$upload->error);
00402 $this->callSubAction('createfile');
00403 return;
00404 }
00405
00406 $file->desc = $description;
00407 $file->filename = $upload->filename;
00408 $file->name = !empty($name)?$name:$upload->filename;
00409 $file->extension = $upload->extension;
00410 $file->size = $upload->size;
00411 $file->parentid = $this->folder->objectid;
00412
00413 $file->value = $upload->value;
00414 }
00415
00416 $file->add();
00417 $this->addNotice('file',$file->name,'ADDED','ok');
00418
00419 $this->folder->setTimestamp();
00420
00421 $this->setTemplateVar('tree_refresh',true);
00422 }
00423
00424
00425
00426 function createnewlink()
00427 {
00428 $type = $this->getRequestVar('type' );
00429 $name = $this->getRequestVar('name' );
00430 $filename = $this->getRequestVar('filename' );
00431 $description = $this->getRequestVar('description');
00432
00433 if ( !empty($name) )
00434 {
00435 $link = new Link();
00436 $link->name = $name;
00437 $link->desc = $description;
00438 $link->parentid = $this->folder->objectid;
00439
00440 $link->isLinkToObject = false;
00441 $link->url = $this->getRequestVar('name');
00442
00443 $this->addNotice('link',$link->name,'ADDED','ok');
00444
00445 $link->add();
00446 }
00447 else
00448 {
00449 $this->addValidationError('name');
00450 $this->callSubAction('createlink');
00451 return;
00452 }
00453
00454 $this->folder->setTimestamp();
00455 }
00456
00457
00458
00459 function createnewpage()
00460 {
00461 $type = $this->getRequestVar('type' );
00462 $name = $this->getRequestVar('name' );
00463 $filename = $this->getRequestVar('filename' );
00464 $description = $this->getRequestVar('description');
00465
00466 if ( $this->getRequestVar('name') != '' )
00467 {
00468 $page = new Page();
00469 $page->name = $name;
00470 $page->desc = $description;
00471 $page->filename = $filename;
00472 $page->templateid = $this->getRequestVar('templateid');
00473 $page->parentid = $this->folder->objectid;
00474
00475 $this->addNotice('page',$page->name,'ADDED','ok');
00476 $page->add();
00477 }
00478 else
00479 {
00480 $this->addValidationError('name');
00481 $this->callSubAction('createpage');
00482 return;
00483 }
00484
00485 $this->folder->setTimestamp();
00486 }
00487
00488
00489
00494 function saveprop()
00495 {
00496
00497 if ( $this->getRequestVar('name') != '' )
00498 $this->folder->name = $this->getRequestVar('name' );
00499 elseif ($this->getRequestVar('filename') != '' )
00500 $this->folder->name = $this->getRequestVar('filename');
00501 else
00502 {
00503 $this->addValidationError('name');
00504 $this->addValidationError('filename');
00505 $this->callSubAction('prop');
00506 return;
00507 }
00508
00509 $this->folder->filename = $this->getRequestVar('filename' );
00510 $this->folder->desc = $this->getRequestVar('description');
00511 $this->folder->save();
00512 $this->addNotice($this->folder->getType(),$this->folder->name,'PROP_SAVED','ok');
00513 }
00514
00515
00520 function delete()
00521 {
00522 if ( $this->getRequestVar('delete') != '' )
00523 {
00524
00525 $this->folder->delete();
00526 $this->addNotice($this->folder->getType(),$this->folder->name,lang('DELETED'),'ok');
00527 }
00528 }
00529
00530
00531
00532 function changesequence()
00533 {
00534 $ids = $this->folder->getObjectIds();
00535 $seq = 0;
00536 foreach( $ids as $id )
00537 {
00538 $seq++;
00539
00540
00541 if ( $id == $this->getRequestVar('objectid1') )
00542 $id = $this->getRequestVar('objectid2');
00543 elseif ( $id == $this->getRequestVar('objectid2') )
00544 $id = $this->getRequestVar('objectid1');
00545
00546 $o = new Object( $id );
00547 $o->setOrderId( $seq );
00548
00549 unset( $o );
00550 }
00551
00552 $this->addNotice($this->folder->getType(),$this->folder->name,'SEQUENCE_CHANGED','ok');
00553 $this->folder->setTimestamp();
00554
00555
00556 $this->callSubAction('order');
00557
00558 }
00559
00560
00567 function edit()
00568 {
00569 $type = $this->getRequestVar('type');
00570
00571 switch( $type )
00572 {
00573 case 'move':
00574 case 'copy':
00575 case 'link':
00576
00577
00578 $otherfolder = array();
00579 foreach( $this->folder->getAllFolders() as $id )
00580 {
00581 $f = new Folder( $id );
00582
00583
00584
00585
00586
00587
00588 if ( ( $type=='link' && $f->hasRight( ACL_CREATE_LINK ) ) ||
00589 ( ( $type=='move' || $type == 'copy' ) &&
00590 ( $f->hasRight(ACL_CREATE_FOLDER) || $f->hasRight(ACL_CREATE_FILE) || $f->hasRight(ACL_CREATE_PAGE) ) ) )
00591
00592 $otherfolder[$id] = FILE_SEP.implode( FILE_SEP,$f->parentObjectNames(false,true) );
00593 }
00594
00595
00596 asort( $otherfolder );
00597
00598 $this->setTemplateVar('folder',$otherfolder);
00599
00600 break;
00601
00602 case 'archive':
00603 $this->setTemplateVar('ask_filename','');
00604 break;
00605
00606 case 'delete':
00607 $this->setTemplateVar('ask_commit','');
00608 break;
00609
00610 default:
00611 exit("trouble");
00612
00613 }
00614
00615 $ids = $this->folder->getObjectIds();
00616 $objectList = array();
00617
00618 foreach( $ids as $id )
00619 {
00620
00621 if ( !$this->hasRequestVar('obj'.$id) )
00622 continue;
00623
00624 $o = new Object( $id );
00625 $o->load();
00626
00627
00628
00629 if ( $type == 'copy' && $o->hasRight( ACL_READ ) ||
00630 $type == 'move' && $o->hasRight( ACL_DELETE ) ||
00631 $type == 'link' && $o->hasRight( ACL_READ ) ||
00632 $type == 'delete' && $o->hasRight( ACL_DELETE ) )
00633 $objectList[ $id ] = $o->getProperties();
00634 }
00635
00636 $this->setTemplateVar('type' ,$type );
00637 $this->setTemplateVar('objectlist',$objectList );
00638
00639
00640 $this->setTemplateVar('ids',join(array_keys($objectList),',') );
00641 }
00642
00643
00644
00648 function multiple()
00649 {
00650 $type = $this->getRequestVar('type');
00651 $ids = explode(',',$this->getRequestVar('ids'));
00652 $targetObjectId = $this->getRequestVar('targetobjectid');
00653
00654 foreach( $ids as $id )
00655 {
00656 $o = new Object( $id );
00657 $o->load();
00658
00659 switch( $type )
00660 {
00661 case 'move':
00662 if ( $o->isFolder )
00663 {
00664 $f = new Folder( $id );
00665 $allsubfolders = $f->getAllSubFolderIds();
00666
00667
00668
00669
00670
00671
00672 if ( !in_array($targetObjectId,$allsubfolders) && $id != $targetObjectId )
00673 {
00674 $this->addNotice($o->getType(),$o->name,'MOVED','ok');
00675
00676 }
00677 else
00678 {
00679 $this->addNotice($o->getType(),$o->name,'ERROR','error');
00680 }
00681 }
00682 else
00683 {
00684 $o->setParentId( $targetObjectId );
00685 $this->addNotice($o->getType(),$o->name,'MOVED','ok');
00686 }
00687 break;
00688
00689 case 'copy':
00690 switch( $o->getType() )
00691 {
00692 case 'folder':
00693
00694
00695 $this->addNotice($o->getType(),$o->name,'CANNOT_COPY_FOLDER','error');
00696 break;
00697
00698 case 'file':
00699 $f = new File( $id );
00700 $f->load();
00701 $f->filename = '';
00702 $f->name = lang('GLOBAL_COPY_OF').' '.$f->name;
00703 $f->parentid = $targetObjectId;
00704 $f->add();
00705 $f->copyValueFromFile( $id );
00706 $this->addNotice($o->getType(),$o->name,'COPIED','ok');
00707 break;
00708
00709 case 'page':
00710 $p = new Page( $id );
00711 $p->load();
00712 $p->filename = '';
00713 $p->name = lang('GLOBAL_COPY_OF').' '.$p->name;
00714 $p->parentid = $targetObjectId;
00715 $p->add();
00716 $p->copyValuesFromPage( $id );
00717 $this->addNotice($o->getType(),$o->name,'COPIED','ok');
00718 break;
00719
00720 case 'link':
00721 $l = new Link( $id );
00722 $l->load();
00723 $l->filename = '';
00724 $l->name = lang('GLOBAL_COPY_OF').' '.$l->name;
00725 $l->parentid = $targetObjectId;
00726 $l->add();
00727 $this->addNotice($o->getType(),$o->name,'COPIED','ok');
00728 break;
00729
00730 default:
00731 die('fatal: what type to delete?');
00732 }
00733 $notices[] = lang('COPIED');
00734 break;
00735
00736 case 'link':
00737
00738 if ( $o->isFile ||
00739 $o->isPage )
00740 {
00741 $link = new Link();
00742 $link->parentid = $targetObjectId;
00743
00744 $link->linkedObjectId = $id;
00745 $link->isLinkToObject = true;
00746 $link->name = lang('GLOBAL_LINK_TO').' '.$o->name;
00747 $link->add();
00748 $this->addNotice($o->getType(),$o->name,'LINKED','ok');
00749 }
00750 else
00751 {
00752 $this->addNotice($o->getType(),$o->name,'ERROR','error');
00753 }
00754 break;
00755
00756 case 'delete':
00757
00758 if ( $this->hasRequestVar('commit') )
00759 {
00760 switch( $o->getType() )
00761 {
00762 case 'folder':
00763 $f = new Folder( $id );
00764 $f->deleteAll();
00765 break;
00766
00767 case 'file':
00768 $f = new File( $id );
00769 $f->delete();
00770 break;
00771
00772 case 'page':
00773 $p = new Page( $id );
00774 $p->load();
00775 $p->delete();
00776 break;
00777
00778 case 'link':
00779 $l = new Link( $id );
00780 $l->delete();
00781 break;
00782
00783 default:
00784 Http::serverError('Internal Error while deleting: What type to delete?');
00785 }
00786 $this->addNotice($o->getType(),$o->name,'DELETED',OR_NOTICE_OK);
00787 }
00788 else
00789 {
00790 $this->addNotice($o->getType(),$o->name,'NOTHING_DONE',OR_NOTICE_WARN);
00791 }
00792
00793 break;
00794
00795 default:
00796 $this->addNotice($o->getType(),$o->name,'ERROR','error');
00797 }
00798
00799 }
00800
00801 $this->folder->setTimestamp();
00802
00803
00804 $this->callSubAction('show');
00805 }
00806
00807
00808
00809 function reorder()
00810 {
00811 $type = $this->getRequestVar('type');
00812
00813 switch( $type )
00814 {
00815 case 'type':
00816 $ids = $this->folder->getObjectIdsByType();
00817 break;
00818
00819 case 'name':
00820 $ids = $this->folder->getObjectIdsByName();
00821 break;
00822
00823 case 'lastchange':
00824 $ids = $this->folder->getObjectIdsByLastChange();
00825 break;
00826
00827 case 'flip':
00828 $ids = $this->folder->getObjectIds();
00829 $ids = array_reverse( $ids );
00830
00831 break;
00832
00833 default:
00834 Http::sendStatus(400,'Bad request','Unknown reordertype: '.$type );
00835 }
00836
00837
00838 $seq = 0;
00839 foreach( $ids as $id )
00840 {
00841 $seq++;
00842
00843 $o = new Object( $id );
00844 $o->setOrderId( $seq );
00845
00846 unset( $o );
00847 }
00848 $this->addNotice($this->folder->getType(),$this->folder->name,'SEQUENCE_CHANGED','ok');
00849
00850 $this->folder->setTimestamp();
00851
00852
00853 $this->callSubAction('order');
00854 }
00855
00856
00857 function settop()
00858 {
00859 $o = new Object( $this->getRequestVar('objectid1') );
00860 $o->setOrderId( 1 );
00861
00862 $ids = $this->folder->getObjectIds();
00863 $seq = 1;
00864
00865 foreach( $ids as $id )
00866 {
00867 if ( $id != $this->getRequestVar('objectid1') )
00868 {
00869 $seq++;
00870
00871 $o = new Object( $id );
00872 $o->setOrderId( $seq );
00873
00874 unset( $o );
00875 }
00876 }
00877
00878 $this->addNotice($this->folder->getType(),$this->folder->name,'SEQUENCE_CHANGED','ok');
00879 $this->folder->setTimestamp();
00880
00881
00882 $this->callSubAction('order');
00883 }
00884
00885
00886 function setbottom()
00887 {
00888 $ids = $this->folder->getObjectIds();
00889 $seq = 0;
00890
00891 foreach( $ids as $id )
00892 {
00893 if ( $id != $this->getRequestVar('objectid1') )
00894 {
00895 $seq++;
00896
00897 $o = new Object( $id );
00898 $o->setOrderId( $seq );
00899
00900 unset( $o );
00901 }
00902 }
00903
00904 $seq++;
00905 $o = new Object( $this->getRequestVar('objectid1') );
00906 $o->setOrderId( $seq );
00907
00908 $this->addNotice($this->folder->getType(),$this->folder->name,'SEQUENCE_CHANGED','ok');
00909 $this->folder->setTimestamp();
00910
00911
00912 $this->callSubAction('order');
00913
00914 }
00915
00916
00917 function create()
00918 {
00919
00920 $maxSizeBytes = $this->maxFileSize();
00921 $this->setTemplateVar('max_size' ,($maxSizeBytes/1024).' KB' );
00922 $this->setTemplateVar('maxlength',$maxSizeBytes );
00923
00924 $all_templates = Template::getAll();
00925 $this->setTemplateVar('templates' ,$all_templates );
00926
00927 if ( count($all_templates) == 0 )
00928 $this->addNotice('folder',$this->folder->name,'NO_TEMPLATES_AVAILABLE',OR_NOTICE_WARN);
00929
00930 $this->setTemplateVar('objectid' ,$this->folder->objectid );
00931 }
00932
00933
00934
00935 function createfolder()
00936 {
00937 $this->setTemplateVar('objectid' ,$this->folder->objectid );
00938 }
00939
00940
00941
00948 function maxFileSize()
00949 {
00950 global $conf;
00951
00952
00953
00954
00955
00956
00957 $sizes = array(10*1024*1024*1024);
00958
00959 foreach( array('upload_max_filesize','post_max_size','memory_limit') as $var )
00960 {
00961 $v = $this->stringToBytes(ini_get($var));
00962
00963 if ($v > 0 )
00964 $sizes[] = $v;
00965 }
00966
00967 $confMaxSize = intval($conf['content']['file']['max_file_size'])*1024;
00968 if ( $confMaxSize > 0 )
00969 $sizes[] = $confMaxSize;
00970
00971 return min($sizes);
00972 }
00973
00974
00979 function createfile()
00980 {
00981
00982 $maxSizeBytes = $this->maxFileSize();
00983 $this->setTemplateVar('max_size' ,($maxSizeBytes/1024).' KB' );
00984 $this->setTemplateVar('maxlength',$maxSizeBytes );
00985
00986 $this->setTemplateVar('objectid',$this->folder->objectid );
00987 }
00988
00989
00999 function stringToBytes($val)
01000 {
01001 $val = trim($val);
01002 $last = strtolower($val{strlen($val)-1});
01003
01004 switch($last)
01005 {
01006
01007 case 'g':
01008 $val *= 1024;
01009 case 'm':
01010 $val *= 1024;
01011 case 'k':
01012 $val *= 1024;
01013 }
01014
01015 return intval($val);
01016 }
01017
01018
01019
01020 function createlink()
01021 {
01022 $this->setTemplateVar('objectid' ,$this->folder->objectid );
01023 }
01024
01025
01026 function createpage()
01027 {
01028 $all_templates = Template::getAll();
01029 $this->setTemplateVar('templates' ,$all_templates );
01030 $this->setTemplateVar('objectid' ,$this->folder->objectid );
01031
01032 if ( count($all_templates) == 0 )
01033 $this->addNotice('folder',$this->folder->name,'NO_TEMPLATES_AVAILABLE',OR_NOTICE_WARN);
01034 }
01035
01036
01041 function show()
01042 {
01043 global $conf_php;
01044
01045 if ( ! $this->folder->isRoot )
01046 $this->setTemplateVar('up_url',Html::url('main','folder',$this->folder->parentid));
01047
01048 $this->setTemplateVar('writable',$this->folder->hasRight(ACL_WRITE) );
01049
01050 $list = array();
01051
01052
01053 foreach( $this->folder->getObjects() as $o )
01054 {
01055 $id = $o->objectid;
01056
01057 if ( $o->hasRight(ACL_READ) )
01058 {
01059 $list[$id]['name'] = Text::maxLaenge( 30,$o->name );
01060 $list[$id]['filename'] = Text::maxLaenge( 20,$o->filename );
01061 $list[$id]['desc'] = Text::maxLaenge( 30,$o->desc );
01062 if ( $list[$id]['desc'] == '' )
01063 $list[$id]['desc'] = lang('GLOBAL_NO_DESCRIPTION_AVAILABLE');
01064 $list[$id]['desc'] = $list[$id]['desc'].' - '.lang('GLOBAL_IMAGE').' '.$id;
01065
01066 $list[$id]['type'] = $o->getType();
01067
01068 $list[$id]['icon' ] = $o->getType();
01069 $list[$id]['class'] = $o->getType();
01070 $list[$id]['url' ] = Html::url('main',$o->getType(),$id);
01071
01072 if ( $o->getType() == 'file' )
01073 {
01074 $file = new File( $id );
01075 $file->load();
01076 $list[$id]['desc'] .= ' - '.intval($file->size/1000).'kB';
01077
01078 if ( $file->isImage() )
01079 {
01080 $list[$id]['icon' ] = 'image';
01081 $list[$id]['class'] = 'image';
01082
01083 }
01084
01085
01086 }
01087
01088 $list[$id]['date'] = $o->lastchangeDate;
01089 $list[$id]['user'] = $o->lastchangeUser;
01090 }
01091 }
01092
01093 $this->setTemplateVar('object' ,$list );
01094 }
01095
01096
01097 function select()
01098 {
01099 global $conf_php;
01100
01101 $this->setTemplateVar('writable',$this->folder->hasRight(ACL_WRITE) );
01102
01103 $list = array();
01104
01105
01106 foreach( $this->folder->getObjects() as $o )
01107 {
01108 $id = $o->objectid;
01109
01110 if ( $o->hasRight(ACL_READ) )
01111 {
01112 $list[$id]['id'] = 'obj'.$id;
01113 $list[$id]['name'] = Text::maxLaenge( 30,$o->name );
01114 $list[$id]['filename'] = Text::maxLaenge( 20,$o->filename );
01115 $list[$id]['desc'] = Text::maxLaenge( 30,$o->desc );
01116 if ( $list[$id]['desc'] == '' )
01117 $list[$id]['desc'] = lang('GLOBAL_NO_DESCRIPTION_AVAILABLE');
01118 $list[$id]['desc'] = 'ID '.$id.' - '.$list[$id]['desc'];
01119
01120 $list[$id]['type'] = $o->getType();
01121
01122 $list[$id]['icon'] = $o->getType();
01123
01124 if ( $o->getType() == 'file' )
01125 {
01126 $file = new File( $id );
01127 $file->load();
01128 $list[$id]['desc'] .= ' - '.intval($file->size/1000).'kB';
01129
01130 if ( substr($file->mimeType(),0,6) == 'image/' )
01131 $list[$id]['icon'] = 'image';
01132
01133
01134 }
01135
01136 $list[$id]['url' ] = Html::url('main',$o->getType(),$id);
01137 $list[$id]['date'] = date( lang('DATE_FORMAT'),$o->lastchangeDate );
01138 $list[$id]['user'] = $o->lastchangeUser;
01139 }
01140 }
01141
01142 if ( $this->folder->hasRight(ACL_WRITE) )
01143 {
01144
01145 $otherfolder = array();
01146 foreach( $this->folder->getAllFolders() as $id )
01147 {
01148 $f = new Folder( $id );
01149 if ( $f->hasRight( ACL_WRITE ) )
01150 $otherfolder[$id] = FILE_SEP.implode( FILE_SEP,$f->parentObjectNames(false,true) );
01151 }
01152 asort( $otherfolder );
01153
01154 $this->setTemplateVar('folder',$otherfolder);
01155
01156
01157 $this->setTemplateVar('order_url' ,Html::url('folder','order',$this->folder->id) );
01158 }
01159
01160 $actionList = array();
01161 $actionList[] = array('type'=>'copy');
01162 $actionList[] = array('type'=>'link');
01163
01164 if ( $this->folder->hasRight(ACL_WRITE) )
01165 {
01166 $actionList[] = array('type'=>'move');
01167 $actionList[] = array('type'=>'delete');
01168 }
01169
01170 $this->setTemplateVar('actionlist',$actionList );
01171
01172 $this->setTemplateVar('object' ,$list );
01173 $this->setTemplateVar('act_objectid',$this->folder->id);
01174 }
01175
01176
01177
01178
01179
01180
01181 function order()
01182 {
01183 global $conf_php;
01184
01185 $list = array();
01186 $last_objectid = 0;
01187
01188
01189 foreach( $this->folder->getObjects() as $o )
01190 {
01191 $id = $o->objectid;
01192
01193 if ( $o->hasRight(ACL_READ) )
01194 {
01195 $list[$id]['name'] = Text::maxLaenge( 30,$o->name );
01196 $list[$id]['filename'] = Text::maxLaenge( 20,$o->filename );
01197 $list[$id]['desc'] = Text::maxLaenge( 30,$o->desc );
01198 if ( $list[$id]['desc'] == '' )
01199 $list[$id]['desc'] = lang('GLOBAL_NO_DESCRIPTION_AVAILABLE');
01200 $list[$id]['desc'] = 'ID '.$id.' - '.$list[$id]['desc'];
01201
01202 $list[$id]['type'] = $o->getType();
01203
01204 $list[$id]['icon'] = $o->getType();
01205
01206 if ( $o->getType() == 'file' )
01207 {
01208 $file = new File( $id );
01209 $file->load();
01210 $list[$id]['desc'] .= ' - '.intval($file->size/1000).'kB';
01211
01212 if ( $file->isImage() )
01213 $list[$id]['icon'] = 'image';
01214 }
01215
01216 $list[$id]['url' ] = Html::url('main',$o->getType(),$id);
01217 $list[$id]['date'] = $o->lastchangeDate;
01218 $list[$id]['user'] = $o->lastchangeUser;
01219
01220 if ( $last_objectid != 0 && $o->hasRight(ACL_WRITE) )
01221 {
01222 $list[$id ]['upurl' ] = Html::url('folder','changesequence',0,array(
01223 'objectid1'=>$id,
01224 'objectid2'=>$last_objectid));
01225 $list[$last_objectid]['downurl' ] = $list[$id]['upurl'];
01226 $list[$last_objectid]['bottomurl'] = Html::url('folder','setbottom',0,array(
01227 'objectid1'=>$last_objectid));
01228 $list[$id ]['topurl' ] = Html::url('folder','settop',0,array(
01229 'objectid1'=>$id));
01230 }
01231
01232 $last_objectid = $id;
01233 }
01234 }
01235
01236 $this->setTemplateVar('flip_url' ,Html::url('folder','reorder',0,array('type'=>'flip' )) );
01237 $this->setTemplateVar('orderbyname_url' ,Html::url('folder','reorder',0,array('type'=>'name' )) );
01238 $this->setTemplateVar('orderbytype_url' ,Html::url('folder','reorder',0,array('type'=>'type' )) );
01239 $this->setTemplateVar('orderbylastchange_url',Html::url('folder','reorder',0,array('type'=>'lastchange')) );
01240 $this->setTemplateVar('object' ,$list );
01241 $this->setTemplateVar('act_objectid',$this->folder->id);
01242 }
01243
01244
01245
01246 function prop()
01247 {
01248 $this->setTemplateVars( $this->folder->getProperties() );
01249 $this->setTemplateVar( 'full_filename',$this->folder->full_filename() );
01250 }
01251
01252
01253 function remove()
01254 {
01255 $this->setTemplateVars( $this->folder->getProperties() );
01256 }
01257
01258
01259 function pub()
01260 {
01261
01262 $this->setTemplateVar('files' ,count($this->folder->getFiles()) > 0 );
01263 $this->setTemplateVar('pages' ,count($this->folder->getPages()) > 0 );
01264 $this->setTemplateVar('subdirs',count($this->folder->getSubFolderIds()) > 0 );
01265 $this->setTemplateVar('clean' ,$this->folder->isRoot );
01266
01267
01268 }
01269
01270
01271 function pubnow()
01272 {
01273 if ( !$this->folder->hasRight( ACL_PUBLISH ) )
01274 die('no rights for publish');
01275
01276 $subdirs = ( $this->hasRequestVar('subdirs') );
01277 $pages = ( $this->hasRequestVar('pages' ) );
01278 $files = ( $this->hasRequestVar('files' ) );
01279
01280 $publish = new Publish();
01281
01282 $this->folder->publish = &$publish;
01283 $this->folder->publish( $pages,$files,$subdirs );
01284 $this->folder->publish->close();
01285
01286 $list = array();
01287 foreach( $publish->publishedObjects as $o )
01288 $list[] = $o['full_filename'];
01289
01290 if ( !$publish->ok )
01291 $this->addNotice('folder',$this->folder->name,'PUBLISHED_ERROR',OR_NOTICE_ERROR,array(),$publish->log);
01292 else
01293 $this->addNotice('folder',$this->folder->name,'PUBLISHED',OR_NOTICE_OK,array(),$list);
01294
01295
01296 if ( $this->hasRequestVar('clean') )
01297 $publish->clean();
01298
01299 $this->callSubaction( 'pub' );
01300 }
01301
01302
01303
01304 function checkMenu( $name )
01305 {
01306 switch( $name)
01307 {
01308 case 'createfolder':
01309 return $this->folder->hasRight(ACL_CREATE_FOLDER) && count($this->folder->parentObjectIds(true,true)) < MAX_FOLDER_DEPTH;
01310
01311 case 'createfile':
01312 return $this->folder->hasRight(ACL_CREATE_FILE);
01313
01314 case 'createlink':
01315 return $this->folder->hasRight(ACL_CREATE_LINK);
01316
01317 case 'createpage':
01318 return $this->folder->hasRight(ACL_CREATE_PAGE);
01319
01320 case 'remove':
01321 return count($this->folder->getObjectIds()) == 0;
01322
01323 default:
01324 return true;
01325 }
01326 }
01327 }