/** * phpBB parser * * @param array $data * @return bool true or false on error * @todo Options caching + customizing option values */ public function perform($data = FALSE) { if (!isset($this->model->phpBBParser) || !is_object($this->model->phpBBParser)) { $options = HTML_BBCodeParser::parseIniFile(JAPA_MODULES_DIR . 'common/includes/PEAR/Text/BBCodeParser_V2.ini'); // set system charset $options['format']['Xhtml']['charset'] = $this->config->getModuleVar('common', 'charset'); $this->model->phpBBParser = new HTML_BBCodeParser($options); } $this->model->phpBBParser->setText($data['content']); $this->model->phpBBParser->parse(); $data['content'] = $this->model->phpBBParser->getParsed(); }
/** * Constructor, initialises the options and filters * * Sets the private variable _options with base options defined with * &PEAR::getStaticProperty(), overwriting them with (if present) * the argument to this method. * Then it sets the extra options to properly escape the tag * characters in preg_replace() etc. The set options are * then stored back with &PEAR::getStaticProperty(), so that the filter * classes can use them. * All the filters in the options are initialised and their defined tags * are copied into the private variable _definedTags. * * @param mixed array or string options or ini file to use, can be left out * @return none * @access public * @author Stijn de Reede <*****@*****.**> */ function HTML_BBCodeParser($options = array()) { // instantiate the Text_Wiki transformer parent::Text_Wiki_BBCode(); // config file (.ini) ? if (is_string($options)) { $options = HTML_BBCodeParser::parseIniFile($options); } // set the already set options if (!defined('HTML_BBCODEPARSER_V2')) { $baseoptions = PEAR::getStaticProperty('HTML_BBCodeParser', '_options'); if (is_array($baseoptions)) { foreach ($baseoptions as $k => $v) { $this->_options[$k] = $v; } } } // set the options passed as an argument foreach ($options as $k => $v) { $this->_options[$k] = $v; } // open and close tags are fixed by Text_Wiki_BBCode if (isset($this->_options['open']) && $this->_options['open'] != '[' || isset($this->_options['close']) && $this->_options['close'] != ']') { return "<p>Sorry, open/close tags are fixed to '[' and ']', put a RFE if neede</p>\n"; } // set the rules $rules = array_merge(array('Prefilter', 'Delimiter'), isset($this->_options['filters']) ? HTML_BBCodeParser::filtersToRules($this->_options['filters']) : array(), isset($this->_options['rules']) ? is_array($this->_options['rules']) ? $this->_options['rules'] : explode(',', $this->_options['rules']) : array()); // filter rules so their order is kept foreach ($this->rules as $rule) { if (!in_array($rule, $rules)) { $this->deleteRule($rule); } } if (isset($options['parse'][$options['set_parse']])) { $this->parseConf = $options['parse'][$options['set_parse']]; } if (isset($options['format'])) { foreach (array_keys($options['format']) as $render) { if (!isset($options['set_render']) || in_array($render, $options['set_render'])) { $this->setFormatConf($render, $options['format'][$render]); } } } if (isset($options['render'])) { foreach (array_keys($options['render']) as $render) { if (in_array($render, $options['set_render'])) { $this->renderConf[$render] = $options['render'][$render]; } } } // var_dump( $options);var_dump($this->parseConf);var_dump($this->formatConf);var_dump($this->renderConf); die(); }