Make WordPress Core

Changeset 510


Ignore:
Timestamp:
11/03/2003 05:22:01 PM (22 years ago)
Author:
saxmatt
Message:

New calendar code.

Location:
trunk
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/b2-include/b2template.functions.php

    r509 r510  
    229229}
    230230
    231 function get_calendar() {
    232     global $wpdb, $HTTP_GET_VARS, $m, $monthnum, $year, $timedifference, $month, $tableposts;
     231function get_calendar($daylength = 1) {
     232    global $wpdb, $HTTP_GET_VARS, $m, $monthnum, $year, $timedifference, $month, $weekday, $tableposts;
    233233// Quick check. If we have no posts at all, abort!
    234234if (!$posts) {
     
    269269                            FROM $tableposts
    270270                            WHERE post_date < '$thisyear-$thismonth-01'
     271                            AND post_status = 'publish'
    271272                            ORDER BY post_date DESC
    272273                            LIMIT 1");
    273274$next = $wpdb->get_row("SELECT  DISTINCT MONTH( post_date ) AS month, YEAR( post_date ) AS year
    274275                            FROM $tableposts
    275                             WHERE post_date >  '$thisyear-$thismonth-01' AND MONTH( post_date )  != MONTH( '$thisyear-$thismonth-01' )
     276                            WHERE post_date >  '$thisyear-$thismonth-01'
     277                            AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
     278                            AND post_status = 'publish'
    276279                            ORDER  BY post_date ASC
    277                             LIMIT 1 ");
     280                            LIMIT 1");
    278281
    279282echo '<table id="wp-calendar">
    280283    <caption>' . $month[zeroise($thismonth, 2)] . ' ' . date('Y', $unixmonth) . '</caption>
    281284<thead>
    282   <tr>
    283     <th abbr="Sunday" scope="col" title="Sunday">Sun</th>
    284     <th abbr="Monday" scope="col" title="Monday">Mon</th>
    285     <th abbr="Tuesday" scope="col" title="Tuesday">Tue</th>
    286     <th abbr="Wednesday" scope="col" title="Wednesday">Wed</th>
    287     <th abbr="Thursday" scope="col" title="Thursday">Thu</th>
    288     <th abbr="Friday" scope="col" title="Friday">Fri</th>
    289     <th abbr="Saturday" scope="col" title="Saturday">Sat</th>
    290   </tr>
     285  <tr>';
     286 foreach ($weekday as $wd) {
     287    echo "\n\t<th abbr='$wd' scope='col' title='$wd'>" . substr($wd, 0, $daylength) . '</th>';
     288 }
     289
     290echo '  </tr>
    291291</thead>
    292292
     
    295295
    296296if ($previous) {
    297     echo '<th abbr="' . $month[zeroise($previous->month, 2)] . '" colspan="3" id="prev"><a href="' .
     297    echo "\n\t".'<td abbr="' . $month[zeroise($previous->month, 2)] . '" colspan="3" id="prev"><a href="' .
    298298    get_month_link($previous->year, $previous->month) . '" title="View posts for ' . $month[zeroise($previous->month, 2)] . ' ' .
    299     date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year)) . '">&laquo; ' . substr($month[zeroise($previous->month, 2)], 0, 3) . '</a>';
     299    date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year)) . '">&laquo; ' . substr($month[zeroise($previous->month, 2)], 0, 3) . '</a></td>';
    300300} else {
    301     echo '<th colspan="3" id="prev">&laquo;</th>';
    302 }
    303 
    304 echo '<th>&nbsp;</th>';
     301    echo "\n\t".'<td colspan="3" id="prev">&laquo;</td>';
     302}
     303
     304echo "\n\t".'<td>&nbsp;</td>';
    305305
    306306if ($next) {
    307     echo '<th abbr="' . $month[zeroise($next->month, 2)] . '" colspan="3" id="next"><a href="' .
     307    echo "\n\t".'<td abbr="' . $month[zeroise($next->month, 2)] . '" colspan="3" id="next"><a href="' .
    308308    get_month_link($previous->year, $next->month) . '" title="View posts for ' . $month[zeroise($next->month, 2)] . ' ' .
    309     date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year)) . '">' . substr($month[zeroise($next->month, 2)], 0, 3) . ' &raquo;</a>';
     309    date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year)) . '">' . substr($month[zeroise($next->month, 2)], 0, 3) . ' &raquo;</a></td>';
    310310} else {
    311     echo '<th colspan="3" id="next">&raquo;</th>';
    312 }
    313 
    314 echo '  </tr>
     311    echo "\n\t".'<td colspan="3" id="next">&raquo;</td>';
     312}
     313
     314echo '
     315  </tr>
    315316</tfoot>
    316317
     
    324325                AND post_status = 'publish'
    325326                AND post_date < '" . date("Y-m-d H:i:s", (time() + ($time_difference * 3600)))."'", ARRAY_N);
    326 foreach ($dayswithposts as $daywith) {
    327     $daywithpost[] = $daywith[0];
     327
     328if ($dayswithposts) {
     329    foreach ($dayswithposts as $daywith) {
     330        $daywithpost[] = $daywith[0];
     331    }
     332} else {
     333    $daywithpost = array();
    328334}
    329335
    330336// See how much we should pad in the beginning
    331337$pad = intval(date('w', $unixmonth));
    332 if (0 != $pad) echo "\n\t<td class='empty' colspan='$pad'>&nbsp;</td>";
     338if (0 != $pad) echo "\n\t<td colspan='$pad'>&nbsp;</td>";
    333339
    334340$daysinmonth = intval(date('t', $unixmonth));
    335341for ($day = 1; $day <= $daysinmonth; ++$day) {
    336     if ($newrow) echo "\n</tr>\n  <tr>";
     342    if ($newrow) echo "\n  </tr>\n  <tr>\n\t";
    337343    $newrow = false;
    338     echo "\n\t<td>";
     344
     345    if ($day == date('j', (time() + ($time_difference * 3600)))) echo '<td id="today">';
     346    else echo "<td>";
    339347
    340348    if (in_array($day, $daywithpost)) {
  • trunk/index.php

    r470 r510  
    9090 </li>
    9191 <li>Calendar:
    92    <ul>
    93      <li>
    94         <?php include_once('b2calendar.php')?>
    95      </li>
    96    </ul>
     92    <?php get_calendar(); ?>
    9793 </li>
    9894 <li>Other:
  • trunk/wp-layout.css

    r507 r510  
    11/* Default WordPress by Dave Shea || http://mezzoblue.com
    2     Tweaked by Matthew Mullenweg || http://photomatt.net
     2    Modifications by Matthew Mullenweg || http://photomatt.net
    33    This is just a basic layout, with only the bare minimum defined.
    44    Please tweak this and make it your own. :)
     
    7474}
    7575
    76 .b2calendarcell {
    77     color: #000;
    78 }
    79 
    80 .b2calendaremptycell {
    81 }
    82 
    83 .b2calendarheadercell {
    84     background: #808080;
    85     color: #ccc;
    86 }
    87 
    88 .b2calendarlinkpost {
    89     color: #f00;
    90     text-decoration: none;
    91 }
    92 
    93 .b2calendarmonth {
    94     color: #aaa;
    95 }
    96 
    97 .b2calendarrow {
    98     color: #0f0;
    99 }
    100 
    101 .b2calendartable {
    102     background: #fff;
    103     border: 1px solid #000;
    104 }
    105 
    106 .b2calendartoday {
    107     color: #00f;
    108 }
    10976
    11077.credit {
     
    239206    border-bottom: 1px solid #809080;
    240207}
     208
     209#wp-calendar {
     210    border: 1px solid #ddd;
     211    empty-cells: show;
     212    font-size: 14px;
     213    margin: 0;
     214    width: 90%;
     215}
     216
     217#wp-calendar #next a {
     218    padding-right: 10px;
     219    text-align: right;
     220}
     221
     222#wp-calendar #prev a {
     223    padding-left: 10px;
     224    text-align: left;
     225}
     226
     227#wp-calendar a {
     228    display: block;
     229    text-decoration: none;
     230}
     231
     232#wp-calendar a:hover {
     233    background: #e0e6e0;
     234    color: #333;
     235}
     236
     237#wp-calendar caption {
     238    color: #999;
     239    font-size: 16px;
     240}
     241
     242#wp-calendar td {
     243    color: #ccc;
     244    font: normal 12px 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif;
     245    text-align: center;
     246    padding: 2px 0;
     247    letter-spacing: normal;
     248}
     249
     250#wp-calendar td:hover, #wp-calendar #today {
     251    background: #eee;
     252    color: #bbb;
     253}
     254
     255#wp-calendar th {
     256    font-style: normal;
     257    text-transform: capitalize;
     258}
Note: See TracChangeset for help on using the changeset viewer.