XPressME Integration Kit

Trac

Changeset 38


Ignore:
Timestamp:
Dec 22, 2008, 9:55:10 PM (15 years ago)
Author:
toemon
Message:

ブロックのスタイルシートはテンプレート変数<{$xoops_block_header}>にアサインします。
使い方としては、xoopsテーマの<{$xoops_module_header}>の直後に<{$xoops_block_header}>を書き加えます。
上記実装 #44

ブロックのレンダリングを行う部分と、ブロック用CSSの場所をWordPressテーマ内にblocksというフォルダーを作成してその中に置く。 #46

Location:
trunk
Files:
4 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/blocks/xpress_block_recent_comments.php

    r36 r38  
    6060        { 
    6161                $mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ; 
    62                 $disp_count = empty( $options[1] ) ? '10' : $options[1] ; 
    63                 $disp_length = empty( $options[2] ) ? '30' : $options[2] ; 
    64                 $selected = array_slice($options,5); // get allowed cats 
    65                 $this_template = empty( $options[6] ) ? 'db:'.$mydirname.'_block_comments.html' : trim( $options[4] ); 
    6662                $mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname; 
     63 
     64                global $wpdb; 
    6765                 
    68                 $myts =& MyTextSanitizer::getInstance(); 
    69  
    70                 $this_url = '/modules/'. $mydirname; 
    71                 $call_url = $_SERVER['REQUEST_URI']; 
    72                  
    73                 $disp_all = in_array('0',$selected); 
    74                 $disp_comment = in_array('1',$selected); 
    75                 $disp_trackback = in_array('2',$selected); 
    76                 $disp_pingback = in_array('3',$selected); 
    77                  
    78                 $type_select = ''; 
    79                 if (!$disp_all){                         
    80                         if ($disp_comment){ 
    81                                 $in_where =  "''"; 
    82                         } 
    83                         if ($disp_trackback){ 
    84                                 if (empty($in_where)) $in_where =  "'trackback' "; else $in_where .=  ",'trackback'"; 
    85                         } 
    86                                          
    87                         if ($disp_pingback){ 
    88                                 if (empty($in_where)) $in_where =  "'pingback' "; else $in_where .=  ",'pingback'"; 
    89                         } 
     66                if (!is_null($wpdb)){ 
     67                        require_once $mydirpath.'/include/xpress_block_theme.php'; 
     68                        xpress_block_css_set($mydirname); 
    9069                         
    91                         if (! empty($in_where)){ 
    92                                 $type_select = " AND comment_type IN($in_where) ";                               
    93                         } 
     70                        $block_theme_file = get_block_file_path($mydirname,'recent_comments_block'); 
     71                        require_once $block_theme_file; 
     72                        $block = recent_comments_block($options); 
     73                         
     74                        require_once $mydirpath.'/include/xoops_block_cache.php'; 
     75                        xpress_block_cache_write($mydirname,'recent_comments_block',$block); 
     76                } else { 
     77                        require_once $mydirpath.'/include/xoops_block_cache.php'; 
     78                        $block = xpress_block_cache_read($mydirname,'recent_comments_block'); 
    9479                } 
    95                  
    96                 global $wpdb; 
    97                          
    98                 if (!is_null($wpdb)){ 
    99                         $comment_sql  = "SELECT comment_ID,comment_post_ID,comment_author,comment_author_email,comment_author_url,comment_content, comment_type,UNIX_TIMESTAMP(comment_date) as comment_unix_time "; 
    100                         $comment_sql .= "FROM $wpdb->comments LEFT JOIN $wpdb->posts ON  $wpdb->posts.ID = $wpdb->comments.comment_post_ID "; 
    101                         $comment_sql .= "WHERE comment_approved = '1' AND post_type = 'post'  AND post_status = 'publish' $type_select "; 
    102                         $comment_sql .= "ORDER BY comment_date_gmt DESC LIMIT $disp_count"; 
    103  
    104                         $comments = $wpdb->get_results($comment_sql); 
    105                         $format = get_settings('date_format') . ' ' . get_settings('time_format');                               
    106  
    107                         if ( $comments ) { 
    108                                 $output .= '<ul>'; 
    109                                 $item_no = 0; 
    110                                 foreach ($comments as $comment){ 
    111                                         $comment_content = $comment->comment_content; 
    112                                         $comment_excerpt = ($disp_length>0 ? xoops_substr($comment_content, 0, $disp_length): $comment->comment_content); 
    113  
    114                                         $comment_link = get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID ; 
    115                                         $comment_title = $comment_excerpt; 
    116                                         $comment_title_link = "<a href='$comment_link' rel='external nofollow' class='url'>$comment_title</a>"; 
    117  
    118                                         $post_link = get_comment_link($comment->comment_ID); 
    119                                         $post_title = get_the_title($comment->comment_post_ID); 
    120                                         $post_title_link = '<a href="'. $post_link . '">' . $post_title . '</a>'; 
    121                                          
    122                                         $author_link = $comment->comment_author_url; 
    123                                         $author_name = $comment->comment_author; 
    124                                         $author_name_link = (( empty( $author_link ) || 'http://' == $author_link ) ? $author_name : "<a href='$author_link' rel='external nofollow' class='url'>$author_name</a>"); 
    125  
    126                                         $comment_type = (empty($comment->comment_type) ? 'comment': $comment->comment_type); 
    127                                         $from_auther_to_post = sprintf(__('%1$s on %2$s'), $author_name_link , $post_title_link ); 
    128  
    129                                         $row_data = array( 
    130                                                 'comment_ID'            => $comment->comment_ID , 
    131                                                 'comment_post_ID'       => $comment->comment_post_ID , 
    132                                                 'comment_date'          => date(get_settings('date_format'),$comment->comment_unix_time) , 
    133                                                 'comment_date_time' => date(get_settings('date_format') . ' ' . get_settings('time_format'),$comment->comment_unix_time) , 
    134                                                 'comment_content'       => $comment_content , 
    135                                                 'comment_excerpt'       => $comment_excerpt ,    
    136                                                 'comment_link'          => $comment_link, 
    137                                                 'comment_title'         => $comment_title , 
    138                                                 'comment_title_link' => $comment_title_link , 
    139                                                 'post_link'             => $post_link, 
    140                                                 'post_title'            => $post_title, 
    141                                                 'post_title_link'       => $post_title_link, 
    142                                                 'author_link'           => $author_link, 
    143                                                 'author_name'           => $author_name, 
    144                                                 'author_name_link'      => $author_name_link,            
    145                                                 'comment_type'          => $comment_type,                                                                                                                                                                                                                                                                                
    146                                                 'from_auther_to_post' => $from_auther_to_post 
    147                                         ); 
    148                                          
    149                                         $block['contents']['item'.$item_no] = $row_data; 
    150                                         $item_no++; 
    151                                 } 
    152                         } 
    153                         require_once dirname(dirname( __FILE__ )).'/include/xoops_block_cache.php'; 
    154                         xpress_block_cache_write($mydirname,'recent_comment_block',$block); 
    155                 } else { 
    156                         require_once dirname(dirname( __FILE__ )).'/include/xoops_block_cache.php'; 
    157                         $block = xpress_block_cache_read($mydirname,'recent_comment_block'); 
    158                 } 
    159                 return $block ; 
     80                return  $block; 
    16081        } 
    16182} 
  • trunk/templates/blocks/xpress_block_recent_comments.html

    r36 r38  
    11<ul class="xpress_recent_comments"> 
     2        <!-- The template tag of the following list can be used.  
     3                        <{$content.from_auther_to_post}> 
     4                        <{$content.comment_ID}> 
     5                        <{$content.comment_post_ID}> 
     6                        <{$content.comment_date}> 
     7                        <{$content.comment_date_time}> 
     8                        <{$content.comment_content}> 
     9                        <{$content.comment_excerpt}> 
     10                        <{$content.comment_link}> 
     11                        <{$content.comment_title}> 
     12                        <{$content.comment_title_link}> 
     13                        <{$content.post_link}> 
     14                        <{$content.post_title}> 
     15                        <{$content.post_title_link}> 
     16                        <{$content.author_link}> 
     17                        <{$content.author_name}> 
     18                        <{$content.author_name_link}> 
     19                        <{$content.comment_type}> 
     20        --> 
     21 
    222        <{foreach from=$block.contents item=content}> 
    323                <li> 
    4                                 <{$content.from_auther_to_post}><br /> 
    5                                 <{$content.comment_ID}><br /> 
    6                                 <{$content.comment_post_ID}><br /> 
    7                                 <{$content.comment_date}><br /> 
    8                                 <{$content.comment_date_time}><br /> 
    9                                 <{$content.comment_content}><br /> 
    10                                 <{$content.comment_excerpt}><br /> 
    11                                 <{$content.comment_link}><br /> 
    12                                 <{$content.comment_title}><br /> 
    13                                 <{$content.comment_title_link}><br /> 
    14                                 <{$content.post_link}><br /> 
    15                                 <{$content.post_title}><br /> 
    16                                 <{$content.post_title_link}><br /> 
    17                                 <{$content.author_link}><br /> 
    18                                 <{$content.author_name}><br /> 
    19                                 <{$content.author_name_link}><br /> 
    20                                 <{$content.comment_type}><br /><br /> 
     24                        <{$content.from_auther_to_post}><br /> 
     25                        <{$content.comment_excerpt}><br /> 
     26                        <{$content.comment_date_time}><br /> 
    2127                </li> 
    2228        <{/foreach}> 
Note: See TracChangeset for help on using the changeset viewer.