Widgets are added through the {@hook WidgetsList.addWidgets} and filtered through the {@hook Widgets.filterWidgets}
event. Observers for this event should call the {@link addWidget()} method to add widgets or use any of the other
methods to remove widgets.
public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { $widgetsList->addWidgetConfig($factory->createContainerWidget('Continent')); $widgetsList->addToContainerWidget('Continent', $factory->createWidget()); $widget = $factory->createWidget()->setAction('getDistinctCountries')->setName(''); $widgetsList->addToContainerWidget('Continent', $widget); }
public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { if (!$this->isSubtableReport) { $widget = $factory->createWidget()->setParameters(array('secondaryDimension' => API::getInstance()->getDefaultSecondaryDimension($this->action))); $widgetsList->addToContainerWidget('Events', $widget); } }
public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { // this will render the default view, in this case an Html Table $widgetsList->addWidgetConfig($factory->createWidget()); $widgetsList->addWidgetConfig($factory->createWidget()->forceViewDataTable(Bar::ID)->setSubcategoryId('Bar graph')); if (PluginManager::getInstance()->isPluginActivated('TreemapVisualization')) { $widgetsList->addWidgetConfig($factory->createWidget()->setName('Treemap example')->setSubcategoryId('Treemap')->forceViewDataTable('infoviz-treemap')); } }
public function home() { $isMarketplaceEnabled = Marketplace::isMarketplaceEnabled(); $isFeedbackEnabled = Plugin\Manager::getInstance()->isPluginLoaded('Feedback'); $widgetsList = WidgetsList::get(); $hasDonateForm = $widgetsList->isDefined('CoreHome', 'getDonateForm'); $hasPiwikBlog = $widgetsList->isDefined('RssWidget', 'rssPiwik'); return $this->renderTemplate('home', array('isMarketplaceEnabled' => $isMarketplaceEnabled, 'isFeedbackEnabled' => $isFeedbackEnabled, 'hasDonateForm' => $hasDonateForm, 'hasPiwikBlog' => $hasPiwikBlog)); }
public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { $idSite = Common::getRequestVar('idSite', 0, 'int'); if (empty($idSite)) { return; } $goals = $this->getGoals(); $reports = Goals::getReportsWithGoalMetrics(); $page = new Pages($factory, $reports); $widgetsList->addWidgetConfigs($page->createGoalsOverviewPage($goals)); if ($this->isEcommerceEnabled($idSite)) { $widgetsList->addWidgetConfigs($page->createEcommerceOverviewPage()); $widgetsList->addWidgetConfigs($page->createEcommerceSalesPage()); } foreach ($goals as $goal) { $widgetsList->addWidgetConfigs($page->createGoalDetailPage($goal)); } }
protected function getExistingCategories() { $categories = array(); foreach (WidgetsList::get()->getWidgetConfigs() as $widget) { if ($widget->getCategoryId()) { $categories[] = Piwik::translate($widget->getCategoryId()); } } $categories = array_values(array_unique($categories)); return $categories; }
public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { $widget = $factory->createWidget()->forceViewDataTable(VisitorLog::ID)->setName('Live_VisitorLog')->setOrder(10)->setParameters(array('small' => 1)); $widgetsList->addWidgetConfig($widget); }
public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { $idSite = Common::getRequestVar('idSite', 0, 'int'); if ($idSite < 1) { return; } $dimensions = $this->getActiveDimensionsForSite($idSite); foreach ($dimensions as $dimension) { if (!$dimension['active']) { continue; } if ($dimension['scope'] === CustomDimensions::SCOPE_ACTION) { $this->categoryId = 'General_Actions'; $this->subcategoryId = 'customdimension' . $dimension['idcustomdimension']; } elseif ($dimension['scope'] === CustomDimensions::SCOPE_VISIT) { $this->categoryId = 'General_Visitors'; $this->subcategoryId = 'customdimension' . $dimension['idcustomdimension']; } else { continue; } $widget = $factory->createWidget()->setName($dimension['name']); $widget->setParameters(array('idDimension' => $dimension['idcustomdimension'])); $widgetsList->addWidgetConfig($widget); } }
public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { $widgetsList->addWidgetConfig($factory->createWidget()->setName('VisitsSummary_WidgetLastVisits')->forceViewDataTable(Evolution::ID)->setAction('getEvolutionGraph')->setOrder(5)); $widgetsList->addWidgetConfig($factory->createWidget()->setName('VisitsSummary_WidgetVisits')->forceViewDataTable(Sparklines::ID)->setOrder(10)); }
public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { $widgetsList->addWidgetConfig($factory->createWidget()->setName('VisitFrequency_WidgetGraphReturning')->forceViewDataTable(Evolution::ID)->setAction('getEvolutionGraph')->setOrder(1)); $widgetsList->addWidgetConfig($factory->createWidget()->forceViewDataTable(Sparklines::ID)->setName('VisitFrequency_WidgetOverview')->setOrder(2)); }
public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { $widget = $factory->createWidget()->setName('Referrers_Socials'); $widgetsList->addWidgetConfig($widget); }
public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { $widgetsList->addWidgetConfig($factory->createWidget()->setName('Referrers_ReferrerTypes')->setSubcategoryId('Referrers_WidgetGetAll')); $widgetsList->addWidgetConfig($factory->createWidget()->setName('General_EvolutionOverPeriod')->setSubcategoryId('General_Overview')->setAction('getEvolutionGraph')->setOrder(9)->setIsNotWidgetizable()->forceViewDataTable(Evolution::ID)->addParameters(array('columns' => $defaultColumns = array('nb_visits')))); $widgetsList->addWidgetConfig($factory->createCustomWidget('getSparklines')->forceViewDataTable(Sparklines::ID)->setIsNotWidgetizable()->setName('Referrers_Type')->setSubcategoryId('General_Overview')->setOrder(10)); }
/** * @param CategoryList $categoryList * @param WidgetsList $widgetsList * @return array */ private function buildPagesMetadata(CategoryList $categoryList, WidgetsList $widgetsList) { $pages = array(); $widgets = array(); foreach ($widgetsList->getWidgetConfigs() as $config) { $pageId = $this->buildPageId($config->getCategoryId(), $config->getSubcategoryId()); if (!isset($widgets[$pageId])) { $widgets[$pageId] = array(); } $widgets[$pageId][] = $config; } foreach ($categoryList->getCategories() as $category) { foreach ($category->getSubcategories() as $subcategory) { $pageId = $this->buildPageId($category->getId(), $subcategory->getId()); if (!empty($widgets[$pageId])) { $pages[] = $this->buildPageMetadata($category, $subcategory, $widgets[$pageId]); } } } return $pages; }
public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { $widget = $factory->createWidget(); $widgetsList->addToContainerWidget('Contents', $widget); }
/** * Returns the unique id of an widget based on module, action and the set parameters. * * @return string */ public function getUniqueId() { $parameters = $this->getParameters(); unset($parameters['module']); unset($parameters['action']); return WidgetsList::getWidgetUniqueId($this->getModule(), $this->getAction(), $parameters); }
public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { $widgetsList->addToContainerWidget('Products', $factory->createWidget()); }
public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { $widgetsList->addWidgetConfig($factory->createWidget()->setName('Actions_WidgetEntryPageTitles')); }
/** * Get a list of all widgetizable widgets. * * @param int $idSite * @return array */ public function getWidgetMetadata($idSite) { Piwik::checkUserHasViewAccess($idSite); $widgetsList = WidgetsList::get(); $categoryList = CategoryList::get(); $metadata = new WidgetMetadata(); return $metadata->getWidgetMetadata($categoryList, $widgetsList); }
public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { $widget = $factory->createWidget()->setName('Live_RealTimeVisitorCount')->setOrder(15); $widgetsList->addWidgetConfig($widget); }
public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { $widgetsList->addWidgetConfig($factory->createWidget()->setSubcategoryId('Sparklines')->forceViewDataTable(Sparklines::ID)); $widgetsList->addWidgetConfig($factory->createWidget()->setName('ExampleUI_TemperaturesEvolution')->setSubcategoryId('Evolution Graph')->forceViewDataTable(Evolution::ID)->setParameters(array('columns' => array('server1', 'server2')))); }
public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { $widget = $factory->createWidget()->setName('Provider_WidgetProviders'); $widgetsList->addWidgetConfig($widget); }
public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { $widgetsList->addWidgetConfig($factory->createWidget()); $widgetsList->addWidgetConfig($factory->createWidget()->setName('Simple tag cloud')->setSubcategoryId('Tag clouds')->forceViewDataTable(Cloud::ID)->setOrder(5)); }
/** * Replaces widgets on the given dashboard layout with other ones * * It uses the given widget definitions to find the old and to create the new widgets * Each widget is defined with an array containing the following information * array ( * 'module' => string * 'action' => string * 'params' => array() * ) * * if $newWidget does not contain a widget definition at the current position, * the old widget will simply be removed * * @param array $oldWidgets array containing widget definitions * @param array $newWidgets array containing widget definitions */ public static function replaceDashboardWidgets($dashboardLayout, $oldWidgets, $newWidgets) { if (empty($dashboardLayout) || !isset($dashboardLayout->columns)) { return $dashboardLayout; } $newColumns = array(); foreach ($dashboardLayout->columns as $id => $column) { $newColumn = array(); foreach ($column as $widget) { foreach ($oldWidgets as $pos => $oldWidgetData) { $oldWidgetId = WidgetsList::getWidgetUniqueId($oldWidgetData['module'], $oldWidgetData['action'], $oldWidgetData['params']); if (empty($newWidgets[$pos])) { continue 2; } $newWidget = $newWidgets[$pos]; if ($widget->uniqueId == $oldWidgetId) { if (!empty($newWidget['uniqueId'])) { $newWidgetId = $newWidget['uniqueId']; } else { $newWidgetId = WidgetsList::getWidgetUniqueId($newWidget['module'], $newWidget['action'], $newWidget['params']); } // is new widget already is on dashboard just remove the old one if (self::layoutContainsWidget($dashboardLayout, $newWidgetId)) { continue 2; } $widget->uniqueId = $newWidgetId; $widget->parameters->module = $newWidget['module']; $widget->parameters->action = $newWidget['action']; foreach ($newWidget['params'] as $key => $value) { $widget->parameters->{$key} = $value; } } } $newColumn[] = $widget; } $newColumns[] = $newColumn; } $dashboardLayout->columns = $newColumns; return $dashboardLayout; }
/** * lets you add any amount of widgets for this report. If a report defines a {@link $categoryId} and a * {@link $subcategoryId} a widget will be generated automatically. * * Example to add a widget manually by overwriting this method in your report: * $widgetsList->addWidgetConfig($factory->createWidget()); * * If you want to have the name and the order of the widget differently to the name and order of the report you can * do the following: * $widgetsList->addWidgetConfig($factory->createWidget()->setName('Custom')->setOrder(5)); * * If you want to add a widget to any container defined by your plugin or by another plugin you can do * this: * $widgetsList->addToContainerWidget($containerId = 'Products', $factory->createWidget()); * * @param WidgetsList $widgetsList * @param ReportWidgetFactory $factory * @api */ public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { if ($this->categoryId && $this->subcategoryId) { $widgetsList->addWidgetConfig($factory->createWidget()); } }
public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { // we have to do it manually since it's only done automatically if a subcategoryId is specified, // we do not set a subcategoryId since this report is not supposed to be shown in the UI $widgetsList->addWidgetConfig($factory->createWidget()); }
public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { $widget = $factory->createWidget()->setName('VisitorInterest_WidgetVisitsByDaysSinceLast'); $widgetsList->addWidgetConfig($widget); }
public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) { $widgetsList->addWidgetConfig($factory->createWidget()->setName('VisitorInterest_VisitsPerDuration')); }
?> " scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe> </div> <br/> <?php $_GET['idSite'] = $idSite; define('PIWIK_INCLUDE_PATH', '../..'); define('PIWIK_ENABLE_DISPATCH', false); define('PIWIK_ENABLE_ERROR_HANDLER', false); define('PIWIK_ENABLE_SESSION_START', false); require_once PIWIK_INCLUDE_PATH . "/index.php"; require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php"; FrontController::getInstance()->init(); $widgets = WidgetsList::get()->getWidgetConfigs(); $widgetCategoriesHandled = array(); foreach ($widgets as $widgetConfig) { $category = $widgetConfig->getCategoryId(); if (!empty($widgetCategoriesHandled[$category])) { continue; } $widgetCategoriesHandled[$category] = true; echo '<h2>' . $category . '</h2>'; foreach ($widgets as $widget) { if ($category !== $widget->getCategoryId()) { continue; } echo '<h3>' . \Piwik\Piwik::translate($widget->getName()) . '</h3>'; $widgetUrl = UrlHelper::getArrayFromQueryString($url); $widgetUrl['moduleToWidgetize'] = $widget->getModule();