[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 | { |
---|
[749] | 23 | global $xoopsDB; |
---|
[435] | 24 | $mydirpath = dirname(dirname(__FILE__)); |
---|
| 25 | $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ; |
---|
[583] | 26 | $wp_prefix = preg_replace('/wordpress/','wp',$mydirname) . '_'; |
---|
[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; |
---|
| 93 | |
---|
[436] | 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\" "; |
---|
[484] | 101 | if ($isAll) $option .= " selected=\"selected\""; |
---|
[436] | 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"; |
---|
[513] | 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"; |
---|
[436] | 122 | $output .= $option; |
---|
| 123 | $output .= '</select><br />'; |
---|
| 124 | $output .= ' |
---|
| 125 | <script type="text/javascript"> |
---|
| 126 | function ComTypeSelect(){ |
---|
| 127 | var idx=new Array(); |
---|
[513] | 128 | var sel=document.getElementById("com_type").options; |
---|
[436] | 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){ |
---|
[513] | 133 | document.getElementById("com_hidden").value = idx; |
---|
[436] | 134 | } |
---|
| 135 | } |
---|
| 136 | </script> |
---|
| 137 | '; |
---|
| 138 | |
---|
| 139 | return $output; |
---|
| 140 | |
---|
| 141 | } |
---|
| 142 | endif; |
---|
| 143 | |
---|
[484] | 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 | } |
---|
[436] | 155 | |
---|
[484] | 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"; |
---|
[513] | 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"; |
---|
[484] | 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>'; |
---|
[513] | 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 />'; |
---|
[484] | 178 | $output .= ' |
---|
| 179 | <script type="text/javascript"> |
---|
| 180 | function Template_Make(){ |
---|
[513] | 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"); |
---|
[484] | 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; |
---|
[495] | 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; |
---|
[484] | 204 | |
---|
[35] | 205 | ?> |
---|