Ignore:
Timestamp:
11/27/09 10:24:20 (14 years ago)
Author:
amuller
Message:

Ticket #597 - Melhorias no módulo gerenciador de arquivos com ajax

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/filemanager/inc/class.uifilemanager.inc.php

    r1704 r1719  
    2929                        'fileModels'=>True, 
    3030                        'getReturnExecuteForm' => True, 
     31                        'dir_ls' => True, 
     32                        'get_permissions' => True, 
    3133                        'uploadModel'=>True 
    3234                ); 
     
    555557                        } 
    556558                } 
     559                function get_permissions(){ 
     560                        /* get permissions */ 
     561                        if((preg_match('+^'.$this->bo->fakebase.'\/(.*)(\/|$)+U', $this->path, $matches)) && $matches[1] != $this->bo->userinfo['account_lid']) //FIXME matches not defined 
     562 
     563                        { 
     564                                $this->bo->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id($matches[1]);//FIXME matches not defined 
     565 
     566                        } 
     567                        else 
     568                        { 
     569                                $this->bo->vfs->working_id = $this->bo->userinfo['username']; 
     570                        } 
     571 
     572                        # Check available permissions for $this->path, so we can disable unusable operations in user interface 
     573                        $path = explode('/',$this->path); 
     574                        $owner_id = $this->bo->vfs->ownerOf($this->bo->fakebase,$path[2]); 
     575                        $user_id = $GLOBALS['phpgw_info']['user']['account_id']; 
     576                        if ($owner_id == $user_id) 
     577                        { 
     578                                $rights = 31; 
     579                        }else 
     580                        { 
     581                                $acl = CreateObject ('phpgwapi.acl', $owner_id); 
     582                                $acl->account_id = $owner_id; 
     583                                $acl->read_repository(); 
     584                                $rights = $acl->get_rights($user_id); 
     585                        } 
     586                        echo $rights;    
     587                } 
     588                function dir_ls() 
     589                { 
     590                        reset($this->files_array); 
     591                        $this->readFilesInfo(); 
     592 
     593                        for($i = 0; $i != $this->numoffiles; $i++) 
     594                        { 
     595                                $files = $this->files_array[$i]; 
     596 
     597                                if(!$this->prefs['dotfiles'] && ereg("^\.", $files['name'])) 
     598                                { 
     599                                        continue; 
     600                                } 
     601                                /* small keys to safe bandwidth */ 
     602                                $tuple['name'] = $files['name']; 
     603                                $tuple['icon'] = $this->mime_icon($files['mime_type']); 
     604                                $tuple['type'] = $files['type']; 
     605                                if ($files['created'] != ''){ 
     606                                        $timestamp = $this->vfs_functions->dateString2timeStamp($files['created']); 
     607                                        if (time() - $timestamp > 86400) // Older than yesterday 
     608                                                $tuple['creatd']=date("Y-m-d",$timestamp); 
     609                                        else 
     610                                                $tuple['creatd']=date("H:i",$timestamp); 
     611                                } 
     612                                else 
     613                                        $tuple['creatd']=''; 
     614                                if ($files['modified'] != ''){ 
     615                                        $timestamp = $this->vfs_functions->dateString2timeStamp($files['modified']); 
     616                                        if (time() - $timestamp > 86400) // Older than yesterday 
     617                                                $tuple['modifd']=date("Y-m-d",$timestamp); 
     618                                        else 
     619                                                $tuple['modifd']=date("H:i",$timestamp); 
     620                                } 
     621                                else 
     622                                        $tuple['modifd']=''; 
     623 
     624                                $tuple['size'] = $files['size']; 
     625                                $tuple['mime'] = $files['mime_type']; 
     626                                $tuple['pub'] = $files['type']; 
     627                                $tuple['creatdby'] = $GLOBALS['phpgw']->accounts->id2name($files['createdby_id']); 
     628                                $tuple['modifdby'] = $files['modifiedby_id']?$GLOBALS['phpgw']->accounts->id2name($files['modifiedby_id']):''; 
     629                                $tuple['owner'] = $GLOBALS['phpgw']->accounts->id2name($files['owner_id']); 
     630                                $tuple['comm'] = $files['comment']; 
     631                                $tuple['vers'] = $files['version']; 
     632                                $output[] = $tuple; 
     633 
     634                        } 
     635 
     636                        foreach ($output as $key => $row) { 
     637                                $temp[$key]  = $row[$this->criteria]; 
     638                        } 
     639                        if ($this->otype == "1") 
     640                                array_multisort($temp, SORT_ASC, $output); 
     641                        else 
     642                                array_multisort($temp, SORT_DESC, $output); 
     643 
     644                        echo serialize($output); 
     645                } 
     646 
    557647                function fileListing() 
    558648                { 
    559                         $this->t->set_file(array('filemanager_list_t' => 'filelisting.tpl')); 
     649                        $this->t->set_file(array('filemanager_list_t' => 'main.tpl')); 
    560650                        $this->t->set_block('filemanager_list_t','filemanager_header','filemanager_header'); 
    561                         $this->t->set_block('filemanager_list_t','column','column'); 
    562                         $this->t->set_block('filemanager_list_t','row','row'); 
    563651                        $this->t->set_block('filemanager_list_t','filemanager_footer','filemanager_footer'); 
    564652 
    565                         $vars['form_action']=$this->encode_href('/index.php', 'menuaction=filemanager.uifilemanager.index','path='.$this->path); 
    566653                        if($this->numoffiles || $this->cwd) 
    567654                        { 
    568                                 while(list($num, $name) = each($this->prefs)) 
    569                                 { 
    570                                         if($name) 
    571                                         { 
    572                                                 $columns++; 
    573                                         } 
    574                                 } 
    575                                 $columns++; 
    576655                                $usedSpace = $this->bo->vfs->get_size(array( 
    577656                                        'string'        => $this->path, 
     
    586665                                $vars[path]='<input type="hidden" id="currentPath" value="'.$this->path.'">'; 
    587666                                $vars[css]='<link rel="stylesheet" type="text/css" href="filemanager/templates/default/main.css">'; 
     667                                $vars[preferences]='<input type="hidden" id="userPreferences" value=\''.serialize($_SESSION['phpgw_info']['user']['preferences']['filemanager']).'\'>'; 
    588668                                $vars[script]='<script>initDrawApi();</script>'; 
    589669 
     
    599679                                        $vars[new_button]=''; 
    600680 
     681                                // reload button with this url 
     682                                $vars[refresh_button]=$this->toolButton('reload','reload',lang('reload')); 
     683 
    601684                                // go up icon when we're not at the top, dont allow to go outside /home = fakebase 
    602685                                if($this->path != '/' && $this->path != $this->bo->fakebase) 
     
    607690                                        $vars[tools_button] = ""; 
    608691 
    609                                 // go home icon when we're not home already 
    610                                 /*if($this->path != $this->bo->homedir) 
    611                                 { 
    612                                         $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->lesspath); 
    613  
    614                                 $vars[up_button]=$this->toolButton($link,'up',lang('go up')); 
    615  
    616                                 $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->bo->homedir); 
    617                                 $toolbar.=$this->toolButton($link,'home',lang('go home')); 
    618                                 }*/ 
    619  
    620                                 // reload button with this url 
    621                                 $vars[refresh_button]=$this->toolButton('reload','reload',lang('reload')); 
    622692 
    623693                                // selectbox for change/move/and copy to 
    624694                                $dirs=$this->all_other_directories_options(); 
    625695                                foreach($dirs as $elem) 
    626                                         $vars[folders].='<br><span onclick="load(\''.$elem['directory'].$elem['name'].'\')" class="l">'.$elem['name'].'</span>'; 
     696                                        $vars[folders].='<br><span onclick="load(\''.$elem['directory'].$elem['name'].'\')" class="l" onmouseover="this.style.border=\'1px solid black\'" onmouseout="this.style.border=\'1px solid transparent\'">'.$elem['name'].'</span>'; 
    627697                                 
    628                                 //$this->toolButton('goto','goto',lang('Quick jump to')); 
    629                                 // selectbox for change/move/and copy to 
    630                                 // submit buttons for 
    631                                 // if($this->path != '/' && $this->path != $this->bo->fakebase) 
    632  
    633                                 if($this->can_edit) 
    634                                 { 
    635                                         // edit text file button 
    636                                         $toolbar.=$this->toolButton('edit','edit',lang('edit')); 
    637                                 } 
    638  
    639                                 if($this->can_edit) 
    640                                 { 
    641                                         $toolbar.=$this->toolButton('rename','rename',lang('Rename')); 
    642                                 } 
    643  
    644                                 if($this->can_delete) 
    645                                 { 
    646                                         $toolbar.=$this->toolButton('delete','delete',lang('Delete')); 
    647                                 } 
    648  
    649  
    650698 
    651699                                // copy and move buttons 
     
    660708                                        } 
    661709 
    662                                 if (strlen($dirs_options) > 0){ 
    663                                          if ($this->can_read) 
    664                                                 $toolbar.=$this->toolButton('copy_to','copy_to',lang('Copy to')); 
    665                                         if ($this->can_delete) 
    666                                                 $toolbar.=$this->toolButton('move_to','move_to',lang('Move to')); 
    667                                 } 
    668710                                $toolbar.='<select name="todir" style="visibility:hidden">'.$dirs_options.'</select>'; 
    669  
    670  
    671711 
    672712                                $vars[toolbar1]=$toolbar; 
     
    685725                                $this->t->set_var($vars); 
    686726                                $this->t->pparse('out','filemanager_header'); 
    687  
    688                                 ### 
    689                                 # Start File Table Column Headers 
    690                                 # Reads values from $file_attributes array and preferences 
    691                                 ### 
    692                                 $this->t->set_var('actions',lang('select')); 
    693                                 $this->t->set_var('mini_bar','&nbsp;'); 
    694  
    695  
    696                                 reset($this->bo->file_attributes); 
    697  
    698                                 if($this->numoffiles>0) 
    699                                 { 
    700                                         while(list($internal, $displayed) = each($this->bo->file_attributes)) 
    701                                         { 
    702                                                 if($this->prefs[$internal]) 
    703                                                 { 
    704                                                         if ($internal != 'owner') 
    705                                                                 $col_data='<span><a href="'.$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path.'&sortby='.$internal).'">'.$displayed.'</a></span>'; 
    706                                                         else 
    707                                                                 $col_data='<span>'.$displayed.'</span>'; 
    708                                                         $this->t->set_var('col_data',$col_data); 
    709                                                         $this->t->parse('columns','column',True); 
    710                                                 } 
    711                                         } 
    712  
    713                                         $this->t->set_var('row_tr_class','message_header'); 
    714                                          
    715                                         $this->t->parse('rows','row'); 
    716                                          
    717                                         $this->t->pparse('out','row'); 
    718                                 } 
    719                                 else 
    720                                 { 
    721                                         $lang_nofiles=lang('No files in this directory.'); 
    722                                 } 
    723                                 $vars[lang_no_files]=$lang_nofiles; 
    724  
    725  
    726                                 if($this->prefs['dotdot'] && $this->prefs['name'] && $this->path != '/') 
    727                                 { 
    728                                         $this->t->set_var('actions',''); 
    729  
    730                                         $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->lesspath); 
    731  
    732                                         $col_data='<a href="'.$link.'"><img src="'.$GLOBALS['phpgw']->common->image('filemanager','mime16up').' "alt="'.lang('Folder Up').'" /></a>'; 
    733                                         $col_data.='&nbsp;<a href="'.$link.'">..</a>'; 
    734  
    735                                         $this->t->set_var('col_data',$col_data); 
    736                                         $this->t->parse('columns','column'); 
    737  
    738                                         if($this->prefs['mime_type']) 
    739                                         { 
    740                                                 $col_data=lang('Directory'); 
    741                                                 $this->t->set_var('col_data',$col_data); 
    742                                                 $this->t->parse('columns','column',True); 
    743                                         } 
    744  
    745                                         $this->t->set_var('row_tr_class',''); 
    746                                         $this->t->parse('rows','row'); 
    747                                         $this->t->pparse('out','row'); 
    748                                 } 
    749  
    750                                 # List all of the files, with their attributes 
    751                                 @reset($this->files_array); 
    752                                 for($i = 0; $i != $this->numoffiles; $i++) 
    753                                 { 
    754                                         $files = $this->files_array[$i]; 
    755                                          
    756  
    757                                         if(!$this->prefs['dotfiles'] && ereg("^\.", $files['name'])) 
    758                                         { 
    759                                                 continue; 
    760                                         } 
    761  
    762                                         # Checkboxes 
    763                                         if($this->path != $this->bo->fakebase && $this->path != '/') 
    764                                         { 
    765                                                 $cbox='<input type="checkbox" name="fileman" value="'.$files['name'].'">'; 
    766                                                 $this->t->set_var('actions',$cbox); 
    767                                         } 
    768                                         else 
    769                                         { 
    770                                                 $this->t->set_var('actions',''); 
    771                                         } 
    772                                         $minibar_data=""; 
    773                                         if($this->can_private) 
    774                                         { 
    775                                                 if ($files['type'] == "1") 
    776                                                 { 
    777                                                         $image = $GLOBALS['phpgw']->common->image('filemanager','button_lock'); 
    778                                                 } 
    779                                                 else 
    780                                                 { 
    781                                                         $image = $GLOBALS['phpgw']->common->image('filemanager','button_unlock'); 
    782                                                 } 
    783                                                 $link=$this->encode_href('/index.php','menuaction=filemanager.vfs_functions.setRestricted','file='.$files['name'].'&path='.$this->path); 
    784                                                 $minibar_data = '<img id="restrict_'.$files['name'].'" onClick="setRestricted(\''.$link.'\')" alt="'.lang("mark as restricted").'" title="'.lang("mark as restricted").'" src="'.$image.'">'; 
    785                                         } 
    786  
    787  
    788                                         if ($files['mime_type'] == "text/html") 
    789                                         { 
    790                                                 $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.export','file='.$files['name'].'&path='.$this->path); 
    791                                                 $image=$GLOBALS['phpgw']->common->image('filemanager','button_export'); 
    792                                                 $minibar_data.='<a href="'.$link.'"><img alt="'.lang("export").'" title="'.lang("export").'" src="'.$image.'"></a>'; 
    793                                         } 
    794                                         else 
    795                                                 $minibar_data.= "<a>&nbsp;</a>"; 
    796                                         $this->t->set_var('mini_bar',$minibar_data); 
    797  
    798  
    799                                         # File name and icon 
    800                                         if($files['mime_type'] == 'Directory') 
    801                                         { 
    802                                                 $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.index','path='.$this->path.$this->dispsep.$files['name']); 
    803  
    804                                                 $icon=$this->mime_icon($files['mime_type']); 
    805  
    806                                                 $col_data='<a href="'.$link.'">'.$icon.'</a>&nbsp;'; 
    807                                                 $col_data.='<a href="'.$link.'">'.$files['name'].'</a>&nbsp;'; 
    808                                         } 
    809                                         else 
    810                                         { 
    811  
    812                                                 if($this->prefs['viewonserver'] && isset($this->bo->filesdir) && !$files['link_directory']) 
    813                                                 { 
    814                                                         #FIXME 
    815                                                         $clickview = $this->filesdir.$pwd.'/'.$files['name']; 
    816  
    817                                                 } 
    818                                                 else 
    819                                                 { 
    820                                                         $icon=$this->mime_icon($files['mime_type']); 
    821                                                         $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.view','file='.$files['name'].'&path='.$this->path); 
    822                                                         //$link=$this->encode_href('inc/download.php','file='.base64_encode($files['name']).'&path='.base64_encode($this->path)); 
    823  
    824                                                         $col_data='<a href="'.$link.'" target="'.$this->target.'">'.$icon.'</a>&nbsp;'. 
    825                                                         '<a id="name_'.$files['name'].'" href="'.$link.'" target="'.$this->target.'">'.$files['name'].'</a>'; 
    826                                                 } 
    827                                         } 
    828  
    829  
    830                                         $this->t->set_var('col_data',$col_data); 
    831                                         $this->t->parse('columns','column'); 
    832  
    833                                         # MIME type 
    834                                         if($this->prefs['mime_type']) 
    835                                         { 
    836                                                 $col_data=$files['mime_type']; 
    837                                                 $this->t->set_var('col_data',$col_data); 
    838                                                 $this->t->parse('columns','column',True); 
    839                                         } 
    840  
    841                                         # File size 
    842                                         if($this->prefs['size']) 
    843                                         { 
    844                                                 $tmp_arr=array( 
    845                                                         'string'        => $files['directory'] . '/' . $files['name'], 
    846                                                         'relatives'     => array(RELATIVE_NONE) 
    847                                                 ); 
    848                                                 if($files['mime_type'] != 'Directory') $tmp_arr['checksubdirs'] = false; 
    849  
    850                                                 $size = $this->bo->vfs->get_size($tmp_arr); 
    851  
    852                                                 $col_data=$this->bo->borkb($size); 
    853  
    854                                                 $this->t->set_var('col_data',$col_data); 
    855                                                 $this->t->parse('columns','column',True); 
    856                                         } 
    857  
    858                                         # Date created 
    859                                         if($this->prefs['created']) 
    860                                         { 
    861                                                 $timestamp = $this->vfs_functions->dateString2timeStamp($files['created']); 
    862                                                 if (time() - $timestamp > 86400) // Older than yesterday 
    863                                                         $col_data=date("Y-m-d",$timestamp); 
    864                                                 else 
    865                                                         $col_data=date("H:i",$timestamp); 
    866                                                 $this->t->set_var('col_data',$col_data); 
    867                                                 $this->t->parse('columns','column',True); 
    868                                         } 
    869  
    870                                         # Date modified 
    871                                         if($this->prefs['modified']) 
    872                                         { 
    873                                                 if ($files['modified'] != ''){ 
    874                                                         $timestamp = $this->vfs_functions->dateString2timeStamp($files['modified']); 
    875                                                         if (time() - $timestamp > 86400) // Older than yesterday 
    876                                                                 $col_data=date("Y-m-d",$timestamp); 
    877                                                         else 
    878                                                                 $col_data=date("H:i",$timestamp); 
    879                                                 } 
    880                                                 else 
    881                                                         $col_data=''; 
    882                                                 $this->t->set_var('col_data',$col_data); 
    883                                                 $this->t->parse('columns','column',True); 
    884                                         } 
    885  
    886                                         # Owner name 
    887                                         if($this->prefs['owner']) 
    888                                         { 
    889                                                 $this->t->set_var('col_data',$GLOBALS['phpgw']->accounts->id2name($files['owner_id'])); 
    890                                                 $this->t->parse('columns','column',True); 
    891                                         } 
    892  
    893                                         # Creator name 
    894                                         if($this->prefs['createdby_id']) 
    895                                         { 
    896                                                 $this->html_table_col_begin(); 
    897                                                 if($files['createdby_id']) 
    898                                                 { 
    899                                                         $col_data=$GLOBALS['phpgw']->accounts->id2name($files['createdby_id']); 
    900                                                 } 
    901                                                 else $col_data=''; 
    902  
    903                                                 $this->t->set_var('col_data',$col_data); 
    904                                                 $this->t->parse('columns','column',True); 
    905                                         } 
    906  
    907                                         # Modified by name 
    908                                         if($this->prefs['modifiedby_id']) 
    909                                         { 
    910                                                 if($files['modifiedby_id']) 
    911                                                 { 
    912                                                         $col_data=$GLOBALS['phpgw']->accounts->id2name($files['modifiedby_id']); 
    913                                                 } 
    914                                                 else $col_data=''; 
    915                                                 $this->t->set_var('col_data',$col_data); 
    916                                                 $this->t->parse('columns','column',True); 
    917                                         } 
    918  
    919                                         # Application 
    920                                         if($this->prefs['app']) 
    921                                         { 
    922                                                 $col_data=$files['app']; 
    923                                                 $this->t->set_var('col_data',$col_data); 
    924                                                 $this->t->parse('columns','column',True); 
    925                                         } 
    926  
    927                                         # Comment 
    928                                         if($this->prefs['comment']) 
    929                                         { 
    930                                                 if (strlen($files['comment']) == 0 ) 
    931                                                         $files['comment'] = "&lt;".lang("no comments")."&gt;"; 
    932                                                 $col_data='<span id="'.$files['name'].'" onClick="setComments(this)">'.$files['comment'].'</span>'; 
    933                                                 $this->t->set_var('col_data',$col_data); 
    934                                                 $this->t->parse('columns','column',True); 
    935                                         } 
    936  
    937                                         # Version 
    938                                         if($this->prefs['version']) 
    939                                         { 
    940                                                 $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.history','file='.$files['name'].'&path='.$this->path); 
    941                                                 $col_data='<a href="'.$link.'" target="_blank">'.$files['version'].'</a>'; 
    942                                                 $this->t->set_var('col_data',$col_data); 
    943                                                 $this->t->parse('columns','column',True); 
    944                                         } 
    945  
    946                                         $usedspace += $files['size']; 
    947  
    948                                         $this->t->set_var('row_tr_color',''); 
    949                                         $this->t->parse('rows','row'); 
    950                                         $this->t->pparse('out','row'); 
    951                                 } 
    952                         } 
    953  
    954                         // The file and directory information 
    955                         $vars[lang_files_in_this_dir]=lang('Files in this directory'); 
    956                         $vars[files_in_this_dir]=$this->numoffiles; 
    957  
    958                         $vars[lang_used_space]=lang('Used space'); 
    959                         $vars[used_space]=$this->bo->borkb($usedspace, NULL, 1); 
    960  
    961                         if($this->path == $this->bo->homedir || $this->path == $this->bo->fakebase) 
    962                         { 
    963                                 $vars[lang_unused_space]=lang('Unused space'); 
    964                                 $vars[unused_space]=$this->bo->borkb($this->bo->userinfo['hdspace'] - $usedspace, NULL, 1); 
    965  
    966                                 $tmp_arr=array( 
    967                                         'string'        => $this->path, 
    968                                         'relatives'     => array(RELATIVE_NONE) 
    969                                 ); 
    970  
    971                                 $ls_array = $this->bo->vfs->ls($tmp_arr); 
    972  
    973                                 $vars[lang_total_files]=lang('Total Files'); 
    974                                 $vars[total_files]=     count($ls_array); 
    975727                        } 
    976728 
     
    1076828                        else 
    1077829                        { 
    1078  
     830                                $this->to = $this->bo->fakebase.'/'.$this->to; 
    1079831                                while(list($num, $file) = each($this->fileman)) 
    1080832                                { 
     
    1114866                        else 
    1115867                        { 
     868                                $this->to = $this->bo->fakebase.'/'.$this->to; 
    1116869                                while(list($num, $file) = each($this->fileman)) 
    1117870                                { 
     
    16391392                        if(!$img) $img=$GLOBALS['phpgw']->common->image('filemanager','mime'.$size.'_unknown'); 
    16401393 
    1641                         $icon='<img src="'.$img.' "alt="'.lang($mime_type).'" />'; 
    1642                         return $icon; 
     1394                        return $img; 
    16431395                } 
    16441396 
Note: See TracChangeset for help on using the changeset viewer.