Added ability to output archives as options (just add select tag)

git-svn-id: http://svn.automattic.com/wordpress/trunk@292 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
mikelittle 2003-08-04 21:55:10 +00:00
parent a1813a9120
commit 966a388a92
1 changed files with 13 additions and 12 deletions

View File

@ -111,17 +111,19 @@ function single_month_title($prefix = '', $display = true ) {
} }
/* link navigation hack by Orien http://icecode.com/ */ /* link navigation hack by Orien http://icecode.com/ */
function get_archives_link( $url, $text, $format ) { function get_archives_link($url, $text, $format) {
if ('link' == $format) { if ('link' == $format) {
echo '<link rel="Archives" title="'.$text.'" href="'.$url.'" />'."\n"; return '<link rel="Archives" title="'.$text.'" href="'.$url.'" />'."\n";
} else { } else if ('option' == $format) {
echo '<li><a href="'.$url.'" title="'.$text.'">'.$text.'</a></li>'."\n"; return '<option value="'.$url.'">'.$text.'</option>'."\n";
} else { // 'html'
return '<li><a href="'.$url.'" title="'.$text.'">'.$text.'</a></li>'."\n";
} }
} }
function get_archives($type='', $limit='', $format='html') { function get_archives($type='', $limit='', $format='html') {
global $tableposts, $dateformat, $time_difference, $siteurl, $blogfilename; global $tableposts, $dateformat, $time_difference, $siteurl, $blogfilename;
GLOBAL $querystring_start, $querystring_equal, $querystring_separator, $month, $wpdb, $start_of_week; global $querystring_start, $querystring_equal, $querystring_separator, $month, $wpdb, $start_of_week;
if ('' == $type) { if ('' == $type) {
$type = get_settings('archive_mode'); $type = get_settings('archive_mode');
@ -163,7 +165,7 @@ function get_archives($type='', $limit='', $format='html') {
foreach ($arcresults as $arcresult) { foreach ($arcresults as $arcresult) {
$url = sprintf("%s%d%02d", $archive_link_m, $arcresult->year, $arcresult->month); $url = sprintf("%s%d%02d", $archive_link_m, $arcresult->year, $arcresult->month);
$text = sprintf("%s %d", $month[zeroise($arcresult->month,2)], $arcresult->year); $text = sprintf("%s %d", $month[zeroise($arcresult->month,2)], $arcresult->year);
get_archives_link($url, $text, $format); echo get_archives_link($url, $text, $format);
} }
} elseif ('daily' == $type) { } elseif ('daily' == $type) {
++$querycount; ++$querycount;
@ -172,7 +174,7 @@ function get_archives($type='', $limit='', $format='html') {
$url = sprintf("%s%d%02d%02d", $archive_link_m, $arcresult->year, $arcresult->month, $arcresult->dayofmonth); $url = sprintf("%s%d%02d%02d", $archive_link_m, $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
$date = sprintf("%d-%02d-%02d 00:00:00", $arcresult->year, $arcresult->month, $arcresult->dayofmonth); $date = sprintf("%d-%02d-%02d 00:00:00", $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
$text = mysql2date($archive_day_date_format, $date); $text = mysql2date($archive_day_date_format, $date);
get_archives_link($url, $text, $format); echo get_archives_link($url, $text, $format);
} }
} elseif ('weekly' == $type) { } elseif ('weekly' == $type) {
if (!isset($start_of_week)) { if (!isset($start_of_week)) {
@ -192,7 +194,7 @@ function get_archives($type='', $limit='', $format='html') {
$querystring_equal, $arc_year, $querystring_separator, $querystring_equal, $arc_year, $querystring_separator,
$querystring_equal, $arcresult->week); $querystring_equal, $arcresult->week);
$text = $arc_week_start . $archive_week_separator . $arc_week_end; $text = $arc_week_start . $archive_week_separator . $arc_week_end;
get_archives_link($url, $text, $format); echo get_archives_link($url, $text, $format);
} }
} }
} elseif ('postbypost' == $type) { } elseif ('postbypost' == $type) {
@ -207,7 +209,7 @@ function get_archives($type='', $limit='', $format='html') {
} else { } else {
$text = $arcresult->ID; $text = $arcresult->ID;
} }
get_archives_link($url, $text, $format); echo get_archives_link($url, $text, $format);
} }
} }
} }
@ -858,8 +860,8 @@ function the_category_head($before='', $after='') {
// out of the b2 loop // out of the b2 loop
function dropdown_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', function dropdown_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc',
$optiondates = 0, $optioncount = 0, $hide_empty = 1) { $optiondates = 0, $optioncount = 0, $hide_empty = 1) {
global $cat, $tablecategories, $tableposts, $querycount, $wpdb; global $cat, $tablecategories, $tableposts, $querycount, $wpdb;
$sort_column = 'cat_'.$sort_column; $sort_column = 'cat_'.$sort_column;
$query = " SELECT cat_ID, cat_name,"; $query = " SELECT cat_ID, cat_name,";
@ -873,7 +875,6 @@ function dropdown_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_
} }
$query .= " ORDER BY $sort_column $sort_order, post_date DESC"; $query .= " ORDER BY $sort_column $sort_order, post_date DESC";
$categories = $wpdb->get_results($query); $categories = $wpdb->get_results($query);
++$querycount; ++$querycount;
echo "<select name='cat' class='postform'>\n"; echo "<select name='cat' class='postform'>\n";