| [35] | 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 |  | 
|---|
| [435] | 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__ ) ) ) ; | 
|---|
| [583] | 25 | $wp_prefix = preg_replace('/wordpress/','wp',$mydirname) . '_'; | 
|---|
| [835] | 26 | $xoopsDB =& XoopsDatabaseFactory::getDatabaseConnection(); | 
|---|
| [435] | 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"; | 
|---|
| [35] | 41 |  | 
|---|
| [435] | 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"; | 
|---|
| [35] | 56 |  | 
|---|
| [435] | 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"; | 
|---|
| [513] | 70 | $output .= '  <select name="categorie" id="cat_sel" '.$size.' multiple="multiple" onclick="CatSelect()">' ."\n"; | 
|---|
| [435] | 71 | $output .= $option; | 
|---|
| [512] | 72 | $output .= '</select>'; | 
|---|
| [513] | 73 | $output .=  ' ' .  _MB_XP2_CATS_DIRECT_SELECT . " <input type='text' name='$option_name' id='cat_csv' value='$value' /><br />\n"; | 
|---|
| [435] | 74 | $output .= ' | 
|---|
|  | 75 | <script type="text/javascript"> | 
|---|
|  | 76 | function CatSelect(){ | 
|---|
|  | 77 | var idx=new Array(); | 
|---|
| [513] | 78 | var sel = document.getElementById("cat_sel").options; | 
|---|
| [435] | 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){ | 
|---|
| [513] | 83 | document.getElementById("cat_csv").value = idx; | 
|---|
| [435] | 84 | } | 
|---|
|  | 85 | } | 
|---|
|  | 86 | </script> | 
|---|
|  | 87 | '; | 
|---|
|  | 88 |  | 
|---|
|  | 89 | return $output; | 
|---|
|  | 90 |  | 
|---|
|  | 91 | } | 
|---|
|  | 92 | endif; | 
|---|
| [792] | 93 | if(!function_exists("blog_select")): | 
|---|
|  | 94 | function blog_select($option_name = '',$value='',$exclusion=false ,$row_num=0) | 
|---|
|  | 95 | { | 
|---|
|  | 96 | $mydirpath = dirname(dirname(__FILE__)); | 
|---|
|  | 97 | $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ; | 
|---|
|  | 98 | $wp_prefix = preg_replace('/wordpress/','wp',$mydirname) . '_'; | 
|---|
| [835] | 99 | $xoopsDB =& XoopsDatabaseFactory::getDatabaseConnection(); | 
|---|
| [792] | 100 | $myts =& MyTextSanitizer::getInstance(); | 
|---|
|  | 101 | $selected = explode(',' , $value); | 
|---|
|  | 102 | $isAll = (count($selected)==0||empty($selected[0]))?true:false; | 
|---|
|  | 103 |  | 
|---|
|  | 104 | if (empty($row_num)) $size = ''; else $size = 'size="' . $row_num . '"'; | 
|---|
|  | 105 | include $mydirpath.'/wp-includes/version.php'; | 
|---|
|  | 106 |  | 
|---|
|  | 107 | $option = "\t<option value=\"0\" "; | 
|---|
|  | 108 | if ($isAll) $option .= " selected=\"selected\""; | 
|---|
|  | 109 | if ($exclusion){ | 
|---|
|  | 110 | $option .= ">"._MB_XP2_NONE ."</option>\n"; | 
|---|
|  | 111 | } else { | 
|---|
|  | 112 | $option .= ">"._MB_XP2_ALL ."</option>\n"; | 
|---|
|  | 113 | } | 
|---|
| [435] | 114 |  | 
|---|
| [792] | 115 | if ($wp_db_version > 6124) { | 
|---|
|  | 116 | $db_xpress_blogs = $xoopsDB->prefix($wp_prefix . 'blogs'); | 
|---|
|  | 117 | $query = " | 
|---|
|  | 118 | SELECT blog_id | 
|---|
|  | 119 | FROM $db_xpress_blogs | 
|---|
|  | 120 | ORDER BY blog_id | 
|---|
|  | 121 | "; | 
|---|
|  | 122 |  | 
|---|
|  | 123 | if ($res =  $xoopsDB->query($query, 0, 0)){ | 
|---|
|  | 124 | while($row = $xoopsDB->fetchArray($res)){ | 
|---|
|  | 125 |  | 
|---|
|  | 126 | $blog_id = $row['blog_id']; | 
|---|
|  | 127 | if ($blog_id == 1) { | 
|---|
|  | 128 | $blog_selector = ''; | 
|---|
|  | 129 | } else { | 
|---|
|  | 130 | $blog_selector = $blog_id . '_'; | 
|---|
|  | 131 | } | 
|---|
|  | 132 | $db_xpress_options = $xoopsDB->prefix($wp_prefix . $blog_selector . 'options'); | 
|---|
|  | 133 | $options_query = " | 
|---|
|  | 134 | SELECT option_value | 
|---|
|  | 135 | FROM $db_xpress_options | 
|---|
|  | 136 | WHERE option_name = 'blogname' | 
|---|
|  | 137 | "; | 
|---|
|  | 138 | if ($options_res =  $xoopsDB->query($options_query, 0, 0)){ | 
|---|
|  | 139 | $options_row = $xoopsDB->fetchArray($options_res); | 
|---|
|  | 140 | $blog_name = $options_row['option_value']; | 
|---|
|  | 141 | } else { | 
|---|
|  | 142 | $blog_name = 'Blog_' . $blog_id ; | 
|---|
|  | 143 | } | 
|---|
|  | 144 |  | 
|---|
|  | 145 | $option .= "\t<option value=\"".$blog_id."\""; | 
|---|
|  | 146 | if (in_array($blog_id, $selected)) | 
|---|
|  | 147 | $option .= ' selected="selected"'; | 
|---|
|  | 148 | $option .= '>'; | 
|---|
|  | 149 | $option .= $myts->htmlspecialchars($blog_name); | 
|---|
|  | 150 | $option .= "</option>\n"; | 
|---|
|  | 151 | } | 
|---|
|  | 152 | } | 
|---|
|  | 153 | } | 
|---|
|  | 154 | if ($exclusion){ | 
|---|
|  | 155 | $output = _MB_XP2_EXCLUSION_BLOGS_SELECT ."<br />\n"; | 
|---|
|  | 156 | } else { | 
|---|
|  | 157 | $output = _MB_XP2_SHOW_BLOGS_SELECT ."<br />\n"; | 
|---|
|  | 158 | } | 
|---|
|  | 159 | $output .= '  <select name="blogs" id="blog_sel" '.$size.' multiple="multiple" onclick="BlogSelect()">' ."\n"; | 
|---|
|  | 160 | $output .= $option; | 
|---|
|  | 161 | $output .= '</select>'; | 
|---|
|  | 162 | $output .=  ' ' .  _MB_XP2_BLOGS_DIRECT_SELECT . " <input type='text' name='$option_name' id='blog_csv' value='$value' /><br />\n"; | 
|---|
|  | 163 | $output .= ' | 
|---|
|  | 164 | <script type="text/javascript"> | 
|---|
|  | 165 | function BlogSelect(){ | 
|---|
|  | 166 | var idx=new Array(); | 
|---|
|  | 167 | var sel = document.getElementById("blog_sel").options; | 
|---|
|  | 168 | for(var i=0, n=0; i<sel.length; i++){ | 
|---|
|  | 169 | if(sel[i].selected){ idx[n++]=sel[i].value; } | 
|---|
|  | 170 | } | 
|---|
|  | 171 | if(idx.length>0){ | 
|---|
|  | 172 | document.getElementById("blog_csv").value = idx; | 
|---|
|  | 173 | } | 
|---|
|  | 174 | } | 
|---|
|  | 175 | </script> | 
|---|
|  | 176 | '; | 
|---|
|  | 177 |  | 
|---|
|  | 178 | return $output; | 
|---|
|  | 179 |  | 
|---|
|  | 180 | } | 
|---|
|  | 181 | endif; | 
|---|
|  | 182 |  | 
|---|
| [436] | 183 | if(!function_exists("comment_type_select")): | 
|---|
|  | 184 | function comment_type_select($option_name = '',$value='') | 
|---|
|  | 185 | { | 
|---|
|  | 186 | $selected = explode(',' , $value); | 
|---|
|  | 187 | $isAll = (count($selected)==0||empty($selected[0]))?true:false; | 
|---|
|  | 188 |  | 
|---|
|  | 189 | $option = "<option value=\"0\" "; | 
|---|
| [484] | 190 | if ($isAll) $option .= " selected=\"selected\""; | 
|---|
| [436] | 191 | $option .= ">"._MB_XP2_ALL ."</option>"; | 
|---|
|  | 192 |  | 
|---|
|  | 193 | $option .= "<option value=\"1\" "; | 
|---|
|  | 194 | if (in_array(1, $selected)) | 
|---|
|  | 195 | $option .= " selected=\"selected\""; | 
|---|
|  | 196 | $option .= ">"._MB_XP2_COMMENT ."</option>"; | 
|---|
|  | 197 |  | 
|---|
|  | 198 | $option .= "<option value=\"2\" "; | 
|---|
|  | 199 | if (in_array(2, $selected)) | 
|---|
|  | 200 | $option .= " selected=\"selected\""; | 
|---|
|  | 201 | $option .= ">"._MB_XP2_TRUCKBACK ."</option>"; | 
|---|
|  | 202 |  | 
|---|
|  | 203 | $option .= "<option value=\"3\" "; | 
|---|
|  | 204 | if (in_array(3, $selected)) | 
|---|
|  | 205 | $option .= " selected=\"selected\""; | 
|---|
|  | 206 | $option .= ">"._MB_XP2_PINGBACK ."</option>"; | 
|---|
|  | 207 |  | 
|---|
|  | 208 | $output = _MB_XP2_COM_TYPE . "<br />\n"; | 
|---|
| [513] | 209 | $output .=  "<input type='hidden' name='$option_name' id='com_hidden' value='$value' />\n"; | 
|---|
|  | 210 | $output .= '  <select name="com_type" id="com_type" multiple="multiple" onclick="ComTypeSelect()">' ."\n"; | 
|---|
| [436] | 211 | $output .= $option; | 
|---|
|  | 212 | $output .= '</select><br />'; | 
|---|
|  | 213 | $output .= ' | 
|---|
|  | 214 | <script type="text/javascript"> | 
|---|
|  | 215 | function ComTypeSelect(){ | 
|---|
|  | 216 | var idx=new Array(); | 
|---|
| [513] | 217 | var sel=document.getElementById("com_type").options; | 
|---|
| [436] | 218 | for(var i=0, n=0; i<sel.length; i++){ | 
|---|
|  | 219 | if(sel[i].selected){ idx[n++]=sel[i].value; } | 
|---|
|  | 220 | } | 
|---|
|  | 221 | if(idx.length>0){ | 
|---|
| [513] | 222 | document.getElementById("com_hidden").value = idx; | 
|---|
| [436] | 223 | } | 
|---|
|  | 224 | } | 
|---|
|  | 225 | </script> | 
|---|
|  | 226 | '; | 
|---|
|  | 227 |  | 
|---|
|  | 228 | return $output; | 
|---|
|  | 229 |  | 
|---|
|  | 230 | } | 
|---|
|  | 231 | endif; | 
|---|
|  | 232 |  | 
|---|
| [484] | 233 | if(!function_exists("block_template_setting")): | 
|---|
|  | 234 | function block_template_setting($mydirname,$option_name = '',$value='') | 
|---|
|  | 235 | { | 
|---|
|  | 236 | $temp_parm = explode(':' , $value); | 
|---|
|  | 237 | if (empty($temp_parm[1])) { | 
|---|
|  | 238 | $filename=$temp_parm[0]; | 
|---|
|  | 239 | $temp_type = 'db'; | 
|---|
|  | 240 | } else  { | 
|---|
|  | 241 | $filename=$temp_parm[1]; | 
|---|
|  | 242 | $temp_type = $temp_parm[0]; | 
|---|
|  | 243 | } | 
|---|
| [436] | 244 |  | 
|---|
| [484] | 245 | $none_prefix_filename = ''; | 
|---|
|  | 246 | $pattern = '^' . $mydirname . '_(.*).html'; | 
|---|
|  | 247 | if (preg_match('/' . $pattern . '/' , $filename, $match)){ // file prefix check | 
|---|
|  | 248 | $none_prefix_filename = $match[1]; | 
|---|
|  | 249 | } | 
|---|
|  | 250 |  | 
|---|
|  | 251 | $output = _MB_XP2_THISTEMPLATE . "\n"; | 
|---|
| [513] | 252 | $output .=      '<input type="hidden" size="50" name="' . $option_name . '" id="template_hide" value="' . $value .'"/>' . "\n"; | 
|---|
|  | 253 | $output .= ' <select name="template_type" id="template_type" onclick="Template_Make()">' ."\n"; | 
|---|
| [484] | 254 | switch ($temp_type){ | 
|---|
|  | 255 | case 'db': | 
|---|
|  | 256 | case 'DB': | 
|---|
|  | 257 | $output .=  '<option value="0" selected="selected">db</option>'; | 
|---|
|  | 258 | $output .=  '<option value="1">file</option>'; | 
|---|
|  | 259 | break; | 
|---|
|  | 260 | default: | 
|---|
|  | 261 | $output .=  '<option value="0">db</option>'; | 
|---|
|  | 262 | $output .=  '<option value="1" selected="selected">file</option>'; | 
|---|
|  | 263 | } | 
|---|
|  | 264 | $output .= '</select>'; | 
|---|
|  | 265 | $output .= '<b>:'.$mydirname . '_</b>'; | 
|---|
| [513] | 266 | $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 />'; | 
|---|
| [484] | 267 | $output .= ' | 
|---|
|  | 268 | <script type="text/javascript"> | 
|---|
|  | 269 | function Template_Make(){ | 
|---|
| [513] | 270 | var type_element = document.getElementById("template_type"); | 
|---|
|  | 271 | var name_element = document.getElementById("none_prefix_file"); | 
|---|
|  | 272 | var real_element = document.getElementById("template_hide"); | 
|---|
| [484] | 273 |  | 
|---|
|  | 274 | var file_name = "' . $mydirname . '_" + name_element.value + ".html"; | 
|---|
|  | 275 | if (type_element.value ==0) var tmp_type = "db:"; else var tmp_type = "file:"; | 
|---|
|  | 276 | real_element.value = tmp_type + file_name; | 
|---|
|  | 277 | } | 
|---|
|  | 278 | </script> | 
|---|
|  | 279 | '; | 
|---|
|  | 280 |  | 
|---|
|  | 281 | return $output; | 
|---|
|  | 282 |  | 
|---|
|  | 283 | } | 
|---|
|  | 284 | endif; | 
|---|
| [495] | 285 | if(!function_exists("javascript_check")): | 
|---|
|  | 286 | function javascript_check() | 
|---|
|  | 287 | { | 
|---|
|  | 288 | $out  = '<div id="JSNG"><p style="color: red"><b>' . _MB_XP2_NO_JSCRIPT . '</b></p><br /></div>'; | 
|---|
|  | 289 | $out .= '<script>  document.getElementById("JSNG").style.display = "none";</script>'; | 
|---|
|  | 290 | return $out; | 
|---|
|  | 291 | } | 
|---|
|  | 292 | endif; | 
|---|
| [484] | 293 |  | 
|---|
| [829] | 294 | if (!function_exists('wp_version_compare')){ | 
|---|
|  | 295 | function wp_version_compare($wp_version , $operator='==',$comp_version){ | 
|---|
|  | 296 | $inc_wp_version = str_replace("ME", "", $wp_version); | 
|---|
|  | 297 | return version_compare($inc_wp_version, $comp_version, $operator); | 
|---|
|  | 298 | } | 
|---|
|  | 299 | } | 
|---|
|  | 300 |  | 
|---|
| [35] | 301 | ?> | 
|---|