Esempio n. 1
0
 /**
  * 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;
 }