Changeset 1707


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

Ticket #788 - Substituição da expressão regular para varias mais legíveis

File:
1 edited

Legend:

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

    r1638 r1707  
    452452 
    453453                $return_get_body = $this->get_body_msg($msg_number, $msg_folder); 
    454  
    455                 //Substituição de links em email para abrir no próprio expresso 
    456                 $body = mb_ereg_replace("<a[^>]*href=[\'\"]mailto:([^\"\']+)[\'\"]>([^<]+)</a>","<a href=\"javascript:new_message_to('\\1')\">\\2</a>",$return_get_body['body']); 
     454                 
     455                $body = $return_get_body['body']; 
    457456                //Remoção de tags <span></span> para correção de erro no firefox 
    458457                $body = mb_ereg_replace("<span><span>","",$body); 
     
    471470            $return['thumbs']           = $return_get_body['thumbs']; 
    472471            $return['signature']        = $return_get_body['signature']; 
    473         } 
     472                } 
     473 
    474474                $pattern = '/^[ \t]*Disposition-Notification-To(^:)*:(.+)*@(.+)*$/isUm'; 
    475475                if (preg_match($pattern, $header_, $fields)) 
     
    703703                $return['login'] = $_SESSION['phpgw_info']['expressomail']['user']['account_id'];//$GLOBALS['phpgw_info']['user']['account_id']; 
    704704                $return['reply_toaddress'] = $header->reply_toaddress; 
    705  
    706705                return $return; 
    707706        } 
     
    10521051                        'applet','embed','frameset','xml','xmp','style'); 
    10531052 
    1054                 $body = $this-> replace_links($body); 
    10551053                $blocked_tags = array(); 
    10561054                foreach($tag_list as $index => $tag) { 
     
    10681066                        $body = str_replace($rest[1][$i],"<".$rest[2][$i].$rest[3][$i].$rest[7][$i].">",$body); 
    10691067 
    1070                 return  "<span>".$body; 
     1068                return  "<span>".$this-> replace_links($body); 
    10711069        } 
    10721070 
     
    10781076                if(count($matches)) 
    10791077                        return $body; 
    1080                  
    1081                 $pattern = '/(?<=[\s\><\n\r;])((http(s?):\/\/((?:[\w]\.?)+(?::[\d]+)?[\/.\-~&=?%;@#,+\w:]*))|((?:www?\.)(?:\w\.?)*(?::\d+)?[\/\w.\-~&=?%;@+]*))/i'; 
    1082                  
    1083                 $replacement = '<a href="http$3://$4$5" target="_blank">$1</a>'; 
    1084                 return preg_replace($pattern, $replacement, $body); 
    1085  
    1086                 // Original 
    1087                 //return preg_replace('/(?<=[\s|(<br>)|\n|\r|;])((http(s?):\/\/((?:[\w]\.?)+(?::[\d]+)?[\/.\-~&=?%;@#,+\w]*))|((?:www?\.)(?:\w\.?)*(?::\d+)?[\/\w.\-~&=?%;@+]*))/i', '<a href="http$3://$4$5" target="_blank">http$3://$4$5</a>', $body); 
     1078 
     1079                /* Replace links tags <a href="" ></a> to links with target=_blank */ 
     1080                $pattern = '/<a[^>]+href="([^>"]+)"[^>]*>(.*)<\/a>/im'; 
     1081                $replacement = '<a href="$1" target="_blank">$2</a>'; 
     1082                $body = preg_replace($pattern, $replacement, $body); 
     1083 
     1084                /*Replace websites that does NOT begin with href=" to links */ 
     1085                $pattern = '/([^h][^r][^e][^f][^=][^"])((https?:\/\/)[A-Za-z0-9\.~?\/_=&#;\-:]*)/m'; 
     1086                $replacement = '$1<a href="$2" target="_blank">$2</a>'; 
     1087                $body = preg_replace($pattern, $replacement, $body); 
     1088 
     1089                /*Transform email address in new_message_to*/ 
     1090                $pattern = '/([A-Za-z0-9\.~?\/_=#\-]*@[A-Za-z0-9\.~?\/_=#\-]*)/im'; 
     1091                $replacement = '<a href="javascript:new_message_to(\'$1\')">$1</a>'; 
     1092                $body = preg_replace($pattern, $replacement, $body); 
     1093 
     1094                /*Subs. email links to expresso*/ 
     1095                $body = mb_ereg_replace("<a[^>]*href=[\'\"]mailto:([^\"\']+)[\'\"]>([^<]+)</a>", 
     1096                        "<a href=\"javascript:new_message_to('\\1')\">\\2</a>",$body); 
     1097 
     1098 
     1099                return $body; 
    10881100        } 
    10891101 
Note: See TracChangeset for help on using the changeset viewer.