Changeset 190
- Timestamp:
- 06/08/2003 12:10:07 AM (22 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/b2-include/b2template.functions.php
r176 r190 112 112 113 113 function 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 116 116 if ('' != $limit) { 117 118 $limit = " LIMIT $limit";117 $limit = (int) $limit; 118 $limit = " LIMIT $limit"; 119 119 } 120 120 // this is what will separate dates on weekly archive links 121 121 $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; 122 127 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 } 129 147 130 148 $now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600))); … … 132 150 if ('monthly' == $type) { 133 151 ++$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); 135 153 foreach ($arcresults as $arcresult) { 136 154 echo "<li><a href=\"$archive_link_m$arcresult->year".zeroise($arcresult->month, 2).'">'; … … 140 158 } elseif ('daily' == $type) { 141 159 ++$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); 143 161 foreach ($arcresults as $arcresult) { 144 162 echo "<li><a href=\"$archive_link_m$arcresult->year".zeroise($arcresult->month, 2).zeroise($arcresult->dayofmonth, 2).'">'; … … 151 169 } 152 170 ++$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 > 0ORDER 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); 154 172 $arc_w_last = ''; 155 173 foreach ($arcresults as $arcresult) { 156 174 if ($arcresult->week != $arc_w_last) { 157 175 $arc_w_last = $arcresult->week; 158 $arc_ymd = $arcresult->year.'-'.zeroise($arcresult->month, 2).'-' .zeroise($arcresult->d ayofmonth, 2);176 $arc_ymd = $arcresult->year.'-'.zeroise($arcresult->month, 2).'-' .zeroise($arcresult->dom, 2); 159 177 $arc_week = get_weekstartend($arc_ymd, $start_of_week); 160 178 $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']); … … 167 185 } elseif ('postbypost' == $type) { 168 186 ++$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); 170 188 foreach ($arcresults as $arcresult) { 171 189 if ($arcresult->post_date != '0000-00-00 00:00:00') {
Note: See TracChangeset
for help on using the changeset viewer.