WordPress.org

Make WordPress Core

Changeset 7338


Ignore:
Timestamp:
03/16/2008 11:05:16 PM (10 years ago)
Author:
ryan
Message:

Better date editing from MarkJaquith. see #6250

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-advanced.php

    r7325 r7338  
    101101<?php
    102102if ($post_ID) {
    103 
    104     if ( 'future' == $post->post_status ) {
     103    if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
    105104        $stamp = __('Scheduled for:<br />%1$s at %2$s');
    106     } else if ( 'publish' == $post->post_status ) {
    107         $stamp = __('%1$s at %2$s');
    108     } else {
    109         $stamp = __('Saved on:<br />%1$s at %2$s');
     105    } else if ( 'publish' == $post->post_status ) { // already published
     106        $stamp = __('Published on:<br />%1$s at %2$s');
     107    } else if ( '0000-00-00 00:00:00' == $post->post_date ) { // draft, 1 or more saves, no date specified
     108        $stamp = __('Publish immediately');
     109    } else { // draft, 1 or more saves, date specified
     110        $stamp = __('Publish on:<br />%1$s at %2$s');
    110111    }
    111 
    112112    $date = mysql2date(get_option('date_format'), $post->post_date);
    113113    $time = mysql2date(get_option('time_format'), $post->post_date);
    114 } else {
    115     $stamp = __('%1$s at %2$s');
     114} else { // draft (no saves, and thus no date specified)
     115    $stamp = __('Publish immediately');
    116116    $date = mysql2date(get_option('date_format'), current_time('mysql'));
    117117    $time = mysql2date(get_option('time_format'), current_time('mysql'));
     
    143143<br class="clear" />
    144144<?php if ($post_ID): ?>
    145 <?php printf(__('Last edit: %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified)); ?>
     145<?php if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) {
     146    $last_user = get_userdata($last_id);
     147    printf(__('Last edited by %1$s on %2$s at %3$s'), wp_specialchars( $last_user->display_name ), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
     148} else {
     149    printf(__('Last edited on %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified));
     150}
     151?>
    146152<br class="clear" />
    147153<?php endif; ?>
  • trunk/wp-admin/includes/comment.php

    r7130 r7338  
    2121    $_POST['comment_content'] = $_POST['content'];
    2222    $_POST['comment_ID'] = (int) $_POST['comment_ID'];
     23
     24    foreach ( array ('aa', 'mm', 'jj', 'hh', 'mm') as $timeunit ) {
     25        if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) {
     26            $_POST['edit_date'] = '1';
     27            break;
     28        }
     29    }
     30
    2331
    2432    if (!empty ( $_POST['edit_date'] ) ) {
  • trunk/wp-admin/includes/post.php

    r7320 r7338  
    7474    if (!isset( $_POST['ping_status'] ))
    7575        $_POST['ping_status'] = 'closed';
     76
     77    foreach ( array ('aa', 'mm', 'jj', 'hh', 'mm') as $timeunit ) {
     78        if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) {
     79            $_POST['edit_date'] = '1';
     80            break;
     81        }
     82    }
    7683
    7784    if (!empty ( $_POST['edit_date'] ) ) {
     
    282289        $_POST['ping_status'] = 'closed';
    283290
     291    foreach ( array ('aa', 'mm', 'jj', 'hh', 'mm') as $timeunit ) {
     292        if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) {
     293            $_POST['edit_date'] = '1';
     294            break;
     295        }
     296    }
     297
    284298    if (!empty ( $_POST['edit_date'] ) ) {
    285299        $aa = $_POST['aa'];
  • trunk/wp-admin/includes/template.php

    r7329 r7338  
    831831        $tab_index_attribute = " tabindex=\"$tab_index\"";
    832832
    833     echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
     833    // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
    834834
    835835    $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
     
    842842    $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj );
    843843
    844     $month = "<select name=\"mm\" onchange=\"edit_date.checked=true\"$tab_index_attribute>\n";
     844    $month = "<select id=\"mm\" name=\"mm\" onchange=\"edit_date.checked=true\"$tab_index_attribute>\n";
    845845    for ( $i = 1; $i < 13; $i = $i +1 ) {
    846         $month .= "\t\t\t<option value=\"$i\"";
     846        $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';
    847847        if ( $i == $mm )
    848848            $month .= ' selected="selected"';
     
    851851    $month .= '</select>';
    852852
    853     $day = '<input type="text" id="jj" name="jj" value="' . $jj . '" size="2" maxlength="2" onchange="edit_date.checked=true"' . $tab_index_attribute . ' autocomplete="off"  />';
    854     $year = '<input type="text" id="aa" name="aa" value="' . $aa . '" size="4" maxlength="5" onchange="edit_date.checked=true"' . $tab_index_attribute . ' autocomplete="off"  />';
    855     $hour = '<input type="text" id="hh" name="hh" value="' . $hh . '" size="2" maxlength="2" onchange="edit_date.checked=true"' . $tab_index_attribute . ' autocomplete="off"  />';
    856     $minute = '<input type="text" id="mn" name="mn" value="' . $mn . '" size="2" maxlength="2" onchange="edit_date.checked=true"' . $tab_index_attribute . ' autocomplete="off"  />';
    857     printf(_c('%1$s%2$s%3$s @ %4$s : %5$s|1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input'), $month, $day, $year, $hour, $minute);
     853    $day = '<input type="text" id="jj" name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off"  />';
     854    $year = '<input type="text" id="aa" name="aa" value="' . $aa . '" size="4" maxlength="5"' . $tab_index_attribute . ' autocomplete="off"  />';
     855    $hour = '<input type="text" id="hh" name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off"  />';
     856    $minute = '<input type="text" id="mn" name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off"  />';
     857    printf(_c('%1$s%2$s, %3$s <br />@ %4$s : %5$s|1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input'), $month, $day, $year, $hour, $minute);
     858    echo "\n\n";
     859    foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit )
     860        echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
    858861?>
    859 <input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" onchange="edit_date.checked=true" />
     862
     863<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" />
    860864<?php
    861865}
  • trunk/wp-admin/js/post.js

    r7325 r7338  
    150150        if (jQuery('#timestampdiv').is(":hidden")) {
    151151            jQuery('#timestampdiv').slideDown("normal");
     152            jQuery('.edit-timestamp').text(postL10n.cancel);
    152153        } else {
    153154            jQuery('#timestampdiv').hide();
     155            jQuery('#mm').val(jQuery('#hidden_mm').val());
     156            jQuery('#jj').val(jQuery('#hidden_jj').val());
     157            jQuery('#aa').val(jQuery('#hidden_aa').val());
     158            jQuery('#hh').val(jQuery('#hidden_hh').val());
     159            jQuery('#mn').val(jQuery('#hidden_mn').val());
     160            jQuery('.edit-timestamp').text(postL10n.edit);
    154161        }
    155162        return false;
  • trunk/wp-includes/script-loader.php

    r7336 r7338  
    148148                'addTag' => attribute_escape(__('Add new tag')),
    149149                'separate' => __('Separate tags with commas'),
     150                'cancel' => __('Cancel'),
     151                'edit' => __('Edit'),
    150152            ) );
    151153            $this->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'postbox'), '20080208' );
Note: See TracChangeset for help on using the changeset viewer.