Allow the calendar start of week to be provisioned. get_calendar() patch from rq. Bug 32.
git-svn-id: http://svn.automattic.com/wordpress/trunk@1632 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
164fa8588e
commit
760af53e88
|
@ -47,7 +47,7 @@ include('options-head.php');
|
|||
<h2><?php _e('General Options') ?></h2>
|
||||
<form name="form1" method="post" action="options.php">
|
||||
<input type="hidden" name="action" value="update" />
|
||||
<input type="hidden" name="action" value="update" /> <input type="hidden" name="page_options" value="'blogname','blogdescription','siteurl','admin_email','users_can_register','new_users_can_blog','gmt_offset','date_format','time_format','home'" />
|
||||
<input type="hidden" name="action" value="update" /> <input type="hidden" name="page_options" value="'blogname','blogdescription','siteurl','admin_email','users_can_register','new_users_can_blog','gmt_offset','date_format','time_format','home','start_of_week'" />
|
||||
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
|
||||
<tr valign="top">
|
||||
<th width="33%" scope="row"><?php _e('Weblog title:') ?></th>
|
||||
|
@ -110,6 +110,19 @@ include('options-head.php');
|
|||
<td><input name="time_format" type="text" id="time_format" size="30" value="<?php form_option('time_format'); ?>" /><br />
|
||||
<?php _e('Output:') ?> <strong><?php echo gmdate(get_settings('time_format'), current_time('timestamp')); ?></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Weeks in the calendar should start on:') ?></th>
|
||||
<td><select name="start_of_week" id="start_of_week">
|
||||
<?php
|
||||
for ($day_index = 0; $day_index <= 6; $day_index++) :
|
||||
if ($day_index == get_settings('start_of_week')) $selected = " selected='selected'";
|
||||
else $selected = '';
|
||||
echo "\n\t<option value='$day_index' $selected>$weekday[$day_index]</option>";
|
||||
endfor;
|
||||
?>
|
||||
</select></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
</fieldset>
|
||||
|
|
|
@ -329,6 +329,12 @@ function get_archives($type='', $limit='', $format='html', $before = '', $after
|
|||
}
|
||||
}
|
||||
|
||||
// Used in get_calendar
|
||||
function calendar_week_mod($num) {
|
||||
$base = 7;
|
||||
return ($num - $base*floor($num/$base));
|
||||
}
|
||||
|
||||
function get_calendar($daylength = 1) {
|
||||
global $wpdb, $m, $monthnum, $year, $timedifference, $month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $posts;
|
||||
|
||||
|
@ -343,6 +349,8 @@ function get_calendar($daylength = 1) {
|
|||
$w = ''.intval($_GET['w']);
|
||||
}
|
||||
|
||||
// week_begins = 0 stands for sunday
|
||||
$week_begins = intval(get_settings('start_of_week'));
|
||||
$add_hours = intval(get_settings('gmt_offset'));
|
||||
$add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours));
|
||||
|
||||
|
@ -395,7 +403,13 @@ function get_calendar($daylength = 1) {
|
|||
$day_abbrev = $weekday_abbrev;
|
||||
}
|
||||
|
||||
foreach ($weekday as $wd) {
|
||||
$myweek = array();
|
||||
|
||||
for ($wdcount=0; $wdcount<=6; $wdcount++) {
|
||||
$myweek[]=$weekday[($wdcount+$week_begins)%7];
|
||||
}
|
||||
|
||||
foreach ($myweek as $wd) {
|
||||
echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">" . $day_abbrev[$wd] . '</th>';
|
||||
}
|
||||
|
||||
|
@ -477,7 +491,7 @@ function get_calendar($daylength = 1) {
|
|||
|
||||
|
||||
// See how much we should pad in the beginning
|
||||
$pad = intval(date('w', $unixmonth));
|
||||
$pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
|
||||
if (0 != $pad) echo "\n\t\t".'<td colspan="'.$pad.'" class="pad"> </td>';
|
||||
|
||||
$daysinmonth = intval(date('t', $unixmonth));
|
||||
|
@ -498,11 +512,11 @@ function get_calendar($daylength = 1) {
|
|||
}
|
||||
echo '</td>';
|
||||
|
||||
if (6 == date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear)))
|
||||
if (6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins))
|
||||
$newrow = true;
|
||||
}
|
||||
|
||||
$pad = 7 - date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear));
|
||||
$pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
|
||||
if ($pad != 0 && $pad != 7)
|
||||
echo "\n\t\t".'<td class="pad" colspan="'.$pad.'"> </td>';
|
||||
|
||||
|
|
Loading…
Reference in New Issue