/** * 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); }
public function __construct() { if (self::$instance !== null) { throw new Exception(__CLASS__ . ": singleton pattern"); } self::$instance = $this; parent::__construct(); }
<?php /** * @package SecureWidgets * @category Widgets * @author Jean-Lou Dupont * @version @@package-version@@ * @Id $Id$ */ MW_WidgetRenderer::getInstance('MW_WidgetRenderer')->setMessages(array('en' => array('securewidgets-renderer' => 'SecureWidgets - renderer', 'securewidgets-renderer-missing-inputs' => 'missing input variables for widget <i>$1</i>.', 'securewidgets-renderer-missing-input' => 'missing input parameter <i>$1</i> of type <i>$2</i>', 'securewidgets-renderer-unsupported-type' => 'unsupported parameter type <i>$2</i> for parameter <i>$1</i>', 'securewidgets-renderer-type-mismatch' => 'parameter type mismatch: expecting type <i>$2</i> for parameter <i>$1</i>')));