Apply PSR-12 code style (#3886)
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / condition / AbstractMultipleFieldsCondition.class.php
CommitLineData
87d3a054 1<?php
a9229942 2
87d3a054 3namespace wcf\system\condition;
a9229942 4
87d3a054
MS
5use wcf\system\WCF;
6
7/**
8 * Abstract implementation of a condition for multiple fields.
a9229942
TD
9 *
10 * @author Matthias Schmidt
11 * @copyright 2001-2019 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package WoltLabSuite\Core\System\Condition
87d3a054 14 */
a9229942
TD
15abstract class AbstractMultipleFieldsCondition extends AbstractCondition
16{
17 /**
18 * language items of the input element descriptions
19 * @var string[]
20 */
21 protected $descriptions = [];
22
23 /**
24 * error messages if the validation failed
25 * @var string[]
26 */
27 protected $errorMessages = [];
28
29 /**
30 * language items of the input element labels
31 * @var string[]
32 */
33 protected $labels = [];
34
35 /**
36 * Returns the description element for the HTML output.
37 *
38 * @param string $identifier
39 * @return string
40 */
41 protected function getDescriptionElement($identifier)
42 {
43 if (isset($this->descriptions[$identifier])) {
44 return '<small>' . WCF::getLanguage()->get($this->descriptions[$identifier]) . '</small>';
45 }
46
47 return '';
48 }
49
50 /**
51 * Returns the error class for the definition list element.
52 *
53 * @param string $identifier
54 * @return string
55 */
56 public function getErrorClass($identifier)
57 {
58 if (isset($this->errorMessages[$identifier])) {
59 return ' class="formError"';
60 }
61
62 return '';
63 }
64
65 /**
66 * Returns the error message element for the HTML output.
67 *
68 * @param string $identifier
69 * @return string
70 */
71 protected function getErrorMessageElement($identifier)
72 {
73 if (isset($this->errorMessages[$identifier])) {
74 return '<small class="innerError">' . WCF::getLanguage()->getDynamicVariable($this->errorMessages[$identifier]) . '</small>';
75 }
76
77 return '';
78 }
79
80 /**
81 * Returns the label of the input element.
82 *
83 * @param string $identifier
84 * @return string
85 */
86 protected function getLabel($identifier)
87 {
88 if (isset($this->labels[$identifier])) {
89 return '<label for="' . $identifier . '">' . WCF::getLanguage()->get($this->labels[$identifier]) . '</label>';
90 }
91
92 return '';
93 }
87d3a054 94}