root/branches/2.0/wp-admin/edit.php

Revision 4656, 8.1 kB (checked in by markjaquith, 1 year ago)

new function for escaping within attributes: attribute_escape()

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