PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.8.2
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.8.2
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 / View / UIControl.php
matomo / app / core / View Last commit date
HtmlEmailFooterView.php 2 years ago HtmlReportEmailHeaderView.php 1 year ago MethodCallExpression.php 1 year ago OneClickDone.php 7 months ago RenderTokenParser.php 1 year ago SecurityPolicy.php 1 year ago UIControl.php 2 years ago ViewInterface.php 1 year ago
UIControl.php
158 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\View;
10
11 use Exception;
12 use Piwik\View;
13 /**
14 * Base type of UI controls.
15 *
16 * The JavaScript companion class can be found in plugins/CoreHome/javascripts/uiControl.js.
17 *
18 * @api
19 */
20 class UIControl extends \Piwik\View
21 {
22 /**
23 * The Twig template file that generates the control's HTML.
24 *
25 * Derived classes must set this constant.
26 */
27 public const TEMPLATE = '';
28 /**
29 * The CSS class that is used to map the root element of this control with the JavaScript class.
30 *
31 * This field must be set prior to rendering.
32 *
33 * @var string
34 */
35 public $cssIdentifier = null;
36 /**
37 * The name of the JavaScript class that handles the behavior of this control.
38 *
39 * This field must be set prior to rendering.
40 *
41 * @var string
42 */
43 public $jsClass = null;
44 /**
45 * The JavaScript module that contains the JavaScript class.
46 *
47 * @var string
48 */
49 public $jsNamespace = 'piwik/UI';
50 /**
51 * Extra CSS class(es) for the root element.
52 *
53 * @var string
54 */
55 public $cssClass = "";
56 /**
57 * HTML Attributes for the root element
58 *
59 * @var string
60 */
61 public $htmlAttributes = array();
62 /**
63 * The inner view that renders the actual control content.
64 *
65 * @var View
66 */
67 private $innerView = null;
68 /**
69 * Constructor.
70 */
71 public function __construct()
72 {
73 $this->innerView = new View(static::TEMPLATE);
74 parent::__construct("@CoreHome\\_uiControl");
75 }
76 /**
77 * Sets a variable. See {@link View::__set()}.
78 */
79 public function __set($key, $val)
80 {
81 $this->innerView->__set($key, $val);
82 }
83 /**
84 * Gets a view variable. See {@link View::__get()}.
85 */
86 public function &__get($key)
87 {
88 return $this->innerView->__get($key);
89 }
90 public function __isset($key)
91 {
92 return isset($this->innerView->templateVars[$key]);
93 }
94 /**
95 * Renders the control view within a containing <div> that is used by the UIControl JavaScript
96 * class.
97 *
98 * @return string
99 */
100 public function render()
101 {
102 if ($this->cssIdentifier === null) {
103 throw new Exception("All UIControls must set a cssIdentifier property");
104 }
105 if ($this->jsClass === null) {
106 throw new Exception("All UIControls must set a jsClass property");
107 }
108 return parent::render();
109 }
110 /**
111 * See {@link View::getTemplateVars()}.
112 */
113 public function getTemplateVars($override = array())
114 {
115 $this->templateVars['implView'] = $this->innerView;
116 $this->templateVars['cssIdentifier'] = $this->cssIdentifier;
117 $this->templateVars['cssClass'] = $this->cssClass;
118 $this->templateVars['jsClass'] = $this->jsClass;
119 $this->templateVars['htmlAttributes'] = $this->htmlAttributes;
120 $this->templateVars['jsNamespace'] = $this->jsNamespace;
121 $this->templateVars['implOverride'] = $override;
122 $innerTemplateVars = $this->innerView->getTemplateVars($override);
123 $this->templateVars['clientSideProperties'] = array();
124 foreach ($this->getClientSideProperties() as $name) {
125 $this->templateVars['clientSideProperties'][$name] = $innerTemplateVars[$name];
126 }
127 $this->templateVars['clientSideParameters'] = array();
128 foreach ($this->getClientSideParameters() as $name) {
129 $this->templateVars['clientSideParameters'][$name] = $innerTemplateVars[$name];
130 }
131 return parent::getTemplateVars($override);
132 }
133 /**
134 * Returns the array of property names whose values are passed to the UIControl JavaScript class.
135 *
136 * Should be overridden by descendants.
137 *
138 * @return array
139 */
140 public function getClientSideProperties()
141 {
142 return array();
143 }
144 /**
145 * Returns an array of property names whose values are passed to the UIControl JavaScript class.
146 * These values differ from those in {@link $clientSideProperties} in that they are meant to passed as
147 * request parameters when the JavaScript code makes an AJAX request.
148 *
149 * Should be overridden by descendants.
150 *
151 * @return array
152 */
153 public function getClientSideParameters()
154 {
155 return array();
156 }
157 }
158