Changeset 2317 in subversion


Ignore:
Timestamp:
Feb 27, 2009 5:56:45 AM (4 years ago)
Author:
thomasb
Message:

Changed code style for better diffs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/lib/html2text.php

    r2248 r2317  
    202202        "\t* \\1\n",                            // <li> and </li> 
    203203        "\n\t* ",                               // <li> 
    204         "\n-------------------------\n",        // <hr> 
    205         "\n\n",                                 // <table> and </table> 
     204        "\n-------------------------\n",        // <hr> 
     205        "\n\n",                                 // <table> and </table> 
    206206        "\n",                                   // <tr> and </tr> 
    207207        "\t\t\\1\n",                            // <td> and </td> 
     
    248248    */ 
    249249    var $pre_search = array( 
    250         "/\n/", 
    251         "/\t/", 
    252         '/ /', 
    253         '/<pre[^>]*>/', 
    254         '/<\/pre>/' 
     250        "/\n/", 
     251        "/\t/", 
     252        '/ /', 
     253        '/<pre[^>]*>/', 
     254        '/<\/pre>/' 
    255255    ); 
    256256 
     
    263263     */ 
    264264    var $pre_replace = array( 
    265         '<br>', 
    266         '&nbsp;&nbsp;&nbsp;&nbsp;', 
    267         '&nbsp;', 
    268         '', 
    269         '' 
     265        '<br>', 
     266        '&nbsp;&nbsp;&nbsp;&nbsp;', 
     267        '&nbsp;', 
     268        '', 
     269        '' 
    270270    ); 
    271271 
     
    343343            $this->set_html($source, $from_file); 
    344344        } 
    345          
     345 
    346346        $this->set_base_url(); 
    347         $this->_do_links = $do_links; 
    348         $this->width = $width; 
     347        $this->_do_links = $do_links; 
     348        $this->width = $width; 
    349349    } 
    350350 
     
    360360    { 
    361361        if ( $from_file && file_exists($source) ) { 
    362             $this->html = file_get_contents($source);  
     362            $this->html = file_get_contents($source);  
    363363        } 
    364364        else 
    365             $this->html = $source; 
     365            $this->html = $source; 
    366366 
    367367        $this->_converted = false; 
     
    464464        $text = trim(stripslashes($this->html)); 
    465465 
    466         // Convert <PRE> 
     466        // Convert <PRE> 
    467467        $this->_convert_pre($text); 
    468468 
     
    471471        $text = preg_replace_callback($this->callback_search, array('html2text', '_preg_callback'), $text); 
    472472 
    473         // Replace known html entities 
    474         $text = html_entity_decode($text, ENT_COMPAT, 'UTF-8'); 
     473        // Replace known html entities 
     474        $text = html_entity_decode($text, ENT_COMPAT, 'UTF-8'); 
    475475 
    476476        // Remove unknown/unhandled entities (this cannot be done in search-and-replace block) 
     
    548548    function _convert_pre(&$text) 
    549549    { 
    550         while(preg_match('/<pre[^>]*>(.*)<\/pre>/ismU', $text, $matches)) 
    551         { 
    552             $result = preg_replace($this->pre_search, $this->pre_replace, $matches[1]); 
    553             $text = preg_replace('/<pre[^>]*>.*<\/pre>/ismU', '<div><br>' . $result . '<br></div>', $text, 1); 
    554         } 
     550        while(preg_match('/<pre[^>]*>(.*)<\/pre>/ismU', $text, $matches)) { 
     551            $result = preg_replace($this->pre_search, $this->pre_replace, $matches[1]); 
     552            $text = preg_replace('/<pre[^>]*>.*<\/pre>/ismU', '<div><br>' . $result . '<br></div>', $text, 1); 
     553        } 
    555554    } 
    556555 
     
    564563    function _preg_callback($matches) 
    565564    { 
    566         switch($matches[1]) 
    567         { 
    568             case 'b': 
    569             case 'strong': 
    570                 return $this->_strtoupper($matches[2]); 
    571             case 'hr': 
    572                 return $this->_strtoupper("\t\t". $matches[2] ."\n"); 
    573             case 'h': 
    574                 return $this->_strtoupper("\n\n". $matches[2] ."\n\n"); 
    575             case 'a': 
    576                 return $this->_build_link_list($matches[3], $matches[4]); 
    577         } 
     565        switch($matches[1]) { 
     566        case 'b': 
     567        case 'strong': 
     568            return $this->_strtoupper($matches[2]); 
     569        case 'hr': 
     570            return $this->_strtoupper("\t\t". $matches[2] ."\n"); 
     571        case 'h': 
     572            return $this->_strtoupper("\n\n". $matches[2] ."\n\n"); 
     573        case 'a': 
     574            return $this->_build_link_list($matches[3], $matches[4]); 
     575        } 
    578576    } 
    579577     
     
    587585    function _strtoupper($str) 
    588586    { 
    589         if (function_exists('mb_strtoupper')) 
    590             return mb_strtoupper($str); 
    591         else 
    592             return strtoupper($str); 
     587        if (function_exists('mb_strtoupper')) 
     588            return mb_strtoupper($str); 
     589        else 
     590            return strtoupper($str); 
    593591    } 
    594592} 
Note: See TracChangeset for help on using the changeset viewer.