/** * Get instance for extension * @param Extension_Extension $extension * @return IWidget */ public static function GetByExtension(Extension_Extension $extension) { global $g_user; // be able to render $widget = new WidgetRendererDecorator(array('fk_user_id' => $g_user->getId(), 'fk_widget_id' => $extension->getId())); // set extension, widget $widget->extension = $extension; $widget->setWidget($extension->getInstance()); return $widget; }
/** * Get widgets by context. * @param IWidgetContext $context * @return array of IWidget */ public static function GetWidgetsByContext(IWidgetContext $context) { global $g_user, $g_ado_db; $queryStr = 'SELECT w.path, w.class, wcw.* FROM ' . Extension_Extension::TABLE . ' w INNER JOIN ' . WidgetManagerDecorator::TABLE . ' wcw ON w.id = wcw.fk_widget_id WHERE wcw.fk_user_id = ' . $g_user->getId() . ' AND wcw.fk_widgetcontext_id = ' . $context->getId() . ' ORDER BY `order`'; $rows = $g_ado_db->GetAll($queryStr); $widgets = array(); if (is_array($rows)) { foreach ($rows as $row) { $widget = new WidgetRendererDecorator((array) $row); if ($widget->getWidget() !== NULL) { $widgets[] = $widget; } } } return $widgets; }