[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/includes/ -> bbcode.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  /**
  15  * @ignore
  16  */
  17  if (!defined('IN_PHPBB'))
  18  {
  19      exit;
  20  }
  21  
  22  /**
  23  * BBCode class
  24  */
  25  class bbcode
  26  {
  27      var $bbcode_uid = '';
  28      var $bbcode_bitfield = '';
  29      var $bbcode_cache = array();
  30      var $bbcode_template = array();
  31  
  32      var $bbcodes = array();
  33  
  34      var $template_bitfield;
  35  
  36      /**
  37      * Constructor
  38      * Init bbcode cache entries if bitfield is specified
  39      */
  40  	function bbcode($bitfield = '')
  41      {
  42          if ($bitfield)
  43          {
  44              $this->bbcode_bitfield = $bitfield;
  45              $this->bbcode_cache_init();
  46          }
  47      }
  48  
  49      /**
  50      * Second pass bbcodes
  51      */
  52  	function bbcode_second_pass(&$message, $bbcode_uid = '', $bbcode_bitfield = false)
  53      {
  54          if ($bbcode_uid)
  55          {
  56              $this->bbcode_uid = $bbcode_uid;
  57          }
  58  
  59          if ($bbcode_bitfield !== false)
  60          {
  61              $this->bbcode_bitfield = $bbcode_bitfield;
  62  
  63              // Init those added with a new bbcode_bitfield (already stored codes will not get parsed again)
  64              $this->bbcode_cache_init();
  65          }
  66  
  67          if (!$this->bbcode_bitfield)
  68          {
  69              // Remove the uid from tags that have not been transformed into HTML
  70              if ($this->bbcode_uid)
  71              {
  72                  $message = str_replace(':' . $this->bbcode_uid, '', $message);
  73              }
  74  
  75              return;
  76          }
  77  
  78          $str = array('search' => array(), 'replace' => array());
  79          $preg = array('search' => array(), 'replace' => array());
  80  
  81          $bitfield = new bitfield($this->bbcode_bitfield);
  82          $bbcodes_set = $bitfield->get_all_set();
  83  
  84          $undid_bbcode_specialchars = false;
  85          foreach ($bbcodes_set as $bbcode_id)
  86          {
  87              if (!empty($this->bbcode_cache[$bbcode_id]))
  88              {
  89                  foreach ($this->bbcode_cache[$bbcode_id] as $type => $array)
  90                  {
  91                      foreach ($array as $search => $replace)
  92                      {
  93                          ${$type}['search'][] = str_replace('$uid', $this->bbcode_uid, $search);
  94                          ${$type}['replace'][] = $replace;
  95                      }
  96  
  97                      if (sizeof($str['search']))
  98                      {
  99                          $message = str_replace($str['search'], $str['replace'], $message);
 100                          $str = array('search' => array(), 'replace' => array());
 101                      }
 102  
 103                      if (sizeof($preg['search']))
 104                      {
 105                          // we need to turn the entities back into their original form to allow the
 106                          // search patterns to work properly
 107                          if (!$undid_bbcode_specialchars)
 108                          {
 109                              $message = str_replace(array('&#58;', '&#46;'), array(':', '.'), $message);
 110                              $undid_bbcode_specialchars = true;
 111                          }
 112  
 113                          $message = preg_replace($preg['search'], $preg['replace'], $message);
 114                          $preg = array('search' => array(), 'replace' => array());
 115                      }
 116                  }
 117              }
 118          }
 119  
 120          // Remove the uid from tags that have not been transformed into HTML
 121          $message = str_replace(':' . $this->bbcode_uid, '', $message);
 122      }
 123  
 124      /**
 125      * Init bbcode cache
 126      *
 127      * requires: $this->bbcode_bitfield
 128      * sets: $this->bbcode_cache with bbcode templates needed for bbcode_bitfield
 129      */
 130  	function bbcode_cache_init()
 131      {
 132          global $phpbb_root_path, $phpEx, $config, $user, $phpbb_dispatcher, $phpbb_extension_manager, $phpbb_path_helper;
 133  
 134          if (empty($this->template_filename))
 135          {
 136              $this->template_bitfield = new bitfield($user->style['bbcode_bitfield']);
 137  
 138              $template = new phpbb\template\twig\twig($phpbb_path_helper, $config, $user, new phpbb\template\context(), $phpbb_extension_manager);
 139              $template->set_style();
 140              $template->set_filenames(array('bbcode.html' => 'bbcode.html'));
 141              $this->template_filename = $template->get_source_file_for_handle('bbcode.html');
 142          }
 143  
 144          $bbcode_ids = $rowset = $sql = array();
 145  
 146          $bitfield = new bitfield($this->bbcode_bitfield);
 147          $bbcodes_set = $bitfield->get_all_set();
 148  
 149          foreach ($bbcodes_set as $bbcode_id)
 150          {
 151              if (isset($this->bbcode_cache[$bbcode_id]))
 152              {
 153                  // do not try to re-cache it if it's already in
 154                  continue;
 155              }
 156              $bbcode_ids[] = $bbcode_id;
 157  
 158              if ($bbcode_id > NUM_CORE_BBCODES)
 159              {
 160                  $sql[] = $bbcode_id;
 161              }
 162          }
 163  
 164          if (sizeof($sql))
 165          {
 166              global $db;
 167  
 168              $sql = 'SELECT *
 169                  FROM ' . BBCODES_TABLE . '
 170                  WHERE ' . $db->sql_in_set('bbcode_id', $sql);
 171              $result = $db->sql_query($sql, 3600);
 172  
 173              while ($row = $db->sql_fetchrow($result))
 174              {
 175                  // To circumvent replacing newlines with <br /> for the generated html,
 176                  // we use carriage returns here. They are later changed back to newlines
 177                  $row['bbcode_tpl'] = str_replace("\n", "\r", $row['bbcode_tpl']);
 178                  $row['second_pass_replace'] = str_replace("\n", "\r", $row['second_pass_replace']);
 179  
 180                  $rowset[$row['bbcode_id']] = $row;
 181              }
 182              $db->sql_freeresult($result);
 183          }
 184  
 185          // To perform custom second pass in extension, use $this->bbcode_second_pass_by_extension()
 186          // method which accepts variable number of parameters
 187          foreach ($bbcode_ids as $bbcode_id)
 188          {
 189              switch ($bbcode_id)
 190              {
 191                  case 0:
 192                      $this->bbcode_cache[$bbcode_id] = array(
 193                          'str' => array(
 194                              '[/quote:$uid]'    => $this->bbcode_tpl('quote_close', $bbcode_id)
 195                          ),
 196                          'preg' => array(
 197                              '#\[quote(?:=&quot;(.*?)&quot;)?:$uid\]((?!\[quote(?:=&quot;.*?&quot;)?:$uid\]).)?#ise'    => "\$this->bbcode_second_pass_quote('\$1', '\$2')"
 198                          )
 199                      );
 200                  break;
 201  
 202                  case 1:
 203                      $this->bbcode_cache[$bbcode_id] = array(
 204                          'str' => array(
 205                              '[b:$uid]'    => $this->bbcode_tpl('b_open', $bbcode_id),
 206                              '[/b:$uid]'    => $this->bbcode_tpl('b_close', $bbcode_id),
 207                          )
 208                      );
 209                  break;
 210  
 211                  case 2:
 212                      $this->bbcode_cache[$bbcode_id] = array(
 213                          'str' => array(
 214                              '[i:$uid]'    => $this->bbcode_tpl('i_open', $bbcode_id),
 215                              '[/i:$uid]'    => $this->bbcode_tpl('i_close', $bbcode_id),
 216                          )
 217                      );
 218                  break;
 219  
 220                  case 3:
 221                      $this->bbcode_cache[$bbcode_id] = array(
 222                          'preg' => array(
 223                              '#\[url:$uid\]((.*?))\[/url:$uid\]#s'            => $this->bbcode_tpl('url', $bbcode_id),
 224                              '#\[url=([^\[]+?):$uid\](.*?)\[/url:$uid\]#s'    => $this->bbcode_tpl('url', $bbcode_id),
 225                          )
 226                      );
 227                  break;
 228  
 229                  case 4:
 230                      if ($user->optionget('viewimg'))
 231                      {
 232                          $this->bbcode_cache[$bbcode_id] = array(
 233                              'preg' => array(
 234                                  '#\[img:$uid\](.*?)\[/img:$uid\]#s'        => $this->bbcode_tpl('img', $bbcode_id),
 235                              )
 236                          );
 237                      }
 238                      else
 239                      {
 240                          $this->bbcode_cache[$bbcode_id] = array(
 241                              'preg' => array(
 242                                  '#\[img:$uid\](.*?)\[/img:$uid\]#s'        => str_replace('$2', '[ img ]', $this->bbcode_tpl('url', $bbcode_id, true)),
 243                              )
 244                          );
 245                      }
 246                  break;
 247  
 248                  case 5:
 249                      $this->bbcode_cache[$bbcode_id] = array(
 250                          'preg' => array(
 251                              '#\[size=([\-\+]?\d+):$uid\](.*?)\[/size:$uid\]#s'    => $this->bbcode_tpl('size', $bbcode_id),
 252                          )
 253                      );
 254                  break;
 255  
 256                  case 6:
 257                      $this->bbcode_cache[$bbcode_id] = array(
 258                          'preg' => array(
 259                              '!\[color=(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z\-]+):$uid\](.*?)\[/color:$uid\]!is'    => $this->bbcode_tpl('color', $bbcode_id),
 260                          )
 261                      );
 262                  break;
 263  
 264                  case 7:
 265                      $this->bbcode_cache[$bbcode_id] = array(
 266                          'str' => array(
 267                              '[u:$uid]'    => $this->bbcode_tpl('u_open', $bbcode_id),
 268                              '[/u:$uid]'    => $this->bbcode_tpl('u_close', $bbcode_id),
 269                          )
 270                      );
 271                  break;
 272  
 273                  case 8:
 274                      $this->bbcode_cache[$bbcode_id] = array(
 275                          'preg' => array(
 276                              '#\[code(?:=([a-z]+))?:$uid\](.*?)\[/code:$uid\]#ise'    => "\$this->bbcode_second_pass_code('\$1', '\$2')",
 277                          )
 278                      );
 279                  break;
 280  
 281                  case 9:
 282                      $this->bbcode_cache[$bbcode_id] = array(
 283                          'preg' => array(
 284                              '#(\[\/?(list|\*):[mou]?:?$uid\])[\n]{1}#'    => "\$1",
 285                              '#(\[list=([^\[]+):$uid\])[\n]{1}#'            => "\$1",
 286                              '#\[list=([^\[]+):$uid\]#e'                    => "\$this->bbcode_list('\$1')",
 287                          ),
 288                          'str' => array(
 289                              '[list:$uid]'        => $this->bbcode_tpl('ulist_open_default', $bbcode_id),
 290                              '[/list:u:$uid]'    => $this->bbcode_tpl('ulist_close', $bbcode_id),
 291                              '[/list:o:$uid]'    => $this->bbcode_tpl('olist_close', $bbcode_id),
 292                              '[*:$uid]'            => $this->bbcode_tpl('listitem', $bbcode_id),
 293                              '[/*:$uid]'            => $this->bbcode_tpl('listitem_close', $bbcode_id),
 294                              '[/*:m:$uid]'        => $this->bbcode_tpl('listitem_close', $bbcode_id)
 295                          ),
 296                      );
 297                  break;
 298  
 299                  case 10:
 300                      $this->bbcode_cache[$bbcode_id] = array(
 301                          'preg' => array(
 302                              '#\[email:$uid\]((.*?))\[/email:$uid\]#is'            => $this->bbcode_tpl('email', $bbcode_id),
 303                              '#\[email=([^\[]+):$uid\](.*?)\[/email:$uid\]#is'    => $this->bbcode_tpl('email', $bbcode_id)
 304                          )
 305                      );
 306                  break;
 307  
 308                  case 11:
 309                      if ($user->optionget('viewflash'))
 310                      {
 311                          $this->bbcode_cache[$bbcode_id] = array(
 312                              'preg' => array(
 313                                  '#\[flash=([0-9]+),([0-9]+):$uid\](.*?)\[/flash:$uid\]#'    => $this->bbcode_tpl('flash', $bbcode_id),
 314                              )
 315                          );
 316                      }
 317                      else
 318                      {
 319                          $this->bbcode_cache[$bbcode_id] = array(
 320                              'preg' => array(
 321                                  '#\[flash=([0-9]+),([0-9]+):$uid\](.*?)\[/flash:$uid\]#'    => str_replace('$1', '$3', str_replace('$2', '[ flash ]', $this->bbcode_tpl('url', $bbcode_id, true)))
 322                              )
 323                          );
 324                      }
 325                  break;
 326  
 327                  case 12:
 328                      $this->bbcode_cache[$bbcode_id] = array(
 329                          'str'    => array(
 330                              '[/attachment:$uid]'    => $this->bbcode_tpl('inline_attachment_close', $bbcode_id)
 331                          ),
 332                          'preg'    => array(
 333                              '#\[attachment=([0-9]+):$uid\]#'    => $this->bbcode_tpl('inline_attachment_open', $bbcode_id)
 334                          )
 335                      );
 336                  break;
 337  
 338                  default:
 339                      if (isset($rowset[$bbcode_id]))
 340                      {
 341                          if ($this->template_bitfield->get($bbcode_id))
 342                          {
 343                              // The bbcode requires a custom template to be loaded
 344                              if (!$bbcode_tpl = $this->bbcode_tpl($rowset[$bbcode_id]['bbcode_tag'], $bbcode_id))
 345                              {
 346                                  // For some reason, the required template seems not to be available, use the default template
 347                                  $bbcode_tpl = (!empty($rowset[$bbcode_id]['second_pass_replace'])) ? $rowset[$bbcode_id]['second_pass_replace'] : $rowset[$bbcode_id]['bbcode_tpl'];
 348                              }
 349                              else
 350                              {
 351                                  // In order to use templates with custom bbcodes we need
 352                                  // to replace all {VARS} to corresponding backreferences
 353                                  // Note that backreferences are numbered from bbcode_match
 354                                  if (preg_match_all('/\{(URL|LOCAL_URL|EMAIL|TEXT|SIMPLETEXT|INTTEXT|IDENTIFIER|COLOR|NUMBER)[0-9]*\}/', $rowset[$bbcode_id]['bbcode_match'], $m))
 355                                  {
 356                                      foreach ($m[0] as $i => $tok)
 357                                      {
 358                                          $bbcode_tpl = str_replace($tok, '$' . ($i + 1), $bbcode_tpl);
 359                                      }
 360                                  }
 361                              }
 362                          }
 363                          else
 364                          {
 365                              // Default template
 366                              $bbcode_tpl = (!empty($rowset[$bbcode_id]['second_pass_replace'])) ? $rowset[$bbcode_id]['second_pass_replace'] : $rowset[$bbcode_id]['bbcode_tpl'];
 367                          }
 368  
 369                          // Replace {L_*} lang strings
 370                          $bbcode_tpl = preg_replace('/{L_([A-Z0-9_]+)}/e', "(!empty(\$user->lang['\$1'])) ? \$user->lang['\$1'] : ucwords(strtolower(str_replace('_', ' ', '\$1')))", $bbcode_tpl);
 371  
 372                          if (!empty($rowset[$bbcode_id]['second_pass_replace']))
 373                          {
 374                              // The custom BBCode requires second-pass pattern replacements
 375                              $this->bbcode_cache[$bbcode_id] = array(
 376                                  'preg' => array($rowset[$bbcode_id]['second_pass_match'] => $bbcode_tpl)
 377                              );
 378                          }
 379                          else
 380                          {
 381                              $this->bbcode_cache[$bbcode_id] = array(
 382                                  'str' => array($rowset[$bbcode_id]['second_pass_match'] => $bbcode_tpl)
 383                              );
 384                          }
 385                      }
 386                      else
 387                      {
 388                          $this->bbcode_cache[$bbcode_id] = false;
 389                      }
 390                  break;
 391              }
 392          }
 393  
 394          $bbcode_cache = $this->bbcode_cache;
 395          $bbcode_bitfield = $this->bbcode_bitfield;
 396          $bbcode_uid = $this->bbcode_uid;
 397  
 398          /**
 399          * Use this event to modify the bbcode_cache
 400          *
 401          * @event core.bbcode_cache_init_end
 402          * @var    array    bbcode_cache        The array of cached search and replace patterns of bbcodes
 403          * @var    string    bbcode_bitfield        The bbcode bitfield
 404          * @var    string    bbcode_uid            The bbcode uid
 405          * @since 3.1.3-RC1
 406          */
 407          $vars = array('bbcode_cache', 'bbcode_bitfield', 'bbcode_uid');
 408          extract($phpbb_dispatcher->trigger_event('core.bbcode_cache_init_end', compact($vars)));
 409  
 410          $this->bbcode_cache = $bbcode_cache;
 411          $this->bbcode_bitfield = $bbcode_bitfield;
 412          $this->bbcode_uid = $bbcode_uid;
 413      }
 414  
 415      /**
 416      * Return bbcode template
 417      */
 418  	function bbcode_tpl($tpl_name, $bbcode_id = -1, $skip_bitfield_check = false)
 419      {
 420          static $bbcode_hardtpl = array();
 421          if (empty($bbcode_hardtpl))
 422          {
 423              global $user;
 424  
 425              $bbcode_hardtpl = array(
 426                  'b_open'    => '<span style="font-weight: bold">',
 427                  'b_close'    => '</span>',
 428                  'i_open'    => '<span style="font-style: italic">',
 429                  'i_close'    => '</span>',
 430                  'u_open'    => '<span style="text-decoration: underline">',
 431                  'u_close'    => '</span>',
 432                  'img'        => '<img src="$1" class="postimage" alt="' . $user->lang['IMAGE'] . '" />',
 433                  'size'        => '<span style="font-size: $1%; line-height: normal">$2</span>',
 434                  'color'        => '<span style="color: $1">$2</span>',
 435                  'email'        => '<a href="mailto:$1">$2</a>'
 436              );
 437          }
 438  
 439          if ($bbcode_id != -1 && !$skip_bitfield_check && !$this->template_bitfield->get($bbcode_id))
 440          {
 441              return (isset($bbcode_hardtpl[$tpl_name])) ? $bbcode_hardtpl[$tpl_name] : false;
 442          }
 443  
 444          if (empty($this->bbcode_template))
 445          {
 446              if (($tpl = file_get_contents($this->template_filename)) === false)
 447              {
 448                  trigger_error('Could not load bbcode template', E_USER_ERROR);
 449              }
 450  
 451              // replace \ with \\ and then ' with \'.
 452              $tpl = str_replace('\\', '\\\\', $tpl);
 453              $tpl = str_replace("'", "\'", $tpl);
 454  
 455              // strip newlines and indent
 456              $tpl = preg_replace("/\n[\n\r\s\t]*/", '', $tpl);
 457  
 458              // Turn template blocks into PHP assignment statements for the values of $bbcode_tpl..
 459              $this->bbcode_template = array();
 460  
 461              $matches = preg_match_all('#<!-- BEGIN (.*?) -->(.*?)<!-- END (?:.*?) -->#', $tpl, $match);
 462  
 463              for ($i = 0; $i < $matches; $i++)
 464              {
 465                  if (empty($match[1][$i]))
 466                  {
 467                      continue;
 468                  }
 469  
 470                  $this->bbcode_template[$match[1][$i]] = $this->bbcode_tpl_replace($match[1][$i], $match[2][$i]);
 471              }
 472          }
 473  
 474          return (isset($this->bbcode_template[$tpl_name])) ? $this->bbcode_template[$tpl_name] : ((isset($bbcode_hardtpl[$tpl_name])) ? $bbcode_hardtpl[$tpl_name] : false);
 475      }
 476  
 477      /**
 478      * Return bbcode template replacement
 479      */
 480  	function bbcode_tpl_replace($tpl_name, $tpl)
 481      {
 482          global $user;
 483  
 484          static $replacements = array(
 485              'quote_username_open'    => array('{USERNAME}'    => '$1'),
 486              'color'                    => array('{COLOR}'        => '$1', '{TEXT}'            => '$2'),
 487              'size'                    => array('{SIZE}'        => '$1', '{TEXT}'            => '$2'),
 488              'img'                    => array('{URL}'        => '$1'),
 489              'flash'                    => array('{WIDTH}'        => '$1', '{HEIGHT}'            => '$2', '{URL}'    => '$3'),
 490              'url'                    => array('{URL}'        => '$1', '{DESCRIPTION}'    => '$2'),
 491              'email'                    => array('{EMAIL}'        => '$1', '{DESCRIPTION}'    => '$2')
 492          );
 493  
 494          $tpl = preg_replace('/{L_([A-Z0-9_]+)}/e', "(!empty(\$user->lang['\$1'])) ? \$user->lang['\$1'] : ucwords(strtolower(str_replace('_', ' ', '\$1')))", $tpl);
 495  
 496          if (!empty($replacements[$tpl_name]))
 497          {
 498              $tpl = strtr($tpl, $replacements[$tpl_name]);
 499          }
 500  
 501          return trim($tpl);
 502      }
 503  
 504      /**
 505      * Second parse list bbcode
 506      */
 507  	function bbcode_list($type)
 508      {
 509          if ($type == '')
 510          {
 511              $tpl = 'ulist_open_default';
 512              $type = 'default';
 513          }
 514          else if ($type == 'i')
 515          {
 516              $tpl = 'olist_open';
 517              $type = 'lower-roman';
 518          }
 519          else if ($type == 'I')
 520          {
 521              $tpl = 'olist_open';
 522              $type = 'upper-roman';
 523          }
 524          else if (preg_match('#^(disc|circle|square)$#i', $type))
 525          {
 526              $tpl = 'ulist_open';
 527              $type = strtolower($type);
 528          }
 529          else if (preg_match('#^[a-z]$#', $type))
 530          {
 531              $tpl = 'olist_open';
 532              $type = 'lower-alpha';
 533          }
 534          else if (preg_match('#[A-Z]#', $type))
 535          {
 536              $tpl = 'olist_open';
 537              $type = 'upper-alpha';
 538          }
 539          else if (is_numeric($type))
 540          {
 541              $tpl = 'olist_open';
 542              $type = 'decimal';
 543          }
 544          else
 545          {
 546              $tpl = 'olist_open';
 547              $type = 'decimal';
 548          }
 549  
 550          return str_replace('{LIST_TYPE}', $type, $this->bbcode_tpl($tpl));
 551      }
 552  
 553      /**
 554      * Second parse quote tag
 555      */
 556  	function bbcode_second_pass_quote($username, $quote)
 557      {
 558          // when using the /e modifier, preg_replace slashes double-quotes but does not
 559          // seem to slash anything else
 560          $quote = str_replace('\"', '"', $quote);
 561          $username = str_replace('\"', '"', $username);
 562  
 563          // remove newline at the beginning
 564          if ($quote == "\n")
 565          {
 566              $quote = '';
 567          }
 568  
 569          $quote = (($username) ? str_replace('$1', $username, $this->bbcode_tpl('quote_username_open')) : $this->bbcode_tpl('quote_open')) . $quote;
 570  
 571          return $quote;
 572      }
 573  
 574      /**
 575      * Second parse code tag
 576      */
 577  	function bbcode_second_pass_code($type, $code)
 578      {
 579          // when using the /e modifier, preg_replace slashes double-quotes but does not
 580          // seem to slash anything else
 581          $code = str_replace('\"', '"', $code);
 582  
 583          switch ($type)
 584          {
 585              case 'php':
 586                  // Not the english way, but valid because of hardcoded syntax highlighting
 587                  if (strpos($code, '<span class="syntaxdefault"><br /></span>') === 0)
 588                  {
 589                      $code = substr($code, 41);
 590                  }
 591  
 592              // no break;
 593  
 594              default:
 595                  $code = str_replace("\t", '&nbsp; &nbsp;', $code);
 596                  $code = str_replace('  ', '&nbsp; ', $code);
 597                  $code = str_replace('  ', ' &nbsp;', $code);
 598                  $code = str_replace("\n ", "\n&nbsp;", $code);
 599  
 600                  // keep space at the beginning
 601                  if (!empty($code) && $code[0] == ' ')
 602                  {
 603                      $code = '&nbsp;' . substr($code, 1);
 604                  }
 605  
 606                  // remove newline at the beginning
 607                  if (!empty($code) && $code[0] == "\n")
 608                  {
 609                      $code = substr($code, 1);
 610                  }
 611              break;
 612          }
 613  
 614          $code = $this->bbcode_tpl('code_open') . $code . $this->bbcode_tpl('code_close');
 615  
 616          return $code;
 617      }
 618  
 619      /**
 620      * Function to perform custom bbcode second pass by extensions
 621      * can be used to assign bbcode pattern replacement
 622      * Example: '#\[list=([^\[]+):$uid\]#e'    => "\$this->bbcode_second_pass_by_extension('\$1')"
 623      *
 624      * Accepts variable number of parameters
 625      *
 626      * @return mixed Second pass result
 627      */
 628  	function bbcode_second_pass_by_extension()
 629      {
 630          global $phpbb_dispatcher;
 631  
 632          $return = false;
 633          $params_array = func_get_args();
 634  
 635          /**
 636          * Event to perform bbcode second pass with
 637          * the custom validating methods provided by extensions
 638          *
 639          * @event core.bbcode_second_pass_by_extension
 640          * @var array    params_array    Array with the function parameters
 641          * @var mixed    return            Second pass result to return
 642          *
 643          * @since 3.1.5-RC1
 644          */
 645          $vars = array('params_array', 'return');
 646          extract($phpbb_dispatcher->trigger_event('core.bbcode_second_pass_by_extension', compact($vars)));
 647  
 648          return $return;
 649      }
 650  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1