|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* XOOPS form radio compo. |
|
5
|
|
|
* |
|
6
|
|
|
* You may not change or alter any portion of this comment or credits |
|
7
|
|
|
* of supporting developers from this source code or any supporting source code |
|
8
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
9
|
|
|
* This program is distributed in the hope that it will be useful, |
|
10
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
12
|
|
|
* |
|
13
|
|
|
* @copyright The XOOPS project http://www.xoops.org/ |
|
14
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
15
|
|
|
* |
|
16
|
|
|
* @since 1.91 |
|
17
|
|
|
* |
|
18
|
|
|
* @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/ |
|
19
|
|
|
* @author Taiwen Jiang <[email protected]> |
|
20
|
|
|
* |
|
21
|
|
|
* @version $Id: TDMCreateFormRadio.php 12360 2014-12-06 13:18:22Z timgno $ |
|
22
|
|
|
*/ |
|
23
|
|
|
class TDMCreateFormRadio extends XoopsFormRadio |
|
|
|
|
|
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* Prepare HTML for output. |
|
27
|
|
|
* |
|
28
|
|
|
* @return string HTML |
|
29
|
|
|
*/ |
|
30
|
|
|
public function render() |
|
31
|
|
|
{ |
|
32
|
|
|
$ret = ''; |
|
33
|
|
|
$ele_name = $this->getName(); |
|
|
|
|
|
|
34
|
|
|
$ele_title = $this->getTitle(); |
|
35
|
|
|
$ele_value = $this->getValue(); |
|
36
|
|
|
$ele_options = $this->getOptions(); |
|
37
|
|
|
$ele_extra = $this->getExtra(); |
|
38
|
|
|
$ele_delimeter = empty($this->columns) ? $this->getDelimeter() : ''; |
|
39
|
|
|
if (!empty($this->columns)) { |
|
40
|
|
|
$ret .= '<table class="table table-bordered"><tr>'; |
|
41
|
|
|
} |
|
42
|
|
|
$i = 0; |
|
43
|
|
|
$id_ele = 0; |
|
44
|
|
|
foreach ($ele_options as $value => $name) { |
|
45
|
|
|
++$id_ele; |
|
46
|
|
|
if (!empty($this->columns)) { |
|
47
|
|
|
if ($i % $this->columns == 0) { |
|
48
|
|
|
$ret .= '<tr>'; |
|
49
|
|
|
} |
|
50
|
|
|
$ret .= '<td class="radio">'; |
|
51
|
|
|
} |
|
52
|
|
|
$ret .= '<input type="radio" name="'.$ele_name.'" id="'.$ele_name.'['.$value.']'.$id_ele.'" title = "'.htmlspecialchars($ele_title, ENT_QUOTES).'" value="'.htmlspecialchars($value, ENT_QUOTES).'"'; |
|
53
|
|
|
if (isset($ele_value) && $value == $ele_value) { |
|
54
|
|
|
$ret .= ' checked="checked"'; |
|
55
|
|
|
} |
|
56
|
|
|
$ret .= $ele_extra.' />'."<label name='xolb_{$ele_name}' for='".$ele_name.'['.$value.']'.$id_ele."'><span><span></span></span>".$name.'</label>'.$ele_delimeter; |
|
57
|
|
|
if (!empty($this->columns)) { |
|
58
|
|
|
$ret .= '</td>'; |
|
59
|
|
|
if (++$i % $this->columns == 0) { |
|
60
|
|
|
$ret .= '</tr>'; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
if (!empty($this->columns)) { |
|
65
|
|
|
if ($span = $i % $this->columns) { |
|
66
|
|
|
$ret .= '<td colspan="'.($this->columns - $span).'"></td></tr>'; |
|
67
|
|
|
} |
|
68
|
|
|
$ret .= '</table>'; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
return $ret; |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.