Changeset 3564
- Timestamp:
- 02/21/2006 08:39:58 AM (19 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-functions.php
r3563 r3564 644 644 } 645 645 646 function page_rows($parent = 0, $level = 0, $pages = 0 ) {646 function page_rows($parent = 0, $level = 0, $pages = 0, $hierarchy = true) { 647 647 global $wpdb, $class, $post; 648 648 649 if (!$pages) 649 650 $pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'page' ORDER BY menu_order"); 650 651 651 if ($pages) { 652 foreach ($pages as $post) { 653 start_wp(); 654 if ($post->post_parent == $parent) { 655 $post->post_title = wp_specialchars($post->post_title); 656 $pad = str_repeat('— ', $level); 657 $id = $post->ID; 658 $class = ('alternate' == $class) ? '' : 'alternate'; 652 if (! $pages) 653 return false; 654 655 foreach ($pages as $post) { 656 setup_postdata($post); 657 if ( $hierarchy && ($post->post_parent != $parent) ) 658 continue; 659 660 $post->post_title = wp_specialchars($post->post_title); 661 $pad = str_repeat('— ', $level); 662 $id = $post->ID; 663 $class = ('alternate' == $class) ? '' : 'alternate'; 659 664 ?> 660 665 <tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'> … … 671 676 672 677 <?php 673 674 page_rows($id, $level +1, $pages); 675 } 676 } 677 } else { 678 return false; 678 if ( $hierarchy) page_rows($id, $level + 1, $pages); 679 679 } 680 680 } -
trunk/wp-admin/edit-pages.php
r3563 r3564 20 20 21 21 <?php 22 wp('post_type=page&orderby=menu_order&what_to_show=posts&posts_per_page=15&posts_per_archive_page=-1'); 22 23 23 $show_post_type = 'page'; 24 25 if ( isset($_GET['s']) ) 26 wp(); 24 if ( $_GET['s'] ) 25 $all = false; 27 26 else 28 $ posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'page'");27 $all = true; 29 28 30 29 if ($posts) { … … 41 40 </tr> 42 41 <?php 43 if ( isset($_GET['s']) ) { 44 foreach ( $posts as $post ) : 45 $class = ('alternate' != $class) ? 'alternate' : ''; ?> 46 <tr id='page-<?php echo $post->ID; ?>' class='<?php echo $class; ?>'> 47 <th scope="row"><?php echo $post->ID; ?></th> 48 <td> 49 <?php echo $pad; ?><?php the_title() ?> 50 </td> 51 <td><?php the_author() ?></td> 52 <td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td> 53 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td> 54 <td><?php if ( current_user_can('edit_page', $post->ID) ) { echo "<a href='page.php?action=edit&post=$post->ID' class='edit'>" . __('Edit') . "</a>"; } ?></td> 55 <td><?php if ( current_user_can('delete_page', $post->ID) ) { echo "<a href='page.php?action=delete&post=$post->ID' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the "%s" page.\\n"OK" to delete, "Cancel" to stop."), wp_specialchars(get_the_title('','',0), 1)) . "' );\">" . __('Delete') . "</a>"; } ?></td> 56 </tr> 57 <?php 58 endforeach; 59 } else { 60 page_rows(); 61 } 42 page_rows(0, 0, $posts, $all); 62 43 ?> 63 44 </table> 64 45 65 46 <div id="ajax-response"></div> 47 48 <div class="navigation"> 49 <div class="alignleft"><?php next_posts_link(__('« Previous Entries')) ?></div> 50 <div class="alignright"><?php previous_posts_link(__('Next Entries »')) ?></div> 51 </div> 66 52 67 53 <?php -
trunk/wp-admin/edit.php
r3528 r3564 56 56 <h2> 57 57 <?php 58 $what_to_show = 'posts'; 59 $posts_per_page = 15; 60 $posts_per_archive_page = -1; 61 62 wp(); 58 59 wp('what_to_show=posts&posts_per_page=15&posts_per_archive_page=-1'); 63 60 64 61 if ( is_month() ) { -
trunk/wp-includes/classes.php
r3528 r3564 115 115 } elseif (!empty($qv['s'])) { 116 116 $this->is_search = true; 117 switch ($qv['show_post_type']) {118 case 'page' :119 $this->is_page = true;120 break;121 case 'attachment' :122 $this->is_attachment = true;123 break;124 }125 117 } else { 126 118 // Look for archive queries. Dates, categories, authors. … … 206 198 $this->is_archive = true; 207 199 } 208 209 if ( 'attachment' == $qv['show_post_type'] ) {210 $this->is_attachment = true;211 }212 200 } 213 201 … … 281 269 $join = ''; 282 270 271 if ( !isset($q['post_type']) ) 272 $q['post_type'] = 'post'; 273 $post_type = $q['post_type']; 283 274 if ( !isset($q['posts_per_page']) || $q['posts_per_page'] == 0 ) 284 275 $q['posts_per_page'] = get_settings('posts_per_page'); … … 551 542 // Order by 552 543 if (empty($q['orderby'])) { 553 $q['orderby'] ='date '.$q['order'];544 $q['orderby'] = 'post_date '.$q['order']; 554 545 } else { 555 546 // Used to filter values 556 $allowed_keys = array('author', 'date', 'category', 'title', 'modified' );547 $allowed_keys = array('author', 'date', 'category', 'title', 'modified', 'menu_order'); 557 548 $q['orderby'] = urldecode($q['orderby']); 558 549 $q['orderby'] = addslashes_gpc($q['orderby']); 559 550 $orderby_array = explode(' ',$q['orderby']); 560 if (!in_array($orderby_array[0],$allowed_keys)) { 561 $orderby_array[0] = 'date'; 562 } 563 $q['orderby'] = $orderby_array[0].' '.$q['order']; 564 if (count($orderby_array)>1) { 565 for ($i = 1; $i < (count($orderby_array)); $i = $i + 1) { 566 // Only allow certain values for safety 567 if (in_array($orderby_array[$i],$allowed_keys)) { 568 $q['orderby'] .= ',post_'.$orderby_array[$i].' '.$q['order']; 569 } 570 } 571 } 551 if ( empty($orderby_array) ) 552 $orderby_array[] = $q['orderby']; 553 $q['orderby'] = ''; 554 for ($i = 0; $i < count($orderby_array); $i++) { 555 // Only allow certain values for safety 556 $orderby = $orderby_array[$i]; 557 if ( 'menu_order' != $orderby ) 558 $orderby = 'post_' . $orderby; 559 if ( in_array($orderby_array[$i], $allowed_keys) ) 560 $q['orderby'] .= (($i == 0) ? '' : ',') . "$orderby {$q['order']}"; 561 } 562 if ( empty($q['orderby']) ) 563 $q['orderby'] = 'post_date '.$q['order']; 572 564 } 573 565 … … 588 580 $where .= ' AND (post_type = "post")'; 589 581 } else { 590 $where .= ' AND (post_type = "post" AND (post_status = "publish"';591 592 if ( $pagenow == 'post.php' || $pagenow == 'edit.php')593 $where .= " OR post_status = 'future' ";582 $where .= " AND (post_type = '$post_type' AND (post_status = 'publish'"; 583 584 if ( is_admin() ) 585 $where .= " OR post_status = 'future' OR post_status = 'draft'"; 594 586 else 595 587 $distinct = 'DISTINCT'; … … 637 629 $groupby = apply_filters('posts_groupby', $groupby); 638 630 $join = apply_filters('posts_join_paged', $join); 639 $orderby = "post_" . $q['orderby']; 640 $orderby = apply_filters('posts_orderby', $orderby); 631 $orderby = apply_filters('posts_orderby', $q['orderby']); 641 632 $request = " SELECT $distinct * FROM $wpdb->posts $join WHERE 1=1" . $where . " GROUP BY " . $groupby . " ORDER BY " . $orderby . " $limits"; 642 633 $this->request = apply_filters('posts_request', $request); … … 1449 1440 var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview'); 1450 1441 1451 var $private_query_vars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'show_post_type'); 1442 var $private_query_vars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type'); 1443 var $extra_query_vars = array(); 1452 1444 1453 1445 var $query_vars; … … 1464 1456 1465 1457 if (! empty($extra_query_vars)) 1466 parse_str($extra_query_vars, $extra_query_vars); 1467 else 1468 $extra_query_vars = array(); 1458 parse_str($extra_query_vars, $this->extra_query_vars); 1469 1459 1470 1460 // Process PATH_INFO, REQUEST_URI, and 404 for permalinks. … … 1540 1530 1541 1531 // Parse the query. 1542 parse_str($query, $ query_vars);1532 parse_str($query, $perma_query_vars); 1543 1533 1544 1534 // If we're processing a 404 request, clear the error var … … 1562 1552 unset($error); 1563 1553 1564 if ( isset($ query_vars) && strstr($_SERVER['PHP_SELF'], 'wp-admin/') )1565 unset($ query_vars);1554 if ( isset($perma_query_vars) && strstr($_SERVER['PHP_SELF'], 'wp-admin/') ) 1555 unset($perma_query_vars); 1566 1556 1567 1557 $this->did_permalink = false; … … 1573 1563 for ($i=0; $i<count($this->public_query_vars); $i += 1) { 1574 1564 $wpvar = $this->public_query_vars[$i]; 1575 if (isset($ extra_query_vars[$wpvar]))1576 $this->query_vars[$wpvar] = $ extra_query_vars[$wpvar];1565 if (isset($this->extra_query_vars[$wpvar])) 1566 $this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar]; 1577 1567 elseif (isset($GLOBALS[$wpvar])) 1578 1568 $this->query_vars[$wpvar] = $GLOBALS[$wpvar]; … … 1581 1571 elseif (!empty($_GET[$wpvar])) 1582 1572 $this->query_vars[$wpvar] = $_GET[$wpvar]; 1583 elseif (!empty($ query_vars[$wpvar]))1584 $this->query_vars[$wpvar] = $ query_vars[$wpvar];1573 elseif (!empty($perma_query_vars[$wpvar])) 1574 $this->query_vars[$wpvar] = $perma_query_vars[$wpvar]; 1585 1575 else 1586 1576 $this->query_vars[$wpvar] = ''; 1577 } 1578 1579 for ($i=0; $i<count($this->private_query_vars); $i += 1) { 1580 $wpvar = $this->private_query_vars[$i]; 1581 if (isset($this->extra_query_vars[$wpvar])) 1582 $this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar]; 1587 1583 } 1588 1584 … … 1633 1629 $this->query_string = ''; 1634 1630 1635 foreach ( $this->public_query_varsas $wpvar) {1636 if ( isset($this->query_vars[$wpvar]) && '' != $this->query_vars[$wpvar]) {1631 foreach (array_keys($this->query_vars) as $wpvar) { 1632 if ( '' != $this->query_vars[$wpvar] ) { 1637 1633 $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&'; 1638 1634 $this->query_string .= $wpvar . '=' . rawurlencode($this->query_vars[$wpvar]); … … 1641 1637 1642 1638 foreach ($this->private_query_vars as $wpvar) { 1643 if (isset($GLOBALS[$wpvar]) && '' != $GLOBALS[$wpvar] ) {1639 if (isset($GLOBALS[$wpvar]) && '' != $GLOBALS[$wpvar] && ! isset($this->extra_query_vars[$wpvar]) ) { 1644 1640 $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&'; 1645 1641 $this->query_string .= $wpvar . '=' . rawurlencode($GLOBALS[$wpvar]);
Note: See TracChangeset
for help on using the changeset viewer.