Added Alex K's title tooltips back into the calendar code.
git-svn-id: http://svn.automattic.com/wordpress/trunk@521 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
13c0dc3c69
commit
785753c40e
|
@ -116,7 +116,7 @@ function get_archives_link($url, $text, $format = "html", $before = "", $after =
|
||||||
return '<option value="'.$url.'">'.$text.'</option>'."\n";
|
return '<option value="'.$url.'">'.$text.'</option>'."\n";
|
||||||
} else if ('html' == $format) {
|
} else if ('html' == $format) {
|
||||||
return "\t".'<li><a href="'.$url.'" title="'.$text.'">'.$text.'</a>'.$after.'</li>'."\n";
|
return "\t".'<li><a href="'.$url.'" title="'.$text.'">'.$text.'</a>'.$after.'</li>'."\n";
|
||||||
} else { // custom
|
} else { // custom
|
||||||
return "\t".$before.'<a href="'.$url.'" title="'.$text.'">'.$text.'</a>'.$after."\n";
|
return "\t".$before.'<a href="'.$url.'" title="'.$text.'">'.$text.'</a>'.$after."\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,8 +200,8 @@ function get_archives($type='', $limit='', $format='html', $before = "", $after
|
||||||
$arc_week = get_weekstartend($arcresult->yyyymmdd, $start_of_week);
|
$arc_week = get_weekstartend($arcresult->yyyymmdd, $start_of_week);
|
||||||
$arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
|
$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']);
|
$arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
|
||||||
$url = sprintf("%s/%s%sm%s%s%sw%s%d", $siteurl, $blogfilename, $querystring_start,
|
$url = sprintf("%s/%s%sm%s%s%sw%s%d", $siteurl, $blogfilename, $querystring_start,
|
||||||
$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;
|
||||||
echo get_archives_link($url, $text, $format, $before, $after);
|
echo get_archives_link($url, $text, $format, $before, $after);
|
||||||
|
@ -230,134 +230,175 @@ function get_archives($type='', $limit='', $format='html', $before = "", $after
|
||||||
|
|
||||||
function get_calendar($daylength = 1) {
|
function get_calendar($daylength = 1) {
|
||||||
global $wpdb, $HTTP_GET_VARS, $m, $monthnum, $year, $timedifference, $month, $weekday, $tableposts;
|
global $wpdb, $HTTP_GET_VARS, $m, $monthnum, $year, $timedifference, $month, $weekday, $tableposts;
|
||||||
// Quick check. If we have no posts at all, abort!
|
|
||||||
if (!$posts) {
|
|
||||||
$gotsome = $wpdb->get_var("SELECT ID from $tableposts WHERE post_status = 'publish' AND post_category > 0 ORDER BY post_date DESC LIMIT 1");
|
|
||||||
if (!$gotsome)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$w = ''.intval($HTTP_GET_VARS['w']);
|
$ak_use_tooltip_titles = 1; // set this to 1 to have the day's post titles as tooltips to the calendar date.
|
||||||
$time_difference = get_settings('time_difference');
|
|
||||||
|
|
||||||
// Let's figure out when we are
|
// Quick check. If we have no posts at all, abort!
|
||||||
if (!empty($monthnum) && !empty($year)) {
|
if (!$posts) {
|
||||||
$thismonth = ''.intval($monthnum);
|
$gotsome = $wpdb->get_var("SELECT ID from $tableposts WHERE post_status = 'publish' AND post_category > 0 ORDER BY post_date DESC LIMIT 1");
|
||||||
$thisyear = ''.intval($year);
|
if (!$gotsome)
|
||||||
} elseif (!empty($w)) {
|
return;
|
||||||
// We need to get the month from MySQL
|
}
|
||||||
$thisyear = ''.intval(substr($m, 0, 4));
|
|
||||||
$d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
|
$w = ''.intval($HTTP_GET_VARS['w']);
|
||||||
$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')");
|
$time_difference = get_settings('time_difference');
|
||||||
} elseif (!empty($m)) {
|
|
||||||
$calendar = substr($m, 0, 6);
|
// Let's figure out when we are
|
||||||
$thisyear = ''.intval(substr($m, 0, 4));
|
if (!empty($monthnum) && !empty($year)) {
|
||||||
if (strlen($m) < 6) {
|
$thismonth = ''.intval($monthnum);
|
||||||
$thismonth = '01';
|
$thisyear = ''.intval($year);
|
||||||
|
} elseif (!empty($w)) {
|
||||||
|
// We need to get the month from MySQL
|
||||||
|
$thisyear = ''.intval(substr($m, 0, 4));
|
||||||
|
$d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
|
||||||
|
$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')");
|
||||||
|
} elseif (!empty($m)) {
|
||||||
|
$calendar = substr($m, 0, 6);
|
||||||
|
$thisyear = ''.intval(substr($m, 0, 4));
|
||||||
|
if (strlen($m) < 6) {
|
||||||
|
$thismonth = '01';
|
||||||
|
} else {
|
||||||
|
$thismonth = ''.intval(substr($m, 4, 2));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$thismonth = ''.intval(substr($m, 4, 2));
|
$thisyear = intval(date('Y', time()+($time_difference * 3600)));
|
||||||
|
$thismonth = intval(date('m', time()+($time_difference * 3600)));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$thisyear = intval(date('Y', time()+($time_difference * 3600)));
|
|
||||||
$thismonth = intval(date('m', time()+($time_difference * 3600)));
|
|
||||||
}
|
|
||||||
|
|
||||||
$unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
|
$unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
|
||||||
|
|
||||||
// Get the next and previous month and year with at least one post
|
// Get the next and previous month and year with at least one post
|
||||||
$previous = $wpdb->get_row("SELECT DISTINCT MONTH( post_date ) AS month, YEAR( post_date ) AS year
|
$previous = $wpdb->get_row("SELECT DISTINCT MONTH( post_date ) AS month, YEAR( post_date ) AS year
|
||||||
FROM $tableposts
|
FROM $tableposts
|
||||||
WHERE post_date < '$thisyear-$thismonth-01'
|
WHERE post_date < '$thisyear-$thismonth-01'
|
||||||
AND post_status = 'publish'
|
AND post_status = 'publish'
|
||||||
ORDER BY post_date DESC
|
ORDER BY post_date DESC
|
||||||
LIMIT 1");
|
LIMIT 1");
|
||||||
$next = $wpdb->get_row("SELECT DISTINCT MONTH( post_date ) AS month, YEAR( post_date ) AS year
|
$next = $wpdb->get_row("SELECT DISTINCT MONTH( post_date ) AS month, YEAR( post_date ) AS year
|
||||||
FROM $tableposts
|
FROM $tableposts
|
||||||
WHERE post_date > '$thisyear-$thismonth-01'
|
WHERE post_date > '$thisyear-$thismonth-01'
|
||||||
AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
|
AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
|
||||||
AND post_status = 'publish'
|
AND post_status = 'publish'
|
||||||
ORDER BY post_date ASC
|
ORDER BY post_date ASC
|
||||||
LIMIT 1");
|
LIMIT 1");
|
||||||
|
|
||||||
echo '<table id="wp-calendar">
|
echo '<table id="wp-calendar">
|
||||||
<caption>' . $month[zeroise($thismonth, 2)] . ' ' . date('Y', $unixmonth) . '</caption>
|
<caption>' . $month[zeroise($thismonth, 2)] . ' ' . date('Y', $unixmonth) . '</caption>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>';
|
<tr>';
|
||||||
foreach ($weekday as $wd) {
|
foreach ($weekday as $wd) {
|
||||||
echo "\n\t<th abbr='$wd' scope='col' title='$wd'>" . substr($wd, 0, $daylength) . '</th>';
|
echo "\n\t\t<th abbr='$wd' scope='col' title='$wd'>" . substr($wd, 0, $daylength) . '</th>';
|
||||||
}
|
|
||||||
|
|
||||||
echo ' </tr>
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tfoot>
|
|
||||||
<tr>';
|
|
||||||
|
|
||||||
if ($previous) {
|
|
||||||
echo "\n\t".'<td abbr="' . $month[zeroise($previous->month, 2)] . '" colspan="3" id="prev"><a href="' .
|
|
||||||
get_month_link($previous->year, $previous->month) . '" title="View posts for ' . $month[zeroise($previous->month, 2)] . ' ' .
|
|
||||||
date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year)) . '">« ' . substr($month[zeroise($previous->month, 2)], 0, 3) . '</a></td>';
|
|
||||||
} else {
|
|
||||||
echo "\n\t".'<td colspan="3" id="prev">«</td>';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "\n\t".'<td> </td>';
|
|
||||||
|
|
||||||
if ($next) {
|
|
||||||
echo "\n\t".'<td abbr="' . $month[zeroise($next->month, 2)] . '" colspan="3" id="next"><a href="' .
|
|
||||||
get_month_link($previous->year, $next->month) . '" title="View posts for ' . $month[zeroise($next->month, 2)] . ' ' .
|
|
||||||
date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year)) . '">' . substr($month[zeroise($next->month, 2)], 0, 3) . ' »</a></td>';
|
|
||||||
} else {
|
|
||||||
echo "\n\t".'<td colspan="3" id="next">»</td>';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
|
|
||||||
<tbody>
|
|
||||||
<tr>';
|
|
||||||
|
|
||||||
// Get days with posts
|
|
||||||
$dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
|
|
||||||
FROM $tableposts WHERE MONTH(post_date) = $thismonth
|
|
||||||
AND YEAR(post_date) = $thisyear
|
|
||||||
AND post_status = 'publish'
|
|
||||||
AND post_date < '" . date("Y-m-d H:i:s", (time() + ($time_difference * 3600)))."'", ARRAY_N);
|
|
||||||
|
|
||||||
if ($dayswithposts) {
|
|
||||||
foreach ($dayswithposts as $daywith) {
|
|
||||||
$daywithpost[] = $daywith[0];
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$daywithpost = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
// See how much we should pad in the beginning
|
echo '
|
||||||
$pad = intval(date('w', $unixmonth));
|
</tr>
|
||||||
if (0 != $pad) echo "\n\t<td colspan='$pad'> </td>";
|
</thead>
|
||||||
|
|
||||||
$daysinmonth = intval(date('t', $unixmonth));
|
<tfoot>
|
||||||
for ($day = 1; $day <= $daysinmonth; ++$day) {
|
<tr>';
|
||||||
if ($newrow) echo "\n </tr>\n <tr>\n\t";
|
|
||||||
$newrow = false;
|
|
||||||
|
|
||||||
if ($day == date('j', (time() + ($time_difference * 3600))) && $thismonth == date('m', time()+($time_difference * 3600))) echo '<td id="today">';
|
if ($previous) {
|
||||||
else echo "<td>";
|
echo "\n\t\t".'<td abbr="' . $month[zeroise($previous->month, 2)] . '" colspan="3" id="prev"><a href="' .
|
||||||
|
get_month_link($previous->year, $previous->month) . '" title="View posts for ' . $month[zeroise($previous->month, 2)] . ' ' .
|
||||||
if (in_array($day, $daywithpost)) {
|
date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year)) . '">« ' . substr($month[zeroise($previous->month, 2)], 0, 3) . '</a></td>';
|
||||||
echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\">$day</a>";
|
|
||||||
} else {
|
} else {
|
||||||
echo $day;
|
echo "\n\t\t".'<td colspan="3" id="prev">«</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</td>';
|
echo "\n\t\t".'<td> </td>';
|
||||||
if (6 == date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))) $newrow = true;
|
|
||||||
}
|
|
||||||
$pad = 7 - date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear));
|
|
||||||
if (0 != $pad) echo "\n\t<td class='empty' colspan='$pad'> </td>";
|
|
||||||
|
|
||||||
echo "\n </tr>\n</tbody>\n</table>";
|
if ($next) {
|
||||||
|
echo "\n\t\t".'<td abbr="' . $month[zeroise($next->month, 2)] . '" colspan="3" id="next"><a href="' .
|
||||||
|
get_month_link($previous->year, $next->month) . '" title="View posts for ' . $month[zeroise($next->month, 2)] . ' ' .
|
||||||
|
date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year)) . '">' . substr($month[zeroise($next->month, 2)], 0, 3) . ' »</a></td>';
|
||||||
|
} else {
|
||||||
|
echo "\n\t\t".'<td colspan="3" id="next">»</td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<tr>';
|
||||||
|
|
||||||
|
// Get days with posts
|
||||||
|
$dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
|
||||||
|
FROM $tableposts WHERE MONTH(post_date) = $thismonth
|
||||||
|
AND YEAR(post_date) = $thisyear
|
||||||
|
AND post_status = 'publish'
|
||||||
|
AND post_date < '" . date("Y-m-d H:i:s", (time() + ($time_difference * 3600)))."'", ARRAY_N);
|
||||||
|
|
||||||
|
if ($dayswithposts) {
|
||||||
|
foreach ($dayswithposts as $daywith) {
|
||||||
|
$daywithpost[] = $daywith[0];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$daywithpost = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($ak_use_tooltip_titles == 1) {
|
||||||
|
if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE") ||
|
||||||
|
strstr(strtolower($_SERVER["HTTP_USER_AGENT"]), "camino")) {
|
||||||
|
$ak_title_separator = "\n";
|
||||||
|
} else {
|
||||||
|
$ak_title_separator = ", ";
|
||||||
|
}
|
||||||
|
|
||||||
|
$ak_titles_for_day = array();
|
||||||
|
$ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom "
|
||||||
|
."FROM $tableposts "
|
||||||
|
."WHERE YEAR(post_date) = '$thisyear' "
|
||||||
|
."AND MONTH(post_date) = '$thismonth' "
|
||||||
|
."AND post_date < '".date("Y-m-d H:i:s", (time() + ($time_difference * 3600)))."' "
|
||||||
|
."AND post_status = 'publish'"
|
||||||
|
);
|
||||||
|
if ($ak_post_titles) {
|
||||||
|
foreach ($ak_post_titles as $ak_post_title) {
|
||||||
|
if (empty($ak_titles_for_day["$ak_post_title->dom"])) { // first one
|
||||||
|
$ak_titles_for_day["$ak_post_title->dom"] .= htmlspecialchars(stripslashes($ak_post_title->post_title));
|
||||||
|
} else {
|
||||||
|
$ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . htmlspecialchars(stripslashes($ak_post_title->post_title));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// See how much we should pad in the beginning
|
||||||
|
$pad = intval(date('w', $unixmonth));
|
||||||
|
if (0 != $pad) echo "\n\t\t<td colspan='$pad'> </td>";
|
||||||
|
|
||||||
|
$daysinmonth = intval(date('t', $unixmonth));
|
||||||
|
for ($day = 1; $day <= $daysinmonth; ++$day) {
|
||||||
|
if ($newrow)
|
||||||
|
echo "\n\t</tr>\n\t<tr>\n\t\t";
|
||||||
|
$newrow = false;
|
||||||
|
|
||||||
|
if ($day == date('j', (time() + ($time_difference * 3600))) && $thismonth == date('m', time()+($time_difference * 3600)))
|
||||||
|
echo '<td id="today">';
|
||||||
|
else
|
||||||
|
echo "<td>";
|
||||||
|
|
||||||
|
if (in_array($day, $daywithpost)) { // any posts today?
|
||||||
|
if ($ak_use_tooltip_titles == 1) { // check to see if we want to show the tooltip titles
|
||||||
|
echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$day</a>";
|
||||||
|
} else {
|
||||||
|
echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\">$day</a>";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo $day;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</td>';
|
||||||
|
if (6 == date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear)))
|
||||||
|
$newrow = true;
|
||||||
|
}
|
||||||
|
$pad = 7 - date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear));
|
||||||
|
if (0 != $pad)
|
||||||
|
echo "\n\t\t<td class='empty' colspan='$pad'> </td>";
|
||||||
|
|
||||||
|
echo "\n\t</tr>\n\t</tbody>\n\t</table>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** // About-the-blog tags *****/
|
/***** // About-the-blog tags *****/
|
||||||
|
@ -553,7 +594,7 @@ function formHandler(form) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_UrlPopNav() {
|
function print_UrlPopNav() {
|
||||||
$sites = array(
|
$sites = array(
|
||||||
array('http://www.acme.com/mapper/?lat='.get_Lat().'&long='.get_Lon().'&scale=11&theme=Image&width=3&height=2&dot=Yes',
|
array('http://www.acme.com/mapper/?lat='.get_Lat().'&long='.get_Lon().'&scale=11&theme=Image&width=3&height=2&dot=Yes',
|
||||||
'Acme Mapper'),
|
'Acme Mapper'),
|
||||||
array('http://geourl.org/near/?lat='.get_Lat().'&lon='.get_Lon().'&dist=500',
|
array('http://geourl.org/near/?lat='.get_Lat().'&lon='.get_Lon().'&dist=500',
|
||||||
|
@ -812,7 +853,7 @@ function get_the_content($more_link_text='(more...)', $stripteaser=0, $more_file
|
||||||
global $querystring_start, $querystring_equal, $querystring_separator;
|
global $querystring_start, $querystring_equal, $querystring_separator;
|
||||||
global $pagenow;
|
global $pagenow;
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
if (!empty($post->post_password)) { // if there's a password
|
if (!empty($post->post_password)) { // if there's a password
|
||||||
if ($HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $post->post_password) { // and it doesn't match the cookie
|
if ($HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] != $post->post_password) { // and it doesn't match the cookie
|
||||||
$output = get_the_password_form();
|
$output = get_the_password_form();
|
||||||
|
@ -1449,7 +1490,7 @@ function comment_author_link() {
|
||||||
$author = stripslashes($comment->comment_author);
|
$author = stripslashes($comment->comment_author);
|
||||||
|
|
||||||
$url = str_replace('http://url', '', $url);
|
$url = str_replace('http://url', '', $url);
|
||||||
|
|
||||||
if (empty($url) && empty($email)) {
|
if (empty($url) && empty($email)) {
|
||||||
echo $author;
|
echo $author;
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue