Changeset 1829


Ignore:
Timestamp:
12/15/09 09:13:57 (14 years ago)
Author:
amuller
Message:

Ticket #597 - Melhoria do FM, miniatura thumbnail de imagens

Location:
sandbox/filemanager
Files:
4 edited

Legend:

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

    r1704 r1829  
    2525                        'editComment'=> True, 
    2626                        'rename'=>True, 
    27                         'delete'=>True 
     27                        'delete'=>True, 
     28                        'summary' => True 
    2829                ); 
    2930 
     
    214215 
    215216                } 
    216                 function download() 
     217                function summary() 
    217218                { 
    218219                        if($this->file) 
    219                         { 
    220                                 //$GLOBALS['phpgw']->browser->content_header($this->file); 
    221                                 header ("Content-Type: application/octet-stream"); 
    222                                 header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); 
     220                        {        
     221                                header('Content-Type: image/gif'); 
     222                                $expires = 60*60*24*15; /* 15 days */ 
     223                                header("Cache-Control: maxage=".$expires); 
    223224                                header("Pragma: public"); 
    224                                 header("Expires: 0"); 
    225                                 header ("Content-Disposition: attachment; filename=\"". addslashes($this->file)."\""); 
    226                                 echo $this->bo->vfs->read(array('string' => $this->file)); 
     225                                header("Expires: ".gmdate('D, d M Y H:i:s', time()+$expires)); 
     226                                echo $this->bo->vfs->summary(array('path' => $this->path, 
     227                                        'string' => $this->file 
     228                                )); 
    227229                                $GLOBALS['phpgw']->common->phpgw_exit(); 
    228230                        } 
    229231                } 
     232         
    230233                function delete(){ 
    231234                        foreach($this->fileman as $filename) 
  • sandbox/filemanager/inc/upload.php

    r1804 r1829  
    2020$path = base64_decode($_POST['path']); 
    2121$show_upload_boxes = count($_FILES['upload_file']['name'])-1; 
     22 
     23 
     24function create_summaryImage($file){ 
     25        list($width, $height,$image_type) = getimagesize($file); 
     26        switch($image_type) 
     27        { 
     28        case 1: 
     29                $image_big = imagecreatefromgif($file); 
     30                break; 
     31        case 2: 
     32                $image_big = imagecreatefromjpeg($file); 
     33                break; 
     34        case 3: 
     35                $image_big = imagecreatefrompng($file); 
     36                break; 
     37        default: 
     38                return; 
     39        } 
     40        $max_resolution = 48; 
     41        if ($width > $height){ 
     42                $new_width = $max_resolution; 
     43                $new_height = $height*($new_width/$width); 
     44        } 
     45        else { 
     46                $new_height = $max_resolution; 
     47                $new_width = $width*($new_height/$height); 
     48        } 
     49        $image_new = imagecreatetruecolor($new_width, $new_height); 
     50        imagecopyresampled($image_new, $image_big, 0, 0, 0, 0, $new_width, $new_height, $width, $height); 
     51        ob_start(); 
     52        imagegif($image_new); 
     53        $content = ob_get_clean(); 
     54        return $content; 
     55} 
    2256 
    2357/* Its much faster test all files only one time */ 
     
    97131                        else 
    98132                        { 
    99  
     133                 
    100134                                if ($bo->vfs->cp(array( 
    101135                                        'from'=> $_FILES['upload_file']['tmp_name'][$i], 
     
    103137                                        'relatives'     => array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL) 
    104138                                ))) 
     139                                { 
    105140                                        $bo->vfs->set_attributes(array( 
    106141                                                'string'=> $_FILES['upload_file']['name'][$i], 
     
    111146                                        ) 
    112147                                )); 
     148                                        if (!(strpos(strtoupper($_FILES['upload_file']['type'][$i]),'IMAGE') === FALSE)) 
     149                                        { 
     150                                                $content = create_summaryImage($_FILES['upload_file']['tmp_name'][$i]); 
     151                                                $bo->vfs->set_summary(array( 
     152                                                'string'=> $_FILES['upload_file']['name'][$i], 
     153                                                'relatives' => array(RELATIVE_ALL), 
     154                                                'summary'=> $content 
     155                                        )); 
     156                                        } 
     157                                } 
    113158                                else{ 
    114159                                        $return[] = lang('Error:').lang('Your quota has exceeded the limit'); 
     
    129174                                'relatives'     => array(RELATIVE_ALL), 
    130175                                'attributes'=> array( 
    131                                         'mime_type' => $_FILES['upload_file']['type'][$i], 
    132                                         'comment' => stripslashes($_POST['upload_comment'][$i]) 
     176                                'mime_type' => $_FILES['upload_file']['type'][$i], 
     177                                'comment' => stripslashes($_POST['upload_comment'][$i]) 
    133178                                ) 
    134179                        )); 
  • sandbox/filemanager/js/draw_api.js

    r1815 r1829  
    239239                        retBuff += '<td></td>'; 
    240240                retBuff += fl.td+'<img src="'+(file.icon)+'">'; 
    241                 retBuff += '<a id="name_'+file.name+'" href="./index.php?menuaction=filemanager.uifilemanager.view&file='+base64_encode(file.name)+'&path='+base64_encode(currentPath)+'" target="_blank">'+file.name+'</a>&nbsp;</td>'; 
     241                if((file.mime).toUpperCase().indexOf('IMAGE') == 0) 
     242                        var mousefunc = 'draw_card(\''+file.name+'\')' 
     243                else 
     244                        var mousefunc = 'document.getElementById(\'menu_newFilepreview\').style.visibility = \'hidden\''; 
     245                retBuff += '<a onmouseover="'+mousefunc+'" id="name_'+file.name+'" href="./index.php?menuaction=filemanager.uifilemanager.view&file='+base64_encode(file.name)+'&path='+base64_encode(currentPath)+'" target="_blank">'+file.name+'</a>&nbsp;</td>'; 
    242246                if (preferences.mime_type =='1') retBuff += fl.td+file.mime+'</td>'; 
    243247                if (preferences.size =='1') retBuff += fl.td+borkb(file.size)+'</td>'; 
     
    531535var toolbar = new toolbar(); 
    532536 
     537 
     538function draw_card(filename){ 
     539        draw_window_card('preview','./index.php?menuaction=filemanager.vfs_functions.summary&file='+base64_encode(filename)+"&path="+base64_encode(currentPath)); 
     540} 
     541 
     542function draw_window_card(id,url){ 
     543        var menu = document.getElementById('menu_newFile'+id); 
     544        if (menu == null){ 
     545                menu = document.createElement('DIV'); 
     546                menu.className = 'menubox'; 
     547                menu.id = "menu_newFile"+id; 
     548                menu.style.left = DocX; 
     549                menu.style.top = (DocY+20)+"px"; 
     550                menu.width = "100%"; 
     551                menu.innerHTML = '<img src="'+url+'">'; 
     552                menu.onmouseout = function () { menuTimeout = setTimeout("document.getElementById('menu_newFile"+id+"').style.visibility = 'hidden'",50);} 
     553                menu.onmouseover = function () { clearTimeout(menuTimeout); }; 
     554                menu.style.zIndex='1'; 
     555                document.getElementById('divAppboxHeader').appendChild(menu); 
     556        } 
     557        else 
     558        { 
     559                menu.style.left = DocX; 
     560                menu.style.top = (DocY+20)+"px"; 
     561                menu.innerHTML = '<img src="'+url+'">'; 
     562        } 
     563        menu.style.visibility = 'visible'; 
     564        clearTimeout(menuTimeout); 
     565        menuTimeout = setTimeout("document.getElementById('menu_newFile"+id+"').style.visibility = 'hidden'",5000); 
     566} 
     567 
  • sandbox/filemanager/templates/default/main.css

    r1804 r1829  
    1717    cursor: pointer; 
    1818    position: absolute; 
    19     width: 160px; 
     19    /* width: 160px;*/ 
    2020    text-align: left; 
    2121    line-height:150%; 
Note: See TracChangeset for help on using the changeset viewer.