You are here

function XBBCodeFilter::pair_tags in Extensible BBCode 6

Same name and namespace in other branches
  1. 5 xbbcode-filter.php \XBBCodeFilter::pair_tags()
1 call to XBBCodeFilter::pair_tags()
XBBCodeFilter::process in ./xbbcode.filter.inc

File

./xbbcode.filter.inc, line 51

Class

XBBCodeFilter

Code

function pair_tags($text) {
  $this->pair_id = 0;
  $this->tagpairs['#complete'] = array();
  $pattern = '/\\[(\\/)?([a-z0-9]+)([= ][^\\[\\]]*[^\\-])?\\]/ie';
  $replace = '$this->pair_tag(\'$2\',\'$1\',\'$3\');';
  foreach (array_keys($this->weighted_tags) as $weight) {
    $this->current_weight = $weight;

    // tell the pairing function which tags to pair up in this round.
    $text = preg_replace($pattern, $replace, $text);

    // invoke the pairing function
  }
  if (variable_get('xbbcode_filter_' . $this->format . '_autoclose', false)) {
    $text .= $this
      ->closure(element_children($this->tagpairs));
  }
  $pairs = $this->tagpairs['#complete'];

  // get the completed pairs
  return array(
    $text,
    $pairs,
  );

  // return the text and the pairs.
}