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