From 600b71019494e1c29898a620e58c0d2602f37b74 Mon Sep 17 00:00:00 2001 From: donncha Date: Fri, 24 Nov 2006 16:16:44 +0000 Subject: WP Merge to 4524 git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@810 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-includes/classes.php | 115 ++++++++++++++++++++++++++---------------------- 1 file changed, 63 insertions(+), 52 deletions(-) (limited to 'wp-includes/classes.php') diff --git a/wp-includes/classes.php b/wp-includes/classes.php index aa19f3c..966e42e 100644 --- a/wp-includes/classes.php +++ b/wp-includes/classes.php @@ -1,7 +1,7 @@ public_query_vars[] = $qv; } @@ -96,7 +96,7 @@ class WP { preg_match("!^$match!", urldecode($request_match), $matches)) { // Got a match. $this->matched_rule = $match; - + // Trim the query of everything up to the '?'. $query = preg_replace("!^.+\?!", '', $query); @@ -178,16 +178,26 @@ class WP { @header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); } else { // We're showing a feed, so WP is indeed the only thing that last changed - if ( $this->query_vars['withcomments'] ) + if ( $this->query_vars['withcomments'] + || ( !$this->query_vars['withoutcomments'] + && ( $this->query_vars['p'] + || $this->query_vars['name'] + || $this->query_vars['page_id'] + || $this->query_vars['pagename'] + || $this->query_vars['attachment'] + || $this->query_vars['attachment_id'] + ) + ) + ) $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT'; - else + else $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT'; $wp_etag = '"' . md5($wp_last_modified) . '"'; @header("Last-Modified: $wp_last_modified"); @header("ETag: $wp_etag"); // Support for Conditional GET - if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) + if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) $client_etag = stripslashes(stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])); else $client_etag = false; @@ -249,8 +259,9 @@ class WP { } function query_posts() { + global $wp_the_query; $this->build_query_string(); - query_posts($this->query_vars); + $wp_the_query->query($this->query_vars); } function handle_404() { @@ -310,7 +321,7 @@ class WP_Error { if ( empty($codes) ) return ''; - return $codes[0]; + return $codes[0]; } function get_error_messages($code = '') { @@ -326,7 +337,7 @@ class WP_Error { if ( isset($this->errors[$code]) ) return $this->errors[$code]; else - return array(); + return array(); } function get_error_message($code = '') { @@ -370,29 +381,29 @@ function is_wp_error($thing) { // A class for displaying various tree-like structures. Extend the Walker class to use it, see examples at the bottom -class Walker { +class Walker { var $tree_type; var $db_fields; - + //abstract callbacks function start_lvl($output) { return $output; } function end_lvl($output) { return $output; } function start_el($output) { return $output; } function end_el($output) { return $output; } - + function walk($elements, $to_depth) { $args = array_slice(func_get_args(), 2); $parents = array(); $depth = 1; $previous_element = ''; $output = ''; - + //padding at the end $last_element->post_parent = 0; $last_element->post_id = 0; $elements[] = $last_element; - + $id_field = $this->db_fields['id']; $parent_field = $this->db_fields['parent']; - + $flat = ($to_depth == -1) ? true : false; - + foreach ( $elements as $element ) { // If flat, start and end the element and skip the level checks. if ( $flat) { @@ -432,7 +443,7 @@ class Walker { $cb_args = array_merge( array($output, $previous_element, $depth - 1), $args); $output = call_user_func_array(array(&$this, 'end_el'), $cb_args); } - + while ( $parent = array_shift($parents) ) { $depth--; if ( !$to_depth || ($depth < $to_depth) ) { @@ -452,7 +463,7 @@ class Walker { $output = call_user_func_array(array(&$this, 'end_el'), $cb_args); } } - + // Start the element. if ( !$to_depth || ($depth <= $to_depth) ) { if ( $element->$id_field != 0 ) { @@ -460,10 +471,10 @@ class Walker { $output = call_user_func_array(array(&$this, 'start_el'), $cb_args); } } - + $previous_element = $element; } - + return $output; } } @@ -471,19 +482,19 @@ class Walker { class Walker_Page extends Walker { var $tree_type = 'page'; var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this - + function start_lvl($output, $depth) { $indent = str_repeat("\t", $depth); $output .= "$indent\n"; return $output; } - + function start_el($output, $page, $depth, $current_page, $show_date, $date_format) { if ( $depth ) $indent = str_repeat("\t", $depth); @@ -519,45 +530,45 @@ class Walker_PageDropdown extends Walker { var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this function start_el($output, $page, $depth, $args) { - $pad = str_repeat(' ', $depth * 3); + $pad = str_repeat(' ', $depth * 3); - $output .= "\t\n"; + $output .= "\t\n"; - return $output; + return $output; } } class Walker_Category extends Walker { var $tree_type = 'category'; var $db_fields = array ('parent' => 'category_parent', 'id' => 'cat_ID'); //TODO: decouple this - + function start_lvl($output, $depth, $args) { if ( 'list' != $args['style'] ) return $output; - + $indent = str_repeat("\t", $depth); $output .= "$indent\n"; return $output; } - + function start_el($output, $category, $depth, $args) { extract($args); - + $link = 'category_description) ) $link .= 'title="'. sprintf(__("View all posts filed under %s"), wp_specialchars($category->cat_name, 1)) . '"'; @@ -565,24 +576,24 @@ class Walker_Category extends Walker { $link .= 'title="' . wp_specialchars(apply_filters('category_description',$category->category_description,$category),1) . '"'; $link .= '>'; $link .= apply_filters('list_cats', $category->cat_name, $category).''; - + if ( (! empty($feed_image)) || (! empty($feed)) ) { $link .= ' '; - + if ( empty($feed_image) ) $link .= '('; - + $link .= ''; else @@ -607,14 +618,14 @@ class Walker_Category extends Walker { } else { $output .= "\t$link
\n"; } - + return $output; } - + function end_el($output, $page, $depth, $args) { if ( 'list' != $args['style'] ) return $output; - + $output .= "\n"; return $output; } @@ -624,10 +635,10 @@ class Walker_Category extends Walker { class Walker_CategoryDropdown extends Walker { var $tree_type = 'category'; var $db_fields = array ('parent' => 'category_parent', 'id' => 'cat_ID'); //TODO: decouple this - - function start_el($output, $category, $depth, $args) { + + function start_el($output, $category, $depth, $args) { $pad = str_repeat(' ', $depth * 3); - + $cat_name = apply_filters('list_cats', $category->cat_name, $category); $output .= "\t\n"; - + return $output; } } @@ -688,7 +699,7 @@ class WP_Ajax_Response { $action = $_POST['action']; $x = ''; - $x .= ""; // The action attribute in the xml output is formatted like a nonce action + $x .= ""; // The action attribute in the xml output is formatted like a nonce action $x .= "<$what id='$id'" . ( false !== $old_id ? "old_id='$old_id'>" : '>' ); $x .= $response; $x .= $s; -- cgit