1 | <?php |
---|
2 | |
---|
3 | if( ! function_exists( 'yes_no_radio_option' ) ) : |
---|
4 | function yes_no_radio_option($option_name,$label,$value,$yes = '',$no= ''){ |
---|
5 | if (empty( $yes )) $yes = _YES ; |
---|
6 | if (empty( $no )) $no = _NO ; |
---|
7 | $form = $label.' : '; |
---|
8 | if ($value){ |
---|
9 | $form .= "<input type='radio' name='". $option_name . "' value='1' checked='checked' />" . $yes. "; " ; |
---|
10 | $form .= "<input type='radio' name='". $option_name . "' value='0' />". $no ; |
---|
11 | }else{ |
---|
12 | $form .= "<input type='radio' name='". $option_name . "' value='1' />" . $yes. "; " ; |
---|
13 | $form .= "<input type='radio' name='". $option_name . "' value='0' checked='checked' />". $no ; |
---|
14 | } |
---|
15 | return $form; |
---|
16 | |
---|
17 | } |
---|
18 | endif; |
---|
19 | |
---|
20 | if(!function_exists("categorie_select")): |
---|
21 | function categorie_select($option_name = '',$value='',$row_num=0 ,$sort_column = 'ID', $sort_order = 'asc') |
---|
22 | { |
---|
23 | $mydirpath = dirname(dirname(__FILE__)); |
---|
24 | $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ; |
---|
25 | $wp_prefix = preg_replace('/wordpress/','wp',$mydirname) . '_'; |
---|
26 | $xoopsDB =& Database::getInstance(); |
---|
27 | $myts =& MyTextSanitizer::getInstance(); |
---|
28 | $selected = explode(',' , $value); |
---|
29 | $isAll = (count($selected)==0||empty($selected[0]))?true:false; |
---|
30 | $sort_column = 'cat_'.$sort_column; |
---|
31 | if (empty($row_num)) $size = ''; else $size = 'size="' . $row_num . '"'; |
---|
32 | include $mydirpath.'/wp-includes/version.php'; |
---|
33 | if ($wp_db_version < 6124) { |
---|
34 | $db_xpress_categories = $xoopsDB->prefix($wp_prefix . 'categories'); |
---|
35 | $query = " |
---|
36 | SELECT cat_ID, cat_name, category_nicename,category_parent |
---|
37 | FROM $db_xpress_categories |
---|
38 | WHERE cat_ID > 0 |
---|
39 | "; |
---|
40 | $query .= " ORDER BY $sort_column $sort_order"; |
---|
41 | |
---|
42 | } else { |
---|
43 | $db_xpress_terms = $xoopsDB->prefix($wp_prefix . 'terms'); |
---|
44 | $db_xpress_term_taxonomy = $xoopsDB->prefix($wp_prefix . 'term_taxonomy'); |
---|
45 | $query = " |
---|
46 | SELECT $db_xpress_terms.term_id as cat_ID , $db_xpress_terms.name as cat_name , $db_xpress_term_taxonomy.taxonomy |
---|
47 | FROM $db_xpress_terms LEFT JOIN $db_xpress_term_taxonomy ON $db_xpress_terms.term_id = $db_xpress_term_taxonomy.term_id |
---|
48 | WHERE $db_xpress_term_taxonomy.taxonomy = 'category' |
---|
49 | "; |
---|
50 | $query .= " ORDER BY $sort_column $sort_order"; |
---|
51 | } |
---|
52 | $res = $xoopsDB->query($query, 0, 0); |
---|
53 | $option = "\t<option value=\"0\" "; |
---|
54 | if ($isAll) $option .= " selected=\"selected\""; |
---|
55 | $option .= ">"._MB_XP2_ALL ."</option>\n"; |
---|
56 | |
---|
57 | if ($res !== false){ |
---|
58 | while($row = $xoopsDB->fetchArray($res)){ |
---|
59 | $cat_name = $row['cat_name']; |
---|
60 | $cat_ID = $row['cat_ID']; |
---|
61 | $option .= "\t<option value=\"".$cat_ID."\""; |
---|
62 | if (in_array($cat_ID, $selected)) |
---|
63 | $option .= ' selected="selected"'; |
---|
64 | $option .= '>'; |
---|
65 | $option .= $myts->htmlspecialchars($cat_name); |
---|
66 | $option .= "</option>\n"; |
---|
67 | } |
---|
68 | } |
---|
69 | $output = _MB_XP2_CATS_SELECT ."<br />\n"; |
---|
70 | $output .= ' <select name="categorie" id="cat_sel" '.$size.' multiple="multiple" onclick="CatSelect()">' ."\n"; |
---|
71 | $output .= $option; |
---|
72 | $output .= '</select>'; |
---|
73 | $output .= ' ' . _MB_XP2_CATS_DIRECT_SELECT . " <input type='text' name='$option_name' id='cat_csv' value='$value' /><br />\n"; |
---|
74 | $output .= ' |
---|
75 | <script type="text/javascript"> |
---|
76 | function CatSelect(){ |
---|
77 | var idx=new Array(); |
---|
78 | var sel = document.getElementById("cat_sel").options; |
---|
79 | for(var i=0, n=0; i<sel.length; i++){ |
---|
80 | if(sel[i].selected){ idx[n++]=sel[i].value; } |
---|
81 | } |
---|
82 | if(idx.length>0){ |
---|
83 | document.getElementById("cat_csv").value = idx; |
---|
84 | } |
---|
85 | } |
---|
86 | </script> |
---|
87 | '; |
---|
88 | |
---|
89 | return $output; |
---|
90 | |
---|
91 | } |
---|
92 | endif; |
---|
93 | |
---|
94 | if(!function_exists("comment_type_select")): |
---|
95 | function comment_type_select($option_name = '',$value='') |
---|
96 | { |
---|
97 | $selected = explode(',' , $value); |
---|
98 | $isAll = (count($selected)==0||empty($selected[0]))?true:false; |
---|
99 | |
---|
100 | $option = "<option value=\"0\" "; |
---|
101 | if ($isAll) $option .= " selected=\"selected\""; |
---|
102 | $option .= ">"._MB_XP2_ALL ."</option>"; |
---|
103 | |
---|
104 | $option .= "<option value=\"1\" "; |
---|
105 | if (in_array(1, $selected)) |
---|
106 | $option .= " selected=\"selected\""; |
---|
107 | $option .= ">"._MB_XP2_COMMENT ."</option>"; |
---|
108 | |
---|
109 | $option .= "<option value=\"2\" "; |
---|
110 | if (in_array(2, $selected)) |
---|
111 | $option .= " selected=\"selected\""; |
---|
112 | $option .= ">"._MB_XP2_TRUCKBACK ."</option>"; |
---|
113 | |
---|
114 | $option .= "<option value=\"3\" "; |
---|
115 | if (in_array(3, $selected)) |
---|
116 | $option .= " selected=\"selected\""; |
---|
117 | $option .= ">"._MB_XP2_PINGBACK ."</option>"; |
---|
118 | |
---|
119 | $output = _MB_XP2_COM_TYPE . "<br />\n"; |
---|
120 | $output .= "<input type='hidden' name='$option_name' id='com_hidden' value='$value' />\n"; |
---|
121 | $output .= ' <select name="com_type" id="com_type" multiple="multiple" onclick="ComTypeSelect()">' ."\n"; |
---|
122 | $output .= $option; |
---|
123 | $output .= '</select><br />'; |
---|
124 | $output .= ' |
---|
125 | <script type="text/javascript"> |
---|
126 | function ComTypeSelect(){ |
---|
127 | var idx=new Array(); |
---|
128 | var sel=document.getElementById("com_type").options; |
---|
129 | for(var i=0, n=0; i<sel.length; i++){ |
---|
130 | if(sel[i].selected){ idx[n++]=sel[i].value; } |
---|
131 | } |
---|
132 | if(idx.length>0){ |
---|
133 | document.getElementById("com_hidden").value = idx; |
---|
134 | } |
---|
135 | } |
---|
136 | </script> |
---|
137 | '; |
---|
138 | |
---|
139 | return $output; |
---|
140 | |
---|
141 | } |
---|
142 | endif; |
---|
143 | |
---|
144 | if(!function_exists("block_template_setting")): |
---|
145 | function block_template_setting($mydirname,$option_name = '',$value='') |
---|
146 | { |
---|
147 | $temp_parm = explode(':' , $value); |
---|
148 | if (empty($temp_parm[1])) { |
---|
149 | $filename=$temp_parm[0]; |
---|
150 | $temp_type = 'db'; |
---|
151 | } else { |
---|
152 | $filename=$temp_parm[1]; |
---|
153 | $temp_type = $temp_parm[0]; |
---|
154 | } |
---|
155 | |
---|
156 | $none_prefix_filename = ''; |
---|
157 | $pattern = '^' . $mydirname . '_(.*).html'; |
---|
158 | if (preg_match('/' . $pattern . '/' , $filename, $match)){ // file prefix check |
---|
159 | $none_prefix_filename = $match[1]; |
---|
160 | } |
---|
161 | |
---|
162 | $output = _MB_XP2_THISTEMPLATE . "\n"; |
---|
163 | $output .= '<input type="hidden" size="50" name="' . $option_name . '" id="template_hide" value="' . $value .'"/>' . "\n"; |
---|
164 | $output .= ' <select name="template_type" id="template_type" onclick="Template_Make()">' ."\n"; |
---|
165 | switch ($temp_type){ |
---|
166 | case 'db': |
---|
167 | case 'DB': |
---|
168 | $output .= '<option value="0" selected="selected">db</option>'; |
---|
169 | $output .= '<option value="1">file</option>'; |
---|
170 | break; |
---|
171 | default: |
---|
172 | $output .= '<option value="0">db</option>'; |
---|
173 | $output .= '<option value="1" selected="selected">file</option>'; |
---|
174 | } |
---|
175 | $output .= '</select>'; |
---|
176 | $output .= '<b>:'.$mydirname . '_</b>'; |
---|
177 | $output .= '<input type="text" size="30" name="none_prefix_file" id="none_prefix_file" value="'. $none_prefix_filename. '" onChange="Template_Make()"/><b>.html</b><br />'; |
---|
178 | $output .= ' |
---|
179 | <script type="text/javascript"> |
---|
180 | function Template_Make(){ |
---|
181 | var type_element = document.getElementById("template_type"); |
---|
182 | var name_element = document.getElementById("none_prefix_file"); |
---|
183 | var real_element = document.getElementById("template_hide"); |
---|
184 | |
---|
185 | var file_name = "' . $mydirname . '_" + name_element.value + ".html"; |
---|
186 | if (type_element.value ==0) var tmp_type = "db:"; else var tmp_type = "file:"; |
---|
187 | real_element.value = tmp_type + file_name; |
---|
188 | } |
---|
189 | </script> |
---|
190 | '; |
---|
191 | |
---|
192 | return $output; |
---|
193 | |
---|
194 | } |
---|
195 | endif; |
---|
196 | if(!function_exists("javascript_check")): |
---|
197 | function javascript_check() |
---|
198 | { |
---|
199 | $out = '<div id="JSNG"><p style="color: red"><b>' . _MB_XP2_NO_JSCRIPT . '</b></p><br /></div>'; |
---|
200 | $out .= '<script> document.getElementById("JSNG").style.display = "none";</script>'; |
---|
201 | return $out; |
---|
202 | } |
---|
203 | endif; |
---|
204 | |
---|
205 | ?> |
---|