]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/edit-attachment-rows.php
Wordpress 2.8.3-scripts
[autoinstalls/wordpress.git] / wp-admin / edit-attachment-rows.php
1 <?php
2 /**
3  * Edit attachments table for inclusion in administration panels.
4  *
5  * @package WordPress
6  * @subpackage Administration
7  */
8
9 // don't load directly
10 if ( !defined('ABSPATH') )
11         die('-1');
12
13 if ( have_posts() ) { ?>
14 <table class="widefat fixed" cellspacing="0">
15         <thead>
16         <tr>
17 <?php print_column_headers('upload'); ?>
18         </tr>
19         </thead>
20
21         <tfoot>
22         <tr>
23 <?php print_column_headers('upload', false); ?>
24         </tr>
25         </tfoot>
26
27         <tbody id="the-list" class="list:post">
28 <?php
29 add_filter('the_title','esc_html');
30 $alt = '';
31 $posts_columns = get_column_headers('upload');
32 $hidden = get_hidden_columns('upload');
33 while (have_posts()) : the_post();
34 $alt = ( 'alternate' == $alt ) ? '' : 'alternate';
35 global $current_user;
36 $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
37 $att_title = _draft_or_post_title();
38
39 ?>
40         <tr id='post-<?php echo $id; ?>' class='<?php echo trim( $alt . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top">
41
42 <?php
43 foreach ($posts_columns as $column_name => $column_display_name ) {
44         $class = "class=\"$column_name column-$column_name\"";
45
46         $style = '';
47         if ( in_array($column_name, $hidden) )
48                 $style = ' style="display:none;"';
49
50         $attributes = "$class$style";
51
52         switch($column_name) {
53
54         case 'cb':
55                 ?>
56                 <th scope="row" class="check-column"><input type="checkbox" name="media[]" value="<?php the_ID(); ?>" /></th>
57                 <?php
58                 break;
59
60         case 'icon':
61                 $attributes = 'class="column-icon media-icon"' . $style;
62                 ?>
63                 <td <?php echo $attributes ?>><?php
64                         if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) {
65 ?>
66
67                                 <a href="media.php?action=edit&amp;attachment_id=<?php the_ID(); ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $att_title)); ?>">
68                                         <?php echo $thumb; ?>
69                                 </a>
70
71 <?php                   }
72                 ?></td>
73                 <?php
74                 // TODO
75                 break;
76
77         case 'media':
78                 ?>
79                 <td <?php echo $attributes ?>><strong><a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $att_title)); ?>"><?php echo $att_title; ?></a></strong><br />
80                 <?php echo strtoupper(preg_replace('/^.*?\.(\w+)$/', '$1', get_attached_file($post->ID))); ?>
81                 <p>
82                 <?php
83                 $actions = array();
84                 if ( current_user_can('edit_post', $post->ID) )
85                         $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
86                 if ( current_user_can('delete_post', $post->ID) )
87                         $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . esc_js(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this attachment '%s'\n  'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this attachment '%s'\n  'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
88                 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
89                 $action_count = count($actions);
90                 $i = 0;
91                 echo '<div class="row-actions">';
92                 foreach ( $actions as $action => $link ) {
93                         ++$i;
94                         ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
95                         echo "<span class='$action'>$link$sep</span>";
96                 }
97                 echo '</div>';
98                 ?></p></td>
99                 <?php
100                 break;
101
102         case 'author':
103                 ?>
104                 <td <?php echo $attributes ?>><?php the_author() ?></td>
105                 <?php
106                 break;
107
108         case 'tags':
109                 ?>
110                 <td <?php echo $attributes ?>><?php
111                 $tags = get_the_tags();
112                 if ( !empty( $tags ) ) {
113                         $out = array();
114                         foreach ( $tags as $c )
115                                 $out[] = "<a href='edit.php?tag=$c->slug'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
116                         echo join( ', ', $out );
117                 } else {
118                         _e('No Tags');
119                 }
120                 ?></td>
121                 <?php
122                 break;
123
124         case 'desc':
125                 ?>
126                 <td <?php echo $attributes ?>><?php echo has_excerpt() ? $post->post_excerpt : ''; ?></td>
127                 <?php
128                 break;
129
130         case 'date':
131                 if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
132                         $t_time = $h_time = __('Unpublished');
133                 } else {
134                         $t_time = get_the_time(__('Y/m/d g:i:s A'));
135                         $m_time = $post->post_date;
136                         $time = get_post_time( 'G', true, $post, false );
137                         if ( ( abs($t_diff = time() - $time) ) < 86400 ) {
138                                 if ( $t_diff < 0 )
139                                         $h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
140                                 else
141                                         $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
142                         } else {
143                                 $h_time = mysql2date(__('Y/m/d'), $m_time);
144                         }
145                 }
146                 ?>
147                 <td <?php echo $attributes ?>><?php echo $h_time ?></td>
148                 <?php
149                 break;
150
151         case 'parent':
152                 if ( $post->post_parent > 0 ) {
153                         if ( get_post($post->post_parent) ) {
154                                 $title =_draft_or_post_title($post->post_parent);
155                         }
156                         ?>
157                         <td <?php echo $attributes ?>><strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>"><?php echo $title ?></a></strong>, <?php echo get_the_time(__('Y/m/d')); ?></td>
158                         <?php
159                 } else {
160                         ?>
161                         <td <?php echo $attributes ?>>&nbsp;</td>
162                         <?php
163                 }
164
165                 break;
166
167         case 'comments':
168                 $attributes = 'class="comments column-comments num"' . $style;
169                 ?>
170                 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
171                 <?php
172                 $left = get_pending_comments_num( $post->ID );
173                 $pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
174                 if ( $left )
175                         echo '<strong>';
176                 comments_number("<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>');
177                 if ( $left )
178                         echo '</strong>';
179                 ?>
180                 </div></td>
181                 <?php
182                 break;
183
184         case 'actions':
185                 ?>
186                 <td <?php echo $attributes ?>>
187                 <a href="media.php?action=edit&amp;attachment_id=<?php the_ID(); ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $att_title)); ?>"><?php _e('Edit'); ?></a> |
188                 <a href="<?php the_permalink(); ?>"><?php _e('Get permalink'); ?></a>
189                 </td>
190                 <?php
191                 break;
192
193         default:
194                 ?>
195                 <td <?php echo $attributes ?>><?php do_action('manage_media_custom_column', $column_name, $id); ?></td>
196                 <?php
197                 break;
198         }
199 }
200 ?>
201         </tr>
202 <?php endwhile; ?>
203         </tbody>
204 </table>
205 <?php } else { ?>
206
207 <p><?php _e('No media attachments found.') ?></p>
208
209 <?php
210 } // end if ( have_posts() )
211 ?>
212