XPressME Integration Kit

Trac


Ignore:
Timestamp:
Oct 7, 2011, 8:59:37 AM (13 years ago)
Author:
toemon
Message:

マルチサイト用、最近の投稿(全ブログ)ブロックのオプションに「対象ブログの除外」、「ブログ毎に抽出」を追加、ブロックオプションのデフォルトテンプレートの誤りを修正

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Ver2.4/xpressme_integration_kit/blocks/block_common.php

    r583 r792  
    9191} 
    9292endif; 
     93if(!function_exists("blog_select")): 
     94function 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) . '_'; 
     99        $xoopsDB =& Database::getInstance(); 
     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        } 
     114 
     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 .= '&nbsp;&nbsp;<select name="blogs" id="blog_sel" '.$size.' multiple="multiple" onclick="BlogSelect()">' ."\n"; 
     160    $output .= $option; 
     161    $output .= '</select>'; 
     162    $output .=  '&emsp;' .  _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} 
     181endif; 
    93182 
    94183if(!function_exists("comment_type_select")): 
Note: See TracChangeset for help on using the changeset viewer.