Changeset 6380 for trunk/wp-admin/includes/template.php
- Timestamp:
- 12/14/2007 06:20:42 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/template.php
r6363 r6380 226 226 } 227 227 228 function page_rows( $parent = 0, $level = 0, $pages = 0, $hierarchy = true ) { 229 global $class, $post; 230 231 if (!$pages ) 232 $pages = get_pages( 'sort_column=menu_order' ); 233 234 if (! $pages ) 235 return false; 236 237 foreach ( $pages as $post) { 238 setup_postdata( $post); 239 if ( $hierarchy && ($post->post_parent != $parent) ) 240 continue; 241 242 $post->post_title = wp_specialchars( $post->post_title ); 243 $pad = str_repeat( '— ', $level ); 244 $id = (int) $post->ID; 245 $class = ('alternate' == $class ) ? '' : 'alternate'; 228 /* 229 * display one row if the page doesn't have any children 230 * otherwise, display the row and its children in subsequent rows 231 */ 232 function display_page_row( $page, &$children_pages, $level = 0 ) { 233 global $post; 234 static $class; 235 236 $post = $page; 237 setup_postdata($page); 238 239 $page->post_title = wp_specialchars( $page->post_title ); 240 $pad = str_repeat( '— ', $level ); 241 $id = (int) $page->ID; 242 $class = ('alternate' == $class ) ? '' : 'alternate'; 243 246 244 ?> 247 245 <tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'> 248 <th scope="row" style="text-align: center"><?php echo $p ost->ID; ?></th>246 <th scope="row" style="text-align: center"><?php echo $page->ID; ?></th> 249 247 <td> 250 <?php echo $pad; ?><?php the_title() ?>248 <?php echo $pad; ?><?php the_title(); ?> 251 249 </td> 252 250 <td><?php the_author() ?></td> 253 <td><?php if ( '0000-00-00 00:00:00' ==$p ost->post_modified ) _e('Unpublished'); else echo mysql2date( __('Y-m-d g:i a'), $post->post_modified ); ?></td>251 <td><?php if ( '0000-00-00 00:00:00' ==$page->post_modified ) _e('Unpublished'); else echo mysql2date( __('Y-m-d g:i a'), $page->post_modified ); ?></td> 254 252 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e( 'View' ); ?></a></td> 255 253 <td><?php if ( current_user_can( 'edit_page', $id ) ) { echo "<a href='page.php?action=edit&post=$id' class='edit'>" . __( 'Edit' ) . "</a>"; } ?></td> … … 258 256 259 257 <?php 260 if ( $hierarchy ) 261 page_rows( $id, $level + 1, $pages ); 262 } 258 259 if ( ! $children_pages ) 260 return true; 261 262 for ( $i=0; $i < count($children_pages); $i++ ) { 263 264 $child = $children_pages[$i]; 265 266 if ( $child->post_parent == $id ) { 267 array_splice($children_pages, $i, 1); 268 display_page_row($child, $children_pages, $level+1); 269 $i--; 270 } 271 } 272 } 273 274 /* 275 * displays pages in hierarchical order 276 */ 277 function page_rows( $pages ) { 278 if ( ! $pages ) 279 $pages = get_pages( 'sort_column=menu_order' ); 280 281 if ( ! $pages ) 282 return false; 283 284 // splice pages into two parts: those without parent and those with parent 285 286 $top_level_pages = array(); 287 $children_pages = array(); 288 289 foreach ( $pages as $page ) { 290 if ( 0 == $page->post_parent ) 291 $top_level_pages[] = $page; 292 else 293 $children_pages[] = $page; 294 } 295 296 foreach ( $top_level_pages as $page ) 297 display_page_row($page, $children_pages, 0); 298 299 /* 300 * display the remaining children_pages which are orphans 301 * having orphan requires parental attention 302 */ 303 if ( count($children_pages) > 0 ) { 304 $empty_array = array(); 305 foreach ($children_pages as $orphan_page) 306 display_page_row($orphan_page, $empty_array, 0); 307 } 263 308 } 264 309 265 310 function user_row( $user_object, $style = '' ) { 266 if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) )311 if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) ) 267 312 $user_object = new WP_User( (int) $user_object ); 268 313 $email = $user_object->user_email;
Note: See TracChangeset
for help on using the changeset viewer.