XPressME Integration Kit

Trac

Changeset 435


Ignore:
Timestamp:
Nov 13, 2009, 6:38:28 PM (14 years ago)
Author:
toemon
Message:

ブロックオプション、カテゴリのマルチセレクトをカンマ区切りデータとして格納するようにした。 #243

Location:
trunk/xpressme_integration_kit
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/xpressme_integration_kit/blocks/block_common.php

    r63 r435  
    6969endif; 
    7070 
     71if(!function_exists("categorie_select")): 
     72function categorie_select($option_name = '',$value='',$row_num=0 ,$sort_column = 'ID', $sort_order = 'asc') 
     73{ 
     74    $mydirpath = dirname(dirname(__FILE__)); 
     75        $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ; 
     76        if ($mydirname == 'wordpress'){ 
     77                $wp_prefix = 'wp_'; 
     78        } else { 
     79                $wp_prefix = $mydirname . '_'; 
     80        } 
     81        $xoopsDB =& Database::getInstance(); 
     82        $myts =& MyTextSanitizer::getInstance(); 
     83    $selected = explode(',' , $value); 
     84        $isAll = (count($selected)==0||empty($selected[0]))?true:false; 
     85    $sort_column = 'cat_'.$sort_column; 
     86    if (empty($row_num)) $size = ''; else $size = 'size="' . $row_num . '"'; 
     87        include $mydirpath.'/wp-includes/version.php'; 
     88        if ($wp_db_version < 6124) { 
     89                $db_xpress_categories = $xoopsDB->prefix($wp_prefix . 'categories'); 
     90                $query = " 
     91                SELECT cat_ID, cat_name, category_nicename,category_parent  
     92                FROM $db_xpress_categories  
     93                WHERE cat_ID > 0  
     94                "; 
     95                $query .= " ORDER BY $sort_column $sort_order"; 
    7196 
     97    } else { 
     98        $db_xpress_terms = $xoopsDB->prefix($wp_prefix . 'terms'); 
     99        $db_xpress_term_taxonomy = $xoopsDB->prefix($wp_prefix . 'term_taxonomy'); 
     100        $query = " 
     101                        SELECT $db_xpress_terms.term_id as cat_ID , $db_xpress_terms.name as cat_name , $db_xpress_term_taxonomy.taxonomy  
     102                        FROM $db_xpress_terms LEFT JOIN $db_xpress_term_taxonomy ON $db_xpress_terms.term_id = $db_xpress_term_taxonomy.term_id  
     103                        WHERE $db_xpress_term_taxonomy.taxonomy = 'category'  
     104        "; 
     105                $query .= " ORDER BY $sort_column $sort_order"; 
     106    } 
     107        $res =  $xoopsDB->query($query, 0, 0); 
     108        $option = "\t<option value=\"0\" "; 
     109        if ($isAll) $option .= " selected=\"selected\""; 
     110        $option .= ">"._MB_XP2_ALL ."</option>\n"; 
     111 
     112    if ($res !== false){ 
     113                while($row = $xoopsDB->fetchArray($res)){ 
     114            $cat_name = $row['cat_name']; 
     115            $cat_ID = $row['cat_ID']; 
     116            $option .= "\t<option value=\"".$cat_ID."\""; 
     117            if (in_array($cat_ID, $selected)) 
     118                $option .= ' selected="selected"'; 
     119            $option .= '>'; 
     120            $option .= $myts->htmlspecialchars($cat_name); 
     121            $option .= "</option>\n"; 
     122        } 
     123    } 
     124    $output = _MB_XP2_CATS_SELECT ."<br />\n"; 
     125    $output .=  "<input type='hidden' name='$option_name' value='$value' />\n"; 
     126    $output .= '&nbsp;&nbsp;<select name="categorie" '.$size.' multiple="multiple" onclick="CatSelect()">' ."\n"; 
     127    $output .= $option; 
     128    $output .= '</select><br />'; 
     129    $output .= ' 
     130<script type="text/javascript"> 
     131    function CatSelect(){ 
     132        var idx=new Array(); 
     133        var sel=document.forms["blockform"].elements["categorie"].options; 
     134        for(var i=0, n=0; i<sel.length; i++){ 
     135            if(sel[i].selected){ idx[n++]=sel[i].value; } 
     136        } 
     137        if(idx.length>0){ 
     138                document.forms["blockform"].elements["' .$option_name . '"].value = idx; 
     139                } 
     140    } 
     141</script> 
     142'; 
     143     
     144    return $output; 
     145 
     146} 
     147endif; 
    72148 
    73149?> 
  • trunk/xpressme_integration_kit/blocks/popular_posts_block.php

    r365 r435  
    2323                $time_format = empty( $options[5] ) ? '' : $options[5] ; 
    2424                $tag_select = $options[6] ; 
    25                 $selected = array_slice($options, 7); // get allowed cats 
     25                $cat_select = empty( $options[7] ) ? '0' : $options[7] ; 
    2626 
    2727                $mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname; 
     
    4444                } 
    4545 
    46             $form .= _MB_XP2_CATS_SELECT ."<br />\n"; 
    47             $isAll = (count($selected)==0||empty($selected[0]))?true:false; 
    48             $form .= "&nbsp;&nbsp;<select name=\"options[]\" multiple=\"multiple\">"; 
    49             $form .= "<option value=\"0\" "; 
    50             if ($isAll) $form .= " selected=\"selected\""; 
    51             $form .= ">"._MB_XP2_ALL ."</option>"; 
    52                 ob_start(); 
    53                 dropdown_cats_options('ID','asc',$selected); 
    54                 $list_str = ob_get_contents(); 
    55                 ob_end_clean(); 
    56             $form .= $list_str. "</select><br />"; 
    57 //          $form .="<br /><input type='text' size='60' name='options[5]' value='".htmlspecialchars($this_template,ENT_QUOTES)."' />"; 
    58  
     46                $form .= categorie_select('options[7]' , $cat_select); 
    5947                return $form; 
    6048        } 
  • trunk/xpressme_integration_kit/blocks/recent_posts_content_block.php

    r429 r435  
    1919                $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ; 
    2020                $this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_recent_posts_content_block.html' : trim( $options[1] ); 
    21                 $day_select = ($options[2])?intval($options[2]):0; 
    22                 $day_size = ($options[3])?intval($options[3]):0; 
    23                 $disp_count =  ($options[4])?intval($options[4]):10; 
    24                 $excerpt = empty( $options[5] ) ? false : true ; 
    25                 $excerpt_size =  ($options[6])?intval($options[6]):100; 
    26                 $date_format = empty( $options[7] ) ? '' : $options[7] ; 
    27                 $time_format = empty( $options[8] ) ? '' : $options[8] ; 
    28                 $tag_select = $options[9] ; 
    29             $selected = array_slice($options,10); // get allowed cats 
     21                $disp_count =  ($options[2])?intval($options[2]):10; 
     22                $excerpt = empty( $options[3] ) ? false : true ; 
     23                $excerpt_size =  ($options[4])?intval($options[4]):100; 
     24                $date_format = empty( $options[5] ) ? '' : $options[5] ; 
     25                $time_format = empty( $options[6] ) ? '' : $options[6] ; 
     26                $tag_select = $options[7] ; 
     27                $cat_select = empty( $options[8] ) ? '0' : $options[8] ; 
     28                $day_select = ($options[9])?intval($options[9]):0; 
     29                $day_size = ($options[10])?intval($options[10]):0; 
    3030 
    3131                $mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname; 
     
    3535                $form  = "MyDirectory <input type='text' name='options[0]' value='" . $mydirname . "' /><br />\n"; 
    3636            $form .= "<input type='hidden' name='options[1]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' /><br />"; 
    37                 $form .= "<br />"; 
    38                 $form .= _MB_XP2_DAY_SELECT . ':' . _MB_XP2_DAY_BETWEEN . '<select name="options[2]">'; 
     37                $form .= _MB_XP2_COUNT .": <input type='text' name='options[2]' value='" . $disp_count . "' /><br />\n"; 
     38                $form .= yes_no_radio_option('options[3]', _MB_XP2_P_EXCERPT , $excerpt) . "<br />\n"; 
     39                $form .= _MB_XP2_P_EXCERPT_SIZE .": <input type='text' name='options[4]' value='" . $excerpt_size . "' /><br />\n"; 
     40                $form .= _MB_XP2_DATE_FORMAT .": <input type='text' name='options[5]' value='" . $date_format . "' /><br />\n"; 
     41                $form .= _MB_XP2_TIME_FORMAT .": <input type='text' name='options[6]' value='" . $time_format . "' /><br />\n"; 
     42                 
     43                include $mydirpath .'/wp-includes/version.php' ; 
     44                if (wp_version_compare($wp_version, '>=','2.3')){ 
     45                        $form .= "<br />\n"; 
     46                        $form .= _MB_XP2_TAGS_SELECT .": <input type='text' name='options[7]' value='" . $tag_select . "' /><br />\n"; 
     47                } else { 
     48                        $form .= "<input type='hidden' name='options[7]' value='' /><br />\n"; 
     49                } 
     50                 
     51            $form .= categorie_select('options[8]' , $cat_select); 
     52             
     53            $form .= "<br />"; 
     54                $form .= _MB_XP2_DAY_SELECT . ':' . _MB_XP2_DAY_BETWEEN . '<select name="options[9]">'; 
    3955                switch ($day_select){ 
    4056                case 1: 
     
    5571                $form .= '</select>'; 
    5672                 
    57                 $form .= ' ' . _MB_XP2_DAYS_AND . " <input type='text' size='2' name='options[3]' value='" . $day_size . "' />" . _MB_XP2_DAYS_AGO . "<br />\n"; 
    58  
    59                 $form .= _MB_XP2_COUNT .": <input type='text' name='options[4]' value='" . $disp_count . "' /><br />\n"; 
    60                 $form .= yes_no_radio_option('options[5]', _MB_XP2_P_EXCERPT , $excerpt) . "<br />\n"; 
    61                 $form .= _MB_XP2_P_EXCERPT_SIZE .": <input type='text' name='options[6]' value='" . $excerpt_size . "' /><br />\n"; 
    62                 $form .= _MB_XP2_DATE_FORMAT .": <input type='text' name='options[7]' value='" . $date_format . "' /><br />\n"; 
    63                 $form .= _MB_XP2_TIME_FORMAT .": <input type='text' name='options[8]' value='" . $time_format . "' /><br />\n"; 
    64                  
    65                 include $mydirpath .'/wp-includes/version.php' ; 
    66                 if (wp_version_compare($wp_version, '>=','2.3')){ 
    67                         $form .= "<br />\n"; 
    68                         $form .= _MB_XP2_TAGS_SELECT .": <input type='text' name='options[9]' value='" . $tag_select . "' /><br />\n"; 
    69                 } else { 
    70                         $form .= "<input type='hidden' name='options[9]' value='' /><br />\n"; 
    71                 } 
    72                  
    73             $form .= _MB_XP2_CATS_SELECT ."<br />\n"; 
    74             $isAll = (count($selected)==0||empty($selected[0]))?true:false; 
    75             $form .= "&nbsp;&nbsp;<select name=\"options[]\" multiple=\"multiple\">\n"; 
    76             $form .= "\t<option value=\"0\" "; 
    77             if ($isAll) $form .= " selected=\"selected\""; 
    78             $form .= ">"._MB_XP2_ALL ."</option>\n"; 
    79                 ob_start(); 
    80                 dropdown_cats_options('ID','asc',$selected); 
    81                 $list_str = ob_get_contents(); 
    82                 ob_end_clean(); 
    83             $form .= $list_str. "</select><br />\n"; 
    84              
    85 //          $form .="<br /><input type='text' size='60' name='options[11]' id='this_template' value='".htmlspecialchars($this_template,ENT_QUOTES)."' />"; 
     73                $form .= ' ' . _MB_XP2_DAYS_AND . " <input type='text' size='2' name='options[10]' value='" . $day_size . "' />" . _MB_XP2_DAYS_AGO . "<br />\n"; 
    8674 
    8775                return $form; 
  • trunk/xpressme_integration_kit/blocks/recent_posts_list_block.php

    r365 r435  
    2424                $time_format = empty( $options[6] ) ? '' : $options[6] ; 
    2525                $tag_select = $options[7] ; 
    26                 $selected = array_slice($options,8); // get allowed cats 
     26                $cat_select = empty( $options[8] ) ? '0' : $options[8] ; 
    2727 
    2828                $mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname; 
     
    4747                } 
    4848 
    49             $form .= _MB_XP2_CATS_SELECT ."<br />\n"; 
    50             $isAll = (count($selected)==0||empty($selected[0]))?true:false; 
    51             $form .= "&nbsp;&nbsp;<select name=\"options[]\" multiple=\"multiple\">\n"; 
    52             $form .= "\t<option value=\"0\" "; 
    53             if ($isAll) $form .= " selected=\"selected\""; 
    54             $form .= ">"._MB_XP2_ALL ."</option>\n"; 
    55                 ob_start(); 
    56                 dropdown_cats_options('ID','asc',$selected); 
    57                 $list_str = ob_get_contents(); 
    58                 ob_end_clean(); 
    59             $form .= $list_str. "</select><br />\n"; 
    60              
    61 //          $form .="<br /><input type='text' size='60' name='options[5]' value='".htmlspecialchars($this_template,ENT_QUOTES)."' />"; 
     49            $form .= categorie_select('options[8]' , $cat_select); 
    6250 
    6351                return $form; 
  • trunk/xpressme_integration_kit/wp-content/themes/xpress_default/blocks/popular_posts_block_theme.php

    r418 r435  
    99        $time_format = empty( $options[5] ) ? '' : $options[5] ; 
    1010        $tag_select = $options[6] ; 
    11         $selected = array_slice($options, 7); // get allowed cats 
     11        $cat_select = empty( $options[7] ) ? '0' : $options[7] ; 
     12         
     13        $selected = explode(',' , $cat_select); 
    1214 
    1315        $mydirpath = get_xpress_dir_path(); 
     
    1517        if (empty($date_format)) $date_format = get_settings('date_format'); 
    1618        if (empty($time_format)) $time_format = get_settings('time_format'); 
    17         if (array_search(0,$selected)===0) { 
    18                 $cat_select = false; 
    19         }else { 
    20                 $cat_select = true;                      
    21         } 
    22         $cat_id = implode(',',$selected); 
     19        if (array_search(0,$selected)===0) $cat_select = 0; 
     20         
     21        $cat_select; 
    2322        $block = array(); 
    2423        $item_no = 0;    
     
    5857 
    5958                if ($cat_select) { 
    60                         $where .= " AND ($term_taxonomy.term_id IN ($cat_id))"; 
     59                        $where .= " AND ($term_taxonomy.term_id IN ($cat_select))"; 
    6160                } 
    6261                 
     
    7574                 
    7675                if ($cat_select) { 
    77                         $where .= " AND ($post2cat_tb.category_id IN ($cat_id))"; 
     76                        $where .= " AND ($post2cat_tb.category_id IN ($cat_select))"; 
    7877                } 
    7978        } 
  • trunk/xpressme_integration_kit/wp-content/themes/xpress_default/blocks/recent_posts_content_block_theme.php

    r429 r435  
    66        $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ; 
    77        $this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_recent_posts_content_block.html' : trim( $options[1] ); 
    8         $day_select = ($options[2])?intval($options[2]):0; 
    9         $day_size = ($options[3])?intval($options[3]):0; 
    10         $disp_count =  ($options[4])?intval($options[4]):10; 
    11         $excerpt = empty( $options[5] ) ? false : true ; 
    12         $excerpt_size =  ($options[6])?intval($options[6]):100; 
    13         $date_format = empty( $options[7] ) ? '' : $options[7] ; 
    14         $time_format = empty( $options[8] ) ? '' : $options[8] ; 
    15         $tag_select = $options[9] ; 
    16     $selected = array_slice($options,10); // get allowed cats 
    17  
     8        $disp_count =  ($options[2])?intval($options[2]):10; 
     9        $excerpt = empty( $options[3] ) ? false : true ; 
     10        $excerpt_size =  ($options[4])?intval($options[4]):100; 
     11        $date_format = empty( $options[5] ) ? '' : $options[5] ; 
     12        $time_format = empty( $options[6] ) ? '' : $options[6] ; 
     13        $tag_select = $options[7] ; 
     14        $cat_select = empty( $options[8] ) ? '0' : $options[8] ; 
     15        $day_select = ($options[9])?intval($options[9]):0; 
     16        $day_size = ($options[10])?intval($options[10]):0; 
     17 
     18        $selected = explode(',' , $cat_select); 
     19         
    1820        $mydirpath = get_xpress_dir_path(); 
    1921         
     
    2123        if (empty($time_format)) $time_format = get_settings('time_format'); 
    2224        if(empty($tag_select)) $tag_where = ''; else $tag_where = "tag='$tag_select'&"; 
    23          
     25        if (array_search(0,$selected)===0) $cat_select = 0; 
     26 
    2427        $selected_author_id = xpress_selected_author_id('echo=0');       
    2528        if (!empty($selected_author_id)){ 
     
    3740        if (!is_null($wpdb)){ 
    3841                $wp_query->in_the_loop = true;          //for use the_tags() in multi lopp  
    39                 if (array_search(0,$selected)===0) { 
     42                if ($cat_select) { 
     43                        $r = new WP_Query($author_where . $tag_where ."cat=$cat_select&showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish"); 
     44                } else { 
    4045                        $r = new WP_Query($author_where . $tag_where ."showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish"); 
    41                 } else { 
    42                         $cat_id = implode(',',$selected); 
    43                         $r = new WP_Query($author_where . $tag_where ."cat=$cat_id&showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish"); 
    4446                } 
    4547                while($r->have_posts()){                         
  • trunk/xpressme_integration_kit/wp-content/themes/xpress_default/blocks/recent_posts_list_block_theme.php

    r272 r435  
    1010        $time_format = empty( $options[6] ) ? '' : $options[6] ; 
    1111        $tag_select = $options[7] ; 
    12         $selected = array_slice($options,8); // get allowed cats 
     12        $cat_select = empty( $options[8] ) ? '0' : $options[8] ; 
     13         
     14        $selected = explode(',' , $cat_select); 
    1315 
    1416        $mydirpath = get_xpress_dir_path(); 
     
    1719        if (empty($time_format)) $time_format = get_settings('time_format'); 
    1820        if(empty($tag_select)) $tag_where = ''; else $tag_where = "tag='$tag_select'&"; 
     21        if (array_search(0,$selected)===0) $cat_select = 0; 
    1922 
    2023        $selected_author_id = xpress_selected_author_id('echo=0');       
     
    3033        if (!is_null($wpdb)){ 
    3134                $wp_query->in_the_loop = true;          //for use the_tags() in multi lopp  
    32                 if (array_search(0,$selected)===0) { 
     35                if ($cat_select) { 
     36                        $r = new WP_Query($author_where . $tag_where . "cat=$cat_select&showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish"); 
     37                } else { 
    3338                        $r = new WP_Query($author_where . $tag_where ."showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish"); 
    34  
    35                 } else { 
    36                         $cat_id = implode(',',$selected); 
    37                         $r = new WP_Query($author_where . $tag_where . "cat=$cat_id&showposts=$disp_count&what_to_show=posts&nopaging=0&post_status=publish"); 
    3839                } 
    3940                while($r->have_posts()){                         
  • trunk/xpressme_integration_kit/xoops_version.php

    r425 r435  
    144144        'edit_func'     => "b_". $mydirname . "_content_edit" , 
    145145        'template'              => '' , 
    146         'options'               => $mydirname. '||0|0|10|0|100||||0' , 
     146        'options'               => $mydirname. '||10|0|100||||0|0|0' , 
    147147        'can_clone'             => true , 
    148148        'func_num'              => $b_no, 
Note: See TracChangeset for help on using the changeset viewer.