b2evolution

Multilingual multiuser multiblog engine

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

Documentation generated on Tue, 18 Dec 2007 19:10:39 +0100 by phpDocumentor 1.4.0