Changeset 1575 for sandbox/filemanager/inc/class.uifilemanager.inc.php
- Timestamp:
- 11/03/09 16:25:43 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/filemanager/inc/class.uifilemanager.inc.php
r1557 r1575 23 23 'help' => True, 24 24 'view' => True, 25 'export'=> True, 26 'touch' => True, 25 27 'history' => True, 26 28 'edit' => True, … … 285 287 echo "<script src='".$GLOBALS['phpgw_info']['flags']['currentapp']."/js/main.js'></script>"; 286 288 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>"; 287 290 include('load_lang.php'); 288 291 … … 561 564 } 562 565 } 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 } 564 576 function fileListing() 565 577 { … … 625 637 $this->t->set_var('row_tr_color','#dedede'); 626 638 627 //kan dit weg?628 639 $this->t->parse('rows','row'); 629 640 … … 750 761 751 762 $col_data='<a href="'.$link.'" target="'.$this->target.'">'.$icon.'</a> <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 } 752 769 } 753 770 } … … 785 802 if($this->prefs['created']) 786 803 { 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); 788 809 $this->t->set_var('col_data',$col_data); 789 810 $this->t->parse('columns','column',True); … … 793 814 if($this->prefs['modified']) 794 815 { 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); 798 822 } 799 823 else 800 {801 824 $col_data=''; 802 }803 804 825 $this->t->set_var('col_data',$col_data); 805 826 $this->t->parse('columns','column',True); … … 1060 1081 if ($usedSpace < $total) 1061 1082 $toolbar.=$this->inputImage('upload','upload',lang('Upload')); 1083 1084 1062 1085 } 1063 1086 $toolbar.='</tr></table>'; … … 1078 1101 { 1079 1102 // edit text file button 1080 //$toolbar.=$this->inputImage('edit','edit',lang('edit'));1103 $toolbar.=$this->inputImage('edit','edit',lang('edit')); 1081 1104 } 1082 1105 … … 1618 1641 $ls_array = $this->bo->vfs->ls(array( 1619 1642 'string' => $this->path.'/'.$this->file, 1620 'relatives' => array(RELATIVE_ ALL),1643 'relatives' => array(RELATIVE_NONE), 1621 1644 'checksubdirs' => False, 1622 1645 'nofiles' => True 1623 1646 )); 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 )); 1624 1658 1625 1659 if($ls_array[0]['mime_type']) … … 1631 1665 $mime_type = 'text/plain'; 1632 1666 } 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)){ 1636 1670 echo lang('Impossbile to edit this file'); 1637 1671 return False; … … 1641 1675 $this->readFilesInfo(); 1642 1676 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>"; 1645 1694 1646 1695 $vars[preview_content]=''; … … 1725 1774 $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))); 1726 1775 $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 1727 1784 $this->t->set_var($vars); 1728 1785 $this->t->parse('rows','row'); … … 1787 1844 } 1788 1845 } 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 } 1790 1857 function view() 1791 1858 { … … 1828 1895 } 1829 1896 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 } 1830 1930 function download() 1831 1931 { … … 1922 2022 if(!$mime_type) $mime_type='unknown'; 1923 2023 1924 $mime_type= 2024 $mime_type=str_replace ('/','_',$mime_type); 1925 2025 1926 2026 $img=$GLOBALS['phpgw']->common->image('filemanager','mime'.$size.'_'.strtolower($mime_type));
Note: See TracChangeset
for help on using the changeset viewer.