Ticket #799: remove-closeTags.diff

File remove-closeTags.diff, 2.8 KB (added by Nicolas, 15 years ago)

Remove closeTags function and same-named property of output_options

  • html/inc/text_transform.inc

     
    2929    var $bb2html;            // BBCode as HTML? (on)
    3030    var $images_as_links;    // Images as hyperlinks? (off)
    3131    var $link_popup;        // Links in new windows? (off)
    32     var $closeTags;            // Close extra HTML tags? (on)
    3332    var $nl2br;                // Convert newlines to <br>'s? (on)
    3433    var $htmlitems;            // Convert special chars to HTML entities? (on)
    3534    var $htmlscrub;            // Scrub "bad" HTML tags? (off)
     
    4140        $this->bb2html = 1;
    4241        $this->images_as_links = 0;
    4342        $this->link_popup = 0;
    44         $this->closeTags = 1;
    4543        $this->nl2br = 1;
    4644        $this->htmlitems = 1;
    4745        $this->htmlscrub = 0;
     
    213211    return $text;
    214212}
    215213
    216 // Closes open HTML tags.  Not quite perfect...
    217 
    218 function closeTags($str = null) {
    219     // Function from http://episteme.arstechnica.com/eve/ubb.x/a/tpc/f/6330927813/m/139006252731/r/287008552731#287008552731
    220     // (thanks Ageless for finding it)
    221     // Edited by Rob to better fit in with boinc's needs
    222    
    223     // List of tags to check $str for
    224     // TODO:  Adapt to use the pre-existing array of tags above
    225     $tags = array('b', 'i', 'a', 'p', 'font[^>]?', 'strong', 'ul', 'li', 'pre', 'blockquote', 'u');
    226     // Note on $tags - no br or img, as they have no closing tags - can we define this above?
    227     // Maybe define two arrays, those with closing tags and those without, and combine the
    228     // two of them for the standard HTML sanitizing function?
    229 
    230     // Don't do anything if the string is too short
    231     if (strlen($str) < 3) {
    232         return $str;
    233     } else {
    234         // Loop over $str and count the opening and closing for each tag in $tags
    235         foreach ($tags as $tag) {
    236             $m = array();
    237             $o = preg_match_all("/<(".$tag.")>/", $str, $m);
    238             $c = substr_count($str, "</{$tag}>");
    239 
    240             $open[$tag]  = ($o < $c) ? $c - $o : 0;
    241             $close[$tag] = ($c < $o) ? $o - $c : 0;
    242 
    243             // Debuggin'
    244             //echo "<pre>Tag: {$tag}\nOpen: {$o}\nClose: {$c}\nOT: {$open[$tag]}\nCT: {$close[$tag]}</pre><hr />";
    245         }
    246 
    247         // Prepend the return string with an opening tag as needed
    248         /* $pre = '';  ...uhh... doesn't work right
    249 
    250         foreach ($open as $tag => $cnt) {
    251             $pre .= ($cnt > 0) ? "<{$tag}>" : '';
    252         }  */
    253 
    254         // Append the return string with a closing tag as needed
    255         $post = '';
    256 
    257         foreach ($close as $tag => $cnt) {
    258             $post .= ($cnt > 0) ? "</{$tag}>" : '';
    259         }
    260 
    261         return /*$pre.*/$str.$post;
    262     }
    263 }
    264 
    265214
    266215// Highlight terms in text (most likely used with searches)
    267216