Changeset 1005


Ignore:
Timestamp:
06/18/09 09:24:17 (15 years ago)
Author:
amuller
Message:

Ticket #520 - Implementação de redução automática de imagens

Location:
trunk/expressoMail1_2
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/inc/class.imap_functions.inc.php

    r1000 r1005  
    10521052                        if (($file_type == 'image/jpeg') || ($file_type == 'image/pjpeg') || ($file_type == 'image/gif') || ($file_type == 'image/png')) { 
    10531053                                $img = "<IMG id='".$msg_folder.";;".$msg_number.";;".$i.";;".$msg->pid[$msg_number][$index].";;".$msg->encoding[$msg_number][$index]."' style='border:2px solid #fde7bc;padding:5px' title='".$this->functions->getLang("Click here do view (+)")."'src=./inc/show_thumbs.php?file_type=".$file_type."&msg_num=".$msg_number."&msg_folder=".$msg_folder."&msg_part=".$msg->pid[$msg_number][$index].">"; 
    1054                                 $href = "<a onMouseDown='save_image(event,this)' href='#".$msg_folder.";;".$msg_number.";;".$i.";;".$msg->pid[$msg_number][$index].";;".$msg->encoding[$msg_number][$index]."' onClick=\"window.open('./inc/show_img.php?msg_num=".$msg_number."&msg_folder=".$msg_folder."&msg_part=".$msg->pid[$msg_number][$index]."','mywindow','width=700,height=600,scrollbars=yes');\">". $img ."</a>"; 
     1054                                $href = "<a onMouseDown='save_image(event,this,\"".$file_type."\")' href='#".$msg_folder.";;".$msg_number.";;".$i.";;".$msg->pid[$msg_number][$index].";;".$msg->encoding[$msg_number][$index]."' onClick=\"window.open('./inc/show_img.php?msg_num=".$msg_number."&msg_folder=".$msg_folder."&msg_part=".$msg->pid[$msg_number][$index]."','mywindow','width=700,height=600,scrollbars=yes');\">". $img ."</a>"; 
    10551055                                        $thumbs_array[] = $href; 
    10561056                        } 
     
    20322032         
    20332033                //      Build Uploading Attachments!!! 
    2034                 if (count($attachments)) 
    2035                         foreach ($attachments as $attach) 
    2036                                 $mail->AddAttachment($attach['tmp_name'], $attach['name'], "base64", $this->get_file_type($attach['name']));  // optional name                   
     2034                $sizeof_attachments = count($attachments); 
     2035                if ($sizeof_attachments) 
     2036                        foreach ($attachments as $numb => $attach){ 
     2037                                if ($numb == ($sizeof_attachments-1) && $params['insertImg'] == 'true'){ // Auto-resize image 
     2038                                        list($width, $height,$image_type) = getimagesize($attach['tmp_name']); 
     2039                                        switch ($image_type) 
     2040                                        { 
     2041                                        case 1: $image_big = imagecreatefromgif($attach['tmp_name']); break; 
     2042                                        case 2: $image_big = imagecreatefromjpeg($attach['tmp_name']);  break; 
     2043                                        case 3: $image_big = imagecreatefrompng($attach['tmp_name']); break; 
     2044                                        case 6: 
     2045                                                include_once("gd_functions.php"); 
     2046                                                $image_big = imagecreatefrombmp($attach['tmp_name']); break; 
     2047                                        default: 
     2048                                                $mail->AddAttachment($attach['tmp_name'], $attach['name'], "base64", $this->get_file_type($attach['name'])); 
     2049                                                break; 
     2050                                        } 
     2051                                        header('Content-type: image/jpeg'); 
     2052                                        $max_resolution = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['image_size']; 
     2053                                        $max_resolution = ($max_resolution==""?'65536':$max_resolution); 
     2054                                        if ($width < $max_resolution && $height < $max_resolution){ 
     2055                                                $new_width = $width; 
     2056                                                $new_height = $height; 
     2057                                        } 
     2058                                        else if ($width > $max_resolution){ 
     2059                                                $new_width = $max_resolution; 
     2060                                                $new_height = $height*($new_width/$width); 
     2061                                        } 
     2062                                        else { 
     2063                                                $new_height = $max_resolution; 
     2064                                                $new_width = $width*($new_height/$height); 
     2065                                        } 
     2066                                        $image_new = imagecreatetruecolor($new_width, $new_height); 
     2067                                        imagecopyresampled($image_new, $image_big, 0, 0, 0, 0, $new_width, $new_height, $width, $height); 
     2068                                        $tmpDir = ini_get("session.save_path"); 
     2069                                        $_file = "cid_image_".base_convert(microtime(), 10, 36).".dat";  
     2070                                        imagejpeg($image_new,$tmpDir.$_file, 85); 
     2071                                        $mail->AddAttachment($tmpDir.$_file, $attach['name'], "base64", $this->get_file_type($tmpDir.$_file)); 
     2072                                } 
     2073                                else 
     2074                                        $mail->AddAttachment($attach['tmp_name'], $attach['name'], "base64", $this->get_file_type($attach['name'])); 
     2075                                // optional name 
     2076                                } 
     2077         
    20372078         
    20382079         
  • trunk/expressoMail1_2/inc/gotodownload.php

    r178 r1005  
    11<? 
     2        if (! array_key_exists('phpgw_info', $_SESSION)) 
     3                exit; 
     4 
    25        $msg_number = $_GET['msg_number']; 
    36        $idx_file = $_GET['idx_file']; 
     
    2528                $mbox_stream = imap_open("{".$imap_server.":".$imap_port.$imap_options."}".$msg_folder, $username, $password);           
    2629                $fileContent = imap_fetchbody($mbox_stream, $msg_number, $msg_part, FT_UID); 
    27                 include("class.imap_attachment.inc.php"); 
    28                 $imap_attachment = new imap_attachment();                        
    29                 $a = $imap_attachment->download_attachment($mbox_stream, $msg_number); 
    30                  
    31                 $filename = $a[$idx_file]['name']; 
     30                /* 
     31                *Removed by Bug #546 
     32                *include("class.imap_attachment.inc.php"); 
     33                *$imap_attachment = new imap_attachment();                       
     34                *$a = $imap_attachment->download_attachment($mbox_stream, $msg_number); 
     35                *$filename = $a[$idx_file]['name']; 
     36                */ 
     37                $filename = $newfilename; 
    3238        } 
    3339        else 
  • trunk/expressoMail1_2/inc/hook_settings.inc.php

    r1002 r1005  
    6767create_check_box(lang('Use shortcuts?'),'use_shotcuts',''); 
    6868create_check_box(lang('Auto save draft'),'auto_save_draft',''); 
     69$default = array( 
     70        '65536' => lang('unlimited'), 
     71        '640' => '640', 
     72        '768' => '768', 
     73        '800' => '800', 
     74        '1024' => '1024', 
     75        '1080' => '1080' 
     76); 
     77 
     78create_select_box(lang('What is the maximum size of embedded images')."?",'image_size',$default,''); 
    6979 
    7080$default = array( 
  • trunk/expressoMail1_2/js/common_functions.js

    r1000 r1005  
    557557function preferences_mail(){ 
    558558        if(preferences.type_signature && preferences.type_signature == 'html') { 
    559                 location.href="../preferences/preferences.php?appname=expressoMail"; 
     559                location.href="../preferences/preferences.php?appname=expressoMail1_2"; 
    560560        } 
    561561        else { 
  • trunk/expressoMail1_2/js/main.js

    r1000 r1005  
    14371437} 
    14381438 
    1439 function save_msg(border_id){ 
     1439function save_msg(border_id,withImage){ 
     1440        if (typeof(withImage) == 'undefined') 
     1441                withImage = false; 
     1442 
    14401443        var rt_checkbox = Element('viewsource_rt_checkbox'); 
    14411444        if (rt_checkbox == null) 
     
    14511454                var folder_id = openTab.imapBox[border_id]; 
    14521455        else 
    1453                 var     folder_id = "INBOX/"+draftsfolder; 
     1456                var folder_id = "INBOX/"+draftsfolder; 
    14541457 
    14551458        if (folder_id == 'INBOX') // and folder name from border 
     
    14821485        input_msgid.name = "msg_id"; 
    14831486        input_msgid.value = message_id; 
     1487        var input_insertImg = document.createElement("INPUT"); 
     1488        input_insertImg.style.display='none'; 
     1489        input_insertImg.name = "insertImg"; 
     1490        input_insertImg.value = withImage; 
     1491 
    14841492         
    14851493        if (is_ie){ 
     
    14931501        form.appendChild(input_folder); 
    14941502        form.appendChild(input_msgid); 
     1503        form.appendChild(input_insertImg); 
    14951504 
    14961505        cExecuteForm ("$this.imap_functions.save_msg", form, handler_save_msg,border_id);        
     
    17951804 
    17961805// Save image file. 
    1797 function save_image(e,thumb){ 
     1806function save_image(e,thumb,file_type){ 
     1807        file_type = file_type.replace("/","."); 
    17981808        thumb.oncontextmenu = function(e) { 
    17991809                return false; 
     
    18041814        if(_button == 2 || _button == 3) { 
    18051815                var _params = _target.id.split(";;"); 
    1806                 download_attachments(_params[0],_params[1],_params[2],_params[3],_params[4]); 
     1816                download_attachments(_params[0],_params[1],_params[2],_params[3],_params[4],file_type); 
    18071817        } 
    18081818} 
  • trunk/expressoMail1_2/js/messages_proxy.js

    r1000 r1005  
    5151                } 
    5252                else { 
    53                         return "javascript:download_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"',"+numero_ordem_anexo+",'"+info_msg.attachments[numero_ordem_anexo].pid+"','"+info_msg.attachments[numero_ordem_anexo].encoding+"')"; 
     53                        return "javascript:download_attachments('"+info_msg.msg_folder+"','"+info_msg.msg_number+"',"+numero_ordem_anexo+",'"+info_msg.attachments[numero_ordem_anexo].pid+"','"+info_msg.attachments[numero_ordem_anexo].encoding+"','"+info_msg.attachments[numero_ordem_anexo].name+"')"; 
    5454                } 
    5555        } 
  • trunk/expressoMail1_2/js/rich_text_editor.js

    r811 r1005  
    306306        var save_link = document.getElementById("save_message_options_"+id); 
    307307        //save_link.onclick = function () {}; 
    308         save_msg(id); 
     308        save_msg(id,true); 
    309309        setTimeout("RichTextEditor.insertImgHtml("+id+")",1000); 
    310310} 
Note: See TracChangeset for help on using the changeset viewer.