XPressME Integration Kit

Trac

source: trunk/blocks/block_common.php @ 35

Last change on this file since 35 was 35, checked in by toemon, 15 years ago

ブロックのテストの為にXOOPSの基本構成でコメントブロックを作成
現状ではブロック側がモジュール複製には対応していない。

File size: 2.2 KB
Line 
1<?php
2
3if( ! function_exists( 'yes_no_radio_option' ) ) :
4function 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}
18endif;
19
20if(!function_exists("dropdown_cats_options")):
21function dropdown_cats_options($sort_column = 'ID', $sort_order = 'asc', $selected=array())
22{
23    global $wpdb, $wp_query, $wp_rewrite, $wp_roles;
24
25        $path = dirname(dirname(__FILE__)) . '/';
26        if (file_exists($path . 'wp-load.php')) {
27                require_once $path . 'wp-load.php';
28        } else {
29                require_once $path . 'wp-config.php';
30        }
31
32        $myts =& MyTextSanitizer::getInstance();
33    $selected = is_array($selected)?$selected:array($selected);
34    $sort_column = 'cat_'.$sort_column;
35        if ($wp_db_version < 6124) {
36                $query = "
37                SELECT cat_ID, cat_name, category_nicename,category_parent
38                FROM $wpdb->categories
39                WHERE cat_ID > 0
40                ";
41        $query .= " ORDER BY $sort_column $sort_order";
42
43    } else {
44        $query = "
45                        SELECT $wpdb->terms.term_id as cat_ID , $wpdb->terms.name as cat_name , $wpdb->term_taxonomy.taxonomy
46                        FROM $wpdb->terms LEFT JOIN $wpdb->term_taxonomy ON $wpdb->terms.term_id = $wpdb->term_taxonomy.term_id
47                        WHERE $wpdb->term_taxonomy.taxonomy = 'category'
48        ";
49                $query .= " ORDER BY $sort_column $sort_order";
50    }
51
52    $categories = $wpdb->get_results($query);
53    if ($categories) {
54        foreach ($categories as $category) {
55            $cat_name = apply_filters('list_cats', $category->cat_name, $category);
56            echo "\t<option value=\"".$category->cat_ID."\"";
57            if (in_array($category->cat_ID, $selected))
58                echo ' selected="selected"';
59            echo '>';
60            echo $myts->htmlspecialchars($cat_name);
61            echo "</option>\n";
62        }
63    }
64    return;
65}
66endif;
67
68
69
70?>
Note: See TracBrowser for help on using the repository browser.