1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* You may not change or alter any portion of this comment or credits |
4
|
|
|
* of supporting developers from this source code or any supporting source code |
5
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
* |
7
|
|
|
* This program is distributed in the hope that it will be useful, |
8
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
14
|
|
|
* @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
15
|
|
|
* @package efqdirectory |
16
|
|
|
* @since |
17
|
|
|
* @author Martijn Hertog (aka wtravel) |
18
|
|
|
* @author XOOPS Development Team, |
19
|
|
|
*/ |
20
|
|
|
class XoopsFormImage extends XoopsFormElement |
|
|
|
|
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* Options |
24
|
|
|
* @var array |
25
|
|
|
* @access private |
26
|
|
|
*/ |
27
|
|
|
public $_options = array(); |
28
|
|
|
public $_multiple = false; |
29
|
|
|
public $_size; |
30
|
|
|
|
31
|
|
|
public $_height; |
32
|
|
|
public $_width; |
33
|
|
|
public $_src; |
34
|
|
|
public $_value = array(); |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Constructor |
38
|
|
|
* |
39
|
|
|
* @param string $caption Caption |
40
|
|
|
* @param string $name "name" attribute |
41
|
|
|
* @param mixed $value Pre-selected value (or array of them). |
42
|
|
|
* @param string $src |
43
|
|
|
* @param string $height |
44
|
|
|
* @param string $width |
45
|
|
|
* @param bool $multiple Allow multiple selections? |
46
|
|
|
* @param int|string $size Size of the selection box |
47
|
|
|
*/ |
48
|
|
|
public function __construct($caption, $name, $value = null, $src = '', $height = '50', $width = '50', $multiple = false, $size = '1') |
49
|
|
|
{ |
50
|
|
|
$this->setCaption($caption); |
51
|
|
|
$this->setName($name); |
52
|
|
|
$this->_multiple = $multiple; |
53
|
|
|
$this->_size = (int)$size; |
54
|
|
|
if (isset($value)) { |
55
|
|
|
$this->setValue($value); |
56
|
|
|
} |
57
|
|
|
$this->_height = $height; |
58
|
|
|
$this->_width = $width; |
59
|
|
|
$this->_src = $src; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return string |
64
|
|
|
*/ |
65
|
|
|
public function getWidth() |
66
|
|
|
{ |
67
|
|
|
return $this->_width; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return string |
72
|
|
|
*/ |
73
|
|
|
public function getHeight() |
74
|
|
|
{ |
75
|
|
|
return $this->_height; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return string |
80
|
|
|
*/ |
81
|
|
|
public function getSrc() |
82
|
|
|
{ |
83
|
|
|
return $this->_src; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/* |
87
|
|
|
* Are multiple selections allowed? |
88
|
|
|
* |
89
|
|
|
* @return bool |
90
|
|
|
*/ |
91
|
|
|
/** |
92
|
|
|
* @return bool |
93
|
|
|
*/ |
94
|
|
|
public function isMultiple() |
95
|
|
|
{ |
96
|
|
|
return $this->_multiple; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Get the size |
101
|
|
|
* |
102
|
|
|
* @return int |
103
|
|
|
*/ |
104
|
|
|
public function getSize() |
105
|
|
|
{ |
106
|
|
|
return $this->_size; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Get an array of pre-selected values |
111
|
|
|
* |
112
|
|
|
* @return array |
113
|
|
|
*/ |
114
|
|
|
public function getValue() |
115
|
|
|
{ |
116
|
|
|
return $this->_value; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Set pre-selected values |
121
|
|
|
* |
122
|
|
|
* @param $value mixed |
123
|
|
|
*/ |
124
|
|
View Code Duplication |
public function setValue($value) |
|
|
|
|
125
|
|
|
{ |
126
|
|
|
if (is_array($value)) { |
127
|
|
|
foreach ($value as $v) { |
128
|
|
|
$this->_value[] = $v; |
129
|
|
|
} |
130
|
|
|
} else { |
131
|
|
|
$this->_value[] = $value; |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Add an option |
137
|
|
|
* |
138
|
|
|
* @param string $value "value" attribute |
139
|
|
|
* @param string $name "name" attribute |
140
|
|
|
*/ |
141
|
|
View Code Duplication |
public function addOption($value, $name = '') |
|
|
|
|
142
|
|
|
{ |
143
|
|
|
if ($name !== '') { |
144
|
|
|
$this->_options[$value] = $name; |
145
|
|
|
} else { |
146
|
|
|
$this->_options[$value] = $value; |
147
|
|
|
} |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Add multiple options |
152
|
|
|
* |
153
|
|
|
* @param array $options Associative array of value->name pairs |
154
|
|
|
*/ |
155
|
|
|
public function addOptionArray($options) |
156
|
|
|
{ |
157
|
|
|
if (is_array($options)) { |
158
|
|
|
foreach ($options as $k => $v) { |
159
|
|
|
$this->addOption($k, $v); |
160
|
|
|
} |
161
|
|
|
} |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* Get all options |
166
|
|
|
* |
167
|
|
|
* @return array Associative array of value->name pairs |
168
|
|
|
*/ |
169
|
|
|
public function getOptions() |
170
|
|
|
{ |
171
|
|
|
return $this->_options; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Prepare HTML for output |
176
|
|
|
* |
177
|
|
|
* @return string HTML |
178
|
|
|
*/ |
179
|
|
|
public function render() |
180
|
|
|
{ |
181
|
|
|
if ($this->getSrc() !== '') { |
182
|
|
|
$ret = "<img src='" . $this->getSrc() . '\' width=\'' . $this->getWidth() . '\' height=\'' . $this->getHeight() . '\''; |
183
|
|
|
$ret .= '>'; |
184
|
|
|
} else { |
185
|
|
|
$ret = _MD_NOIMAGE; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
return $ret; |
189
|
|
|
} |
190
|
|
|
} |
191
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths