From 385677b9095ed3a2b4cd5922c243a5f560719511 Mon Sep 17 00:00:00 2001 From: ryan Date: Sun, 16 Mar 2008 23:05:16 +0000 Subject: [PATCH] Better date editing from MarkJaquith. see #6250 git-svn-id: http://svn.automattic.com/wordpress/trunk@7338 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-form-advanced.php | 26 ++++++++++++++++---------- wp-admin/includes/comment.php | 8 ++++++++ wp-admin/includes/post.php | 14 ++++++++++++++ wp-admin/includes/template.php | 22 +++++++++++++--------- wp-admin/js/post.js | 7 +++++++ wp-includes/script-loader.php | 2 ++ 6 files changed, 60 insertions(+), 19 deletions(-) diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 4f6e786691..5724ef5ce1 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -100,19 +100,19 @@ else

post_status ) { + if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date $stamp = __('Scheduled for:
%1$s at %2$s'); - } else if ( 'publish' == $post->post_status ) { - $stamp = __('%1$s at %2$s'); - } else { - $stamp = __('Saved on:
%1$s at %2$s'); + } else if ( 'publish' == $post->post_status ) { // already published + $stamp = __('Published on:
%1$s at %2$s'); + } else if ( '0000-00-00 00:00:00' == $post->post_date ) { // draft, 1 or more saves, no date specified + $stamp = __('Publish immediately'); + } else { // draft, 1 or more saves, date specified + $stamp = __('Publish on:
%1$s at %2$s'); } - $date = mysql2date(get_option('date_format'), $post->post_date); $time = mysql2date(get_option('time_format'), $post->post_date); -} else { - $stamp = __('%1$s at %2$s'); +} else { // draft (no saves, and thus no date specified) + $stamp = __('Publish immediately'); $date = mysql2date(get_option('date_format'), current_time('mysql')); $time = mysql2date(get_option('time_format'), current_time('mysql')); } @@ -142,7 +142,13 @@ if ( ( 'edit' == $action) && current_user_can('delete_post', $post_ID) ) ?>
-post_modified), mysql2date(get_option('time_format'), $post->post_modified)); ?> +display_name ), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified)); +} else { + 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)); +} +?>
diff --git a/wp-admin/includes/comment.php b/wp-admin/includes/comment.php index f5ee23ad1d..59bd9b6532 100644 --- a/wp-admin/includes/comment.php +++ b/wp-admin/includes/comment.php @@ -21,6 +21,14 @@ function edit_comment() { $_POST['comment_content'] = $_POST['content']; $_POST['comment_ID'] = (int) $_POST['comment_ID']; + foreach ( array ('aa', 'mm', 'jj', 'hh', 'mm') as $timeunit ) { + if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { + $_POST['edit_date'] = '1'; + break; + } + } + + if (!empty ( $_POST['edit_date'] ) ) { $aa = $_POST['aa']; $mm = $_POST['mm']; diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index eb43ae92d2..b4db0263a4 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -74,6 +74,13 @@ function edit_post() { if (!isset( $_POST['ping_status'] )) $_POST['ping_status'] = 'closed'; + foreach ( array ('aa', 'mm', 'jj', 'hh', 'mm') as $timeunit ) { + if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { + $_POST['edit_date'] = '1'; + break; + } + } + if (!empty ( $_POST['edit_date'] ) ) { $aa = $_POST['aa']; $mm = $_POST['mm']; @@ -281,6 +288,13 @@ function wp_write_post() { if (!isset( $_POST['ping_status'] )) $_POST['ping_status'] = 'closed'; + foreach ( array ('aa', 'mm', 'jj', 'hh', 'mm') as $timeunit ) { + if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { + $_POST['edit_date'] = '1'; + break; + } + } + if (!empty ( $_POST['edit_date'] ) ) { $aa = $_POST['aa']; $mm = $_POST['mm']; diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 7175012f29..44d034ca16 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -830,7 +830,7 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0 ) { if ( (int) $tab_index > 0 ) $tab_index_attribute = " tabindex=\"$tab_index\""; - echo '
'; + // echo '
'; $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 ); $post_date = ($for_post) ? $post->post_date : $comment->comment_date; @@ -841,22 +841,26 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0 ) { $mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj ); $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj ); - $month = "\n"; for ( $i = 1; $i < 13; $i = $i +1 ) { - $month .= "\t\t\t\n"; } $month .= ''; - $day = ''; - $year = ''; - $hour = ''; - $minute = ''; - 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); + $day = ''; + $year = ''; + $hour = ''; + $minute = ''; + 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); + echo "\n\n"; + foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) + echo '' . "\n"; ?> - + + attribute_escape(__('Add')), 'addTag' => attribute_escape(__('Add new tag')), 'separate' => __('Separate tags with commas'), + 'cancel' => __('Cancel'), + 'edit' => __('Edit'), ) ); $this->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'postbox'), '20080208' ); $this->add( 'link', '/wp-admin/js/link.js', array('jquery-ui-tabs', 'wp-lists', 'postbox'), '20080131' );