diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-11-24 16:16:44 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-11-24 16:16:44 +0000 |
commit | 600b71019494e1c29898a620e58c0d2602f37b74 (patch) | |
tree | 21181d77ad4ebbcd42cd883e509c08a568d29514 /wp-includes/classes.php | |
parent | 7935d0bd9ef23d32ae29a95bd6c3ea0b6eab2973 (diff) | |
download | wordpress-mu-600b71019494e1c29898a620e58c0d2602f37b74.tar.gz wordpress-mu-600b71019494e1c29898a620e58c0d2602f37b74.tar.xz wordpress-mu-600b71019494e1c29898a620e58c0d2602f37b74.zip |
WP Merge to 4524
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@810 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/classes.php')
-rw-r--r-- | wp-includes/classes.php | 115 |
1 files changed, 63 insertions, 52 deletions
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 @@ <?php class WP { - 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', 'robots'); + var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', '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', 'robots'); var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type'); var $extra_query_vars = array(); @@ -12,7 +12,7 @@ class WP { var $matched_rule; var $matched_query; var $did_permalink = false; - + function add_query_var($qv) { $this->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<ul>\n"; return $output; } - + function end_lvl($output, $depth) { $indent = str_repeat("\t", $depth); $output .= "$indent</ul>\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<option value=\"$page->ID\""; - if ( $page->ID == $args['selected'] ) - $output .= ' selected="selected"'; - $output .= '>'; - $title = wp_specialchars($page->post_title); - $output .= "$pad$title"; - $output .= "</option>\n"; + $output .= "\t<option value=\"$page->ID\""; + if ( $page->ID == $args['selected'] ) + $output .= ' selected="selected"'; + $output .= '>'; + $title = wp_specialchars($page->post_title); + $output .= "$pad$title"; + $output .= "</option>\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<ul class='children'>\n"; return $output; } - + function end_lvl($output, $depth, $args) { if ( 'list' != $args['style'] ) return $output; - + $indent = str_repeat("\t", $depth); $output .= "$indent</ul>\n"; return $output; } - + function start_el($output, $category, $depth, $args) { extract($args); - + $link = '<a href="' . get_category_link($category->cat_ID) . '" '; if ( $use_desc_for_title == 0 || empty($category->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).'</a>'; - + if ( (! empty($feed_image)) || (! empty($feed)) ) { $link .= ' '; - + if ( empty($feed_image) ) $link .= '('; - + $link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"'; - + if ( !empty($feed) ) { $title = ' title="' . $feed . '"'; $alt = ' alt="' . $feed . '"'; $name = $feed; $link .= $title; } - + $link .= '>'; - + if ( !empty($feed_image) ) $link .= "<img src='$feed_image' $alt$title" . ' />'; else @@ -607,14 +618,14 @@ class Walker_Category extends Walker { } else { $output .= "\t$link<br />\n"; } - + return $output; } - + function end_el($output, $page, $depth, $args) { if ( 'list' != $args['style'] ) return $output; - + $output .= "</li>\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<option value=\"".$category->cat_ID."\""; if ( $category->cat_ID == $args['selected'] ) @@ -641,7 +652,7 @@ class Walker_CategoryDropdown extends Walker { $output .= ' ' . gmdate($format, $category->last_update_timestamp); } $output .= "</option>\n"; - + return $output; } } @@ -688,7 +699,7 @@ class WP_Ajax_Response { $action = $_POST['action']; $x = ''; - $x .= "<response action='$action_$id'>"; // The action attribute in the xml output is formatted like a nonce action + $x .= "<response action='{$action}_$id'>"; // 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; |