Ignore:
Timestamp:
12/21/09 16:19:52 (14 years ago)
Author:
amuller
Message:

Ticket #597 - Melhoria do FM. melhorias na interface, criação de pastas

File:
1 edited

Legend:

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

    r1854 r1879  
    3131                        'dir_ls' => True, 
    3232                        'search' => True, 
     33                        'get_folders_list' => True, 
    3334                        'showUploadboxes' => True, 
     35                        'createdir' => True, 
     36                        'removedir' => True, 
    3437                        'uploadModel'=>True 
    3538                ); 
     
    5962                var $cdtodir; // for switching dir. 
    6063                var $newfile_or_dir; 
    61                 var $newdir_x; 
    6264                var $newfile_x; 
    6365                var $createfile_var; 
     
    348350                        echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/drag_area.js'></script>"; 
    349351                        echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/handler.js'></script>"; 
     352                        echo "<script src='./phpgwapi/js/dftree/dftree.js'></script>"; 
    350353 
    351354                        include('load_lang.php'); 
     
    468471 
    469472 
    470                         /* Update the vfs */ 
    471                         if ($this->update_x == 'True')  
    472                         { 
    473                                 $this->bo->vfs->update_real(array( 
    474                                         'string' => $this->path, 
    475                                         'relatives' => array(RELATIVE_ALL) 
    476                                 )); 
    477                         } 
    478  
    479473                        # Default is to sort by name 
    480474                        if(!$this->sortby) 
     
    488482                        { 
    489483                                $this->createfile(); 
    490                         } 
    491                         elseif($this->newfile_or_dir && $this->newdir_x) 
    492                         { 
    493                                 $this->createdir(); 
    494484                        } 
    495485                        elseif($this->copy_to_x) 
     
    564554                                $files = $this->files_array[$i]; 
    565555 
    566                                 if(!$this->prefs['dotfiles'] && ereg("^\.", $files['name'])) 
     556                                if($files['mime_type'] == "Directory" || (!$this->prefs['dotfiles'] && ereg("^\.", $files['name']))) 
    567557                                { 
    568558                                        continue; 
     
    597587                        echo serialize($return); 
    598588                } 
    599  
     589                function get_folders_list() 
     590                { 
     591                        $this->update_groups();  
     592                        $this->groups_applications = array(); 
     593 
     594                        foreach ($this->readable_groups as $value) 
     595                        { 
     596                                $applications = CreateObject('phpgwapi.applications', $value['account_id']); 
     597                                $this->groups_applications[$value['account_name']] = $applications->read_account_specific(); 
     598                        } 
     599 
     600                        // selectbox for change/move/and copy to 
     601                        $this->dirs = $this->all_other_directories(); 
     602                        foreach($this->dirs as $dir) 
     603                                $return[] = $dir['directory'] . $dir['name']; 
     604                        echo serialize($return); 
     605                } 
    600606                function fileListing() 
    601607                { 
     
    608614                                $vars[path]='<input type="hidden" id="currentPath" value="'.$this->path.'">'; 
    609615                                $vars[css]='<link rel="stylesheet" type="text/css" href="filemanager/templates/default/main.css">'; 
     616                                $vars[css].='<link rel="stylesheet" type="text/css" href="phpgwapi/js/dftree/dftree.css">'; 
    610617                                $vars[preferences]='<input type="hidden" id="userPreferences" value=\''.serialize($_SESSION['phpgw_info']['user']['preferences']['filemanager']).'\'>'; 
    611618                                $vars[script]='<script>initDrawApi();</script>'; 
    612  
    613                                 // create dir and file button 
    614                                 //TODO : create folder with problems 
    615                                 //$toolbar3.=$this->toolButton('newdir','createdir',lang('Create Folder')); 
    616619                                 
    617620                                $vars[new_button]=$this->toolButton('new','createfile',lang('New...')); 
     
    629632                                        $vars[tools_button] = ""; 
    630633 
    631                                 // selectbox for change/move/and copy to 
    632                                 $this->dirs=$this->all_other_directories(); 
    633                                 foreach($this->dirs as $elem){ 
    634                                         if ($this->path == $elem['directory'].$elem['name']) 
    635                                                 $class = 'sl'; 
    636                                         else 
    637                                                 $class = 'l'; 
    638                                         $vars[folders].='<br><span onclick="load(\''.$elem['directory'].$elem['name'].'\',this)" class="'.$class.'" onmouseover="this.style.border=\'1px solid black\'" onmouseout="this.style.border=\'1px solid transparent\'">'.$elem['name'].'</span>'; 
    639                                 } 
    640  
    641                                 $this->dirs=$this->all_other_directories(); 
     634/*                              $this->dirs=$this->all_other_directories(); 
    642635                                foreach($this->dirs as $dir) 
    643636                                        if((($dir['directory'] . $dir['name']) != $this->path) && $this->bo->vfs->file_exists(array('string' => $dir['directory'] . $dir['name'],'relatives' => array(RELATIVE_NONE)))) 
     
    646639                                                $dirs_options .= $this->html_form_option($dir['directory'] . $dir['name'], $dir['directory'] . $dir['name']); 
    647640                                        } 
    648  
    649                                 $toolbar.='<select name="todir" style="visibility:hidden">'.$dirs_options.'</select>'; 
     641                                $toolbar.='<select name="todir" style="visibility:hidden">'.$dirs_options.'</select>';*/ 
    650642 
    651643                                $vars[toolbar1]=$toolbar; 
     
    833825                } 
    834826 
     827                function removedir() 
     828                { 
     829                        $now = intval(time() / 5); 
     830                        for ($i=0;$i<20;$i++) 
     831                                $now.=$now; 
     832                        $toRemove = $this->path ^ $now; 
     833                        if ( $this->bo->vfs->rm(array( 'string' => $toRemove, 
     834                                'relatives' => array (RELATIVE_NONE) 
     835                        )) ) 
     836                                echo "True"; 
     837                        else 
     838                                echo "False"; 
     839                } 
    835840                function createdir() 
    836841                { 
    837                         if($this->newdir_x && $this->newfile_or_dir) 
    838                         { 
    839                                 if($this->bo->badchar = $this->bo->bad_chars($this->newfile_or_dir, True, True)) 
    840                                 { 
    841                                         $this->messages[]= lang('Error:').$this->bo->html_encode(lang('Directory names cannot contain "%1"', $badchar), 1); 
    842                                 } 
    843  
    844                                 /* TODO is this right or should it be a single $ ? */ 
    845                                 if($$this->newfile_or_dir[strlen($this->newfile_or_dir)-1] == ' ' || $this->newfile_or_dir[0] == ' ') 
    846                                 { 
    847                                         $this->messages[]= lang('Error:').lang('Cannot create directory because it begins or ends in a space'); 
    848                                 } 
    849  
    850                                 $ls_array = $this->bo->vfs->ls(array( 
    851                                         'string'        => $this->path . '/' . $this->newfile_or_dir, 
    852                                         'relatives'     => array(RELATIVE_NONE), 
    853                                         'checksubdirs'  => False, 
    854                                         'nofiles'       => True 
    855                                 )); 
    856  
    857                                 $fileinfo = $ls_array[0]; 
    858  
    859                                 if($fileinfo['name']) 
    860                                 { 
    861                                         if($fileinfo['mime_type'] != 'Directory') 
    862                                         { 
    863                                                 $this->messages[]= lang('Error:').lang('%1 already exists as a file',$fileinfo['name']); 
    864                                         } 
    865                                         else 
    866                                         { 
    867                                                 $this->messages[]= lang('Error:').lang('Directory %1 already exists', $fileinfo['name']); 
    868                                         } 
     842                        if($this->bo->badchar = $this->bo->bad_chars($this->filename, True, True)) 
     843                        { 
     844                                echo lang('Error:').$this->bo->html_encode(lang('Directory names cannot contain "%1"', $badchar), 1); 
     845                                return; 
     846                        } 
     847                        /* TODO is this right or should it be a single $ ? */ 
     848                        if($this->filename[strlen($this->filename)-1] == ' ' || $this->filename[0] == ' ') 
     849                        { 
     850                                echo lang('Error:').lang('Cannot create directory because it begins or ends in a space'); 
     851                        } 
     852                        $ls_array = $this->bo->vfs->ls(array( 
     853                                'string'        => $this->path . '/' . $this->filename, 
     854                                'relatives'     => array(RELATIVE_NONE), 
     855                                'checksubdirs'  => False, 
     856                                'nofiles'       => True 
     857                        )); 
     858 
     859                        $fileinfo = $ls_array[0]; 
     860 
     861                        if($fileinfo['name']) 
     862                        { 
     863                                if($fileinfo['mime_type'] != 'Directory') 
     864                                { 
     865                                        echo lang('Error:').lang('%1 already exists as a file',$fileinfo['name']); 
    869866                                } 
    870867                                else 
    871868                                { 
    872                                         if($this->bo->vfs->mkdir(array('string' => $this->newfile_or_dir))) 
    873                                         { 
    874                                                 $this->messages[]=lang('Created directory %1', $this->disppath.'/'.$this->newfile_or_dir); 
    875                                         } 
    876                                         else 
    877                                         { 
    878                                                 $this->messages[]=lang('Error:').lang('Could not create %1', $this->disppath.'/'.$this->newfile_or_dir); 
    879                                         } 
    880                                 } 
    881  
    882                                 $this->readFilesInfo(); 
    883                                 $this->filelisting(); 
    884                         } 
     869                                        echo lang('Error:').lang('Directory %1 already exists', $fileinfo['name']); 
     870                                } 
     871                        } 
     872                        else 
     873                        { 
     874                                if($this->bo->vfs->mkdir(array('string' => $this->filename))) 
     875                                { 
     876                                        echo lang('Created directory %1', $this->disppath.'/'.$this->filename); 
     877                                } 
     878                                else 
     879                                { 
     880                                        echo lang('Error:').lang('Could not create %1', $this->disppath.'/'.$this->filename); 
     881                                } 
     882                        } 
     883                        echo lang('Directory created'); 
    885884                } 
    886885                function getReturnExecuteForm(){ 
Note: See TracChangeset for help on using the changeset viewer.