Ignore:
Timestamp:
11/03/09 16:25:43 (14 years ago)
Author:
amuller
Message:

Ticket #597 - Implentação, melhorias do modulo gerenciador de arquivos

File:
1 edited

Legend:

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

    r1557 r1575  
    2323                        'help'  => True, 
    2424                        'view'  => True, 
     25                        'export'=> True, 
     26                        'touch' => True, 
    2527                        'history' => True, 
    2628                        'edit' => True, 
     
    285287                        echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/main.js'></script>"; 
    286288                        echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/common_functions.js'></script>"; 
     289                        echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/connector.js'></script>"; 
    287290                        include('load_lang.php'); 
    288291 
     
    561564                        } 
    562565                } 
    563  
     566                // String format is YYYY-MM-DD HH:MM 
     567                function dateString2timeStamp($string){ 
     568                        return mktime($string[11].$string[12], 
     569                                $string[14].$string[15], 
     570                                $string[17].$string[18],  
     571                                $string[5].$string[6],  
     572                                $string[8].$string[9], 
     573                                $string[0].$string[1]. 
     574                                $string[2].$string[3]); 
     575                } 
    564576                function fileListing() 
    565577                { 
     
    625637                                        $this->t->set_var('row_tr_color','#dedede'); 
    626638                                         
    627                                         //kan dit weg? 
    628639                                        $this->t->parse('rows','row'); 
    629640                                         
     
    750761 
    751762                                                                $col_data='<a href="'.$link.'" target="'.$this->target.'">'.$icon.'</a>&nbsp;<a href="'.$link.'" target="'.$this->target.'">'.$files['name'].'</a>'; 
     763                                                                if ($files['mime_type'] == "text/html") 
     764                                                                { 
     765                                                                        $link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.export','file='.$files['name'].'&path='.$this->path); 
     766                                                                        $image=$GLOBALS['phpgw']->common->image('filemanager','button_export'); 
     767                                                                        $col_data.='<a href="'.$link.'"><img alt="'.lang("export").'" src="'.$image.'"></a>'; 
     768                                                                } 
    752769                                                        } 
    753770                                                } 
     
    785802                                        if($this->prefs['created']) 
    786803                                        { 
    787                                                 $col_data=$files['created']; 
     804                                                $timestamp = $this->dateString2timeStamp($files['created']); 
     805                                                if (time() - $timestamp > 86400) // Older than yesterday 
     806                                                        $col_data=date("Y-m-d",$timestamp); 
     807                                                else 
     808                                                        $col_data=date("H:i",$timestamp); 
    788809                                                $this->t->set_var('col_data',$col_data); 
    789810                                                $this->t->parse('columns','column',True); 
     
    793814                                        if($this->prefs['modified']) 
    794815                                        { 
    795                                                 if($files['modified'] != '0000-00-00') 
    796                                                 { 
    797                                                         $col_data=$files['modified']; 
     816                                                if ($files['modified'] != ''){ 
     817                                                        $timestamp = $this->dateString2timeStamp($files['modified']); 
     818                                                        if (time() - $timestamp > 86400) // Older than yesterday 
     819                                                                $col_data=date("Y-m-d",$timestamp); 
     820                                                        else 
     821                                                                $col_data=date("H:i",$timestamp); 
    798822                                                } 
    799823                                                else 
    800                                                 { 
    801824                                                        $col_data=''; 
    802                                                 } 
    803  
    804825                                                $this->t->set_var('col_data',$col_data); 
    805826                                                $this->t->parse('columns','column',True); 
     
    10601081                                                if ($usedSpace < $total) 
    10611082                                                        $toolbar.=$this->inputImage('upload','upload',lang('Upload')); 
     1083                                                 
     1084 
    10621085                                        } 
    10631086                                        $toolbar.='</tr></table>'; 
     
    10781101                                                { 
    10791102                                                        // edit text file button 
    1080                                                         // $toolbar.=$this->inputImage('edit','edit',lang('edit')); 
     1103                                                        $toolbar.=$this->inputImage('edit','edit',lang('edit')); 
    10811104                                                } 
    10821105 
     
    16181641                                $ls_array = $this->bo->vfs->ls(array( 
    16191642                                        'string'        => $this->path.'/'.$this->file, 
    1620                                         'relatives'     => array(RELATIVE_ALL), 
     1643                                        'relatives'     => array(RELATIVE_NONE), 
    16211644                                        'checksubdirs'  => False, 
    16221645                                        'nofiles'       => True 
    16231646                                )); 
     1647                                $timestamp = $this->dateString2timeStamp($ls_array[0]['modified']); 
     1648                                if (time() - $timestamp < 60 && $ls_array[0]['modifiedby_id'] != $GLOBALS['phpgw_info']['user']['account_id']) // recently than last minute: someone is editing 
     1649                                { 
     1650                                        echo lang('This file is being edited right now by:').$GLOBALS['phpgw']->accounts->id2name($ls_array[0]['modifiedby_id']); 
     1651                                        return False; 
     1652                                         
     1653                                } 
     1654                                $this->bo->vfs->touch(array( 
     1655                                        'string'=> $this->path.'/'.$this->file, 
     1656                                        'relatives'     => array(RELATIVE_NONE) 
     1657                                )); 
    16241658 
    16251659                                if($ls_array[0]['mime_type']) 
     
    16311665                                        $mime_type = 'text/plain'; 
    16321666                                } 
    1633                                 $viewable = array('','text/plain','text/csv','text/html','text/text'); 
    1634  
    1635                                 if(!in_array($mime_type,$viewable)){ 
     1667                                $editable = array('','text/plain','text/csv','text/html','text/text','message/rfc822'); 
     1668 
     1669                                if(!in_array($mime_type,$editable)){ 
    16361670                                        echo lang('Impossbile to edit this file'); 
    16371671                                        return False; 
     
    16411675                        $this->readFilesInfo(); 
    16421676 
    1643                         $this->t->set_file(array('filemanager_edit' => 'edit_file.tpl')); 
    1644                         $this->t->set_block('filemanager_edit','row','row'); 
     1677                        if ($mime_type == 'text/html') 
     1678                        { 
     1679                                $this->t->set_file(array('filemanager_edit' => 'edit_html.tpl')); 
     1680                                $this->t->set_block('filemanager_edit','row','row'); 
     1681                                include_once("fckeditor.php"); 
     1682                                $oFCKeditor = new FCKeditor('edit_file_content') ; 
     1683                                $oFCKeditor->BasePath   = 'filemanager/tp/fckeditor/'; 
     1684                                $oFCKeditor->ToolbarSet = 'Default'; 
     1685 
     1686                        } 
     1687                        else{ 
     1688                                $this->t->set_file(array('filemanager_edit' => 'edit_file.tpl')); 
     1689                                $this->t->set_block('filemanager_edit','row','row'); 
     1690 
     1691                        } 
     1692 
     1693                        $vars[refresh_script] = "<script src='filemanager/js/refresh.js'></script>"; 
    16451694 
    16461695                        $vars[preview_content]=''; 
     
    17251774                                        $vars[buttonDone]=$this->inputImage('edit_save_done','ok',lang('Save %1, and go back to file listing ', $this->bo->html_encode($this->fileman[$j], 1))); 
    17261775                                        $vars[buttonCancel]=$this->inputImage('edit_cancel','cancel',lang('Cancel editing %1 without saving', $this->bo->html_encode($this->fileman[$j], 1))); 
     1776 
     1777                                         if ($mime_type == 'text/html'){ 
     1778                                        $oFCKeditor->Value = $content; 
     1779                                        $vars[fck_edit] = $oFCKeditor->Create(); 
     1780 
     1781                                        } 
     1782 
     1783 
    17271784                                        $this->t->set_var($vars); 
    17281785                                        $this->t->parse('rows','row'); 
     
    17871844                        } 
    17881845                } 
    1789  
     1846                function touch(){ 
     1847                        if($this->file) 
     1848                        if ($this->bo->vfs->touch(array('string'=> $this->file,'relatives' => array(RELATIVE_ALL)))) 
     1849                        { 
     1850                                echo "True"; 
     1851                                return True; 
     1852                        } 
     1853                        else 
     1854                                return False; 
     1855 
     1856                } 
    17901857                function view() 
    17911858                { 
     
    18281895                } 
    18291896 
     1897                function export(){ 
     1898                        if($this->file) 
     1899                        { 
     1900                                $ls_array = $this->bo->vfs->ls(array( 
     1901                                        'string'        => $this->path.'/'.$this->file, 
     1902                                        'relatives'     => array(RELATIVE_NONE), 
     1903                                        'checksubdirs'  => False, 
     1904                                        'nofiles'       => True 
     1905                                )); 
     1906                                $timestamp = $this->dateString2timeStamp($ls_array[0]['modified']); 
     1907                                if (time() - $timestamp < 60 && $ls_array[0]['modifiedby_id'] != $GLOBALS['phpgw_info']['user']['account_id']); 
     1908                                { 
     1909                                                // recently than last minute: someone is editing 
     1910                                } 
     1911                                $mime_type = $ls_array[0]['mime_type']; 
     1912                                $formats = array('text/html'); 
     1913                                if(!in_array($mime_type,$formats)){ 
     1914                                        echo lang('Impossbile to export this file'); 
     1915                                        return False; 
     1916                                } 
     1917                                $content = $this->bo->vfs->read(array('string' => $this->path.'/'.$this->file, 
     1918                                               'relatives'     => array(RELATIVE_NONE) 
     1919                                       )); 
     1920 
     1921                                include_once('filemanager/tp/dompdf/dompdf_config.inc.php'); 
     1922                                $dompdf = new DOMPDF(); 
     1923                                $dompdf->load_html($content); 
     1924                                $dompdf->set_paper('letter', 'portrait'); 
     1925                                $dompdf->render(); 
     1926                                $dompdf->stream(strtok($this->file,'.').".pdf"); 
     1927                                $GLOBALS['phpgw']->common->phpgw_exit(); 
     1928                        } 
     1929                } 
    18301930                function download() 
    18311931                { 
     
    19222022                        if(!$mime_type) $mime_type='unknown'; 
    19232023 
    1924                         $mime_type=     str_replace     ('/','_',$mime_type); 
     2024                        $mime_type=str_replace  ('/','_',$mime_type); 
    19252025 
    19262026                        $img=$GLOBALS['phpgw']->common->image('filemanager','mime'.$size.'_'.strtolower($mime_type)); 
Note: See TracChangeset for help on using the changeset viewer.