]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/edit-pages.php
Wordpress 2.6.2
[autoinstalls/wordpress.git] / wp-admin / edit-pages.php
1 <?php
2 require_once('admin.php');
3
4 // Handle bulk deletes
5 if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) {
6         check_admin_referer('bulk-pages');
7         foreach( (array) $_GET['delete'] as $post_id_del ) {
8                 $post_del = & get_post($post_id_del);
9
10                 if ( !current_user_can('delete_page', $post_id_del) )
11                         wp_die( __('You are not allowed to delete this page.') );
12
13                 if ( $post_del->post_type == 'attachment' ) {
14                         if ( ! wp_delete_attachment($post_id_del) )
15                                 wp_die( __('Error in deleting...') );
16                 } else {
17                         if ( !wp_delete_post($post_id_del) )
18                                 wp_die( __('Error in deleting...') );
19                 }
20         }
21
22         $sendback = wp_get_referer();
23         if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('page-new.php');
24         elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
25         $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
26
27         wp_redirect($sendback);
28         exit();
29 } elseif ( !empty($_GET['_wp_http_referer']) ) {
30          wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
31          exit;
32 }
33
34 $title = __('Pages');
35 $parent_file = 'edit.php';
36 wp_enqueue_script('admin-forms');
37
38 $post_stati  = array(   //      array( adj, noun )
39                 'publish' => array(__('Published'), __('Published pages'), __ngettext_noop('Published (%s)', 'Published (%s)')),
40                 'future' => array(__('Scheduled'), __('Scheduled pages'), __ngettext_noop('Scheduled (%s)', 'Scheduled (%s)')),
41                 'pending' => array(__('Pending Review'), __('Pending pages'), __ngettext_noop('Pending Review (%s)', 'Pending Review (%s)')),
42                 'draft' => array(__('Draft'), _c('Drafts|manage posts header'), __ngettext_noop('Draft (%s)', 'Drafts (%s)')),
43                 'private' => array(__('Private'), __('Private pages'), __ngettext_noop('Private (%s)', 'Private (%s)'))
44         );
45
46 $post_status_label = __('Manage Pages');
47 $post_status_q = '';
48 if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) {
49         $post_status_label = $post_stati[$_GET['post_status']][1];
50         $post_status_q = '&post_status=' . $_GET['post_status'];
51         $post_status_q .= '&perm=readable';
52 }
53
54 $query_str = "post_type=page&orderby=menu_order title&what_to_show=posts$post_status_q&posts_per_page=-1&posts_per_archive_page=-1&order=asc";
55
56 $query_str = apply_filters('manage_pages_query', $query_str);
57 wp($query_str);
58
59 if ( is_singular() )
60         wp_enqueue_script( 'admin-comments' );
61 require_once('admin-header.php');
62
63 ?>
64 <div class="wrap">
65 <form id="posts-filter" action="" method="get">
66 <h2><?php
67 // Use $_GET instead of is_ since they can override each other
68 $h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching &#8220;%s&#8221;'), wp_specialchars( stripslashes( $_GET['s'] ) ) ) : '';
69 $h2_author = '';
70 if ( isset($_GET['author']) && $_GET['author'] ) {
71         $author_user = get_userdata( (int) $_GET['author'] );
72         $h2_author = ' ' . sprintf(__('by %s'), wp_specialchars( $author_user->display_name ));
73 }
74 printf( _c( '%1$s%2$s%3$s|You can reorder these: 1: Pages, 2: by {s}, 3: matching {s}' ), $post_status_label, $h2_author, $h2_search );
75 ?></h2>
76
77 <ul class="subsubsub">
78 <?php
79
80 $avail_post_stati = get_available_post_statuses('page');
81
82 $status_links = array();
83 $num_posts = wp_count_posts('page', 'readable');
84 $class = empty($_GET['post_status']) ? ' class="current"' : '';
85 $status_links[] = "<li><a href=\"edit-pages.php\"$class>".__('All Pages')."</a>";
86 foreach ( $post_stati as $status => $label ) {
87         $class = '';
88
89         if ( !in_array($status, $avail_post_stati) )
90                 continue;
91
92         if ( $status == $_GET['post_status'] )
93                 $class = ' class="current"';
94
95         $status_links[] = "<li><a href=\"edit-pages.php?post_status=$status\"$class>" .
96         sprintf(__ngettext($label[2][0], $label[2][1], $num_posts->$status), number_format_i18n( $num_posts->$status ) ) . '</a>';
97 }
98 echo implode(' |</li>', $status_links) . '</li>';
99 unset($status_links);
100 ?>
101 </ul>
102
103 <?php if ( isset($_GET['post_status'] ) ) : ?>
104 <input type="hidden" name="post_status" value="<?php echo attribute_escape($_GET['post_status']) ?>" />
105 <?php
106 endif;
107 if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
108 <div id="message" class="updated fade"><p><strong><?php _e('Your page has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View page'); ?></a> | <a href="page.php?action=edit&amp;post=<?php echo $_GET['posted']; ?>"><?php _e('Edit page'); ?></a></p></div>
109 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
110 endif;
111 ?>
112
113 <p id="post-search">
114         <label class="hidden" for="post-search-input"><?php _e( 'Search Pages' ); ?>:</label>
115         <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" />
116         <input type="submit" value="<?php _e( 'Search Pages' ); ?>" class="button" />
117 </p>
118
119 <div class="tablenav">
120
121 <?php
122 $pagenum = absint( $_GET['pagenum'] );
123 if ( empty($pagenum) )
124         $pagenum = 1;
125 if( !$per_page || $per_page < 0 )
126         $per_page = 20;
127
128 $num_pages = ceil(count($posts) / $per_page);
129 $page_links = paginate_links( array(
130         'base' => add_query_arg( 'pagenum', '%#%' ),
131         'format' => '',
132         'total' => $num_pages,
133         'current' => $pagenum
134 ));
135
136 if ( $page_links )
137         echo "<div class='tablenav-pages'>$page_links</div>";
138 ?>
139
140 <div class="alignleft">
141 <input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" />
142 <?php wp_nonce_field('bulk-pages'); ?>
143 </div>
144
145 <br class="clear" />
146 </div>
147
148 <br class="clear" />
149
150 <?php
151
152 $all = !( $h2_search || $post_status_q );
153
154 if ($posts) {
155 ?>
156 <table class="widefat">
157   <thead>
158   <tr>
159 <?php $posts_columns = wp_manage_pages_columns(); ?>
160 <?php foreach($posts_columns as $post_column_key => $column_display_name) {
161         if ( 'cb' === $post_column_key )
162                 $class = ' class="check-column"';
163         elseif ( 'comments' === $post_column_key )
164                 $class = ' class="num"';
165         else
166                 $class = '';
167 ?>
168         <th scope="col"<?php echo $class; ?>><?php echo $column_display_name; ?></th>
169 <?php } ?>
170   </tr>
171   </thead>
172   <tbody>
173   <?php page_rows($posts, $pagenum, $per_page); ?>
174   </tbody>
175 </table>
176
177 </form>
178
179 <div id="ajax-response"></div>
180
181 <?php
182 } else {
183 ?>
184 </form>
185 <p><?php _e('No pages found.') ?></p>
186 <?php
187 } // end if ($posts)
188 ?>
189
190 <div class="tablenav">
191 <?php
192 if ( $page_links )
193         echo "<div class='tablenav-pages'>$page_links</div>";
194 ?>
195 <br class="clear" />
196 </div>
197
198 <?php
199
200 if ( 1 == count($posts) && is_singular() ) :
201
202         $comments = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved != 'spam' ORDER BY comment_date", $id) );
203         if ( $comments ) :
204                 // Make sure comments, post, and post_author are cached
205                 update_comment_cache($comments);
206                 $post = get_post($id);
207                 $authordata = get_userdata($post->post_author);
208         ?>
209
210 <br class="clear" />
211
212 <table class="widefat" style="margin-top: .5em">
213 <thead>
214   <tr>
215     <th scope="col"><?php _e('Comment') ?></th>
216     <th scope="col"><?php _e('Date') ?></th>
217     <th scope="col"><?php _e('Actions') ?></th>
218   </tr>
219 </thead>
220 <tbody id="the-comment-list" class="list:comment">
221 <?php
222         foreach ($comments as $comment)
223                 _wp_comment_row( $comment->comment_ID, 'detail', false, false );
224 ?>
225 </tbody>
226 </table>
227
228 <?php
229
230 endif; // comments
231 endif; // posts;
232
233 ?>
234
235 </div>
236
237 <?php include('admin-footer.php'); ?>