b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (Version 2.4) [ class tree: plugins ] [ index: plugins ] [ all elements ]

Source for file _auto_p.plugin.php

Documentation is available at _auto_p.plugin.php

  1. <?php
  2. /**
  3.  * This file implements the Auto P plugin for b2evolution
  4.  *
  5.  * @author blueyed: Daniel HAHLER - {@link http://daniel.hahler.de/}
  6.  *
  7.  * @package plugins
  8.  */
  9. if!defined('EVO_MAIN_INIT') ) die'Please, do not access this page directly.' );
  10.  
  11.  
  12. /**
  13.  * The Auto-P Plugin.
  14.  *
  15.  * It wraps text blocks, which are devided by newline(s) into HTML P tags (paragraphs)
  16.  * and optionally replaces single newlines with BR tags (line breaks).
  17.  *
  18.  * @package plugins
  19.  */
  20. class auto_p_plugin extends Plugin
  21. {
  22.     var $code = 'b2WPAutP';
  23.     var $name = 'Auto P';
  24.     var $priority = 70;
  25.     var $version = '1.9';
  26.     var $apply_rendering = 'opt-out';
  27.     var $group = 'rendering';
  28.     var $short_desc;
  29.     var $long_desc;
  30.     var $number_of_installs = 1;
  31.  
  32.     /**
  33.      * List of block elements (we want a paragraph before and after), excludes: address, added: td, th
  34.      * @var string 
  35.      */
  36.     var $block_tags = 'blockquote|dd|div|dl|dt|fieldset|form|h[1-6]|hr|li|object|ol|p|pre|select|script|table|td|th|ul';
  37.  
  38.  
  39.     var $p_allowed_in = array('address''applet''blockquote''body''button''center''dd''del''div''fieldset''form''iframe''ins''li''map''noframes''noscript''object''td''th' );
  40.  
  41.  
  42.     var $br_allowed_in = array(
  43.         // Block level:
  44.         'address''center''dl''dir''div''fieldset''form''h1''h2''h3''h4''h5''h6''hr''isindex''menu''noframes''noscript''p''pre',
  45.         // Inline:
  46.         'a''abbr''acronym''applet''b''basefont''bdo''big''button''cite''code''dfn''em''font''i''img''input''iframe''kbd''label''li''map''object''q''samp''select''small''span''strong''sub''sup''textarea''td''th''tt''var' );
  47.  
  48.  
  49.     /**
  50.      * Init
  51.      */
  52.     function PluginInit$params )
  53.     {
  54.         $this->short_desc = T_('Automatic &lt;P&gt; and &lt;BR&gt; tags');
  55.         $this->long_desc = T_('This renderer will automatically detect paragraphs on double line-breaks. and mark them with appropriate HTML &lt;P&gt; tags.<br />
  56.             Optionally, it will also mark single line breaks with HTML &lt;BR&gt; tags.');
  57.     }
  58.  
  59.  
  60.     /**
  61.      * @return array 
  62.      */
  63.     function GetDefaultSettings()
  64.     {
  65.         return array(
  66.                 'br' => array(
  67.                     'label' => T_('Line breaks'),
  68.                     'type' => 'checkbox',
  69.                     'defaultvalue' => 1,
  70.                     'note' => T_('Make line breaks (&lt;br /&gt;) for single newlines.'),
  71.                 ),
  72.                 'add_p_in_block' => array(
  73.                     'label' => T_('Add P tags in blocks (e.g. DIV)'),
  74.                     'type' => 'checkbox',
  75.                     'defaultvalue' => 1,
  76.                     'note' => '',
  77.                 ),
  78.                 'skip_tags' => array(
  79.                     'label' => T_('Ignore tags'),
  80.                     'type' => 'text',
  81.                     'defaultvalue' => 'pre',
  82.                     'note' => T_('A list of tags, in which no P or BR tags should get added.'),
  83.                 ),
  84.             );
  85.     }
  86.  
  87.  
  88.     /**
  89.      * Perform rendering
  90.      */
  91.     function RenderItemAsHtml$params )
  92.     {
  93.         #echo '<hr style="border:1em solid blue;" />';
  94.  
  95.         $this->use_auto_br $this->Settings->get('br');
  96.         $this->add_p_in_block $this->Settings->get('add_p_in_block');
  97.         $this->skip_tags preg_split'~\s+~'$this->Settings->get('skip_tags')-1PREG_SPLIT_NO_EMPTY );
  98.  
  99.         $content $params['data'];
  100.  
  101.         $content preg_replace"~(\r\n|\r)~""\n"$content )// cross-platform newlines
  102.  
  103.         // Handle blocks, splitted by comments. This includes especially the "meta-comments"
  104.         // ("<!--more-->", "<!--nextpage-->" or "<!--noteaser-->"):
  105.         $content_parts preg_split'~(<!--.*?-->)~s'$content-1PREG_SPLIT_DELIM_CAPTURE);
  106.         $content_parts['';
  107.  
  108.         $content '';
  109.         for$i 0$i count($content_parts)$i $i+)
  110.         {
  111.             $content .= $this->handle_blocks$content_parts[$i);
  112.             $content .= $content_parts[$i+1];
  113.         }
  114.  
  115.         return true;
  116.     }
  117.  
  118.  
  119.     /**
  120.      * - Split text into blocks, using $block_tags pattern.
  121.      *
  122.      * @param string Text
  123.      * @param string The HTML tag where $text is in
  124.      * @return string 
  125.      */
  126.     function handle_blocks$text$in_tag '' )
  127.     {
  128.         #echo '<h1>HANDLE_BLOCKS</h1>'; pre_dump( $text, $in_tag );
  129.  
  130.         $new_text '';
  131.  
  132.         ifpreg_match'~^(.*?)(<\s*('.$this->block_tags.')(\b[^>]*)?>)~is'$text$match ) )
  133.         // there's a block tag:
  134.             $tag $match[3];
  135.             $before_tag $match[1];
  136.  
  137.             ifempty($before_tag) )
  138.             // Recurse (one pattern/callback deeper):
  139.                 $new_text .= $this->handle_pre_blocks$before_tag$in_tag );
  140.             }
  141.  
  142.             $text_after_tag substr$textstrlen($match[0]) );
  143.  
  144.  
  145.             ifempty($match[4]|| strpos($match[4]'/'=== false )
  146.             // No self-closing tag: handle text in tag:
  147.                 // Opening tag:
  148.                 $new_text .= $match[2];
  149.  
  150.                 // Find closing tag:
  151.                 list$text_in_tag$closing_tag$NL_before$NL_after $this->split_text_for_tag($tag$text_after_tag);
  152.  
  153.                 ifempty($text_in_tag) )
  154.                 // Recurse (same level):
  155.                     $text_in_tag $this->handle_blocks$text_in_tag$tag );
  156.                 }
  157.  
  158.                 $new_text .= $NL_before.$text_in_tag.$NL_after;
  159.  
  160.                 $new_text .= $closing_tag;
  161.             }
  162.             else
  163.             // self-closing tag:
  164.                 $new_text .= $match[2];
  165.             }
  166.  
  167.             ifempty($text_after_tag) )
  168.             {
  169.                 #echo '<h1>RECURSE: text_after_tag (block)</h1>';
  170.                 // Recurse (same level):
  171.                 $new_text .= $this->handle_blocks$text_after_tag$in_tag );
  172.             }
  173.         }
  174.         else
  175.         // No BLOCKS in this $text:
  176.             $new_text $this->handle_pre_blocks($text$in_tag);
  177.         }
  178.  
  179.         #pre_dump( 'HANDLE_BLOCKS return: ', $new_text, $in_tag );
  180.         return $new_text;
  181.     }
  182.  
  183.  
  184.     /**
  185.      * Handle text which may contain inline tags
  186.      *
  187.      * - Explode by \n\n
  188.      * - Merge blocks that span over multiple tags
  189.      * - Apply BR to blocks
  190.      * - Wrap block in P
  191.      *
  192.      * @param string Text
  193.      * @param string Tag where $text is in
  194.      * @return string 
  195.      */
  196.     function handle_pre_blocks$text$in_tag )
  197.     {
  198.         #echo '<h2>HANDLE_PRE_BLOCKS</h2>'; pre_dump( $text, $in_tag );
  199.  
  200.         if$in_tag )
  201.         {
  202.             ifin_array($in_tag$this->skip_tags) )
  203.             {
  204.                 return $text;
  205.             }
  206.  
  207.             ifin_array($in_tag$this->p_allowed_in) )
  208.             // we're in a tag, where no P tags are allowed, so just do the BRs:
  209.                 return $this->handle_br$text$in_tag );
  210.             }
  211.         }
  212.  
  213.         $text_lines preg_split'~(\n\n+)~'$text-1/*PREG_SPLIT_NO_EMPTY |*/ PREG_SPLIT_DELIM_CAPTURE );
  214.         $text_lines[''// dummy
  215.  
  216.         #echo '<strong>text_lines</strong><br />'; pre_dump( $text_lines, $in_tag );
  217.  
  218.         $new_blocks array();
  219.         $count_new_blocks 0;
  220.         for$i 0$n count($text_lines)$i $n$i $i+/* every second block is a real one */ )
  221.         {
  222.             ifisset($new_blocks[$count_new_blocks]) )
  223.             {
  224.                 $new_blocks[$count_new_blocks'';
  225.             }
  226.             if$text_lines[$i== '' )
  227.             {
  228.                 $new_blocks[$count_new_blocks.= $text_lines[$i+1];
  229.                 $new_blocks[$count_new_blocks+1''// dummy
  230.                 continue;
  231.             }
  232.             $new_blocks[$count_new_blocks.= $text_lines[$i];
  233.             $new_blocks[$count_new_blocks+1$text_lines[$i+1];
  234.             $count_new_blocks $count_new_blocks+2;
  235.         }
  236.  
  237.         $text_lines $new_blocks;
  238.         #echo '<strong>new text_lines</strong><br />'; pre_dump( $new_blocks );
  239.  
  240.         iftrim($text== '' )
  241.         // there's only whitespace
  242.             return $text;
  243.         }
  244.  
  245.  
  246.         // fix it, so no (inline) tags span across multiple blocks:
  247.         $new_blocks array();
  248.         $new_blocks_nowrap array()// blocks that should not be wrapped in P (opening without closing tag or vice versa)
  249.         $count_new_blocks 0;
  250.         $looking_for_close_tag array();
  251.  
  252.         for$i 0$n count($text_lines)$i $n$i $i+/* every 2nd line is a real block */ )
  253.         {
  254.             $line $text_lines[$i];
  255.             ifisset($new_blocks[$count_new_blocks]) )
  256.             {
  257.                 $new_blocks[$count_new_blocks'';
  258.  
  259.                 $line_copy $line;
  260.  
  261.                 whilepreg_match'~^(.*?)(<\s*/\s*(\w+)(\s+[^>]*?)?>)~is'$line_copy$match )
  262.                     && !(preg_match'~^(.*?)(<\s*'.$match[3].'(\s+[^>]*?(\s*/\s*)?)?>)~is'$new_blocks[$count_new_blocks].$match[1)) )
  263.                 // a closing tag:
  264.                     $new_blocks[$count_new_blocks.= $match[0];
  265.                     $line_copy substr($line_copystrlen($match[0]));
  266.                 }
  267.                 ifempty($new_blocks[$count_new_blocks]) )
  268.                 // we've found a closing tag with no opening tag, this must not get wrapped in P:
  269.                     $new_blocks_nowrap[$count_new_blocks;
  270.                     $new_blocks[$count_new_blocks+1''// dummy
  271.                     $new_blocks[$count_new_blocks+2''// init new
  272.                     $line substr$linestrlen($new_blocks[$count_new_blocks]) );
  273.                     $count_new_blocks $count_new_blocks+2;
  274.                 }
  275.             }
  276.             else
  277.             // we're looking for a closing tag:
  278.                 // Find closing tag:
  279.                 $line_copy $line;
  280.                 list$text_in_tag$closing_tag$NL_before$NL_after $this->split_text_for_tag$looking_for_close_tag['tag']$line_copy /* by ref */ );
  281.                 ifempty($closing_tag) )
  282.                 // not in this whole block:
  283.                     $new_blocks$count_new_blocks .= $line.$text_lines[$i+1];
  284.                     continue;
  285.                 }
  286.  
  287.                 // Tag has been found:
  288.                 $looking_for_close_tag array();
  289.             }
  290.  
  291.             ifpreg_match'~^(.*?)(<\s*(\w+)(\s+[^>/]*)?(\s*/\s*)?>)~is'$line$match ) )
  292.             // a opening tag:
  293.                 $tag $match[3];
  294.                 $pos_after_tag strlen($match[0]);
  295.  
  296.                 whileempty($match[5]/* "/" */ )
  297.                 // self-closing tag, find next:
  298.                     $tag false;
  299.                     ifpreg_match'~^(.*?)(<\s*(\w+)(\s+[^>/]*)?(\s*/\s*)?>)~is'substr($line$pos_after_tag)$match ) )
  300.                     {
  301.                         $tag $match[3];
  302.                         $pos_after_tag += strlen($match[0]);
  303.                     }
  304.                 }
  305.                 $text_after_tag substr($line$pos_after_tag);
  306.  
  307.                 if$tag )
  308.                 {
  309.                     // Find closing tag:
  310.                     list$text_in_tag$closing_tag$NL_before$NL_after $this->split_text_for_tag($tag$text_after_tag /* by ref */ );
  311.                     ifempty($closing_tag) )
  312.                     {
  313.                         $looking_for_close_tag array(
  314.                                 'tag' => $tag,
  315.                                 'block' => $i,
  316.                                 'pos' => strlen($new_blocks$count_new_blocks ])+strlen($match[1])// position where the unclosed tag begins
  317.                             );
  318.                         $new_blocks$count_new_blocks .= $line.$text_lines[$i+1];
  319.                         continue;
  320.                     }
  321.                 }
  322.             }
  323.             $new_blocks$count_new_blocks .= $line;
  324.             $new_blocks++$count_new_blocks $text_lines[$i+1];
  325.  
  326.             $count_new_blocks++;
  327.         }
  328.         if$looking_for_close_tag )
  329.         {
  330.             #echo '<h1>looking_for_close_tag</h1>'; pre_dump( $looking_for_close_tag );
  331.             $new_blocks$count_new_blocks+''// dummy
  332.  
  333.             if$looking_for_close_tag['pos')
  334.             // move part of last block without closing tag to an own block:
  335.                 $new_blocks$count_new_blocks+substr($new_blocks$count_new_blocks ]$looking_for_close_tag['pos']);
  336.                 $new_blocks$count_new_blocks substr($new_blocks$count_new_blocks ]0$looking_for_close_tag['pos']);
  337.                 $new_blocks$count_new_blocks+''// dummy
  338.  
  339.                 $new_blocks_nowrap[$count_new_blocks+2;
  340.             }
  341.             else
  342.             // the whole block should not get wrapped!
  343.                 $new_blocks_nowrap[$count_new_blocks;
  344.             }
  345.         }
  346.  
  347.         #echo '<h1>new_blocks:</h1>'; pre_dump( $new_blocks, $new_blocks_nowrap );
  348.  
  349.         $after_block_wp '';
  350.         $before_block_wp '';
  351.         ifempty($in_tag) )
  352.         {
  353.             $wrap_in_p true;
  354.         }
  355.         elseifin_array($in_tag$this->p_allowed_in) )
  356.         {
  357.             if$this->add_p_in_block )
  358.             {
  359.                 $wrap_in_p false;
  360.             }
  361.             elseifcount($new_blocks)
  362.             {
  363.                 $wrap_in_p true;
  364.             }
  365.             else
  366.             {
  367.                 $wrap_in_p false;
  368.                 ifsubstr$new_blocks[0]0== "\n" )
  369.                 {
  370.                     $before_block_wp "\n";
  371.                     $new_blocks[0substr$new_blocks[0]);
  372.                     $wrap_in_p true;
  373.                 }
  374.                 ifsubstr$new_blocks[0]-== "\n" )
  375.                 {
  376.                     $after_block_wp "\n";
  377.                     $new_blocks[0substr$new_blocks[0]0-);
  378.                     $wrap_in_p true;
  379.                 }
  380.             }
  381.         }
  382.         else
  383.         {
  384.             $wrap_in_p false;
  385.         }
  386.  
  387.         if$new_blocks[count($new_blocks)-2== '' )
  388.         {
  389.             array_pop($new_blocks);
  390.             array_pop($new_blocks);
  391.         }
  392.  
  393.         $new_text '';
  394.  
  395.         for$i 0$n count($new_blocks)$i $n$i $i+)
  396.         {
  397.             #echo '<h2>--new_blocks['.$i.']: '; pre_dump( $new_blocks[$i] ); echo '</h2>';
  398.  
  399.             $this_wrap_in_p $wrap_in_p && in_array$i$new_blocks_nowrap )// only wrap this, if it's a valid block
  400.  
  401.             ifempty($new_blocks[$i]) )
  402.             {
  403.                 if$this_wrap_in_p )
  404.                 // not the last one
  405.                     $block '<p></p>';
  406.                 }
  407.                 else
  408.                 {
  409.                     $block '';
  410.                 }
  411.                 $new_text .= $before_block_wp.$block.$after_block_wp.$new_blocks[$i+1];
  412.                 continue;
  413.             }
  414.  
  415.             list($new_block$has_p$this->handle_pre_blocks_helper$new_blocks[$i]$in_tag$this_wrap_in_p );
  416.  
  417.  
  418.             $new_text .= $before_block_wp.$new_block.$after_block_wp.$new_blocks[$i+1];
  419.         }
  420.  
  421.         #pre_dump( 'HANDLE_PRE_BLOCKS return: ', $new_text, $in_tag );
  422.         return $new_text;
  423.     }
  424.  
  425.  
  426.     /**
  427.      * This is a helper for handling blocks from {@link handle_pre_blocks_helper()}.
  428.      *
  429.      * What comes here is supposed to have no block tags.
  430.      *
  431.      * @return array array( $text, $has_p )
  432.      */
  433.     function handle_pre_blocks_helper$block$in_tag$wrap_in_p$ignore_NL true )
  434.     {
  435.         #pre_dump( 'HANDLE_PRE_BLOCKS_HELPER begin', $block, $in_tag );
  436.         $has_p NULL;
  437.         $r '';
  438.  
  439.         if$in_tag == 'blockquote' )
  440.         // XHTML strict: blockquote content needs to be in block tag
  441.             $in_tag 'p';
  442.             $wrap_in_p true// at the end
  443.         }
  444.  
  445.         // Remove newlines at start and end (will get re-applied later):
  446.         $NL_start '';
  447.         $NL_end '';
  448.         if$ignore_NL )
  449.         {
  450.             while$block{0== "\n" )
  451.             {
  452.                 $NL_start .= $block{0};
  453.                 $block substr($block1);
  454.             }
  455.             whilesubstr($block-1== "\n" )
  456.             {
  457.                 $NL_end .= substr($block-1);
  458.                 $block substr($block0-1);
  459.             }
  460.         }
  461.  
  462.         ifpreg_match'~^(.*?)(<\s*(\w+)(\s+[^>]*)?>)~is'$block$match ) )
  463.         // a tag:
  464.             $tag $match[3];
  465.             $before_tag $match[1];
  466.  
  467.             ifempty($before_tag) )
  468.             // Delegate to handle_br:
  469.                 $r .= $this->handle_br$before_tag$in_tag );
  470.             }
  471.  
  472.             // Opening tag:
  473.             $r .= $match[2];
  474.  
  475.             $text_after_tag substr$blockstrlen($match[0]) );
  476.  
  477.             // Find closing tag:
  478.             list$text_in_tag$closing_tag$NL_before$NL_after $this->split_text_for_tag($tag$text_after_tag);
  479.  
  480.             ifempty($text_in_tag) )
  481.             // Recurse (same level) - with the optional newlines at start and end, because in an inline tag every linebreak should become a BR:
  482.                 list($text_in_tag$sub_has_p$this->handle_pre_blocks_helper$NL_before.$text_in_tag.$NL_after$tagfalsefalse );
  483.             }
  484.             $r .= $text_in_tag;
  485.  
  486.             $r .= $closing_tag;
  487.  
  488.             ifempty($text_after_tag) )
  489.             {
  490.                 #echo '<h1>RECURSE: text_after_tag (handle_pre_blocks)</h1>';
  491.                 // Recurse (same level):
  492.                 list$text_after_tag$sub_has_p $this->handle_pre_blocks_helper$text_after_tag$in_tagfalsefalse );
  493.                 $r .= $text_after_tag;
  494.             }
  495.         }
  496.         else
  497.         // No tags in this $text:
  498.             $r .= $this->handle_br$block$in_tag );
  499.         }
  500.  
  501.         ifempty($wrap_in_p) )
  502.         {
  503.             $r '<p>'.$r.'</p>';
  504.             $has_p true;
  505.         }
  506.  
  507.         // re-apply newlines from start and end:
  508.         $r $NL_start.$r.$NL_end;
  509.  
  510.         #pre_dump( 'HANDLE_PRE_BLOCKS_HELPER return: ', $r, $has_p );
  511.         return array$r$has_p );
  512.     }
  513.  
  514.  
  515.     /**
  516.      * Handles adding BR.
  517.      *
  518.      * @return string 
  519.      */
  520.     function handle_br$text$in_tag )
  521.     {
  522.         #echo '<h3>LEVEL>1 (BR)</h3>'; pre_dump( $text );
  523.  
  524.         ifempty($in_tag|| in_array($in_tag$this->br_allowed_in) )
  525.         {
  526.             $new_text $this->autobr($text);
  527.         }
  528.         else
  529.         {
  530.             $new_text $text;
  531.         }
  532.  
  533.         #pre_dump( 'HANDLE_BR return: ', $new_text, $in_tag );
  534.         return $new_text;
  535.     }
  536.  
  537.  
  538.     /**
  539.      * Split the text for a given tag, mainly to find the closing tag.
  540.      *
  541.      * @return array 
  542.      */
  543.     function split_text_for_tag($tag$text_after_tag)
  544.     {
  545.         #echo '<strong>split_text_for_tag</strong><br />'; pre_dump( $tag, $text_after_tag );
  546.         $depth 1;
  547.         $text_in_tag '';
  548.  
  549.         $loop_text $text_after_tag;
  550.         while)
  551.         {
  552.             #echo '<hr />loop_text:'; pre_dump( $loop_text );
  553.             ifpreg_match'~^(.*?)(<\s*(/)?\s*'.$tag.'\s*(/\s*)?>)~is'$loop_text$after_match ) )
  554.             {
  555.                 #pre_dump( 'after_match', $after_match );
  556.                 $text_in_tag .= $after_match[1];
  557.                 $found_tag $after_match[2];
  558.                 $is_closing empty($after_match[3]|| empty($after_match[4]/* self-closing */ );
  559.  
  560.                 if$is_closing )
  561.                 {
  562.                     $depth--;
  563.                     if$depth == )
  564.                     // found the matching closing tag:
  565.                         $closing_tag $found_tag;
  566.                         break;
  567.                     }
  568.                     else
  569.                     // this closing tag is part of the outer:
  570.                         $text_in_tag .= $found_tag;
  571.                     }
  572.                 }
  573.                 else
  574.                 // found the same, but opening tag (nested)
  575.                     $text_in_tag .= $found_tag;
  576.                     $depth++;
  577.                 }
  578.  
  579.                 // skip what we've matched:
  580.                 $loop_text substr($loop_textstrlen($after_match[0]) );
  581.             }
  582.             else
  583.             // did not find the closing tag.. :/
  584.                 $closing_tag '';
  585.                 return arrayfalsefalsefalsefalse );
  586.             }
  587.         }
  588.  
  589.         // remove newline at start and end:
  590.         ifsubstr($text_in_tag01== "\n" )
  591.         {
  592.             $NL_before "\n";
  593.             $text_in_tag substr($text_in_tag1);
  594.         }
  595.         else
  596.         {
  597.             $NL_before '';
  598.         }
  599.         ifsubstr($text_in_tag-1== "\n" )
  600.         {
  601.             $NL_after "\n";
  602.             $text_in_tag substr($text_in_tag0-1);
  603.         }
  604.         else
  605.         {
  606.             $NL_after '';
  607.         }
  608.  
  609.         $text_after_tag substr$text_after_tagstrlen($NL_before.$text_in_tag.$NL_after)+strlen($closing_tag) );
  610.         $r array$text_in_tag$closing_tag$NL_before$NL_after );
  611.  
  612.         #pre_dump( 'return: ', $r, $text_after_tag );
  613.         return $r;
  614.     }
  615.  
  616.  
  617.     /**
  618.      * Add "<br />" to the end of newlines, which do not end with "<br />" already and which aren't
  619.      * the last line, if the "Auto-BR" setting is enabled.
  620.      *
  621.      * @return string 
  622.      */
  623.     function autobr$text$replace_last true )
  624.     {
  625.         if$this->use_auto_br )
  626.         // don't make <br />'s
  627.             return $text;
  628.         }
  629.  
  630.         return preg_replace'~(?<!<br />)\n'.$replace_last '' '(?!\z)' ).'~i'"<br />\n"$text );
  631.     }
  632.  
  633. }
  634.  
  635.  
  636. /*
  637.  * $Log: _auto_p.plugin.php,v $
  638.  * Revision 1.42  2008/01/14 18:08:48  blueyed
  639.  * Add OBJECT to list of block tags (i.e. no P/BR therein)
  640.  *
  641.  * Revision 1.41  2008/01/04 23:14:20  blueyed
  642.  * Fix auto_p_plugin to not pee in the middle of some tags
  643.  *
  644.  * Revision 1.40  2007/07/04 19:59:12  blueyed
  645.  * Auto-P: Do not add BR in html comments, nor wrap it in a P
  646.  *
  647.  * Revision 1.39  2007/07/04 19:52:00  blueyed
  648.  * Auto-P: Do not add BR in SCRIPT, nor wrap it in a paragraph
  649.  *
  650.  * Revision 1.38  2007/05/21 17:44:10  blueyed
  651.  * Auto-P: Fixed adding linebreaks/BR tags directly in OL elements
  652.  *
  653.  * Revision 1.37  2007/04/20 02:53:13  fplanque
  654.  * limited number of installs
  655.  *
  656.  * Revision 1.36  2007/01/17 23:35:58  blueyed
  657.  * Removed obsolete question/todo
  658.  *
  659.  * Revision 1.35  2006/12/26 03:19:12  fplanque
  660.  * assigned a few significant plugin groups
  661.  *
  662.  * Revision 1.34  2006/12/20 13:42:54  blueyed
  663.  * Made Auto-P plugin work again and let it handle also nextpage and noteaser special tags
  664.  *
  665.  * Revision 1.33  2006/12/18 13:31:12  fplanque
  666.  * fixed broken more tag
  667.  *
  668.  * Revision 1.32  2006/12/07 23:13:13  fplanque
  669.  * @var needs to have only one argument: the variable type
  670.  * Otherwise, I can't code!
  671.  *
  672.  * Revision 1.31  2006/11/09 22:19:39  blueyed
  673.  * Fix: split blocks by "<!--more-->" before working on them
  674.  *
  675.  * Revision 1.30  2006/08/26 15:57:39  blueyed
  676.  * Fixed handling of self-closing inline tags in Auto-P
  677.  *
  678.  * Revision 1.29  2006/08/24 01:00:28  fplanque
  679.  * Versioning
  680.  *
  681.  * Revision 1.28  2006/08/21 01:34:04  blueyed
  682.  * Auto-P: BR is not allowed in UL, but LI
  683.  *
  684.  * Revision 1.27  2006/08/21 00:42:29  blueyed
  685.  * Fix for leading and trailing newline in inline tags
  686.  *
  687.  * Revision 1.26  2006/08/20 23:37:46  blueyed
  688.  * Fix: there were no <br /> after inline tags
  689.  *
  690.  * Revision 1.25  2006/08/20 22:41:36  blueyed
  691.  * Fixed Auto-P: "the web is not a type-writer". Split blocks by two or more newlines and do not pee <br/> everywhere.
  692.  *
  693.  * Revision 1.24  2006/08/16 01:13:29  blueyed
  694.  * Auto-P plugin: fix for self-closing block tags
  695.  *
  696.  * Revision 1.23  2006/07/31 22:03:01  blueyed
  697.  * More fixes to the Auto-P plugin
  698.  *
  699.  * Revision 1.22  2006/07/27 21:35:54  blueyed
  700.  * fix
  701.  *
  702.  * Revision 1.21  2006/07/27 21:17:29  blueyed
  703.  * Fixed Auto-P plugin
  704.  *
  705.  * Revision 1.20  2006/07/10 20:19:30  blueyed
  706.  * Fixed PluginInit behaviour. It now gets called on both installed and non-installed Plugins, but with the "is_installed" param appropriately set.
  707.  *
  708.  * Revision 1.19  2006/07/07 21:26:49  blueyed
  709.  * Bumped to 1.9-dev
  710.  *
  711.  * Revision 1.18  2006/07/05 21:41:17  blueyed
  712.  * fixes
  713.  *
  714.  * Revision 1.17  2006/07/05 20:10:17  blueyed
  715.  * Merge/Parse error fixed
  716.  *
  717.  * Revision 1.16  2006/07/05 19:54:02  blueyed
  718.  * Auto-P-plugin: respect newlines to create empty paragraphs
  719.  *
  720.  * Revision 1.15  2006/06/19 19:25:28  blueyed
  721.  * Fixed auto-p plugin: <code> is an inline element
  722.  *
  723.  * Revision 1.14  2006/06/16 21:30:57  fplanque
  724.  * Started clean numbering of plugin versions (feel free do add dots...)
  725.  *
  726.  * Revision 1.13  2006/05/30 19:39:55  fplanque
  727.  * plugin cleanup
  728.  *
  729.  * Revision 1.12  2006/05/22 18:14:16  blueyed
  730.  * Fixed the fixed auto-p-plugin
  731.  *
  732.  * Revision 1.11  2006/05/21 01:42:39  blueyed
  733.  * Fixed Auto-P Plugin
  734.  *
  735.  * Revision 1.10  2006/04/22 01:30:26  blueyed
  736.  * Fix for HR, CODE and FIELDSET by balupton (http://forums.b2evolution.net/viewtopic.php?p=35709#35709)
  737.  *
  738.  * Revision 1.9  2006/04/11 21:22:26  fplanque
  739.  * partial cleanup
  740.  *
  741.  */
  742. ?>

Documentation generated on Sat, 06 Mar 2010 03:27:29 +0100 by phpDocumentor 1.4.2. This site is hosted and maintained by Daniel HAHLER (Contact).