Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Sedo_Demo_BbCode_Formatter_BaseFilter extends XenForo_BbCode_Formatter_Base
- {
- protected $baseFilterAllowedTags = array();
- protected $baseFilterOriginalParentTags;
- protected $baseFilterInvisibleTags = false;
- public function setBaseFilterAllowedTags(array $tags)
- {
- $this->baseFilterAllowedTags = $tags;
- $this->_tags = $this->getTags();
- }
- public function setBaseFilterInvisible($value = false)
- {
- $this->baseFilterInvisibleTags = $value;
- }
- public function getTags()
- {
- $tags = parent::getTags();
- if($this->baseFilterOriginalParentTags !== null)
- {
- return $this->_baseFilterTags($this->baseFilterOriginalParentTags);
- }
- $this->baseFilterOriginalParentTags = $tags;
- return $this->_baseFilterTags($tags);
- }
- public function addCustomTags(array $tags)
- {
- $tags = $this->_baseFilterTags($tags);
- return parent::addCustomTags($tags);
- }
- protected function _baseFilterTags($tags)
- {
- //Raw Bb Code return
- if(!$this->baseFilterInvisibleTags)
- {
- return array_intersect_key($tags, array_flip($this->baseFilterAllowedTags));
- }
- //Customized Bb Code return
- foreach($tags as $bbCode => $data)
- {
- if(!in_array($bbCode, $this->baseFilterAllowedTags))
- {
- if(!isset($tags[$bbCode]['bb_code_mode']))
- {
- //Normal Bb Code
- if(isset($tags[$bbCode]['callback']))
- {
- unset($tags[$bbCode]['callback']);
- }
- $tags[$bbCode]['replace'] = array('', '');
- }
- else
- {
- //Custom Bb Code
- $tags[$bbCode]['bb_code_mode'] = 'replace';
- $tags[$bbCode]['replace_html'] = '{text}';
- }
- }
- }
- return $tags;
- }
- }
- //Zend_Debug::dump($bbCodeFormatter);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement