PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.2.0
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.2.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 1 year ago WidgetConfig.php 1 year ago WidgetContainerConfig.php 1 year ago WidgetsList.php 1 year ago
WidgetContainerConfig.php
129 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 * @param WidgetConfig $widget
83 * @return static
84 */
85 public function addWidgetConfig(\Piwik\Widget\WidgetConfig $widget)
86 {
87 $this->widgets[] = $widget;
88 return $this;
89 }
90 /**
91 * Set (overwrite) widget configs.
92 *
93 * @param WidgetConfig[] $configs
94 */
95 public function setWidgetConfigs($configs)
96 {
97 $this->widgets = $configs;
98 }
99 /**
100 * Get all added widget configs.
101 *
102 * @return WidgetConfig[]
103 */
104 public function getWidgetConfigs()
105 {
106 return $this->widgets;
107 }
108 /**
109 * @inheritdoc
110 */
111 public function getUniqueId()
112 {
113 $parameters = $this->getParameters();
114 unset($parameters['module']);
115 unset($parameters['action']);
116 unset($parameters['containerId']);
117 return \Piwik\Widget\WidgetsList::getWidgetUniqueId($this->id, '', $parameters);
118 }
119 /**
120 * @inheritdoc
121 */
122 public function getParameters()
123 {
124 $params = parent::getParameters();
125 $params['containerId'] = $this->getId();
126 return $params;
127 }
128 }
129