[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\" "; |
---|
| 105 | if ($isAll) $form .= " selected=\"selected\""; |
---|
| 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 | |
---|
| 148 | |
---|
[35] | 149 | ?> |
---|