PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.0.3
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.0.3
5.13.0 5.12.1 5.12.0 5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / core / Widget / WidgetContainerConfig.php
matomo / app / core / Widget Last commit date
Widget.php 2 years ago WidgetConfig.php 2 years ago WidgetContainerConfig.php 2 years ago WidgetsList.php 2 years ago
WidgetContainerConfig.php
130 lines
1 <?php
2
3 /**
4 * Matomo - free/libre analytics platform
5 *
6 * @link https://matomo.org
7 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
8 *
9 */
10 namespace Piwik\Widget;
11
12 /**
13 * Defines a new widget container. Widget containers are useful when you want to combine several widgets
14 * into one unique widgets. For example you could combine an evolution graph widget with a sparklines widget
15 * and combine them to a single "overview widget". It also allows you to specify layouts meaning you can
16 * define a layout that will group multiple widgets into one widget displaying a menu on the left side for each
17 * widget and the actual widget on the right side. By default widgets within a container are displayed vertically
18 * one after another.
19 *
20 * To define a widget container just place a subclass within the `Widgets` folder of your plugin.
21 *
22 * @api since Piwik 3.0.0
23 */
24 class WidgetContainerConfig extends \Piwik\Widget\WidgetConfig
25 {
26 /**
27 * @var WidgetConfig[]
28 */
29 protected $widgets = array();
30 protected $layout = '';
31 protected $id = '';
32 protected $module = 'CoreHome';
33 protected $action = 'renderWidgetContainer';
34 protected $isWidgetizable = false;
35 /**
36 * Sets (overwrites) the id of the widget container.
37 *
38 * The id can be used by any plugins to add more widgets to this container and it will be also used for the unique
39 * widget id and in the URL to render this widget.
40 *
41 * @param string $id eg 'Products' or 'Contents'
42 * @return static
43 */
44 public function setId($id)
45 {
46 $this->id = $id;
47 return $this;
48 }
49 /**
50 * Get the id of the widget.
51 * @return string
52 */
53 public function getId()
54 {
55 return $this->id;
56 }
57 /**
58 * Sets the layout of the container widget.
59 *
60 * By default widgets within a container are displayed one after another. In case you want to change this
61 * behaviour you can specify a layout that will be recognized by the UI. It is not yet possible to define
62 * custom layouts.
63 *
64 * @param string $layout eg 'ByDimension' see {@link Piwik\Plugins\CoreHome\CoreHome::WIDGET_CONTAINER_LAYOUT_BY_DIMENSION}
65 * @return static
66 */
67 public function setLayout($layout)
68 {
69 $this->layout = $layout;
70 return $this;
71 }
72 /**
73 * Gets the currently set layout.
74 * @return string
75 */
76 public function getLayout()
77 {
78 return $this->layout;
79 }
80 /**
81 * Adds a new widget to the container widget.
82 *
83 * @param WidgetConfig $widget
84 * @return static
85 */
86 public function addWidgetConfig(\Piwik\Widget\WidgetConfig $widget)
87 {
88 $this->widgets[] = $widget;
89 return $this;
90 }
91 /**
92 * Set (overwrite) widget configs.
93 *
94 * @param WidgetConfig[] $configs
95 */
96 public function setWidgetConfigs($configs)
97 {
98 $this->widgets = $configs;
99 }
100 /**
101 * Get all added widget configs.
102 *
103 * @return WidgetConfig[]
104 */
105 public function getWidgetConfigs()
106 {
107 return $this->widgets;
108 }
109 /**
110 * @inheritdoc
111 */
112 public function getUniqueId()
113 {
114 $parameters = $this->getParameters();
115 unset($parameters['module']);
116 unset($parameters['action']);
117 unset($parameters['containerId']);
118 return \Piwik\Widget\WidgetsList::getWidgetUniqueId($this->id, '', $parameters);
119 }
120 /**
121 * @inheritdoc
122 */
123 public function getParameters()
124 {
125 $params = parent::getParameters();
126 $params['containerId'] = $this->getId();
127 return $params;
128 }
129 }
130