/** * Parser Function #widget */ public function pfnc_widget(&$parser, $_name = null) { if (empty($_name)) { $msg = new MessageList(); $msg->pushMessageById(self::NAME . '-missing-name'); return $this->handleError($msg); } $params = func_get_args(); array_shift($params); # $parser array_shift($params); # $name // make sure we are not tricked $name = $this->makeSecureName($_name); // get Factory istance $factory = MW_WidgetFactory::gs(); // try building a widget from the provided name $widget = $factory->newFromWidgetName($name); if (!$widget instanceof Widget) { return $this->handleError($widget); } // render the widget with the provided parameters // TODO change to 'borg' pattern $renderer = MW_WidgetRenderer::gs(); $output = $renderer->render($widget, $params); if (!is_string($output)) { return $this->handleError($output); } return array($output, 'noparse' => true, 'isHTML' => true); }