config['loadBootstrap'] = false; $this->config['blurbTitle'] = ''; $this->config['blurbText'] = ''; $this->config['blurbMoreLink'] = ''; // load custom config if needed if (isset($config['PicoUIBlurb.loadBootstrap'])) { $this->config['loadBootstrap'] = $config['PicoUIBlurb.loadBootstrap']; } if (isset($config['PicoUIBlurb.cssClass.blurbTitle'])) { $this->config['blurbTitle'] = $config['PicoUIBlurb.cssClass.blurbTitle']; } if (isset($config['PicoUIBlurb.cssClass.blurbText'])) { $this->config['blurbText'] = $config['PicoUIBlurb.cssClass.blurbText']; } if (isset($config['PicoUIBlurb.cssClass.blurbMoreLink'])) { $this->config['blurbMoreLink'] = $config['PicoUIBlurb.cssClass.blurbMoreLink']; } } /** * Triggered after Pico has prepared the raw file contents for parsing * * @see Pico::parseFileContent() * @see DummyPlugin::onContentParsed() * @param string &$content prepared file contents for parsing * @return void */ public function onContentPrepared(&$content) { // we only do any processing at all if the page contains our tag, so we save time if (strpos($content, '[ui.blurb') !== false) { // below is our comprehensive regex to detect for the full [ui.blurb] tag, // which includes the tag and its attributes, and the [title] and [text] subtags. $config = $this->config; $content = preg_replace_callback( '/\[ui\.blurb((\s+[a-z]+\=[\'\"][^\'\"]*[\'\"])*)\s*\]\s*((\[[a-z]+\][^\[]*\[\/[a-z]+\]\s*)*)\[\/ui\.blurb\s*\]/', function ($matches) use ($config) { // $matches[1] contain the list of attributes // $matches[3] contain the list of subtags preg_match_all('/\s*([a-z]+)\=[\'\"]([^\'\"]*)[\'\"]/', $matches[1], $attributes); preg_match_all('/\[([a-z]+)\]([^\[]*)\[\/([a-z]+)\]\s*/', $matches[3], $subtags); // look for what we want from attributes and subtags $uiblurb = array('href' => '', 'img' => '', 'imgpos' => '', 'title' => '', 'text' => '', 'more' => ''); for ($i = 0; $i < count($attributes[0]); $i++) { $uiblurb[ $attributes[1][$i] ] = $attributes[2][$i]; } for ($i = 0; $i < count($subtags[0]); $i++) { if ($subtags[1][$i] != $subtags[3][$i]) { continue; // closing subtag must match in order to be valid } $uiblurb[ $subtags[1][$i] ] = $subtags[2][$i]; } $result = '