PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 4.3.0
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v4.3.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 / QuickForm2.php
matomo / app / core Last commit date
API 5 years ago Access 5 years ago Application 5 years ago Archive 5 years ago ArchiveProcessor 5 years ago Archiver 5 years ago AssetManager 5 years ago Auth 5 years ago Category 5 years ago CliMulti 5 years ago Columns 5 years ago Composer 5 years ago Concurrency 5 years ago Config 5 years ago Container 5 years ago CronArchive 5 years ago DataAccess 5 years ago DataFiles 5 years ago DataTable 5 years ago Db 5 years ago DeviceDetector 5 years ago Email 5 years ago Exception 5 years ago Http 5 years ago Intl 5 years ago Mail 5 years ago Measurable 5 years ago Menu 5 years ago Metrics 5 years ago Notification 5 years ago Period 5 years ago Plugin 5 years ago ProfessionalServices 5 years ago Report 5 years ago ReportRenderer 5 years ago Scheduler 5 years ago Segment 5 years ago Session 5 years ago Settings 5 years ago Tracker 5 years ago Translation 5 years ago UpdateCheck 5 years ago Updater 5 years ago Updates 5 years ago Validators 5 years ago View 5 years ago ViewDataTable 5 years ago Visualization 5 years ago Widget 5 years ago .htaccess 6 years ago Access.php 5 years ago Archive.php 5 years ago ArchiveProcessor.php 5 years ago AssetManager.php 5 years ago Auth.php 5 years ago AuthResult.php 5 years ago BaseFactory.php 5 years ago Cache.php 5 years ago CacheId.php 5 years ago CliMulti.php 5 years ago Common.php 5 years ago Config.php 5 years ago Console.php 5 years ago Context.php 5 years ago Cookie.php 5 years ago CronArchive.php 5 years ago DataArray.php 5 years ago DataTable.php 5 years ago Date.php 5 years ago Db.php 5 years ago DbHelper.php 5 years ago Development.php 5 years ago ErrorHandler.php 5 years ago EventDispatcher.php 5 years ago ExceptionHandler.php 5 years ago FileIntegrity.php 5 years ago Filechecks.php 5 years ago Filesystem.php 5 years ago FrontController.php 5 years ago Http.php 5 years ago IP.php 5 years ago Log.php 5 years ago LogDeleter.php 5 years ago Mail.php 5 years ago Metrics.php 5 years ago NoAccessException.php 5 years ago Nonce.php 5 years ago Notification.php 5 years ago NumberFormatter.php 5 years ago Option.php 5 years ago Period.php 5 years ago Piwik.php 5 years ago Plugin.php 5 years ago Profiler.php 5 years ago ProxyHeaders.php 5 years ago ProxyHttp.php 5 years ago QuickForm2.php 5 years ago RankingQuery.php 5 years ago ReportRenderer.php 5 years ago Segment.php 5 years ago Sequence.php 5 years ago Session.php 5 years ago SettingsPiwik.php 5 years ago SettingsServer.php 5 years ago Singleton.php 5 years ago Site.php 5 years ago SupportedBrowser.php 5 years ago TCPDF.php 5 years ago Theme.php 5 years ago Timer.php 5 years ago Tracker.php 5 years ago Twig.php 5 years ago Unzip.php 5 years ago UpdateCheck.php 5 years ago Updater.php 5 years ago UpdaterErrorException.php 5 years ago Updates.php 5 years ago Url.php 5 years ago UrlHelper.php 5 years ago Version.php 5 years ago View.php 5 years ago bootstrap.php 5 years ago dispatch.php 5 years ago testMinimumPhpVersion.php 5 years ago
QuickForm2.php
146 lines
1 <?php
2 /**
3 * Matomo - 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
10 namespace Piwik;
11
12 use HTML_QuickForm2;
13 use HTML_QuickForm2_InvalidArgumentException;
14 use HTML_QuickForm2_Node;
15 use HTML_QuickForm2_NotFoundException;
16 use HTML_QuickForm2_Renderer;
17
18 /**
19 * Manages forms displayed in Twig
20 *
21 * For an example, @see Piwik\Plugins\Login\FormLogin
22 *
23 * @see HTML_QuickForm2, libs/HTML/QuickForm2.php
24 * @link http://pear.php.net/package/HTML_QuickForm2/
25 */
26 abstract class QuickForm2 extends HTML_QuickForm2
27 {
28 protected $a_formElements = array();
29
30 public function __construct($id, $method = 'post', $attributes = null, $trackSubmit = false)
31 {
32 if (!isset($attributes['action'])) {
33 $attributes['action'] = Url::getCurrentQueryString();
34 }
35 if (!isset($attributes['name'])) {
36 $attributes['name'] = $id;
37 }
38 parent::__construct($id, $method, $attributes, $trackSubmit);
39
40 $this->init();
41 }
42
43 /**
44 * Class specific initialization
45 */
46 abstract public function init();
47
48 /**
49 * The elements in this form
50 *
51 * @return array Element names
52 */
53 public function getElementList()
54 {
55 return $this->a_formElements;
56 }
57
58 /**
59 * Wrapper around HTML_QuickForm2_Container's addElement()
60 *
61 * @param string|HTML_QuickForm2_Node $elementOrType Either type name (treated
62 * case-insensitively) or an element instance
63 * @param mixed $name Element name
64 * @param mixed $attributes Element attributes
65 * @param array $data Element-specific data
66 * @return HTML_QuickForm2_Node Added element
67 * @throws HTML_QuickForm2_InvalidArgumentException
68 * @throws HTML_QuickForm2_NotFoundException
69 */
70 public function addElement($elementOrType, $name = null, $attributes = null,
71 array $data = array())
72 {
73 if ($name != 'submit') {
74 $this->a_formElements[] = $name;
75 }
76
77 return parent::addElement($elementOrType, $name, $attributes, $data);
78 }
79
80 public function setChecked($nameElement)
81 {
82 foreach ($this->_elements as $key => $value) {
83 if ($value->_attributes['name'] == $nameElement) {
84 $this->_elements[$key]->_attributes['checked'] = 'checked';
85 }
86 }
87 }
88
89 public function setSelected($nameElement, $value)
90 {
91 foreach ($this->_elements as $key => $value) {
92 if ($value->_attributes['name'] == $nameElement) {
93 $this->_elements[$key]->_attributes['selected'] = 'selected';
94 }
95 }
96 }
97
98 /**
99 * Ported from HTML_QuickForm to minimize changes to Controllers
100 *
101 * @param string $elementName
102 * @return mixed
103 */
104 public function getSubmitValue($elementName)
105 {
106 $value = $this->getValue();
107 return isset($value[$elementName]) ? $value[$elementName] : null;
108 }
109
110 public function getErrorMessages()
111 {
112 $messages = array();
113
114 foreach ($this as $element) {
115 $messages[] = $element->getError();
116 }
117
118 return array_filter($messages);
119 }
120
121 protected static $registered = false;
122
123 /**
124 * Returns the rendered form as an array.
125 *
126 * @param bool $groupErrors Whether to group errors together or not.
127 * @return array
128 */
129 public function getFormData($groupErrors = true)
130 {
131 if (!self::$registered) {
132 HTML_QuickForm2_Renderer::register('smarty', 'HTML_QuickForm2_Renderer_Smarty');
133 self::$registered = true;
134 }
135
136 // Create the renderer object
137 $renderer = HTML_QuickForm2_Renderer::factory('smarty');
138 $renderer->setOption('group_errors', $groupErrors);
139
140 // build the HTML for the form
141 $this->render($renderer);
142
143 return $renderer->toArray();
144 }
145 }
146