/** * 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); }
/** * Constructor */ public function __construct() { if (self::$instance !== null) { throw new Exception(__CLASS__ . ": there can only be one instance of this class"); } self::$instance = $this; parent::__construct(); $this->registerDefaultStorages(); }
<?php /** * @package SecureWidgets * @category Widgets * @author Jean-Lou Dupont * @version @@package-version@@ * @Id $Id$ */ MW_WidgetFactory::getInstance('MW_WidgetFactory')->setMessages(array('en' => array('securewidgets-factory' => 'SecureWidgets - Factory', 'securewidgets-factory-nocode' => 'missing code in <includeonly> tag section')));