root/tags/1_0-rc1/wp-admin/edit.php

Revision 550, 9.5 kB (checked in by donncha, 3 years ago)

WP Merge and new features

  • Property svn:eol-style set to native
Line 
1 <?php
2 require_once('admin.php');
3
4 $title = __('Posts');
5 $parent_file = 'edit.php';
6 wp_enqueue_script( 1 == $_GET['c'] ? 'admin-comments' : 'listman' );
7 require_once('admin-header.php');
8
9 $_GET['m'] = (int) $_GET['m'];
10
11 $drafts = get_users_drafts( $user_ID );
12 $other_drafts = get_others_drafts( $user_ID);
13
14 if ($drafts || $other_drafts) {
15 ?> 
16 <div class="wrap">
17 <?php if ($drafts) { ?>
18     <p><strong><?php _e('Your Drafts:') ?></strong>
19     <?php
20     $i = 0;
21     foreach ($drafts as $draft) {
22         if (0 != $i)
23             echo ', ';
24         $draft->post_title = stripslashes($draft->post_title);
25         if ($draft->post_title == '')
26             $draft->post_title = sprintf(__('Post #%s'), $draft->ID);
27         echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
28         ++$i;
29         }
30     ?>
31     .</p>
32 <?php } ?>
33
34 <?php if ($other_drafts) { ?> 
35     <p><strong><?php _e('Other&#8217;s Drafts:') ?></strong>
36     <?php
37     $i = 0;
38     foreach ($other_drafts as $draft) {
39         if (0 != $i)
40             echo ', ';
41         $draft->post_title = stripslashes($draft->post_title);
42         if ($draft->post_title == '')
43             $draft->post_title = sprintf(__('Post #%s'), $draft->ID);
44         echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
45         ++$i;
46         }
47     ?>
48     .</p>
49
50 <?php } ?>
51
52 </div>
53 <?php } ?>
54
55 <div class="wrap">
56 <h2>
57 <?php
58
59 wp('what_to_show=posts&posts_per_page=15&posts_per_archive_page=-1');
60
61 if ( is_month() ) {
62     single_month_title(' ');
63 } elseif ( is_search() ) {
64     printf(__('Search for &#8220;%s&#8221;'), wp_specialchars($_GET['s']) );
65 } else {
66     if ( is_single() )
67         printf(__('Comments on %s'), $post->post_title);
68     elseif ( ! is_paged() || get_query_var('paged') == 1 )
69         _e('Last 15 Posts');
70     else
71         _e('Previous Posts');
72 }
73 ?>
74 </h2>
75
76 <form name="searchform" action="" method="get" style="float: left; width: 16em; margin-right: 3em;">
77   <fieldset>
78   <legend><?php _e('Search Posts&hellip;') ?></legend>
79   <input type="text" name="s" value="<?php if (isset($s)) echo wp_specialchars($s, 1); ?>" size="17" />
80   <input type="submit" name="submit" value="<?php _e('Search') ?>"  />
81   </fieldset>
82 </form>
83
84 <?php $arc_result = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC");
85
86 if ( count($arc_result) ) { ?>
87
88 <form name="viewarc" action="" method="get" style="float: left; width: 20em; margin-bottom: 1em;">
89     <fieldset>
90     <legend><?php _e('Browse Month&hellip;') ?></legend>
91     <select name='m'>
92     <?php
93         foreach ($arc_result as $arc_row) {
94             if ( $arc_row->yyear == 0 )
95                 continue;
96             $arc_row->mmonth = zeroise($arc_row->mmonth, 2);
97
98             if( isset($_GET['m']) && $arc_row->yyear . $arc_row->mmonth == (int) $_GET['m'] )
99                 $default = 'selected="selected"';
100             else
101                 $default = null;
102
103             echo "<option $default value='$arc_row->yyear$arc_row->mmonth'>";
104             echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear";
105             echo "</option>\n";
106         }
107     ?>
108     </select>
109         <input type="submit" name="submit" value="<?php _e('Show Month') ?>"  />
110     </fieldset>
111 </form>
112
113 <?php } ?>
114
115 <br style="clear:both;" />
116
117 <?php
118 // define the columns to display, the syntax is 'internal name' => 'display name'
119 $posts_columns = array(
120   'id'         => __('ID'),
121   'date'       => __('When'),
122   'title'      => __('Title'),
123   'categories' => __('Categories'),
124   'comments'   => __('Comments'),
125   'author'     => __('Author')
126 );
127 $posts_columns = apply_filters('manage_posts_columns', $posts_columns);
128
129 // you can not edit these at the moment
130 $posts_columns['control_view']   = '';
131 $posts_columns['control_edit']   = '';
132 $posts_columns['control_delete'] = '';
133
134 ?>
135
136 <table class="widefat">
137     <thead>
138     <tr>
139
140 <?php foreach($posts_columns as $column_display_name) { ?>
141     <th scope="col"><?php echo $column_display_name; ?></th>
142 <?php } ?>
143
144     </tr>
145     </thead>
146     <tbody id="the-list">
147 <?php
148 if ($posts) {
149 $bgcolor = '';
150 foreach ($posts as $post) { start_wp();
151 add_filter('the_title','wp_specialchars');
152 $class = ('alternate' == $class) ? '' : 'alternate';
153 ?> 
154     <tr id='post-<?php echo $id; ?>' class='<?php echo $class; ?>'>
155
156 <?php
157
158 foreach($posts_columns as $column_name=>$column_display_name) {
159
160     switch($column_name) {
161
162     case 'id':
163         ?>
164         <th scope="row"><?php echo $id ?></th>
165         <?php
166         break;
167
168     case 'date':
169         ?>
170         <td><?php the_time('Y-m-d \<\b\r \/\> g:i:s a'); ?></td>
171         <?php
172         break;
173     case 'title':
174         ?>
175         <td><?php the_title() ?>
176         <?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?></td>
177         <?php
178         break;
179
180     case 'categories':
181         ?>
182         <td><?php the_category(','); ?></td>
183         <?php
184         break;
185
186     case 'comments':
187         ?>
188         <td style="text-align: center"><a href="edit.php?p=<?php echo $id ?>&amp;c=1">
189       <?php comments_number(__('0'), __('1'), __('%')) ?>
190       </a></td>
191         <?php
192         break;
193
194     case 'author':
195         ?>
196         <td><?php the_author() ?></td>
197         <?php
198         break;
199
200     case 'control_view':
201         ?>
202         <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
203         <?php
204         break;
205
206     case 'control_edit':
207         ?>
208         <td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
209         <?php
210         break;
211
212     case 'control_delete':
213         ?>
214         <td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $post->ID) . "' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . sprintf(__("You are about to delete this post &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), js_escape(get_the_title()) ) . "' );\">" . __('Delete') . "</a>"; } ?></td>
215         <?php
216         break;
217
218     default:
219         ?>
220         <td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td>
221         <?php
222         break;
223     }
224 }
225 ?>
226     </tr>
227 <?php
228 }
229 } else {
230 ?>
231   <tr style='background-color: <?php echo $bgcolor; ?>'>
232     <td colspan="8"><?php _e('No posts found.') ?></td>
233   </tr>
234 <?php
235 } // end if ($posts)
236 ?>
237     </tbody>
238 </table>
239
240 <div id="ajax-response"></div>
241
242 <div class="navigation">
243 <div class="alignleft"><?php next_posts_link(__('&laquo; Previous Entries')) ?></div>
244 <div class="alignright"><?php previous_posts_link(__('Next Entries &raquo;')) ?></div>
245 </div>
246
247 <?php
248 if ( 1 == count($posts) ) {
249
250     $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date");
251     if ($comments) {
252     ?>
253 <h3 id="comments"><?php _e('Comments') ?></h3>
254 <ol id="the-comment-list" class="commentlist">
255 <?php
256 $i = 0;
257 foreach ($comments as $comment) {
258
259         ++$i; $class = '';
260         $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
261             $comment_status = wp_get_comment_status($comment->comment_ID);
262             if ('unapproved' == $comment_status)
263                 $class .= ' unapproved';
264             if ($i % 2)
265                 $class .= ' alternate';
266             echo "<li id='comment-$comment->comment_ID' class='$class'>";
267 ?>
268 <p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
269
270 <?php comment_text() ?>
271
272 <p><?php comment_date('M j, g:i A');  ?> &#8212; [
273 <?php
274 if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
275     echo " <a href='comment.php?action=editcomment&amp;comment=".$comment->comment_ID."\'>" __('Edit') . '</a>';
276     echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape($comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> ';
277     if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
278         echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>';
279         echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>';
280     }
281     echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&amp;delete_type=spam&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . sprintf(__("You are about to mark as spam this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to mark as spam."), js_escape( $comment->comment_author))  . "', theCommentList );\">" . __('Spam') . "</a> ]";
282 } // end if any comments to show
283 ?>
284 </p>
285         </li>
286
287 <?php //end of the loop, don't delete
288         } // end foreach
289     echo '</ol>';
290     }//end if comments
291     ?>
292 <?php } ?> 
293 </div>
294 <?php
295  include('admin-footer.php');
296 ?> 
297
Note: See TracBrowser for help on using the browser.