]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/edit.php
Wordpress 2.7.1-scripts
[autoinstalls/wordpress.git] / wp-admin / edit.php
1 <?php
2 /**
3  * Edit Posts Administration Panel.
4  *
5  * @package WordPress
6  * @subpackage Administration
7  */
8
9 /** WordPress Administration Bootstrap */
10 require_once('admin.php');
11
12 // Back-compat for viewing comments of an entry
13 if ( $_redirect = intval( max( @$_GET['p'], @$_GET['attachment_id'], @$_GET['page_id'] ) ) ) {
14         wp_redirect( admin_url('edit-comments.php?p=' . $_redirect ) );
15         exit;
16 } else {
17         unset( $_redirect );
18 }
19
20 // Handle bulk actions
21 if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
22         $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
23
24         switch ( $doaction ) {
25                 case 'delete':
26                         if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) {
27                                 check_admin_referer('bulk-posts');
28                                 $deleted = 0;
29                                 foreach( (array) $_GET['post'] as $post_id_del ) {
30                                         $post_del = & get_post($post_id_del);
31
32                                         if ( !current_user_can('delete_post', $post_id_del) )
33                                                 wp_die( __('You are not allowed to delete this post.') );
34
35                                         if ( $post_del->post_type == 'attachment' ) {
36                                                 if ( ! wp_delete_attachment($post_id_del) )
37                                                         wp_die( __('Error in deleting...') );
38                                         } else {
39                                                 if ( !wp_delete_post($post_id_del) )
40                                                         wp_die( __('Error in deleting...') );
41                                         }
42                                         $deleted++;
43                                 }
44                         }
45                         break;
46                 case 'edit':
47                         if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) {
48                                 check_admin_referer('bulk-posts');
49
50                                 if ( -1 == $_GET['_status'] ) {
51                                         $_GET['post_status'] = null;
52                                         unset($_GET['_status'], $_GET['post_status']);
53                                 } else {
54                                         $_GET['post_status'] = $_GET['_status'];
55                                 }
56
57                                 $done = bulk_edit_posts($_GET);
58                         }
59                         break;
60         }
61
62         $sendback = wp_get_referer();
63         if ( strpos($sendback, 'post.php') !== false ) $sendback = admin_url('post-new.php');
64         elseif ( strpos($sendback, 'attachments.php') !== false ) $sendback = admin_url('attachments.php');
65         if ( isset($done) ) {
66                 $done['updated'] = count( $done['updated'] );
67                 $done['skipped'] = count( $done['skipped'] );
68                 $done['locked'] = count( $done['locked'] );
69                 $sendback = add_query_arg( $done, $sendback );
70         }
71         if ( isset($deleted) )
72                 $sendback = add_query_arg('deleted', $deleted, $sendback);
73         wp_redirect($sendback);
74         exit();
75 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
76          wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
77          exit;
78 }
79
80 if ( empty($title) )
81         $title = __('Edit Posts');
82 $parent_file = 'edit.php';
83 wp_enqueue_script('inline-edit-post');
84
85 list($post_stati, $avail_post_stati) = wp_edit_posts_query();
86
87 require_once('admin-header.php');
88
89 if ( !isset( $_GET['paged'] ) )
90         $_GET['paged'] = 1;
91
92 if ( empty($_GET['mode']) )
93         $mode = 'list';
94 else
95         $mode = attribute_escape($_GET['mode']); ?>
96
97 <div class="wrap">
98 <?php screen_icon(); ?>
99 <h2><?php echo wp_specialchars( $title );
100 if ( isset($_GET['s']) && $_GET['s'] )
101         printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', wp_specialchars( get_search_query() ) ); ?>
102 </h2>
103
104 <?php
105 if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
106 <div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?></a> | <a href="<?php echo get_edit_post_link( $_GET['posted'] ); ?>"><?php _e('Edit post'); ?></a></p></div>
107 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
108 endif; ?>
109
110 <?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) ) { ?>
111 <div id="message" class="updated fade"><p>
112 <?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
113         printf( __ngettext( '%s post updated.', '%s posts updated.', $_GET['updated'] ), number_format_i18n( $_GET['updated'] ) );
114         unset($_GET['updated']);
115 }
116
117 if ( isset($_GET['skipped']) && (int) $_GET['skipped'] )
118         unset($_GET['skipped']);
119
120 if ( isset($_GET['locked']) && (int) $_GET['locked'] ) {
121         printf( __ngettext( '%s post not updated, somebody is editing it.', '%s posts not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['locked'] ) );
122         unset($_GET['locked']);
123 }
124
125 if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
126         printf( __ngettext( 'Post deleted.', '%s posts deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
127         unset($_GET['deleted']);
128 }
129
130 $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted'), $_SERVER['REQUEST_URI'] );
131 ?>
132 </p></div>
133 <?php } ?>
134
135 <form id="posts-filter" action="" method="get">
136
137 <ul class="subsubsub">
138 <?php
139 if ( empty($locked_post_status) ) :
140 $status_links = array();
141 $num_posts = wp_count_posts( 'post', 'readable' );
142 $total_posts = array_sum( (array) $num_posts );
143 $class = empty( $_GET['post_status'] ) ? ' class="current"' : '';
144 $status_links[] = "<li><a href='edit.php' $class>" . sprintf( __ngettext( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts ), number_format_i18n( $total_posts ) ) . '</a>';
145
146
147 foreach ( $post_stati as $status => $label ) {
148         $class = '';
149
150         if ( !in_array( $status, $avail_post_stati ) )
151                 continue;
152
153         if ( empty( $num_posts->$status ) )
154                 continue;
155         if ( isset($_GET['post_status']) && $status == $_GET['post_status'] )
156                 $class = ' class="current"';
157
158         $status_links[] = "<li><a href='edit.php?post_status=$status' $class>" . sprintf( __ngettext( $label[2][0], $label[2][1], $num_posts->$status ), number_format_i18n( $num_posts->$status ) ) . '</a>';
159 }
160 echo implode( " |</li>\n", $status_links ) . '</li>';
161 unset( $status_links );
162 endif;
163 ?>
164 </ul>
165
166 <p class="search-box">
167         <label class="hidden" for="post-search-input"><?php _e( 'Search Posts' ); ?>:</label>
168         <input type="text" class="search-input" id="post-search-input" name="s" value="<?php the_search_query(); ?>" />
169         <input type="submit" value="<?php _e( 'Search Posts' ); ?>" class="button" />
170 </p>
171
172 <?php if ( isset($_GET['post_status'] ) ) : ?>
173 <input type="hidden" name="post_status" value="<?php echo attribute_escape($_GET['post_status']) ?>" />
174 <?php endif; ?>
175 <input type="hidden" name="mode" value="<?php echo $mode; ?>" />
176
177 <?php if ( have_posts() ) { ?>
178
179 <div class="tablenav">
180 <?php
181 $page_links = paginate_links( array(
182         'base' => add_query_arg( 'paged', '%#%' ),
183         'format' => '',
184         'prev_text' => __('&laquo;'),
185         'next_text' => __('&raquo;'),
186         'total' => $wp_query->max_num_pages,
187         'current' => $_GET['paged']
188 ));
189
190 ?>
191
192 <div class="alignleft actions">
193 <select name="action">
194 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
195 <option value="edit"><?php _e('Edit'); ?></option>
196 <option value="delete"><?php _e('Delete'); ?></option>
197 </select>
198 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
199 <?php wp_nonce_field('bulk-posts'); ?>
200
201 <?php // view filters
202 if ( !is_singular() ) {
203 $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC";
204
205 $arc_result = $wpdb->get_results( $arc_query );
206
207 $month_count = count($arc_result);
208
209 if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) {
210 $m = isset($_GET['m']) ? (int)$_GET['m'] : 0;
211 ?>
212 <select name='m'>
213 <option<?php selected( $m, 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
214 <?php
215 foreach ($arc_result as $arc_row) {
216         if ( $arc_row->yyear == 0 )
217                 continue;
218         $arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
219
220         if ( $arc_row->yyear . $arc_row->mmonth == $m )
221                 $default = ' selected="selected"';
222         else
223                 $default = '';
224
225         echo "<option$default value='$arc_row->yyear$arc_row->mmonth'>";
226         echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear";
227         echo "</option>\n";
228 }
229 ?>
230 </select>
231 <?php } ?>
232
233 <?php
234 $dropdown_options = array('show_option_all' => __('View all categories'), 'hide_empty' => 0, 'hierarchical' => 1,
235         'show_count' => 0, 'orderby' => 'name', 'selected' => $cat);
236 wp_dropdown_categories($dropdown_options);
237 do_action('restrict_manage_posts');
238 ?>
239 <input type="submit" id="post-query-submit" value="<?php _e('Filter'); ?>" class="button-secondary" />
240
241 <?php } ?>
242 </div>
243
244 <?php if ( $page_links ) { ?>
245 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
246         number_format_i18n( ( $_GET['paged'] - 1 ) * $wp_query->query_vars['posts_per_page'] + 1 ),
247         number_format_i18n( min( $_GET['paged'] * $wp_query->query_vars['posts_per_page'], $wp_query->found_posts ) ),
248         number_format_i18n( $wp_query->found_posts ),
249         $page_links
250 ); echo $page_links_text; ?></div>
251 <?php } ?>
252
253 <div class="view-switch">
254         <a href="<?php echo clean_url(add_query_arg('mode', 'list', $_SERVER['REQUEST_URI'])) ?>"><img <?php if ( 'list' == $mode ) echo 'class="current"'; ?> id="view-switch-list" src="../wp-includes/images/blank.gif" width="20" height="20" title="<?php _e('List View') ?>" alt="<?php _e('List View') ?>" /></a>
255         <a href="<?php echo clean_url(add_query_arg('mode', 'excerpt', $_SERVER['REQUEST_URI'])) ?>"><img <?php if ( 'excerpt' == $mode ) echo 'class="current"'; ?> id="view-switch-excerpt" src="../wp-includes/images/blank.gif" width="20" height="20" title="<?php _e('Excerpt View') ?>" alt="<?php _e('Excerpt View') ?>" /></a>
256 </div>
257
258 <div class="clear"></div>
259 </div>
260
261 <div class="clear"></div>
262
263 <?php include( 'edit-post-rows.php' ); ?>
264
265 <div class="tablenav">
266
267 <?php
268 if ( $page_links )
269         echo "<div class='tablenav-pages'>$page_links_text</div>";
270 ?>
271
272 <div class="alignleft actions">
273 <select name="action2">
274 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
275 <option value="edit"><?php _e('Edit'); ?></option>
276 <option value="delete"><?php _e('Delete'); ?></option>
277 </select>
278 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
279 <br class="clear" />
280 </div>
281 <br class="clear" />
282 </div>
283
284 <?php } else { // have_posts() ?>
285 <div class="clear"></div>
286 <p><?php _e('No posts found') ?></p>
287 <?php } ?>
288
289 </form>
290
291 <?php inline_edit_row( 'post' ); ?>
292
293 <div id="ajax-response"></div>
294
295 <br class="clear" />
296
297 </div>
298
299 <script type="text/javascript">
300 /* <![CDATA[ */
301 (function($){
302         $(document).ready(function(){
303                 $('#doaction, #doaction2').click(function(){
304                         if ( $('select[name^="action"]').val() == 'delete' ) {
305                                 var m = '<?php echo js_escape(__("You are about to delete the selected posts.\n  'Cancel' to stop, 'OK' to delete.")); ?>';
306                                 return showNotice.warn(m);
307                         }
308                 });
309         });
310 })(jQuery);
311 columns.init('edit');
312 /* ]]> */
313 </script>
314
315 <?php include('admin-footer.php'); ?>