Fixed other archive modes in get_archives.Removed standalone archives files.
However limit does not work as expected in weekly mode. git-svn-id: http://svn.automattic.com/wordpress/trunk@190 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b8bd0d129f
commit
9e3d334434
|
@ -111,27 +111,45 @@ function single_month_title($prefix = '', $display = true ) {
|
|||
}
|
||||
|
||||
function get_archives($type, $limit='') {
|
||||
global $tableposts, $dateformat, $time_difference, $siteurl, $blogfilename, $querystring_start, $querystring_equal, $month, $wpdb;
|
||||
// weekly and daily are *broken*
|
||||
global $tableposts, $dateformat, $time_difference, $siteurl, $blogfilename, $querystring_start, $querystring_equal, $month, $wpdb, $start_of_week;
|
||||
|
||||
if ('' != $limit) {
|
||||
$limit = (int) $limit;
|
||||
$limit= " LIMIT $limit";
|
||||
$limit = (int) $limit;
|
||||
$limit = " LIMIT $limit";
|
||||
}
|
||||
// this is what will separate dates on weekly archive links
|
||||
$archive_week_separator = '–';
|
||||
|
||||
|
||||
|
||||
// archive link url
|
||||
$archive_link_m = $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal; # monthly archive
|
||||
$archive_link_w = $siteurl.'/'.$blogfilename.$querystring_start.'w'.$querystring_equal; # weekly archive
|
||||
$archive_link_p = $siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal; # post-by-post archive
|
||||
$archive_link_m = $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal; # monthly archive;
|
||||
$archive_link_w = $siteurl.'/'.$blogfilename.$querystring_start.'w'.$querystring_equal; # weekly archive;
|
||||
$archive_link_p = $siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal; # post-by-post archive;
|
||||
|
||||
// over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
|
||||
$archive_date_format_over_ride = 0;
|
||||
|
||||
// options for daily archive (only if you over-ride the general date format)
|
||||
$archive_day_date_format = 'Y/m/d';
|
||||
|
||||
// options for weekly archive (only if you over-ride the general date format)
|
||||
$archive_week_start_date_format = 'Y/m/d';
|
||||
$archive_week_end_date_format = 'Y/m/d';
|
||||
|
||||
|
||||
//$dateformat=get_settings('date_format');
|
||||
//$time_difference=get_settings('time_difference');
|
||||
|
||||
if (!$archive_date_format_over_ride) {
|
||||
$archive_day_date_format = $dateformat;
|
||||
$archive_week_start_date_format = $dateformat;
|
||||
$archive_week_end_date_format = $dateformat;
|
||||
}
|
||||
|
||||
$now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600)));
|
||||
|
||||
if ('monthly' == $type) {
|
||||
++$querycount;
|
||||
$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);
|
||||
$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);
|
||||
foreach ($arcresults as $arcresult) {
|
||||
echo "<li><a href=\"$archive_link_m$arcresult->year".zeroise($arcresult->month, 2).'">';
|
||||
echo $month[zeroise($arcresult->month, 2)].' '.$arcresult->year;
|
||||
|
@ -139,7 +157,7 @@ function get_archives($type, $limit='') {
|
|||
}
|
||||
} elseif ('daily' == $type) {
|
||||
++$querycount;
|
||||
$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);
|
||||
$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);
|
||||
foreach ($arcresults as $arcresult) {
|
||||
echo "<li><a href=\"$archive_link_m$arcresult->year".zeroise($arcresult->month, 2).zeroise($arcresult->dayofmonth, 2).'">';
|
||||
echo mysql2date($archive_day_date_format, $arcresult->year.'-'.zeroise($arcresult->month,2).'-'.zeroise($arcresult->dayofmonth,2).' 00:00:00');
|
||||
|
@ -150,12 +168,12 @@ function get_archives($type, $limit='') {
|
|||
$start_of_week = 1;
|
||||
}
|
||||
++$querycount;
|
||||
$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);
|
||||
$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);
|
||||
$arc_w_last = '';
|
||||
foreach ($arcresults as $arcresult) {
|
||||
if ($arcresult->week != $arc_w_last) {
|
||||
$arc_w_last = $arcresult->week;
|
||||
$arc_ymd = $arcresult->year.'-'.zeroise($arcresult->month, 2).'-' .zeroise($arcresult->dayofmonth, 2);
|
||||
$arc_ymd = $arcresult->year.'-'.zeroise($arcresult->month, 2).'-' .zeroise($arcresult->dom, 2);
|
||||
$arc_week = get_weekstartend($arc_ymd, $start_of_week);
|
||||
$arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
|
||||
$arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
|
||||
|
@ -166,7 +184,7 @@ function get_archives($type, $limit='') {
|
|||
}
|
||||
} elseif ('postbypost' == $type) {
|
||||
++$querycount;
|
||||
$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);
|
||||
$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);
|
||||
foreach ($arcresults as $arcresult) {
|
||||
if ($arcresult->post_date != '0000-00-00 00:00:00') {
|
||||
echo "<li><a href=\"$archive_link_p".$arcresult->ID.'">';
|
||||
|
|
117
b2archives.php
117
b2archives.php
|
@ -1,117 +0,0 @@
|
|||
<?php
|
||||
|
||||
// *** b2 Archive file
|
||||
|
||||
require_once('b2config.php');
|
||||
require_once($abspath.$b2inc.'/b2functions.php');
|
||||
|
||||
// this is what will separate your archive links
|
||||
// this is what will separate dates on weekly archive links
|
||||
$archive_week_separator = '–';
|
||||
|
||||
|
||||
// archive link url
|
||||
$archive_link_m = $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal; # monthly archive
|
||||
$archive_link_w = $siteurl.'/'.$blogfilename.$querystring_start.'w'.$querystring_equal; # weekly archive
|
||||
$archive_link_p = $siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal; # post-by-post archive
|
||||
|
||||
|
||||
// over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
|
||||
$archive_date_format_over_ride = 0;
|
||||
|
||||
|
||||
// options for daily archive (only if you over-ride the general date format)
|
||||
$archive_day_date_format = 'Y/m/d';
|
||||
|
||||
// options for weekly archive (only if you over-ride the general date format)
|
||||
$archive_week_start_date_format = 'Y/m/d';
|
||||
$archive_week_end_date_format = 'Y/m/d';
|
||||
|
||||
|
||||
// --- //
|
||||
|
||||
|
||||
$dateformat=get_settings('date_format');
|
||||
$time_difference=get_settings('time_difference');
|
||||
|
||||
if (!$archive_date_format_over_ride) {
|
||||
$archive_day_date_format = $dateformat;
|
||||
$archive_week_start_date_format = $dateformat;
|
||||
$archive_week_end_date_format = $dateformat;
|
||||
}
|
||||
|
||||
if (basename($HTTP_SERVER_VARS['SCRIPT_FILENAME']) == 'b2archives.php')
|
||||
include ('blog.header.php');
|
||||
|
||||
if (!isset($querycount)) {
|
||||
$querycount = 0;
|
||||
}
|
||||
|
||||
$now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600)));
|
||||
|
||||
if ($archive_mode == 'monthly') {
|
||||
$arc_sql="SELECT DISTINCT YEAR(post_date) AS yr, MONTH(post_date) AS mn FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC";
|
||||
$querycount++;
|
||||
$arc_results = $wpdb->get_results($arc_sql);
|
||||
foreach ($arc_results as $arc_row) {
|
||||
$arc_year = $arc_row->yr;
|
||||
$arc_month = $arc_row->mn;
|
||||
echo "<li><a href=\"$archive_link_m$arc_year".zeroise($arc_month,2).'">';
|
||||
echo $month[zeroise($arc_month,2)].' '.$arc_year;
|
||||
echo "</a></li>\n";
|
||||
}
|
||||
} elseif ($archive_mode == 'daily') {
|
||||
$arc_sql="SELECT DISTINCT YEAR(post_date) AS yr, MONTH(post_date) AS mn, DAYOFMONTH(post_date) as dom FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC";
|
||||
$querycount++;
|
||||
$arc_results = $wpdb->get_results($arc_sql);
|
||||
foreach ($arc_results as $arc_row) {
|
||||
$arc_year = $arc_row->yr;
|
||||
$arc_month = $arc_row->mn;
|
||||
$arc_dayofmonth = $arc_row->dom;
|
||||
echo "<li><a href=\"$archive_link_m$arc_year".zeroise($arc_month,2).zeroise($arc_dayofmonth,2).'">';
|
||||
echo mysql2date($archive_day_date_format, $arc_year.'-'.zeroise($arc_month,2).'-'.zeroise($arc_dayofmonth,2).' 00:00:00');
|
||||
echo "</a></li>\n";
|
||||
}
|
||||
} elseif ($archive_mode == 'weekly') {
|
||||
if (!isset($start_of_week)) {
|
||||
$start_of_week = 1;
|
||||
}
|
||||
$arc_sql="SELECT DISTINCT YEAR(post_date) AS yr, MONTH(post_date) AS mn, DAYOFMONTH(post_date) AS dom, WEEK(post_date) AS wk FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC";
|
||||
$querycount++;
|
||||
$arc_results = $wpdb->get_results($arc_sql);
|
||||
$arc_w_last = '';
|
||||
foreach ($arc_results as $arc_row) {
|
||||
$arc_year = $arc_row->yr;
|
||||
$arc_w = $arc_row->wk;
|
||||
if ($arc_w != $arc_w_last) {
|
||||
$arc_w_last = $arc_w;
|
||||
$arc_ymd = $arc_year.'-'.zeroise($arc_row->mn,2).'-' .zeroise($arc_row->dom,2);
|
||||
$arc_week = get_weekstartend($arc_ymd, $start_of_week);
|
||||
$arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
|
||||
$arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
|
||||
echo "<li><a href=\"$siteurl/".$blogfilename."?m=$arc_year&w=$arc_w\">";
|
||||
echo $arc_week_start.$archive_week_separator.$arc_week_end;
|
||||
echo "</a></li>\n";
|
||||
}
|
||||
}
|
||||
} elseif ($archive_mode == 'postbypost') {
|
||||
$requestarc = " 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";
|
||||
$querycount++;
|
||||
$resultarc = $wpdb->get_results($requestarc);
|
||||
foreach ($resultarc as $row) {
|
||||
if ($row->post_date != '0000-00-00 00:00:00') {
|
||||
echo "<li><a href=\"$archive_link_p".$row->ID.'">';
|
||||
$arc_title = stripslashes($row->post_title);
|
||||
if ($arc_title) {
|
||||
echo strip_tags($arc_title);
|
||||
} else {
|
||||
echo $row->ID;
|
||||
}
|
||||
echo "</a></li>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# echo $querycount."<br />\n";
|
||||
# timer_stop(1,8);
|
||||
?>
|
Loading…
Reference in New Issue