1 : <?php
2 :
3 :
4 :
5 :
6 :
7 :
8 :
9 :
10 :
11 :
12 : class JetHtmlUtil{
13 :
14 :
15 :
16 :
17 :
18 :
19 :
20 :
21 :
22 : static public function joinTagAttribute($baseTag, $key, $value){
23 18 : if(empty($baseTag)){
24 1 : return $baseTag;
25 : }
26 18 : if(empty($key)){
27 1 : return $baseTag;
28 : }
29 18 : if(empty($value)){
30 0 : return $baseTag;
31 : }
32 :
33 18 : $createTag = str_replace(">", " " . $key . "=\"" . $value . "\">", $baseTag);
34 18 : return $createTag;
35 : }
36 :
37 :
38 :
39 :
40 :
41 :
42 :
43 :
44 :
45 :
46 : static public function createSelectBox($data, $selected, $attribute = array()){
47 7 : if(empty($data)){
48 3 : return null;
49 : }
50 4 : $html .= "<select>";
51 4 : foreach($attribute as $attributeKey=>$attributeValue){
52 3 : $html = JetHtmlUtil::joinTagAttribute($html, $attributeKey, $attributeValue);
53 3 : }
54 :
55 4 : $html .= "<option value=\"0\"></option>";
56 :
57 4 : $i = 1;
58 4 : foreach($data as $dataKey=>$dataValue){
59 4 : $html .= "<option value=\"" . $i . "\"";
60 4 : if($dataValue == $selected){
61 3 : $html .= " selected ";
62 : }
63 4 : $html .= ">" . $dataValue . "</option>";
64 4 : $i++;
65 4 : }
66 :
67 4 : $html .= "</select>";
68 4 : return $html;
69 : }
70 : }
71 : ?>
|