PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / trunk
Matomo Analytics – Powerful, Privacy-First Insights for WordPress vtrunk
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 3 months ago WidgetConfig.php 1 month ago WidgetContainerConfig.php 3 months ago WidgetsList.php 1 month ago
WidgetContainerConfig.php
128 lines
1 <?php
2
3 /**
4 * Matomo - free/libre analytics platform
5 *
6 * @link https://matomo.org
7 * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
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 \Piwik\Widget\WidgetConfig
24 {
25 /**
26 * @var WidgetConfig[]
27 */
28 protected $widgets = array();
29 protected $layout = '';
30 protected $id = '';
31 protected $module = 'CoreHome';
32 protected $action = 'renderWidgetContainer';
33 protected $isWidgetizable = \false;
34 /**
35 * Sets (overwrites) the id of the widget container.
36 *
37 * The id can be used by any plugins to add more widgets to this container and it will be also used for the unique
38 * widget id and in the URL to render this widget.
39 *
40 * @param string $id eg 'Products' or 'Contents'
41 * @return static
42 */
43 public function setId($id)
44 {
45 $this->id = $id;
46 return $this;
47 }
48 /**
49 * Get the id of the widget.
50 * @return string
51 */
52 public function getId()
53 {
54 return $this->id;
55 }
56 /**
57 * Sets the layout of the container widget.
58 *
59 * By default widgets within a container are displayed one after another. In case you want to change this
60 * behaviour you can specify a layout that will be recognized by the UI. It is not yet possible to define
61 * custom layouts.
62 *
63 * @param string $layout eg 'ByDimension' see {@link Piwik\Plugins\CoreHome\CoreHome::WIDGET_CONTAINER_LAYOUT_BY_DIMENSION}
64 * @return static
65 */
66 public function setLayout($layout)
67 {
68 $this->layout = $layout;
69 return $this;
70 }
71 /**
72 * Gets the currently set layout.
73 * @return string
74 */
75 public function getLayout()
76 {
77 return $this->layout;
78 }
79 /**
80 * Adds a new widget to the container widget.
81 *
82 * @return static
83 */
84 public function addWidgetConfig(\Piwik\Widget\WidgetConfig $widget)
85 {
86 $this->widgets[] = $widget;
87 return $this;
88 }
89 /**
90 * Set (overwrite) widget configs.
91 *
92 * @param WidgetConfig[] $configs
93 */
94 public function setWidgetConfigs($configs)
95 {
96 $this->widgets = $configs;
97 }
98 /**
99 * Get all added widget configs.
100 *
101 * @return WidgetConfig[]
102 */
103 public function getWidgetConfigs()
104 {
105 return $this->widgets;
106 }
107 /**
108 * @inheritdoc
109 */
110 public function getUniqueId()
111 {
112 $parameters = $this->getParameters();
113 unset($parameters['module']);
114 unset($parameters['action']);
115 unset($parameters['containerId']);
116 return \Piwik\Widget\WidgetsList::getWidgetUniqueId($this->id, '', $parameters);
117 }
118 /**
119 * @inheritdoc
120 */
121 public function getParameters()
122 {
123 $params = parent::getParameters();
124 $params['containerId'] = $this->getId();
125 return $params;
126 }
127 }
128