diff options
Diffstat (limited to 'phpBB/includes/bbcode.php')
-rw-r--r-- | phpBB/includes/bbcode.php | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 680d17dd20..96efad10f8 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -15,7 +15,7 @@ class bbcode { var $bbcode_uid = ''; - var $bbcode_bitfield = 0; + var $bbcode_bitfield = ''; var $bbcode_cache = array(); var $bbcode_template = array(); @@ -69,32 +69,31 @@ class bbcode $str = array('search' => array(), 'replace' => array()); $preg = array('search' => array(), 'replace' => array()); - $bitlen = strlen(decbin($this->bbcode_bitfield)); - for ($bbcode_id = 0; $bbcode_id < $bitlen; ++$bbcode_id) + $bitfield = new bitfield($this->bbcode_bitfield); + $bbcodes_set = $bitfield->get_all_set(); + + foreach ($bbcodes_set as $bbcode_id) { - if ($this->bbcode_bitfield & (1 << $bbcode_id)) + if (!empty($this->bbcode_cache[$bbcode_id])) { - if (!empty($this->bbcode_cache[$bbcode_id])) + foreach ($this->bbcode_cache[$bbcode_id] as $type => $array) { - foreach ($this->bbcode_cache[$bbcode_id] as $type => $array) + foreach ($array as $search => $replace) { - foreach ($array as $search => $replace) - { - ${$type}['search'][] = str_replace('$uid', $this->bbcode_uid, $search); - ${$type}['replace'][] = $replace; - } + ${$type}['search'][] = str_replace('$uid', $this->bbcode_uid, $search); + ${$type}['replace'][] = $replace; + } - if (sizeof($str['search'])) - { - $message = str_replace($str['search'], $str['replace'], $message); - $str = array('search' => array(), 'replace' => array()); - } + if (sizeof($str['search'])) + { + $message = str_replace($str['search'], $str['replace'], $message); + $str = array('search' => array(), 'replace' => array()); + } - if (sizeof($preg['search'])) - { - $message = preg_replace($preg['search'], $preg['replace'], $message); - $preg = array('search' => array(), 'replace' => array()); - } + if (sizeof($preg['search'])) + { + $message = preg_replace($preg['search'], $preg['replace'], $message); + $preg = array('search' => array(), 'replace' => array()); } } } @@ -129,9 +128,12 @@ class bbcode $bbcode_ids = $rowset = array(); $bitlen = strlen(decbin($this->bbcode_bitfield)); - for ($bbcode_id = 0; $bbcode_id < $bitlen; ++$bbcode_id) + $bitfield = new bitfield($this->bbcode_bitfield); + $bbcodes_set = $bitfield->get_all_set(); + + foreach ($bbcodes_set as $bbcode_id) { - if (isset($this->bbcode_cache[$bbcode_id]) || !($this->bbcode_bitfield & (1 << $bbcode_id))) + if (isset($this->bbcode_cache[$bbcode_id])) { // do not try to re-cache it if it's already in continue; @@ -312,9 +314,13 @@ class bbcode break; default: + if (!isset($template_bitfield)) + { + $template_bitfield = new bitfield($this->template_bitfield); + } if (isset($rowset[$bbcode_id])) { - if ($this->template_bitfield & (1 << $bbcode_id)) + if ($template_bitfield->get($bbcode_id)) { // The bbcode requires a custom template to be loaded if (!$bbcode_tpl = $this->bbcode_tpl($rowset[$bbcode_id]['bbcode_tag'], $bbcode_id)) @@ -390,9 +396,10 @@ class bbcode 'color' => '<span style="color: $1">$2</span>', 'email' => '<a href="mailto:$1">$2</a>' ); + $template_bitfield = new bitfield($this->template_bitfield); } - if ($bbcode_id != -1 && !($this->template_bitfield & (1 << $bbcode_id))) + if ($bbcode_id != -1 && !$template_bitfield->get($bbcode_id)) { return (isset($bbcode_hardtpl[$tpl_name])) ? $bbcode_hardtpl[$tpl_name] : false; } |