To define a widget container just place a subclass within the Widgets folder of your plugin.
Наследование: extends WidgetConfig
Пример #1
0
 private function addContainer(WidgetContainerConfig $containerWidget)
 {
     $widgetId = $containerWidget->getId();
     $this->container[$widgetId] = $containerWidget;
     // widgets were added to this container, but the container did not exist yet.
     if (isset($this->containerWidgets[$widgetId])) {
         foreach ($this->containerWidgets[$widgetId] as $widget) {
             $containerWidget->addWidgetConfig($widget);
         }
         unset($this->containerWidgets[$widgetId]);
     }
 }
Пример #2
0
 /**
  * Creates a new container widget based on the specified report in {@link construct()}.
  *
  * It will automatically use the report's categoryId, subcategoryId (if specified) and order in order to
  * create the container.
  *
  * @param string $containerId eg 'Products' or 'Contents' see {Piwik\Widget\WidgetContainerConfig::setId()}.
  *                            Other reports or widgets will be able to add more widgets to this container.
  *                            This is useful when you want to show for example multiple related widgets
  *                            together.
  * @return WidgetContainerConfig
  */
 public function createContainerWidget($containerId)
 {
     $widget = new WidgetContainerConfig();
     $widget->setCategoryId($this->report->getCategoryId());
     $widget->setId($containerId);
     if ($this->report->getSubcategoryId()) {
         $widget->setSubcategoryId($this->report->getSubcategoryId());
     }
     $orderThatListsReportsAtTheEndOfEachCategory = 100 + $this->report->getOrder();
     $widget->setOrder($orderThatListsReportsAtTheEndOfEachCategory);
     return $widget;
 }
Пример #3
0
 private function buildGoalByDimensionView($idGoal, WidgetContainerConfig $container)
 {
     $container->setLayout('ByDimension');
     $ecommerce = $idGoal == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER;
     // for non-Goals reports, we show the goals table
     $customParams = array('documentationForGoalsPage' => '1');
     if ($idGoal === '') {
         // if no idGoal, use 0 for overview. Must be string! Otherwise Piwik_View_HtmlTable_Goals fails.
         $customParams['idGoal'] = '0';
     } else {
         $customParams['idGoal'] = $idGoal;
     }
     $translationHelper = new TranslationHelper();
     foreach ($this->allReports as $category => $reports) {
         $order = $this->getSortOrderOfCategory($category) * 100;
         if ($ecommerce) {
             $categoryText = $translationHelper->translateEcommerceMetricCategory($category);
         } else {
             $categoryText = $translationHelper->translateGoalMetricCategory($category);
         }
         foreach ($reports as $report) {
             $order++;
             if (empty($report['viewDataTable']) && empty($report['abandonedCarts'])) {
                 $report['viewDataTable'] = 'tableGoals';
             }
             if (!empty($report['parameters'])) {
                 $params = array_merge($customParams, $report['parameters']);
             } else {
                 $params = $customParams;
             }
             $widget = $this->createWidgetForReport($report['module'], $report['action']);
             if (!empty($report['name'])) {
                 $widget->setName($report['name']);
             }
             $widget->setParameters($params);
             $widget->setCategoryId($categoryText);
             $widget->setSubcategoryId($categoryText);
             $widget->setOrder($order);
             $widget->setIsNotWidgetizable();
             if (!empty($report['viewDataTable'])) {
                 $widget->forceViewDataTable($report['viewDataTable']);
             }
             $container->addWidgetConfig($widget);
         }
     }
 }