From 3a4570b0fc8b3d6339bef71d17d7701554e0bbf7 Mon Sep 17 00:00:00 2001 From: donncha Date: Fri, 12 Oct 2007 16:21:15 +0000 Subject: Merge with WP 2.3 - testing use only! Move pluggable functions out of wpmu-functions and into pluggable.php, fixes #439 git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1069 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-includes/atomlib.php | 313 ++ wp-includes/author-template.php | 244 +- wp-includes/bookmark-template.php | 301 +- wp-includes/bookmark.php | 116 +- wp-includes/cache.php | 22 +- wp-includes/canonical.php | 201 ++ wp-includes/capabilities.php | 24 +- wp-includes/category-template.php | 339 +- wp-includes/category.php | 334 +- wp-includes/class-phpmailer.php | 190 +- wp-includes/class-pop3.php | 99 +- wp-includes/classes.php | 68 +- wp-includes/comment-template.php | 24 +- wp-includes/comment.php | 132 +- wp-includes/compat.php | 48 +- wp-includes/cron.php | 10 +- wp-includes/default-filters.php | 220 +- wp-includes/deprecated.php | 327 +- wp-includes/feed-atom-comments.php | 3 +- wp-includes/feed-atom.php | 10 +- wp-includes/feed-rdf.php | 8 +- wp-includes/feed-rss.php | 4 +- wp-includes/feed-rss2-comments.php | 13 +- wp-includes/feed-rss2.php | 4 +- wp-includes/feed.php | 65 +- wp-includes/formatting.php | 92 +- wp-includes/functions.php | 427 +-- wp-includes/general-template.php | 157 +- wp-includes/js/jquery/jquery.js | 14 +- wp-includes/js/prototype.js | 1446 ++++++-- wp-includes/js/scriptaculous/MIT-LICENSE | 2 +- wp-includes/js/scriptaculous/builder.js | 19 +- wp-includes/js/scriptaculous/controls.js | 78 +- wp-includes/js/scriptaculous/dragdrop.js | 56 +- wp-includes/js/scriptaculous/effects.js | 126 +- wp-includes/js/scriptaculous/prototype.js | 1446 ++++++-- wp-includes/js/scriptaculous/scriptaculous.js | 22 +- wp-includes/js/scriptaculous/slider.js | 7 +- wp-includes/js/scriptaculous/sound.js | 60 + wp-includes/js/scriptaculous/unittest.js | 10 +- wp-includes/js/scriptaculous/wp-scriptaculous.js | 29 +- wp-includes/js/tinymce/license.html | 465 --- .../tinymce/plugins/inlinepopups/editor_plugin.js | 17 +- .../tinymce/plugins/spellchecker/editor_plugin.js | 632 +++- .../js/tinymce/plugins/spellchecker/tinyspell.php | 42 +- .../js/tinymce/plugins/wordpress/langs/en.js | 7 +- .../js/tinymce/themes/advanced/editor_template.js | 102 +- wp-includes/js/tinymce/themes/advanced/image.htm | 16 +- .../themes/advanced/jscripts/color_picker.js | 15 +- .../js/tinymce/themes/advanced/jscripts/link.js | 14 +- wp-includes/js/tinymce/themes/advanced/langs/en.js | 8 +- wp-includes/js/tinymce/themes/advanced/link.htm | 5 +- .../js/tinymce/themes/advanced/source_editor.htm | 4 +- wp-includes/js/tinymce/tiny_mce.js | 3577 ++++++++++---------- wp-includes/js/tinymce/tiny_mce_config.php | 4 +- wp-includes/js/tinymce/tiny_mce_popup.js | 54 +- wp-includes/js/tinymce/wp-mce-help.php | 8 +- wp-includes/kses.php | 272 +- wp-includes/link-template.php | 254 +- wp-includes/locale.php | 12 + wp-includes/pluggable.php | 344 +- wp-includes/plugin.php | 100 +- wp-includes/post-template.php | 105 +- wp-includes/post.php | 692 ++-- wp-includes/query.php | 361 +- wp-includes/registration.php | 75 +- wp-includes/rewrite.php | 67 +- wp-includes/rss.php | 51 +- wp-includes/script-loader.php | 128 +- wp-includes/taxonomy.php | 1410 ++++++++ wp-includes/template-loader.php | 7 +- wp-includes/theme.php | 94 +- wp-includes/update.php | 54 + wp-includes/user.php | 77 +- wp-includes/version.php | 6 +- wp-includes/widgets.php | 311 +- wp-includes/wp-db.php | 36 +- wp-includes/wpmu-functions.php | 304 +- 78 files changed, 10995 insertions(+), 5845 deletions(-) create mode 100644 wp-includes/atomlib.php create mode 100644 wp-includes/canonical.php create mode 100644 wp-includes/js/scriptaculous/sound.js delete mode 100644 wp-includes/js/tinymce/license.html create mode 100644 wp-includes/taxonomy.php create mode 100644 wp-includes/update.php (limited to 'wp-includes') diff --git a/wp-includes/atomlib.php b/wp-includes/atomlib.php new file mode 100644 index 0000000..a518908 --- /dev/null +++ b/wp-includes/atomlib.php @@ -0,0 +1,313 @@ + + * Version: 0.4 + * + */ + +class AtomFeed { + var $links = array(); + var $categories = array(); + + var $entries = array(); +} + +class AtomEntry { + var $links = array(); + var $categories = array(); +} + +class AtomParser { + + var $NS = 'http://www.w3.org/2005/Atom'; + var $ATOM_CONTENT_ELEMENTS = array('content','summary','title','subtitle','rights'); + var $ATOM_SIMPLE_ELEMENTS = array('id','updated','published','draft'); + + var $debug = false; + + var $depth = 0; + var $indent = 2; + var $in_content; + var $ns_contexts = array(); + var $ns_decls = array(); + var $content_ns_decls = array(); + var $content_ns_contexts = array(); + var $is_xhtml = false; + var $is_html = false; + var $is_text = true; + var $skipped_div = false; + + var $FILE = "php://input"; + + var $feed; + var $current; + + function AtomParser() { + + $this->feed = new AtomFeed(); + $this->current = null; + $this->map_attrs_func = create_function('$k,$v', 'return "$k=\"$v\"";'); + $this->map_xmlns_func = create_function('$p,$n', '$xd = "xmlns"; if(strlen($n[0])>0) $xd .= ":{$n[0]}"; return "{$xd}=\"{$n[1]}\"";'); + } + + function _p($msg) { + if($this->debug) { + print str_repeat(" ", $this->depth * $this->indent) . $msg ."\n"; + } + } + + function error_handler($log_level, $log_text, $error_file, $error_line) { + $this->error = $log_text; + } + + function parse() { + + set_error_handler(array(&$this, 'error_handler')); + + array_unshift($this->ns_contexts, array()); + + $parser = xml_parser_create_ns(); + xml_set_object($parser, $this); + xml_set_element_handler($parser, "start_element", "end_element"); + xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); + xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,0); + xml_set_character_data_handler($parser, "cdata"); + xml_set_default_handler($parser, "_default"); + xml_set_start_namespace_decl_handler($parser, "start_ns"); + xml_set_end_namespace_decl_handler($parser, "end_ns"); + + $this->content = ''; + + $ret = true; + + $fp = fopen($this->FILE, "r"); + while ($data = fread($fp, 4096)) { + if($this->debug) $this->content .= $data; + + if(!xml_parse($parser, $data, feof($fp))) { + trigger_error(sprintf(__('XML error: %s at line %d')."\n", + xml_error_string(xml_get_error_code($xml_parser)), + xml_get_current_line_number($xml_parser))); + $ret = false; + break; + } + } + fclose($fp); + + xml_parser_free($parser); + + restore_error_handler(); + + return $ret; + } + + function start_element($parser, $name, $attrs) { + + $tag = array_pop(split(":", $name)); + + switch($name) { + case $this->NS . ':feed': + $this->current = $this->feed; + break; + case $this->NS . ':entry': + $this->current = new AtomEntry(); + break; + }; + + $this->_p("start_element('$name')"); + #$this->_p(print_r($this->ns_contexts,true)); + #$this->_p('current(' . $this->current . ')'); + + array_unshift($this->ns_contexts, $this->ns_decls); + + $this->depth++; + + if(!empty($this->in_content)) { + + $this->content_ns_decls = array(); + + if($this->is_html || $this->is_text) + trigger_error("Invalid content in element found. Content must not be of type text or html if it contains markup."); + + $attrs_prefix = array(); + + // resolve prefixes for attributes + foreach($attrs as $key => $value) { + $with_prefix = $this->ns_to_prefix($key, true); + $attrs_prefix[$with_prefix[1]] = $this->xml_escape($value); + } + + $attrs_str = join(' ', array_map($this->map_attrs_func, array_keys($attrs_prefix), array_values($attrs_prefix))); + if(strlen($attrs_str) > 0) { + $attrs_str = " " . $attrs_str; + } + + $with_prefix = $this->ns_to_prefix($name); + + if(!$this->is_declared_content_ns($with_prefix[0])) { + array_push($this->content_ns_decls, $with_prefix[0]); + } + + $xmlns_str = ''; + if(count($this->content_ns_decls) > 0) { + array_unshift($this->content_ns_contexts, $this->content_ns_decls); + $xmlns_str .= join(' ', array_map($this->map_xmlns_func, array_keys($this->content_ns_contexts[0]), array_values($this->content_ns_contexts[0]))); + if(strlen($xmlns_str) > 0) { + $xmlns_str = " " . $xmlns_str; + } + } + + array_push($this->in_content, array($tag, $this->depth, "<". $with_prefix[1] ."{$xmlns_str}{$attrs_str}" . ">")); + + } else if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS) || in_array($tag, $this->ATOM_SIMPLE_ELEMENTS)) { + $this->in_content = array(); + $this->is_xhtml = $attrs['type'] == 'xhtml'; + $this->is_html = $attrs['type'] == 'html' || $attrs['type'] == 'text/html'; + $this->is_text = !in_array('type',array_keys($attrs)) || $attrs['type'] == 'text'; + $type = $this->is_xhtml ? 'XHTML' : ($this->is_html ? 'HTML' : ($this->is_text ? 'TEXT' : $attrs['type'])); + + if(in_array('src',array_keys($attrs))) { + $this->current->$tag = $attrs; + } else { + array_push($this->in_content, array($tag,$this->depth, $type)); + } + } else if($tag == 'link') { + array_push($this->current->links, $attrs); + } else if($tag == 'category') { + array_push($this->current->categories, $attrs); + } + + $this->ns_decls = array(); + } + + function end_element($parser, $name) { + + $tag = array_pop(split(":", $name)); + + $ccount = count($this->in_content); + + # if we are *in* content, then let's proceed to serialize it + if(!empty($this->in_content)) { + # if we are ending the original content element + # then let's finalize the content + if($this->in_content[0][0] == $tag && + $this->in_content[0][1] == $this->depth) { + $origtype = $this->in_content[0][2]; + array_shift($this->in_content); + $newcontent = array(); + foreach($this->in_content as $c) { + if(count($c) == 3) { + array_push($newcontent, $c[2]); + } else { + if($this->is_xhtml || $this->is_text) { + array_push($newcontent, $this->xml_escape($c)); + } else { + array_push($newcontent, $c); + } + } + } + if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS)) { + $this->current->$tag = array($origtype, join('',$newcontent)); + } else { + $this->current->$tag = join('',$newcontent); + } + $this->in_content = array(); + } else if($this->in_content[$ccount-1][0] == $tag && + $this->in_content[$ccount-1][1] == $this->depth) { + $this->in_content[$ccount-1][2] = substr($this->in_content[$ccount-1][2],0,-1) . "/>"; + } else { + # else, just finalize the current element's content + $endtag = $this->ns_to_prefix($name); + array_push($this->in_content, array($tag, $this->depth, "")); + } + } + + array_shift($this->ns_contexts); + + $this->depth--; + + if($name == ($this->NS . ':entry')) { + array_push($this->feed->entries, $this->current); + $this->current = null; + } + + $this->_p("end_element('$name')"); + } + + function start_ns($parser, $prefix, $uri) { + $this->_p("starting: " . $prefix . ":" . $uri); + array_push($this->ns_decls, array($prefix,$uri)); + } + + function end_ns($parser, $prefix) { + $this->_p("ending: #" . $prefix . "#"); + } + + function cdata($parser, $data) { + $this->_p("data: #" . str_replace(array("\n"), array("\\n"), trim($data)) . "#"); + if(!empty($this->in_content)) { + array_push($this->in_content, $data); + } + } + + function _default($parser, $data) { + # when does this gets called? + } + + + function ns_to_prefix($qname, $attr=false) { + # split 'http://www.w3.org/1999/xhtml:div' into ('http','//www.w3.org/1999/xhtml','div') + $components = split(":", $qname); + + # grab the last one (e.g 'div') + $name = array_pop($components); + + if(!empty($components)) { + # re-join back the namespace component + $ns = join(":",$components); + foreach($this->ns_contexts as $context) { + foreach($context as $mapping) { + if($mapping[1] == $ns && strlen($mapping[0]) > 0) { + return array($mapping, "$mapping[0]:$name"); + } + } + } + } + + if($attr) { + return array(null, $name); + } else { + foreach($this->ns_contexts as $context) { + foreach($context as $mapping) { + if(strlen($mapping[0]) == 0) { + return array($mapping, $name); + } + } + } + } + } + + function is_declared_content_ns($new_mapping) { + foreach($this->content_ns_contexts as $context) { + foreach($context as $mapping) { + if($new_mapping == $mapping) { + return true; + } + } + } + return false; + } + + function xml_escape($string) + { + return str_replace(array('&','"',"'",'<','>'), + array('&','"',''','<','>'), + $string ); + } +} + +?> diff --git a/wp-includes/author-template.php b/wp-includes/author-template.php index cc67faf..57bc3a9 100644 --- a/wp-includes/author-template.php +++ b/wp-includes/author-template.php @@ -1,86 +1,191 @@ display_name); } -// Using echo = false is deprecated. Use get_the_author instead. +/** + * Echo the name of the author of the current post in the Loop. + * @see get_the_author() + * @param string $deprecated Deprecated. + * @param string $deprecated_echo Echo the string or return it. Deprecated, use get_the_author(). + * @return string The author's display name, from get_the_author(). + */ function the_author($deprecated = '', $deprecated_echo = true) { if ( $deprecated_echo ) echo get_the_author(); return get_the_author(); } +/** + * Get the description of the author of the current post in the Loop. + * @global object $authordata The current author's DB object. + * @return string The author's description. + */ function get_the_author_description() { global $authordata; return $authordata->description; } + +/** + * Echo the description of the author of the current post in the Loop. + * @see get_the_author_description() + * @return null + */ function the_author_description() { echo get_the_author_description(); } +/** + * Get the login name of the author of the current post in the Loop. + * @global object $authordata The current author's DB object. + * @return string The author's login name (username). + */ function get_the_author_login() { global $authordata; return $authordata->user_login; } +/** + * Echo the login name of the author of the current post in the Loop. + * @see get_the_author_login() + * @return null + */ function the_author_login() { echo get_the_author_login(); } +/** + * Get the first name of the author of the current post in the Loop. + * @global object $authordata The current author's DB object. + * @return string The author's first name. + */ function get_the_author_firstname() { global $authordata; return $authordata->first_name; } + +/** + * Echo the first name of the author of the current post in the Loop. + * @see get_the_author_firstname() + * @return null + */ function the_author_firstname() { echo get_the_author_firstname(); } +/** + * Get the last name of the author of the current post in the Loop. + * @global object $authordata The current author's DB object. + * @return string The author's last name. + */ function get_the_author_lastname() { global $authordata; return $authordata->last_name; } +/** + * Echo the last name of the author of the current post in the Loop. + * @see get_the_author_lastname() + * @return null + */ function the_author_lastname() { echo get_the_author_lastname(); } +/** + * Get the nickname of the author of the current post in the Loop. + * @global object $authordata The current author's DB object. + * @return string The author's nickname. + */ function get_the_author_nickname() { global $authordata; return $authordata->nickname; } +/** + * Echo the nickname of the author of the current post in the Loop. + * @see get_the_author_nickname() + * @return null + */ function the_author_nickname() { echo get_the_author_nickname(); } +/** + * Get the ID of the author of the current post in the Loop. + * @global object $authordata The current author's DB object. + * @return int The author's ID. + */ function get_the_author_ID() { global $authordata; - return $authordata->ID; + return (int) $authordata->ID; } + +/** + * Echo the ID of the author of the current post in the Loop. + * @see get_the_author_ID() + * @return null + */ function the_author_ID() { echo get_the_author_id(); } +/** + * Get the email of the author of the current post in the Loop. + * @global object $authordata The current author's DB object. + * @return string The author's username. + */ function get_the_author_email() { global $authordata; return $authordata->user_email; } +/** + * Echo the email of the author of the current post in the Loop. + * @see get_the_author_email() + * @return null + */ function the_author_email() { echo apply_filters('the_author_email', get_the_author_email() ); } +/** + * Get the URL to the home page of the author of the current post in the Loop. + * @global object $authordata The current author's DB object. + * @return string The URL to the author's page. + */ function get_the_author_url() { global $authordata; + + if ( 'http://' == $authordata->user_url ) + return ''; + return $authordata->user_url; } +/** + * Echo the URL to the home page of the author of the current post in the Loop. + * @see get_the_author_url() + * @return null + */ function the_author_url() { echo get_the_author_url(); } +/** + * If the author has a home page set, echo an HTML link, otherwise just echo the author's name. + * @see get_the_author_url() + * @see the_author() + * @return null + */ function the_author_link() { if (get_the_author_url()) { echo '' . get_the_author() . ''; @@ -89,61 +194,129 @@ function the_author_link() { } } +/** + * Get the ICQ number of the author of the current post in the Loop. + * @global object $authordata The current author's DB object. + * @return string The author's ICQ number. + */ function get_the_author_icq() { global $authordata; return $authordata->icq; } +/** + * Echo the ICQ number of the author of the current post in the Loop. + * @see get_the_author_icq() + * @return null + */ function the_author_icq() { echo get_the_author_icq(); } +/** + * Get the AIM name of the author of the current post in the Loop. + * @global object $authordata The current author's DB object. + * @return string The author's AIM name. + */ function get_the_author_aim() { global $authordata; return str_replace(' ', '+', $authordata->aim); } +/** + * Echo the AIM name of the author of the current post in the Loop. + * @see get_the_author_aim() + * @return null + */ function the_author_aim() { echo get_the_author_aim(); } +/** + * Get the Yahoo! IM name of the author of the current post in the Loop. + * @global object $authordata The current author's DB object. + * @return string The author's Yahoo! IM name. + */ function get_the_author_yim() { global $authordata; return $authordata->yim; } +/** + * Echo the Yahoo! IM name of the author of the current post in the Loop. + * @see get_the_author_yim() + * @return null + */ function the_author_yim() { echo get_the_author_yim(); } +/** + * Get the MSN address of the author of the current post in the Loop. + * @global object $authordata The current author's DB object. + * @return string The author's MSN address. + */ function get_the_author_msn() { global $authordata; return $authordata->msn; } +/** + * Echo the MSN address of the author of the current post in the Loop. + * @see get_the_author_msn() + * @return null + */ function the_author_msn() { echo get_the_author_msn(); } +/** + * Get the number of posts by the author of the current post in the Loop. + * @global object $post The current post in the Loop's DB object. + * @see get_usernumposts() + * @return int The number of posts by the author. + */ function get_the_author_posts() { global $post; - $posts = get_usernumposts($post->post_author); - return $posts; + return get_usernumposts($post->post_author); } +/** + * Echo the number of posts by the author of the current post in the Loop. + * @see get_the_author_posts() + * @return null + */ function the_author_posts() { echo get_the_author_posts(); } +/** + * Echo an HTML link to the author page of the author of the current post in the Loop. + * @global object $authordata The current author's DB object. + * @see get_author_posts_url() + * @see get_the_author() + * @return null + */ /* the_author_posts_link() requires no get_, use get_author_posts_url() */ function the_author_posts_link($deprecated = '') { global $authordata; - - echo '' . get_the_author() . ''; -} - + printf( + '%3$s', + get_author_posts_url( $authordata->ID, $authordata->user_nicename ), + sprintf( __( 'Posts by %s' ), attribute_escape( get_the_author() ) ), + get_the_author() + ); +} + +/** + * Get the URL to the author page of the author of the current post in the Loop. + * @global object $wpdb WordPress database layer. + * @global object $wp_rewrite WP_Rewrite + * @global object $post The current post in the Loop's DB object. + * @return string The URL to the author's page. + */ function get_author_posts_url($author_id, $author_nicename = '') { - global $wpdb, $wp_rewrite, $post, $cache_userdata; + global $wpdb, $wp_rewrite, $post; $auth_ID = (int) $author_id; $link = $wp_rewrite->get_author_permastruct(); @@ -165,44 +338,60 @@ function get_author_posts_url($author_id, $author_nicename = '') { return $link; } -// Get author's preferred display name +/** + * Get the specified author's preferred display name. + * @param int $auth_id The ID of the author. + * @return string The author's display name. + */ function get_author_name( $auth_id ) { $authordata = get_userdata( $auth_id ); - return $authordata->display_name; } +/** + * List all the authors of the blog, with several options available. + * optioncount (boolean) (false): Show the count in parenthesis next to the author's name. + * exclude_admin (boolean) (true): Exclude the 'admin' user that is installed by default. + * show_fullname (boolean) (false): Show their full names. + * hide_empty (boolean) (true): Don't show authors without any posts. + * feed (string) (''): If isn't empty, show links to author's feeds. + * feed_image (string) (''): If isn't empty, use this image to link to feeds. + * echo (boolean) (true): Set to false to return the output, instead of echoing. + * @param array $args The argument array. + * @return null|string The output, if echo is set to false. + */ function wp_list_authors($args = '') { global $wpdb; - - if ( is_array($args) ) - $r = &$args; - else - parse_str($args, $r); - - $defaults = array('optioncount' => false, 'exclude_admin' => true, 'show_fullname' => false, 'hide_empty' => true, - 'feed' => '', 'feed_image' => ''); - $r = array_merge($defaults, $r); + + $defaults = array( + 'optioncount' => false, 'exclude_admin' => true, + 'show_fullname' => false, 'hide_empty' => true, + 'feed' => '', 'feed_image' => '', 'echo' => true + ); + + $r = wp_parse_args( $args, $defaults ); extract($r, EXTR_SKIP); - + + $return = ''; + // TODO: Move select to get_authors(). $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name"); - + $author_count = array(); - foreach ((array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_status = 'publish' GROUP BY post_author") as $row) { + foreach ((array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author") as $row) { $author_count[$row->post_author] = $row->count; } foreach ( (array) $authors as $author ) { $author = get_userdata( $author->ID ); $posts = (isset($author_count[$author->ID])) ? $author_count[$author->ID] : 0; - $name = $author->nickname; + $name = $author->display_name; if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') ) $name = "$author->first_name $author->last_name"; if ( !($posts == 0 && $hide_empty) ) - echo "
  • "; + $return .= '
  • '; if ( $posts == 0 ) { if ( !$hide_empty ) $link = $name; @@ -241,8 +430,11 @@ function wp_list_authors($args = '') { } if ( !($posts == 0 && $hide_empty) ) - echo "$link
  • "; + $return .= $link . ''; } + if ( !$echo ) + return $return; + echo $return; } ?> diff --git a/wp-includes/bookmark-template.php b/wp-includes/bookmark-template.php index 79bf8a3..68a2842 100644 --- a/wp-includes/bookmark-template.php +++ b/wp-includes/bookmark-template.php @@ -1,259 +1,14 @@ '; - if ( !isset($between) ) $between = ' '; - if ( !isset($show_images) ) $show_images = true; - if ( !isset($orderby) ) $orderby = 'name'; - if ( !isset($show_description) ) $show_description = true; - if ( !isset($show_rating) ) $show_rating = false; - if ( !isset($limit) ) $limit = -1; - if ( !isset($show_updated) ) $show_updated = 1; - if ( !isset($echo) ) $echo = true; - - return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo); -} // end wp_get_links - -/** function get_links() - ** Gets the links associated with category n. - ** Parameters: - ** category (default -1) - The category to use. If no category supplied - ** uses all - ** before (default '') - the html to output before the link - ** after (default '
    ') - the html to output after the link - ** between (default ' ') - the html to output between the link/image - ** and its description. Not used if no image or show_images == true - ** show_images (default true) - whether to show images (if defined). - ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name', - ** 'url', 'description', or 'rating'. Or maybe owner. If you start the - ** name with an underscore the order will be reversed. - ** You can also specify 'rand' as the order which will return links in a - ** random order. - ** show_description (default true) - whether to show the description if - ** show_images=false/not defined . - ** show_rating (default false) - show rating stars/chars - ** limit (default -1) - Limit to X entries. If not specified, all entries - ** are shown. - ** show_updated (default 0) - whether to show last updated timestamp - ** echo (default true) - whether to echo the results, or return them instead - */ -function get_links($category = -1, - $before = '', - $after = '
    ', - $between = ' ', - $show_images = true, - $orderby = 'name', - $show_description = true, - $show_rating = false, - $limit = -1, - $show_updated = 1, - $echo = true) { - - global $wpdb; - - $order = 'ASC'; - if ( substr($orderby, 0, 1) == '_' ) { - $order = 'DESC'; - $orderby = substr($orderby, 1); - } - - if ( $category == -1 ) //get_bookmarks uses '' to signify all categories - $category = ''; - - $results = get_bookmarks("category=$category&orderby=$orderby&order=$order&show_updated=$show_updated&limit=$limit"); - - if ( !$results ) - return; - - $output = ''; - - foreach ( (array) $results as $row ) { - if ( !isset($row->recently_updated) ) - $row->recently_updated = false; - $output .= $before; - if ( $show_updated && $row->recently_updated ) - $output .= get_option('links_recently_updated_prepend'); - $the_link = '#'; - if ( !empty($row->link_url) ) - $the_link = clean_url($row->link_url); - $rel = $row->link_rel; - if ( '' != $rel ) - $rel = ' rel="' . $rel . '"'; - - $desc = attribute_escape($row->link_description); - $name = attribute_escape($row->link_name); - $title = $desc; - - if ( $show_updated ) - if (substr($row->link_updated_f, 0, 2) != '00') - $title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * 3600)) . ')'; - - if ( '' != $title ) - $title = ' title="' . $title . '"'; - - $alt = ' alt="' . $name . '"'; - - $target = $row->link_target; - if ( '' != $target ) - $target = ' target="' . $target . '"'; - - $output .= ''; - - if ( $row->link_image != null && $show_images ) { - if ( strpos($row->link_image, 'http') !== false ) - $output .= "link_image\" $alt $title />"; - else // If it's a relative path - $output .= "link_image\" $alt $title />"; - } else { - $output .= $name; - } - - $output .= ''; - - if ( $show_updated && $row->recently_updated ) - $output .= get_option('links_recently_updated_append'); - - if ( $show_description && '' != $desc ) - $output .= $between . $desc; - - if ($show_rating) { - $output .= $between . get_linkrating($row); - } - - $output .= "$after\n"; - } // end while - - if ( !$echo ) - return $output; - echo $output; -} - -function get_linkrating($link) { - return apply_filters('link_rating', $link->link_rating); -} - -/** function get_linkcatname() - ** Gets the name of category n. - ** Parameters: id (default 0) - The category to get. If no category supplied - ** uses 0 - */ -function get_linkcatname($id = 0) { - $id = (int) $id; - - if ( empty($id) ) - return ''; - - $cats = wp_get_link_cats($id); - - if ( empty($cats) || ! is_array($cats) ) - return ''; - - $cat_id = (int) $cats[0]; // Take the first cat. - - $cat = get_category($cat_id); - return $cat->cat_name; -} - -/** function links_popup_script() - ** This function contributed by Fullo -- http://sprite.csr.unibo.it/fullo/ - ** Show the link to the links popup and the number of links - ** Parameters: - ** text (default Links) - the text of the link - ** width (default 400) - the width of the popup window - ** height (default 400) - the height of the popup window - ** file (default linkspopup.php) - the page to open in the popup window - ** count (default true) - the number of links in the db - */ -function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) { - if ( $count ) - $counts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links"); - - $javascript = ""; - $javascript .= $text; - - if ( $count ) - $javascript .= " ($counts)"; - - $javascript .= "\n\n"; - echo $javascript; -} - - -/* - * function get_links_list() - * - * added by Dougal - * - * Output a list of all links, listed by category, using the - * settings in $wpdb->linkcategories and output it as a nested - * HTML unordered list. - * - * Parameters: - * order (default 'name') - Sort link categories by 'name' or 'id' - * hide_if_empty (default true) - Supress listing empty link categories - */ -function get_links_list($order = 'name', $hide_if_empty = 'obsolete') { - $order = strtolower($order); - - // Handle link category sorting - $direction = 'ASC'; - if ( '_' == substr($order,0,1) ) { - $direction = 'DESC'; - $order = substr($order,1); - } - - if ( !isset($direction) ) - $direction = ''; - - $cats = get_categories("type=link&orderby=$order&order=$direction&hierarchical=0"); - - // Display each category - if ( $cats ) { - foreach ( (array) $cats as $cat ) { - // Handle each category. - - // Display the category name - echo '
  • ' . $cat->cat_name . "

    \n\t\n
  • \n"; - } - } -} - function _walk_bookmarks($bookmarks, $args = '' ) { - if ( is_array($args) ) - $r = &$args; - else - parse_str($args, $r); + $defaults = array( + 'show_updated' => 0, 'show_description' => 0, + 'show_images' => 1, 'before' => '
  • ', + 'after' => '
  • ', 'between' => "\n" + ); - $defaults = array('show_updated' => 0, 'show_description' => 0, 'show_images' => 1, 'before' => '
  • ', - 'after' => '
  • ', 'between' => "\n"); - $r = array_merge($defaults, $r); - extract($r, EXTR_SKIP); + $r = wp_parse_args( $args, $defaults ); + extract( $r, EXTR_SKIP ); foreach ( (array) $bookmarks as $bookmark ) { if ( !isset($bookmark->recently_updated) ) @@ -270,8 +25,8 @@ function _walk_bookmarks($bookmarks, $args = '' ) { if ( '' != $rel ) $rel = ' rel="' . $rel . '"'; - $desc = attribute_escape(apply_filters('link_description', $bookmark->link_description)); - $name = attribute_escape(apply_filters('link_title', $bookmark->link_name)); + $desc = attribute_escape(sanitize_bookmark_field('link_description', $bookmark->link_description, $bookmark->link_id, 'display')); + $name = attribute_escape(sanitize_bookmark_field('link_name', $bookmark->link_name, $bookmark->link_id, 'display')); $title = $desc; if ( $show_updated ) @@ -308,11 +63,11 @@ function _walk_bookmarks($bookmarks, $args = '' ) { if ( $show_description && '' != $desc ) $output .= $between . $desc; - + if ($show_rating) { $output .= $between . get_linkrating($bookmark); } - + $output .= "$after\n"; } // end while @@ -320,32 +75,34 @@ function _walk_bookmarks($bookmarks, $args = '' ) { } function wp_list_bookmarks($args = '') { - if ( is_array($args) ) - $r = &$args; - else - parse_str($args, $r); - - $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => '', - 'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'echo' => 1, - 'categorize' => 1, 'title_li' => __('Bookmarks'), 'title_before' => '

    ', 'title_after' => '

    ', - 'category_orderby' => 'name', 'category_order' => 'ASC', 'class' => 'linkcat', - 'category_before' => '
  • ', 'category_after' => '
  • '); - $r = array_merge($defaults, $r); - extract($r, EXTR_SKIP); + $defaults = array( + 'orderby' => 'name', 'order' => 'ASC', + 'limit' => -1, 'category' => '', + 'category_name' => '', 'hide_invisible' => 1, + 'show_updated' => 0, 'echo' => 1, + 'categorize' => 1, 'title_li' => __('Bookmarks'), + 'title_before' => '

    ', 'title_after' => '

    ', + 'category_orderby' => 'name', 'category_order' => 'ASC', + 'class' => 'linkcat', 'category_before' => '
  • ', + 'category_after' => '
  • ' + ); + + $r = wp_parse_args( $args, $defaults ); + extract( $r, EXTR_SKIP ); $output = ''; if ( $categorize ) { //Split the bookmarks into ul's for each category - $cats = get_categories("type=link&category_name=$category_name&include=$category&orderby=$category_orderby&order=$category_order&hierarchical=0"); + $cats = get_terms('link_category', "category_name=$category_name&include=$category&orderby=$category_orderby&order=$category_order&hierarchical=0"); foreach ( (array) $cats as $cat ) { - $params = array_merge($r, array('category'=>$cat->cat_ID)); + $params = array_merge($r, array('category'=>$cat->term_id)); $bookmarks = get_bookmarks($params); if ( empty($bookmarks) ) continue; - $output .= str_replace(array('%id', '%class'), array("linkcat-$cat->cat_ID", $class), $category_before); - $catname = apply_filters( "link_category", $cat->cat_name ); + $output .= str_replace(array('%id', '%class'), array("linkcat-$cat->term_id", $class), $category_before); + $catname = apply_filters( "link_category", $cat->name ); $output .= "$title_before$catname$title_after\n\t\n$category_after\n"; diff --git a/wp-includes/bookmark.php b/wp-includes/bookmark.php index aca1e72..a8c1a3f 100644 --- a/wp-includes/bookmark.php +++ b/wp-includes/bookmark.php @@ -1,11 +1,13 @@ get_row("SELECT * FROM $wpdb->links WHERE link_id = '$bookmark_id'"); - $link->link_category = wp_get_link_cats($bookmark_id); + $link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = '$bookmark_id' LIMIT 1"); + $link->link_category = array_unique( wp_get_object_terms($link_id, 'link_category', 'fields=ids') ); + + $link = sanitize_bookmark($link, $filter); if ( $output == OBJECT ) { return $link; @@ -18,6 +20,22 @@ function get_bookmark($bookmark_id, $output = OBJECT) { } } +function get_bookmark_field( $field, $bookmark, $context = 'display' ) { + $bookmark = (int) $bookmark; + $bookmark = get_bookmark( $bookmark ); + + if ( is_wp_error($bookmark) ) + return $bookmark; + + if ( !is_object($bookmark) ) + return ''; + + if ( !isset($bookmark->$field) ) + return ''; + + return sanitize_bookmark_field($field, $bookmark->$field, $bookmark->link_id, $context); +} + // Deprecate function get_link($bookmark_id, $output = OBJECT) { return get_bookmark($bookmark_id, $output); @@ -26,15 +44,16 @@ function get_link($bookmark_id, $output = OBJECT) { function get_bookmarks($args = '') { global $wpdb; - if ( is_array($args) ) - $r = &$args; - else - parse_str($args, $r); + $defaults = array( + 'orderby' => 'name', 'order' => 'ASC', + 'limit' => -1, 'category' => '', + 'category_name' => '', 'hide_invisible' => 1, + 'show_updated' => 0, 'include' => '', + 'exclude' => '' + ); - $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => '', - 'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'include' => '', 'exclude' => ''); - $r = array_merge($defaults, $r); - extract($r, EXTR_SKIP); + $r = wp_parse_args( $args, $defaults ); + extract( $r, EXTR_SKIP ); $key = md5( serialize( $r ) ); if ( $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) ) @@ -75,8 +94,8 @@ function get_bookmarks($args = '') { $exclusions .= ')'; if ( ! empty($category_name) ) { - if ( $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category_name' LIMIT 1") ) - $category = $cat_id; + if ( $category = get_term_by('name', $category_name, 'link_category') ) + $category = $category->term_id; } $category_query = ''; @@ -86,15 +105,15 @@ function get_bookmarks($args = '') { if ( count($incategories) ) { foreach ( $incategories as $incat ) { if (empty($category_query)) - $category_query = ' AND ( category_id = ' . intval($incat) . ' '; + $category_query = ' AND ( tt.term_id = ' . intval($incat) . ' '; else - $category_query .= ' OR category_id = ' . intval($incat) . ' '; + $category_query .= ' OR tt.term_id = ' . intval($incat) . ' '; } } } if (!empty($category_query)) { - $category_query .= ')'; - $join = " LEFT JOIN $wpdb->link2cat ON ($wpdb->links.link_id = $wpdb->link2cat.link_id) "; + $category_query .= ") AND taxonomy = 'link_category'"; + $join = " LEFT JOIN $wpdb->term_relationships AS tr ON ($wpdb->links.link_id = tr.object_id) LEFT JOIN $wpdb->term_taxonomy as tt ON tt.term_taxonomy_id = tr.term_taxonomy_id"; } if (get_option('links_recently_updated_time')) { @@ -136,11 +155,72 @@ function get_bookmarks($args = '') { $results = $wpdb->get_results($query); $cache[ $key ] = $results; - wp_cache_add( 'get_bookmarks', $cache, 'bookmark' ); + wp_cache_set( 'get_bookmarks', $cache, 'bookmark' ); return apply_filters('get_bookmarks', $results, $r); } +function sanitize_bookmark($bookmark, $context = 'display') { + $fields = array('link_id', 'link_url', 'link_name', 'link_image', 'link_target', 'link_category', + 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_updated', + 'link_rel', 'link_notes', 'link_rss', ); + + $do_object = false; + if ( is_object($bookmark) ) + $do_object = true; + + foreach ( $fields as $field ) { + if ( $do_object ) + $bookmark->$field = sanitize_bookmark_field($field, $bookmark->$field, $bookmark->link_id, $context); + else + $bookmark[$field] = sanitize_bookmark_field($field, $bookmark[$field], $bookmark['link_id'], $context); + } + + return $bookmark; +} + +function sanitize_bookmark_field($field, $value, $bookmark_id, $context) { + $int_fields = array('link_id', 'link_rating'); + if ( in_array($field, $int_fields) ) + $value = (int) $value; + + $yesno = array('link_visible'); + if ( in_array($field, $yesno) ) + $value = preg_replace('/[^YNyn]/', '', $value); + + if ( 'link_target' == $field ) { + $targets = array('_top', '_blank'); + if ( ! in_array($value, $targets) ) + $value = ''; + } + + if ( 'raw' == $context ) + return $value; + + if ( 'edit' == $context ) { + $format_to_edit = array('link_notes'); + $value = apply_filters("edit_$field", $value, $bookmark_id); + + if ( in_array($field, $format_to_edit) ) { + $value = format_to_edit($value); + } else { + $value = attribute_escape($value); + } + } else if ( 'db' == $context ) { + $value = apply_filters("pre_$field", $value); + } else { + // Use display filters by default. + $value = apply_filters($field, $value, $bookmark_id, $context); + } + + if ( 'attribute' == $context ) + $value = attribute_escape($value); + else if ( 'js' == $context ) + $value = js_escape($value); + + return $value; +} + function delete_get_bookmark_cache() { wp_cache_delete( 'get_bookmarks', 'bookmark' ); } diff --git a/wp-includes/cache.php b/wp-includes/cache.php index 695a986..1b300d4 100644 --- a/wp-includes/cache.php +++ b/wp-includes/cache.php @@ -63,6 +63,7 @@ class WP_Object_Cache { var $dirty_objects = array (); var $non_existant_objects = array (); var $global_groups = array ('users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details'); + var $non_persistent_groups = array('comment'); var $blog_id; var $cold_cache_hits = 0; var $warm_cache_hits = 0; @@ -207,18 +208,7 @@ class WP_Object_Cache { } function load_group_from_db($group) { - global $wpdb; - - if ('category' == $group) { - $this->cache['category'] = array (); - if ($dogs = $wpdb->get_results("SELECT * FROM $wpdb->categories")) { - foreach ($dogs as $catt) { - $this->cache['category'][$catt->cat_ID] = $catt; - $this->cache[$this->key( $catt->cat_ID, 'category' )] = $catt; - } - } - } - + return; } function make_group_dir($group, $perms) { @@ -384,14 +374,14 @@ class WP_Object_Cache { function stats() { echo "

    "; - echo "Cold Cache Hits: {$this->cold_cache_hits}
    "; - echo "Warm Cache Hits: {$this->warm_cache_hits}
    "; - echo "Cache Misses: {$this->cache_misses}
    "; + echo "Cold Cache Hits: {$this->cold_cache_hits}
    "; + echo "Warm Cache Hits: {$this->warm_cache_hits}
    "; + echo "Cache Misses: {$this->cache_misses}
    "; echo "

    "; foreach ($this->cache as $group => $cache) { echo "

    "; - echo "Group: $group
    "; + echo "Group: $group
    "; echo "Cache:"; echo "

    ";
     			print_r($cache);
    diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php
    new file mode 100644
    index 0000000..8027a1c
    --- /dev/null
    +++ b/wp-includes/canonical.php
    @@ -0,0 +1,201 @@
    +using_permalinks() ) {
    +		// rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101
    +		if ( is_single() && isset($_GET['p']) ) {
    +			if ( $redirect_url = get_permalink(get_query_var('p')) )
    +				$redirect['query'] = remove_query_arg('p', $redirect['query']);
    +		} elseif ( is_page() && isset($_GET['page_id']) ) {
    +			if ( $redirect_url = get_permalink(get_query_var('page_id')) )
    +				$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
    +		} elseif ( isset($_GET['m']) && ( is_year() || is_month() || is_day() ) ) {
    +			$m = get_query_var('m');
    +			switch ( strlen($m) ) {
    +				case 4: // Yearly
    +					$redirect_url = get_year_link($m);
    +					break;
    +				case 6: // Monthly
    +					$redirect_url = get_month_link( substr($m, 0, 4), substr($m, 4, 2) );
    +					break;
    +				case 8: // Daily
    +					$redirect_url = get_day_link(substr($m, 0, 4), substr($m, 4, 2), substr($m, 6, 2));
    +					break;
    +			}
    +			if ( $redirect_url )
    +				$redirect['query'] = remove_query_arg('m', $redirect['query']);
    +		// now moving on to non ?m=X year/month/day links
    +		} elseif ( is_day() && get_query_var('year') && get_query_var('monthnum') && isset($_GET['day']) ) {
    +			if ( $redirect_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')) )
    +				$redirect['query'] = remove_query_arg(array('year', 'monthnum', 'day'), $redirect['query']);
    +		} elseif ( is_month() && get_query_var('year') && isset($_GET['monthnum']) ) {
    +			if ( $redirect_url = get_month_link(get_query_var('year'), get_query_var('monthnum')) )
    +				$redirect['query'] = remove_query_arg(array('year', 'monthnum'), $redirect['query']);
    +		} elseif ( is_year() && isset($_GET['year']) ) {
    +			if ( $redirect_url = get_year_link(get_query_var('year')) )
    +				$redirect['query'] = remove_query_arg('year', $redirect['query']);
    +		} elseif ( is_category() && isset($_GET['cat']) ) {
    +			if ( $redirect_url = get_category_link(get_query_var('cat')) )
    +				$redirect['query'] = remove_query_arg('cat', $redirect['query']);
    +		} elseif ( is_author() && isset($_GET['author']) ) {
    +			$author = get_userdata(get_query_var('author'));
    +			if ( false !== $author && $redirect_url = get_author_link(false, $author->ID, $author->user_nicename) )
    +				$redirect['query'] = remove_query_arg('author', $redirect['author']);
    +		}
    +
    +	// paging
    +		if ( $paged = get_query_var('paged') ) {
    +			if ( $paged > 0 ) {
    +				if ( !$redirect_url )
    +					$redirect_url = $requested_url;
    +				$paged_redirect = @parse_url($redirect_url);
    +				$paged_redirect['path'] = preg_replace('|/page/[0-9]+?(/+)?$|', '/', $paged_redirect['path']); // strip off any existing paging
    +				$paged_redirect['path'] = preg_replace('|/index.php/?$|', '/', $paged_redirect['path']); // strip off trailing /index.php/
    +				if ( $paged > 1 && !is_single() ) {
    +					$paged_redirect['path'] = trailingslashit($paged_redirect['path']);
    +					if ( $wp_rewrite->using_index_permalinks() && strpos($paged_redirect['path'], '/index.php/') === false )
    +						$paged_redirect['path'] .= 'index.php/';
    +					$paged_redirect['path'] .= user_trailingslashit("page/$paged", 'paged');
    +				} elseif ( !is_home() && !is_single() ){
    +					$paged_redirect['path'] = user_trailingslashit($paged_redirect['path'], 'paged');
    +				}
    +				$redirect_url = $paged_redirect['scheme'] . '://' . $paged_redirect['host'] . $paged_redirect['path'];
    +				$redirect['path'] = $paged_redirect['path'];
    +			}
    +			$redirect['query'] = remove_query_arg('paged', $redirect['query']);
    +		}
    +	}
    +
    +	// tack on any additional query vars
    +	if ( $redirect_url && $redirect['query'] ) {
    +		if ( strpos($redirect_url, '?') !== false )
    +			$redirect_url .= '&';
    +		else
    +			$redirect_url .= '?';
    +		$redirect_url .= $redirect['query'];
    +	}
    +
    +	if ( $redirect_url )
    +		$redirect = @parse_url($redirect_url);
    +
    +	// www.example.com vs example.com
    +	$user_home = @parse_url(get_option('home'));
    +	$redirect['host'] = $user_home['host'];
    +
    +	// Handle ports
    +	if ( isset($user_home['port']) )
    +		$redirect['port'] = $user_home['port'];
    +	else
    +		unset($redirect['port']);
    +
    +	// trailing /index.php/
    +	$redirect['path'] = preg_replace('|/index.php/$|', '/', $redirect['path']);
    +
    +	// strip /index.php/ when we're not using PATHINFO permalinks
    +	if ( !$wp_rewrite->using_index_permalinks() )
    +		$redirect['path'] = str_replace('/index.php/', '/', $redirect['path']);
    +
    +	// trailing slashes
    +	if ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() && !is_404() && (!is_home() || ( is_home() && (get_query_var('paged') > 1) ) ) ) {
    +		$user_ts_type = '';
    +		if ( get_query_var('paged') > 0 ) {
    +			$user_ts_type = 'paged';
    +		} else {
    +			foreach ( array('single', 'category', 'page', 'day', 'month', 'year') as $type ) {
    +				$func = 'is_' . $type;
    +				if ( call_user_func($func) )
    +					$user_ts_type = $type;
    +					break;
    +				}
    +			}
    +		$redirect['path'] = user_trailingslashit($redirect['path'], $user_ts_type);
    +	} elseif ( is_home() ) {
    +		$redirect['path'] = trailingslashit($redirect['path']);
    +	}
    +
    +	// Always trailing slash the 'home' URL
    +	if ( $redirect['path'] == $user_home['path'] )
    +		$redirect['path'] = trailingslashit($redirect['path']);
    +
    +	// Ignore differences in host capitalization, as this can lead to infinite redirects
    +	if ( strtolower($original['host']) == strtolower($redirect['host']) )
    +		$redirect['host'] = $original['host'];
    +
    +	if ( array($original['host'], $original['port'], $original['path'], $original['query']) !== array($redirect['host'], $redirect['port'], $redirect['path'], $redirect['query']) ) {
    +		$redirect_url = $redirect['scheme'] . '://' . $redirect['host'];
    +		if ( isset($redirect['port']) )
    +		 	$redirect_url .= ':' . $redirect['port'];
    +		$redirect_url .= $redirect['path'];
    +		if ( $redirect['query'] )
    +			$redirect_url .= '?' . $redirect['query'];
    +	}
    +
    +	if ( $redirect_url && $redirect_url != $requested_url ) {
    +		// var_dump($redirect_url); die();
    +		$redirect_url = apply_filters('redirect_canonical', $redirect_url, $requested_url);
    +		if ( $do_redirect) {
    +			// protect against chained redirects
    +			if ( !redirect_canonical($redirect_url, false) ) {
    +				wp_redirect($redirect_url, 301);
    +				exit();
    +			} else {
    +				return false;
    +			}
    +		} else {
    +			return $redirect_url;
    +		}
    +	} else {
    +		return false;
    +	}
    +}
    +
    +function redirect_guess_404_permalink() {
    +	global $wp_query, $wpdb;
    +	if ( !get_query_var('name') )
    +		return false;
    +
    +	$where = "post_name LIKE '" . $wpdb->escape(get_query_var('name')) . "%'";
    +
    +	// if any of year, monthnum, or day are set, use them to refine the query
    +	if ( get_query_var('year') )
    +		$where .= " AND YEAR(post_date) = '" . $wpdb->escape(get_query_var('year')) . "'";
    +	if ( get_query_var('monthnum') )
    +		$where .= " AND MONTH(post_date) = '" . $wpdb->escape(get_query_var('monthnum')) . "'";
    +	if ( get_query_var('day') )
    +		$where .= " AND DAYOFMONTH(post_date) = '" . $wpdb->escape(get_query_var('day')) . "'";
    +
    +	$post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE $where AND post_status = 'publish'");
    +	if ( !$post_id )
    +		return false;
    +	return get_permalink($post_id);
    +}
    +
    +add_action('template_redirect', 'redirect_canonical');
    +
    +?>
    \ No newline at end of file
    diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php
    index eccde97..3c3594d 100644
    --- a/wp-includes/capabilities.php
    +++ b/wp-includes/capabilities.php
    @@ -267,7 +267,7 @@ class WP_User {
     		// Must have ALL requested caps
     		$capabilities = apply_filters('user_has_cap', $this->allcaps, $caps, $args);
     		foreach ($caps as $cap) {
    -			//echo "Checking cap $cap
    "; + //echo "Checking cap $cap
    "; if(empty($capabilities[$cap]) || !$capabilities[$cap]) return false; } @@ -295,14 +295,14 @@ function map_meta_cap($cap, $user_id) { break; case 'delete_post': $author_data = get_userdata($user_id); - //echo "post ID: {$args[0]}
    "; + //echo "post ID: {$args[0]}
    "; $post = get_post($args[0]); if ( 'page' == $post->post_type ) { $args = array_merge(array('delete_page', $user_id), $args); return call_user_func_array('map_meta_cap', $args); } $post_author_data = get_userdata($post->post_author); - //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "
    "; + //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "
    "; // If the user is the author... if ($user_id == $post_author_data->ID) { // If the post is published... @@ -323,10 +323,10 @@ function map_meta_cap($cap, $user_id) { break; case 'delete_page': $author_data = get_userdata($user_id); - //echo "post ID: {$args[0]}
    "; + //echo "post ID: {$args[0]}
    "; $page = get_page($args[0]); $page_author_data = get_userdata($page->post_author); - //echo "current user id : $user_id, page author id: " . $page_author_data->ID . "
    "; + //echo "current user id : $user_id, page author id: " . $page_author_data->ID . "
    "; // If the user is the author... if ($user_id == $page_author_data->ID) { // If the page is published... @@ -349,14 +349,14 @@ function map_meta_cap($cap, $user_id) { // edit_others_posts case 'edit_post': $author_data = get_userdata($user_id); - //echo "post ID: {$args[0]}
    "; + //echo "post ID: {$args[0]}
    "; $post = get_post($args[0]); if ( 'page' == $post->post_type ) { $args = array_merge(array('edit_page', $user_id), $args); return call_user_func_array('map_meta_cap', $args); } $post_author_data = get_userdata($post->post_author); - //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "
    "; + //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "
    "; // If the user is the author... if ($user_id == $post_author_data->ID) { // If the post is published... @@ -377,10 +377,10 @@ function map_meta_cap($cap, $user_id) { break; case 'edit_page': $author_data = get_userdata($user_id); - //echo "post ID: {$args[0]}
    "; + //echo "post ID: {$args[0]}
    "; $page = get_page($args[0]); $page_author_data = get_userdata($page->post_author); - //echo "current user id : $user_id, page author id: " . $page_author_data->ID . "
    "; + //echo "current user id : $user_id, page author id: " . $page_author_data->ID . "
    "; // If the user is the author... if ($user_id == $page_author_data->ID) { // If the page is published... @@ -445,12 +445,12 @@ function map_meta_cap($cap, $user_id) { function current_user_can($capability) { $current_user = wp_get_current_user(); - $args = array_slice(func_get_args(), 1); - $args = array_merge(array($capability), $args); - if ( empty($current_user) ) return false; + $args = array_slice(func_get_args(), 1); + $args = array_merge(array($capability), $args); + return call_user_func_array(array(&$current_user, 'has_cap'), $args); } diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index 5eaabfb..cd8dbcb 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -5,16 +5,18 @@ function get_category_children($id, $before = '/', $after = '') { return ''; $chain = ''; - + // TODO: consult hierarchy $cat_ids = get_all_category_ids(); foreach ( $cat_ids as $cat_id ) { - if ( $cat_id == $id) + if ( $cat_id == $id ) continue; $category = get_category($cat_id); - if ( $category->category_parent == $id ) { - $chain .= $before.$category->cat_ID.$after; - $chain .= get_category_children($category->cat_ID, $before, $after); + if ( is_wp_error( $category ) ) + return $category; + if ( $category->parent == $id ) { + $chain .= $before.$category->term_id.$after; + $chain .= get_category_children($category->term_id, $before, $after); } } return $chain; @@ -29,12 +31,11 @@ function get_category_link($category_id) { $catlink = $file . '?cat=' . $category_id; } else { $category = &get_category($category_id); - $category_nicename = $category->category_nicename; - - if ( $category->category_parent == $category_id ) // recursive recursion - $category->category_parent = 0; + if ( is_wp_error( $category ) ) + return $category; + $category_nicename = $category->slug; - if ( $parent = $category->category_parent ) + if ( $parent = $category->parent ) $category_nicename = get_category_parents($parent, false, '/', true) . $category_nicename; $catlink = str_replace('%category%', $category_nicename, $catlink); @@ -46,50 +47,55 @@ function get_category_link($category_id) { function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){ $chain = ''; $parent = &get_category($id); + if ( is_wp_error( $parent ) ) + return $parent; if ( $nicename ) - $name = $parent->category_nicename; + $name = $parent->slug; else $name = $parent->cat_name; - if ( $parent->category_parent && ($parent->category_parent != $parent->cat_ID) ) - $chain .= get_category_parents($parent->category_parent, $link, $separator, $nicename); + if ( $parent->parent && ($parent->parent != $parent->term_id) ) + $chain .= get_category_parents($parent->parent, $link, $separator, $nicename); if ( $link ) - $chain .= 'cat_name) . '">'.$name.'' . $separator; + $chain .= 'cat_name) . '">'.$name.'' . $separator; else $chain .= $name.$separator; return $chain; } function get_the_category($id = false) { -global $post, $category_cache, $blog_id; + global $post, $term_cache, $blog_id; $id = (int) $id; if ( !$id ) $id = (int) $post->ID; - if ( !isset($category_cache[$blog_id][$id]) ) - update_post_category_cache($id); - - $categories = $category_cache[$blog_id][$id]; + $categories = get_object_term_cache($id, 'category'); + if ( false === $categories ) + $categories = wp_get_object_terms($id, 'category'); if ( !empty($categories) ) - usort($categories, '_get_the_category_usort'); + usort($categories, '_usort_terms_by_name'); else $categories = array(); + foreach(array_keys($categories) as $key) { + _make_cat_compat($categories[$key]); + } + return $categories; } -function _get_the_category_usort($a, $b) { - return strcmp($a->category_name, $b->category_name); +function _usort_terms_by_name($a, $b) { + return strcmp($a->name, $b->name); } -function _get_the_category_usort_by_ID($a, $b) { - if ( $a->cat_ID > $b->cat_ID ) +function _usort_terms_by_ID($a, $b) { + if ( $a->term_id > $b->term_id ) return 1; - elseif ( $a->cat_ID < $b->cat_ID ) + elseif ( $a->term_id < $b->term_id ) return -1; else return 0; @@ -98,7 +104,9 @@ function _get_the_category_usort_by_ID($a, $b) { function get_the_category_by_ID($cat_ID) { $cat_ID = (int) $cat_ID; $category = &get_category($cat_ID); - return $category->cat_name; + if ( is_wp_error( $category ) ) + return $category; + return $category->name; } function get_the_category_list($separator = '', $parents='') { @@ -116,19 +124,19 @@ function get_the_category_list($separator = '', $parents='') { $thelist .= "\n\t
  • "; switch ( strtolower($parents) ) { case 'multiple': - if ($category->category_parent) - $thelist .= get_category_parents($category->category_parent, TRUE); - $thelist .= 'cat_name) . '" ' . $rel . '>' . $category->cat_name.'
  • '; + if ($category->parent) + $thelist .= get_category_parents($category->parent, TRUE); + $thelist .= 'name) . '" ' . $rel . '>' . $category->name.''; break; case 'single': - $thelist .= 'cat_name) . '" ' . $rel . '>'; - if ($category->category_parent) - $thelist .= get_category_parents($category->category_parent, FALSE); - $thelist .= $category->cat_name.''; + $thelist .= 'name) . '" ' . $rel . '>'; + if ($category->parent) + $thelist .= get_category_parents($category->parent, FALSE); + $thelist .= $category->name.''; break; case '': default: - $thelist .= 'cat_name) . '" ' . $rel . '>' . $category->cat_name.''; + $thelist .= 'name) . '" ' . $rel . '>' . $category->cat_name.''; } } $thelist .= ''; @@ -139,19 +147,19 @@ function get_the_category_list($separator = '', $parents='') { $thelist .= $separator . ' '; switch ( strtolower($parents) ) { case 'multiple': - if ( $category->category_parent ) - $thelist .= get_category_parents($category->category_parent, TRUE); - $thelist .= 'cat_name) . '" ' . $rel . '>' . $category->cat_name.''; + if ( $category->parent ) + $thelist .= get_category_parents($category->parent, TRUE); + $thelist .= 'name) . '" ' . $rel . '>' . $category->cat_name.''; break; case 'single': - $thelist .= 'cat_name) . '" ' . $rel . '>'; - if ( $category->category_parent ) - $thelist .= get_category_parents($category->category_parent, FALSE); + $thelist .= 'name) . '" ' . $rel . '>'; + if ( $category->parent ) + $thelist .= get_category_parents($category->parent, FALSE); $thelist .= "$category->cat_name"; break; case '': default: - $thelist .= 'cat_name) . '" ' . $rel . '>' . $category->cat_name.''; + $thelist .= 'name) . '" ' . $rel . '>' . $category->name.''; } ++$i; } @@ -159,10 +167,13 @@ function get_the_category_list($separator = '', $parents='') { return apply_filters('the_category', $thelist, $separator, $parents); } -function in_category($category) { // Check if the current post is in the given category - global $category_cache, $post, $blog_id; +function in_category( $category ) { // Check if the current post is in the given category + global $post, $blog_id; - if ( isset( $category_cache[$blog_id][$post->ID][$category] ) ) + $categories = get_object_term_cache($post->ID, 'category'); + if ( false === $categories ) + $categories = wp_get_object_terms($post->ID, 'category'); + if(array_key_exists($category, $categories)) return true; else return false; @@ -176,25 +187,26 @@ function category_description($category = 0) { global $cat; if ( !$category ) $category = $cat; - $category = & get_category($category); - return apply_filters('category_description', $category->category_description, $category->cat_ID); + + return get_term_field('description', $category, 'category'); } function wp_dropdown_categories($args = '') { - if ( is_array($args) ) - $r = &$args; - else - parse_str($args, $r); + $defaults = array( + 'show_option_all' => '', 'show_option_none' => '', + 'orderby' => 'ID', 'order' => 'ASC', + 'show_last_update' => 0, 'show_count' => 0, + 'hide_empty' => 1, 'child_of' => 0, + 'exclude' => '', 'echo' => 1, + 'selected' => 0, 'hierarchical' => 0, + 'name' => 'cat', 'class' => 'postform' + ); - $defaults = array('show_option_all' => '', 'show_option_none' => '', 'orderby' => 'ID', - 'order' => 'ASC', 'show_last_update' => 0, 'show_count' => 0, - 'hide_empty' => 1, 'child_of' => 0, 'exclude' => '', 'echo' => 1, - 'selected' => 0, 'hierarchical' => 0, 'name' => 'cat', - 'class' => 'postform'); $defaults['selected'] = ( is_category() ) ? get_query_var('cat') : 0; - $r = array_merge($defaults, $r); + + $r = wp_parse_args( $args, $defaults ); $r['include_last_update_time'] = $r['show_last_update']; - extract($r, EXTR_SKIP); + extract( $r ); $categories = get_categories($r); @@ -230,22 +242,28 @@ function wp_dropdown_categories($args = '') { } function wp_list_categories($args = '') { - if ( is_array($args) ) - $r = &$args; - else - parse_str($args, $r); - - $defaults = array('show_option_all' => '', 'orderby' => 'name', - 'order' => 'ASC', 'show_last_update' => 0, 'style' => 'list', - 'show_count' => 0, 'hide_empty' => 1, 'use_desc_for_title' => 1, - 'child_of' => 0, 'feed' => '', 'feed_image' => '', 'exclude' => '', - 'hierarchical' => true, 'title_li' => __('Categories')); - $r = array_merge($defaults, $r); - if ( !isset($r['pad_counts']) && $r['show_count'] && $r['hierarchical'] ) + $defaults = array( + 'show_option_all' => '', 'orderby' => 'name', + 'order' => 'ASC', 'show_last_update' => 0, + 'style' => 'list', 'show_count' => 0, + 'hide_empty' => 1, 'use_desc_for_title' => 1, + 'child_of' => 0, 'feed' => '', + 'feed_image' => '', 'exclude' => '', + 'hierarchical' => true, 'title_li' => __('Categories'), + 'echo' => 1 + ); + + $r = wp_parse_args( $args, $defaults ); + + if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) { $r['pad_counts'] = true; - if ( isset($r['show_date']) ) + } + + if ( isset( $r['show_date'] ) ) { $r['include_last_update_time'] = $r['show_date']; - extract($r, EXTR_SKIP); + } + + extract( $r ); $categories = get_categories($r); @@ -260,13 +278,13 @@ function wp_list_categories($args = '') { $output .= __("No categories"); } else { global $wp_query; - + if( !empty($show_option_all) ) - if ('list' == $style ) + if ('list' == $style ) $output .= '
  • ' . $show_option_all . '
  • '; else $output .= '' . $show_option_all . ''; - + if ( is_category() ) $r['current_category'] = $wp_query->get_queried_object_id(); @@ -281,7 +299,103 @@ function wp_list_categories($args = '') { if ( $title_li && 'list' == $style ) $output .= ''; - echo apply_filters('wp_list_categories', $output); + $output = apply_filters('wp_list_categories', $output); + + if ( $echo ) + echo $output; + else + return $output; +} + +function wp_tag_cloud( $args = '' ) { + $defaults = array( + 'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, + 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC', + 'exclude' => '', 'include' => '' + ); + $args = wp_parse_args( $args, $defaults ); + + $tags = get_tags( array_merge($args, array('orderby' => 'count', 'order' => 'DESC')) ); // Always query top tags + + if ( empty($tags) ) + return; + + $return = wp_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args + if ( is_wp_error( $return ) ) + return false; + else + echo apply_filters( 'wp_tag_cloud', $return, $args ); +} + +// $tags = prefetched tag array ( get_tags() ) +// $args['format'] = 'flat' => whitespace separated, 'list' => UL, 'array' => array() +// $args['orderby'] = 'name', 'count' +function wp_generate_tag_cloud( $tags, $args = '' ) { + global $wp_rewrite; + $defaults = array( + 'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, + 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC' + ); + $args = wp_parse_args( $args, $defaults ); + extract($args); + + if ( !$tags ) + return; + $counts = $tag_links = array(); + foreach ( (array) $tags as $tag ) { + $counts[$tag->name] = $tag->count; + $tag_links[$tag->name] = get_tag_link( $tag->term_id ); + if ( is_wp_error( $tag_links[$tag->name] ) ) + return $tag_links[$tag->name]; + $tag_ids[$tag->name] = $tag->term_id; + } + + $min_count = min($counts); + $spread = max($counts) - $min_count; + if ( $spread <= 0 ) + $spread = 1; + $font_spread = $largest - $smallest; + if ( $font_spread <= 0 ) + $font_spread = 1; + $font_step = $font_spread / $spread; + + // SQL cannot save you; this is a second (potentially different) sort on a subset of data. + if ( 'name' == $orderby ) + uksort($counts, 'strnatcasecmp'); + else + asort($counts); + + if ( 'DESC' == $order ) + $counts = array_reverse( $counts, true ); + + $a = array(); + + $rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? ' rel="tag"' : ''; + + foreach ( $counts as $tag => $count ) { + $tag_id = $tag_ids[$tag]; + $tag_link = clean_url($tag_links[$tag]); + $tag = str_replace(' ', ' ', wp_specialchars( $tag )); + $a[] = "$tag"; + } + + switch ( $format ) : + case 'array' : + $return =& $a; + break; + case 'list' : + $return = "\n"; + break; + default : + $return = join("\n", $a); + break; + endswitch; + + return apply_filters( 'wp_generate_tag_cloud', $return, $tags, $args ); } // @@ -300,4 +414,79 @@ function walk_category_dropdown_tree() { return call_user_func_array(array(&$walker, 'walk'), $args); } +// +// Tags +// + +function get_tag_link( $tag_id ) { + global $wp_rewrite; + $taglink = $wp_rewrite->get_tag_permastruct(); + + $tag = &get_term($tag_id, 'post_tag'); + if ( is_wp_error( $tag ) ) + return $tag; + $slug = $tag->slug; + + if ( empty($taglink) ) { + $file = get_option('home') . '/'; + $taglink = $file . '?tag=' . $slug; + } else { + $taglink = str_replace('%tag%', $slug, $taglink); + $taglink = get_option('home') . user_trailingslashit($taglink, 'category'); + } + return apply_filters('tag_link', $taglink, $tag_id); +} + +function get_the_tags( $id = 0 ) { + global $post; + + $id = (int) $id; + + if ( ! $id && ! in_the_loop() ) + return false; // in-the-loop function + + if ( !$id ) + $id = (int) $post->ID; + + $tags = get_object_term_cache($id, 'post_tag'); + if ( false === $tags ) + $tags = wp_get_object_terms($id, 'post_tag'); + + $tags = apply_filters( 'get_the_tags', $tags ); + if ( empty( $tags ) ) + return false; + return $tags; +} + +function get_the_tag_list( $before = '', $sep = '', $after = '' ) { + $tags = get_the_tags(); + + if ( empty( $tags ) ) + return false; + + $tag_list = $before; + foreach ( $tags as $tag ) { + $link = get_tag_link($tag->term_id); + if ( is_wp_error( $link ) ) + return $link; + $tag_links[] = ''; + } + + $tag_links = join( $sep, $tag_links ); + $tag_links = apply_filters( 'the_tags', $tag_links ); + $tag_list .= $tag_links; + + $tag_list .= $after; + + return $tag_list; +} + +function the_tags( $before = 'Tags: ', $sep = ', ', $after = '' ) { + $return = get_the_tag_list($before, $sep, $after); + if ( is_wp_error( $return ) ) + return false; + else + echo $return; +} + ?> diff --git a/wp-includes/category.php b/wp-includes/category.php index fcfb60f..71e5be8 100644 --- a/wp-includes/category.php +++ b/wp-includes/category.php @@ -4,7 +4,7 @@ function get_all_category_ids() { global $wpdb; if ( ! $cat_ids = wp_cache_get('all_category_ids', 'category') ) { - $cat_ids = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories"); + $cat_ids = get_terms('category', 'fields=ids&get=all'); wp_cache_add('all_category_ids', $cat_ids, 'category'); } @@ -12,162 +12,30 @@ function get_all_category_ids() { } function &get_categories($args = '') { - global $wpdb, $category_links; - - if ( is_array($args) ) - $r = &$args; - else - parse_str($args, $r); - - $defaults = array('type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC', - 'hide_empty' => true, 'include_last_update_time' => false, 'hierarchical' => 1, 'exclude' => '', 'include' => '', - 'number' => '', 'pad_counts' => false); - $r = array_merge($defaults, $r); - if ( 'count' == $r['orderby'] ) - $r['orderby'] = 'category_count'; - else - $r['orderby'] = "cat_" . $r['orderby']; // restricts order by to cat_ID and cat_name fields - $r['number'] = (int) $r['number']; - extract($r, EXTR_SKIP); - - $key = md5( serialize( $r ) ); - if ( $cache = wp_cache_get( 'get_categories', 'category' ) ) - if ( isset( $cache[ $key ] ) ) - return apply_filters('get_categories', $cache[$key], $r); - - $where = 'cat_ID > 0'; - $inclusions = ''; - if ( !empty($include) ) { - $child_of = 0; //ignore child_of and exclude params if using include - $exclude = ''; - $incategories = preg_split('/[\s,]+/',$include); - if ( count($incategories) ) { - foreach ( $incategories as $incat ) { - if (empty($inclusions)) - $inclusions = ' AND ( cat_ID = ' . intval($incat) . ' '; - else - $inclusions .= ' OR cat_ID = ' . intval($incat) . ' '; - } - } - } - if (!empty($inclusions)) - $inclusions .= ')'; - $where .= $inclusions; - - $exclusions = ''; - if ( !empty($exclude) ) { - $excategories = preg_split('/[\s,]+/',$exclude); - if ( count($excategories) ) { - foreach ( $excategories as $excat ) { - if (empty($exclusions)) - $exclusions = ' AND ( cat_ID <> ' . intval($excat) . ' '; - else - $exclusions .= ' AND cat_ID <> ' . intval($excat) . ' '; - // TODO: Exclude children of excluded cats? Note: children are getting excluded - } - } - } - if (!empty($exclusions)) - $exclusions .= ')'; - $exclusions = apply_filters('list_cats_exclusions', $exclusions, $r ); - $where .= $exclusions; - - if ( $hide_empty && !$hierarchical ) { - if ( 'link' == $type ) - $where .= ' AND link_count > 0'; - else - $where .= ' AND category_count > 0'; - } - - if ( !empty($number) ) - $number = 'LIMIT ' . $number; - else - $number = ''; - - $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE $where ORDER BY $orderby $order $number"); - - if ( empty($categories) ) - return array(); - - // TODO: Integrate this into the main query. - if ( $include_last_update_time ) { - $stamps = $wpdb->get_results("SELECT category_id, UNIX_TIMESTAMP( MAX(post_date) ) AS ts FROM $wpdb->posts, $wpdb->post2cat, $wpdb->categories - WHERE post_status = 'publish' AND post_id = ID AND $where GROUP BY category_id"); - global $cat_stamps; - foreach ($stamps as $stamp) - $cat_stamps[$stamp->category_id] = $stamp->ts; - function stamp_cat($cat) { - global $cat_stamps; - $cat->last_update_timestamp = $cat_stamps[$cat->cat_ID]; - return $cat; - } - $categories = array_map('stamp_cat', $categories); - unset($cat_stamps); - } - - if ( $child_of || $hierarchical ) { - $children = _get_category_hierarchy(); - if ( ! empty($children) ) - $categories = & _get_cat_children($child_of, $categories); - } + $defaults = array('type' => 'category'); + $args = wp_parse_args($args, $defaults); - // Update category counts to include children. - if ( $pad_counts ) - _pad_category_counts($type, $categories); - - // Make sure we show empty categories that have children. - if ( $hierarchical && $hide_empty ) { - foreach ( $categories as $k => $category ) { - if ( ! $category->{'link' == $type ? 'link_count' : 'category_count'} ) { - $children = _get_cat_children($category->cat_ID, $categories); - foreach ( $children as $child ) - if ( $child->{'link' == $type ? 'link_count' : 'category_count'} ) - continue 2; - - // It really is empty - unset($categories[$k]); - } - } - } - reset ( $categories ); + $taxonomy = 'category'; + if ( 'link' == $args['type'] ) + $taxonomy = 'link_category'; + $categories = get_terms($taxonomy, $args); - $cache[ $key ] = $categories; - wp_cache_add( 'get_categories', $cache, 'category' ); + foreach ( array_keys($categories) as $k ) + _make_cat_compat($categories[$k]); - $categories = apply_filters('get_categories', $categories, $r); return $categories; } // Retrieves category data given a category ID or category object. // Handles category caching. -function &get_category(&$category, $output = OBJECT) { - global $wpdb; +function &get_category($category, $output = OBJECT, $filter = 'raw') { + $category = get_term($category, 'category', $output, $filter); + if ( is_wp_error( $category ) ) + return $category; - if ( empty($category) ) - return null; + _make_cat_compat($category); - if ( is_object($category) ) { - wp_cache_add($category->cat_ID, $category, 'category'); - $_category = $category; - } else { - $category = (int) $category; - if ( ! $_category = wp_cache_get($category, 'category') ) { - $_category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$category' LIMIT 1"); - wp_cache_add($category, $_category, 'category'); - } - } - - $_category = apply_filters('get_category', $_category); - - if ( $output == OBJECT ) { - return $_category; - } elseif ( $output == ARRAY_A ) { - return get_object_vars($_category); - } elseif ( $output == ARRAY_N ) { - return array_values(get_object_vars($_category)); - } else { - return $_category; - } + return $category; } function get_category_by_path($category_path, $full_match = true, $output = OBJECT) { @@ -182,7 +50,7 @@ function get_category_by_path($category_path, $full_match = true, $output = OBJE foreach ( (array) $category_paths as $pathdir ) $full_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title($pathdir); - $categories = $wpdb->get_results("SELECT cat_ID, category_nicename, category_parent FROM $wpdb->categories WHERE category_nicename = '$leaf_path'"); + $categories = get_terms('category', "get=all&slug=$leaf_path"); if ( empty($categories) ) return NULL; @@ -190,29 +58,40 @@ function get_category_by_path($category_path, $full_match = true, $output = OBJE foreach ($categories as $category) { $path = '/' . $leaf_path; $curcategory = $category; - while ( ($curcategory->category_parent != 0) && ($curcategory->category_parent != $curcategory->cat_ID) ) { - $curcategory = $wpdb->get_row("SELECT cat_ID, category_nicename, category_parent FROM $wpdb->categories WHERE cat_ID = '$curcategory->category_parent'"); - $path = '/' . $curcategory->category_nicename . $path; + while ( ($curcategory->parent != 0) && ($curcategory->parent != $curcategory->term_id) ) { + $curcategory = get_term($curcategory->parent, 'category'); + if ( is_wp_error( $curcategory ) ) + return $curcategory; + $path = '/' . $curcategory->slug . $path; } if ( $path == $full_path ) - return get_category($category->cat_ID, $output); + return get_category($category->term_id, $output); } // If full matching is not required, return the first cat that matches the leaf. if ( ! $full_match ) - return get_category($categories[0]->cat_ID, $output); + return get_category($categories[0]->term_id, $output); return NULL; } +function get_category_by_slug( $slug ) { + $category = get_term_by('slug', $slug, 'category'); + if ( $category ) + _make_cat_compat($category); + + return $category; +} + // Get the ID of a category from its name function get_cat_ID($cat_name='General') { global $wpdb; - $cid = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'"); - - return $cid?$cid:1; // default to cat 1 + $cat = get_term_by('name', $cat_name, 'category'); + if ($cat) + return $cat->term_id; + return 0; } // Deprecate @@ -224,108 +103,91 @@ function get_catname($cat_ID) { function get_cat_name($cat_id) { $cat_id = (int) $cat_id; $category = &get_category($cat_id); - return $category->cat_name; + return $category->name; } -function cat_is_ancestor_of($cat1, $cat2) { - if ( is_int($cat1) ) - $cat1 = & get_category($cat1); - if ( is_int($cat2) ) - $cat2 = & get_category($cat2); +function cat_is_ancestor_of($cat1, $cat2) { + if ( is_int($cat1) ) + $cat1 = & get_category($cat1); + if ( is_int($cat2) ) + $cat2 = & get_category($cat2); - if ( !$cat1->cat_ID || !$cat2->category_parent ) - return false; + if ( !$cat1->term_id || !$cat2->parent ) + return false; - if ( $cat2->category_parent == $cat1->cat_ID ) - return true; + if ( $cat2->parent == $cat1->term_id ) + return true; - return cat_is_ancestor_of($cat1, get_category($cat2->parent_category)); -} + return cat_is_ancestor_of($cat1, get_category($cat2->parent)); +} -// -// Private -// +function sanitize_category($category, $context = 'display') { + return sanitize_term($category, 'category', $context); +} -function &_get_cat_children($category_id, $categories) { - if ( empty($categories) ) - return array(); +function sanitize_category_field($field, $value, $cat_id, $context) { + return sanitize_term_field($field, $value, $cat_id, 'category', $context); +} - $category_list = array(); - $has_children = _get_category_hierarchy(); +// Tags - if ( ( 0 != $category_id ) && ! isset($has_children[$category_id]) ) - return array(); +function &get_tags($args = '') { + global $wpdb, $category_links; - foreach ( $categories as $category ) { - if ( $category->cat_ID == $category_id ) - continue; + $key = md5( serialize( $args ) ); + if ( $cache = wp_cache_get( 'get_tags', 'category' ) ) + if ( isset( $cache[ $key ] ) ) + return apply_filters('get_tags', $cache[$key], $args); - if ( $category->category_parent == $category_id ) { - $category_list[] = $category; - if ( !isset($has_children[$category->cat_ID]) ) - continue; + $tags = get_terms('post_tag', $args); - if ( $children = _get_cat_children($category->cat_ID, $categories) ) - $category_list = array_merge($category_list, $children); - } - } + if ( empty($tags) ) + return array(); - return $category_list; -} + $cache[ $key ] = $tags; + wp_cache_set( 'get_tags', $cache, 'category' ); -// Recalculates link or post counts by including items from child categories -// Assumes all relevant children are already in the $categories argument -function _pad_category_counts($type, &$categories) { - global $wpdb; + $tags = apply_filters('get_tags', $tags, $args); + return $tags; +} - // Set up some useful arrays - foreach ( $categories as $key => $cat ) { - $cats[$cat->cat_ID] = & $categories[$key]; - $cat_IDs[] = $cat->cat_ID; - } +function &get_tag($tag, $output = OBJECT, $filter = 'raw') { + return get_term($tag, 'post_tag', $output, $filter); +} - // Get the relevant post2cat or link2cat records and stick them in a lookup table - if ( $type == 'post' ) { - $results = $wpdb->get_results("SELECT post_id, category_id FROM $wpdb->post2cat LEFT JOIN $wpdb->posts ON post_id = ID WHERE category_id IN (".join(',', $cat_IDs).") AND post_type = 'post' AND post_status = 'publish'"); - foreach ( $results as $row ) - ++$cat_items[$row->category_id][$row->post_id]; - } else { - $results = $wpdb->get_results("SELECT $wpdb->link2cat.link_id, category_id FROM $wpdb->link2cat LEFT JOIN $wpdb->links USING (link_id) WHERE category_id IN (".join(',', $cat_IDs).") AND link_visible = 'Y'"); - foreach ( $results as $row ) - ++$cat_items[$row->category_id][$row->link_id]; - } +// +// Cache +// - // Touch every ancestor's lookup row for each post in each category - foreach ( $cat_IDs as $cat_ID ) { - $child = $cat_ID; - while ( $parent = $cats[$child]->category_parent ) { - if ( !empty($cat_items[$cat_ID]) ) - foreach ( $cat_items[$cat_ID] as $item_id => $touches ) - ++$cat_items[$parent][$item_id]; - $child = $parent; - } - } +function update_category_cache() { + return true; +} - // Transfer the touched cells - foreach ( (array) $cat_items as $id => $items ) - if ( isset($cats[$id]) ) - $cats[$id]->{'link' == $type ? 'link_count' : 'category_count'} = count($items); +function clean_category_cache($id) { + clean_term_cache($id, 'category'); } -function _get_category_hierarchy() { - $children = get_option('category_children'); - if ( is_array($children) ) - return $children; +// +// Private helpers +// - $children = array(); - $categories = get_categories('hide_empty=0&hierarchical=0'); - foreach ( $categories as $cat ) { - if ( $cat->category_parent > 0 ) - $children[$cat->category_parent][] = $cat->cat_ID; +function _make_cat_compat( &$category) { + if ( is_object($category) ) { + $category->cat_ID = &$category->term_id; + $category->category_count = &$category->count; + $category->category_description = &$category->description; + $category->cat_name = &$category->name; + $category->category_nicename = &$category->slug; + $category->category_parent = &$category->parent; + } else if ( is_array($category) && isset($category['term_id']) ) { + $category['cat_ID'] = &$category['term_id']; + $category['category_count'] = &$category['count']; + $category['category_description'] = &$category['description']; + $category['cat_name'] = &$category['name']; + $category['category_nicename'] = &$category['slug']; + $category['category_parent'] = &$category['parent']; } - update_option('category_children', $children); - - return $children; } + ?> diff --git a/wp-includes/class-phpmailer.php b/wp-includes/class-phpmailer.php index 4c93bae..acacabb 100644 --- a/wp-includes/class-phpmailer.php +++ b/wp-includes/class-phpmailer.php @@ -96,7 +96,7 @@ class PHPMailer var $AltBody = ""; /** - * Sets word wrapping on the body of the message to a given number of + * Sets word wrapping on the body of the message to a given number of * characters. * @var int */ @@ -113,10 +113,10 @@ class PHPMailer * @var string */ var $Sendmail = "/usr/sbin/sendmail"; - + /** - * Path to PHPMailer plugins. This is now only useful if the SMTP class - * is in a different directory than the PHP include path. + * Path to PHPMailer plugins. This is now only useful if the SMTP class + * is in a different directory than the PHP include path. * @var string */ var $PluginDir = ""; @@ -186,7 +186,7 @@ class PHPMailer var $Password = ""; /** - * Sets the SMTP server timeout in seconds. This function will not + * Sets the SMTP server timeout in seconds. This function will not * work with the win32 version. * @var int */ @@ -199,9 +199,9 @@ class PHPMailer var $SMTPDebug = false; /** - * Prevents the SMTP connection from being closed after each mail - * sending. If this is set to true then to close the connection - * requires an explicit call to SmtpClose(). + * Prevents the SMTP connection from being closed after each mail + * sending. If this is set to true then to close the connection + * requires an explicit call to SmtpClose(). * @var bool */ var $SMTPKeepAlive = false; @@ -222,13 +222,13 @@ class PHPMailer var $error_count = 0; var $LE = "\n"; /**#@-*/ - + ///////////////////////////////////////////////// // VARIABLE METHODS ///////////////////////////////////////////////// /** - * Sets message type to HTML. + * Sets message type to HTML. * @param bool $bool * @return void */ @@ -264,7 +264,7 @@ class PHPMailer } /** - * Sets Mailer to send message using the qmail MTA. + * Sets Mailer to send message using the qmail MTA. * @return void */ function IsQmail() { @@ -278,7 +278,7 @@ class PHPMailer ///////////////////////////////////////////////// /** - * Adds a "To" address. + * Adds a "To" address. * @param string $address * @param string $name * @return void @@ -292,7 +292,7 @@ class PHPMailer /** * Adds a "Cc" address. Note: this function works * with the SMTP mailer on win32, not with the "mail" - * mailer. + * mailer. * @param string $address * @param string $name * @return void @@ -306,7 +306,7 @@ class PHPMailer /** * Adds a "Bcc" address. Note: this function works * with the SMTP mailer on win32, not with the "mail" - * mailer. + * mailer. * @param string $address * @param string $name * @return void @@ -318,7 +318,7 @@ class PHPMailer } /** - * Adds a "Reply-to" address. + * Adds a "Reply-to" address. * @param string $address * @param string $name * @return void @@ -337,7 +337,7 @@ class PHPMailer /** * Creates message and assigns Mailer. If the message is * not sent successfully then it returns false. Use the ErrorInfo - * variable to view description of the error. + * variable to view description of the error. * @return bool */ function Send() { @@ -382,9 +382,9 @@ class PHPMailer return $result; } - + /** - * Sends mail using the $Sendmail program. + * Sends mail using the $Sendmail program. * @access private * @return bool */ @@ -402,7 +402,7 @@ class PHPMailer fputs($mail, $header); fputs($mail, $body); - + $result = pclose($mail) >> 8 & 0xFF; if($result != 0) { @@ -414,7 +414,7 @@ class PHPMailer } /** - * Sends mail using the PHP mail() function. + * Sends mail using the PHP mail() function. * @access private * @return bool */ @@ -431,7 +431,7 @@ class PHPMailer $old_from = ini_get("sendmail_from"); ini_set("sendmail_from", $this->Sender); $params = sprintf("-oi -f %s", $this->Sender); - $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, + $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header, $params); } else @@ -457,7 +457,7 @@ class PHPMailer * @return bool */ function SmtpSend($header, $body) { - include_once($this->PluginDir . "class.smtp.php"); + include_once($this->PluginDir . "class-smtp.php"); $error = ""; $bad_rcpt = array(); @@ -518,7 +518,7 @@ class PHPMailer } /** - * Initiates a connection to an SMTP server. Returns false if the + * Initiates a connection to an SMTP server. Returns false if the * operation failed. * @access private * @return bool @@ -529,7 +529,7 @@ class PHPMailer $this->smtp->do_debug = $this->SMTPDebug; $hosts = explode(";", $this->Host); $index = 0; - $connection = ($this->smtp->Connected()); + $connection = ($this->smtp->Connected()); // Retry while there is no connection while($index < count($hosts) && $connection == false) @@ -548,10 +548,10 @@ class PHPMailer $this->smtp->Hello($this->Helo); else $this->smtp->Hello($this->ServerHostname()); - + if($this->SMTPAuth) { - if(!$this->smtp->Authenticate($this->Username, + if(!$this->smtp->Authenticate($this->Username, $this->Password)) { $this->SetError($this->Lang("authenticate")); @@ -585,7 +585,7 @@ class PHPMailer } /** - * Sets the language for all class error messages. Returns false + * Sets the language for all class error messages. Returns false * if it cannot load the language file. The default language type * is English. * @param string $lang_type Type of language (e.g. Portuguese: "br") @@ -604,7 +604,7 @@ class PHPMailer return false; } $this->language = $PHPMAILER_LANG; - + return true; } @@ -613,7 +613,7 @@ class PHPMailer ///////////////////////////////////////////////// /** - * Creates recipient headers. + * Creates recipient headers. * @access private * @return string */ @@ -629,9 +629,9 @@ class PHPMailer return $addr_str; } - + /** - * Formats an address correctly. + * Formats an address correctly. * @access private * @return string */ @@ -640,7 +640,7 @@ class PHPMailer $formatted = $addr[0]; else { - $formatted = $this->EncodeHeader($addr[1], 'phrase') . " <" . + $formatted = $this->EncodeHeader($addr[1], 'phrase') . " <" . $addr[0] . ">"; } @@ -650,7 +650,7 @@ class PHPMailer /** * Wraps message for use with mailers that do not * automatically perform wrapping and for quoted-printable. - * Original written by philippe. + * Original written by philippe. * @access private * @return string */ @@ -712,7 +712,7 @@ class PHPMailer else { $buf_o = $buf; - $buf .= ($e == 0) ? $word : (" " . $word); + $buf .= ($e == 0) ? $word : (" " . $word); if (strlen($buf) > $length and $buf_o != "") { @@ -726,7 +726,7 @@ class PHPMailer return $message; } - + /** * Set the body wrapping. * @access private @@ -735,7 +735,7 @@ class PHPMailer function SetWordWrap() { if($this->WordWrap < 1) return; - + switch($this->message_type) { case "alt": @@ -750,13 +750,13 @@ class PHPMailer } /** - * Assembles message header. + * Assembles message header. * @access private * @return string */ function CreateHeader() { $result = ""; - + // Set the boundaries $uniq_id = md5(uniqid(time())); $this->boundary[1] = "b1_" . $uniq_id; @@ -767,7 +767,7 @@ class PHPMailer $result .= $this->HeaderLine("Return-Path", trim($this->From)); else $result .= $this->HeaderLine("Return-Path", trim($this->Sender)); - + // To be created automatically by mail() if($this->Mailer != "mail") { @@ -782,7 +782,7 @@ class PHPMailer $from = array(); $from[0][0] = trim($this->From); $from[0][1] = $this->FromName; - $result .= $this->AddrAppend("From", $from); + $result .= $this->AddrAppend("From", $from); // sendmail and mail() extract Bcc from the header before sending if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0)) @@ -797,17 +797,17 @@ class PHPMailer $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE); $result .= $this->HeaderLine("X-Priority", $this->Priority); - + if($this->ConfirmReadingTo != "") { - $result .= $this->HeaderLine("Disposition-Notification-To", + $result .= $this->HeaderLine("Disposition-Notification-To", "<" . trim($this->ConfirmReadingTo) . ">"); } // Add custom headers for($index = 0; $index < count($this->CustomHeader); $index++) { - $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), + $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1]))); } $result .= $this->HeaderLine("MIME-Version", "1.0"); @@ -824,8 +824,8 @@ class PHPMailer case "alt_attachments": if($this->InlineImageExists()) { - $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", - "multipart/related", $this->LE, $this->LE, + $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", + "multipart/related", $this->LE, $this->LE, $this->boundary[1], $this->LE); } else @@ -859,16 +859,16 @@ class PHPMailer switch($this->message_type) { case "alt": - $result .= $this->GetBoundary($this->boundary[1], "", + $result .= $this->GetBoundary($this->boundary[1], "", "text/plain", ""); $result .= $this->EncodeString($this->AltBody, $this->Encoding); $result .= $this->LE.$this->LE; - $result .= $this->GetBoundary($this->boundary[1], "", + $result .= $this->GetBoundary($this->boundary[1], "", "text/html", ""); - + $result .= $this->EncodeString($this->Body, $this->Encoding); $result .= $this->LE.$this->LE; - + $result .= $this->EndBoundary($this->boundary[1]); break; case "plain": @@ -878,32 +878,32 @@ class PHPMailer $result .= $this->GetBoundary($this->boundary[1], "", "", ""); $result .= $this->EncodeString($this->Body, $this->Encoding); $result .= $this->LE; - + $result .= $this->AttachAll(); break; case "alt_attachments": $result .= sprintf("--%s%s", $this->boundary[1], $this->LE); $result .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", - "multipart/alternative", $this->LE, + "multipart/alternative", $this->LE, $this->boundary[2], $this->LE.$this->LE); - + // Create text body - $result .= $this->GetBoundary($this->boundary[2], "", + $result .= $this->GetBoundary($this->boundary[2], "", "text/plain", "") . $this->LE; $result .= $this->EncodeString($this->AltBody, $this->Encoding); $result .= $this->LE.$this->LE; - + // Create the HTML body - $result .= $this->GetBoundary($this->boundary[2], "", + $result .= $this->GetBoundary($this->boundary[2], "", "text/html", "") . $this->LE; - + $result .= $this->EncodeString($this->Body, $this->Encoding); $result .= $this->LE.$this->LE; $result .= $this->EndBoundary($this->boundary[2]); - + $result .= $this->AttachAll(); break; } @@ -924,23 +924,23 @@ class PHPMailer if($encoding == "") { $encoding = $this->Encoding; } $result .= $this->TextLine("--" . $boundary); - $result .= sprintf("Content-Type: %s; charset = \"%s\"", + $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet); $result .= $this->LE; $result .= $this->HeaderLine("Content-Transfer-Encoding", $encoding); $result .= $this->LE; - + return $result; } - + /** * Returns the end of a message boundary. * @access private */ function EndBoundary($boundary) { - return $this->LE . "--" . $boundary . "--" . $this->LE; + return $this->LE . "--" . $boundary . "--" . $this->LE; } - + /** * Sets the message type. * @access private @@ -992,7 +992,7 @@ class PHPMailer * @param string $type File extension (MIME) type. * @return bool */ - function AddAttachment($path, $name = "", $encoding = "base64", + function AddAttachment($path, $name = "", $encoding = "base64", $type = "application/octet-stream") { if(!@is_file($path)) { @@ -1043,7 +1043,7 @@ class PHPMailer $type = $this->attachment[$i][4]; $disposition = $this->attachment[$i][6]; $cid = $this->attachment[$i][7]; - + $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE); $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE); $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE); @@ -1051,7 +1051,7 @@ class PHPMailer if($disposition == "inline") $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); - $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", + $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $name, $this->LE.$this->LE); // Encode as string attachment @@ -1063,7 +1063,7 @@ class PHPMailer } else { - $mime[] = $this->EncodeFile($path, $encoding); + $mime[] = $this->EncodeFile($path, $encoding); if($this->IsError()) { return ""; } $mime[] = $this->LE.$this->LE; } @@ -1073,7 +1073,7 @@ class PHPMailer return join("", $mime); } - + /** * Encodes attachment in requested format. Returns an * empty string on failure. @@ -1129,13 +1129,13 @@ class PHPMailer } /** - * Encode a header string to best of Q, B, quoted or none. + * Encode a header string to best of Q, B, quoted or none. * @access private * @return string */ function EncodeHeader ($str, $position = 'text') { $x = 0; - + switch (strtolower($position)) { case 'phrase': if (!preg_match('/[\200-\377]/', $str)) { @@ -1177,12 +1177,12 @@ class PHPMailer $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded); $encoded = trim(str_replace("\n", $this->LE, $encoded)); - + return $encoded; } - + /** - * Encode string to quoted-printable. + * Encode string to quoted-printable. * @access private * @return string */ @@ -1205,7 +1205,7 @@ class PHPMailer } /** - * Encode string to q encoding. + * Encode string to q encoding. * @access private * @return string */ @@ -1226,7 +1226,7 @@ class PHPMailer "'='.sprintf('%02X', ord('\\1'))", $encoded); break; } - + // Replace every spaces to _ (more readable than =20) $encoded = str_replace(" ", "_", $encoded); @@ -1243,7 +1243,7 @@ class PHPMailer * @param string $type File extension (MIME) type. * @return void */ - function AddStringAttachment($string, $filename, $encoding = "base64", + function AddStringAttachment($string, $filename, $encoding = "base64", $type = "application/octet-stream") { // Append to $attachment array $cur = count($this->attachment); @@ -1256,23 +1256,23 @@ class PHPMailer $this->attachment[$cur][6] = "attachment"; $this->attachment[$cur][7] = 0; } - + /** - * Adds an embedded attachment. This can include images, sounds, and - * just about any other document. Make sure to set the $type to an - * image type. For JPEG images use "image/jpeg" and for GIF images + * Adds an embedded attachment. This can include images, sounds, and + * just about any other document. Make sure to set the $type to an + * image type. For JPEG images use "image/jpeg" and for GIF images * use "image/gif". * @param string $path Path to the attachment. - * @param string $cid Content ID of the attachment. Use this to identify + * @param string $cid Content ID of the attachment. Use this to identify * the Id for accessing the image in an HTML form. * @param string $name Overrides the attachment name. * @param string $encoding File encoding (see $Encoding). - * @param string $type File extension (MIME) type. + * @param string $type File extension (MIME) type. * @return bool */ - function AddEmbeddedImage($path, $cid, $name = "", $encoding = "base64", + function AddEmbeddedImage($path, $cid, $name = "", $encoding = "base64", $type = "application/octet-stream") { - + if(!@is_file($path)) { $this->SetError($this->Lang("file_access") . $path); @@ -1293,10 +1293,10 @@ class PHPMailer $this->attachment[$cur][5] = false; // isStringAttachment $this->attachment[$cur][6] = "inline"; $this->attachment[$cur][7] = $cid; - + return true; } - + /** * Returns true if an inline attachment is present. * @access private @@ -1312,7 +1312,7 @@ class PHPMailer break; } } - + return $result; } @@ -1397,7 +1397,7 @@ class PHPMailer } /** - * Returns the proper RFC 822 formatted date. + * Returns the proper RFC 822 formatted date. * @access private * @return string */ @@ -1410,10 +1410,10 @@ class PHPMailer return $result; } - + /** - * Returns the appropriate server variable. Should work with both - * PHP 4.1.0+ as well as older versions. Returns an empty string + * Returns the appropriate server variable. Should work with both + * PHP 4.1.0+ as well as older versions. Returns an empty string * if nothing is found. * @access private * @return mixed @@ -1428,7 +1428,7 @@ class PHPMailer if(!isset($_SERVER["REMOTE_ADDR"])) $_SERVER = $HTTP_ENV_VARS; // must be Apache } - + if(isset($_SERVER[$varName])) return $_SERVER[$varName]; else @@ -1459,13 +1459,13 @@ class PHPMailer function Lang($key) { if(count($this->language) < 1) $this->SetLanguage("en"); // set the default language - + if(isset($this->language[$key])) return $this->language[$key]; else return "Language string failed to load: " . $key; } - + /** * Returns true if an error occurred. * @return bool @@ -1475,7 +1475,7 @@ class PHPMailer } /** - * Changes every end of line from CR or LF to CRLF. + * Changes every end of line from CR or LF to CRLF. * @access private * @return string */ @@ -1487,7 +1487,7 @@ class PHPMailer } /** - * Adds a custom header. + * Adds a custom header. * @return void */ function AddCustomHeader($custom_header) { diff --git a/wp-includes/class-pop3.php b/wp-includes/class-pop3.php index fccf329..38c6694 100644 --- a/wp-includes/class-pop3.php +++ b/wp-includes/class-pop3.php @@ -1,4 +1,4 @@ -TIMEOUT = $timeout; if (!ini_get('safe_mode')) - set_time_limit($timeout); + set_time_limit($timeout); } return true; } function update_timer () { if (!ini_get('safe_mode')) - set_time_limit($this->TIMEOUT); + set_time_limit($this->TIMEOUT); return true; } @@ -74,12 +74,12 @@ class POP3 { // If MAILSERVER is set, override $server with it's value - if (!isset($port) || !$port) {$port = 110;} + if (!isset($port) || !$port) {$port = 110;} if(!empty($this->MAILSERVER)) $server = $this->MAILSERVER; if(empty($server)){ - $this->ERROR = _("POP3 connect:") . ' ' . _("No server specified"); + $this->ERROR = "POP3 connect: " . _("No server specified"); unset($this->FP); return false; } @@ -87,7 +87,7 @@ class POP3 { $fp = @fsockopen("$server", $port, $errno, $errstr); if(!$fp) { - $this->ERROR = _("POP3 connect:") . ' ' . _("Error ") . "[$errno] [$errstr]"; + $this->ERROR = "POP3 connect: " . _("Error ") . "[$errno] [$errstr]"; unset($this->FP); return false; } @@ -99,7 +99,7 @@ class POP3 { if($this->DEBUG) error_log("POP3 SEND [connect: $server] GOT [$reply]",0); if(!$this->is_ok($reply)) { - $this->ERROR = _("POP3 connect:") . ' ' . _("Error ") . "[$reply]"; + $this->ERROR = "POP3 connect: " . _("Error ") . "[$reply]"; unset($this->FP); return false; } @@ -112,15 +112,15 @@ class POP3 { // Sends the USER command, returns true or false if( empty($user) ) { - $this->ERROR = _("POP3 user:") . ' ' . _("no login ID submitted"); + $this->ERROR = "POP3 user: " . _("no login ID submitted"); return false; } elseif(!isset($this->FP)) { - $this->ERROR = _("POP3 user:") . ' ' . _("connection not established"); + $this->ERROR = "POP3 user: " . _("connection not established"); return false; } else { $reply = $this->send_cmd("USER $user"); if(!$this->is_ok($reply)) { - $this->ERROR = _("POP3 user:") . ' ' . _("Error ") . "[$reply]"; + $this->ERROR = "POP3 user: " . _("Error ") . "[$reply]"; return false; } else return true; @@ -132,15 +132,15 @@ class POP3 { // returns false (undef) on Auth failure if(empty($pass)) { - $this->ERROR = _("POP3 pass:") . ' ' . _("No password submitted"); + $this->ERROR = "POP3 pass: " . _("No password submitted"); return false; } elseif(!isset($this->FP)) { - $this->ERROR = _("POP3 pass:") . ' ' . _("connection not established"); + $this->ERROR = "POP3 pass: " . _("connection not established"); return false; } else { $reply = $this->send_cmd("PASS $pass"); if(!$this->is_ok($reply)) { - $this->ERROR = _("POP3 pass:") . ' ' . _("Authentication failed ") . "[$reply]"; + $this->ERROR = "POP3 pass: " . _("Authentication failed") . " [$reply]"; $this->quit(); return false; } else { @@ -159,21 +159,21 @@ class POP3 { // (apop is optional per rfc1939) if(!isset($this->FP)) { - $this->ERROR = _("POP3 apop:") . ' ' . _("No connection to server"); + $this->ERROR = "POP3 apop: " . _("No connection to server"); return false; } elseif(!$this->ALLOWAPOP) { $retVal = $this->login($login,$pass); return $retVal; } elseif(empty($login)) { - $this->ERROR = _("POP3 apop:") . ' ' . _("No login ID submitted"); + $this->ERROR = "POP3 apop: " . _("No login ID submitted"); return false; } elseif(empty($pass)) { - $this->ERROR = _("POP3 apop:") . ' ' . _("No password submitted"); + $this->ERROR = "POP3 apop: " . _("No password submitted"); return false; } else { $banner = $this->BANNER; if( (!$banner) or (empty($banner)) ) { - $this->ERROR = _("POP3 apop:") . ' ' . _("No server banner") . ' - ' . _("abort"); + $this->ERROR = "POP3 apop: " . _("No server banner") . ' - ' . _("abort"); $retVal = $this->login($login,$pass); return $retVal; } else { @@ -183,7 +183,7 @@ class POP3 { $cmd = "APOP $login $APOPString"; $reply = $this->send_cmd($cmd); if(!$this->is_ok($reply)) { - $this->ERROR = _("POP3 apop:") . ' ' . _("apop authentication failed") . ' - ' . _("abort"); + $this->ERROR = "POP3 apop: " . _("apop authentication failed") . ' - ' . _("abort"); $retVal = $this->login($login,$pass); return $retVal; } else { @@ -202,7 +202,7 @@ class POP3 { // the number of messages.) if( !isset($this->FP) ) { - $this->ERROR = _("POP3 login:") . ' ' . _("No connection to server"); + $this->ERROR = "POP3 login: " . _("No connection to server"); return false; } else { $fp = $this->FP; @@ -227,7 +227,7 @@ class POP3 { // only the header information, and none of the body. if(!isset($this->FP)) { - $this->ERROR = _("POP3 top:") . ' ' . _("No connection to server"); + $this->ERROR = "POP3 top: " . _("No connection to server"); return false; } $this->update_timer(); @@ -243,7 +243,7 @@ class POP3 { } if(!$this->is_ok($reply)) { - $this->ERROR = _("POP3 top:") . ' ' . _("Error ") . "[$reply]"; + $this->ERROR = "POP3 top: " . _("Error ") . "[$reply]"; return false; } @@ -269,7 +269,7 @@ class POP3 { if(!isset($this->FP)) { - $this->ERROR = _("POP3 pop_list:") . ' ' . _("No connection to server"); + $this->ERROR = "POP3 pop_list: " . _("No connection to server"); return false; } $fp = $this->FP; @@ -297,7 +297,7 @@ class POP3 { } if(!$this->is_ok($reply)) { - $this->ERROR = _("POP3 pop_list:") . ' ' . _("Error ") . "[$reply]"; + $this->ERROR = "POP3 pop_list: " . _("Error ") . "[$reply]"; return false; } list($junk,$num,$size) = preg_split('/\s+/',$reply); @@ -308,7 +308,7 @@ class POP3 { if(!$this->is_ok($reply)) { $reply = $this->strip_clf($reply); - $this->ERROR = _("POP3 pop_list:") . ' ' . _("Error ") . "[$reply]"; + $this->ERROR = "POP3 pop_list: " . _("Error ") . "[$reply]"; return false; } $MsgArray = array(); @@ -320,7 +320,7 @@ class POP3 { $line = $this->strip_clf($line); if(ereg("^\.",$line)) { - $this->ERROR = _("POP3 pop_list:") . ' ' . _("Premature end of list"); + $this->ERROR = "POP3 pop_list: " . _("Premature end of list"); return false; } list($thisMsg,$msgSize) = preg_split('/\s+/',$line); @@ -343,7 +343,7 @@ class POP3 { if(!isset($this->FP)) { - $this->ERROR = _("POP3 get:") . ' ' . _("No connection to server"); + $this->ERROR = "POP3 get: " . _("No connection to server"); return false; } @@ -356,25 +356,21 @@ class POP3 { if(!$this->is_ok($reply)) { - $this->ERROR = _("POP3 get:") . ' ' . _("Error ") . "[$reply]"; + $this->ERROR = "POP3 get: " . _("Error ") . "[$reply]"; return false; } $count = 0; $MsgArray = array(); - $line = ""; + $line = fgets($fp,$buffer); while ( !ereg("^\.\r\n",$line)) { - $line = fgets($fp,$buffer); - if (preg_match("/^\s+/", $line) && $count > 0) { - $MsgArray[$count-1] .= $line; - continue; - } - if(empty($line)) { break; } - + if ( $line{0} == '.' ) { $line = substr($line,1); } $MsgArray[$count] = $line; $count++; + $line = fgets($fp,$buffer); + if(empty($line)) { break; } } return $MsgArray; } @@ -387,14 +383,14 @@ class POP3 { $last = -1; if(!isset($this->FP)) { - $this->ERROR = _("POP3 last:") . ' ' . _("No connection to server"); + $this->ERROR = "POP3 last: " . _("No connection to server"); return $last; } $reply = $this->send_cmd("STAT"); if(!$this->is_ok($reply)) { - $this->ERROR = _("POP3 last:") . ' ' . _("Error ") . "[$reply]"; + $this->ERROR = "POP3 last: " . _("Error ") . "[$reply]"; return $last; } @@ -417,7 +413,7 @@ class POP3 { if(!isset($this->FP)) { - $this->ERROR = _("POP3 reset:") . ' ' . _("No connection to server"); + $this->ERROR = "POP3 reset: " . _("No connection to server"); return false; } $reply = $this->send_cmd("RSET"); @@ -427,7 +423,7 @@ class POP3 { // response - if it ever does, something truely // wild is going on. - $this->ERROR = _("POP3 reset:") . ' ' . _("Error ") . "[$reply]"; + $this->ERROR = "POP3 reset: " . _("Error ") . "[$reply]"; @error_log("POP3 reset: ERROR [$reply]",0); } $this->quit(); @@ -451,13 +447,13 @@ class POP3 { if(!isset($this->FP)) { - $this->ERROR = _("POP3 send_cmd:") . ' ' . _("No connection to server"); + $this->ERROR = "POP3 send_cmd: " . _("No connection to server"); return false; } if(empty($cmd)) { - $this->ERROR = _("POP3 send_cmd:") . ' ' . _("Empty command string"); + $this->ERROR = "POP3 send_cmd: " . _("Empty command string"); return ""; } @@ -477,7 +473,7 @@ class POP3 { if(!isset($this->FP)) { - $this->ERROR = _("POP3 quit:") . ' ' . _("connection does not exist"); + $this->ERROR = "POP3 quit: " . _("connection does not exist"); return false; } $fp = $this->FP; @@ -514,7 +510,7 @@ class POP3 { // Array element 0 will contain the total number of msgs if(!isset($this->FP)) { - $this->ERROR = _("POP3 uidl:") . ' ' . _("No connection to server"); + $this->ERROR = "POP3 uidl: " . _("No connection to server"); return false; } @@ -526,7 +522,7 @@ class POP3 { $reply = $this->send_cmd($cmd); if(!$this->is_ok($reply)) { - $this->ERROR = _("POP3 uidl:") . ' ' . _("Error ") . "[$reply]"; + $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]"; return false; } list ($ok,$num,$myUidl) = preg_split('/\s+/',$reply); @@ -549,7 +545,7 @@ class POP3 { if($this->DEBUG) { @error_log("POP3 SEND [$cmd] GOT [$reply]",0); } if(!$this->is_ok($reply)) { - $this->ERROR = _("POP3 uidl:") . ' ' . _("Error ") . "[$reply]"; + $this->ERROR = "POP3 uidl: " . _("Error ") . "[$reply]"; return false; } @@ -582,18 +578,18 @@ class POP3 { if(!isset($this->FP)) { - $this->ERROR = _("POP3 delete:") . ' ' . _("No connection to server"); + $this->ERROR = "POP3 delete: " . _("No connection to server"); return false; } if(empty($msgNum)) { - $this->ERROR = _("POP3 delete:") . ' ' . _("No msg number submitted"); + $this->ERROR = "POP3 delete: " . _("No msg number submitted"); return false; } $reply = $this->send_cmd("DELE $msgNum"); if(!$this->is_ok($reply)) { - $this->ERROR = _("POP3 delete:") . ' ' . _("Command failed ") . "[$reply]"; + $this->ERROR = "POP3 delete: " . _("Command failed ") . "[$reply]"; return false; } return true; @@ -630,8 +626,8 @@ class POP3 { $length = strlen($server_text); for($count =0; $count < $length; $count++) { - $digit = substr($server_text, $count, 1); - if (!empty($digit)) { + $digit = substr($server_text,$count,1); + if(!empty($digit)) { if( (!$outside) && ($digit != '<') && ($digit != '>') ) { $banner .= $digit; @@ -651,5 +647,4 @@ class POP3 { } } // End class - ?> diff --git a/wp-includes/classes.php b/wp-includes/classes.php index dd05256..6e55c45 100644 --- a/wp-includes/classes.php +++ b/wp-includes/classes.php @@ -1,9 +1,9 @@ public_query_vars[] = $qv; } + function set_query_var($key, $value) { + $this->query_vars[$key] = $value; + } + function parse_request($extra_query_vars = '') { global $wp_rewrite; @@ -176,9 +180,9 @@ class WP { status_header( 404 ); if ( !is_user_logged_in() ) nocache_headers(); - @header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); + @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); } else if ( empty($this->query_vars['feed']) ) { - @header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); + @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'] @@ -507,10 +511,10 @@ class Walker_Page extends Walker { if ( $depth ) $indent = str_repeat("\t", $depth); extract($args, EXTR_SKIP); - $css_class = 'page_item'; + $css_class = 'page_item page-item-'.$page->ID; $_current_page = get_page( $current_page ); if ( $page->ID == $current_page ) - $css_class .= ' current_page_item'; + $css_class .= ' current_page_item '; elseif ( $_current_page && $page->ID == $_current_page->post_parent ) $css_class .= ' current_page_parent'; @@ -557,7 +561,7 @@ class Walker_PageDropdown extends Walker { class Walker_Category extends Walker { var $tree_type = 'category'; - var $db_fields = array ('parent' => 'category_parent', 'id' => 'cat_ID'); //TODO: decouple this + var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this function start_lvl($output, $depth, $args) { if ( 'list' != $args['style'] ) @@ -580,13 +584,13 @@ class Walker_Category extends Walker { function start_el($output, $category, $depth, $args) { extract($args); - $cat_name = attribute_escape( $category->cat_name); + $cat_name = attribute_escape( $category->name); $cat_name = apply_filters( 'list_cats', $cat_name, $category ); - $link = 'category_description) ) + $link = 'description) ) $link .= 'title="' . sprintf(__( 'View all posts filed under %s' ), $cat_name) . '"'; else - $link .= 'title="' . attribute_escape( apply_filters( 'category_description', $category->category_description, $category )) . '"'; + $link .= 'title="' . attribute_escape( apply_filters( 'category_description', $category->description, $category )) . '"'; $link .= '>'; $link .= $cat_name . ''; @@ -596,7 +600,7 @@ class Walker_Category extends Walker { if ( empty($feed_image) ) $link .= '('; - $link .= 'term_id, $category->slug ) . '"'; if ( empty($feed) ) $alt = ' alt="' . sprintf(__( 'Feed for all posts filed under %s' ), $cat_name ) . '"'; @@ -619,7 +623,7 @@ class Walker_Category extends Walker { } if ( isset($show_count) && $show_count ) - $link .= ' (' . intval($category->category_count) . ')'; + $link .= ' (' . intval($category->count) . ')'; if ( isset($show_date) && $show_date ) { $link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp); @@ -630,10 +634,12 @@ class Walker_Category extends Walker { if ( 'list' == $args['style'] ) { $output .= "\tcat_ID == $current_category) ) - $output .= ' class="current-cat"'; - elseif ( $_current_category && ($category->cat_ID == $_current_category->category_parent) ) - $output .= ' class="current-cat-parent"'; + $class = 'cat-item cat-item-'.$category->term_id; + if ( $current_category && ($category->term_id == $current_category) ) + $class .= ' current-cat'; + elseif ( $_current_category && ($category->term_id == $_current_category->parent) ) + $class .= ' current-cat-parent'; + $output .= ' class="'.$class.'"'; $output .= ">$link\n"; } else { $output .= "\t$link
    \n"; @@ -654,19 +660,19 @@ 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 + var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this function start_el($output, $category, $depth, $args) { $pad = str_repeat(' ', $depth * 3); - $cat_name = apply_filters('list_cats', $category->cat_name, $category); - $output .= "\t
    '; diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 82a00ab..3fedd9b 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -71,25 +71,28 @@ function get_approved_comments($post_id) { // Retrieves comment data given a comment ID or comment object. // Handles comment caching. function &get_comment(&$comment, $output = OBJECT) { - global $comment_cache, $wpdb; - - if ( empty($comment) ) - return null; + global $wpdb; - if ( is_object($comment) ) { - if ( !isset($comment_cache[$comment->comment_ID]) ) - $comment_cache[$comment->comment_ID] = &$comment; - $_comment = & $comment_cache[$comment->comment_ID]; + if ( empty($comment) ) { + if ( isset($GLOBALS['comment']) ) + $_comment = & $GLOBALS['comment']; + else + $_comment = null; + } elseif ( is_object($comment) ) { + wp_cache_add($comment->comment_ID, $comment, 'comment'); + $_comment = $comment; } else { $comment = (int) $comment; - if ( !isset($comment_cache[$comment]) ) { + if ( isset($GLOBALS['comment']) && ($GLOBALS['comment']->comment_ID == $comment) ) { + $_comment = & $GLOBALS['comment']; + } elseif ( ! $_comment = wp_cache_get($comment, 'comment') ) { $_comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment' LIMIT 1"); - $comment_cache[$comment->comment_ID] = & $_comment; - } else { - $_comment = & $comment_cache[$comment]; + wp_cache_add($_comment->comment_ID, $_comment, 'comment'); } } + $_comment = apply_filters('get_comment', $_comment); + if ( $output == OBJECT ) { return $_comment; } elseif ( $output == ARRAY_A ) { @@ -135,13 +138,13 @@ function get_lastcommentmodified($timezone = 'server') { if ( !isset($cache_lastcommentmodified[$timezone]) ) { switch ( strtolower($timezone)) { case 'gmt': - $lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1"); + $lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_date_gmt <= '$now' AND comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1"); break; case 'blog': - $lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM $wpdb->comments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1"); + $lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM $wpdb->comments WHERE comment_date_gmt <= '$now' AND comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1"); break; case 'server': - $lastcommentmodified = $wpdb->get_var("SELECT DATE_ADD(comment_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->comments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1"); + $lastcommentmodified = $wpdb->get_var("SELECT DATE_ADD(comment_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->comments WHERE comment_date_gmt <= '$now' AND comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1"); break; } $cache_lastcommentmodified[$timezone] = $lastcommentmodified; @@ -170,7 +173,6 @@ function sanitize_comment_cookies() { if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) { $comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]); $comment_author_url = stripslashes($comment_author_url); - $comment_author_url = clean_url($comment_author_url); $_COOKIE['comment_author_url_'.COOKIEHASH] = $comment_author_url; } } @@ -188,16 +190,7 @@ function wp_allow_comment($commentdata) { if ( $wpdb->get_var($dupe) ) wp_die( __('Duplicate comment detected; it looks as though you\'ve already said that!') ); - // Simple flood-protection - if ( $lasttime = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_author_IP = '$comment_author_IP' OR comment_author_email = '$comment_author_email' ORDER BY comment_date DESC LIMIT 1") ) { - $time_lastcomment = mysql2date('U', $lasttime); - $time_newcomment = mysql2date('U', $comment_date_gmt); - $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment); - if ( $flood_die ) { - do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment); - wp_die( __('You are posting comments too quickly. Slow down.') ); - } - } + do_action( 'check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt ); if ( $user_id ) { $userdata = get_userdata($user_id); @@ -222,6 +215,18 @@ function wp_allow_comment($commentdata) { return $approved; } +function check_comment_flood_db( $ip, $email, $date ) { + global $wpdb; + if ( $lasttime = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_author_IP = '$ip' OR comment_author_email = '$email' ORDER BY comment_date DESC LIMIT 1") ) { + $time_lastcomment = mysql2date('U', $lasttime); + $time_newcomment = mysql2date('U', $date); + $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment); + if ( $flood_die ) { + do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment); + wp_die( __('You are posting comments too quickly. Slow down.') ); + } + } +} function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) { global $wpdb; @@ -281,6 +286,8 @@ function wp_delete_comment($comment_id) { if ( $post_id && $comment->comment_approved == 1 ) wp_update_comment_count($post_id); + clean_comment_cache($comment_id); + do_action('wp_set_comment_status', $comment_id, 'delete'); return true; } @@ -289,15 +296,19 @@ function wp_delete_comment($comment_id) { function wp_get_comment_status($comment_id) { global $wpdb; - $result = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1"); + $comment = get_comment($comment_id); + if ( !$comment ) + return false; - if ( $result == NULL ) + $approved = $comment->comment_approved; + + if ( $approved == NULL ) return 'deleted'; - elseif ( $result == '1' ) + elseif ( $approved == '1' ) return 'approved'; - elseif ( $result == '0' ) + elseif ( $approved == '0' ) return 'unapproved'; - elseif ( $result == 'spam' ) + elseif ( $approved == 'spam' ) return 'spam'; else return false; @@ -434,9 +445,12 @@ function wp_set_comment_status($comment_id, $comment_status) { if ( !$wpdb->query($query) ) return false; + clean_comment_cache($comment_id); + do_action('wp_set_comment_status', $comment_id, $comment_status); $comment = get_comment($comment_id); wp_update_comment_count($comment->comment_post_ID); + return true; } @@ -475,6 +489,8 @@ function wp_update_comment($commentarr) { WHERE comment_ID = $comment_ID" ); $rval = $wpdb->rows_affected; + + clean_comment_cache($comment_ID); wp_update_comment_count($comment_post_ID); do_action('edit_comment', $comment_ID); return $rval; @@ -486,17 +502,21 @@ function wp_update_comment_count($post_id) { $post_id = (int) $post_id; if ( !$post_id ) return false; - $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$post_id' AND comment_approved = '1'"); - $wpdb->query("UPDATE $wpdb->posts SET comment_count = $count WHERE ID = '$post_id'"); - $comment_count_cache[$post_id] = $count; + if ( !$post = get_post($post_id) ) + return false; + + $old = (int) $post->comment_count; + $new = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$post_id' AND comment_approved = '1'"); + $wpdb->query("UPDATE $wpdb->posts SET comment_count = '$new' WHERE ID = '$post_id'"); + $comment_count_cache[$post_id] = $new; - $post = get_post($post_id); if ( 'page' == $post->post_type ) clean_page_cache( $post_id ); else clean_post_cache( $post_id ); - do_action('edit_post', $post_id); + do_action('wp_update_comment_count', $post_id, $new, $old); + do_action('edit_post', $post_id, $post); return true; } @@ -672,9 +692,7 @@ function pingback($content, $post_ID) { include_once(ABSPATH . WPINC . '/class-IXR.php'); // original code by Mort (http://mort.mine.nu:8080) - $log = debug_fopen(ABSPATH . '/pingback.log', 'a'); $post_links = array(); - debug_fwrite($log, 'BEGIN ' . date('YmdHis', time()) . "\n"); $pung = get_pung($post_ID); @@ -690,10 +708,6 @@ function pingback($content, $post_ID) { // http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp); - // Debug - debug_fwrite($log, 'Post contents:'); - debug_fwrite($log, $content."\n"); - // Step 2. // Walking thru the links array // first we get rid of links pointing to sites, not to specific files @@ -717,16 +731,12 @@ function pingback($content, $post_ID) { do_action_ref_array('pre_ping', array(&$post_links, &$pung)); foreach ( (array) $post_links as $pagelinkedto ) { - debug_fwrite($log, "Processing -- $pagelinkedto\n"); $pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048); if ( $pingback_server_url ) { @ set_time_limit( 60 ); // Now, the RPC call - debug_fwrite($log, "Page Linked To: $pagelinkedto \n"); - debug_fwrite($log, 'Page Linked From: '); $pagelinkedfrom = get_permalink($post_ID); - debug_fwrite($log, $pagelinkedfrom."\n"); // using a timeout of 3 seconds should be enough to cover slow servers $client = new IXR_Client($pingback_server_url); @@ -736,15 +746,10 @@ function pingback($content, $post_ID) { // when set to true, this outputs debug messages by itself $client->debug = false; - if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto ) ) + if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || ( isset($client->error->code) && 48 == $client->error->code ) ) // Already registered add_ping( $post_ID, $pagelinkedto ); - else - debug_fwrite($log, "Error.\n Fault code: ".$client->getErrorCode()." : ".$client->getErrorMessage()."\n"); } } - - debug_fwrite($log, "\nEND: ".time()."\n****************************\n"); - debug_fclose($log); } @@ -781,16 +786,6 @@ function trackback($trackback_url, $title, $excerpt, $ID) { $trackback_url['port'] = 80; $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4); @fputs($fs, $http_request); -/* - $debug_file = 'trackback.log'; - $fp = fopen($debug_file, 'a'); - fwrite($fp, "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n"); - while(!@feof($fs)) { - fwrite($fp, @fgets($fs, 4096)); - } - fwrite($fp, "\n\n"); - fclose($fp); -*/ @fclose($fs); $tb_url = addslashes( $tb_url ); @@ -815,4 +810,17 @@ function weblog_ping($server = '', $path = '') { $client->query('weblogUpdates.ping', get_option('blogname'), $home); } +// +// Cache +// + +function clean_comment_cache($id) { + wp_cache_delete($id, 'comment'); +} + +function update_comment_cache($comments) { + foreach ( $comments as $comment ) + wp_cache_add($comment->comment_ID, $comment, 'comment'); +} + ?> diff --git a/wp-includes/compat.php b/wp-includes/compat.php index b346fdd..a4914b5 100644 --- a/wp-includes/compat.php +++ b/wp-includes/compat.php @@ -73,7 +73,7 @@ if (!defined('CASE_UPPER')) { * @link http://php.net/function.array_change_key_case * @author Stephan Schmidt * @author Aidan Lister - * @version $Revision: 5187 $ + * @version $Revision: 6070 $ * @since PHP 4.2.0 * @require PHP 4.0.0 (user_error) */ @@ -98,18 +98,40 @@ if (!function_exists('array_change_key_case')) { } } -// From php.net -if(!function_exists('http_build_query')) { - function http_build_query( $formdata, $numeric_prefix = null, $key = null ) { - $res = array(); - foreach ((array)$formdata as $k=>$v) { - $tmp_key = urlencode(is_int($k) ? $numeric_prefix.$k : $k); - if ($key) $tmp_key = $key.'['.$tmp_key.']'; - $res[] = ( ( is_array($v) || is_object($v) ) ? http_build_query($v, null, $tmp_key) : $tmp_key."=".urlencode($v) ); - } - $separator = ini_get('arg_separator.output'); - return implode($separator, $res); - } +if (!function_exists('http_build_query')) { + function http_build_query($data, $prefix=null, $sep=null) { + return _http_build_query($data, $prefix, $sep); + } +} + +// from php.net (modified by Mark Jaquith to behave like the native PHP5 function) +function _http_build_query($data, $prefix=null, $sep=null, $key='', $urlencode=true) { + $ret = array(); + + foreach ( (array) $data as $k => $v ) { + if ( $urlencode) + $k = urlencode($k); + if ( is_int($k) && $prefix != null ) + $k = $prefix.$k; + if ( !empty($key) ) + $k = $key . '%5B' . $k . '%5D'; + if ( $v === NULL ) + continue; + elseif ( $v === FALSE ) + $v = '0'; + + if ( is_array($v) || is_object($v) ) + array_push($ret,_http_build_query($v, '', $sep, $k, $urlencode)); + elseif ( $urlencode ) + array_push($ret, $k.'='.urlencode($v)); + else + array_push($ret, $k.'='.$v); + } + + if ( NULL === $sep ) + $sep = ini_get('arg_separator.output'); + + return implode($sep, $ret); } if ( !function_exists('_') ) { diff --git a/wp-includes/cron.php b/wp-includes/cron.php index f81c6ad..1c17c76 100644 --- a/wp-includes/cron.php +++ b/wp-includes/cron.php @@ -83,18 +83,20 @@ function spawn_cron() { $cron_url = get_option( 'siteurl' ) . '/wp-cron.php'; $parts = parse_url( $cron_url ); - + if ($parts['scheme'] == 'https') { // support for SSL was added in 4.3.0 if (version_compare(phpversion(), '4.3.0', '>=') && function_exists('openssl_open')) { - $argyle = @fsockopen('ssl://' . $parts['host'], $_SERVER['SERVER_PORT'], $errno, $errstr, 0.01); + $port = isset($parts['port']) ? $parts['port'] : 443; + $argyle = @fsockopen('ssl://' . $parts['host'], $port, $errno, $errstr, 0.01); } else { return false; } } else { - $argyle = @ fsockopen( $parts['host'], $_SERVER['SERVER_PORT'], $errno, $errstr, 0.01 ); + $port = isset($parts['port']) ? $parts['port'] : 80; + $argyle = @ fsockopen( $parts['host'], $port, $errno, $errstr, 0.01 ); } - + if ( $argyle ) fputs( $argyle, "GET {$parts['path']}?check=" . wp_hash('187425') . " HTTP/1.0\r\n" diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index 1613b33..53060b1 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -1,135 +1,102 @@ diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php index c93abe3..67ef9f9 100644 --- a/wp-includes/deprecated.php +++ b/wp-includes/deprecated.php @@ -56,7 +56,7 @@ function start_wp() { function the_category_ID($echo = true) { // Grab the first cat in the list. $categories = get_the_category(); - $cat = $categories[0]->cat_ID; + $cat = $categories[0]->term_id; if ( $echo ) echo $cat; @@ -217,12 +217,10 @@ function get_linksbyname($cat_name = "noname", $before = '', $after = '
    ', $limit = -1, $show_updated = 0) { global $wpdb; $cat_id = -1; - $results = $wpdb->get_results("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'"); - if ($results) { - foreach ($results as $result) { - $cat_id = $result->cat_ID; - } - } + $cat = get_term_by('name', $cat_name, 'link_category'); + if ( $cat ) + $cat_id = $cat->term_id; + get_links($cat_id, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated); } @@ -235,10 +233,10 @@ function get_linksbyname($cat_name = "noname", $before = '', $after = '
    ', function wp_get_linksbyname($category, $args = '') { global $wpdb; - $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category' LIMIT 1"); - - if (! $cat_id) - return; + $cat = get_term_by('name', $cat_name, 'link_category'); + if ( !$cat ) + return false; + $cat_id = $cat->term_id; $args = add_query_arg('category', $cat_id, $args); wp_get_links($args); @@ -263,17 +261,13 @@ function wp_get_linksbyname($category, $args = '') { ** echo '
  • '.$link->link_name.'
  • '; ** } **/ -// Deprecate in favor of get_linkz(). function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) { global $wpdb; $cat_id = -1; - //$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'"); - // TODO: Fix me. - if ($results) { - foreach ($results as $result) { - $cat_id = $result->cat_id; - } - } + $cat = get_term_by('name', $cat_name, 'link_category'); + if ( $cat ) + $cat_id = $cat->term_id; + return get_linkobjects($cat_id, $orderby, $limit); } @@ -313,41 +307,17 @@ function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit ** link_notes **/ // Deprecate in favor of get_linkz(). -function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) { +function get_linkobjects($category = 0, $orderby = 'name', $limit = 0) { global $wpdb; - $sql = "SELECT * FROM $wpdb->links WHERE link_visible = 'Y'"; - if ($category != -1) { - $sql .= " AND link_category = $category "; - } - if ($orderby == '') - $orderby = 'id'; - if (substr($orderby,0,1) == '_') { - $direction = ' DESC'; - $orderby = substr($orderby,1); - } - if (strcasecmp('rand',$orderby) == 0) { - $orderby = 'rand()'; - } else { - $orderby = " link_" . $orderby; - } - $sql .= ' ORDER BY ' . $orderby; - $sql .= $direction; - /* The next 2 lines implement LIMIT TO processing */ - if ($limit != -1) - $sql .= " LIMIT $limit"; - - $results = $wpdb->get_results($sql); - if ($results) { - foreach ($results as $result) { - $result->link_url = $result->link_url; - $result->link_name = $result->link_name; - $result->link_description = $result->link_description; - $result->link_notes = $result->link_notes; - $newresults[] = $result; - } + $links = get_bookmarks("category=$category&orderby=$orderby&limit=$limit"); + + $links_array = array(); + foreach ($links as $link) { + $links_array[] = $link; } - return $newresults; + + return $links_array; } /** function get_linksbyname_withrating() @@ -427,10 +397,7 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde } function wp_list_cats($args = '') { - if ( is_array($args) ) - $r = &$args; - else - parse_str($args, $r); + $r = wp_parse_args( $args ); // Map to new names. if ( isset($r['optionall']) && isset($r['all'])) @@ -512,4 +479,254 @@ function get_settings($option) { return get_option($option); } +// Use the_permalink(). +function permalink_link() { + the_permalink(); +} + +// Use the_permalink_rss() +function permalink_single_rss($file = '') { + the_permalink_rss(); +} + +/** function wp_get_links() + ** Gets the links associated with category n. + ** Parameters: + ** category (no default) - The category to use. + ** or: + ** a query string + **/ +function wp_get_links($args = '') { + global $wpdb; + + if ( strpos( $args, '=' ) === false ) { + $cat_id = $args; + $args = add_query_arg( 'category', $cat_id, $args ); + } + + $defaults = array( + 'category' => -1, 'before' => '', + 'after' => '
    ', 'between' => ' ', + 'show_images' => true, 'orderby' => 'name', + 'show_description' => true, 'show_rating' => false, + 'limit' => -1, 'show_updated' => true, + 'echo' => true + ); + + $r = wp_parse_args( $args, $defaults ); + extract( $r, EXTR_SKIP ); + + return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo); +} // end wp_get_links + +/** function get_links() + ** Gets the links associated with category n. + ** Parameters: + ** category (default -1) - The category to use. If no category supplied + ** uses all + ** before (default '') - the html to output before the link + ** after (default '
    ') - the html to output after the link + ** between (default ' ') - the html to output between the link/image + ** and its description. Not used if no image or show_images == true + ** show_images (default true) - whether to show images (if defined). + ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name', + ** 'url', 'description', or 'rating'. Or maybe owner. If you start the + ** name with an underscore the order will be reversed. + ** You can also specify 'rand' as the order which will return links in a + ** random order. + ** show_description (default true) - whether to show the description if + ** show_images=false/not defined . + ** show_rating (default false) - show rating stars/chars + ** limit (default -1) - Limit to X entries. If not specified, all entries + ** are shown. + ** show_updated (default 0) - whether to show last updated timestamp + ** echo (default true) - whether to echo the results, or return them instead + */ +function get_links($category = -1, + $before = '', + $after = '
    ', + $between = ' ', + $show_images = true, + $orderby = 'name', + $show_description = true, + $show_rating = false, + $limit = -1, + $show_updated = 1, + $echo = true) { + + global $wpdb; + + $order = 'ASC'; + if ( substr($orderby, 0, 1) == '_' ) { + $order = 'DESC'; + $orderby = substr($orderby, 1); + } + + if ( $category == -1 ) //get_bookmarks uses '' to signify all categories + $category = ''; + + $results = get_bookmarks("category=$category&orderby=$orderby&order=$order&show_updated=$show_updated&limit=$limit"); + + if ( !$results ) + return; + + $output = ''; + + foreach ( (array) $results as $row ) { + if ( !isset($row->recently_updated) ) + $row->recently_updated = false; + $output .= $before; + if ( $show_updated && $row->recently_updated ) + $output .= get_option('links_recently_updated_prepend'); + $the_link = '#'; + if ( !empty($row->link_url) ) + $the_link = clean_url($row->link_url); + $rel = $row->link_rel; + if ( '' != $rel ) + $rel = ' rel="' . $rel . '"'; + + $desc = attribute_escape(sanitize_bookmark_field('link_description', $row->link_description, $row->link_id, 'display')); + $name = attribute_escape(sanitize_bookmark_field('link_name', $row->link_name, $row->link_id, 'display')); + $title = $desc; + + if ( $show_updated ) + if (substr($row->link_updated_f, 0, 2) != '00') + $title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * 3600)) . ')'; + + if ( '' != $title ) + $title = ' title="' . $title . '"'; + + $alt = ' alt="' . $name . '"'; + + $target = $row->link_target; + if ( '' != $target ) + $target = ' target="' . $target . '"'; + + $output .= ''; + + if ( $row->link_image != null && $show_images ) { + if ( strpos($row->link_image, 'http') !== false ) + $output .= "link_image\" $alt $title />"; + else // If it's a relative path + $output .= "link_image\" $alt $title />"; + } else { + $output .= $name; + } + + $output .= ''; + + if ( $show_updated && $row->recently_updated ) + $output .= get_option('links_recently_updated_append'); + + if ( $show_description && '' != $desc ) + $output .= $between . $desc; + + if ($show_rating) { + $output .= $between . get_linkrating($row); + } + + $output .= "$after\n"; + } // end while + + if ( !$echo ) + return $output; + echo $output; +} + +/* + * function get_links_list() + * + * added by Dougal + * + * Output a list of all links, listed by category, using the + * settings in $wpdb->linkcategories and output it as a nested + * HTML unordered list. + * + * Parameters: + * order (default 'name') - Sort link categories by 'name' or 'id' + * hide_if_empty (default true) - Supress listing empty link categories + */ +function get_links_list($order = 'name', $hide_if_empty = 'obsolete') { + $order = strtolower($order); + + // Handle link category sorting + $direction = 'ASC'; + if ( '_' == substr($order,0,1) ) { + $direction = 'DESC'; + $order = substr($order,1); + } + + if ( !isset($direction) ) + $direction = ''; + + $cats = get_categories("type=link&orderby=$order&order=$direction&hierarchical=0"); + + // Display each category + if ( $cats ) { + foreach ( (array) $cats as $cat ) { + // Handle each category. + + // Display the category name + echo '
  • ' . apply_filters('link_category', $cat->name ) . "

    \n\t
      \n"; + // Call get_links() with all the appropriate params + get_links($cat->term_id, '
    • ', "
    • ", "\n", true, 'name', false); + + // Close the last category + echo "\n\t
    \n
  • \n"; + } + } +} + + +/** function links_popup_script() + ** This function contributed by Fullo -- http://sprite.csr.unibo.it/fullo/ + ** Show the link to the links popup and the number of links + ** Parameters: + ** text (default Links) - the text of the link + ** width (default 400) - the width of the popup window + ** height (default 400) - the height of the popup window + ** file (default linkspopup.php) - the page to open in the popup window + ** count (default true) - the number of links in the db + */ +function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) { + if ( $count ) + $counts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links"); + + $javascript = ""; + $javascript .= $text; + + if ( $count ) + $javascript .= " ($counts)"; + + $javascript .= "\n\n"; + echo $javascript; +} + + +function get_linkrating($link) { + return sanitize_bookmark_field('link_rating', $link->link_rating, $link->link_id, 'display'); +} + +/** function get_linkcatname() + ** Gets the name of category n. + ** Parameters: id (default 0) - The category to get. If no category supplied + ** uses 0 + */ +function get_linkcatname($id = 0) { + $id = (int) $id; + + if ( empty($id) ) + return ''; + + $cats = wp_get_link_cats($id); + + if ( empty($cats) || ! is_array($cats) ) + return ''; + + $cat_id = (int) $cats[0]; // Take the first cat. + + $cat = get_category($cat_id); + return $cat->name; +} + ?> diff --git a/wp-includes/feed-atom-comments.php b/wp-includes/feed-atom-comments.php index 0cde6e7..ee9a73b 100644 --- a/wp-includes/feed-atom-comments.php +++ b/wp-includes/feed-atom-comments.php @@ -7,7 +7,7 @@ echo '' xml:lang="" > - <?php + <title type="text"><?php if ( is_singular() ) printf(__('Comments on: %s'), get_the_title_rss()); elseif ( is_search() ) @@ -33,7 +33,6 @@ if ( have_comments() ) : while ( have_comments() ) : the_comment(); <title><?php if ( !is_singular() ) { $title = get_the_title($comment_post->ID); - $title = apply_filters('the_title', $title); $title = apply_filters('the_title_rss', $title); printf(__('Comment on %1$s by %2$s'), $title, get_comment_author_rss()); } else { diff --git a/wp-includes/feed-atom.php b/wp-includes/feed-atom.php index 2eb7c2f..f80f48f 100644 --- a/wp-includes/feed-atom.php +++ b/wp-includes/feed-atom.php @@ -1,5 +1,5 @@ <?php -header('Content-type: application/atom+xml; charset=' . get_option('blog_charset'), true); +header('Content-Type: application/atom+xml; charset=' . get_option('blog_charset'), true); $more = 1; ?> @@ -26,17 +26,19 @@ $more = 1; <entry> <author> <name><?php the_author() ?></name> + <?php $author_url = get_the_author_url(); if ( !empty($author_url) ) : ?> <uri><?php the_author_url()?></uri> + <?php endif; ?> </author> <title type="<?php html_type_rss(); ?>"><![CDATA[<?php the_title_rss() ?>]]> - + - + ]]> - ]]> + ]]> diff --git a/wp-includes/feed-rdf.php b/wp-includes/feed-rdf.php index d1ac458..1f92b23 100644 --- a/wp-includes/feed-rdf.php +++ b/wp-includes/feed-rdf.php @@ -1,5 +1,5 @@ @@ -27,15 +27,15 @@ $more = 1; - + - + <?php the_title_rss() ?> - + post_date_gmt, false); ?> diff --git a/wp-includes/feed-rss.php b/wp-includes/feed-rss.php index 447dd59..469e4bc 100644 --- a/wp-includes/feed-rss.php +++ b/wp-includes/feed-rss.php @@ -1,5 +1,5 @@ @@ -23,7 +23,7 @@ $more = 1; - + diff --git a/wp-includes/feed-rss2-comments.php b/wp-includes/feed-rss2-comments.php index adb2930..7bd5ae2 100644 --- a/wp-includes/feed-rss2-comments.php +++ b/wp-includes/feed-rss2-comments.php @@ -1,10 +1,10 @@ '; +echo ''; ?> - @@ -17,12 +17,12 @@ echo ''; else printf(__('Comments for %s'), get_bloginfo_rss( 'name' ) . get_wp_title_rss()); ?> - + http://wordpress.org/?v= - - +comment_post_ID); get_post_custom($comment_post->ID); @@ -31,7 +31,6 @@ if ( have_comments() ) : while ( have_comments() ) : the_comment(); <?php if ( !is_singular() ) { $title = get_the_title($comment_post->ID); - $title = apply_filters('the_title', $title); $title = apply_filters('the_title_rss', $title); printf(__('Comment on %1$s by %2$s'), $title, get_comment_author_rss()); } else { diff --git a/wp-includes/feed-rss2.php b/wp-includes/feed-rss2.php index 588a063..21d9b8e 100644 --- a/wp-includes/feed-rss2.php +++ b/wp-includes/feed-rss2.php @@ -1,5 +1,5 @@ <?php -header('Content-type: text/xml; charset=' . get_option('blog_charset'), true); +header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true); $more = 1; ?> @@ -24,7 +24,7 @@ $more = 1; <?php while( have_posts()) : the_post(); ?> <item> <title><?php the_title_rss() ?> - + diff --git a/wp-includes/feed.php b/wp-includes/feed.php index 3474ef3..8f9219c 100644 --- a/wp-includes/feed.php +++ b/wp-includes/feed.php @@ -12,6 +12,8 @@ function bloginfo_rss($show = '') { function get_wp_title_rss($sep = '»') { $title = wp_title($sep, false); + if ( is_wp_error( $title ) ) + return $title->get_error_message(); $title = apply_filters('get_wp_title_rss', $title); return $title; } @@ -22,7 +24,6 @@ function wp_title_rss($sep = '»') { function get_the_title_rss() { $title = get_the_title(); - $title = apply_filters('the_title', $title); $title = apply_filters('the_title_rss', $title); return $title; } @@ -66,16 +67,15 @@ function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file function the_excerpt_rss() { - $output = get_the_excerpt(true); + $output = get_the_excerpt(); echo apply_filters('the_excerpt_rss', $output); } +function the_permalink_rss() { + echo apply_filters('the_permalink_rss', get_permalink()); -function permalink_single_rss($file = '') { - echo get_permalink(); } - function comment_link() { echo get_comment_link(); } @@ -117,7 +117,7 @@ function get_author_rss_link($echo = false, $author_id, $author_nicename) { $link = get_option('home') . '?feed=rss2&author=' . $author_id; } else { $link = get_author_posts_url($author_id, $author_nicename); - $link = $link . user_trailingslashit('feed', 'feed'); + $link = trailingslashit($link) . user_trailingslashit('feed', 'feed'); } $link = apply_filters('author_feed_link', $link); @@ -135,7 +135,7 @@ function get_category_rss_link($echo = false, $cat_ID, $category_nicename) { $link = get_option('home') . '?feed=rss2&cat=' . $cat_ID; } else { $link = get_category_link($cat_ID); - $link = $link . user_trailingslashit('feed', 'feed'); + $link = trailingslashit($link) . user_trailingslashit('feed', 'feed'); } $link = apply_filters('category_feed_link', $link); @@ -148,17 +148,34 @@ function get_category_rss_link($echo = false, $cat_ID, $category_nicename) { function get_the_category_rss($type = 'rss') { $categories = get_the_category(); + $tags = get_the_tags(); $home = get_bloginfo_rss('home'); $the_list = ''; - foreach ( (array) $categories as $category ) { - $cat_name = convert_chars($category->cat_name); + $cat_names = array(); + + $filter = 'rss'; + if ( 'atom' == $type ) + $filter = 'raw'; + + if ( !empty($categories) ) foreach ( (array) $categories as $category ) { + $cat_names[] = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter); + } + + if ( !empty($tags) ) foreach ( (array) $tags as $tag ) { + $cat_names[] = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter); + } + + $cat_names = array_unique($cat_names); + + foreach ( $cat_names as $cat_name ) { if ( 'rdf' == $type ) $the_list .= "\n\t\t\n"; - if ( 'atom' == $type ) - $the_list .= sprintf( '', attribute_escape( apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ) ), attribute_escape( $category->cat_name ) ); + elseif ( 'atom' == $type ) + $the_list .= sprintf( '', attribute_escape( apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ) ), attribute_escape( $cat_name ) ); else $the_list .= "\n\t\t\n"; } + return apply_filters('the_category_rss', $the_list, $type); } @@ -167,6 +184,32 @@ function the_category_rss($type = 'rss') { echo get_the_category_rss($type); } +function get_tag_feed_link($tag_id, $feed = 'rss2') { + $tag_id = (int) $tag_id; + + $tag = get_tag($tag_id); + + if ( empty($tag) || is_wp_error($tag) ) + return false; + + $permalink_structure = get_option('permalink_structure'); + + if ( '' == $permalink_structure ) { + $link = get_option('home') . "?feed=$feed&tag=" . $tag->slug; + } else { + $link = get_tag_link($tag->term_id); + if ( 'rss2' == $feed ) + $feed_link = 'feed'; + else + $feed_link = "feed/$feed"; + $link = $link . user_trailingslashit($feed_link, 'feed'); + } + + $link = apply_filters('tag_feed_link', $link, $feed); + + return $link; +} + function html_type_rss() { $type = get_bloginfo('html_type'); if (strpos($type, 'xhtml') !== false) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index cb8b372..a58aa88 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -17,7 +17,7 @@ function wptexturize($text) { $cockneyreplace = array("’tain’t","’twere","’twas","’tis","’twill","’til","’bout","’nuff","’round","’cause"); } - $static_characters = array_merge(array('---', ' -- ', '--', 'xn–', '...', '``', '\'s', '\'\'', ' (tm)'), $cockney); + $static_characters = array_merge(array('---', ' -- ', '--', 'xn–', '...', '``', '\'s', '\'\'', ' (tm)'), $cockney); $static_replacements = array_merge(array('—', ' — ', '–', 'xn--', '…', '“', '’s', '”', ' ™'), $cockneyreplace); $dynamic_characters = array('/\'(\d\d(?:’|\')?s)/', '/(\s|\A|")\'/', '/(\d+)"/', '/(\d+)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A)"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/(\d+)x(\d+)/'); @@ -44,10 +44,18 @@ function wptexturize($text) { return $output; } -function clean_pre($text) { +// Accepts matches array from preg_replace_callback in wpautop() +// or a string +function clean_pre($matches) { + if ( is_array($matches) ) + $text = $matches[1] . $matches[2] . "
    "; + else + $text = $matches; + $text = str_replace('
    ', '', $text); $text = str_replace('

    ', "\n", $text); $text = str_replace('

    ', '', $text); + return $text; } @@ -78,7 +86,7 @@ function wpautop($pee, $br = 1) { $pee = preg_replace('!(]*>)\s*
    !', "$1", $pee); $pee = preg_replace('!
    (\s*]*>)!', '$1', $pee); if (strpos($pee, ')(.*?)!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '' ", $pee); + $pee = preg_replace_callback('!()(.*?)!is', 'clean_pre', $pee ); $pee = preg_replace( "|\n

    $|", '

    ', $pee ); return $pee; @@ -131,7 +139,7 @@ function utf8_uri_encode( $utf8_string, $length = 0 ) { if ( $value < 128 ) { if ( $length && ( strlen($unicode) + 1 > $length ) ) - break; + break; $unicode .= chr($value); } else { if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3; @@ -413,8 +421,14 @@ function funky_javascript_fix($text) { return $text; } +function balanceTags( $text, $force = false ) { + if ( !$force && get_option('use_balanceTags') == 0 ) + return $text; + return force_balance_tags( $text ); +} + /* - balanceTags + force_balance_tags Balances Tags of string using a modified stack. @@ -433,12 +447,10 @@ function funky_javascript_fix($text) { Added Cleaning Hooks 1.0 First Version */ -function balanceTags($text, $force = false) { - - if ( !$force && get_option('use_balanceTags') == 0 ) - return $text; - +function force_balance_tags( $text ) { $tagstack = array(); $stacksize = 0; $tagqueue = ''; $newtext = ''; + $single_tags = array('br', 'hr', 'img', 'input'); //Known single-entity/self-closing tags + $nestable_tags = array('blockquote', 'div', 'span'); //Tags that can be immediately nested within themselves # WP bug fix for comments - in case you REALLY meant to type '< !--' $text = str_replace('< !--', '< !--', $text); @@ -489,11 +501,11 @@ function balanceTags($text, $force = false) { if((substr($regex[2],-1) == '/') || ($tag == '')) { } // ElseIf it's a known single-entity tag but it doesn't close itself, do so - elseif ($tag == 'br' || $tag == 'img' || $tag == 'hr' || $tag == 'input') { + elseif ( in_array($tag, $single_tags) ) { $regex[2] .= '/'; } else { // Push the tag onto the stack // If the top of the stack is the same as the tag we want to push, close previous tag - if (($stacksize > 0) && ($tag != 'div') && ($tagstack[$stacksize - 1] == $tag)) { + if (($stacksize > 0) && !in_array($tag, $nestable_tags) && ($tagstack[$stacksize - 1] == $tag)) { $tagqueue = ''; $stacksize--; } @@ -534,10 +546,6 @@ function balanceTags($text, $force = false) { return $newtext; } -function force_balance_tags($text) { - return balanceTags($text, true); -} - function format_to_edit($content, $richedit = false) { $content = apply_filters('format_to_edit', $content); if (! $richedit ) @@ -636,24 +644,30 @@ function wp_rel_nofollow( $text ) { global $wpdb; // This is a pre save filter, so text is already escaped. $text = stripslashes($text); - $text = preg_replace('||ie', "''", $text); + $text = preg_replace_callback('||i', 'wp_rel_nofollow_callback', $text); $text = $wpdb->escape($text); return $text; } +function wp_rel_nofollow_callback( $matches ) { + $text = $matches[1]; + $text = str_replace(array(' rel="nofollow"', " rel='nofollow'"), '', $text); + return ""; +} + function convert_smilies($text) { global $wp_smiliessearch, $wp_smiliesreplace; $output = ''; if (get_option('use_smilies')) { // HTML loop taken from texturize function, could possible be consolidated $textarr = preg_split("/(<.*>)/U", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between - $stop = count($textarr);// loop stuff - for ($i = 0; $i < $stop; $i++) { - $content = $textarr[$i]; - if ((strlen($content) > 0) && ('<' != $content{0})) { // If it's not a tag - $content = preg_replace($wp_smiliessearch, $wp_smiliesreplace, $content); - } - $output .= $content; + $stop = count($textarr);// loop stuff + for ($i = 0; $i < $stop; $i++) { + $content = $textarr[$i]; + if ((strlen($content) > 0) && ('<' != $content{0})) { // If it's not a tag + $content = preg_replace($wp_smiliessearch, $wp_smiliesreplace, $content); + } + $output .= $content; } } else { // return default text. @@ -1074,22 +1088,28 @@ function wp_richedit_pre($text) { } function clean_url( $url, $protocols = null ) { + $original_url = $url; + if ('' == $url) return $url; - $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%]|i', '', $url); + $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@]|i', '', $url); $strip = array('%0d', '%0a'); $url = str_replace($strip, '', $url); $url = str_replace(';//', '://', $url); - // Append http unless a relative link starting with / or a php file. - if ( strpos($url, '://') === false && + /* If the URL doesn't appear to contain a scheme, we + * presume it needs http:// appended (unless a relative + * link starting with / or a php file). + */ + if ( strpos($url, ':') === false && substr( $url, 0, 1 ) != '/' && !preg_match('/^[a-z0-9-]+?\.php/i', $url) ) $url = 'http://' . $url; - + $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); if ( !is_array($protocols) ) - $protocols = array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet'); + $protocols = array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet'); if ( wp_kses_bad_protocol( $url, $protocols ) != $url ) return ''; - return $url; + + return apply_filters('clean_url', $url, $original_url); } // Borrowed from the PHP Manual user notes. Convert entities, while @@ -1185,6 +1205,7 @@ function sanitize_option($option, $value) { // Remember to call stripslashes! $value = clean_url($value); break; default : + $value = apply_filters("sanitize_option_{$option}", $value, $option); break; } @@ -1198,4 +1219,15 @@ function wp_parse_str( $string, &$array ) { $array = apply_filters( 'wp_parse_str', $array ); } +// Convert lone less than signs. KSES already converts lone greater than signs. +function wp_pre_kses_less_than( $text ) { + return preg_replace_callback('%<[^>]*?((?=<)|>|$)%', 'wp_pre_kses_less_than_callback', $text); +} + +function wp_pre_kses_less_than_callback( $matches ) { + if ( false === strpos($matches[0], '>') ) + return wp_specialchars($matches[0]); + return $matches[0]; +} + ?> diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 60a5730..43a2ba9 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1,16 +1,14 @@ number_format['decimals'] : intval($decimals); + + return number_format($number, $decimals, $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep']); +} + +function size_format($bytes, $decimals = null) { + // technically the correct unit names for powers of 1024 are KiB, MiB etc + // see http://en.wikipedia.org/wiki/Byte + $quant = array( + 'TB' => pow(1024, 4), + 'GB' => pow(1024, 3), + 'MB' => pow(1024, 2), + 'kB' => pow(1024, 1), + 'B' => pow(1024, 0), + ); + + foreach ($quant as $unit => $mag) + if ( intval($bytes) >= $mag ) + return number_format_i18n($bytes / $mag, $decimals) . ' ' . $unit; +} + function get_weekstartend($mysqlstring, $start_of_week) { $my = substr($mysqlstring,0,4); $mm = substr($mysqlstring,8,2); @@ -108,56 +130,6 @@ function get_weekstartend($mysqlstring, $start_of_week) { return $week; } -function get_lastpostdate($timezone = 'server') { - global $cache_lastpostdate, $pagenow, $wpdb, $blog_id; - $add_seconds_blog = get_option('gmt_offset') * 3600; - $add_seconds_server = date('Z'); - if ( !isset($cache_lastpostdate[$blog_id][$timezone]) ) { - switch(strtolower($timezone)) { - case 'gmt': - $lastpostdate = $wpdb->get_var("SELECT post_date_gmt FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1"); - break; - case 'blog': - $lastpostdate = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1"); - break; - case 'server': - $lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1"); - break; - } - $cache_lastpostdate[$blog_id][$timezone] = $lastpostdate; - } else { - $lastpostdate = $cache_lastpostdate[$blog_id][$timezone]; - } - return $lastpostdate; -} - -function get_lastpostmodified($timezone = 'server') { - global $cache_lastpostmodified, $pagenow, $wpdb, $blog_id; - $add_seconds_blog = get_option('gmt_offset') * 3600; - $add_seconds_server = date('Z'); - if ( !isset($cache_lastpostmodified[$blog_id][$timezone]) ) { - switch(strtolower($timezone)) { - case 'gmt': - $lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1"); - break; - case 'blog': - $lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1"); - break; - case 'server': - $lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1"); - break; - } - $lastpostdate = get_lastpostdate($timezone); - if ( $lastpostdate > $lastpostmodified ) { - $lastpostmodified = $lastpostdate; - } - $cache_lastpostmodified[$blog_id][$timezone] = $lastpostmodified; - } else { - $lastpostmodified = $cache_lastpostmodified[$blog_id][$timezone]; - } - return $lastpostmodified; -} - function maybe_unserialize($original) { if ( is_serialized($original) ) // don't attempt to unserialize data that wasn't serialized going in if ( false !== $gm = @ unserialize($original) ) @@ -208,9 +180,9 @@ function get_option($setting) { global $wpdb, $switched, $current_blog; // Allow plugins to short-circuit options. - $pre = apply_filters( 'pre_option_' . $setting, false ); - if ( $pre ) - return $pre; + $pre = apply_filters( 'pre_option_' . $setting, false ); + if ( false !== $pre ) + return $pre; if ( $switched != false || defined('WP_INSTALLING') != false ) { wp_cache_delete($setting, 'options'); @@ -252,8 +224,8 @@ function get_option($setting) { if ( 'home' == $setting && '' == $value ) return get_option('siteurl'); - if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting ) - $value = preg_replace('|/+$|', '', $value); + if ( in_array($setting, array('siteurl', 'home', 'category_base', 'tag_base')) ) + $value = untrailingslashit($value); if (! unserialize($value) ) $value = stripslashes( $value ); @@ -319,6 +291,7 @@ function update_option($option_name, $newvalue) { wp_protect_special_option($option_name); $safe_option_name = $wpdb->escape($option_name); + $newvalue = sanitize_option($option_name, $newvalue); if ( is_string($newvalue) ) $newvalue = trim($newvalue); @@ -363,7 +336,7 @@ function update_option($option_name, $newvalue) { // thx Alex Stapleton, http://alex.vort-x.net/blog/ // expects $name to NOT be SQL-escaped -function add_option($name, $value = '', $description = '', $autoload = 'yes') { +function add_option($name, $value = '', $deprecated = '', $autoload = 'yes') { global $wpdb; wp_protect_special_option($name); @@ -395,8 +368,7 @@ function add_option($name, $value = '', $description = '', $autoload = 'yes') { $name = $wpdb->escape($name); $value = $wpdb->escape($value); - $description = $wpdb->escape($description); - $wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, option_description, autoload) VALUES ('$name', '$value', '$description', '$autoload')"); + $wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES ('$name', '$value', '$autoload')"); return; } @@ -433,10 +405,16 @@ function maybe_serialize($data) { } function gzip_compression() { - if ( !get_option('gzipcompression') ) return false; + if ( !get_option( 'gzipcompression' ) ) { + return false; + } - if ( extension_loaded('zlib') ) { - ob_start('ob_gzhandler'); + if ( ( ini_get( 'zlib.output_compression' ) == 'On' || ini_get( 'zlib.output_compression_level' ) > 0 ) || ini_get( 'output_handler' ) == 'ob_gzhandler' ) { + return false; + } + + if ( extension_loaded( 'zlib' ) ) { + ob_start( 'ob_gzhandler' ); } } @@ -518,7 +496,7 @@ function do_enclose( $content, $post_ID ) { global $wp_version, $wpdb; include_once (ABSPATH . WPINC . '/class-IXR.php'); - $log = debug_fopen(ABSPATH . '/enclosures.log', 'a'); + $log = debug_fopen(ABSPATH . 'enclosures.log', 'a'); $post_links = array(); debug_fwrite($log, 'BEGIN '.date('YmdHis', time())."\n"); @@ -610,162 +588,8 @@ function is_new_day() { } } -function update_post_cache(&$posts) { - global $post_cache, $blog_id; - - if ( !$posts ) - return; - - for ($i = 0; $i < count($posts); $i++) { - $post_cache[$blog_id][$posts[$i]->ID] = &$posts[$i]; - } -} - -function clean_post_cache($id) { - global $post_cache, $post_meta_cache, $category_cache, $blog_id; - - if ( isset( $post_cache[$blog_id][$id] ) ) - unset( $post_cache[$blog_id][$id] ); - - if ( isset ($post_meta_cache[$blog_id][$id] ) ) - unset( $post_meta_cache[$blog_id][$id] ); - - if ( isset( $category_cache[$blog_id][$id]) ) - unset ( $category_cache[$blog_id][$id] ); -} - -function update_page_cache(&$pages) { - global $page_cache, $blog_id; - - if ( !$pages ) - return; - - for ($i = 0; $i < count($pages); $i++) { - $page_cache[$blog_id][$pages[$i]->ID] = &$pages[$i]; - wp_cache_add($pages[$i]->ID, $pages[$i], 'pages'); - } -} - -function clean_page_cache($id) { - global $page_cache, $blog_id; - - if ( isset( $page_cache[$blog_id][$id] ) ) - unset( $page_cache[$blog_id][$id] ); - - wp_cache_delete($id, 'pages'); - wp_cache_delete( 'all_page_ids', 'pages' ); - wp_cache_delete( 'get_pages', 'page' ); -} - -function update_post_category_cache($post_ids) { - global $wpdb, $category_cache, $blog_id; - - if ( empty($post_ids) ) - return; - - if ( is_array($post_ids) ) - $post_id_list = implode(',', $post_ids); - - $post_id_array = (array) explode(',', $post_ids); - $count = count( $post_id_array); - for ( $i = 0; $i < $count; $i++ ) { - $post_id = (int) $post_id_array[ $i ]; - if ( isset( $category_cache[$blog_id][$post_id] ) ) { - unset( $post_id_array[ $i ] ); - continue; - } - } - if ( count( $post_id_array ) == 0 ) - return; - $post_id_list = join( ',', $post_id_array ); // with already cached stuff removed - - $dogs = $wpdb->get_results("SELECT post_id, category_id FROM $wpdb->post2cat WHERE post_id IN ($post_id_list)"); - - if ( empty($dogs) ) - return; - - foreach ($dogs as $catt) - $category_cache[$blog_id][$catt->post_id][$catt->category_id] = &get_category($catt->category_id); -} - -function update_post_caches(&$posts) { - global $post_cache, $category_cache, $post_meta_cache; - global $wpdb, $blog_id; - - // No point in doing all this work if we didn't match any posts. - if ( !$posts ) - return; - - // Get the categories for all the posts - for ($i = 0; $i < count($posts); $i++) { - $post_id_array[] = $posts[$i]->ID; - $post_cache[$blog_id][$posts[$i]->ID] = &$posts[$i]; - } - - $post_id_list = implode(',', $post_id_array); - - update_post_category_cache($post_id_list); - - update_postmeta_cache($post_id_list); -} - -function update_postmeta_cache($post_id_list = '') { - global $wpdb, $post_meta_cache, $blog_id; - - // We should validate this comma-separated list for the upcoming SQL query - $post_id_list = preg_replace('|[^0-9,]|', '', $post_id_list); - - if ( empty( $post_id_list ) ) - return false; - - // we're marking each post as having its meta cached (with no keys... empty array), to prevent posts with no meta keys from being queried again - // any posts that DO have keys will have this empty array overwritten with a proper array, down below - $post_id_array = (array) explode(',', $post_id_list); - $count = count( $post_id_array); - for ( $i = 0; $i < $count; $i++ ) { - $post_id = (int) $post_id_array[ $i ]; - if ( isset( $post_meta_cache[$blog_id][$post_id] ) ) { // If the meta is already cached - unset( $post_id_array[ $i ] ); - continue; - } - $post_meta_cache[$blog_id][$post_id] = array(); - } - if ( count( $post_id_array ) == 0 ) - return; - $post_id_list = join( ',', $post_id_array ); // with already cached stuff removeds - - // Get post-meta info - if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id IN($post_id_list) ORDER BY post_id, meta_key", ARRAY_A) ) { - // Change from flat structure to hierarchical: - if ( !isset($post_meta_cache) ) - $post_meta_cache[$blog_id] = array(); - - foreach ($meta_list as $metarow) { - $mpid = (int) $metarow['post_id']; - $mkey = $metarow['meta_key']; - $mval = $metarow['meta_value']; - - // Force subkeys to be array type: - if ( !isset($post_meta_cache[$blog_id][$mpid]) || !is_array($post_meta_cache[$blog_id][$mpid]) ) - $post_meta_cache[$blog_id][$mpid] = array(); - if ( !isset($post_meta_cache[$blog_id][$mpid]["$mkey"]) || !is_array($post_meta_cache[$blog_id][$mpid]["$mkey"]) ) - $post_meta_cache[$blog_id][$mpid]["$mkey"] = array(); - - // Add a value to the current pid/key: - $post_meta_cache[$blog_id][$mpid][$mkey][] = $mval; - } - } -} - -function update_category_cache() { - return true; -} - -function clean_category_cache($id) { - wp_cache_delete($id, 'category'); - wp_cache_delete('all_category_ids', 'category'); - wp_cache_delete('get_categories', 'category'); - delete_option('category_children'); +function build_query($data) { + return _http_build_query($data, NULL, '&', '', false); } /* @@ -813,7 +637,7 @@ function add_query_arg() { $base = $parts[0] . '?'; $query = $parts[1]; } - } elseif (!empty($protocol) || strpos($uri, '/') !== false) { + } elseif (!empty($protocol) || strpos($uri, '=') === false ) { $base = $uri . '?'; $query = ''; } else { @@ -822,7 +646,7 @@ function add_query_arg() { } wp_parse_str($query, $qs); - $qs = urlencode_deep($qs); + $qs = urlencode_deep($qs); // this re-URL-encodes things that were already in the query string if ( is_array(func_get_arg(0)) ) { $kayvees = func_get_arg(0); $qs = array_merge($qs, $kayvees); @@ -830,17 +654,14 @@ function add_query_arg() { $qs[func_get_arg(0)] = func_get_arg(1); } - foreach($qs as $k => $v) { - if ( $v !== FALSE ) { - if ( $ret != '' ) - $ret .= '&'; - if ( empty($v) && !preg_match('|[?&]' . preg_quote($k, '|') . '=|', $query) ) - $ret .= $k; - else - $ret .= "$k=$v"; - } + foreach ( $qs as $k => $v ) { + if ( $v === false ) + unset($qs[$k]); } + + $ret = build_query($qs); $ret = trim($ret, '?'); + $ret = preg_replace('#=(&|$)#', '$1', $ret); $ret = $protocol . $base . $ret . $frag; $ret = rtrim($ret, '?'); return $ret; @@ -919,25 +740,78 @@ function wp($query_vars = '') { $wp->main($query_vars); } +function get_status_header_desc( $code ) { + global $wp_header_to_desc; + + $code = (int) $code; + + if ( !isset($wp_header_to_desc) ) { + $wp_header_to_desc = array( + 100 => 'Continue', + 101 => 'Switching Protocols', + + 200 => 'OK', + 201 => 'Created', + 202 => 'Accepted', + 203 => 'Non-Authoritative Information', + 204 => 'No Content', + 205 => 'Reset Content', + 206 => 'Partial Content', + + 300 => 'Multiple Choices', + 301 => 'Moved Permanently', + 302 => 'Found', + 303 => 'See Other', + 304 => 'Not Modified', + 305 => 'Use Proxy', + 307 => 'Temporary Redirect', + + 400 => 'Bad Request', + 401 => 'Unauthorized', + 403 => 'Forbidden', + 404 => 'Not Found', + 405 => 'Method Not Allowed', + 406 => 'Not Acceptable', + 407 => 'Proxy Authentication Required', + 408 => 'Request Timeout', + 409 => 'Conflict', + 410 => 'Gone', + 411 => 'Length Required', + 412 => 'Precondition Failed', + 413 => 'Request Entity Too Large', + 414 => 'Request-URI Too Long', + 415 => 'Unsupported Media Type', + 416 => 'Requested Range Not Satisfiable', + 417 => 'Expectation Failed', + + 500 => 'Internal Server Error', + 501 => 'Not Implemented', + 502 => 'Bad Gateway', + 503 => 'Service Unavailable', + 504 => 'Gateway Timeout', + 505 => 'HTTP Version Not Supported' + ); + } + + if ( isset( $wp_header_to_desc[$code] ) ) { + return $wp_header_to_desc[$code]; + } else { + return ''; + } +} + function status_header( $header ) { - if ( 200 == $header ) - $text = 'OK'; - elseif ( 301 == $header ) - $text = 'Moved Permanently'; - elseif ( 302 == $header ) - $text = 'Moved Temporarily'; - elseif ( 304 == $header ) - $text = 'Not Modified'; - elseif ( 404 == $header ) - $text = 'Not Found'; - elseif ( 410 == $header ) - $text = 'Gone'; + $text = get_status_header_desc( $header ); + + if ( empty( $text ) ) + return false; $protocol = $_SERVER["SERVER_PROTOCOL"]; if ( ('HTTP/1.1' != $protocol) && ('HTTP/1.0' != $protocol) ) $protocol = 'HTTP/1.0'; $status_header = "$protocol $header $text"; - $status_header = apply_filters('status_header', $status_header, $header, $text, $protocol); + if ( function_exists('apply_filters') ) + $status_header = apply_filters('status_header', $status_header, $header, $text, $protocol); if ( version_compare( phpversion(), '4.3.0', '>=' ) ) { return @header( $status_header, true, $header ); @@ -955,7 +829,7 @@ function nocache_headers() { function cache_javascript_headers() { $expiresOffset = 864000; // 10 days - header("Content-type: text/javascript; charset=" . get_bloginfo('charset')); + header("Content-Type: text/javascript; charset=" . get_bloginfo('charset')); header("Vary: Accept-Encoding"); // Handle proxies header("Expires: " . gmdate("D, d M Y H:i:s", time() + $expiresOffset) . " GMT"); } @@ -965,9 +839,8 @@ function get_num_queries() { return $wpdb->num_queries; } -function bool_from_yn($yn) { - if ($yn == 'Y') return 1; - return 0; +function bool_from_yn( $yn ) { + return ( strtolower( $yn ) == 'y' ); } function do_feed() { @@ -1011,7 +884,7 @@ function do_feed_atom($for_comments) { function do_robots() { global $current_blog; - header('Content-type: text/plain; charset=utf-8'); + header('Content-Type: text/plain; charset=utf-8'); do_action('do_robotstxt'); @@ -1035,6 +908,7 @@ function is_blog_installed() { } function wp_nonce_url($actionurl, $action = -1) { + $actionurl = str_replace('&', '&', $actionurl); return wp_specialchars(add_query_arg('_wpnonce', wp_create_nonce($action), $actionurl)); } @@ -1223,7 +1097,16 @@ function wp_check_filetype($filename, $mimes = null) { 'tar' => 'application/x-tar', 'zip' => 'application/zip', 'gz|gzip' => 'application/x-gzip', - 'exe' => 'application/x-msdownload' + 'exe' => 'application/x-msdownload', + // openoffice formats + 'odt' => 'application/vnd.oasis.opendocument.text', + 'odp' => 'application/vnd.oasis.opendocument.presentation', + 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', + 'odg' => 'application/vnd.oasis.opendocument.graphics', + 'odc' => 'application/vnd.oasis.opendocument.chart', + 'odb' => 'application/vnd.oasis.opendocument.database', + 'odf' => 'application/vnd.oasis.opendocument.formula', + )); $type = false; @@ -1358,18 +1241,28 @@ function wp_die( $message, $title = '' ) { $message = "

    $message

    "; } - if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) + if ( defined('WP_SITEURL') && '' != WP_SITEURL ) + $admin_dir = WP_SITEURL.'/wp-admin/'; + elseif (function_exists('get_bloginfo') && '' != get_bloginfo('wpurl')) + $admin_dir = get_bloginfo('wpurl').'/wp-admin/'; + elseif (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $admin_dir = ''; else $admin_dir = 'wp-admin/'; - if ( !did_action('admin_head') ) : - header('Content-Type: text/html; charset=utf-8'); - - if ( empty($title) ) - $title = __('WordPress › Error'); - + if ( !function_exists('did_action') || !did_action('admin_head') ) : + if( !headers_sent() ){ + status_header(500); + nocache_headers(); + header('Content-Type: text/html; charset=utf-8'); + } + if ( empty($title) ){ + if( function_exists('__') ) + $title = __('WordPress › Error'); + else + $title = 'WordPress › Error'; + } ?> @@ -1377,10 +1270,10 @@ function wp_die( $message, $title = '' ) { <?php echo $title ?> - -css/install.css" type="text/css" /> +text_direction) ) : ?> - + @@ -1395,13 +1288,13 @@ if ( ( $wp_locale ) && ('rtl' == $wp_locale->text_direction) ) : ?> } function _config_wp_home($url = '') { - if ( defined( 'WP_HOME' ) ) + if ( defined( 'WP_HOME' ) ) return WP_HOME; else return $url; } function _config_wp_siteurl($url = '') { - if ( defined( 'WP_SITEURL' ) ) + if ( defined( 'WP_SITEURL' ) ) return WP_SITEURL; else return $url; } @@ -1500,7 +1393,9 @@ function smilies_init() { } function wp_parse_args( $args, $defaults = '' ) { - if ( is_array( $args ) ) + if ( is_object($args) ) + $r = get_object_vars($args); + else if ( is_array( $args ) ) $r =& $args; else wp_parse_str( $args, $r ); diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 7c3c5f3..9af63b6 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -60,28 +60,16 @@ function wp_meta() { function bloginfo($show='') { - $info = get_bloginfo($show); - - // Don't filter URL's. - if (strpos($show, 'url') === false && - strpos($show, 'directory') === false && - strpos($show, 'home') === false) { - $info = apply_filters('bloginfo', $info, $show); - $info = convert_chars($info); - } else { - $info = apply_filters('bloginfo_url', $info, $show); - } - - echo $info; + echo get_bloginfo($show, 'display'); } /** - * Note: some of these values are DEPRECATED. Meaning they could be - * taken out at any time and shouldn't be relied upon. Options - * without "// DEPRECATED" are the preferred and recommended ways + * Note: some of these values are DEPRECATED. Meaning they could be + * taken out at any time and shouldn't be relied upon. Options + * without "// DEPRECATED" are the preferred and recommended ways * to get the information. */ -function get_bloginfo($show='') { +function get_bloginfo($show = '', $filter = 'raw') { switch($show) { case 'url' : @@ -153,6 +141,20 @@ function get_bloginfo($show='') { $output = get_option('blogname'); break; } + + $url = true; + if (strpos($show, 'url') === false && + strpos($show, 'directory') === false && + strpos($show, 'home') === false) + $url = false; + + if ( 'display' == $filter ) { + if ( $url ) + $output = apply_filters('bloginfo_url', $output, $show); + else + $output = apply_filters('bloginfo', $output, $show); + } + return $output; } @@ -161,6 +163,7 @@ function wp_title($sep = '»', $display = true) { global $wpdb, $wp_locale, $wp_query; $cat = get_query_var('cat'); + $tag = get_query_var('tag_id'); $p = get_query_var('p'); $name = get_query_var('name'); $category_name = get_query_var('category_name'); @@ -185,8 +188,17 @@ function wp_title($sep = '»', $display = true) { else $category_name = $category_name[count($category_name)-2]; // there was a trailling slash } - $title = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE category_nicename = '$category_name'"); - $title = apply_filters('single_cat_title', $title); + $cat = get_term_by('slug', $category_name, 'category', OBJECT, 'display'); + if ( $cat ) + $title = apply_filters('single_cat_title', $cat->name); + } + + if ( !empty($tag) ) { + $tag = get_term($tag, 'post_tag', OBJECT, 'display'); + if ( is_wp_error( $tag ) ) + return $tag; + if ( ! empty($tag->name) ) + $title = apply_filters('single_tag_title', $tag->name); } // If there's an author @@ -265,6 +277,29 @@ function single_cat_title($prefix = '', $display = true ) { else return strip_tags($my_cat_name); } + } else if ( is_tag() ) { + return single_tag_title($prefix, $display); + } +} + + +function single_tag_title($prefix = '', $display = true ) { + if ( !is_tag() ) + return; + + $tag_id = intval( get_query_var('tag_id') ); + + if ( !empty($tag_id) ) { + $my_tag = &get_term($tag_id, 'post_tag', OBJECT, 'display'); + if ( is_wp_error( $my_tag ) ) + return false; + $my_tag_name = apply_filters('single_tag_title', $my_tag->name); + if ( !empty($my_tag_name) ) { + if ( $display ) + echo $prefix . $my_tag_name; + else + return $my_tag_name; + } } } @@ -313,16 +348,16 @@ function get_archives_link($url, $text, $format = 'html', $before = '', $after = function wp_get_archives($args = '') { - global $wp_locale, $wpdb; + global $wpdb, $wp_locale; - if ( is_array($args) ) - $r = &$args; - else - parse_str($args, $r); + $defaults = array( + 'type' => 'monthly', 'limit' => '', + 'format' => 'html', 'before' => '', + 'after' => '', 'show_post_count' => false + ); - $defaults = array('type' => 'monthly', 'limit' => '', 'format' => 'html', 'before' => '', 'after' => '', 'show_post_count' => false); - $r = array_merge($defaults, $r); - extract($r, EXTR_SKIP); + $r = wp_parse_args( $args, $defaults ); + extract( $r, EXTR_SKIP ); if ( '' == $type ) $type = 'monthly'; @@ -365,7 +400,7 @@ function wp_get_archives($args = '') { foreach ( $arcresults as $arcresult ) { $url = get_month_link($arcresult->year, $arcresult->month); $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year); - if ( $show_post_count ) + if ( $show_post_count ) $after = ' ('.$arcresult->posts.')' . $afterafter; echo get_archives_link($url, $text, $format, $before, $after); } @@ -585,10 +620,10 @@ function get_calendar($initial = true) { ); if ( $ak_post_titles ) { foreach ( $ak_post_titles as $ak_post_title ) { - + $post_title = apply_filters( "the_title", $ak_post_title->post_title ); $post_title = str_replace('"', '"', wptexturize( $post_title )); - + if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) ) $ak_titles_for_day['day_'.$ak_post_title->dom] = ''; if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one @@ -635,7 +670,7 @@ function get_calendar($initial = true) { ob_end_clean(); echo $output; $cache[ $key ] = $output; - wp_cache_add( 'get_calendar', $cache, 'calendar' ); + wp_cache_set( 'get_calendar', $cache, 'calendar' ); } function delete_get_calendar_cache() { @@ -675,7 +710,7 @@ function the_date_xml() { function the_date($d='', $before='', $after='', $echo = true) { - global $id, $post, $day, $previousday, $newday; + global $id, $post, $day, $previousday; $the_date = ''; if ( $day != $previousday ) { $the_date .= $before; @@ -810,10 +845,10 @@ function rich_edit_exists() { function user_can_richedit() { global $wp_rich_edit, $pagenow; - + if ( !isset( $wp_rich_edit) ) { - if ( get_user_option( 'rich_editing' ) == 'true' && - ( ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval($match[1]) >= 420 ) || + if ( get_user_option( 'rich_editing' ) == 'true' && + ( ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval($match[1]) >= 420 ) || !preg_match( '!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT'] ) ) && 'comment.php' != $pagenow ) { $wp_rich_edit = true; @@ -863,30 +898,6 @@ function the_editor($content, $id = 'content', $prev_id = 'title') { // 0 ) document.getElementById("quicktags").style.display="none"; - - function edInsertContent(myField, myValue) { - //IE support - if (document.selection) { - myField.focus(); - sel = document.selection.createRange(); - sel.text = myValue; - myField.focus(); - } - //MOZILLA/NETSCAPE support - else if (myField.selectionStart || myField.selectionStart == "0") { - var startPos = myField.selectionStart; - var endPos = myField.selectionEnd; - myField.value = myField.value.substring(0, startPos) - + myValue - + myField.value.substring(endPos, myField.value.length); - myField.focus(); - myField.selectionStart = startPos + myValue.length; - myField.selectionEnd = startPos + myValue.length; - } else { - myField.value += myValue; - myField.focus(); - } - } // ]]> '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below) 'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number 'total' => 1, @@ -1038,4 +1052,23 @@ function paginate_links( $args = '' ) { endswitch; return $r; } + +function wp_admin_css_uri( $file = 'wp-admin' ) { + if ( defined('WP_INSTALLING') ) + { + $_file = add_query_arg( 'version', get_bloginfo( 'version' ), "./$file.css" ); + } else { + $_file = add_query_arg( 'version', get_bloginfo( 'version' ), get_option( 'siteurl' ) . "/wp-admin/$file.css" ); + } + return apply_filters( 'wp_admin_css_uri', $_file, $file ); +} + +function wp_admin_css( $file = 'wp-admin' ) { + echo apply_filters( 'wp_admin_css', "\n", $file ); + if ( 'rtl' == get_bloginfo( 'text_direction' ) ) { + $rtl = ( 'wp-admin' == $file ) ? 'rtl' : "$file-rtl"; + echo apply_filters( 'wp_admin_css', "\n", $rtl ); + } +} + ?> diff --git a/wp-includes/js/jquery/jquery.js b/wp-includes/js/jquery/jquery.js index c684bda..59201f3 100644 --- a/wp-includes/js/jquery/jquery.js +++ b/wp-includes/js/jquery/jquery.js @@ -1 +1,13 @@ -eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('7(1C 1w.6=="T"){1w.T=1w.T;B 6=u(a,c){7(1w==q)v 1p 6(a,c);a=a||17;7(6.1t(a))v 1p 6(17)[6.E.27?"27":"2O"](a);7(1C a=="23"){B m=/^[^<]*(<(.|\\s)+>)[^>]*$/.2Q(a);7(m)a=6.3k([m[1]]);J v 1p 6(c).2o(a)}v q.6r(a.1l==2y&&a||(a.3Y||a.I&&a!=1w&&!a.24&&a[0]!=T&&a[0].24)&&6.3M(a)||[a])};7(1C $!="T")6.2S$=$;B $=6;6.E=6.8p={3Y:"1.1.2",8q:u(){v q.I},I:0,2b:u(1T){v 1T==T?6.3M(q):q[1T]},2r:u(a){B L=6(a);L.6p=q;v L},6r:u(a){q.I=0;[].1g.14(q,a);v q},K:u(E,1E){v 6.K(q,E,1E)},2h:u(1c){B 4c=-1;q.K(u(i){7(q==1c)4c=i});v 4c},1I:u(1Y,O,C){B 1c=1Y;7(1Y.1l==3t)7(O==T)v q.I&&6[C||"1I"](q[0],1Y)||T;J{1c={};1c[1Y]=O}v q.K(u(2h){P(B H 1x 1c)6.1I(C?q.1q:q,H,6.H(q,1c[H],C,2h,H))})},1m:u(1Y,O){v q.1I(1Y,O,"30")},2L:u(e){7(1C e=="23")v q.3u().3r(17.8t(e));B t="";6.K(e||q,u(){6.K(q.2I,u(){7(q.24!=8)t+=q.24!=1?q.60:6.E.2L([q])})});v t},2K:u(){B a=6.3k(1A);v q.K(u(){B b=a[0].3l(U);q.11.2X(b,q);22(b.1b)b=b.1b;b.4C(q)})},3r:u(){v q.3j(1A,U,1,u(a){q.4C(a)})},5i:u(){v q.3j(1A,U,-1,u(a){q.2X(a,q.1b)})},5j:u(){v q.3j(1A,12,1,u(a){q.11.2X(a,q)})},5t:u(){v q.3j(1A,12,-1,u(a){q.11.2X(a,q.2e)})},4g:u(){v q.6p||6([])},2o:u(t){v q.2r(6.31(q,u(a){v 6.2o(t,a)}),t)},4Y:u(4N){v q.2r(6.31(q,u(a){B a=a.3l(4N!=T?4N:U);a.$1H=16;v a}))},1D:u(t){v q.2r(6.1t(t)&&6.2q(q,u(2z,2h){v t.14(2z,[2h])})||6.3z(t,q))},2g:u(t){v q.2r(t.1l==3t&&6.3z(t,q,U)||6.2q(q,u(a){v(t.1l==2y||t.3Y)?6.3y(a,t)<0:a!=t}))},1M:u(t){v q.2r(6.2k(q.2b(),t.1l==3t?6(t).2b():t.I!=T&&(!t.1f||t.1f=="8v")?t:[t]))},4l:u(1s){v 1s?6.1D(1s,q).r.I>0:12},1a:u(1a){v 1a==T?(q.I?q[0].O:16):q.1I("O",1a)},4U:u(1a){v 1a==T?(q.I?q[0].2t:16):q.3u().3r(1a)},3j:u(1E,1P,3Z,E){B 4Y=q.I>1;B a=6.3k(1E);7(3Z<0)a.8w();v q.K(u(){B 1c=q;7(1P&&6.1f(q,"1P")&&6.1f(a[0],"3m"))1c=q.5J("20")[0]||q.4C(17.6n("20"));6.K(a,u(){E.14(1c,[4Y?q.3l(U):q])})})}};6.1z=6.E.1z=u(){B 1O=1A[0],a=1;7(1A.I==1){1O=q;a=0}B H;22(H=1A[a++])P(B i 1x H)1O[i]=H[i];v 1O};6.1z({8x:u(){7(6.2S$)$=6.2S$;v 6},1t:u(E){v!!E&&1C E!="23"&&!E.1f&&1C E[0]=="T"&&/u/i.1n(E+"")},4B:u(D){v D.66&&D.5I&&!D.5I.64},1f:u(D,Y){v D.1f&&D.1f.3K()==Y.3K()},K:u(1c,E,1E){7(1c.I==T)P(B i 1x 1c)E.14(1c[i],1E||[i,1c[i]]);J P(B i=0,6q=1c.I;i<6q;i++)7(E.14(1c[i],1E||[i,1c[i]])===12)3O;v 1c},H:u(D,O,C,2h,H){7(6.1t(O))O=O.3n(D,[2h]);B 6s=/z-?2h|7P-?8A|1d|58|8B-?28/i;v O&&O.1l==3Q&&C=="30"&&!6s.1n(H)?O+"4S":O},19:{1M:u(D,c){6.K(c.3o(/\\s+/),u(i,Q){7(!6.19.2V(D.19,Q))D.19+=(D.19?" ":"")+Q})},2f:u(D,c){D.19=c?6.2q(D.19.3o(/\\s+/),u(Q){v!6.19.2V(c,Q)}).6t(" "):""},2V:u(t,c){t=t.19||t;c=c.1R(/([\\.\\\\\\+\\*\\?\\[\\^\\]\\$\\(\\)\\{\\}\\=\\!\\<\\>\\|\\:])/g,"\\\\$1");v t&&1p 4v("(^|\\\\s)"+c+"(\\\\s|$)").1n(t)}},4d:u(e,o,f){P(B i 1x o){e.1q["1N"+i]=e.1q[i];e.1q[i]=o[i]}f.14(e,[]);P(B i 1x o)e.1q[i]=e.1q["1N"+i]},1m:u(e,p){7(p=="28"||p=="3V"){B 1N={},46,3P,d=["7d","8C","8D","8E"];6.K(d,u(){1N["8F"+q]=0;1N["8G"+q+"8H"]=0});6.4d(e,1N,u(){7(6.1m(e,"1h")!="1Z"){46=e.8I;3P=e.8J}J{e=6(e.3l(U)).2o(":4j").5l("2Z").4g().1m({4n:"1G",45:"8K",1h:"2D",7I:"0",8M:"0"}).5z(e.11)[0];B 3d=6.1m(e.11,"45");7(3d==""||3d=="4b")e.11.1q.45="6x";46=e.6y;3P=e.6z;7(3d==""||3d=="4b")e.11.1q.45="4b";e.11.33(e)}});v p=="28"?46:3P}v 6.30(e,p)},30:u(D,H,53){B L;7(H=="1d"&&6.W.1j)v 6.1I(D.1q,"1d");7(H=="4h"||H=="2v")H=6.W.1j?"3T":"2v";7(!53&&D.1q[H])L=D.1q[H];J 7(17.44&&17.44.4W){7(H=="2v"||H=="3T")H="4h";H=H.1R(/([A-Z])/g,"-$1").4m();B Q=17.44.4W(D,16);7(Q)L=Q.55(H);J 7(H=="1h")L="1Z";J 6.4d(D,{1h:"2D"},u(){B c=17.44.4W(q,"");L=c&&c.55(H)||""})}J 7(D.51){B 56=H.1R(/\\-(\\w)/g,u(m,c){v c.3K()});L=D.51[H]||D.51[56]}v L},3k:u(a){B r=[];6.K(a,u(i,1r){7(!1r)v;7(1r.1l==3Q)1r=1r.6C();7(1C 1r=="23"){B s=6.35(1r),1V=17.6n("1V"),2i=[];B 2K=!s.18("<1u")&&[1,"<42>",""]||(!s.18("<6D")||!s.18("<20")||!s.18("<6E"))&&[1,"<1P>",""]||!s.18("<3m")&&[2,"<1P><20>",""]||(!s.18("<6F")||!s.18("<6G"))&&[3,"<1P><20><3m>",""]||[0,"",""];1V.2t=2K[1]+s+2K[2];22(2K[0]--)1V=1V.1b;7(6.W.1j){7(!s.18("<1P")&&s.18("<20")<0)2i=1V.1b&&1V.1b.2I;J 7(2K[1]=="<1P>"&&s.18("<20")<0)2i=1V.2I;P(B n=2i.I-1;n>=0;--n)7(6.1f(2i[n],"20")&&!2i[n].2I.I)2i[n].11.33(2i[n])}1r=[];P(B i=0,l=1V.2I.I;im[3]-0",2a:"m[3]-0==i",5q:"m[3]-0==i",2u:"i==0",2T:"i==r.I-1",5R:"i%2==0",5S:"i%2","2a-3s":"6.2a(a.11.1b,m[3],\'2e\',a)==a","2u-3s":"6.2a(a.11.1b,1,\'2e\')==a","2T-3s":"6.2a(a.11.7n,1,\'5s\')==a","7p-3s":"6.2B(a.11.1b).I==1",5u:"a.1b",3u:"!a.1b",5v:"6.E.2L.14([a]).18(m[3])>=0",3i:\'a.C!="1G"&&6.1m(a,"1h")!="1Z"&&6.1m(a,"4n")!="1G"\',1G:\'a.C=="1G"||6.1m(a,"1h")=="1Z"||6.1m(a,"4n")=="1G"\',7v:"!a.2W",2W:"a.2W",2Z:"a.2Z",2Y:"a.2Y||6.1I(a,\'2Y\')",2L:"a.C==\'2L\'",4j:"a.C==\'4j\'",5x:"a.C==\'5x\'",4G:"a.C==\'4G\'",5y:"a.C==\'5y\'",4R:"a.C==\'4R\'",5A:"a.C==\'5A\'",5B:"a.C==\'5B\'",3x:\'a.C=="3x"||6.1f(a,"3x")\',5C:"/5C|42|7A|3x/i.1n(a.1f)"},".":"6.19.2V(a,m[2])","@":{"=":"z==m[4]","!=":"z!=m[4]","^=":"z&&!z.18(m[4])","$=":"z&&z.2U(z.I - m[4].I,m[4].I)==m[4]","*=":"z&&z.18(m[4])>=0","":"z",4u:u(m){v["",m[1],m[3],m[2],m[5]]},5P:"z=a[m[3]];7(!z||/5E|3e/.1n(m[3]))z=6.1I(a,m[3]);"},"[":"6.2o(m[2],a).I"},5M:[/^\\[ *(@)([a-2m-3C-]*) *([!*$^=]*) *(\'?"?)(.*?)\\4 *\\]/i,/^(\\[)\\s*(.*?(\\[.*?\\])?[^[]*?)\\s*\\]/,/^(:)([a-2m-3C-]*)\\("?\'?(.*?(\\(.*?\\))?[^(]*?)"?\'?\\)/i,/^([:.#]*)([a-2m-3C*-]*)/i],1Q:[/^(\\/?\\.\\.)/,"a.11",/^(>|\\/)/,"6.2B(a.1b)",/^(\\+)/,"6.2a(a,2,\'2e\')",/^(~)/,u(a){B s=6.2B(a.11.1b);v s.3N(6.3y(a,s)+1)}],3z:u(1s,1U,2g){B 1N,Q=[];22(1s&&1s!=1N){1N=1s;B f=6.1D(1s,1U,2g);1s=f.t.1R(/^\\s*,\\s*/,"");Q=2g?1U=f.r:6.2k(Q,f.r)}v Q},2o:u(t,1B){7(1C t!="23")v[t];7(1B&&!1B.24)1B=16;1B=1B||17;7(!t.18("//")){1B=1B.4H;t=t.2U(2,t.I)}J 7(!t.18("/")){1B=1B.4H;t=t.2U(1,t.I);7(t.18("/")>=1)t=t.2U(t.18("/"),t.I)}B L=[1B],2c=[],2T=16;22(t&&2T!=t){B r=[];2T=t;t=6.35(t).1R(/^\\/\\//i,"");B 3B=12;B 1J=/^[\\/>]\\s*([a-2m-9*-]+)/i;B m=1J.2Q(t);7(m){6.K(L,u(){P(B c=q.1b;c;c=c.2e)7(c.24==1&&(6.1f(c,m[1])||m[1]=="*"))r.1g(c)});L=r;t=t.1R(1J,"");7(t.18(" ")==0)5F;3B=U}J{P(B i=0;i<6.1Q.I;i+=2){B 1J=6.1Q[i];B m=1J.2Q(t);7(m){r=L=6.31(L,6.1t(6.1Q[i+1])?6.1Q[i+1]:u(a){v 40(6.1Q[i+1])});t=6.35(t.1R(1J,""));3B=U;3O}}}7(t&&!3B){7(!t.18(",")){7(L[0]==1B)L.4L();6.2k(2c,L);r=L=[1B];t=" "+t.2U(1,t.I)}J{B 34=/^([a-2m-3C-]+)(#)([a-2m-9\\\\*2S-]*)/i;B m=34.2Q(t);7(m){m=[0,m[2],m[3],m[1]]}J{34=/^([#.]?)([a-2m-9\\\\*2S-]*)/i;m=34.2Q(t)}7(m[1]=="#"&&L[L.I-1].4X){B 2l=L[L.I-1].4X(m[2]);7(6.W.1j&&2l&&2l.2J!=m[2])2l=6(\'[@2J="\'+m[2]+\'"]\',L[L.I-1])[0];L=r=2l&&(!m[3]||6.1f(2l,m[3]))?[2l]:[]}J{7(m[1]==".")B 4r=1p 4v("(^|\\\\s)"+m[2]+"(\\\\s|$)");6.K(L,u(){B 3E=m[1]!=""||m[0]==""?"*":m[2];7(6.1f(q,"7J")&&3E=="*")3E="3g";6.2k(r,m[1]!=""&&L.I!=1?6.4x(q,[],m[1],m[2],4r):q.5J(3E))});7(m[1]=="."&&L.I==1)r=6.2q(r,u(e){v 4r.1n(e.19)});7(m[1]=="#"&&L.I==1){B 5K=r;r=[];6.K(5K,u(){7(q.36("2J")==m[2]){r=[q];v 12}})}L=r}t=t.1R(34,"")}}7(t){B 1a=6.1D(t,r);L=r=1a.r;t=6.35(1a.t)}}7(L&&L[0]==1B)L.4L();6.2k(2c,L);v 2c},1D:u(t,r,2g){22(t&&/^[a-z[({<*:.#]/i.1n(t)){B p=6.5M,m;6.K(p,u(i,1J){m=1J.2Q(t);7(m){t=t.7M(m[0].I);7(6.1s[m[1]].4u)m=6.1s[m[1]].4u(m);v 12}});7(m[1]==":"&&m[2]=="2g")r=6.1D(m[3],r,U).r;J 7(m[1]=="."){B 1J=1p 4v("(^|\\\\s)"+m[2]+"(\\\\s|$)");r=6.2q(r,u(e){v 1J.1n(e.19||"")},2g)}J{B f=6.1s[m[1]];7(1C f!="23")f=6.1s[m[1]][m[2]];40("f = u(a,i){"+(6.1s[m[1]].5P||"")+"v "+f+"}");r=6.2q(r,f,2g)}}v{r:r,t:t}},4x:u(o,r,1Q,Y,1J){P(B s=o.1b;s;s=s.2e)7(s.24==1){B 1M=U;7(1Q==".")1M=s.19&&1J.1n(s.19);J 7(1Q=="#")1M=s.36("2J")==Y;7(1M)r.1g(s);7(1Q=="#"&&r.I)3O;7(s.1b)6.4x(s,r,1Q,Y,1J)}v r},4z:u(D){B 4A=[];B Q=D.11;22(Q&&Q!=17){4A.1g(Q);Q=Q.11}v 4A},2a:u(Q,1i,3Z,D){1i=1i||1;B 1T=0;P(;Q;Q=Q[3Z]){7(Q.24==1)1T++;7(1T==1i||1i=="5R"&&1T%2==0&&1T>1&&Q==D||1i=="5S"&&1T%2==1&&Q==D)v Q}},2B:u(n,D){B r=[];P(;n;n=n.2e){7(n.24==1&&(!D||n!=D))r.1g(n)}v r}});6.G={1M:u(S,C,1o,F){7(6.W.1j&&S.3L!=T)S=1w;7(F)1o.F=F;7(!1o.2A)1o.2A=q.2A++;7(!S.$1H)S.$1H={};B 38=S.$1H[C];7(!38){38=S.$1H[C]={};7(S["39"+C])38[0]=S["39"+C]}38[1o.2A]=1o;S["39"+C]=q.5Y;7(!q.1k[C])q.1k[C]=[];q.1k[C].1g(S)},2A:1,1k:{},2f:u(S,C,1o){7(S.$1H){B i,j,k;7(C&&C.C){1o=C.1o;C=C.C}7(C&&S.$1H[C])7(1o)5U S.$1H[C][1o.2A];J P(i 1x S.$1H[C])5U S.$1H[C][i];J P(j 1x S.$1H)q.2f(S,j);P(k 1x S.$1H[C])7(k){k=U;3O}7(!k)S["39"+C]=16}},1S:u(C,F,S){F=6.3M(F||[]);7(!S)6.K(q.1k[C]||[],u(){6.G.1S(C,F,q)});J{B 1o=S["39"+C],1a,E=6.1t(S[C]);7(1o){F.61(q.2j({C:C,1O:S}));7((1a=1o.14(S,F))!==12)q.4F=U}7(E&&1a!==12)S[C]();q.4F=12}},5Y:u(G){7(1C 6=="T"||6.G.4F)v;G=6.G.2j(G||1w.G||{});B 3R;B c=q.$1H[G.C];B 1E=[].3N.3n(1A,1);1E.61(G);P(B j 1x c){1E[0].1o=c[j];1E[0].F=c[j].F;7(c[j].14(q,1E)===12){G.2n();G.2H();3R=12}}7(6.W.1j)G.1O=G.2n=G.2H=G.1o=G.F=16;v 3R},2j:u(G){7(!G.1O&&G.63)G.1O=G.63;7(G.65==T&&G.67!=T){B e=17.4H,b=17.64;G.65=G.67+(e.68||b.68);G.7Y=G.7Z+(e.6c||b.6c)}7(6.W.2N&&G.1O.24==3){B 3a=G;G=6.1z({},3a);G.1O=3a.1O.11;G.2n=u(){v 3a.2n()};G.2H=u(){v 3a.2H()}}7(!G.2n)G.2n=u(){q.3R=12};7(!G.2H)G.2H=u(){q.82=U};v G}};6.E.1z({3U:u(C,F,E){v q.K(u(){6.G.1M(q,C,E||F,F)})},6u:u(C,F,E){v q.K(u(){6.G.1M(q,C,u(G){6(q).6f(G);v(E||F).14(q,1A)},F)})},6f:u(C,E){v q.K(u(){6.G.2f(q,C,E)})},1S:u(C,F){v q.K(u(){6.G.1S(C,F,q)})},3X:u(){B a=1A;v q.6j(u(e){q.4M=q.4M==0?1:0;e.2n();v a[q.4M].14(q,[e])||12})},83:u(f,g){u 4O(e){B p=(e.C=="41"?e.84:e.85)||e.86;22(p&&p!=q)2G{p=p.11}2w(e){p=q};7(p==q)v 12;v(e.C=="41"?f:g).14(q,[e])}v q.41(4O).6k(4O)},27:u(f){7(6.3W)f.14(17,[6]);J{6.3c.1g(u(){v f.14(q,[6])})}v q}});6.1z({3W:12,3c:[],27:u(){7(!6.3W){6.3W=U;7(6.3c){6.K(6.3c,u(){q.14(17)});6.3c=16}7(6.W.3h||6.W.3f)17.87("6o",6.27,12)}}});1p u(){6.K(("88,8a,2O,8b,8d,52,6j,8e,"+"8f,8g,8h,41,6k,8j,42,"+"4R,8k,8l,8m,2C").3o(","),u(i,o){6.E[o]=u(f){v f?q.3U(o,f):q.1S(o)}});7(6.W.3h||6.W.3f)17.8n("6o",6.27,12);J 7(6.W.1j){17.8o("<8r"+"8s 2J=62 8u=U "+"3e=//:><\\/2d>");B 2d=17.4X("62");7(2d)2d.37=u(){7(q.3D!="1X")v;q.11.33(q);6.27()};2d=16}J 7(6.W.2N)6.50=3L(u(){7(17.3D=="8y"||17.3D=="1X"){4p(6.50);6.50=16;6.27()}},10);6.G.1M(1w,"2O",6.27)};7(6.W.1j)6(1w).6u("52",u(){B 1k=6.G.1k;P(B C 1x 1k){B 4Z=1k[C],i=4Z.I;7(i&&C!=\'52\')6w 6.G.2f(4Z[i-1],C);22(--i)}});6.E.1z({6A:u(V,21,M){q.2O(V,21,M,1)},2O:u(V,21,M,1W){7(6.1t(V))v q.3U("2O",V);M=M||u(){};B C="5d";7(21)7(6.1t(21)){M=21;21=16}J{21=6.3g(21);C="5V"}B 4e=q;6.3v({V:V,C:C,F:21,1W:1W,1X:u(2P,15){7(15=="2M"||!1W&&15=="5L")4e.1I("2t",2P.3G).4V().K(M,[2P.3G,15,2P]);J M.14(4e,[2P.3G,15,2P])}});v q},6B:u(){v 6.3g(q)},4V:u(){v q.2o("2d").K(u(){7(q.3e)6.59(q.3e);J 6.4a(q.2L||q.6H||q.2t||"")}).4g()}});7(!1w.3p)3p=u(){v 1p 6I("6K.6M")};6.K("5m,5Q,5O,5W,5N,5H".3o(","),u(i,o){6.E[o]=u(f){v q.3U(o,f)}});6.1z({2b:u(V,F,M,C,1W){7(6.1t(F)){M=F;F=16}v 6.3v({V:V,F:F,2M:M,4t:C,1W:1W})},6Q:u(V,F,M,C){v 6.2b(V,F,M,C,1)},59:u(V,M){v 6.2b(V,16,M,"2d")},6S:u(V,F,M){v 6.2b(V,F,M,"6m")},6U:u(V,F,M,C){7(6.1t(F)){M=F;F={}}v 6.3v({C:"5V",V:V,F:F,2M:M,4t:C})},6X:u(29){6.3q.29=29},6Y:u(5c){6.1z(6.3q,5c)},3q:{1k:U,C:"5d",29:0,5r:"70/x-73-3w-77",5h:U,48:U,F:16},3S:{},3v:u(s){s=6.1z({},6.3q,s);7(s.F){7(s.5h&&1C s.F!="23")s.F=6.3g(s.F);7(s.C.4m()=="2b"){s.V+=((s.V.18("?")>-1)?"&":"?")+s.F;s.F=16}}7(s.1k&&!6.4E++)6.G.1S("5m");B 4y=12;B N=1p 3p();N.7j(s.C,s.V,s.48);7(s.F)N.3A("7l-7m",s.5r);7(s.1W)N.3A("7o-4K-7q",6.3S[s.V]||"7s, 7t 7w 7x 4o:4o:4o 7z");N.3A("X-7B-7C","3p");7(N.7E)N.3A("7F","7G");7(s.5G)s.5G(N);7(s.1k)6.G.1S("5H",[N,s]);B 37=u(4s){7(N&&(N.3D==4||4s=="29")){4y=U;7(3I){4p(3I);3I=16}B 15;2G{15=6.5Z(N)&&4s!="29"?s.1W&&6.69(N,s.V)?"5L":"2M":"2C";7(15!="2C"){B 3F;2G{3F=N.4P("6b-4K")}2w(e){}7(s.1W&&3F)6.3S[s.V]=3F;B F=6.6i(N,s.4t);7(s.2M)s.2M(F,15);7(s.1k)6.G.1S("5N",[N,s])}J 6.3J(s,N,15)}2w(e){15="2C";6.3J(s,N,15,e)}7(s.1k)6.G.1S("5O",[N,s]);7(s.1k&&!--6.4E)6.G.1S("5Q");7(s.1X)s.1X(N,15);7(s.48)N=16}};B 3I=3L(37,13);7(s.29>0)57(u(){7(N){N.7N();7(!4y)37("29")}},s.29);2G{N.7Q(s.F)}2w(e){6.3J(s,N,16,e)}7(!s.48)37();v N},3J:u(s,N,15,e){7(s.2C)s.2C(N,15,e);7(s.1k)6.G.1S("5W",[N,s,e])},4E:0,5Z:u(r){2G{v!r.15&&7V.7W=="4G:"||(r.15>=5X&&r.15<7X)||r.15==6d||6.W.2N&&r.15==T}2w(e){}v 12},69:u(N,V){2G{B 6e=N.4P("6b-4K");v N.15==6d||6e==6.3S[V]||6.W.2N&&N.15==T}2w(e){}v 12},6i:u(r,C){B 4Q=r.4P("8c-C");B F=!C&&4Q&&4Q.18("N")>=0;F=C=="N"||F?r.8i:r.3G;7(C=="2d")6.4a(F);7(C=="6m")40("F = "+F);7(C=="4U")6("<1V>").4U(F).4V();v F},3g:u(a){B s=[];7(a.1l==2y||a.3Y)6.K(a,u(){s.1g(2x(q.Y)+"="+2x(q.O))});J P(B j 1x a)7(a[j]&&a[j].1l==2y)6.K(a[j],u(){s.1g(2x(j)+"="+2x(q))});J s.1g(2x(j)+"="+2x(a[j]));v s.6t("&")},4a:u(F){7(1w.54)1w.54(F);J 7(6.W.2N)1w.57(F,0);J 40.3n(1w,F)}});6.E.1z({1L:u(R,M){B 1G=q.1D(":1G");R?1G.26({28:"1L",3V:"1L",1d:"1L"},R,M):1G.K(u(){q.1q.1h=q.2E?q.2E:"";7(6.1m(q,"1h")=="1Z")q.1q.1h="2D"});v q},1K:u(R,M){B 3i=q.1D(":3i");R?3i.26({28:"1K",3V:"1K",1d:"1K"},R,M):3i.K(u(){q.2E=q.2E||6.1m(q,"1h");7(q.2E=="1Z")q.2E="2D";q.1q.1h="1Z"});v q},5g:6.E.3X,3X:u(E,4I){B 1E=1A;v 6.1t(E)&&6.1t(4I)?q.5g(E,4I):q.K(u(){6(q)[6(q).4l(":1G")?"1L":"1K"].14(6(q),1E)})},7a:u(R,M){v q.26({28:"1L"},R,M)},7c:u(R,M){v q.26({28:"1K"},R,M)},7f:u(R,M){v q.K(u(){B 5k=6(q).4l(":1G")?"1L":"1K";6(q).26({28:5k},R,M)})},7r:u(R,M){v q.26({1d:"1L"},R,M)},7u:u(R,M){v q.26({1d:"1K"},R,M)},7y:u(R,43,M){v q.26({1d:43},R,M)},26:u(H,R,1v,M){v q.1F(u(){q.2F=6.1z({},H);B 1u=6.R(R,1v,M);P(B p 1x H){B e=1p 6.3b(q,1u,p);7(H[p].1l==3Q)e.2s(e.Q(),H[p]);J e[H[p]](H)}})},1F:u(C,E){7(!E){E=C;C="3b"}v q.K(u(){7(!q.1F)q.1F={};7(!q.1F[C])q.1F[C]=[];q.1F[C].1g(E);7(q.1F[C].I==1)E.14(q)})}});6.1z({R:u(R,1v,E){B 1u=R&&R.1l==7K?R:{1X:E||!E&&1v||6.1t(R)&&R,25:R,1v:E&&1v||1v&&1v.1l!=4w&&1v};1u.25=(1u.25&&1u.25.1l==3Q?1u.25:{7R:7S,7T:5X}[1u.25])||7U;1u.1N=1u.1X;1u.1X=u(){6.6a(q,"3b");7(6.1t(1u.1N))1u.1N.14(q)};v 1u},1v:{},1F:{},6a:u(D,C){C=C||"3b";7(D.1F&&D.1F[C]){D.1F[C].4L();B f=D.1F[C][0];7(f)f.14(D)}},3b:u(D,1e,H){B z=q;B y=D.1q;B 4D=6.1m(D,"1h");y.5T="1G";z.a=u(){7(1e.49)1e.49.14(D,[z.2p]);7(H=="1d")6.1I(y,"1d",z.2p);J 7(6l(z.2p))y[H]=6l(z.2p)+"4S";y.1h="2D"};z.6v=u(){v 4T(6.1m(D,H))};z.Q=u(){B r=4T(6.30(D,H));v r&&r>-8z?r:z.6v()};z.2s=u(4f,43){z.4J=(1p 5o()).5w();z.2p=4f;z.a();z.4q=3L(u(){z.49(4f,43)},13)};z.1L=u(){7(!D.1y)D.1y={};D.1y[H]=q.Q();1e.1L=U;z.2s(0,D.1y[H]);7(H!="1d")y[H]="5a"};z.1K=u(){7(!D.1y)D.1y={};D.1y[H]=q.Q();1e.1K=U;z.2s(D.1y[H],0)};z.3X=u(){7(!D.1y)D.1y={};D.1y[H]=q.Q();7(4D=="1Z"){1e.1L=U;7(H!="1d")y[H]="5a";z.2s(0,D.1y[H])}J{1e.1K=U;z.2s(D.1y[H],0)}};z.49=u(32,47){B t=(1p 5o()).5w();7(t>1e.25+z.4J){4p(z.4q);z.4q=16;z.2p=47;z.a();7(D.2F)D.2F[H]=U;B 2c=U;P(B i 1x D.2F)7(D.2F[i]!==U)2c=12;7(2c){y.5T="";y.1h=4D;7(6.1m(D,"1h")=="1Z")y.1h="2D";7(1e.1K)y.1h="1Z";7(1e.1K||1e.1L)P(B p 1x D.2F)7(p=="1d")6.1I(y,p,D.1y[p]);J y[p]=""}7(2c&&6.1t(1e.1X))1e.1X.14(D)}J{B n=t-q.4J;B p=n/1e.25;z.2p=1e.1v&&6.1v[1e.1v]?6.1v[1e.1v](p,n,32,(47-32),1e.25):((-6h.7O(p*6h.8L)/2)+0.5)*(47-32)+32;z.a()}}}})}',62,545,'||||||jQuery|if|||||||||||||||||||this||||function|return||||||var|type|elem|fn|data|event|prop|length|else|each|ret|callback|xml|value|for|cur|speed|element|undefined|true|url|browser||name|||parentNode|false||apply|status|null|document|indexOf|className|val|firstChild|obj|opacity|options|nodeName|push|display|result|msie|global|constructor|css|test|handler|new|style|arg|expr|isFunction|opt|easing|window|in|orig|extend|arguments|context|typeof|filter|args|queue|hidden|events|attr|re|hide|show|add|old|target|table|token|replace|trigger|num|elems|div|ifModified|complete|key|none|tbody|params|while|string|nodeType|duration|animate|ready|height|timeout|nth|get|done|script|nextSibling|remove|not|index|tb|fix|merge|oid|z0|preventDefault|find|now|grep|pushStack|custom|innerHTML|first|cssFloat|catch|encodeURIComponent|Array|el|guid|sibling|error|block|oldblock|curAnim|try|stopPropagation|childNodes|id|wrap|text|success|safari|load|res|exec|al|_|last|substr|has|disabled|insertBefore|selected|checked|curCSS|map|firstNum|removeChild|re2|trim|getAttribute|onreadystatechange|handlers|on|originalEvent|fx|readyList|parPos|src|opera|param|mozilla|visible|domManip|clean|cloneNode|tr|call|split|XMLHttpRequest|ajaxSettings|append|child|String|empty|ajax|form|button|inArray|multiFilter|setRequestHeader|foundToken|9_|readyState|tag|modRes|responseText|second|ival|handleError|toUpperCase|setInterval|makeArray|slice|break|oWidth|Number|returnValue|lastModified|styleFloat|bind|width|isReady|toggle|jquery|dir|eval|mouseover|select|to|defaultView|position|oHeight|lastNum|async|step|globalEval|static|pos|swap|self|from|end|float|alpha|radio|inv|is|toLowerCase|visibility|00|clearInterval|timer|rec|isTimeout|dataType|_resort|RegExp|Function|getAll|requestDone|parents|matched|isXMLDoc|appendChild|oldDisplay|active|triggered|file|documentElement|fn2|startTime|Modified|shift|lastToggle|deep|handleHover|getResponseHeader|ct|submit|px|parseFloat|html|evalScripts|getComputedStyle|getElementById|clone|els|safariTimer|currentStyle|unload|force|execScript|getPropertyValue|newProp|setTimeout|zoom|getScript|1px|sl|settings|GET|rl|check|_toggle|processData|prepend|before|state|removeAttr|ajaxStart|lt|Date|gt|eq|contentType|previousSibling|after|parent|contains|getTime|checkbox|password|appendTo|image|reset|input|webkit|href|continue|beforeSend|ajaxSend|ownerDocument|getElementsByTagName|tmp|notmodified|parse|ajaxSuccess|ajaxComplete|_prefix|ajaxStop|even|odd|overflow|delete|POST|ajaxError|200|handle|httpSuccess|nodeValue|unshift|__ie_init|srcElement|body|pageX|tagName|clientX|scrollLeft|httpNotModified|dequeue|Last|scrollTop|304|xmlRes|unbind|100|Math|httpData|click|mouseout|parseInt|json|createElement|DOMContentLoaded|prevObject|ol|setArray|exclude|join|one|max|do|relative|clientHeight|clientWidth|loadIfModified|serialize|toString|thead|tfoot|td|th|textContent|ActiveXObject|htmlFor|Microsoft|class|XMLHTTP|readOnly|gi|match|getIfModified|9999|getJSON|getAttributeNode|post|setAttribute|ig|ajaxTimeout|ajaxSetup|concat|application|userAgent|compatible|www|compatMode|CSS1Compat|next|urlencoded|siblings|children|slideDown|prependTo|slideUp|Top|insertAfter|slideToggle|removeAttribute|addClass|removeClass|open|toggleClass|Content|Type|lastChild|If|only|Since|fadeIn|Thu|01|fadeOut|enabled|Jan|1970|fadeTo|GMT|textarea|Requested|With|prev|overrideMimeType|Connection|close|boxModel|right|object|Object|navigator|substring|abort|cos|font|send|slow|600|fast|400|location|protocol|300|pageY|clientY|method|action|cancelBubble|hover|fromElement|toElement|relatedTarget|removeEventListener|blur|readonly|focus|resize|content|scroll|dblclick|mousedown|mouseup|mousemove|responseXML|change|keydown|keypress|keyup|addEventListener|write|prototype|size|scr|ipt|createTextNode|defer|FORM|reverse|noConflict|loaded|10000|weight|line|Bottom|Right|Left|padding|border|Width|offsetHeight|offsetWidth|absolute|PI|left'.split('|'),0,{}));jQuery.noConflict(); +/* + * jQuery 1.1.4 - New Wave Javascript + * + * Copyright (c) 2007 John Resig (jquery.com) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * $Date: 2007-08-23 21:49:27 -0400 (Thu, 23 Aug 2007) $ + * $Rev: 2862 $ + */ +eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(9(){6(1f C!="Q")E v=C;E C=19.16=9(a,c){6(19==7||!7.4a)F 1s C(a,c);F 7.4a(a,c)};6(1f $!="Q")E B=$;19.$=C;E q=/^[^<]*(<(.|\\s)+>)[^>]*$|^#(\\w+)$/;C.15=C.3v={4a:9(a,c){a=a||R;6(1f a=="1E"){E m=q.2d(a);6(m&&(m[1]||!c)){6(m[1])a=C.3c([m[1]]);G{E b=R.37(m[3]);6(b)6(b.2j!=m[3])F C().1F(a);G{7[0]=b;7.H=1;F 7}G a=[]}}G F 1s C(c).1F(a)}G 6(C.1g(a))F 1s C(R)[C.15.1L?"1L":"2f"](a);F 7.5J(a.1b==1K&&a||(a.3w||a.H&&a!=19&&!a.1t&&a[0]!=Q&&a[0].1t)&&C.2V(a)||[a])},3w:"1.1.4",7K:9(){F 7.H},H:0,21:9(a){F a==Q?C.2V(7):7[a]},1O:9(a){E b=C(a);b.5c=7;F b},5J:9(a){7.H=0;1K.3v.Y.T(7,a);F 7},J:9(a,b){F C.J(7,a,b)},45:9(a){E b=-1;7.J(9(i){6(7==a)b=i});F b},1j:9(f,d,e){E c=f;6(f.1b==3n)6(d==Q)F 7.H&&C[e||"1j"](7[0],f)||Q;G{c={};c[f]=d}F 7.J(9(a){I(E b 17 c)C.1j(e?7.S:7,b,C.4Q(7,c[b],e,a,b))})},1h:9(b,a){F 7.1j(b,a,"34")},2Q:9(e){6(1f e!="4P"&&e!=K)F 7.3K().3H(R.60(e));E t="";C.J(e||7,9(){C.J(7.2Z,9(){6(7.1t!=8)t+=7.1t!=1?7.5S:C.15.2Q([7])})});F t},82:9(){E a,2e=1a;F 7.J(9(){6(!a)a=C.3c(2e,7.2I);E b=a[0].3B(O);7.P.2p(b,7);20(b.1k)b=b.1k;b.4p(7)})},3H:9(){F 7.2J(1a,O,1,9(a){7.4p(a)})},5v:9(){F 7.2J(1a,O,-1,9(a){7.2p(a,7.1k)})},5u:9(){F 7.2J(1a,M,1,9(a){7.P.2p(a,7)})},5t:9(){F 7.2J(1a,M,-1,9(a){7.P.2p(a,7.2a)})},3L:9(){F 7.5c||C([])},1F:9(t){E b=C.3M(7,9(a){F C.1F(t,a)});F 7.1O(/[^+>] [^+>]/.1d(t)||t.U("..")>-1?C.4d(b):b)},7o:9(e){e=e!=Q?e:O;E d=7.1r(7.1F("*"));6(C.N.12){d.J(9(){7.2l$1i={};I(E a 17 7.$1i)7.2l$1i[a]=C.14({},7.$1i[a])}).49()}E r=7.1O(C.3M(7,9(a){F a.3B(e)}));6(C.N.12){d.J(9(){E c=7.2l$1i;I(E a 17 c)I(E b 17 c[a])C.1c.1r(7,a,c[a][b],c[a][b].V);7.2l$1i=K})}6(e){E f=r.1r(r.1F(\'*\')).1l(\'2b,39[@L=3i]\');d.1l(\'2b,39[@L=3i]\').J(9(i){6(7.3j)f[i].3j=7.3j;6(7.27)f[i].27=O})}F r},1l:9(t){F 7.1O(C.1g(t)&&C.2B(7,9(b,a){F t.T(b,[a])})||C.2R(t,7))},5l:9(t){F 7.1O(t.1b==3n&&C.2R(t,7,O)||C.2B(7,9(a){F(t.1b==1K||t.3w)?C.4K(a,t)<0:a!=t}))},1r:9(t){F 7.1O(C.29(7.21(),t.1b==3n?C(t).21():t.H!=Q&&(!t.W||t.W=="6s")?t:[t]))},3y:9(a){F a?C.2R(a,7).H>0:M},2G:9(a){F a==Q?(7.H?7[0].2A:K):7.1j("2A",a)},5W:9(a){F a==Q?(7.H?7[0].2W:K):7.3K().3H(a)},3S:9(){F 7.1O(1K.3v.3S.T(7,1a))},2J:9(f,d,g,e){E c=7.H>1,a;F 7.J(9(){6(!a){a=C.3c(f,7.2I);6(g<0)a.8E()}E b=7;6(d&&C.W(7,"1A")&&C.W(a[0],"3O"))b=7.4L("1w")[0]||7.4p(R.6a("1w"));C.J(a,9(){6(C.W(7,"33")){6(7.32)C.31({1G:7.32,2w:M,3G:"33"});G C.4E(7.2Q||7.5Z||7.2W||"")}G e.T(b,[c?7.3B(O):7])})})}};C.14=C.15.14=9(){E c=1a[0]||{},a=1,1M=1a.H,4D=M;6(c.1b==8d){4D=c;c=1a[1]||{}}6(1M==1){c=7;a=0}E b;I(;a<1M;a++)6((b=1a[a])!=K)I(E i 17 b){6(c==b[i])5X;6(4D&&1f b[i]==\'4P\'&&c[i])C.14(c[i],b[i]);G 6(b[i]!=Q)c[i]=b[i]}F c};C.14({8a:9(a){19.$=B;6(a)19.16=v;F C},1g:9(a){F!!a&&1f a!="1E"&&!a.W&&a.1b!=1K&&/9/i.1d(a+"")},3E:9(a){F a.3D&&!a.4z||a.4y&&a.2I&&!a.2I.4z},4E:9(a){a=C.2s(a);6(a){6(19.5N)19.5N(a);G 6(C.N.1H)19.4x(a,0);G 2T.2S(19,a)}},W:9(b,a){F b.W&&b.W.1I()==a.1I()},J:9(a,b,c){6(c){6(a.H==Q)I(E i 17 a)b.T(a[i],c);G I(E i=0,3A=a.H;i<3A;i++)6(b.T(a[i],c)===M)1J}G{6(a.H==Q)I(E i 17 a)b.2S(a[i],i,a[i]);G I(E i=0,3A=a.H,2G=a[0];i<3A&&b.2S(2G,i,2G)!==M;2G=a[++i]){}}F a},4Q:9(c,b,d,e,a){6(C.1g(b))b=b.2S(c,[e]);E f=/z-?45|7S-?7Q|1e|5y|7O-?1u/i;F b&&b.1b==3x&&d=="34"&&!f.1d(a)?b+"4t":b},18:{1r:9(b,c){C.J((c||"").2M(/\\s+/),9(i,a){6(!C.18.2N(b.18,a))b.18+=(b.18?" ":"")+a})},23:9(b,c){b.18=c!=Q?C.2B(b.18.2M(/\\s+/),9(a){F!C.18.2N(c,a)}).5w(" "):""},2N:9(t,c){F C.4K(c,(t.18||t).3s().2M(/\\s+/))>-1}},1V:9(e,o,f){I(E i 17 o){e.S["2U"+i]=e.S[i];e.S[i]=o[i]}f.T(e,[]);I(E i 17 o)e.S[i]=e.S["2U"+i]},1h:9(e,p){6(p=="1u"||p=="24"){E b={},3p,3o,d=["7J","7G","7F","7B"];C.J(d,9(){b["7A"+7]=0;b["7x"+7+"7u"]=0});C.1V(e,b,9(){6(C(e).3y(\':4N\')){3p=e.7t;3o=e.7q}G{e=C(e.3B(O)).1F(":4e").5d("27").3L().1h({3V:"1C",3k:"7n",11:"2m",7h:"0",7e:"0"}).57(e.P)[0];E a=C.1h(e.P,"3k")||"3g";6(a=="3g")e.P.S.3k="76";3p=e.74;3o=e.71;6(a=="3g")e.P.S.3k="3g";e.P.3e(e)}});F p=="1u"?3p:3o}F C.34(e,p)},34:9(h,d,g){E i,1R=[],1V=[];9 2E(a){6(!C.N.1H)F M;E b=R.2L.3b(a,K);F!b||b.44("2E")==""}6(d=="1e"&&C.N.12){i=C.1j(h.S,"1e");F i==""?"1":i}6(d.2k(/3a/i))d=x;6(!g&&h.S[d])i=h.S[d];G 6(R.2L&&R.2L.3b){6(d.2k(/3a/i))d="3a";d=d.1v(/([A-Z])/g,"-$1").2D();E e=R.2L.3b(h,K);6(e&&!2E(h))i=e.44(d);G{I(E a=h;a&&2E(a);a=a.P)1R.42(a);I(a=0;a<1R.H;a++)6(2E(1R[a])){1V[a]=1R[a].S.11;1R[a].S.11="2m"}i=d=="11"&&1V[1R.H-1]!=K?"1T":R.2L.3b(h,K).44(d)||"";I(a=0;a<1V.H;a++)6(1V[a]!=K)1R[a].S.11=1V[a]}6(d=="1e"&&i=="")i="1"}G 6(h.41){E f=d.1v(/\\-(\\w)/g,9(m,c){F c.1I()});i=h.41[d]||h.41[f]}F i},3c:9(a,c){E r=[];c=c||R;C.J(a,9(i,b){6(!b)F;6(b.1b==3x)b=b.3s();6(1f b=="1E"){E s=C.2s(b).2D(),1m=c.6a("1m"),1P=[];E a=!s.U("<1Z")&&[1,"<2b>",""]||!s.U("<6L")&&[1,"<4V>",""]||s.2k(/^<(6I|1w|6H|6F|6D)/)&&[1,"<1A>",""]||!s.U("<3O")&&[2,"<1A><1w>",""]||(!s.U("<6A")||!s.U("<6y"))&&[3,"<1A><1w><3O>",""]||!s.U("<6x")&&[2,"<1A><1w><4T>",""]||C.N.12&&[1,"1m<1m>",""]||[0,"",""];1m.2W=a[1]+b+a[2];20(a[0]--)1m=1m.3Y;6(C.N.12){6(!s.U("<1A")&&s.U("<1w")<0)1P=1m.1k&&1m.1k.2Z;G 6(a[1]=="<1A>"&&s.U("<1w")<0)1P=1m.2Z;I(E n=1P.H-1;n>=0;--n)6(C.W(1P[n],"1w")&&!1P[n].2Z.H)1P[n].P.3e(1P[n]);6(/^\\s/.1d(b))1m.2p(c.60(b.2k(/^\\s*/)[0]),1m.1k)}b=C.2V(1m.2Z)}6(0===b.H&&(!C.W(b,"38")&&!C.W(b,"2b")))F;6(b[0]==Q||C.W(b,"38")||b.6u)r.Y(b);G r=C.29(r,b)});F r},1j:9(c,d,a){E e=C.3E(c)?{}:C.4q;6(d=="28"&&C.N.1H)c.P.3j;6(e[d]){6(a!=Q)c[e[d]]=a;F c[e[d]]}G 6(C.N.12&&d=="S")F C.1j(c.S,"6p",a);G 6(a==Q&&C.N.12&&C.W(c,"38")&&(d=="6n"||d=="6m"))F c.6k(d).5S;G 6(c.4y){6(a!=Q)c.6j(d,a);6(C.N.12&&/5R|32/.1d(d)&&!C.3E(c))F c.3F(d,2);F c.3F(d)}G{6(d=="1e"&&C.N.12){6(a!=Q){c.5y=1;c.1l=(c.1l||"").1v(/5T\\([^)]*\\)/,"")+(3m(a).3s()=="6d"?"":"5T(1e="+a*6c+")")}F c.1l?(3m(c.1l.2k(/1e=([^)]*)/)[1])/6c).3s():""}d=d.1v(/-([a-z])/8I,9(z,b){F b.1I()});6(a!=Q)c[d]=a;F c[d]}},2s:9(t){F(t||"").1v(/^\\s+|\\s+$/g,"")},2V:9(a){E r=[];6(1f a!="8H")I(E i=0,1M=a.H;i<1M;i++)r.Y(a[i]);G r=a.3S(0);F r},4K:9(b,a){I(E i=0,1M=a.H;i<1M;i++)6(a[i]==b)F i;F-1},29:9(a,b){6(C.N.12){I(E i=0;b[i];i++)6(b[i].1t!=8)a.Y(b[i])}G I(E i=0;b[i];i++)a.Y(b[i]);F a},4d:9(a){E r=[],4O=C.1q++;2g{I(E i=0,69=a.H;i<69;i++)6(4O!=a[i].1q){a[i].1q=4O;r.Y(a[i])}}2h(e){r=a}F r},1q:0,2B:9(b,a,c){6(1f a=="1E")a=2T("M||9(a,i){F "+a+"}");E d=[];I(E i=0,3P=b.H;i<3P;i++)6(!c&&a(b[i],i)||c&&!a(b[i],i))d.Y(b[i]);F d},3M:9(c,b){6(1f b=="1E")b=2T("M||9(a){F "+b+"}");E d=[];I(E i=0,3P=c.H;i<3P;i++){E a=b(c[i],i);6(a!==K&&a!=Q){6(a.1b!=1K)a=[a];d=d.8x(a)}}F d}});E u=8w.8u.2D();C.N={6b:(u.2k(/.+(?:8s|8q|8p|8o)[\\/: ]([\\d.]+)/)||[])[1],1H:/61/.1d(u),2t:/2t/.1d(u),12:/12/.1d(u)&&!/2t/.1d(u),3J:/3J/.1d(u)&&!/(8n|61)/.1d(u)};E x=C.N.12?"3I":"4G";C.14({8m:!C.N.12||R.8l=="8k",3I:C.N.12?"3I":"4G",4q:{"I":"8j","8i":"18","3a":x,4G:x,3I:x,2W:"2W",18:"18",2A:"2A",30:"30",27:"27",8h:"8g",28:"28",8f:"8e"}});C.J({5Y:"a.P",4C:"16.4C(a)",8c:"16.25(a,2,\'2a\')",8b:"16.25(a,2,\'4B\')",88:"16.4A(a.P.1k,a)",87:"16.4A(a.1k)"},9(i,n){C.15[i]=9(a){E b=C.3M(7,n);6(a&&1f a=="1E")b=C.2R(a,b);F 7.1O(C.4d(b))}});C.J({57:"3H",86:"5v",2p:"5u",85:"5t"},9(i,n){C.15[i]=9(){E a=1a;F 7.J(9(){I(E j=0,1M=a.H;j<1M;j++)C(a[j])[n](7)})}});C.J({5d:9(a){C.1j(7,a,"");7.84(a)},83:9(c){C.18.1r(7,c)},81:9(c){C.18.23(7,c)},80:9(c){C.18[C.18.2N(7,c)?"23":"1r"](7,c)},23:9(a){6(!a||C.1l(a,[7]).r.H)7.P.3e(7)},3K:9(){20(7.1k)7.3e(7.1k)}},9(i,n){C.15[i]=9(){F 7.J(n,1a)}});C.J(["5Q","5P","5M","5L"],9(i,n){C.15[n]=9(a,b){F 7.1l(":"+n+"("+a+")",b)}});C.J(["1u","24"],9(i,n){C.15[n]=9(h){F h==Q?(7.H?C.1h(7[0],n):K):7.1h(n,h.1b==3n?h:h+"4t")}});E A=C.N.1H&&5K(C.N.6b)<7Z?"(?:[\\\\w*2l-]|\\\\\\\\.)":"(?:[\\\\w\\7Y-\\7V*2l-]|\\\\\\\\.)",5I=1s 3C("^[/>]\\\\s*("+A+"+)"),5H=1s 3C("^("+A+"+)(#)("+A+"+)"),5G=1s 3C("^([#.]?)("+A+"*)");C.14({4w:{"":"m[2]==\'*\'||16.W(a,m[2])","#":"a.3F(\'2j\')==m[2]",":":{5P:"im[3]-0",25:"m[3]-0==i",5Q:"m[3]-0==i",2H:"i==0",2P:"i==r.H-1",5E:"i%2==0",5D:"i%2","2H-3z":"a.P.4L(\'*\')[0]==a","2P-3z":"16.25(a.P.3Y,1,\'4B\')==a","7U-3z":"!16.25(a.P.3Y,2,\'4B\')",5Y:"a.1k",3K:"!a.1k",5L:"(a.5Z||a.7T||\'\').U(m[3])>=0",4N:\'"1C"!=a.L&&16.1h(a,"11")!="1T"&&16.1h(a,"3V")!="1C"\',1C:\'"1C"==a.L||16.1h(a,"11")=="1T"||16.1h(a,"3V")=="1C"\',7R:"!a.30",30:"a.30",27:"a.27",28:"a.28||16.1j(a,\'28\')",2Q:"\'2Q\'==a.L",4e:"\'4e\'==a.L",3i:"\'3i\'==a.L",4v:"\'4v\'==a.L",5C:"\'5C\'==a.L",4u:"\'4u\'==a.L",5B:"\'5B\'==a.L",5A:"\'5A\'==a.L",1X:\'"1X"==a.L||16.W(a,"1X")\',39:"/39|2b|7P|1X/i.1d(a.W)",2N:"16.1F(m[3],a).H"},"[":"16.1F(m[2],a).H"},5x:[/^\\[ *(@)([\\w-]+) *([!*$^~=]*) *(\'?"?)(.*?)\\4 *\\]/,/^(\\[)\\s*(.*?(\\[.*?\\])?[^[]*?)\\s*\\]/,/^(:)([\\w-]+)\\("?\'?(.*?(\\(.*?\\))?[^(]*?)"?\'?\\)/,1s 3C("^([:.#]*)("+A+"+)")],2R:9(a,c,b){E d,1Y=[];20(a&&a!=d){d=a;E f=C.1l(a,c,b);a=f.t.1v(/^\\s*,\\s*/,"");1Y=b?c=f.r:C.29(1Y,f.r)}F 1Y},1F:9(t,l){6(1f t!="1E")F[t];6(l&&!l.1t)l=K;l=l||R;6(!t.U("//")){t=t.2K(2,t.H)}G 6(!t.U("/")&&!l.2I){l=l.3D;t=t.2K(1,t.H);6(t.U("/")>=1)t=t.2K(t.U("/"),t.H)}E d=[l],2q=[],2P;20(t&&2P!=t){E r=[];2P=t;t=C.2s(t).1v(/^\\/\\//,"");E k=M;E g=5I;E m=g.2d(t);6(m){E o=m[1].1I();I(E i=0;d[i];i++)I(E c=d[i].1k;c;c=c.2a)6(c.1t==1&&(o=="*"||c.W.1I()==o.1I()))r.Y(c);d=r;t=t.1v(g,"");6(t.U(" ")==0)5X;k=O}G{g=/^((\\/?\\.\\.)|([>\\/+~]))\\s*(\\w*)/i;6((m=g.2d(t))!=K){r=[];E o=m[4],1q=C.1q++;m=m[1];I(E j=0,2o=d.H;j<2o;j++)6(m.U("..")<0){E n=m=="~"||m=="+"?d[j].2a:d[j].1k;I(;n;n=n.2a)6(n.1t==1){6(m=="~"&&n.1q==1q)1J;6(!o||n.W.1I()==o.1I()){6(m=="~")n.1q=1q;r.Y(n)}6(m=="+")1J}}G r.Y(d[j].P);d=r;t=C.2s(t.1v(g,""));k=O}}6(t&&!k){6(!t.U(",")){6(l==d[0])d.4s();2q=C.29(2q,d);r=d=[l];t=" "+t.2K(1,t.H)}G{E h=5H;E m=h.2d(t);6(m){m=[0,m[2],m[3],m[1]]}G{h=5G;m=h.2d(t)}m[2]=m[2].1v(/\\\\/g,"");E f=d[d.H-1];6(m[1]=="#"&&f&&f.37&&!C.3E(f)){E p=f.37(m[2]);6((C.N.12||C.N.2t)&&p&&1f p.2j=="1E"&&p.2j!=m[2])p=C(\'[@2j="\'+m[2]+\'"]\',f)[0];d=r=p&&(!m[3]||C.W(p,m[3]))?[p]:[]}G{I(E i=0;d[i];i++){E a=m[1]!=""||m[0]==""?"*":m[2];6(a=="*"&&d[i].W.2D()=="4P")a="2O";r=C.29(r,d[i].4L(a))}6(m[1]==".")r=C.4r(r,m[2]);6(m[1]=="#"){E e=[];I(E i=0;r[i];i++)6(r[i].3F("2j")==m[2]){e=[r[i]];1J}r=e}d=r}t=t.1v(h,"")}}6(t){E b=C.1l(t,r);d=r=b.r;t=C.2s(b.t)}}6(t)d=[];6(d&&l==d[0])d.4s();2q=C.29(2q,d);F 2q},4r:9(r,m,a){m=" "+m+" ";E c=[];I(E i=0;r[i];i++){E b=(" "+r[i].18+" ").U(m)>=0;6(!a&&b||a&&!b)c.Y(r[i])}F c},1l:9(t,r,h){E d;20(t&&t!=d){d=t;E p=C.5x,m;I(E i=0;p[i];i++){m=p[i].2d(t);6(m){t=t.7N(m[0].H);m[2]=m[2].1v(/\\\\/g,"");1J}}6(!m)1J;6(m[1]==":"&&m[2]=="5l")r=C.1l(m[3],r,O).r;G 6(m[1]==".")r=C.4r(r,m[2],h);G 6(m[1]=="@"){E g=[],L=m[3];I(E i=0,2o=r.H;i<2o;i++){E a=r[i],z=a[C.4q[m[2]]||m[2]];6(z==K||/5R|32|28/.1d(m[2]))z=C.1j(a,m[2])||\'\';6((L==""&&!!z||L=="="&&z==m[5]||L=="!="&&z!=m[5]||L=="^="&&z&&!z.U(m[5])||L=="$="&&z.2K(z.H-m[5].H)==m[5]||(L=="*="||L=="~=")&&z.U(m[5])>=0)^h)g.Y(a)}r=g}G 6(m[1]==":"&&m[2]=="25-3z"){E e=C.1q++,g=[],1d=/(\\d*)n\\+?(\\d*)/.2d(m[3]=="5E"&&"2n"||m[3]=="5D"&&"2n+1"||!/\\D/.1d(m[3])&&"n+"+m[3]||m[3]),2H=(1d[1]||1)-0,d=1d[2]-0;I(E i=0,2o=r.H;i<2o;i++){E j=r[i],P=j.P;6(e!=P.1q){E c=1;I(E n=P.1k;n;n=n.2a)6(n.1t==1)n.4o=c++;P.1q=e}E b=M;6(2H==1){6(d==0||j.4o==d)b=O}G 6((j.4o+d)%2H==0)b=O;6(b^h)g.Y(j)}r=g}G{E f=C.4w[m[1]];6(1f f!="1E")f=C.4w[m[1]][m[2]];f=2T("M||9(a,i){F "+f+"}");r=C.2B(r,f,h)}}F{r:r,t:t}},4C:9(c){E b=[];E a=c.P;20(a&&a!=R){b.Y(a);a=a.P}F b},25:9(a,e,c,b){e=e||1;E d=0;I(;a;a=a[c])6(a.1t==1&&++d==e)1J;F a},4A:9(n,a){E r=[];I(;n;n=n.2a){6(n.1t==1&&(!a||n!=a))r.Y(n)}F r}});C.1c={1r:9(f,d,c,b){6(C.N.12&&f.3t!=Q)f=19;6(!c.22)c.22=7.22++;6(b!=Q){E e=c;c=9(){F e.T(7,1a)};c.V=b;c.22=e.22}6(!f.$1i)f.$1i={};6(!f.$1y)f.$1y=9(){E a;6(1f C=="Q"||C.1c.4n)F a;a=C.1c.1y.T(f,1a);F a};E g=f.$1i[d];6(!g){g=f.$1i[d]={};6(f.4m)f.4m(d,f.$1y,M);G f.7M("3r"+d,f.$1y)}g[c.22]=c;7.1D[d]=O},22:1,1D:{},23:9(c,b,a){E d=c.$1i,2c,45;6(d){6(b&&b.L){a=b.4l;b=b.L}6(!b){I(b 17 d)7.23(c,b)}G 6(d[b]){6(a)4k d[b][a.22];G I(a 17 c.$1i[b])4k d[b][a];I(2c 17 d[b])1J;6(!2c){6(c.4j)c.4j(b,c.$1y,M);G c.7L("3r"+b,c.$1y);2c=K;4k d[b]}}I(2c 17 d)1J;6(!2c)c.$1y=c.$1i=K}},1z:9(c,b,d){b=C.2V(b||[]);6(!d){6(7.1D[c])C("*").1r([19,R]).1z(c,b)}G{E a,2c,15=C.1g(d[c]||K);b.42(7.4i({L:c,1S:d}));6(C.1g(d.$1y))a=d.$1y.T(d,b);6(!15&&d["3r"+c]&&d["3r"+c].T(d,b)===M)a=M;6(15&&a!==M&&!(C.W(d,\'a\')&&c=="4h")){7.4n=O;d[c]()}7.4n=M}},1y:9(b){E a;b=C.1c.4i(b||19.1c||{});E c=7.$1i&&7.$1i[b.L],2e=1K.3v.3S.2S(1a,1);2e.42(b);I(E j 17 c){2e[0].4l=c[j];2e[0].V=c[j].V;6(c[j].T(7,2e)===M){b.2u();b.2X();a=M}}6(C.N.12)b.1S=b.2u=b.2X=b.4l=b.V=K;F a},4i:9(c){E a=c;c=C.14({},a);c.2u=9(){6(a.2u)a.2u();a.7I=M};c.2X=9(){6(a.2X)a.2X();a.7H=O};6(!c.1S&&c.5r)c.1S=c.5r;6(C.N.1H&&c.1S.1t==3)c.1S=a.1S.P;6(!c.4g&&c.4F)c.4g=c.4F==c.1S?c.7C:c.4F;6(c.5p==K&&c.66!=K){E e=R.3D,b=R.4z;c.5p=c.66+(e&&e.5o||b.5o||0);c.7z=c.7v+(e&&e.5m||b.5m||0)}6(!c.3Q&&(c.5k||c.5j))c.3Q=c.5k||c.5j;6(!c.5i&&c.5g)c.5i=c.5g;6(!c.3Q&&c.1X)c.3Q=(c.1X&1?1:(c.1X&2?3:(c.1X&4?2:0)));F c}};C.15.14({3l:9(c,a,b){F c=="5f"?7.5e(c,a,b):7.J(9(){C.1c.1r(7,c,b||a,b&&a)})},5e:9(d,b,c){F 7.J(9(){C.1c.1r(7,d,9(a){C(7).49(a);F(c||b).T(7,1a)},c&&b)})},49:9(a,b){F 7.J(9(){C.1c.23(7,a,b)})},1z:9(a,b){F 7.J(9(){C.1c.1z(a,b,7)})},1W:9(){E a=1a;F 7.4h(9(e){7.3T=0==7.3T?1:0;e.2u();F a[7.3T].T(7,[e])||M})},7p:9(f,g){9 3U(e){E p=e.4g;20(p&&p!=7)2g{p=p.P}2h(e){p=7};6(p==7)F M;F(e.L=="3W"?f:g).T(7,[e])}F 7.3W(3U).5b(3U)},1L:9(f){5a();6(C.36)f.T(R,[C]);G C.2C.Y(9(){F f.T(7,[C])});F 7}});C.14({36:M,2C:[],1L:9(){6(!C.36){C.36=O;6(C.2C){C.J(C.2C,9(){7.T(R)});C.2C=K}6(C.N.3J||C.N.2t)R.4j("59",C.1L,M);6(!19.7m.H)C(19).2f(9(){C("#4b").23()})}}});C.J(("7l,7k,2f,7j,7i,5f,4h,7g,"+"7f,7d,7c,3W,5b,7b,2b,"+"4u,7a,79,78,3f").2M(","),9(i,o){C.15[o]=9(f){F f?7.3l(o,f):7.1z(o)}});E w=M;9 5a(){6(w)F;w=O;6(C.N.3J||C.N.2t)R.4m("59",C.1L,M);G 6(C.N.12){R.75("<73"+"72 2j=4b 70=O "+"32=//:><\\/33>");E a=R.37("4b");6(a)a.6Z=9(){6(R.3d!="1x")F;C.1L()};a=K}G 6(C.N.1H)C.48=3t(9(){6(R.3d=="6Y"||R.3d=="1x"){47(C.48);C.48=K;C.1L()}},10);C.1c.1r(19,"2f",C.1L)}C.15.14({6X:9(c,b,a){7.2f(c,b,a,1)},2f:9(g,e,c,d){6(C.1g(g))F 7.3l("2f",g);c=c||9(){};E f="46";6(e)6(C.1g(e)){c=e;e=K}G{e=C.2O(e);f="55"}E h=7;C.31({1G:g,L:f,V:e,2F:d,1x:9(a,b){6(b=="1U"||!d&&b=="54")h.5W(a.43);4x(9(){h.J(c,[a.43,b,a])},13)}});F 7},6W:9(){F C.2O(7)},6V:9(){}});C.J("53,52,51,50,4Z,5h".2M(","),9(i,o){C.15[o]=9(f){F 7.3l(o,f)}});C.14({21:9(e,c,a,d,b){6(C.1g(c)){a=c;c=K}F C.31({L:"46",1G:e,V:c,1U:a,3G:d,2F:b})},6U:9(d,b,a,c){F C.21(d,b,a,c,1)},6T:9(b,a){F C.21(b,K,a,"33")},77:9(c,b,a){F C.21(c,b,a,"56")},6S:9(d,b,a,c){6(C.1g(b)){a=b;b={}}F C.31({L:"55",1G:d,V:b,1U:a,3G:c})},6R:9(a){C.3u.1Q=a},6Q:9(a){C.14(C.3u,a)},3u:{1D:O,L:"46",1Q:0,4Y:"6P/x-6O-38-6N",4X:O,2w:O,V:K},3h:{},31:9(s){s=C.14(O,s,C.14(O,{},C.3u,s));6(s.V){6(s.4X&&1f s.V!="1E")s.V=C.2O(s.V);6(s.L.2D()=="21"){s.1G+=(s.1G.U("?")>-1?"&":"?")+s.V;s.V=K}}6(s.1D&&!C.40++)C.1c.1z("53");E f=M;E h=19.4W?1s 4W("6M.6K"):1s 58();h.6J(s.L,s.1G,s.2w);6(s.V)h.4c("7r-7s",s.4Y);6(s.2F)h.4c("6G-3Z-6E",C.3h[s.1G]||"7w, 6C 7y 6B 4J:4J:4J 6z");h.4c("X-7D-7E","58");6(s.4U)s.4U(h);6(s.1D)C.1c.1z("5h",[h,s]);E g=9(d){6(!f&&h&&(h.3d==4||d=="1Q")){f=O;6(i){47(i);i=K}E c=d=="1Q"&&"1Q"||!C.5n(h)&&"3f"||s.2F&&C.5s(h,s.1G)&&"54"||"1U";6(c=="1U"){2g{E a=C.5q(h,s.3G)}2h(e){c="4I"}}6(c=="1U"){E b;2g{b=h.4f("4S-3Z")}2h(e){}6(s.2F&&b)C.3h[s.1G]=b;6(s.1U)s.1U(a,c);6(s.1D)C.1c.1z("4Z",[h,s])}G C.3X(s,h,c);6(s.1D)C.1c.1z("51",[h,s]);6(s.1D&&!--C.40)C.1c.1z("52");6(s.1x)s.1x(h,c);6(s.2w)h=K}};6(s.2w){E i=3t(g,13);6(s.1Q>0)4x(9(){6(h){h.6w();6(!f)g("1Q")}},s.1Q)}2g{h.6v(s.V)}2h(e){C.3X(s,h,K,e)}6(!s.2w)g();F h},3X:9(s,a,b,e){6(s.3f)s.3f(a,b,e);6(s.1D)C.1c.1z("50",[a,s,e])},40:0,5n:9(r){2g{F!r.26&&6t.6r=="4v:"||(r.26>=4R&&r.26<6q)||r.26==5z||C.N.1H&&r.26==Q}2h(e){}F M},5s:9(a,c){2g{E b=a.4f("4S-3Z");F a.26==5z||b==C.3h[c]||C.N.1H&&a.26==Q}2h(e){}F M},5q:9(r,a){E b=r.4f("6o-L");E c=a=="5F"||!a&&b&&b.U("5F")>=0;V=c?r.7W:r.43;6(c&&V.3D.4y=="4I")7X"4I";6(a=="33")C.4E(V);6(a=="56")V=2T("("+V+")");F V},2O:9(a){E s=[];6(a.1b==1K||a.3w)C.J(a,9(){s.Y(2y(7.6l)+"="+2y(7.2A))});G I(E j 17 a)6(a[j]&&a[j].1b==1K)C.J(a[j],9(){s.Y(2y(j)+"="+2y(7))});G s.Y(2y(j)+"="+2y(a[j]));F s.5w("&")}});C.15.14({1o:9(b,a){F b?7.1B({1u:"1o",24:"1o",1e:"1o"},b,a):7.1l(":1C").J(9(){7.S.11=7.2r?7.2r:"";6(C.1h(7,"11")=="1T")7.S.11="2m"}).3L()},1p:9(b,a){F b?7.1B({1u:"1p",24:"1p",1e:"1p"},b,a):7.1l(":4N").J(9(){7.2r=7.2r||C.1h(7,"11");6(7.2r=="1T")7.2r="2m";7.S.11="1T"}).3L()},5O:C.15.1W,1W:9(a,b){F C.1g(a)&&C.1g(b)?7.5O(a,b):a?7.1B({1u:"1W",24:"1W",1e:"1W"},a,b):7.J(9(){C(7)[C(7).3y(":1C")?"1o":"1p"]()})},6i:9(b,a){F 7.1B({1u:"1o"},b,a)},6h:9(b,a){F 7.1B({1u:"1p"},b,a)},6g:9(b,a){F 7.1B({1u:"1W"},b,a)},6f:9(b,a){F 7.1B({1e:"1o"},b,a)},89:9(b,a){F 7.1B({1e:"1p"},b,a)},6e:9(c,a,b){F 7.1B({1e:a},c,b)},1B:9(d,h,f,g){F 7.1n(9(){E c=C(7).3y(":1C"),1Z=C.5V(h,f,g),5U=7;I(E p 17 d){6(d[p]=="1p"&&c||d[p]=="1o"&&!c)F C.1g(1Z.1x)&&1Z.1x.T(7);6(p=="1u"||p=="24"){1Z.11=C.1h(7,"11");1Z.2z=7.S.2z}}6(1Z.2z!=K)7.S.2z="1C";7.2v=C.14({},d);C.J(d,9(a,b){E e=1s C.2Y(5U,1Z,a);6(b.1b==3x)e.3R(e.1Y()||0,b);G e[b=="1W"?c?"1o":"1p":b](d)});F O})},1n:9(a,b){6(!b){b=a;a="2Y"}F 7.J(9(){6(!7.1n)7.1n={};6(!7.1n[a])7.1n[a]=[];7.1n[a].Y(b);6(7.1n[a].H==1)b.T(7)})}});C.14({5V:9(b,a,c){E d=b&&b.1b==8G?b:{1x:c||!c&&a||C.1g(b)&&b,1N:b,35:c&&a||a&&a.1b!=8F&&a};d.1N=(d.1N&&d.1N.1b==3x?d.1N:{8D:8C,8B:4R}[d.1N])||8A;d.2U=d.1x;d.1x=9(){C.68(7,"2Y");6(C.1g(d.2U))d.2U.T(7)};F d},35:{62:9(p,n,b,a){F b+a*p},4H:9(p,n,b,a){F((-67.8z(p*67.8y)/2)+0.5)*a+b}},1n:{},68:9(b,a){a=a||"2Y";6(b.1n&&b.1n[a]){b.1n[a].4s();E f=b.1n[a][0];6(f)f.T(b)}},3N:[],2Y:9(f,e,g){E z=7;E y=f.S;z.a=9(){6(e.3q)e.3q.T(f,[z.2x]);6(g=="1e")C.1j(y,"1e",z.2x);G{y[g]=5K(z.2x)+"4t";6(g=="1u"||g=="24")y.11="2m"}};z.65=9(){F 3m(C.1h(f,g))};z.1Y=9(){E r=3m(C.34(f,g));F r&&r>-8v?r:z.65()};z.3R=9(c,b){z.4M=(1s 64()).63();z.2x=c;z.a();C.3N.Y(9(){F z.3q(c,b)});6(C.3N.H==1){E d=3t(9(){E a=C.3N;I(E i=0;ie.1N+z.4M){z.2x=c;z.a();6(f.2v)f.2v[g]=O;E b=O;I(E i 17 f.2v)6(f.2v[i]!==O)b=M;6(b){6(e.11!=K){y.2z=e.2z;y.11=e.11;6(C.1h(f,"11")=="1T")y.11="2m"}6(e.1p)y.11="1T";6(e.1p||e.1o)I(E p 17 f.2v)C.1j(y,p,f.2i[p])}6(b&&C.1g(e.1x))e.1x.T(f);F M}G{E n=t-7.4M;E p=n/e.1N;z.2x=C.35[e.35||(C.35.4H?"4H":"62")](p,n,a,(c-a),e.1N);z.a()}F O}}})})();',62,541,'||||||if|this||function|||||||||||||||||||||||||||||||var|return|else|length|for|each|null|type|false|browser|true|parentNode|undefined|document|style|apply|indexOf|data|nodeName||push|||display|msie||extend|fn|jQuery|in|className|window|arguments|constructor|event|test|opacity|typeof|isFunction|css|events|attr|firstChild|filter|div|queue|show|hide|mergeNum|add|new|nodeType|height|replace|tbody|complete|handle|trigger|table|animate|hidden|global|string|find|url|safari|toUpperCase|break|Array|ready|al|duration|pushStack|tb|timeout|stack|target|none|success|swap|toggle|button|cur|opt|while|get|guid|remove|width|nth|status|checked|selected|merge|nextSibling|select|ret|exec|args|load|try|catch|orig|id|match|_|block||rl|insertBefore|done|oldblock|trim|opera|preventDefault|curAnim|async|now|encodeURIComponent|overflow|value|grep|readyList|toLowerCase|color|ifModified|val|first|ownerDocument|domManip|substr|defaultView|split|has|param|last|text|multiFilter|call|eval|old|makeArray|innerHTML|stopPropagation|fx|childNodes|disabled|ajax|src|script|curCSS|easing|isReady|getElementById|form|input|float|getComputedStyle|clean|readyState|removeChild|error|static|lastModified|checkbox|selectedIndex|position|bind|parseFloat|String|oWidth|oHeight|step|on|toString|setInterval|ajaxSettings|prototype|jquery|Number|is|child|ol|cloneNode|RegExp|documentElement|isXMLDoc|getAttribute|dataType|append|styleFloat|mozilla|empty|end|map|timers|tr|el|which|custom|slice|lastToggle|handleHover|visibility|mouseover|handleError|lastChild|Modified|active|currentStyle|unshift|responseText|getPropertyValue|index|GET|clearInterval|safariTimer|unbind|init|__ie_init|setRequestHeader|unique|radio|getResponseHeader|relatedTarget|click|fix|removeEventListener|delete|handler|addEventListener|triggered|nodeIndex|appendChild|props|classFilter|shift|px|submit|file|expr|setTimeout|tagName|body|sibling|previousSibling|parents|deep|globalEval|fromElement|cssFloat|swing|parsererror|00|inArray|getElementsByTagName|startTime|visible|num|object|prop|200|Last|colgroup|beforeSend|fieldset|ActiveXObject|processData|contentType|ajaxSuccess|ajaxError|ajaxComplete|ajaxStop|ajaxStart|notmodified|POST|json|appendTo|XMLHttpRequest|DOMContentLoaded|bindReady|mouseout|prevObject|removeAttr|one|unload|ctrlKey|ajaxSend|metaKey|keyCode|charCode|not|scrollTop|httpSuccess|scrollLeft|pageX|httpData|srcElement|httpNotModified|after|before|prepend|join|parse|zoom|304|reset|image|password|odd|even|xml|quickClass|quickID|quickChild|setArray|parseInt|contains|gt|execScript|_toggle|lt|eq|href|nodeValue|alpha|self|speed|html|continue|parent|textContent|createTextNode|webkit|linear|getTime|Date|max|clientX|Math|dequeue|fl|createElement|version|100|NaN|fadeTo|fadeIn|slideToggle|slideUp|slideDown|setAttribute|getAttributeNode|name|method|action|content|cssText|300|protocol|FORM|location|options|send|abort|col|th|GMT|td|1970|01|cap|Since|colg|If|tfoot|thead|open|XMLHTTP|leg|Microsoft|urlencoded|www|application|ajaxSetup|ajaxTimeout|post|getScript|getIfModified|evalScripts|serialize|loadIfModified|loaded|onreadystatechange|defer|clientWidth|ipt|scr|clientHeight|write|relative|getJSON|keyup|keypress|keydown|change|mousemove|mouseup|left|mousedown|dblclick|right|scroll|resize|focus|blur|frames|absolute|clone|hover|offsetWidth|Content|Type|offsetHeight|Width|clientY|Thu|border|Jan|pageY|padding|Left|toElement|Requested|With|Right|Bottom|cancelBubble|returnValue|Top|size|detachEvent|attachEvent|substring|line|textarea|weight|enabled|font|innerText|only|uFFFF|responseXML|throw|u0128|417|toggleClass|removeClass|wrap|addClass|removeAttribute|insertAfter|prependTo|children|siblings|fadeOut|noConflict|prev|next|Boolean|maxLength|maxlength|readOnly|readonly|class|htmlFor|CSS1Compat|compatMode|boxModel|compatible|ie|ra|it|1px|rv|splice|userAgent|10000|navigator|concat|PI|cos|400|fast|600|slow|reverse|Function|Object|array|ig'.split('|'),0,{})); +jQuery.noConflict(); + diff --git a/wp-includes/js/prototype.js b/wp-includes/js/prototype.js index 6253917..979f3b3 100644 --- a/wp-includes/js/prototype.js +++ b/wp-includes/js/prototype.js @@ -1,19 +1,33 @@ -/* Prototype JavaScript framework, version 1.5.0 +/* Prototype JavaScript framework, version 1.5.1.1 * (c) 2005-2007 Sam Stephenson * * Prototype is freely distributable under the terms of an MIT-style license. - * For details, see the Prototype web site: http://prototype.conio.net/ + * For details, see the Prototype web site: http://www.prototypejs.org/ * /*--------------------------------------------------------------------------*/ var Prototype = { - Version: '1.5.0', + Version: '1.5.1.1', + + Browser: { + IE: !!(window.attachEvent && !window.opera), + Opera: !!window.opera, + WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1, + Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1 + }, + BrowserFeatures: { - XPath: !!document.evaluate + XPath: !!document.evaluate, + ElementExtensions: !!window.HTMLElement, + SpecificElementExtensions: + (document.createElement('div').__proto__ !== + document.createElement('form').__proto__) }, - ScriptFragment: '(?:)((\n|\r|.)*?)(?:<\/script>)', - emptyFunction: function() {}, + ScriptFragment: ']*>([\\S\\s]*?)<\/script>', + JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/, + + emptyFunction: function() { }, K: function(x) { return x } } @@ -46,6 +60,26 @@ Object.extend(Object, { } }, + toJSON: function(object) { + var type = typeof object; + switch(type) { + case 'undefined': + case 'function': + case 'unknown': return; + case 'boolean': return object.toString(); + } + if (object === null) return 'null'; + if (object.toJSON) return object.toJSON(); + if (object.ownerDocument === document) return; + var results = []; + for (var property in object) { + var value = Object.toJSON(object[property]); + if (value !== undefined) + results.push(property.toJSON() + ': ' + value); + } + return '{' + results.join(', ') + '}'; + }, + keys: function(object) { var keys = []; for (var property in object) @@ -75,15 +109,13 @@ Function.prototype.bind = function() { Function.prototype.bindAsEventListener = function(object) { var __method = this, args = $A(arguments), object = args.shift(); return function(event) { - return __method.apply(object, [( event || window.event)].concat(args).concat($A(arguments))); + return __method.apply(object, [event || window.event].concat(args)); } } Object.extend(Number.prototype, { toColorPart: function() { - var digits = this.toString(16); - if (this < 16) return '0' + digits; - return digits; + return this.toPaddedString(2, 16); }, succ: function() { @@ -93,9 +125,27 @@ Object.extend(Number.prototype, { times: function(iterator) { $R(0, this, true).each(iterator); return this; + }, + + toPaddedString: function(length, radix) { + var string = this.toString(radix || 10); + return '0'.times(length - string.length) + string; + }, + + toJSON: function() { + return isFinite(this) ? this.toString() : 'null'; } }); +Date.prototype.toJSON = function() { + return '"' + this.getFullYear() + '-' + + (this.getMonth() + 1).toPaddedString(2) + '-' + + this.getDate().toPaddedString(2) + 'T' + + this.getHours().toPaddedString(2) + ':' + + this.getMinutes().toPaddedString(2) + ':' + + this.getSeconds().toPaddedString(2) + '"'; +}; + var Try = { these: function() { var returnValue; @@ -145,9 +195,19 @@ PeriodicalExecuter.prototype = { } } } -String.interpret = function(value){ - return value == null ? '' : String(value); -} +Object.extend(String, { + interpret: function(value) { + return value == null ? '' : String(value); + }, + specialChar: { + '\b': '\\b', + '\t': '\\t', + '\n': '\\n', + '\f': '\\f', + '\r': '\\r', + '\\': '\\\\' + } +}); Object.extend(String.prototype, { gsub: function(pattern, replacement) { @@ -213,17 +273,16 @@ Object.extend(String.prototype, { }, escapeHTML: function() { - var div = document.createElement('div'); - var text = document.createTextNode(this); - div.appendChild(text); - return div.innerHTML; + var self = arguments.callee; + self.text.data = this; + return self.div.innerHTML; }, unescapeHTML: function() { var div = document.createElement('div'); div.innerHTML = this.stripTags(); return div.childNodes[0] ? (div.childNodes.length > 1 ? - $A(div.childNodes).inject('',function(memo,node){ return memo+node.nodeValue }) : + $A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) : div.childNodes[0].nodeValue) : ''; }, @@ -233,15 +292,15 @@ Object.extend(String.prototype, { return match[1].split(separator || '&').inject({}, function(hash, pair) { if ((pair = pair.split('='))[0]) { - var name = decodeURIComponent(pair[0]); - var value = pair[1] ? decodeURIComponent(pair[1]) : undefined; + var key = decodeURIComponent(pair.shift()); + var value = pair.length > 1 ? pair.join('=') : pair[0]; + if (value != undefined) value = decodeURIComponent(value); - if (hash[name] !== undefined) { - if (hash[name].constructor != Array) - hash[name] = [hash[name]]; - if (value) hash[name].push(value); + if (key in hash) { + if (hash[key].constructor != Array) hash[key] = [hash[key]]; + hash[key].push(value); } - else hash[name] = value; + else hash[key] = value; } return hash; }); @@ -256,6 +315,12 @@ Object.extend(String.prototype, { String.fromCharCode(this.charCodeAt(this.length - 1) + 1); }, + times: function(count) { + var result = ''; + for (var i = 0; i < count; i++) result += this; + return result; + }, + camelize: function() { var parts = this.split('-'), len = parts.length; if (len == 1) return parts[0]; @@ -270,7 +335,7 @@ Object.extend(String.prototype, { return camelized; }, - capitalize: function(){ + capitalize: function() { return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); }, @@ -283,11 +348,63 @@ Object.extend(String.prototype, { }, inspect: function(useDoubleQuotes) { - var escapedString = this.replace(/\\/g, '\\\\'); - if (useDoubleQuotes) - return '"' + escapedString.replace(/"/g, '\\"') + '"'; - else - return "'" + escapedString.replace(/'/g, '\\\'') + "'"; + var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) { + var character = String.specialChar[match[0]]; + return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16); + }); + if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"'; + return "'" + escapedString.replace(/'/g, '\\\'') + "'"; + }, + + toJSON: function() { + return this.inspect(true); + }, + + unfilterJSON: function(filter) { + return this.sub(filter || Prototype.JSONFilter, '#{1}'); + }, + + isJSON: function() { + var str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''); + return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str); + }, + + evalJSON: function(sanitize) { + var json = this.unfilterJSON(); + try { + if (!sanitize || json.isJSON()) return eval('(' + json + ')'); + } catch (e) { } + throw new SyntaxError('Badly formed JSON string: ' + this.inspect()); + }, + + include: function(pattern) { + return this.indexOf(pattern) > -1; + }, + + startsWith: function(pattern) { + return this.indexOf(pattern) === 0; + }, + + endsWith: function(pattern) { + var d = this.length - pattern.length; + return d >= 0 && this.lastIndexOf(pattern) === d; + }, + + empty: function() { + return this == ''; + }, + + blank: function() { + return /^\s*$/.test(this); + } +}); + +if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, { + escapeHTML: function() { + return this.replace(/&/g,'&').replace(//g,'>'); + }, + unescapeHTML: function() { + return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); } }); @@ -299,6 +416,13 @@ String.prototype.gsub.prepareReplacement = function(replacement) { String.prototype.parseQuery = String.prototype.toQueryParams; +Object.extend(String.prototype.escapeHTML, { + div: document.createElement('div'), + text: document.createTextNode('') +}); + +with (String.prototype.escapeHTML) div.appendChild(text); + var Template = Class.create(); Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/; Template.prototype = { @@ -316,19 +440,14 @@ Template.prototype = { } } -var $break = new Object(); -var $continue = new Object(); +var $break = {}, $continue = new Error('"throw $continue" is deprecated, use "return" instead'); var Enumerable = { each: function(iterator) { var index = 0; try { this._each(function(value) { - try { - iterator(value, index++); - } catch (e) { - if (e != $continue) throw e; - } + iterator(value, index++); }); } catch (e) { if (e != $break) throw e; @@ -530,6 +649,21 @@ var $A = Array.from = function(iterable) { } } +if (Prototype.Browser.WebKit) { + $A = Array.from = function(iterable) { + if (!iterable) return []; + if (!(typeof iterable == 'function' && iterable == '[object NodeList]') && + iterable.toArray) { + return iterable.toArray(); + } else { + var results = []; + for (var i = 0, length = iterable.length; i < length; i++) + results.push(iterable[i]); + return results; + } + } +} + Object.extend(Array.prototype, Enumerable); if (!Array.prototype._reverse) @@ -588,9 +722,11 @@ Object.extend(Array.prototype, { return this.length > 1 ? this : this[0]; }, - uniq: function() { - return this.inject([], function(array, value) { - return array.include(value) ? array : array.concat([value]); + uniq: function(sorted) { + return this.inject([], function(array, value, index) { + if (0 == index || (sorted ? array.last() != value : !array.include(value))) + array.push(value); + return array; }); }, @@ -604,23 +740,32 @@ Object.extend(Array.prototype, { inspect: function() { return '[' + this.map(Object.inspect).join(', ') + ']'; + }, + + toJSON: function() { + var results = []; + this.each(function(object) { + var value = Object.toJSON(object); + if (value !== undefined) results.push(value); + }); + return '[' + results.join(', ') + ']'; } }); Array.prototype.toArray = Array.prototype.clone; -function $w(string){ +function $w(string) { string = string.strip(); return string ? string.split(/\s+/) : []; } -if(window.opera){ - Array.prototype.concat = function(){ +if (Prototype.Browser.Opera){ + Array.prototype.concat = function() { var array = []; - for(var i = 0, length = this.length; i < length; i++) array.push(this[i]); - for(var i = 0, length = arguments.length; i < length; i++) { - if(arguments[i].constructor == Array) { - for(var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++) + for (var i = 0, length = this.length; i < length; i++) array.push(this[i]); + for (var i = 0, length = arguments.length; i < length; i++) { + if (arguments[i].constructor == Array) { + for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++) array.push(arguments[i][j]); } else { array.push(arguments[i]); @@ -629,37 +774,48 @@ if(window.opera){ return array; } } -var Hash = function(obj) { - Object.extend(this, obj || {}); +var Hash = function(object) { + if (object instanceof Hash) this.merge(object); + else Object.extend(this, object || {}); }; Object.extend(Hash, { toQueryString: function(obj) { var parts = []; + parts.add = arguments.callee.addPair; - this.prototype._each.call(obj, function(pair) { + this.prototype._each.call(obj, function(pair) { if (!pair.key) return; + var value = pair.value; - if (pair.value && pair.value.constructor == Array) { - var values = pair.value.compact(); - if (values.length < 2) pair.value = values.reduce(); - else { - key = encodeURIComponent(pair.key); - values.each(function(value) { - value = value != undefined ? encodeURIComponent(value) : ''; - parts.push(key + '=' + encodeURIComponent(value)); - }); - return; - } + if (value && typeof value == 'object') { + if (value.constructor == Array) value.each(function(value) { + parts.add(pair.key, value); + }); + return; } - if (pair.value == undefined) pair[1] = ''; - parts.push(pair.map(encodeURIComponent).join('=')); - }); + parts.add(pair.key, value); + }); return parts.join('&'); + }, + + toJSON: function(object) { + var results = []; + this.prototype._each.call(object, function(pair) { + var value = Object.toJSON(pair.value); + if (value !== undefined) results.push(pair.key.toJSON() + ': ' + value); + }); + return '{' + results.join(', ') + '}'; } }); +Hash.toQueryString.addPair = function(key, value, prefix) { + key = encodeURIComponent(key); + if (value === undefined) this.push(key); + else this.push(key + '=' + (value == null ? '' : encodeURIComponent(value))); +} + Object.extend(Hash.prototype, Enumerable); Object.extend(Hash.prototype, { _each: function(iterator) { @@ -713,13 +869,36 @@ Object.extend(Hash.prototype, { return '#'; + }, + + toJSON: function() { + return Hash.toJSON(this); } }); function $H(object) { - if (object && object.constructor == Hash) return object; + if (object instanceof Hash) return object; return new Hash(object); }; + +// Safari iterates over shadowed properties +if (function() { + var i = 0, Test = function(value) { this.key = value }; + Test.prototype.key = 'foo'; + for (var property in new Test('bar')) i++; + return i > 1; +}()) Hash.prototype._each = function(iterator) { + var cache = []; + for (var key in this) { + var value = this[key]; + if ((value && value == Hash.prototype[key]) || cache.include(key)) continue; + cache.push(key); + var pair = [key, value]; + pair.key = key; + pair.value = value; + iterator(pair); + } +}; ObjectRange = Class.create(); Object.extend(ObjectRange.prototype, Enumerable); Object.extend(ObjectRange.prototype, { @@ -834,7 +1013,7 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), { request: function(url) { this.url = url; this.method = this.options.method; - var params = this.options.parameters; + var params = Object.clone(this.options.parameters); if (!['get', 'post'].include(this.method)) { // simulate other verbs over post @@ -842,14 +1021,18 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), { this.method = 'post'; } - params = Hash.toQueryString(params); - if (params && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) params += '&_=' + this.parameters = params; - // when GET, append parameters to URL - if (this.method == 'get' && params) - this.url += (this.url.indexOf('?') > -1 ? '&' : '?') + params; + if (params = Hash.toQueryString(params)) { + // when GET, append parameters to URL + if (this.method == 'get') + this.url += (this.url.include('?') ? '&' : '?') + params; + else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) + params += '&_='; + } try { + if (this.options.onCreate) this.options.onCreate(this.transport); Ajax.Responders.dispatch('onCreate', this, this.transport); this.transport.open(this.method.toUpperCase(), this.url, @@ -861,9 +1044,8 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), { this.transport.onreadystatechange = this.onStateChange.bind(this); this.setRequestHeaders(); - var body = this.method == 'post' ? (this.options.postBody || params) : null; - - this.transport.send(body); + this.body = this.method == 'post' ? (this.options.postBody || params) : null; + this.transport.send(this.body); /* Force Firefox to handle ready state 4 for synchronous requests */ if (!this.options.asynchronous && this.transport.overrideMimeType) @@ -935,7 +1117,8 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), { this.dispatchException(e); } - if ((this.getHeader('Content-type') || 'text/javascript').strip(). + var contentType = this.getHeader('Content-type'); + if (contentType && contentType.strip(). match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i)) this.evalResponse(); } @@ -962,13 +1145,13 @@ Ajax.Request.prototype = Object.extend(new Ajax.Base(), { evalJSON: function() { try { var json = this.getHeader('X-JSON'); - return json ? eval('(' + json + ')') : null; + return json ? json.evalJSON() : null; } catch (e) { return null } }, evalResponse: function() { try { - return eval(this.transport.responseText); + return eval((this.transport.responseText || '').unfilterJSON()); } catch (e) { this.dispatchException(e); } @@ -1083,50 +1266,54 @@ if (Prototype.BrowserFeatures.XPath) { results.push(query.snapshotItem(i)); return results; }; -} -document.getElementsByClassName = function(className, parentElement) { - if (Prototype.BrowserFeatures.XPath) { + document.getElementsByClassName = function(className, parentElement) { var q = ".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]"; return document._getElementsByXPath(q, parentElement); - } else { - var children = ($(parentElement) || document.body).getElementsByTagName('*'); - var elements = [], child; - for (var i = 0, length = children.length; i < length; i++) { - child = children[i]; - if (Element.hasClassName(child, className)) - elements.push(Element.extend(child)); - } - return elements; } + +} else document.getElementsByClassName = function(className, parentElement) { + var children = ($(parentElement) || document.body).getElementsByTagName('*'); + var elements = [], child, pattern = new RegExp("(^|\\s)" + className + "(\\s|$)"); + for (var i = 0, length = children.length; i < length; i++) { + child = children[i]; + var elementClassName = child.className; + if (elementClassName.length == 0) continue; + if (elementClassName == className || elementClassName.match(pattern)) + elements.push(Element.extend(child)); + } + return elements; }; /*--------------------------------------------------------------------------*/ -if (!window.Element) - var Element = new Object(); +if (!window.Element) var Element = {}; Element.extend = function(element) { - if (!element || _nativeExtensions || element.nodeType == 3) return element; - - if (!element._extended && element.tagName && element != window) { - var methods = Object.clone(Element.Methods), cache = Element.extend.cache; + var F = Prototype.BrowserFeatures; + if (!element || !element.tagName || element.nodeType == 3 || + element._extended || F.SpecificElementExtensions || element == window) + return element; - if (element.tagName == 'FORM') - Object.extend(methods, Form.Methods); - if (['INPUT', 'TEXTAREA', 'SELECT'].include(element.tagName)) - Object.extend(methods, Form.Element.Methods); + var methods = {}, tagName = element.tagName, cache = Element.extend.cache, + T = Element.Methods.ByTag; + // extend methods for all tags (Safari doesn't need this) + if (!F.ElementExtensions) { + Object.extend(methods, Element.Methods), Object.extend(methods, Element.Methods.Simulated); + } - for (var property in methods) { - var value = methods[property]; - if (typeof value == 'function' && !(property in element)) - element[property] = cache.findOrStore(value); - } + // extend methods for specific tags + if (T[tagName]) Object.extend(methods, T[tagName]); + + for (var property in methods) { + var value = methods[property]; + if (typeof value == 'function' && !(property in element)) + element[property] = cache.findOrStore(value); } - element._extended = true; + element._extended = Prototype.emptyFunction; return element; }; @@ -1212,7 +1399,13 @@ Element.Methods = { }, descendants: function(element) { - return $A($(element).getElementsByTagName('*')); + return $A($(element).getElementsByTagName('*')).each(Element.extend); + }, + + firstDescendant: function(element) { + element = $(element).firstChild; + while (element && element.nodeType != 1) element = element.nextSibling; + return $(element); }, immediateDescendants: function(element) { @@ -1242,19 +1435,35 @@ Element.Methods = { }, up: function(element, expression, index) { - return Selector.findElement($(element).ancestors(), expression, index); + element = $(element); + if (arguments.length == 1) return $(element.parentNode); + var ancestors = element.ancestors(); + return expression ? Selector.findElement(ancestors, expression, index) : + ancestors[index || 0]; }, down: function(element, expression, index) { - return Selector.findElement($(element).descendants(), expression, index); + element = $(element); + if (arguments.length == 1) return element.firstDescendant(); + var descendants = element.descendants(); + return expression ? Selector.findElement(descendants, expression, index) : + descendants[index || 0]; }, previous: function(element, expression, index) { - return Selector.findElement($(element).previousSiblings(), expression, index); + element = $(element); + if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element)); + var previousSiblings = element.previousSiblings(); + return expression ? Selector.findElement(previousSiblings, expression, index) : + previousSiblings[index || 0]; }, next: function(element, expression, index) { - return Selector.findElement($(element).nextSiblings(), expression, index); + element = $(element); + if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element)); + var nextSiblings = element.nextSiblings(); + return expression ? Selector.findElement(nextSiblings, expression, index) : + nextSiblings[index || 0]; }, getElementsBySelector: function() { @@ -1268,12 +1477,13 @@ Element.Methods = { readAttribute: function(element, name) { element = $(element); - if (document.all && !window.opera) { + if (Prototype.Browser.IE) { + if (!element.attributes) return null; var t = Element._attributeTranslations; if (t.values[name]) return t.values[name](element, name); if (t.names[name]) name = t.names[name]; var attribute = element.attributes[name]; - if(attribute) return attribute.nodeValue; + return attribute ? attribute.nodeValue : null; } return element.getAttribute(name); }, @@ -1342,7 +1552,7 @@ Element.Methods = { }, empty: function(element) { - return $(element).innerHTML.match(/^\s*$/); + return $(element).innerHTML.blank(); }, descendantOf: function(element, ancestor) { @@ -1361,55 +1571,38 @@ Element.Methods = { getStyle: function(element, style) { element = $(element); - if (['float','cssFloat'].include(style)) - style = (typeof element.style.styleFloat != 'undefined' ? 'styleFloat' : 'cssFloat'); - style = style.camelize(); + style = style == 'float' ? 'cssFloat' : style.camelize(); var value = element.style[style]; if (!value) { - if (document.defaultView && document.defaultView.getComputedStyle) { - var css = document.defaultView.getComputedStyle(element, null); - value = css ? css[style] : null; - } else if (element.currentStyle) { - value = element.currentStyle[style]; - } + var css = document.defaultView.getComputedStyle(element, null); + value = css ? css[style] : null; } + if (style == 'opacity') return value ? parseFloat(value) : 1.0; + return value == 'auto' ? null : value; + }, - if((value == 'auto') && ['width','height'].include(style) && (element.getStyle('display') != 'none')) - value = element['offset'+style.capitalize()] + 'px'; + getOpacity: function(element) { + return $(element).getStyle('opacity'); + }, - if (window.opera && ['left', 'top', 'right', 'bottom'].include(style)) - if (Element.getStyle(element, 'position') == 'static') value = 'auto'; - if(style == 'opacity') { - if(value) return parseFloat(value); - if(value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/)) - if(value[1]) return parseFloat(value[1]) / 100; - return 1.0; - } - return value == 'auto' ? null : value; + setStyle: function(element, styles, camelized) { + element = $(element); + var elementStyle = element.style; + + for (var property in styles) + if (property == 'opacity') element.setOpacity(styles[property]) + else + elementStyle[(property == 'float' || property == 'cssFloat') ? + (elementStyle.styleFloat === undefined ? 'cssFloat' : 'styleFloat') : + (camelized ? property : property.camelize())] = styles[property]; + + return element; }, - setStyle: function(element, style) { + setOpacity: function(element, value) { element = $(element); - for (var name in style) { - var value = style[name]; - if(name == 'opacity') { - if (value == 1) { - value = (/Gecko/.test(navigator.userAgent) && - !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 0.999999 : 1.0; - if(/MSIE/.test(navigator.userAgent) && !window.opera) - element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,''); - } else if(value == '') { - if(/MSIE/.test(navigator.userAgent) && !window.opera) - element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,''); - } else { - if(value < 0.00001) value = 0; - if(/MSIE/.test(navigator.userAgent) && !window.opera) - element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'') + - 'alpha(opacity='+value*100+')'; - } - } else if(['float','cssFloat'].include(name)) name = (typeof element.style.styleFloat != 'undefined') ? 'styleFloat' : 'cssFloat'; - element.style[name.camelize()] = value; - } + element.style.opacity = (value == 1 || value === '') ? '' : + (value < 0.00001) ? 0 : value; return element; }, @@ -1483,61 +1676,58 @@ Element.Methods = { } }; -Object.extend(Element.Methods, {childOf: Element.Methods.descendantOf}); - -Element._attributeTranslations = {}; - -Element._attributeTranslations.names = { - colspan: "colSpan", - rowspan: "rowSpan", - valign: "vAlign", - datetime: "dateTime", - accesskey: "accessKey", - tabindex: "tabIndex", - enctype: "encType", - maxlength: "maxLength", - readonly: "readOnly", - longdesc: "longDesc" -}; - -Element._attributeTranslations.values = { - _getAttr: function(element, attribute) { - return element.getAttribute(attribute, 2); - }, - - _flag: function(element, attribute) { - return $(element).hasAttribute(attribute) ? attribute : null; - }, +Object.extend(Element.Methods, { + childOf: Element.Methods.descendantOf, + childElements: Element.Methods.immediateDescendants +}); - style: function(element) { - return element.style.cssText.toLowerCase(); - }, +if (Prototype.Browser.Opera) { + Element.Methods._getStyle = Element.Methods.getStyle; + Element.Methods.getStyle = function(element, style) { + switch(style) { + case 'left': + case 'top': + case 'right': + case 'bottom': + if (Element._getStyle(element, 'position') == 'static') return null; + default: return Element._getStyle(element, style); + } + }; +} +else if (Prototype.Browser.IE) { + Element.Methods.getStyle = function(element, style) { + element = $(element); + style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize(); + var value = element.style[style]; + if (!value && element.currentStyle) value = element.currentStyle[style]; - title: function(element) { - var node = element.getAttributeNode('title'); - return node.specified ? node.nodeValue : null; - } -}; + if (style == 'opacity') { + if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/)) + if (value[1]) return parseFloat(value[1]) / 100; + return 1.0; + } -Object.extend(Element._attributeTranslations.values, { - href: Element._attributeTranslations.values._getAttr, - src: Element._attributeTranslations.values._getAttr, - disabled: Element._attributeTranslations.values._flag, - checked: Element._attributeTranslations.values._flag, - readonly: Element._attributeTranslations.values._flag, - multiple: Element._attributeTranslations.values._flag -}); + if (value == 'auto') { + if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none')) + return element['offset'+style.capitalize()] + 'px'; + return null; + } + return value; + }; -Element.Methods.Simulated = { - hasAttribute: function(element, attribute) { - var t = Element._attributeTranslations; - attribute = t.names[attribute] || attribute; - return $(element).getAttributeNode(attribute).specified; - } -}; + Element.Methods.setOpacity = function(element, value) { + element = $(element); + var filter = element.getStyle('filter'), style = element.style; + if (value == 1 || value === '') { + style.filter = filter.replace(/alpha\([^\)]*\)/gi,''); + return element; + } else if (value < 0.00001) value = 0; + style.filter = filter.replace(/alpha\([^\)]*\)/gi, '') + + 'alpha(opacity=' + (value * 100) + ')'; + return element; + }; -// IE is missing .innerHTML support for TABLE-related elements -if (document.all && !window.opera){ + // IE is missing .innerHTML support for TABLE-related elements Element.Methods.update = function(element, html) { element = $(element); html = typeof html == 'undefined' ? '' : html.toString(); @@ -1558,35 +1748,123 @@ if (document.all && !window.opera){ div.innerHTML = '
    ' + html.stripScripts() + '
    '; depth = 4; } - $A(element.childNodes).each(function(node){ - element.removeChild(node) - }); - depth.times(function(){ div = div.firstChild }); - - $A(div.childNodes).each( - function(node){ element.appendChild(node) }); + $A(element.childNodes).each(function(node) { element.removeChild(node) }); + depth.times(function() { div = div.firstChild }); + $A(div.childNodes).each(function(node) { element.appendChild(node) }); } else { element.innerHTML = html.stripScripts(); } - setTimeout(function() {html.evalScripts()}, 10); + setTimeout(function() { html.evalScripts() }, 10); + return element; + } +} +else if (Prototype.Browser.Gecko) { + Element.Methods.setOpacity = function(element, value) { + element = $(element); + element.style.opacity = (value == 1) ? 0.999999 : + (value === '') ? '' : (value < 0.00001) ? 0 : value; return element; + }; +} + +Element._attributeTranslations = { + names: { + colspan: "colSpan", + rowspan: "rowSpan", + valign: "vAlign", + datetime: "dateTime", + accesskey: "accessKey", + tabindex: "tabIndex", + enctype: "encType", + maxlength: "maxLength", + readonly: "readOnly", + longdesc: "longDesc" + }, + values: { + _getAttr: function(element, attribute) { + return element.getAttribute(attribute, 2); + }, + _flag: function(element, attribute) { + return $(element).hasAttribute(attribute) ? attribute : null; + }, + style: function(element) { + return element.style.cssText.toLowerCase(); + }, + title: function(element) { + var node = element.getAttributeNode('title'); + return node.specified ? node.nodeValue : null; + } } }; +(function() { + Object.extend(this, { + href: this._getAttr, + src: this._getAttr, + type: this._getAttr, + disabled: this._flag, + checked: this._flag, + readonly: this._flag, + multiple: this._flag + }); +}).call(Element._attributeTranslations.values); + +Element.Methods.Simulated = { + hasAttribute: function(element, attribute) { + var t = Element._attributeTranslations, node; + attribute = t.names[attribute] || attribute; + node = $(element).getAttributeNode(attribute); + return node && node.specified; + } +}; + +Element.Methods.ByTag = {}; + Object.extend(Element, Element.Methods); -var _nativeExtensions = false; +if (!Prototype.BrowserFeatures.ElementExtensions && + document.createElement('div').__proto__) { + window.HTMLElement = {}; + window.HTMLElement.prototype = document.createElement('div').__proto__; + Prototype.BrowserFeatures.ElementExtensions = true; +} -if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)) - ['', 'Form', 'Input', 'TextArea', 'Select'].each(function(tag) { - var className = 'HTML' + tag + 'Element'; - if(window[className]) return; - var klass = window[className] = {}; - klass.prototype = document.createElement(tag ? tag.toLowerCase() : 'div').__proto__; - }); +Element.hasAttribute = function(element, attribute) { + if (element.hasAttribute) return element.hasAttribute(attribute); + return Element.Methods.Simulated.hasAttribute(element, attribute); +}; Element.addMethods = function(methods) { - Object.extend(Element.Methods, methods || {}); + var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag; + + if (!methods) { + Object.extend(Form, Form.Methods); + Object.extend(Form.Element, Form.Element.Methods); + Object.extend(Element.Methods.ByTag, { + "FORM": Object.clone(Form.Methods), + "INPUT": Object.clone(Form.Element.Methods), + "SELECT": Object.clone(Form.Element.Methods), + "TEXTAREA": Object.clone(Form.Element.Methods) + }); + } + + if (arguments.length == 2) { + var tagName = methods; + methods = arguments[1]; + } + + if (!tagName) Object.extend(Element.Methods, methods || {}); + else { + if (tagName.constructor == Array) tagName.each(extend); + else extend(tagName); + } + + function extend(tagName) { + tagName = tagName.toUpperCase(); + if (!Element.Methods.ByTag[tagName]) + Element.Methods.ByTag[tagName] = {}; + Object.extend(Element.Methods.ByTag[tagName], methods); + } function copy(methods, destination, onlyIfAbsent) { onlyIfAbsent = onlyIfAbsent || false; @@ -1598,19 +1876,49 @@ Element.addMethods = function(methods) { } } - if (typeof HTMLElement != 'undefined') { + function findDOMClass(tagName) { + var klass; + var trans = { + "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph", + "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList", + "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading", + "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote", + "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION": + "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD": + "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR": + "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET": + "FrameSet", "IFRAME": "IFrame" + }; + if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element'; + if (window[klass]) return window[klass]; + klass = 'HTML' + tagName + 'Element'; + if (window[klass]) return window[klass]; + klass = 'HTML' + tagName.capitalize() + 'Element'; + if (window[klass]) return window[klass]; + + window[klass] = {}; + window[klass].prototype = document.createElement(tagName).__proto__; + return window[klass]; + } + + if (F.ElementExtensions) { copy(Element.Methods, HTMLElement.prototype); copy(Element.Methods.Simulated, HTMLElement.prototype, true); - copy(Form.Methods, HTMLFormElement.prototype); - [HTMLInputElement, HTMLTextAreaElement, HTMLSelectElement].each(function(klass) { - copy(Form.Element.Methods, klass.prototype); - }); - _nativeExtensions = true; } -} -var Toggle = new Object(); -Toggle.display = Element.toggle; + if (F.SpecificElementExtensions) { + for (var tag in Element.Methods.ByTag) { + var klass = findDOMClass(tag); + if (typeof klass == "undefined") continue; + copy(T[tag], klass.prototype); + } + } + + Object.extend(Element, Element.Methods); + delete Element.ByTag; +}; + +var Toggle = { display: Element.toggle }; /*--------------------------------------------------------------------------*/ @@ -1741,129 +2049,572 @@ Element.ClassNames.prototype = { }; Object.extend(Element.ClassNames.prototype, Enumerable); +/* Portions of the Selector class are derived from Jack Slocum’s DomQuery, + * part of YUI-Ext version 0.40, distributed under the terms of an MIT-style + * license. Please see http://www.yui-ext.com/ for more information. */ + var Selector = Class.create(); + Selector.prototype = { initialize: function(expression) { - this.params = {classNames: []}; - this.expression = expression.toString().strip(); - this.parseExpression(); + this.expression = expression.strip(); this.compileMatcher(); }, - parseExpression: function() { - function abort(message) { throw 'Parse error in selector: ' + message; } + compileMatcher: function() { + // Selectors with namespaced attributes can't use the XPath version + if (Prototype.BrowserFeatures.XPath && !(/\[[\w-]*?:/).test(this.expression)) + return this.compileXPathMatcher(); - if (this.expression == '') abort('empty expression'); + var e = this.expression, ps = Selector.patterns, h = Selector.handlers, + c = Selector.criteria, le, p, m; - var params = this.params, expr = this.expression, match, modifier, clause, rest; - while (match = expr.match(/^(.*)\[([a-z0-9_:-]+?)(?:([~\|!]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)) { - params.attributes = params.attributes || []; - params.attributes.push({name: match[2], operator: match[3], value: match[4] || match[5] || ''}); - expr = match[1]; + if (Selector._cache[e]) { + this.matcher = Selector._cache[e]; return; } - - if (expr == '*') return this.params.wildcard = true; - - while (match = expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+)(.*)/i)) { - modifier = match[1], clause = match[2], rest = match[3]; - switch (modifier) { - case '#': params.id = clause; break; - case '.': params.classNames.push(clause); break; - case '': - case undefined: params.tagName = clause.toUpperCase(); break; - default: abort(expr.inspect()); + this.matcher = ["this.matcher = function(root) {", + "var r = root, h = Selector.handlers, c = false, n;"]; + + while (e && le != e && (/\S/).test(e)) { + le = e; + for (var i in ps) { + p = ps[i]; + if (m = e.match(p)) { + this.matcher.push(typeof c[i] == 'function' ? c[i](m) : + new Template(c[i]).evaluate(m)); + e = e.replace(m[0], ''); + break; + } } - expr = rest; } - if (expr.length > 0) abort(expr.inspect()); + this.matcher.push("return h.unique(n);\n}"); + eval(this.matcher.join('\n')); + Selector._cache[this.expression] = this.matcher; }, - buildMatchExpression: function() { - var params = this.params, conditions = [], clause; + compileXPathMatcher: function() { + var e = this.expression, ps = Selector.patterns, + x = Selector.xpath, le, m; - if (params.wildcard) - conditions.push('true'); - if (clause = params.id) - conditions.push('element.readAttribute("id") == ' + clause.inspect()); - if (clause = params.tagName) - conditions.push('element.tagName.toUpperCase() == ' + clause.inspect()); - if ((clause = params.classNames).length > 0) - for (var i = 0, length = clause.length; i < length; i++) - conditions.push('element.hasClassName(' + clause[i].inspect() + ')'); - if (clause = params.attributes) { - clause.each(function(attribute) { - var value = 'element.readAttribute(' + attribute.name.inspect() + ')'; - var splitValueBy = function(delimiter) { - return value + ' && ' + value + '.split(' + delimiter.inspect() + ')'; - } + if (Selector._cache[e]) { + this.xpath = Selector._cache[e]; return; + } - switch (attribute.operator) { - case '=': conditions.push(value + ' == ' + attribute.value.inspect()); break; - case '~=': conditions.push(splitValueBy(' ') + '.include(' + attribute.value.inspect() + ')'); break; - case '|=': conditions.push( - splitValueBy('-') + '.first().toUpperCase() == ' + attribute.value.toUpperCase().inspect() - ); break; - case '!=': conditions.push(value + ' != ' + attribute.value.inspect()); break; - case '': - case undefined: conditions.push('element.hasAttribute(' + attribute.name.inspect() + ')'); break; - default: throw 'Unknown operator ' + attribute.operator + ' in selector'; + this.matcher = ['.//*']; + while (e && le != e && (/\S/).test(e)) { + le = e; + for (var i in ps) { + if (m = e.match(ps[i])) { + this.matcher.push(typeof x[i] == 'function' ? x[i](m) : + new Template(x[i]).evaluate(m)); + e = e.replace(m[0], ''); + break; } - }); + } } - return conditions.join(' && '); + this.xpath = this.matcher.join(''); + Selector._cache[this.expression] = this.xpath; }, - compileMatcher: function() { - this.match = new Function('element', 'if (!element.tagName) return false; \ - element = $(element); \ - return ' + this.buildMatchExpression()); + findElements: function(root) { + root = root || document; + if (this.xpath) return document._getElementsByXPath(this.xpath, root); + return this.matcher(root); }, - findElements: function(scope) { - var element; - - if (element = $(this.params.id)) - if (this.match(element)) - if (!scope || Element.childOf(element, scope)) - return [element]; - - scope = (scope || document).getElementsByTagName(this.params.tagName || '*'); - - var results = []; - for (var i = 0, length = scope.length; i < length; i++) - if (this.match(element = scope[i])) - results.push(Element.extend(element)); - - return results; + match: function(element) { + return this.findElements(document).include(element); }, toString: function() { return this.expression; + }, + + inspect: function() { + return "#"; } -} +}; Object.extend(Selector, { + _cache: {}, + + xpath: { + descendant: "//*", + child: "/*", + adjacent: "/following-sibling::*[1]", + laterSibling: '/following-sibling::*', + tagName: function(m) { + if (m[1] == '*') return ''; + return "[local-name()='" + m[1].toLowerCase() + + "' or local-name()='" + m[1].toUpperCase() + "']"; + }, + className: "[contains(concat(' ', @class, ' '), ' #{1} ')]", + id: "[@id='#{1}']", + attrPresence: "[@#{1}]", + attr: function(m) { + m[3] = m[5] || m[6]; + return new Template(Selector.xpath.operators[m[2]]).evaluate(m); + }, + pseudo: function(m) { + var h = Selector.xpath.pseudos[m[1]]; + if (!h) return ''; + if (typeof h === 'function') return h(m); + return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m); + }, + operators: { + '=': "[@#{1}='#{3}']", + '!=': "[@#{1}!='#{3}']", + '^=': "[starts-with(@#{1}, '#{3}')]", + '$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']", + '*=': "[contains(@#{1}, '#{3}')]", + '~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]", + '|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]" + }, + pseudos: { + 'first-child': '[not(preceding-sibling::*)]', + 'last-child': '[not(following-sibling::*)]', + 'only-child': '[not(preceding-sibling::* or following-sibling::*)]', + 'empty': "[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]", + 'checked': "[@checked]", + 'disabled': "[@disabled]", + 'enabled': "[not(@disabled)]", + 'not': function(m) { + var e = m[6], p = Selector.patterns, + x = Selector.xpath, le, m, v; + + var exclusion = []; + while (e && le != e && (/\S/).test(e)) { + le = e; + for (var i in p) { + if (m = e.match(p[i])) { + v = typeof x[i] == 'function' ? x[i](m) : new Template(x[i]).evaluate(m); + exclusion.push("(" + v.substring(1, v.length - 1) + ")"); + e = e.replace(m[0], ''); + break; + } + } + } + return "[not(" + exclusion.join(" and ") + ")]"; + }, + 'nth-child': function(m) { + return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m); + }, + 'nth-last-child': function(m) { + return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m); + }, + 'nth-of-type': function(m) { + return Selector.xpath.pseudos.nth("position() ", m); + }, + 'nth-last-of-type': function(m) { + return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m); + }, + 'first-of-type': function(m) { + m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m); + }, + 'last-of-type': function(m) { + m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m); + }, + 'only-of-type': function(m) { + var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m); + }, + nth: function(fragment, m) { + var mm, formula = m[6], predicate; + if (formula == 'even') formula = '2n+0'; + if (formula == 'odd') formula = '2n+1'; + if (mm = formula.match(/^(\d+)$/)) // digit only + return '[' + fragment + "= " + mm[1] + ']'; + if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b + if (mm[1] == "-") mm[1] = -1; + var a = mm[1] ? Number(mm[1]) : 1; + var b = mm[2] ? Number(mm[2]) : 0; + predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " + + "((#{fragment} - #{b}) div #{a} >= 0)]"; + return new Template(predicate).evaluate({ + fragment: fragment, a: a, b: b }); + } + } + } + }, + + criteria: { + tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;', + className: 'n = h.className(n, r, "#{1}", c); c = false;', + id: 'n = h.id(n, r, "#{1}", c); c = false;', + attrPresence: 'n = h.attrPresence(n, r, "#{1}"); c = false;', + attr: function(m) { + m[3] = (m[5] || m[6]); + return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}"); c = false;').evaluate(m); + }, + pseudo: function(m) { + if (m[6]) m[6] = m[6].replace(/"/g, '\\"'); + return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m); + }, + descendant: 'c = "descendant";', + child: 'c = "child";', + adjacent: 'c = "adjacent";', + laterSibling: 'c = "laterSibling";' + }, + + patterns: { + // combinators must be listed first + // (and descendant needs to be last combinator) + laterSibling: /^\s*~\s*/, + child: /^\s*>\s*/, + adjacent: /^\s*\+\s*/, + descendant: /^\s/, + + // selectors follow + tagName: /^\s*(\*|[\w\-]+)(\b|$)?/, + id: /^#([\w\-\*]+)(\b|$)/, + className: /^\.([\w\-\*]+)(\b|$)/, + pseudo: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|\s|(?=:))/, + attrPresence: /^\[([\w]+)\]/, + attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\]]*?)\4|([^'"][^\]]*?)))?\]/ + }, + + handlers: { + // UTILITY FUNCTIONS + // joins two collections + concat: function(a, b) { + for (var i = 0, node; node = b[i]; i++) + a.push(node); + return a; + }, + + // marks an array of nodes for counting + mark: function(nodes) { + for (var i = 0, node; node = nodes[i]; i++) + node._counted = true; + return nodes; + }, + + unmark: function(nodes) { + for (var i = 0, node; node = nodes[i]; i++) + node._counted = undefined; + return nodes; + }, + + // mark each child node with its position (for nth calls) + // "ofType" flag indicates whether we're indexing for nth-of-type + // rather than nth-child + index: function(parentNode, reverse, ofType) { + parentNode._counted = true; + if (reverse) { + for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) { + node = nodes[i]; + if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++; + } + } else { + for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++) + if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++; + } + }, + + // filters out duplicates and extends all nodes + unique: function(nodes) { + if (nodes.length == 0) return nodes; + var results = [], n; + for (var i = 0, l = nodes.length; i < l; i++) + if (!(n = nodes[i])._counted) { + n._counted = true; + results.push(Element.extend(n)); + } + return Selector.handlers.unmark(results); + }, + + // COMBINATOR FUNCTIONS + descendant: function(nodes) { + var h = Selector.handlers; + for (var i = 0, results = [], node; node = nodes[i]; i++) + h.concat(results, node.getElementsByTagName('*')); + return results; + }, + + child: function(nodes) { + var h = Selector.handlers; + for (var i = 0, results = [], node; node = nodes[i]; i++) { + for (var j = 0, children = [], child; child = node.childNodes[j]; j++) + if (child.nodeType == 1 && child.tagName != '!') results.push(child); + } + return results; + }, + + adjacent: function(nodes) { + for (var i = 0, results = [], node; node = nodes[i]; i++) { + var next = this.nextElementSibling(node); + if (next) results.push(next); + } + return results; + }, + + laterSibling: function(nodes) { + var h = Selector.handlers; + for (var i = 0, results = [], node; node = nodes[i]; i++) + h.concat(results, Element.nextSiblings(node)); + return results; + }, + + nextElementSibling: function(node) { + while (node = node.nextSibling) + if (node.nodeType == 1) return node; + return null; + }, + + previousElementSibling: function(node) { + while (node = node.previousSibling) + if (node.nodeType == 1) return node; + return null; + }, + + // TOKEN FUNCTIONS + tagName: function(nodes, root, tagName, combinator) { + tagName = tagName.toUpperCase(); + var results = [], h = Selector.handlers; + if (nodes) { + if (combinator) { + // fastlane for ordinary descendant combinators + if (combinator == "descendant") { + for (var i = 0, node; node = nodes[i]; i++) + h.concat(results, node.getElementsByTagName(tagName)); + return results; + } else nodes = this[combinator](nodes); + if (tagName == "*") return nodes; + } + for (var i = 0, node; node = nodes[i]; i++) + if (node.tagName.toUpperCase() == tagName) results.push(node); + return results; + } else return root.getElementsByTagName(tagName); + }, + + id: function(nodes, root, id, combinator) { + var targetNode = $(id), h = Selector.handlers; + if (!nodes && root == document) return targetNode ? [targetNode] : []; + if (nodes) { + if (combinator) { + if (combinator == 'child') { + for (var i = 0, node; node = nodes[i]; i++) + if (targetNode.parentNode == node) return [targetNode]; + } else if (combinator == 'descendant') { + for (var i = 0, node; node = nodes[i]; i++) + if (Element.descendantOf(targetNode, node)) return [targetNode]; + } else if (combinator == 'adjacent') { + for (var i = 0, node; node = nodes[i]; i++) + if (Selector.handlers.previousElementSibling(targetNode) == node) + return [targetNode]; + } else nodes = h[combinator](nodes); + } + for (var i = 0, node; node = nodes[i]; i++) + if (node == targetNode) return [targetNode]; + return []; + } + return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : []; + }, + + className: function(nodes, root, className, combinator) { + if (nodes && combinator) nodes = this[combinator](nodes); + return Selector.handlers.byClassName(nodes, root, className); + }, + + byClassName: function(nodes, root, className) { + if (!nodes) nodes = Selector.handlers.descendant([root]); + var needle = ' ' + className + ' '; + for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) { + nodeClassName = node.className; + if (nodeClassName.length == 0) continue; + if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle)) + results.push(node); + } + return results; + }, + + attrPresence: function(nodes, root, attr) { + var results = []; + for (var i = 0, node; node = nodes[i]; i++) + if (Element.hasAttribute(node, attr)) results.push(node); + return results; + }, + + attr: function(nodes, root, attr, value, operator) { + if (!nodes) nodes = root.getElementsByTagName("*"); + var handler = Selector.operators[operator], results = []; + for (var i = 0, node; node = nodes[i]; i++) { + var nodeValue = Element.readAttribute(node, attr); + if (nodeValue === null) continue; + if (handler(nodeValue, value)) results.push(node); + } + return results; + }, + + pseudo: function(nodes, name, value, root, combinator) { + if (nodes && combinator) nodes = this[combinator](nodes); + if (!nodes) nodes = root.getElementsByTagName("*"); + return Selector.pseudos[name](nodes, value, root); + } + }, + + pseudos: { + 'first-child': function(nodes, value, root) { + for (var i = 0, results = [], node; node = nodes[i]; i++) { + if (Selector.handlers.previousElementSibling(node)) continue; + results.push(node); + } + return results; + }, + 'last-child': function(nodes, value, root) { + for (var i = 0, results = [], node; node = nodes[i]; i++) { + if (Selector.handlers.nextElementSibling(node)) continue; + results.push(node); + } + return results; + }, + 'only-child': function(nodes, value, root) { + var h = Selector.handlers; + for (var i = 0, results = [], node; node = nodes[i]; i++) + if (!h.previousElementSibling(node) && !h.nextElementSibling(node)) + results.push(node); + return results; + }, + 'nth-child': function(nodes, formula, root) { + return Selector.pseudos.nth(nodes, formula, root); + }, + 'nth-last-child': function(nodes, formula, root) { + return Selector.pseudos.nth(nodes, formula, root, true); + }, + 'nth-of-type': function(nodes, formula, root) { + return Selector.pseudos.nth(nodes, formula, root, false, true); + }, + 'nth-last-of-type': function(nodes, formula, root) { + return Selector.pseudos.nth(nodes, formula, root, true, true); + }, + 'first-of-type': function(nodes, formula, root) { + return Selector.pseudos.nth(nodes, "1", root, false, true); + }, + 'last-of-type': function(nodes, formula, root) { + return Selector.pseudos.nth(nodes, "1", root, true, true); + }, + 'only-of-type': function(nodes, formula, root) { + var p = Selector.pseudos; + return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root); + }, + + // handles the an+b logic + getIndices: function(a, b, total) { + if (a == 0) return b > 0 ? [b] : []; + return $R(1, total).inject([], function(memo, i) { + if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i); + return memo; + }); + }, + + // handles nth(-last)-child, nth(-last)-of-type, and (first|last)-of-type + nth: function(nodes, formula, root, reverse, ofType) { + if (nodes.length == 0) return []; + if (formula == 'even') formula = '2n+0'; + if (formula == 'odd') formula = '2n+1'; + var h = Selector.handlers, results = [], indexed = [], m; + h.mark(nodes); + for (var i = 0, node; node = nodes[i]; i++) { + if (!node.parentNode._counted) { + h.index(node.parentNode, reverse, ofType); + indexed.push(node.parentNode); + } + } + if (formula.match(/^\d+$/)) { // just a number + formula = Number(formula); + for (var i = 0, node; node = nodes[i]; i++) + if (node.nodeIndex == formula) results.push(node); + } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b + if (m[1] == "-") m[1] = -1; + var a = m[1] ? Number(m[1]) : 1; + var b = m[2] ? Number(m[2]) : 0; + var indices = Selector.pseudos.getIndices(a, b, nodes.length); + for (var i = 0, node, l = indices.length; node = nodes[i]; i++) { + for (var j = 0; j < l; j++) + if (node.nodeIndex == indices[j]) results.push(node); + } + } + h.unmark(nodes); + h.unmark(indexed); + return results; + }, + + 'empty': function(nodes, value, root) { + for (var i = 0, results = [], node; node = nodes[i]; i++) { + // IE treats comments as element nodes + if (node.tagName == '!' || (node.firstChild && !node.innerHTML.match(/^\s*$/))) continue; + results.push(node); + } + return results; + }, + + 'not': function(nodes, selector, root) { + var h = Selector.handlers, selectorType, m; + var exclusions = new Selector(selector).findElements(root); + h.mark(exclusions); + for (var i = 0, results = [], node; node = nodes[i]; i++) + if (!node._counted) results.push(node); + h.unmark(exclusions); + return results; + }, + + 'enabled': function(nodes, value, root) { + for (var i = 0, results = [], node; node = nodes[i]; i++) + if (!node.disabled) results.push(node); + return results; + }, + + 'disabled': function(nodes, value, root) { + for (var i = 0, results = [], node; node = nodes[i]; i++) + if (node.disabled) results.push(node); + return results; + }, + + 'checked': function(nodes, value, root) { + for (var i = 0, results = [], node; node = nodes[i]; i++) + if (node.checked) results.push(node); + return results; + } + }, + + operators: { + '=': function(nv, v) { return nv == v; }, + '!=': function(nv, v) { return nv != v; }, + '^=': function(nv, v) { return nv.startsWith(v); }, + '$=': function(nv, v) { return nv.endsWith(v); }, + '*=': function(nv, v) { return nv.include(v); }, + '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); }, + '|=': function(nv, v) { return ('-' + nv.toUpperCase() + '-').include('-' + v.toUpperCase() + '-'); } + }, + matchElements: function(elements, expression) { - var selector = new Selector(expression); - return elements.select(selector.match.bind(selector)).map(Element.extend); + var matches = new Selector(expression).findElements(), h = Selector.handlers; + h.mark(matches); + for (var i = 0, results = [], element; element = elements[i]; i++) + if (element._counted) results.push(element); + h.unmark(matches); + return results; }, findElement: function(elements, expression, index) { - if (typeof expression == 'number') index = expression, expression = false; + if (typeof expression == 'number') { + index = expression; expression = false; + } return Selector.matchElements(elements, expression || '*')[index || 0]; }, findChildElements: function(element, expressions) { - return expressions.map(function(expression) { - return expression.match(/[^\s"]+(?:"[^"]*"[^\s"]+)*/g).inject([null], function(results, expr) { - var selector = new Selector(expr); - return results.inject([], function(elements, result) { - return elements.concat(selector.findElements(result || element)); - }); - }); - }).flatten(); + var exprs = expressions.join(','), expressions = []; + exprs.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) { + expressions.push(m[1].strip()); + }); + var results = [], h = Selector.handlers; + for (var i = 0, l = expressions.length, selector; i < l; i++) { + selector = new Selector(expressions[i].strip()); + h.concat(results, selector.findElements(element)); + } + return (l > 1) ? h.unique(results) : results; } }); @@ -1880,8 +2631,8 @@ var Form = { var data = elements.inject({}, function(result, element) { if (!element.disabled && element.name) { var key = element.name, value = $(element).getValue(); - if (value != undefined) { - if (result[key]) { + if (value != null) { + if (key in result) { if (result[key].constructor != Array) result[key] = [result[key]]; result[key].push(value); } @@ -1928,18 +2679,13 @@ Form.Methods = { disable: function(form) { form = $(form); - form.getElements().each(function(element) { - element.blur(); - element.disabled = 'true'; - }); + Form.getElements(form).invoke('disable'); return form; }, enable: function(form) { form = $(form); - form.getElements().each(function(element) { - element.disabled = ''; - }); + Form.getElements(form).invoke('enable'); return form; }, @@ -1954,11 +2700,26 @@ Form.Methods = { form = $(form); form.findFirstElement().activate(); return form; + }, + + request: function(form, options) { + form = $(form), options = Object.clone(options || {}); + + var params = options.parameters; + options.parameters = form.serialize(true); + + if (params) { + if (typeof params == 'string') params = params.toQueryParams(); + Object.extend(options.parameters, params); + } + + if (form.hasAttribute('method') && !options.method) + options.method = form.method; + + return new Ajax.Request(form.readAttribute('action'), options); } } -Object.extend(Form, Form.Methods); - /*--------------------------------------------------------------------------*/ Form.Element = { @@ -2004,30 +2765,33 @@ Form.Element.Methods = { activate: function(element) { element = $(element); - element.focus(); - if (element.select && ( element.tagName.toLowerCase() != 'input' || - !['button', 'reset', 'submit'].include(element.type) ) ) - element.select(); + try { + element.focus(); + if (element.select && (element.tagName.toLowerCase() != 'input' || + !['button', 'reset', 'submit'].include(element.type))) + element.select(); + } catch (e) {} return element; }, disable: function(element) { element = $(element); + element.blur(); element.disabled = true; return element; }, enable: function(element) { element = $(element); - element.blur(); element.disabled = false; return element; } } -Object.extend(Form.Element, Form.Element.Methods); +/*--------------------------------------------------------------------------*/ + var Field = Form.Element; -var $F = Form.Element.getValue; +var $F = Form.Element.Methods.getValue; /*--------------------------------------------------------------------------*/ @@ -2194,7 +2958,7 @@ Object.extend(Event, { KEY_PAGEDOWN: 34, element: function(event) { - return event.target || event.srcElement; + return $(event.target || event.srcElement); }, isLeftClick: function(event) { @@ -2259,8 +3023,7 @@ Object.extend(Event, { useCapture = useCapture || false; if (name == 'keypress' && - (navigator.appVersion.match(/Konqueror|Safari|KHTML/) - || element.attachEvent)) + (Prototype.Browser.WebKit || element.attachEvent)) name = 'keydown'; Event._observeAndCache(element, name, observer, useCapture); @@ -2271,8 +3034,7 @@ Object.extend(Event, { useCapture = useCapture || false; if (name == 'keypress' && - (navigator.appVersion.match(/Konqueror|Safari|KHTML/) - || element.detachEvent)) + (Prototype.Browser.WebKit || element.attachEvent)) name = 'keydown'; if (element.removeEventListener) { @@ -2286,7 +3048,7 @@ Object.extend(Event, { }); /* prevent memory leaks in IE */ -if (navigator.appVersion.match(/\bMSIE\b/)) +if (Prototype.Browser.IE) Event.observe(window, 'unload', Event.unloadCache, false); var Position = { // set to true if needed, warning: firefox performance problems @@ -2400,7 +3162,7 @@ var Position = { valueL += element.offsetLeft || 0; // Safari fix - if (element.offsetParent==document.body) + if (element.offsetParent == document.body) if (Element.getStyle(element,'position')=='absolute') break; } while (element = element.offsetParent); @@ -2496,7 +3258,7 @@ var Position = { // Safari returns margins on body which is incorrect if the child is absolutely // positioned. For performance reasons, redefine Position.cumulativeOffset for // KHTML/WebKit only. -if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) { +if (Prototype.Browser.WebKit) { Position.cumulativeOffset = function(element) { var valueT = 0, valueL = 0; do { diff --git a/wp-includes/js/scriptaculous/MIT-LICENSE b/wp-includes/js/scriptaculous/MIT-LICENSE index a67de52..5600377 100644 --- a/wp-includes/js/scriptaculous/MIT-LICENSE +++ b/wp-includes/js/scriptaculous/MIT-LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/wp-includes/js/scriptaculous/builder.js b/wp-includes/js/scriptaculous/builder.js index 199afc1..5b4ce87 100644 --- a/wp-includes/js/scriptaculous/builder.js +++ b/wp-includes/js/scriptaculous/builder.js @@ -1,6 +1,6 @@ -// script.aculo.us builder.js v1.7.0, Fri Jan 19 19:16:36 CET 2007 +// script.aculo.us builder.js v1.7.1_beta3, Fri May 25 17:19:41 +0200 2007 -// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // // script.aculo.us is freely distributable under the terms of an MIT-style license. // For details, see the script.aculo.us web site: http://script.aculo.us/ @@ -48,7 +48,8 @@ var Builder = { // attributes (or text) if(arguments[1]) if(this._isStringOrNumber(arguments[1]) || - (arguments[1] instanceof Array)) { + (arguments[1] instanceof Array) || + arguments[1].tagName) { this._children(element, arguments[1]); } else { var attrs = this._attributes(arguments[1]); @@ -66,7 +67,7 @@ var Builder = { } if(element.tagName.toUpperCase() != elementName) element = parentElement.getElementsByTagName(elementName)[0]; - } + } } // text, or array of children @@ -88,10 +89,14 @@ var Builder = { var attrs = []; for(attribute in attributes) attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) + - '="' + attributes[attribute].toString().escapeHTML() + '"'); + '="' + attributes[attribute].toString().escapeHTML().gsub(/"/,'"') + '"'); return attrs.join(" "); }, _children: function(element, children) { + if(children.tagName) { + element.appendChild(children); + return; + } if(typeof children=='object') { // array can hold nodes and text children.flatten().each( function(e) { if(typeof e=='object') @@ -101,8 +106,8 @@ var Builder = { element.appendChild(Builder._text(e)); }); } else - if(Builder._isStringOrNumber(children)) - element.appendChild(Builder._text(children)); + if(Builder._isStringOrNumber(children)) + element.appendChild(Builder._text(children)); }, _isStringOrNumber: function(param) { return(typeof param=='string' || typeof param=='number'); diff --git a/wp-includes/js/scriptaculous/controls.js b/wp-includes/js/scriptaculous/controls.js index 46f2cc1..6783bd0 100644 --- a/wp-includes/js/scriptaculous/controls.js +++ b/wp-includes/js/scriptaculous/controls.js @@ -1,8 +1,8 @@ -// script.aculo.us controls.js v1.7.0, Fri Jan 19 19:16:36 CET 2007 +// script.aculo.us controls.js v1.7.1_beta3, Fri May 25 17:19:41 +0200 2007 -// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) -// (c) 2005, 2006 Ivan Krstic (http://blogs.law.harvard.edu/ivan) -// (c) 2005, 2006 Jon Tirsen (http://www.tirsen.com) +// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan) +// (c) 2005-2007 Jon Tirsen (http://www.tirsen.com) // Contributors: // Richard Livsey // Rahul Bhargava @@ -43,7 +43,8 @@ var Autocompleter = {} Autocompleter.Base = function() {}; Autocompleter.Base.prototype = { baseInitialize: function(element, update, options) { - this.element = $(element); + element = $(element) + this.element = element; this.update = $(update); this.hasFocus = false; this.changed = false; @@ -83,15 +84,20 @@ Autocompleter.Base.prototype = { Element.hide(this.update); - Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this)); - Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this)); + Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this)); + Event.observe(this.element, 'keypress', this.onKeyPress.bindAsEventListener(this)); + + // Turn autocomplete back on when the user leaves the page, so that the + // field's value will be remembered on Mozilla-based browsers. + Event.observe(window, 'beforeunload', function(){ + element.setAttribute('autocomplete', 'on'); + }); }, show: function() { if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update); if(!this.iefix && - (navigator.appVersion.indexOf('MSIE')>0) && - (navigator.userAgent.indexOf('Opera')<0) && + (Prototype.Browser.IE) && (Element.getStyle(this.update, 'position')=='absolute')) { new Insertion.After(this.update, '