XPressME Integration Kit

Trac

Changeset 198


Ignore:
Timestamp:
Apr 30, 2009, 11:00:43 PM (15 years ago)
Author:
toemon
Message:

#117 カスタムテンプレートタグget_xpress_calender()の追加
recent_posts_content_block_theme.phpインデント修正

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/plugins/xpressme/include/custom_functions.php

    r193 r198  
    573573                        return false; 
    574574} 
     575 
     576function get_xpress_calendar($sun_color = '#DB0000' ,$sat_color = '#004D99' ,$initial = true) { 
     577        global $wpdb, $m, $monthnum, $year, $wp_locale, $posts; 
     578 
     579 
     580 
     581        ob_start(); 
     582        // Quick check. If we have no posts at all, abort! 
     583        if ( !$posts ) { 
     584                $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1"); 
     585                if ( !$gotsome ) 
     586                        return; 
     587        } 
     588 
     589        if ( isset($_GET['w']) ) 
     590                $w = ''.intval($_GET['w']); 
     591 
     592        // week_begins = 0 stands for Sunday 
     593        $week_begins = intval(get_option('start_of_week')); 
     594 
     595        // Let's figure out when we are 
     596        if ( !empty($monthnum) && !empty($year) ) { 
     597                $thismonth = ''.zeroise(intval($monthnum), 2); 
     598                $thisyear = ''.intval($year); 
     599        } elseif ( !empty($w) ) { 
     600                // We need to get the month from MySQL 
     601                $thisyear = ''.intval(substr($m, 0, 4)); 
     602                $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's 
     603                $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')"); 
     604        } elseif ( !empty($m) ) { 
     605                $thisyear = ''.intval(substr($m, 0, 4)); 
     606                if ( strlen($m) < 6 ) 
     607                                $thismonth = '01'; 
     608                else 
     609                                $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2); 
     610        } else { 
     611                $thisyear = gmdate('Y', current_time('timestamp')); 
     612                $thismonth = gmdate('m', current_time('timestamp')); 
     613        } 
     614 
     615        $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear); 
     616 
     617        // Get the next and previous month and year with at least one post 
     618        $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year 
     619                FROM $wpdb->posts 
     620                WHERE post_date < '$thisyear-$thismonth-01' 
     621                AND post_type = 'post' AND post_status = 'publish' 
     622                        ORDER BY post_date DESC 
     623                        LIMIT 1"); 
     624        $next = $wpdb->get_row("SELECT  DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year 
     625                FROM $wpdb->posts 
     626                WHERE post_date >       '$thisyear-$thismonth-01' 
     627                AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' ) 
     628                AND post_type = 'post' AND post_status = 'publish' 
     629                        ORDER   BY post_date ASC 
     630                        LIMIT 1"); 
     631 
     632        echo '<table  summary="' . __('Calendar') . '"> 
     633        <caption>' . sprintf(_c('%1$s %2$s|Used as a calendar caption'), $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption> 
     634        <thead> 
     635        <tr>'; 
     636 
     637        $myweek = array(); 
     638 
     639        for ( $wdcount=0; $wdcount<=6; $wdcount++ ) { 
     640                $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7); 
     641        } 
     642 
     643        foreach ( $myweek as $wd ) { 
     644 
     645                for($week_num=0;$week_num<=6;$week_num++){ 
     646                        $week_name = $wp_locale->get_weekday($week_num); 
     647                        if ($week_name === $wd) break; 
     648                } 
     649                 
     650                $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); 
     651                if ($week_num ==0) $day_name = '<span style="color: ' . $sun_color . '">' . $day_name . '</span>'; 
     652                if ($week_num ==6) $day_name = '<span style="color: ' . $sat_color . '">' . $day_name . '</span>'; 
     653                echo "\n\t\t<th align=\"center\" abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>"; 
     654        } 
     655 
     656        echo ' 
     657        </tr> 
     658        </thead> 
     659 
     660        <tfoot> 
     661        <tr>'; 
     662 
     663        if ( $previous ) { 
     664                echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' . 
     665                get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), 
     666                        date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">&laquo; ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>'; 
     667        } else { 
     668                echo "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>'; 
     669        } 
     670 
     671        echo "\n\t\t".'<td class="pad">&nbsp;</td>'; 
     672 
     673        if ( $next ) { 
     674                echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' . 
     675                get_month_link($next->year, $next->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month), 
     676                        date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' &raquo;</a></td>'; 
     677        } else { 
     678                echo "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>'; 
     679        } 
     680 
     681        echo ' 
     682        </tr> 
     683        </tfoot> 
     684 
     685        <tbody> 
     686        <tr>'; 
     687 
     688        // Get days with posts 
     689        $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) 
     690                FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth' 
     691                AND YEAR(post_date) = '$thisyear' 
     692                AND post_type = 'post' AND post_status = 'publish' 
     693                AND post_date < '" . current_time('mysql') . '\'', ARRAY_N); 
     694        if ( $dayswithposts ) { 
     695                foreach ( (array) $dayswithposts as $daywith ) { 
     696                        $daywithpost[] = $daywith[0]; 
     697                } 
     698        } else { 
     699                $daywithpost = array(); 
     700        } 
     701 
     702        if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') !== false) 
     703                $ak_title_separator = "\n"; 
     704        else 
     705                $ak_title_separator = ', '; 
     706 
     707        $ak_titles_for_day = array(); 
     708        $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom " 
     709                ."FROM $wpdb->posts " 
     710                ."WHERE YEAR(post_date) = '$thisyear' " 
     711                ."AND MONTH(post_date) = '$thismonth' " 
     712                ."AND post_date < '".current_time('mysql')."' " 
     713                ."AND post_type = 'post' AND post_status = 'publish'" 
     714        ); 
     715        if ( $ak_post_titles ) { 
     716                foreach ( (array) $ak_post_titles as $ak_post_title ) { 
     717 
     718                                $post_title = apply_filters( "the_title", $ak_post_title->post_title ); 
     719                                $post_title = str_replace('"', '&quot;', wptexturize( $post_title )); 
     720 
     721                                if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) ) 
     722                                        $ak_titles_for_day['day_'.$ak_post_title->dom] = ''; 
     723                                if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one 
     724                                        $ak_titles_for_day["$ak_post_title->dom"] = $post_title; 
     725                                else 
     726                                        $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title; 
     727                } 
     728        } 
     729 
     730 
     731        // See how much we should pad in the beginning 
     732        $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins); 
     733        if ( 0 != $pad ) 
     734                echo "\n\t\t".'<td colspan="'.$pad.'" class="pad">&nbsp;</td>'; 
     735 
     736        $daysinmonth = intval(date('t', $unixmonth)); 
     737        for ( $day = 1; $day <= $daysinmonth; ++$day ) { 
     738                if ( isset($newrow) && $newrow ) 
     739                        echo "\n\t</tr>\n\t<tr>\n\t\t"; 
     740                $newrow = false; 
     741 
     742                if ( $day == gmdate('j', (time() + (get_option('gmt_offset') * 3600))) && $thismonth == gmdate('m', time()+(get_option('gmt_offset') * 3600)) && $thisyear == gmdate('Y', time()+(get_option('gmt_offset') * 3600)) ) 
     743                        echo '<td id="today" align="center">'; 
     744                else 
     745                        echo '<td align="center">'; 
     746 
     747                if ( in_array($day, $daywithpost) ) // any posts today? 
     748                                echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$day</a>"; 
     749                else 
     750                        echo $day; 
     751                echo '</td>'; 
     752 
     753                if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) ) 
     754                        $newrow = true; 
     755        } 
     756 
     757        $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins); 
     758        if ( $pad != 0 && $pad != 7 ) 
     759                echo "\n\t\t".'<td class="pad" colspan="'.$pad.'">&nbsp;</td>'; 
     760 
     761        echo "\n\t</tr>\n\t</tbody>\n\t</table>"; 
     762 
     763        $output = ob_get_contents(); 
     764        ob_end_clean(); 
     765//      echo $output; 
     766//      $cache[ $key ] = $output; 
     767//      wp_cache_set( 'get_calendar', $cache, 'calendar' ); 
     768        return $output; 
     769} 
    575770?> 
  • trunk/wp-content/themes/xpress_default/blocks/calender_block_theme.php

    r120 r198  
    1212        return $block ;  
    1313} 
    14  
    15 function get_xpress_calendar($sun_color = '#DB0000' ,$sat_color = '#004D99' ,$initial = true) { 
    16         global $wpdb, $m, $monthnum, $year, $wp_locale, $posts; 
    17  
    18  
    19  
    20         ob_start(); 
    21         // Quick check. If we have no posts at all, abort! 
    22         if ( !$posts ) { 
    23                 $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1"); 
    24                 if ( !$gotsome ) 
    25                         return; 
    26         } 
    27  
    28         if ( isset($_GET['w']) ) 
    29                 $w = ''.intval($_GET['w']); 
    30  
    31         // week_begins = 0 stands for Sunday 
    32         $week_begins = intval(get_option('start_of_week')); 
    33  
    34         // Let's figure out when we are 
    35         if ( !empty($monthnum) && !empty($year) ) { 
    36                 $thismonth = ''.zeroise(intval($monthnum), 2); 
    37                 $thisyear = ''.intval($year); 
    38         } elseif ( !empty($w) ) { 
    39                 // We need to get the month from MySQL 
    40                 $thisyear = ''.intval(substr($m, 0, 4)); 
    41                 $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's 
    42                 $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')"); 
    43         } elseif ( !empty($m) ) { 
    44                 $thisyear = ''.intval(substr($m, 0, 4)); 
    45                 if ( strlen($m) < 6 ) 
    46                                 $thismonth = '01'; 
    47                 else 
    48                                 $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2); 
    49         } else { 
    50                 $thisyear = gmdate('Y', current_time('timestamp')); 
    51                 $thismonth = gmdate('m', current_time('timestamp')); 
    52         } 
    53  
    54         $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear); 
    55  
    56         // Get the next and previous month and year with at least one post 
    57         $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year 
    58                 FROM $wpdb->posts 
    59                 WHERE post_date < '$thisyear-$thismonth-01' 
    60                 AND post_type = 'post' AND post_status = 'publish' 
    61                         ORDER BY post_date DESC 
    62                         LIMIT 1"); 
    63         $next = $wpdb->get_row("SELECT  DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year 
    64                 FROM $wpdb->posts 
    65                 WHERE post_date >       '$thisyear-$thismonth-01' 
    66                 AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' ) 
    67                 AND post_type = 'post' AND post_status = 'publish' 
    68                         ORDER   BY post_date ASC 
    69                         LIMIT 1"); 
    70  
    71         echo '<table  summary="' . __('Calendar') . '"> 
    72         <caption>' . sprintf(_c('%1$s %2$s|Used as a calendar caption'), $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption> 
    73         <thead> 
    74         <tr>'; 
    75  
    76         $myweek = array(); 
    77  
    78         for ( $wdcount=0; $wdcount<=6; $wdcount++ ) { 
    79                 $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7); 
    80         } 
    81  
    82         foreach ( $myweek as $wd ) { 
    83  
    84                 for($week_num=0;$week_num<=6;$week_num++){ 
    85                         $week_name = $wp_locale->get_weekday($week_num); 
    86                         if ($week_name === $wd) break; 
    87                 } 
    88                  
    89                 $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); 
    90                 if ($week_num ==0) $day_name = '<span style="color: ' . $sun_color . '">' . $day_name . '</span>'; 
    91                 if ($week_num ==6) $day_name = '<span style="color: ' . $sat_color . '">' . $day_name . '</span>'; 
    92                 echo "\n\t\t<th align=\"center\" abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>"; 
    93         } 
    94  
    95         echo ' 
    96         </tr> 
    97         </thead> 
    98  
    99         <tfoot> 
    100         <tr>'; 
    101  
    102         if ( $previous ) { 
    103                 echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' . 
    104                 get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), 
    105                         date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">&laquo; ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>'; 
    106         } else { 
    107                 echo "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>'; 
    108         } 
    109  
    110         echo "\n\t\t".'<td class="pad">&nbsp;</td>'; 
    111  
    112         if ( $next ) { 
    113                 echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' . 
    114                 get_month_link($next->year, $next->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month), 
    115                         date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' &raquo;</a></td>'; 
    116         } else { 
    117                 echo "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>'; 
    118         } 
    119  
    120         echo ' 
    121         </tr> 
    122         </tfoot> 
    123  
    124         <tbody> 
    125         <tr>'; 
    126  
    127         // Get days with posts 
    128         $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) 
    129                 FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth' 
    130                 AND YEAR(post_date) = '$thisyear' 
    131                 AND post_type = 'post' AND post_status = 'publish' 
    132                 AND post_date < '" . current_time('mysql') . '\'', ARRAY_N); 
    133         if ( $dayswithposts ) { 
    134                 foreach ( (array) $dayswithposts as $daywith ) { 
    135                         $daywithpost[] = $daywith[0]; 
    136                 } 
    137         } else { 
    138                 $daywithpost = array(); 
    139         } 
    140  
    141         if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') !== false) 
    142                 $ak_title_separator = "\n"; 
    143         else 
    144                 $ak_title_separator = ', '; 
    145  
    146         $ak_titles_for_day = array(); 
    147         $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom " 
    148                 ."FROM $wpdb->posts " 
    149                 ."WHERE YEAR(post_date) = '$thisyear' " 
    150                 ."AND MONTH(post_date) = '$thismonth' " 
    151                 ."AND post_date < '".current_time('mysql')."' " 
    152                 ."AND post_type = 'post' AND post_status = 'publish'" 
    153         ); 
    154         if ( $ak_post_titles ) { 
    155                 foreach ( (array) $ak_post_titles as $ak_post_title ) { 
    156  
    157                                 $post_title = apply_filters( "the_title", $ak_post_title->post_title ); 
    158                                 $post_title = str_replace('"', '&quot;', wptexturize( $post_title )); 
    159  
    160                                 if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) ) 
    161                                         $ak_titles_for_day['day_'.$ak_post_title->dom] = ''; 
    162                                 if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one 
    163                                         $ak_titles_for_day["$ak_post_title->dom"] = $post_title; 
    164                                 else 
    165                                         $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title; 
    166                 } 
    167         } 
    168  
    169  
    170         // See how much we should pad in the beginning 
    171         $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins); 
    172         if ( 0 != $pad ) 
    173                 echo "\n\t\t".'<td colspan="'.$pad.'" class="pad">&nbsp;</td>'; 
    174  
    175         $daysinmonth = intval(date('t', $unixmonth)); 
    176         for ( $day = 1; $day <= $daysinmonth; ++$day ) { 
    177                 if ( isset($newrow) && $newrow ) 
    178                         echo "\n\t</tr>\n\t<tr>\n\t\t"; 
    179                 $newrow = false; 
    180  
    181                 if ( $day == gmdate('j', (time() + (get_option('gmt_offset') * 3600))) && $thismonth == gmdate('m', time()+(get_option('gmt_offset') * 3600)) && $thisyear == gmdate('Y', time()+(get_option('gmt_offset') * 3600)) ) 
    182                         echo '<td id="today" align="center">'; 
    183                 else 
    184                         echo '<td align="center">'; 
    185  
    186                 if ( in_array($day, $daywithpost) ) // any posts today? 
    187                                 echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$day</a>"; 
    188                 else 
    189                         echo $day; 
    190                 echo '</td>'; 
    191  
    192                 if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) ) 
    193                         $newrow = true; 
    194         } 
    195  
    196         $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins); 
    197         if ( $pad != 0 && $pad != 7 ) 
    198                 echo "\n\t\t".'<td class="pad" colspan="'.$pad.'">&nbsp;</td>'; 
    199  
    200         echo "\n\t</tr>\n\t</tbody>\n\t</table>"; 
    201  
    202         $output = ob_get_contents(); 
    203         ob_end_clean(); 
    204 //      echo $output; 
    205 //      $cache[ $key ] = $output; 
    206 //      wp_cache_set( 'get_calendar', $cache, 'calendar' ); 
    207         return $output; 
    208 } 
    209  
    21014?> 
  • trunk/wp-content/themes/xpress_default/blocks/recent_posts_content_block_theme.php

    r197 r198  
    7474                        } else { 
    7575                                $post_content = get_the_content(__('more'),0,'',false);  
    76                                                 $post_content = apply_filters('the_content', $post_content); 
    77                 $post_content = str_replace(']]>', ']]&gt;', $post_content); 
    78  
     76                                $post_content = apply_filters('the_content', $post_content); 
     77                                $post_content = str_replace(']]>', ']]&gt;', $post_content); 
    7978                        } 
    8079 
  • trunk/xoops_version.php

    r197 r198  
    4040 
    4141// status 
    42 $modversion['codename'] = "Bata3(r197)"; 
     42$modversion['codename'] = "Bata3(r198)"; 
    4343 
    4444// onInstall, onUpdate, onUninstall 
Note: See TracChangeset for help on using the changeset viewer.