Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'core/Widget/WidgetContainerConfig.php')
-rw-r--r--core/Widget/WidgetContainerConfig.php131
1 files changed, 131 insertions, 0 deletions
diff --git a/core/Widget/WidgetContainerConfig.php b/core/Widget/WidgetContainerConfig.php
new file mode 100644
index 0000000000..258d182ab4
--- /dev/null
+++ b/core/Widget/WidgetContainerConfig.php
@@ -0,0 +1,131 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Widget;
+
+/**
+ * Defines a new widget container. Widget containers are useful when you want to combine several widgets
+ * into one unique widgets. For example you could combine an evolution graph widget with a sparklines widget
+ * and combine them to a single "overview widget". It also allows you to specify layouts meaning you can
+ * define a layout that will group multiple widgets into one widget displaying a menu on the left side for each
+ * widget and the actual widget on the right side. By default widgets within a container are displayed vertically
+ * one after another.
+ *
+ * To define a widget container just place a subclass within the `Widgets` folder of your plugin.
+ *
+ * @api since Piwik 3.0.0
+ */
+class WidgetContainerConfig extends WidgetConfig
+{
+ /**
+ * @var WidgetConfig[]
+ */
+ protected $widgets = array();
+ protected $layout = '';
+ protected $id = '';
+
+ protected $module = 'CoreHome';
+ protected $action = 'renderWidgetContainer';
+ protected $isWidgetizable = false;
+
+ /**
+ * Sets (overwrites) the id of the widget container.
+ *
+ * The id can be used by any plugins to add more widgets to this container and it will be also used for the unique
+ * widget id and in the URL to render this widget.
+ *
+ * @param string $id eg 'Products' or 'Contents'
+ * @return static
+ */
+ public function setId($id)
+ {
+ $this->id = $id;
+ return $this;
+ }
+
+ /**
+ * Get the id of the widget.
+ * @return string
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Sets the layout of the container widget.
+ *
+ * By default widgets within a container are displayed one after another. In case you want to change this
+ * behaviour you can specify a layout that will be recognized by the UI. It is not yet possible to define
+ * custom layouts.
+ *
+ * @param string $layout eg 'ByDimension' see {@link Piwik\Plugins\CoreHome\CoreHome::WIDGET_CONTAINER_LAYOUT_BY_DIMENSION}
+ * @return static
+ */
+ public function setLayout($layout)
+ {
+ $this->layout = $layout;
+ return $this;
+ }
+
+ /**
+ * Gets the currently set layout.
+ * @return string
+ */
+ public function getLayout()
+ {
+ return $this->layout;
+ }
+
+ /**
+ * Adds a new widget to the container widget.
+ *
+ * @param WidgetConfig $widget
+ * @return static
+ */
+ public function addWidgetConfig(WidgetConfig $widget)
+ {
+ $this->widgets[] = $widget;
+
+ return $this;
+ }
+
+ /**
+ * Get all added widget configs.
+ *
+ * @return WidgetConfig[]
+ */
+ public function getWidgetConfigs()
+ {
+ return $this->widgets;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getUniqueId()
+ {
+ $parameters = $this->getParameters();
+ unset($parameters['module']);
+ unset($parameters['action']);
+ unset($parameters['containerId']);
+
+ return WidgetsList::getWidgetUniqueId($this->id, '', $parameters);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getParameters()
+ {
+ $params = parent::getParameters();
+ $params['containerId'] = $this->getId();
+ return $params;
+ }
+
+} \ No newline at end of file