Make WordPress Core

Changeset 273


Ignore:
Timestamp:
07/25/2003 11:07:38 PM (23 years ago)
Author:
mikelittle
Message:

Update to get_archives()
Now can produce site navigation links
Hack by Orien (http://icecode.com/)

File:
1 edited

Legend:

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

    r272 r273  
    111111}
    112112
    113 function get_archives($type='', $limit='') {
     113function get_archives_link( $url, $text, $format ) {
     114    if ('link' == $format) {
     115        echo "  <link rel='Archives' title='$text' href='$url' />\n";
     116    } else {
     117        echo "<li><a href='$url'>";
     118        echo $text;
     119        echo "</a></li>\n";
     120    }
     121}
     122
     123function get_archives($type='', $limit='',$format='html') {
    114124    global $tableposts, $dateformat, $time_difference, $siteurl, $blogfilename;
    115125    GLOBAL $querystring_start, $querystring_equal, $querystring_separator, $month, $wpdb, $start_of_week;
     
    153163        $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);
    154164        foreach ($arcresults as $arcresult) {
    155             echo "<li><a href=\"$archive_link_m$arcresult->year".zeroise($arcresult->month, 2).'">';
    156             echo $month[zeroise($arcresult->month, 2)].' '.$arcresult->year;
    157             echo "</a></li>\n";
     165            $url  = sprintf("%s%d%02d", $archive_link_m,  $arcresult->year,   $arcresult->month);
     166            $text = sprintf("%s %d",    $month[zeroise($arcresult->month,2)], $arcresult->year);
     167            get_archives_link($url, $text, $format);
    158168        }
    159169    } elseif ('daily' == $type) {
     
    161171        $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);
    162172        foreach ($arcresults as $arcresult) {
    163             echo "<li><a href=\"$archive_link_m$arcresult->year".zeroise($arcresult->month, 2).zeroise($arcresult->dayofmonth, 2).'">';
    164             echo mysql2date($archive_day_date_format, $arcresult->year.'-'.zeroise($arcresult->month,2).'-'.zeroise($arcresult->dayofmonth,2).' 00:00:00');
    165             echo "</a></li>\n";
     173            $url  = sprintf("%s%d%02d%02d", $archive_link_m, $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
     174            $date = sprintf("%d-%02d-%02d 00:00:00", $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
     175            $text = mysql2date($archive_day_date_format, $date);
     176            get_archives_link($url, $text, $format);
    166177        }
    167178    } elseif ('weekly' == $type) {
     
    179190                $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
    180191                $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
    181                 echo "<li><a href='$siteurl/$blogfilename$querystring_start"."m$querystring_equal$arc_year$querystring_separator"."w$querystring_equal$arcresult->week'>";
    182                 echo $arc_week_start.$archive_week_separator.$arc_week_end;
    183                 echo "</a></li>\n";
     192                $url  = sprintf("%s/%s%sm%s%s%sw%s%d", $siteurl, $blogfilename, $querystring_start,
     193                                                     $querystring_equal, $arc_year, $querystring_separator,
     194                                                     $querystring_equal, $arcresult->week);
     195                $text = $arc_week_start . $archive_week_separator . $arc_week_end;
     196                get_archives_link($url, $text, $format);
    184197            }
    185198        }
     
    189202        foreach ($arcresults as $arcresult) {
    190203            if ($arcresult->post_date != '0000-00-00 00:00:00') {
    191                 echo "<li><a href=\"$archive_link_p".$arcresult->ID.'">';
     204                $url  = $archive_link_p . $arcresult->ID;
    192205                $arc_title = stripslashes($arcresult->post_title);
    193206                if ($arc_title) {
    194                     echo strip_tags($arc_title);
     207                    $text = strip_tags($arc_title);
    195208                } else {
    196                     echo $arcresult->ID;
     209                    $text = $arcresult->ID;
    197210                }
    198                 echo "</a></li>\n";
     211                get_archives_link($url, $text, $format);
    199212            }
    200213        }
Note: See TracChangeset for help on using the changeset viewer.