]>
Raphaƫl G. Git Repositories - airbundle/blob - Twig/Bb2htmlExtension.php
   2 // src/Rapsys/AirBundle/Twig/Bb2htmlExtension.php 
   3 namespace Rapsys\AirBundle\Twig
; 
   5 class Bb2htmlExtension 
extends \Twig_Extension 
{ 
   6         public function getFilters() { 
  13                                                         '' => array('type' => BBCODE_TYPE_ROOT
), 
  15                                                                 'type' => BBCODE_TYPE_OPTARG
, 
  16                                                                 'open_tag' => '<pre class="{PARAM}">', 
  17                                                                 'close_tag' => '</pre>', 
  18                                                                 'default_arg' => '{CONTENT}' 
  21                                                                 'type' => BBCODE_TYPE_NOARG
, 
  23                                                                 'close_tag' => '</ul>', 
  27                                                                 'type' => BBCODE_TYPE_NOARG
, 
  29                                                                 'close_tag' => '</li>', 
  34                                                                 'type' => BBCODE_TYPE_OPTARG
, 
  35                                                                 'open_tag' => '<a href="{PARAM}">', 
  36                                                                 'close_tag' => '</a>', 
  37                                                                 'default_arg' => '{CONTENT}', 
  42                                         $text = nl2br(bbcode_parse($ctx, htmlspecialchars($text))); 
  43                                         if (preg_match_all('#\<pre[^>]*\>(.*?)\</pre\>#s', $text, $matches) && !empty($matches[1])) { 
  44                                                 foreach($matches[1] as $string) { 
  45                                                         $text = str_replace($string, str_replace('<br />', '', $string), $text); 
  48                                         if (preg_match_all('#\<ul[^>]*\>(.*?)\</ul\>#s', $text, $matches) && !empty($matches[1])) { 
  49                                                 foreach($matches[1] as $string) { 
  50                                                         $text = str_replace($string, str_replace('<br />', '', $string), $text); 
  54                                                 array('#(<br />(\r?\n?))*<pre#s', '#</pre>(<br />(\r?\n?))*#', '#(<br />(\r?\n?))*<ul#s', '#</ul>(<br />(\r?\n?))*#', '#(<br />(\r?\n?)){2,}#'), 
  55                                                 array('</p>\2<pre', '</pre>\2<p>', '</p>\2<ul', '</ul>\2<p>', '</p>\2<p>'), 
  60                                 array('is_safe' => array('html'))