Make WordPress Core

Changeset 190


Ignore:
Timestamp:
06/08/2003 12:10:07 AM (23 years ago)
Author:
mikelittle
Message:

Fixed other archive modes in get_archives.Removed standalone archives files.
However limit does not work as expected in weekly mode.

Location:
trunk
Files:
1 deleted
1 edited

Legend:

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

    r176 r190  
    112112
    113113function get_archives($type, $limit='') {
    114         global $tableposts, $dateformat, $time_difference, $siteurl, $blogfilename, $querystring_start, $querystring_equal, $month, $wpdb;
    115         // weekly and daily are *broken*
     114        global $tableposts, $dateformat, $time_difference, $siteurl, $blogfilename, $querystring_start, $querystring_equal, $month, $wpdb, $start_of_week;
     115
    116116        if ('' != $limit) {
    117                 $limit = (int) $limit;
    118                 $limit= " LIMIT $limit";
     117        $limit = (int) $limit;
     118                $limit = " LIMIT $limit";
    119119        }
    120120        // this is what will separate dates on weekly archive links
    121121        $archive_week_separator = '–';
     122
     123        // archive link url
     124        $archive_link_m = $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal; # monthly archive;
     125        $archive_link_w = $siteurl.'/'.$blogfilename.$querystring_start.'w'.$querystring_equal; # weekly archive;
     126        $archive_link_p = $siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal; # post-by-post archive;
    122127       
    123        
    124         // archive link url
    125         $archive_link_m = $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal; # monthly archive
    126         $archive_link_w = $siteurl.'/'.$blogfilename.$querystring_start.'w'.$querystring_equal; # weekly archive
    127         $archive_link_p = $siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal; # post-by-post archive
    128        
     128    // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
     129    $archive_date_format_over_ride = 0;
     130
     131    // options for daily archive (only if you over-ride the general date format)
     132    $archive_day_date_format = 'Y/m/d';
     133
     134    // options for weekly archive (only if you over-ride the general date format)
     135    $archive_week_start_date_format = 'Y/m/d';
     136    $archive_week_end_date_format   = 'Y/m/d';
     137
     138
     139    //$dateformat=get_settings('date_format');
     140    //$time_difference=get_settings('time_difference');
     141
     142    if (!$archive_date_format_over_ride) {
     143        $archive_day_date_format = $dateformat;
     144        $archive_week_start_date_format = $dateformat;
     145        $archive_week_end_date_format   = $dateformat;
     146    }
    129147       
    130148        $now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600)));
    … …  
    132150        if ('monthly' == $type) {
    133151                ++$querycount;
    134                 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month` FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC" . $limit);
     152                $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month` FROM $tableposts WHERE post_date < '$now' AND post_category > 0 AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    135153                foreach ($arcresults as $arcresult) {
    136154                        echo "<li><a href=\"$archive_link_m$arcresult->year".zeroise($arcresult->month, 2).'">';
    … …  
    140158        } elseif ('daily' == $type) {
    141159                ++$querycount;
    142                 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC" . $limit);
     160                $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $tableposts WHERE post_date < '$now' AND post_category > 0 AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    143161                foreach ($arcresults as $arcresult) {
    144162                        echo "<li><a href=\"$archive_link_m$arcresult->year".zeroise($arcresult->month, 2).zeroise($arcresult->dayofmonth, 2).'">';
    … …  
    151169                }
    152170                ++$querycount;
    153                 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, WEEK(post_date) AS `week` FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC" . $limit);
     171                $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS dom, WEEK(post_date) AS `week` FROM $tableposts WHERE post_date < '$now' AND post_category > 0 AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    154172                $arc_w_last = '';
    155173                foreach ($arcresults as $arcresult) {
    156174                        if ($arcresult->week != $arc_w_last) {
    157175                                $arc_w_last = $arcresult->week;
    158                                 $arc_ymd = $arcresult->year.'-'.zeroise($arcresult->month, 2).'-' .zeroise($arcresult->dayofmonth, 2);
     176                                $arc_ymd = $arcresult->year.'-'.zeroise($arcresult->month, 2).'-' .zeroise($arcresult->dom, 2);
    159177                                $arc_week = get_weekstartend($arc_ymd, $start_of_week);
    160178                                $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
    … …  
    167185        } elseif ('postbypost' == $type) {
    168186                ++$querycount;
    169                 $arcresults = $wpdb->get_results("SELECT ID, post_date, post_title FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC" . $limit);
     187                $arcresults = $wpdb->get_results("SELECT ID, post_date, post_title FROM $tableposts WHERE post_date < '$now' AND post_category > 0 AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
    170188                foreach ($arcresults as $arcresult) {
    171189                        if ($arcresult->post_date != '0000-00-00 00:00:00') {
Note: See TracChangeset for help on using the changeset viewer.