PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 1.3.1
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v1.3.1
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 6 years ago WidgetConfig.php 6 years ago WidgetContainerConfig.php 6 years ago WidgetsList.php 6 years ago
WidgetContainerConfig.php
141 lines
1 <?php
2 /**
3 * Piwik - free/libre analytics platform
4 *
5 * @link https://matomo.org
6 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
7 *
8 */
9 namespace Piwik\Widget;
10
11 /**
12 * Defines a new widget container. Widget containers are useful when you want to combine several widgets
13 * into one unique widgets. For example you could combine an evolution graph widget with a sparklines widget
14 * and combine them to a single "overview widget". It also allows you to specify layouts meaning you can
15 * define a layout that will group multiple widgets into one widget displaying a menu on the left side for each
16 * widget and the actual widget on the right side. By default widgets within a container are displayed vertically
17 * one after another.
18 *
19 * To define a widget container just place a subclass within the `Widgets` folder of your plugin.
20 *
21 * @api since Piwik 3.0.0
22 */
23 class WidgetContainerConfig extends WidgetConfig
24 {
25 /**
26 * @var WidgetConfig[]
27 */
28 protected $widgets = array();
29 protected $layout = '';
30 protected $id = '';
31
32 protected $module = 'CoreHome';
33 protected $action = 'renderWidgetContainer';
34 protected $isWidgetizable = false;
35
36 /**
37 * Sets (overwrites) the id of the widget container.
38 *
39 * The id can be used by any plugins to add more widgets to this container and it will be also used for the unique
40 * widget id and in the URL to render this widget.
41 *
42 * @param string $id eg 'Products' or 'Contents'
43 * @return static
44 */
45 public function setId($id)
46 {
47 $this->id = $id;
48 return $this;
49 }
50
51 /**
52 * Get the id of the widget.
53 * @return string
54 */
55 public function getId()
56 {
57 return $this->id;
58 }
59
60 /**
61 * Sets the layout of the container widget.
62 *
63 * By default widgets within a container are displayed one after another. In case you want to change this
64 * behaviour you can specify a layout that will be recognized by the UI. It is not yet possible to define
65 * custom layouts.
66 *
67 * @param string $layout eg 'ByDimension' see {@link Piwik\Plugins\CoreHome\CoreHome::WIDGET_CONTAINER_LAYOUT_BY_DIMENSION}
68 * @return static
69 */
70 public function setLayout($layout)
71 {
72 $this->layout = $layout;
73 return $this;
74 }
75
76 /**
77 * Gets the currently set layout.
78 * @return string
79 */
80 public function getLayout()
81 {
82 return $this->layout;
83 }
84
85 /**
86 * Adds a new widget to the container widget.
87 *
88 * @param WidgetConfig $widget
89 * @return static
90 */
91 public function addWidgetConfig(WidgetConfig $widget)
92 {
93 $this->widgets[] = $widget;
94
95 return $this;
96 }
97
98 /**
99 * Set (overwrite) widget configs.
100 *
101 * @param WidgetConfig[] $configs
102 */
103 public function setWidgetConfigs($configs)
104 {
105 $this->widgets = $configs;
106 }
107
108 /**
109 * Get all added widget configs.
110 *
111 * @return WidgetConfig[]
112 */
113 public function getWidgetConfigs()
114 {
115 return $this->widgets;
116 }
117
118 /**
119 * @inheritdoc
120 */
121 public function getUniqueId()
122 {
123 $parameters = $this->getParameters();
124 unset($parameters['module']);
125 unset($parameters['action']);
126 unset($parameters['containerId']);
127
128 return WidgetsList::getWidgetUniqueId($this->id, '', $parameters);
129 }
130
131 /**
132 * @inheritdoc
133 */
134 public function getParameters()
135 {
136 $params = parent::getParameters();
137 $params['containerId'] = $this->getId();
138 return $params;
139 }
140
141 }