Changeset 1005
- Timestamp:
- 06/21/07 16:41:02 (2 years ago)
- Files:
-
- trunk/wp-admin/admin-db.php (modified) (4 diffs)
- trunk/wp-admin/admin-footer.php (modified) (1 diff)
- trunk/wp-admin/admin-functions.php (modified) (12 diffs)
- trunk/wp-admin/categories.php (modified) (1 diff)
- trunk/wp-admin/comment.php (modified) (4 diffs)
- trunk/wp-admin/edit-comments.php (modified) (1 diff)
- trunk/wp-admin/edit-form-advanced.php (modified) (11 diffs)
- trunk/wp-admin/edit-form-comment.php (modified) (5 diffs)
- trunk/wp-admin/edit-form.php (modified) (4 diffs)
- trunk/wp-admin/edit-link-form.php (modified) (1 diff)
- trunk/wp-admin/edit-page-form.php (modified) (7 diffs)
- trunk/wp-admin/edit-pages.php (modified) (1 diff)
- trunk/wp-admin/edit.php (modified) (2 diffs)
- trunk/wp-admin/export.php (modified) (1 diff)
- trunk/wp-admin/import/livejournal.php (modified) (1 diff)
- trunk/wp-admin/import/textpattern.php (modified) (2 diffs)
- trunk/wp-admin/index.php (modified) (2 diffs)
- trunk/wp-admin/link-manager.php (modified) (1 diff)
- trunk/wp-admin/moderation.php (modified) (3 diffs)
- trunk/wp-admin/options-reading.php (modified) (1 diff)
- trunk/wp-admin/plugins.php (modified) (1 diff)
- trunk/wp-admin/post-new.php (modified) (2 diffs)
- trunk/wp-admin/upgrade-functions.php (modified) (2 diffs)
- trunk/wp-admin/user-edit.php (modified) (1 diff)
- trunk/wp-admin/users.php (modified) (1 diff)
- trunk/wp-admin/widgets.php (modified) (1 diff)
- trunk/wp-admin/wp-admin.css (modified) (7 diffs)
- trunk/wp-config-sample.php (modified) (1 diff)
- trunk/wp-content/themes/classic/style.css (modified) (5 diffs)
- trunk/wp-content/themes/default/archive.php (modified) (1 diff)
- trunk/wp-content/themes/default/functions.php (modified) (1 diff)
- trunk/wp-content/themes/default/sidebar.php (modified) (1 diff)
- trunk/wp-includes/author-template.php (modified) (1 diff)
- trunk/wp-includes/bookmark-template.php (modified) (3 diffs)
- trunk/wp-includes/bookmark.php (modified) (1 diff)
- trunk/wp-includes/category-template.php (modified) (3 diffs)
- trunk/wp-includes/category.php (modified) (7 diffs)
- trunk/wp-includes/class-phpmailer.php (modified) (1 diff)
- trunk/wp-includes/class-snoopy.php (modified) (1 diff)
- trunk/wp-includes/classes.php (modified) (2 diffs)
- trunk/wp-includes/comment-template.php (modified) (2 diffs)
- trunk/wp-includes/comment.php (modified) (12 diffs)
- trunk/wp-includes/compat.php (modified) (1 diff)
- trunk/wp-includes/deprecated.php (modified) (1 diff)
- trunk/wp-includes/feed-atom-comments.php (modified) (1 diff)
- trunk/wp-includes/feed.php (modified) (1 diff)
- trunk/wp-includes/formatting.php (modified) (2 diffs)
- trunk/wp-includes/functions.php (modified) (8 diffs)
- trunk/wp-includes/general-template.php (modified) (8 diffs)
- trunk/wp-includes/js/prototype.js (modified) (52 diffs)
- trunk/wp-includes/js/scriptaculous/builder.js (modified) (5 diffs)
- trunk/wp-includes/js/scriptaculous/controls.js (modified) (12 diffs)
- trunk/wp-includes/js/scriptaculous/dragdrop.js (modified) (10 diffs)
- trunk/wp-includes/js/scriptaculous/effects.js (modified) (18 diffs)
- trunk/wp-includes/js/scriptaculous/scriptaculous.js (modified) (3 diffs)
- trunk/wp-includes/js/scriptaculous/slider.js (modified) (2 diffs)
- trunk/wp-includes/js/scriptaculous/sound.js (deleted)
- trunk/wp-includes/js/scriptaculous/unittest.js (modified) (1 diff)
- trunk/wp-includes/js/tinymce/plugins/wordpress/langs/en.js (modified) (2 diffs)
- trunk/wp-includes/js/tinymce/tiny_mce_config.php (modified) (1 diff)
- trunk/wp-includes/js/tinymce/tiny_mce_popup.js (modified) (1 diff)
- trunk/wp-includes/kses.php (modified) (3 diffs)
- trunk/wp-includes/link-template.php (modified) (4 diffs)
- trunk/wp-includes/locale.php (modified) (1 diff)
- trunk/wp-includes/pluggable.php (modified) (3 diffs)
- trunk/wp-includes/plugin.php (modified) (2 diffs)
- trunk/wp-includes/post-template.php (modified) (3 diffs)
- trunk/wp-includes/post.php (modified) (9 diffs)
- trunk/wp-includes/registration.php (modified) (1 diff)
- trunk/wp-includes/rewrite.php (modified) (3 diffs)
- trunk/wp-includes/rss.php (modified) (2 diffs)
- trunk/wp-includes/script-loader.php (modified) (5 diffs)
- trunk/wp-includes/theme.php (modified) (2 diffs)
- trunk/wp-includes/user.php (modified) (1 diff)
- trunk/wp-includes/vars.php (modified) (1 diff)
- trunk/wp-includes/widgets.php (modified) (9 diffs)
- trunk/wp-settings.php (modified) (1 diff)
- trunk/xmlrpc.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wp-admin/admin-db.php
r987 r1005 84 84 global $wpdb; 85 85 86 extract($catarr );86 extract($catarr, EXTR_SKIP); 87 87 88 88 if( trim( $cat_name ) == '' ) … … 125 125 else 126 126 $links_private = 0; 127 128 129 // Let's check if we have this category already, if so just do an update130 if ( !$update && $cat_ID = category_object_exists( $category_nicename ) )131 $update = true;132 127 133 128 if (!$update) { … … 256 251 } 257 252 258 function category_object_exists($cat_name) {259 global $wpdb;260 if (!$category_nicename = sanitize_title($cat_name))261 return 0;262 263 return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'");264 }265 266 253 function category_exists($cat_name) { 267 254 global $wpdb; … … 315 302 global $wpdb, $current_user; 316 303 317 extract($linkdata );304 extract($linkdata, EXTR_SKIP); 318 305 319 306 $update = false; trunk/wp-admin/admin-footer.php
r972 r1005 3 3 <p class="logo"><a href="http://wordpress.org/" id="wordpress-logo"><img src="images/wordpress-logo.png" alt="WordPress" /></a></p> 4 4 <p class="docs"><?php _e('<a href="http://codex.wordpress.org/">Documentation</a>'); ?> — <?php _e('<a href="http://wordpress.org/support/">Support Forums</a>'); ?><br /> 5 <?php printf( __('Version %s'), get_bloginfo('version')); ?></p>5 <?php bloginfo('version'); ?> — <?php printf(__('%s seconds'), timer_stop(0, 2)); ?></p> 6 6 </div> 7 7 <?php do_action('admin_footer', ''); ?> trunk/wp-admin/admin-functions.php
r989 r1005 348 348 349 349 $post->post_password = format_to_edit( $post->post_password ); 350 351 $post->menu_order = (int) $post->menu_order; 350 352 351 353 if ( $post->post_type == 'page' ) … … 397 399 function get_comment_to_edit( $id ) { 398 400 $comment = get_comment( $id ); 399 400 $comment->comment_content = format_to_edit( $comment->comment_content, user_can_richedit() ); 401 402 $comment->comment_ID = (int) $comment->comment_ID; 403 $comment->comment_post_ID = (int) $comment->comment_post_ID; 404 405 $comment->comment_content = format_to_edit( $comment->comment_content ); 401 406 $comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content); 402 407 403 408 $comment->comment_author = format_to_edit( $comment->comment_author ); 404 409 $comment->comment_author_email = format_to_edit( $comment->comment_author_email ); 410 $comment->comment_author_url = clean_url($comment->comment_author_url); 405 411 $comment->comment_author_url = format_to_edit( $comment->comment_author_url ); 406 412 … … 410 416 function get_category_to_edit( $id ) { 411 417 $category = get_category( $id ); 418 419 $category->term_id = (int) $category->term_id; 420 $category->parent = (int) $category->parent; 412 421 413 422 return $category; … … 820 829 $class = ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'"; 821 830 822 $category->category_count = number_format _i18n( $category->category_count );823 $category->link_count = number_format _i18n( $category->link_count );831 $category->category_count = number_format( $category->category_count ); 832 $category->link_count = number_format( $category->link_count ); 824 833 $posts_count = ( $category->category_count > 0 ) ? "<a href='edit.php?cat=$category->cat_ID'>$category->category_count</a>" : $category->category_count; 825 834 return "<tr id='cat-$category->cat_ID'$class> … … 949 958 if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 950 959 echo " <a href='comment.php?action=editcomment&c=".$comment->comment_ID."'>" . __('Edit') . '</a>'; 951 echo ' | <a href="' . wp_nonce_url(' ocomment.php?action=deletecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> ';960 echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> '; 952 961 if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { 953 962 echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>'; … … 1040 1049 $entry['meta_key'] = attribute_escape($entry['meta_key']); 1041 1050 $entry['meta_value'] = attribute_escape($entry['meta_value']); 1051 $entry['meta_id'] = (int) $entry['meta_id']; 1042 1052 $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>"; 1043 1053 $r .= "\n\t\t<td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>"; … … 1092 1102 1093 1103 foreach ( $keys as $key ) { 1094 $key = attribute_escape( $key );1104 $key = attribute_escape( $key ); 1095 1105 echo "\n\t<option value='$key'>$key</option>"; 1096 1106 } … … 1113 1123 $post_ID = (int) $post_ID; 1114 1124 1125 $protected = array( '_wp_attached_file', '_wp_attachment_metadata', '_wp_old_slug', '_wp_page_template' ); 1126 1115 1127 $metakeyselect = $wpdb->escape( stripslashes( trim( $_POST['metakeyselect'] ) ) ); 1116 1128 $metakeyinput = $wpdb->escape( stripslashes( trim( $_POST['metakeyinput'] ) ) ); … … 1127 1139 if ( $metakeyinput) 1128 1140 $metakey = $metakeyinput; // default 1141 1142 if ( in_array($metakey, $protected) ) 1143 return false; 1129 1144 1130 1145 $result = $wpdb->query( " … … 1147 1162 function update_meta( $mid, $mkey, $mvalue ) { 1148 1163 global $wpdb; 1164 1165 $protected = array( '_wp_attached_file', '_wp_attachment_metadata', '_wp_old_slug', '_wp_page_template' ); 1166 1167 if ( in_array($mkey, $protected) ) 1168 return false; 1169 1149 1170 $mvalue = maybe_serialize( stripslashes( $mvalue )); 1150 1171 $mvalue = $wpdb->escape( $mvalue ); … … 1346 1367 function page_template_dropdown( $default = '' ) { 1347 1368 $templates = get_page_templates(); 1348 ksort( $templates );1349 1369 foreach (array_keys( $templates ) as $template ) 1350 1370 : if ( $default == $templates[$template] ) … … 1946 1966 extract( $wp_filetype ); 1947 1967 1948 if ( ( !$type || !$ext ) && !current_user_can( 'unfiltered_upload' ))1968 if ( !$type || !$ext ) 1949 1969 return $upload_error_handler( $file, __( 'File type does not meet security guidelines. Try another.' )); 1950 1951 if ( !$ext )1952 $ext = strrchr($file['name'], '.');1953 1970 } 1954 1971 trunk/wp-admin/categories.php
r972 r1005 119 119 120 120 <?php include('edit-category-form.php'); ?> 121 122 121 <?php endif; ?> 123 122 trunk/wp-admin/comment.php
r972 r1005 40 40 $nonce_action .= $comment; 41 41 42 if ( ! $comment = get_comment ($comment) )42 if ( ! $comment = get_comment_to_edit($comment) ) 43 43 wp_die(__('Oops, no comment with this ID.').sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php')); 44 44 … … 92 92 <tr> 93 93 <th scope="row"><?php _e('URL:'); ?></th> 94 <td><?php echo "<a href='$comment->comment_author_url'>$comment->comment_author_url</a>"; ?></td>94 <td><?php echo $comment->comment_author_url; ?></td> 95 95 </tr> 96 96 <?php } ?> 97 97 <tr> 98 98 <th scope="row" valign="top"><p><?php _e('Comment:'); ?></p></th> 99 <td><?php echo apply_filters( 'comment_text', $comment->comment_content ); ?></td>99 <td><?php echo $comment->comment_content; ?></td> 100 100 </tr> 101 101 </table> … … 156 156 wp_redirect(wp_get_referer()); 157 157 } else { 158 wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p='. $comment->comment_post_ID.'&c=1#comments');158 wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p='. (int) $comment->comment_post_ID.'&c=1#comments'); 159 159 } 160 160 exit(); … … 186 186 wp_redirect(wp_get_referer()); 187 187 } else { 188 wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p='. $comment->comment_post_ID.'&c=1#comments');188 wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p='. (int) $comment->comment_post_ID.'&c=1#comments'); 189 189 } 190 190 exit(); trunk/wp-admin/edit-comments.php
r976 r1005 158 158 ?> 159 159 <tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'> 160 <td style="text-align: center"><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { ?><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td>160 <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { ?><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td> 161 161 <td><?php comment_author_link() ?></td> 162 162 <td><?php comment_author_email_link() ?></td> trunk/wp-admin/edit-form-advanced.php
r972 r1005 1 1 <?php 2 if ( isset($_GET['message']) ) 3 $_GET['message'] = (int) $_GET['message']; 2 4 $messages[1] = __('Post updated'); 3 5 $messages[2] = __('Custom field updated'); … … 5 7 ?> 6 8 <?php if (isset($_GET['message'])) : ?> 7 <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>9 <div id="message" class="updated fade"><p><?php echo wp_specialchars($messages[$_GET['message']]); ?></p></div> 8 10 <?php endif; ?> 9 11 … … 22 24 wp_nonce_field('add-post'); 23 25 } else { 26 $post_ID = (int) $post_ID; 24 27 $form_action = 'editpost'; 25 28 $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />"; … … 27 30 } 28 31 29 $form_pingback = '<input type="hidden" name="post_pingback" value="' . get_option('default_pingback_flag') . '" id="post_pingback" />';30 31 $form_prevstatus = '<input type="hidden" name="prev_status" value="' . $post->post_status. '" />';32 33 $form_trackback = '<input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" value="'. str_replace("\n", ' ', $post->to_ping) .'" />';32 $form_pingback = '<input type="hidden" name="post_pingback" value="' . (int) get_option('default_pingback_flag') . '" id="post_pingback" />'; 33 34 $form_prevstatus = '<input type="hidden" name="prev_status" value="' . attribute_escape( $post->post_status ) . '" />'; 35 36 $form_trackback = '<input type="text" name="trackback_url" style="width: 415px" id="trackback" tabindex="7" value="'. attribute_escape( str_replace("\n", ' ', $post->to_ping) ) .'" />'; 34 37 35 38 if ('' != $post->pinged) { … … 42 45 } 43 46 44 $saveasdraft = '<input name="save" type="submit" id="save" tabindex="3" value="' . __('Save and Continue Editing') . '" />';47 $saveasdraft = '<input name="save" type="submit" id="save" tabindex="3" value="' . attribute_escape( __('Save and Continue Editing') ) . '" />'; 45 48 46 49 if (empty($post->post_status)) $post->post_status = 'draft'; … … 48 51 ?> 49 52 50 <input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />53 <input type="hidden" name="user_ID" value="<?php echo (int) $user_ID ?>" /> 51 54 <input type="hidden" id="hiddenaction" name="action" value="<?php echo $form_action ?>" /> 52 55 <input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" /> 53 <input type="hidden" name="post_author" value="<?php echo $post->post_author?>" />56 <input type="hidden" name="post_author" value="<?php echo attribute_escape( $post->post_author ); ?>" /> 54 57 <input type="hidden" id="post_type" name="post_type" value="post" /> 55 58 … … 89 92 <fieldset id="passworddiv" class="dbx-box"> 90 93 <h3 class="dbx-handle"><?php _e('Post Password') ?></h3> 91 <div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo $post->post_password?>" /></div>94 <div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" /></div> 92 95 </fieldset> 93 96 94 97 <fieldset id="slugdiv" class="dbx-box"> 95 98 <h3 class="dbx-handle"><?php _e('Post Slug') ?></h3> 96 <div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo $post->post_name?>" /></div>99 <div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" /></div> 97 100 </fieldset> 98 101 … … 126 129 if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"'; 127 130 else $selected = ''; 128 echo "<option value=' $o->ID' $selected>$o->display_name</option>";131 echo "<option value='" . (int) $o->ID . "' $selected>" . wp_specialchars( $o->display_name ) . "</option>"; 129 132 endforeach; 130 133 ?> … … 141 144 <fieldset id="titlediv"> 142 145 <legend><?php _e('Title') ?></legend> 143 <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo $post->post_title; ?>" id="title" /></div>146 <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape($post->post_title); ?>" id="title" /></div> 144 147 </fieldset> 145 148 … … 169 172 ?> 170 173 <?php if ( current_user_can('publish_posts') ) : ?> 171 <input name="publish" type="submit" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />174 <input name="publish" type="submit" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish'); ?>" /> 172 175 <?php endif; ?> 173 176 <?php … … 187 190 <?php 188 191 if (current_user_can('upload_files')) { 189 $uploading_iframe_ID = ( 0 == $post_ID ? $temp_ID : $post_ID);192 $uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID); 190 193 $uploading_iframe_src = wp_nonce_url("upload.php?style=inline&tab=upload&post_id=$uploading_iframe_ID", 'inlineuploading'); 191 194 $uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src); 192 195 if ( false != $uploading_iframe_src ) 193 echo '<iframe id="uploading" name="uploading"frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';196 echo '<iframe id="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>'; 194 197 } 195 198 ?> trunk/wp-admin/edit-form-comment.php
r972 r1005 3 3 $toprow_title = sprintf(__('Editing Comment # %s'), $comment->comment_ID); 4 4 $form_action = 'editedcomment'; 5 $form_extra = "' />\n<input type='hidden' name='comment_ID' value='" . $comment->comment_ID . "' />\n<input type='hidden' name='comment_post_ID' value='" .$comment->comment_post_ID;5 $form_extra = "' />\n<input type='hidden' name='comment_ID' value='" . $comment->comment_ID . "' />\n<input type='hidden' name='comment_post_ID' value='" . $comment->comment_post_ID; 6 6 ?> 7 7 … … 9 9 <?php wp_nonce_field('update-comment_' . $comment->comment_ID) ?> 10 10 <div class="wrap"> 11 <input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />11 <input type="hidden" name="user_ID" value="<?php echo (int) $user_ID ?>" /> 12 12 <input type="hidden" name="action" value='<?php echo $form_action . $form_extra ?>' /> 13 13 … … 21 21 <legend><label for="name"><?php _e('Name:') ?></label></legend> 22 22 <div> 23 <input type="text" name="newcomment_author" size="25" value="<?php echo $comment->comment_author?>" tabindex="1" id="name" />23 <input type="text" name="newcomment_author" size="25" value="<?php echo attribute_escape( $comment->comment_author ); ?>" tabindex="1" id="name" /> 24 24 </div> 25 25 </fieldset> … … 27 27 <legend><label for="email"><?php _e('E-mail:') ?></label></legend> 28 28 <div> 29 <input type="text" name="newcomment_author_email" size="20" value="<?php echo $comment->comment_author_email?>" tabindex="2" id="email" />29 <input type="text" name="newcomment_author_email" size="20" value="<?php echo attribute_escape( $comment->comment_author_email ); ?>" tabindex="2" id="email" /> 30 30 </div> 31 31 </fieldset> … … 33 33 <legend><label for="newcomment_author_url"><?php _e('URL:') ?></label></legend> 34 34 <div> 35 <input type="text" id="newcomment_author_url" name="newcomment_author_url" size="35" value="<?php echo $comment->comment_author_url?>" tabindex="3" />35 <input type="text" id="newcomment_author_url" name="newcomment_author_url" size="35" value="<?php echo attribute_escape( $comment->comment_author_url ); ?>" tabindex="3" /> 36 36 </div> 37 37 </fieldset> trunk/wp-admin/edit-form.php
r828 r1005 7 7 <input type="hidden" name="mode" value="bookmarklet" /> 8 8 <?php endif; ?> 9 <input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />9 <input type="hidden" name="user_ID" value="<?php echo (int) $user_ID ?>" /> 10 10 <input type="hidden" name="action" value='post' /> 11 11 … … 22 22 <fieldset id="titlediv"> 23 23 <legend><a href="http://wordpress.org/docs/reference/post/#title" title="<?php _e('Help on titles') ?>"><?php _e('Title') ?></a></legend> 24 <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo $post->post_title; ?>" id="title" /></div>24 <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape( $post->post_title ); ?>" id="title" /></div> 25 25 </fieldset> 26 26 … … 50 50 </script> 51 51 52 <input type="hidden" name="post_pingback" value="<?php echo get_option('default_pingback_flag') ?>" id="post_pingback" />52 <input type="hidden" name="post_pingback" value="<?php echo (int) get_option('default_pingback_flag') ?>" id="post_pingback" /> 53 53 54 54 <p><label for="trackback"> <?php printf(__('<a href="%s" title="Help on trackbacks"><strong>TrackBack</strong> a <abbr title="Universal Resource Locator">URL</abbr></a>:</label> (Separate multiple <abbr title="Universal Resource Locator">URL</abbr>s with spaces.)'), 'http://wordpress.org/docs/reference/post/#trackback'); echo '<br />'; ?> … … 65 65 echo '<input name="advanced" type="submit" id="advancededit" tabindex="7" value="' . __('Advanced Editing »') . '" />'; 66 66 } ?> 67 <input name="referredby" type="hidden" id="referredby" value="<?php if ( wp_get_referer() ) echo urlencode(wp_get_referer()); ?>" />67 <input name="referredby" type="hidden" id="referredby" value="<?php if ( $refby = wp_get_referer() ) echo urlencode($refby); ?>" /> 68 68 </p> 69 69 trunk/wp-admin/edit-link-form.php
r972 r1005 81 81 <tr> 82 82 <th scope="row" valign="top"><label for="link_name"><?php _e('Name:') ?></label></th> 83 <td><input type="text" name="link_name" id="link_name"value="<?php echo $link->link_name; ?>" style="width: 95%" /></td>83 <td><input type="text" name="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td> 84 84 </tr> 85 85 <tr> 86 86 <th width="20%" scope="row" valign="top"><label for="link_url"><?php _e('Address:') ?></label></th> 87 <td width="80%"><input type="text" name="link_url" id="link_url"value="<?php echo $link->link_url; if ( empty( $link->link_url ) ) echo 'http://'; ?>" style="width: 95%" /></td>87 <td width="80%"><input type="text" name="link_url" value="<?php echo $link->link_url; if ( empty( $link->link_url ) ) echo 'http://'; ?>" style="width: 95%" /></td> 88 88 </tr> 89 89 <tr> 90 90 <th scope="row" valign="top"><label for="link_description"><?php _e('Description:') ?></label></th> 91 <td><input type="text" name="link_description" id="link_description"value="<?php echo $link->link_description; ?>" style="width: 95%" /></td>91 <td><input type="text" name="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td> 92 92 </tr> 93 93 </table> trunk/wp-admin/edit-page-form.php
r972 r1005 3 3 <h2 id="write-post"><?php _e('Write Page'); ?></h2> 4 4 <?php 5 5 6 if (0 == $post_ID) { 6 7 $form_action = 'post'; … … 9 10 $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />"; 10 11 } else { 12 $post_ID = (int) $post_ID; 11 13 $form_action = 'editpost'; 12 14 $nonce_action = 'update-page_' . $post_ID; 13 15 $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />"; 14 16 } 17 18 $temp_ID = (int) $temp_ID; 19 $user_ID = (int) $user_ID; 15 20 16 21 $sendto = clean_url(stripslashes(wp_get_referer())); … … 69 74 <fieldset id="passworddiv" class="dbx-box"> 70 75 <h3 class="dbx-handle"><?php _e('Page Password') ?></h3> 71 <div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo $post->post_password?>" /></div>76 <div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo attribute_escape( $post->post_password ); ?>" /></div> 72 77 </fieldset> 73 78 … … 94 99 <fieldset id="slugdiv" class="dbx-box"> 95 100 <h3 class="dbx-handle"><?php _e('Page Slug') ?></h3> 96 <div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo $post->post_name?>" /></div>101 <div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo attribute_escape( $post->post_name ); ?>" /></div> 97 102 </fieldset> 98 103 … … 107 112 if ( $post->post_author == $o->ID || ( empty($post_ID) && $user_ID == $o->ID ) ) $selected = 'selected="selected"'; 108 113 else $selected = ''; 114 $o->ID = (int) $o->ID; 115 $o->display_name = wp_specialchars( $o->display_name ); 109 116 echo "<option value='$o->ID' $selected>$o->display_name</option>"; 110 117 endforeach; … … 127 134 <fieldset id="titlediv"> 128 135 <legend><?php _e('Page Title') ?></legend> 129 <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo $post->post_title; ?>" id="title" /></div>136 <div><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape( $post->post_title ); ?>" id="title" /></div> 130 137 </fieldset> 131 138 … … 164 171 $uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src); 165 172 if ( false != $uploading_iframe_src ) 166 echo '<iframe id="uploading" name="uploading"frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';173 echo '<iframe id="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>'; 167 174 } 168 175 ?> trunk/wp-admin/edit-pages.php
r972 r1005 11 11 <p><?php _e('Pages are like posts except they live outside of the normal blog chronology and can be hierarchical. You can use pages to organize and manage any amount of content.'); ?> <a href="page-new.php"><?php _e('Create a new page »'); ?></a></p> 12 12 13 <form name="searchform" id="searchform"action="" method="get">13 <form name="searchform" action="" method="get"> 14 14 <fieldset> 15 15 <legend><?php _e('Search Pages…') ?></legend> 16 <input type="text" name="s" id="s"value="<?php if (isset($_GET['s'])) echo attribute_escape($_GET['s']); ?>" size="17" />16 <input type="text" name="s" value="<?php if (isset($_GET['s'])) echo attribute_escape($_GET['s']); ?>" size="17" /> 17 17 <input type="submit" name="submit" value="<?php _e('Search') ?>" /> 18 18 </fieldset> 19 19 </form> 20 21 <br style="clear:both;" />22 20 23 21 <?php trunk/wp-admin/edit.php
r972 r1005 77 77 <fieldset> 78 78 <legend><?php _e('Search Posts…') ?></legend> 79 <input type="text" name="s" id="s"value="<?php if (isset($s)) echo attribute_escape($s); ?>" size="17" />79 <input type="text" name="s" value="<?php if (isset($s)) echo attribute_escape($s); ?>" size="17" /> 80 80 <input type="submit" name="submit" value="<?php _e('Search') ?>" class="button" /> 81 81 </fieldset> … … 197 197 ?> 198 198 <td style="text-align: center"> 199 <?php comments_number( "<a href='edit.php?p=$id&c=1'>" . __('0') . '</a>', "<a href='edit.php?p=$id&c=1'>" . __('1') . '</a>', "<a href='edit.php?p=$id&c=1'>" . __('%') . '</a>') ?>199 <?php comments_number(__('0'), "<a href='edit.php?p=$id&c=1'>" . __('1') . '</a>', "<a href='edit.php?p=$id&c=1'>" . __('%') . '</a>') ?> 200 200 </td> 201 201 <?php trunk/wp-admin/export.php
r972 r1005 149 149 --> 150 150 151 <!-- generator="wordpress/<?php bloginfo_rss('version') ?>" created="<?php echo date('Y-m-d H: m'); ?>"-->151 <!-- generator="wordpress/<?php bloginfo_rss('version') ?>" created="<?php echo date('Y-m-d H:i'); ?>"--> 152 152 <rss version="2.0" 153 153 xmlns:content="http://purl.org/rss/1.0/modules/content/" trunk/wp-admin/import/livejournal.php
r972 r1005 50 50 preg_match('|<eventtime>(.*?)</eventtime>|is', $post, $post_date); 51 51 $post_date = strtotime($post_date[1]); 52 $post_date = date('Y-m-d H:i:s', $post_date);52 $post_date = gmdate('Y-m-d H:i:s', $post_date); 53 53 54 54 preg_match('|<event>(.*?)</event>|is', $post, $post_content); trunk/wp-admin/import/textpattern.php
r972 r1005 560 560 echo '<p>'.__('Welcome to WordPress. We hope (and expect!) that you will find this platform incredibly rewarding! As a new WordPress user coming from Textpattern, there are some things that we would like to point out. Hopefully, they will help your transition go as smoothly as possible.').'</p>'; 561 561 echo '<h3>'.__('Users').'</h3>'; 562 echo '<p>'.sprintf(__('You have already setup WordPress and have been assigned an administrative login and password. Forget it. You didn ’t have that login in Textpattern, why should you have it here? Instead we have taken care to import all of your users into our system. Unfortunately there is one downside. Because both WordPress and Textpattern uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users. <strong>Every user has the same username, but their passwords are reset to password123.</strong> So <a href="%1$s">Login</a> and change it.'), get_bloginfo( 'wpurl' ) .'/wp-login.php').'</p>';562 echo '<p>'.sprintf(__('You have already setup WordPress and have been assigned an administrative login and password. Forget it. You didn\'t have that login in Textpattern, why should you have it here? Instead we have taken care to import all of your users into our system. Unfortunately there is one downside. Because both WordPress and Textpattern uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users. <strong>Every user has the same username, but their passwords are reset to password123.</strong> So <a href="%1$s">Login</a> and change it.'), '/wp-login.php').'</p>'; 563 563 echo '<h3>'.__('Preserving Authors').'</h3>'; 564 564 echo '<p>'.__('Secondly, we have attempted to preserve post authors. If you are the only author or contributor to your blog, then you are safe. In most cases, we are successful in this preservation endeavor. However, if we cannot ascertain the name of the writer due to discrepancies between database tables, we assign it to you, the administrative user.').'</p>'; 565 565 echo '<h3>'.__('Textile').'</h3>'; 566 echo '<p>'.__('Also, since you ’re coming from Textpattern, you probably have been using Textile to format your comments and posts. If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/category/development/wordpress/textile/">Textile for WordPress</a>. Trust me... You’ll want it.').'</p>';566 echo '<p>'.__('Also, since you\'re coming from Textpattern, you probably have been using Textile to format your comments and posts. If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/category/development/wordpress/textile/">Textile for WordPress</a>. Trust me... You\'ll want it.').'</p>'; 567 567 echo '<h3>'.__('WordPress Resources').'</h3>'; 568 568 echo '<p>'.__('Finally, there are numerous WordPress resources around the internet. Some of them are:').'</p>'; … … 572 572 echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>'; 573 573 echo '</ul>'; 574 echo '<p>'.sprintf(__('That ’s it! What are you waiting for? Go <a href="%1$s">login</a>!'), get_bloginfo( 'wpurl' ) .'/wp-login.php').'</p>';574 echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '/wp-login.php').'</p>'; 575 575 } 576 576 trunk/wp-admin/index.php
r972 r1005 44 44 45 45 <?php if ( $numcomments ) : ?> 46 <p><strong><a href="moderation.php"><?php echo sprintf(__('Comments in moderation (%s)'), number_format _i18n($numcomments) ); ?> »</a></strong></p>46 <p><strong><a href="moderation.php"><?php echo sprintf(__('Comments in moderation (%s)'), number_format($numcomments) ); ?> »</a></strong></p> 47 47 <?php endif; ?> 48 48 … … 104 104 $numcats = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->categories"); 105 105 106 $post_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Posts">post</a>', '%1$s <a href="%2$s" title="Posts">posts</a>', $numposts), number_format _i18n($numposts), 'edit.php');107 $comm_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Comments">comment</a>', '%1$s <a href="%2$s" title="Comments">comments</a>', $numcomms), number_format _i18n($numcomms), 'edit-comments.php');108 $cat_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Categories">category</a>', '%1$s <a href="%2$s" title="Categories">categories</a>', $numcats), number_format _i18n($numcats), 'categories.php');106 $post_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Posts">post</a>', '%1$s <a href="%2$s" title="Posts">posts</a>', $numposts), number_format($numposts), 'edit.php'); 107 $comm_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Comments">comment</a>', '%1$s <a href="%2$s" title="Comments">comments</a>', $numcomms), number_format($numcomms), 'edit-comments.php'); 108 $cat_str = sprintf(__ngettext('%1$s <a href="%2$s" title="Categories">category</a>', '%1$s <a href="%2$s" title="Categories">categories</a>', $numcats), number_format($numcats), 'categories.php'); 109 109 ?> 110 110 trunk/wp-admin/link-manager.php
r972 r1005 200 200 201 201 <?php } ?> 202 <?php203 if( wp_cache_get( "checked_bookmarks_table", "options" ) == false ) {204 $results = $wpdb->get_results( "SELECT link_id, category_id, count( * ) AS c FROM {$wpdb->link2cat} GROUP BY link_id, category_id" );205 if( $results != null ) {206 foreach( $results as $link ) {207 if( $link->c > 1 ) {208 $wpdb->query( "DELETE FROM {$wpdb->link2cat} WHERE link_id='{$link->link_id}' AND category_id='{$link->category_id}'" );209 $wpdb->query( "INSERT INTO {$wpdb->link2cat} VALUES ( 0, '{$link->link_id}', '{$link->category_id}' )" );210 }211 }212 }213 wp_cache_set( "checked_bookmarks_table", "1", "options" );214 } ?>215 202 216 203 </div> trunk/wp-admin/moderation.php
r972 r1005 124 124 <p><?php comment_date(__('M j, g:i A')); ?> — [ <?php 125 125 echo '<a href="comment.php?action=editcomment&c='.$comment->comment_ID.'">' . __('Edit') . '</a> | '; 126 echo " <a href=\"post.php?action=deletecomment&p=".$comment->comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author )) . "', theCommentList );\">" . __('Delete') . "</a> "; ?> ] —126 echo " <a href=\"post.php?action=deletecomment&p=".$comment->comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author )) . "', theCommentList );\">" . __('Delete') . "</a> | "; ?> 127 127 <?php 128 128 $post = get_post($comment->comment_post_ID); … … 130 130 $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; 131 131 ?> 132 <a href="<?php echo get_permalink($comment->comment_post_ID); ?>" ><?php echo $post_title; ?></a></p>133 <p><?php _e('Bulk action:') ?>132 <a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ] — 133 <?php _e('Bulk action:') ?> 134 134 <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-approve" value="approve" /> <label for="comment-<?php echo $comment->comment_ID; ?>-approve"><?php _e('Approve') ?></label> 135 135 <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-spam" value="spam" /> <label for="comment-<?php echo $comment->comment_ID; ?>-spam"><?php _e('Spam') ?></label> … … 183 183 <noscript> 184 184 <p> 185 <input name="feelinglucky" type="checkbox" id="feelinglucky" value="true" /> <label for="feelinglucky"><?php _e('Delete every comment marked “defer.”<strong>Warning: This can’t be undone.</strong>'); ?></label>185 <input name="feelinglucky" type="checkbox" id="feelinglucky" value="true" /> <label for="feelinglucky"><?php _e('Delete every comment marked "defer." <strong>Warning: This can’t be undone.</strong>'); ?></label> 186 186 </p> 187 187 </noscript> trunk/wp-admin/options-reading.php
r873 r1005 6 6 7 7 include('admin-header.php'); 8 9 // Sanity checks10 if ( 'page' == get_option('show_on_front') ) {11 $front_page = get_option('page_on_front');12 if ( empty($front_page) ) {13 update_option('show_on_front', 'posts');14 delete_option('page_for_posts');15 delete_option('page_on_front');16 }17 }18 8 ?> 19 9 trunk/wp-admin/plugins.php
r981 r1005 139 139 if ( $style != '' ) 140 140 $style = 'class="' . $style . '"'; 141 $edit = ''; 141 if ( is_writable(ABSPATH . PLUGINDIR . '/' . $plugin_file) ) 142 $edit = "<a href='plugin-editor.php?file=$plugin_file' title='".__('Open this file in the Plugin Editor')."' class='edit'>".__('Edit')."</a>"; 143 else 144 $edit = ''; 142 145 143 146 echo " trunk/wp-admin/post-new.php
r972 r1005 11 11 if ( ! current_user_can('edit_posts') ) { ?> 12 12 <div class="wrap"> 13 <p><?php printf(__('Since you’re a newcomer, you’ll have to wait for an admin to add the <code>edit_posts</code> capability to your user, in order to be authorized to post.<br />13 <p><?php printf(__('Since you’re a newcomer, you’ll have to wait for an admin to raise your level to 1, in order to be authorized to post.<br /> 14 14 You can also <a href="mailto:%s?subject=Promotion?">e-mail the admin</a> to ask for a promotion.<br /> 15 15 When you’re promoted, just reload this page and you’ll be able to blog. :)'), get_option('admin_email')); ?> … … 58 58 <div id="wp-bookmarklet" class="wrap"> 59 59 <h3><?php _e('WordPress Bookmarklet'); ?></h3> 60 <p><?php _e('Right click on the following link and choose “Bookmark This Link...” or “Add to Favorites...”to create a posting shortcut.'); ?></p>60 <p><?php _e('Right click on the following link and choose "Add to favorites" to create a posting shortcut.'); ?></p> 61 61 <p> 62 62 trunk/wp-admin/upgrade-functions.php
r992 r1005 176 176 upgrade_130(); 177 177 } 178 179 maybe_disable_automattic_widgets(); 178 180 179 181 if ( $wp_current_db_version < 3308 ) … … 185 187 if ( $wp_current_db_version < 4351 ) 186 188 upgrade_old_slugs(); 187 188 maybe_disable_automattic_widgets();189 189 190 190 $wp_rewrite->flush_rules(); trunk/wp-admin/user-edit.php
r972 r1005 83 83 <?php wp_nonce_field('update-user_' . $user_id) ?> 84 84 <?php if ( $wp_http_referer ) : ?> 85 <input type="hidden" name="wp_http_referer" value="<?php echo wp_specialchars($wp_http_referer); ?>" />85 <input type="hidden" name="wp_http_referer" value="<?php echo clean_url($wp_http_referer); ?>" /> 86 86 <?php endif; ?> 87 87 <p> trunk/wp-admin/users.php
r938 r1005 512 512 <th colspan="7"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th> 513 513 <?php else : ?> 514 <th colspan="7"><h3><em><?php _e('No role for this blog'); ?></ h3></th>514 <th colspan="7"><h3><em><?php _e('No role for this blog'); ?></em></h3></th> 515 515 <?php endif; ?> 516 516 </tr> trunk/wp-admin/widgets.php
r972 r1005 69 69 //for ( var n in Draggables.drags ) { 70 70 for ( n=0; n<=Draggables.drags.length; n++ ) { 71 if ( Draggables.drags[n].element.id == 'lastmodule' ) { 72 Draggables.drags[n].destroy(); 73 break; 71 if ( parseInt( n ) ) { 72 if ( Draggables.drags[n].element.id == 'lastmodule' ) { 73 Draggables.drags[n].destroy(); 74 break; 75 } 74 76 } 75 77 } trunk/wp-admin/wp-admin.css
r972 r1005 121 121 122 122 a:hover { 123 /* border-bottom: 1px solid #3a75ae;*/ 123 124 color: #069; 124 125 } … … 132 133 133 134 body, td { 134 font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana , sans-serif;135 font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana; 135 136 } 136 137 … … 170 171 171 172 h2 { 173 border-bottom: .5em solid #e5f3ff; 172 174 color: #333; 173 font: normal 32px serif;175 font: normal 32px/5px serif; 174 176 margin: 5px 10px; 175 background: url( images/heading-bg.gif ) repeat-x bottom;176 177 } 177 178 … … 437 438 438 439 .wrap h2 { 439 margin: 00 .5em;440 margin: .4em 0 .5em; 440 441 clear: both; 441 442 } … … 538 539 } 539 540 540 #postdiv, #titlediv, #guiddiv , #tagdiv{541 #postdiv, #titlediv, #guiddiv { 541 542 margin: 0 8px 0 0; 542 543 padding: 0; … … 558 559 } 559 560 560 #titlediv input, #guiddiv input , #tagdiv input{561 #titlediv input, #guiddiv input { 561 562 margin: 0; 562 563 width: 100%; … … 912 913 913 914 #zeitgeist h2, fieldset legend a { 914 b ackground: none;915 border-bottom: none; 915 916 } 916 917 917 918 * html #zeitgeist h2 { 918 919 padding-top: 10px; 920 } 921 922 #zeitgeist h2 { 923 margin-top: .4em; 919 924 } 920 925 trunk/wp-config-sample.php
r995 r1005 19 19 // chosen language must be installed to wp-content/languages. 20 20 // For example, install de.mo to wp-content/languages and set WPLANG to 'de' 21 // to enable language support.21 // to enable German language support. 22 22 define('WPLANG', ''); 23 23 // uncomment this to enable wp-content/sunrise.php support trunk/wp-content/themes/classic/style.css
r972 r1005 49 49 body { 50 50 background: #fff; 51 border: 2px solid#565;52 border-bottom: 1px solid#565;53 border-top: 3px solid#565;51 border: solid 2px #565; 52 border-bottom: solid 1px #565; 53 border-top: solid 3px #565; 54 54 color: #000; 55 55 font-family: 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif; … … 72 72 73 73 h3 { 74 border-bottom: 1px dotted#eee;74 border-bottom: dotted 1px #eee; 75 75 font-family: "Times New Roman", Times, serif; 76 76 margin-top: 0; … … 97 97 .credit { 98 98 background: #90a090; 99 border-top: 3px double#aba;99 border-top: double 3px #aba; 100 100 color: #fff; 101 101 font-size: 11px; … … 167 167 #header { 168 168 background: #90a090; 169 border-bottom: 3px double#aba;170 border-left: 1px solid#9a9;171 border-right: 1px solid#565;172 border-top: 1px solid#9a9;169 border-bottom: double 3px #aba; 170 border-left: solid 1px #9a9; 171 border-right: solid 1px #565; 172 border-top: solid 1px #9a9; 173 173 font: italic normal 230% 'Times New Roman', Times, serif; 174 174 letter-spacing: 0.2em; … … 189 189 background: #fff; 190 190 border-left: 1px dotted #ccc; 191 border-top: 3px solid#e0e6e0;191 border-top: solid 3px #e0e6e0; 192 192 padding: 20px 0 10px 30px; 193 193 position: absolute; trunk/wp-content/themes/default/archive.php
r972 r1005 5 5 <?php if (have_posts()) : ?> 6 6 7 <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>8 <?php /* If this is a category archive */ if (is_category()) { ?>7 <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?> 8 <?php /* If this is a category archive */ if (is_category()) { ?> 9 9 <h2 class="pagetitle">Archive for the ‘<?php single_cat_title(); ?>’ Category</h2> 10 10 11 11 <?php /* If this is a daily archive */ } elseif (is_day()) { ?> 12 12 <h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2> 13 <?php /* If this is a monthly archive */ } elseif (is_month()) { ?> 13 14 <?php /* If this is a monthly archive */ } elseif (is_month()) { ?> 14 15 <h2 class="pagetitle">Archive for <?php the_time('F, Y'); ?></h2> 15 <?php /* If this is a yearly archive */ } elseif (is_year()) { ?> 16 17 <?php /* If this is a yearly archive */ } elseif (is_year()) { ?> 16 18 <h2 class="pagetitle">Archive for <?php the_time('Y'); ?></h2> 19 17 20 <?php /* If this is an author archive */ } elseif (is_author()) { ?> 18 21 <h2 class="pagetitle">Author Archive</h2> 19 <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?> 22 23 <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?> 20 24 <h2 class="pagetitle">Blog Archives</h2> 21 <?php } ?> 25 26 <?php } ?> 22 27 23 28 trunk/wp-content/themes/default/functions.php
r972 r1005 385 385 </div> 386 386 <div id="jsForm"> 387 <form style="display:inline;" method="post" name="hicolor" id="hicolor" action="<?php echo $_SERVER['REQUEST_URI']; ?>">387 <form style="display:inline;" method="post" name="hicolor" id="hicolor" action="<?php echo attribute_escape($_SERVER['REQUEST_URI']); ?>"> 388 388 <?php wp_nonce_field('kubrick-header'); ?> 389 389 <input type="button" onclick="tgt=document.getElementById('fontcolor');colorSelect(tgt,'pick1');return false;" name="pick1" id="pick1" value="<?php echo attribute_escape(__('Font Color')); ?>"></input> trunk/wp-content/themes/default/sidebar.php
r972 r1005 3 3 <?php /* Widgetized sidebar, if you have the plugin installed. */ 4 4 if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?> 5 <?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar() ) : ?>6 7 </ul>8 </div>9 <?php return; ?>10 11 <?php endif; ?>12 13 5 <li> 14 6 <?php include (TEMPLATEPATH . '/searchform.php'); ?> trunk/wp-includes/author-template.php
r972 r1005 176 176 global $wpdb; 177 177 178 $defaults = array( 179 'optioncount' => false, 'exclude_admin' => true, 180 'show_fullname' => false, 'hide_empty' => true, 181 'feed' => '', 'feed_image' => '' 182 ); 183 184 $r = wp_parse_args( $args, $defaults ); 185 extract($r); 178 if ( is_array($args) ) 179 $r = &$args; 180 else 181 parse_str($args, $r); 182 183 $defaults = array('optioncount' => false, 'exclude_admin' => true, 'show_fullname' => false, 'hide_empty' => true, 184 'feed' => '', 'feed_image' => ''); 185 $r = array_merge($defaults, $r); 186 extract($r, EXTR_SKIP); 186 187 187 188 // TODO: Move select to get_authors(). trunk/wp-includes/bookmark-template.php
r972 r1005 10 10 function wp_get_links($args = '') { 11 11 global $wpdb; 12 13 if ( strpos( $args, '=' ) === false ) { 12 13 if ( empty($args) ) 14 return; 15 16 if ( false === strpos($args, '=') ) { 14 17 $cat_id = $args; 15 $args = add_query_arg( 'category', $cat_id, $args ); 16 } 17 18 $defaults = array( 19 'category' => -1, 'before' => '', 20 'after' => '<br />', 'between' => ' ', 21 'show_images' => true, 'orderby' => 'name', 22 'show_description' => true, 'show_rating' => false, 23 'limit' => -1, 'show_updated' => true, 24 'echo' => true 25 ); 26 27 $r = wp_parse_args( $args, $defaults ); 28 extract( $r ); 18 $args = add_query_arg('category', $cat_id, $args); 19 } 20 21 parse_str($args); 22 23 if ( !isset($category) ) $category = -1; 24 if ( !isset($before) ) $before = ''; 25 if ( !isset($after) ) $after = '<br />'; 26 if ( !isset($between) ) $between = ' '; 27 if ( !isset($show_images) ) $show_images = true; 28 if ( !isset($orderby) ) $orderby = 'name'; 29 if ( !isset($show_description) ) $show_description = true; 30 if ( !isset($show_rating) ) $show_rating = false; 31 if ( !isset($limit) ) $limit = -1; 32 if ( !isset($show_updated) ) $show_updated = 1; 33 if ( !isset($echo) ) $echo = true; 29 34 30 35 return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo); … … 241 246 242 247 function _walk_bookmarks($bookmarks, $args = '' ) { 243 $defaults = array( 244 'show_updated' => 0, 'show_description' => 0, 245 'show_images' => 1, 'before' => '<li>', 246 'after' => '</li>', 'between' => "\n" 247 ); 248 249 $r = wp_parse_args( $args, $defaults ); 250 extract( $r ); 248 if ( is_array($args) ) 249 $r = &$args; 250 else 251 parse_str($args, $r); 252 253 $defaults = array('show_updated' => 0, 'show_description' => 0, 'show_images' => 1, 'before' => '<li>', 254 'after' => '</li>', 'between' => "\n"); 255 $r = array_merge($defaults, $r); 256 extract($r, EXTR_SKIP); 251 257 252 258 foreach ( (array) $bookmarks as $bookmark ) { … … 315 321 316 322 function wp_list_bookmarks($args = '') { 317 $defaults = array( 318 'orderby' => 'name', 'order' => 'ASC', 319 'limit' => -1, 'category' => '', 320 'category_name' => '', 'hide_invisible' => 1, 321 'show_updated' => 0, 'echo' => 1, 322 'categorize' => 1, 'title_li' => __('Bookmarks'), 323 'title_before' => '<h2>', 'title_after' => '</h2>', 324 'category_orderby' => 'name', 'category_order' => 'ASC', 325 'class' => 'linkcat', 'category_before' => '<li id="%id" class="%class">', 326 'category_after' => '</li>' 327 ); 328 329 $r = wp_parse_args( $args, $defaults ); 330 extract( $r ); 323 if ( is_array($args) ) 324 $r = &$args; 325 else 326 parse_str($args, $r); 327 328 $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => '', 329 'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'echo' => 1, 330 'categorize' => 1, 'title_li' => __('Bookmarks'), 'title_before' => '<h2>', 'title_after' => '</h2>', 331 'category_orderby' => 'name', 'category_order' => 'ASC', 'class' => 'linkcat', 332 'category_before' => '<li id="%id" class="%class">', 'category_after' => '</li>'); 333 $r = array_merge($defaults, $r); 334 extract($r, EXTR_SKIP); 331 335 332 336 $output = ''; trunk/wp-includes/bookmark.php
r972 r1005 26 26 function get_bookmarks($args = '') { 27 27 global $wpdb; 28 29 $defaults = array( 30 'orderby' => 'name', 'order' => 'ASC', 31 'limit' => -1, 'category' => '', 32 'category_name' => '', 'hide_invisible' => 1, 33 'show_updated' => 0, 'include' => '', 34 'exclude' => '' 35 ); 36 37 $r = wp_parse_args( $args, $defaults ); 38 extract( $r ); 28 29 if ( is_array($args) ) 30 $r = &$args; 31 else 32 parse_str($args, $r); 33 34 $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => '', 35 'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'include' => '', 'exclude' => ''); 36 $r = array_merge($defaults, $r); 37 extract($r, EXTR_SKIP); 39 38 40 39 $key = md5( serialize( $r ) ); trunk/wp-includes/category-template.php
r972 r1005 85 85 function _get_the_category_usort($a, $b) { 86 86 return strcmp($a->category_name, $b->category_name); 87 } 88 89 function _get_the_category_usort_by_ID($a, $b) { 90 if ( $a->cat_ID > $b->cat_ID ) 91 return 1; 92 elseif ( $a->cat_ID < $b->cat_ID ) 93 return -1; 94 else 95 return 0; 87 96 } 88 97 … … 173 182 174 183 function wp_dropdown_categories($args = '') { 175 $defaults = array(176 'show_option_all' => '', 'show_option_none' => '',177 'orderby' => 'ID', 'order' => 'ASC',178 'show_last_update' => 0, 'show_count' => 0,179 'hide_empty' => 1, 'child_of' => 0, 180 'exclude' => '', 'echo' => 1,181 ' selected' => 0, 'hierarchical' => 0,182 ' name' => 'cat', 'class' => 'postform'183 );184 184 if ( is_array($args) ) 185 $r = &$args; 186 else 187 parse_str($args, $r); 188 189 $defaults = array('show_option_all' => '', 'show_option_none' => '', 'orderby' => 'ID', 190 'order' => 'ASC', 'show_last_update' => 0, 'show_count' => 0, 191 'hide_empty' => 1, 'child_of' => 0, 'exclude' => '', 'echo' => 1, 192 'selected' => 0, 'hierarchical' => 0, 'name' => 'cat', 193 'class' => 'postform'); 185 194 $defaults['selected'] = ( is_category() ) ? get_query_var('cat') : 0; 186 187 $r = wp_parse_args( $args, $defaults ); 195 $r = array_merge($defaults, $r); 188 196 $r['include_last_update_time'] = $r['show_last_update']; 189 extract( $r);197 extract($r, EXTR_SKIP); 190 198 191 199 $categories = get_categories($r); … … 223 231 224 232 function wp_list_categories($args = '') { 225 $defaults = array( 226 'show_option_all' => '', 'orderby' => 'name', 227 'order' => 'ASC', 'show_last_update' => 0, 228 'style' => 'list', 'show_count' => 0, 229 'hide_empty' => 1, 'use_desc_for_title' => 1, 230 'child_of' => 0, 'feed' => '', 231 'feed_image' => '', 'exclude' => '', 232 'hierarchical' => true, 'title_li' => __('Categories') 233 ); 234 235 $r = wp_parse_args( $args, $defaults ); 236 237 if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) { 233 if ( is_array($args) ) 234 $r = &$args; 235 else 236 parse_str($args, $r); 237 238 $defaults = array('show_option_all' => '', 'orderby' => 'name', 239 'order' => 'ASC', 'show_last_update' => 0, 'style' => 'list', 240 'show_count' => 0, 'hide_empty' => 1, 'use_desc_for_title' => 1, 241 'child_of' => 0, 'feed' => '', 'feed_image' => '', 'exclude' => '', 242 'hierarchical' => true, 'title_li' => __('Categories')); 243 $r = array_merge($defaults, $r); 244 if ( !isset($r['pad_counts']) && $r['show_count'] && $r['hierarchical'] ) 238 245 $r['pad_counts'] = true; 239 } 240 241 if ( isset( $r['show_date'] ) ) { 246 if ( isset($r['show_date']) ) 242 247 $r['include_last_update_time'] = $r['show_date']; 243 } 244 245 extract( $r ); 246 248 extract($r, EXTR_SKIP); 249 247 250 $categories = get_categories($r); 248 251 trunk/wp-includes/category.php
r972 r1005 6 6 if ( ! $cat_ids = wp_cache_get('all_category_ids', 'category') ) { 7 7 $cat_ids = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories"); 8 wp_cache_ set('all_category_ids', $cat_ids, 'category');8 wp_cache_add('all_category_ids', $cat_ids, 'category'); 9 9 } 10 10 … … 14 14 function &get_categories($args = '') { 15 15 global $wpdb, $category_links; 16 17 $defaults = array( 18 'type' => 'post', 'child_of' => 0, 19 'orderby' => 'name', 'order' => 'ASC', 20 'hide_empty' => true, 'include_last_update_time' => false, 21 'hierarchical' => 1, 'exclude' => '', 22 'include' => '', 'number' => '', 23 'pad_counts' => false 24 ); 25 26 $r = wp_parse_args( $args, $defaults ); 27 28 if ( $r['orderby'] == 'count' ) { 16 17 if ( is_array($args) ) 18 $r = &$args; 19 else 20 parse_str($args, $r); 21 22 $defaults = array('type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC', 23 'hide_empty' => true, 'include_last_update_time' => false, 'hierarchical' => 1, 'exclude' => '', 'include' => '', 24 'number' => '', 'pad_counts' => false); 25 $r = array_merge($defaults, $r); 26 if ( 'count' == $r['orderby'] ) 29 27 $r['orderby'] = 'category_count'; 30 } else { 31 $r['orderby'] = 'cat_' . $r['orderby']; 32 } 33 34 extract( $r ); 28 else 29 $r['orderby'] = "cat_" . $r['orderby']; // restricts order by to cat_ID and cat_name fields 30 $r['number'] = (int) $r['number']; 31 extract($r, EXTR_SKIP); 35 32 36 33 $key = md5( serialize( $r ) ); … … 83 80 } 84 81 85 86 87 82 if ( !empty($number) ) 88 83 $number = 'LIMIT ' . $number; … … 138 133 139 134 $cache[ $key ] = $categories; 140 wp_cache_ set( 'get_categories', $cache, 'category' );135 wp_cache_add( 'get_categories', $cache, 'category' ); 141 136 142 137 $categories = apply_filters('get_categories', $categories, $r); … … 159 154 if ( ! $_category = wp_cache_get($category, 'category') ) { 160 155 $_category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$category' LIMIT 1"); 161 wp_cache_ set($category, $_category, 'category');156 wp_cache_add($category, $_category, 'category'); 162 157 } 163 158 } … … 212 207 } 213 208 214 function get_category_by_slug( $slug ) {215 global $wpdb;216 $slug = sanitize_title( $slug );217 if ( empty( $slug ) )218 return false;219 $category = $wpdb->get_var( "SELECT * FROM $wpdb->categories WHERE category_nicename = '$slug' " );220 return get_category( $category );221 }222 223 209 // Get the ID of a category from its name 224 210 function get_cat_ID($cat_name='General') { … … 343 329 return $children; 344 330 } 345 346 331 ?> trunk/wp-includes/class-phpmailer.php
r972 r1005 391 391 function SendmailSend($header, $body) { 392 392 if ($this->Sender != "") 393 $sendmail = sprintf("%s -oi -f %s -t", $this->Sendmail, $this->Sender);393 $sendmail = sprintf("%s -oi -f %s -t", $this->Sendmail, escapeshellarg($this->Sender)); 394 394 else 395 395 $sendmail = sprintf("%s -oi -t", $this->Sendmail); trunk/wp-includes/class-snoopy.php
r972 r1005 797 797 if(!empty($this->host) && !isset($this->rawheaders['Host'])) { 798 798 $headers .= "Host: ".$this->host; 799 if(!empty($this->port) && $this->port != 80)799 if(!empty($this->port)) 800 800 $headers .= ":".$this->port; 801 801 $headers .= "\r\n"; trunk/wp-includes/classes.php
r972 r1005 507 507 if ( $depth ) 508 508 $indent = str_repeat("\t", $depth); 509 extract($args );509 extract($args, EXTR_SKIP); 510 510 $css_class = 'page_item'; 511 511 $_current_page = get_page( $current_page ); … … 688 688 // a WP_Error object can be passed in 'id' or 'data' 689 689 function add( $args = '' ) { 690 $defaults = array( 691 'what' => 'object', 'action' => false, 692 'id' => '0', 'old_id' => false, 693 'data' => '', 'supplemental' => array() 694 ); 695 696 $r = wp_parse_args( $args, $defaults ); 697 extract( $r ); 690 if ( is_array($args) ) 691 $r = &$args; 692 else 693 parse_str($args, $r); 694 695 $defaults = array('what' => 'object', 'action' => false, 'id' => '0', 'old_id' => false, 696 'data' => '', 'supplemental' => array()); 697 698 $r = array_merge($defaults, $r); 699 extract($r, EXTR_SKIP); 698 700 699 701 if ( is_wp_error($id) ) { trunk/wp-includes/comment-template.php
r972 r1005 240 240 function trackback_rdf($timezone = 0) { 241 241 global $id; 242 if (str pos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') !== false) {242 if (stripos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') === false) { 243 243 echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 244 244 xmlns:dc="http://purl.org/dc/elements/1.1/" … … 286 286 $req = get_option('require_name_email'); 287 287 $commenter = wp_get_current_commenter(); 288 extract($commenter );288 extract($commenter, EXTR_SKIP); 289 289 290 290 // TODO: Use API instead of SELECTs. trunk/wp-includes/comment.php
r972 r1005 74 74 global $comment_cache, $wpdb; 75 75 76 if ( empty($comment) ) { 77 if ( isset($GLOBALS['comment']) ) 78 $_comment = & $GLOBALS['comment']; 79 else 80 $_comment = null; 81 } elseif ( is_object($comment) ) { 76 if ( empty($comment) ) 77 return null; 78 79 if ( is_object($comment) ) { 82 80 if ( !isset($comment_cache[$comment->comment_ID]) ) 83 81 $comment_cache[$comment->comment_ID] = &$comment; … … 85 83 } else { 86 84 $comment = (int) $comment; 87 if ( isset($GLOBALS['comment']) && ($GLOBALS['comment']->comment_ID == $comment) ) { 88 $_comment = & $GLOBALS['comment']; 89 } elseif ( !isset($comment_cache[$comment]) ) { 85 if ( !isset($comment_cache[$comment]) ) { 90 86 $_comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment' LIMIT 1"); 91 87 $comment_cache[$comment->comment_ID] = & $_comment; … … 183 179 function wp_allow_comment($commentdata) { 184 180 global $wpdb; 185 extract($commentdata );181 extract($commentdata, EXTR_SKIP); 186 182 187 183 // Simple duplicate check … … 330 326 function wp_insert_comment($commentdata) { 331 327 global $wpdb; 332 extract($commentdata );328 extract($commentdata, EXTR_SKIP); 333 329 334 330 if ( ! isset($comment_author_IP) ) … … 462 458 463 459 // Now extract the merged array. 464 extract($commentarr );460 extract($commentarr, EXTR_SKIP); 465 461 466 462 $comment_content = apply_filters('comment_save_pre', $comment_content); … … 522 518 $pingback_href_original_pos = 27; 523 519 524 extract(parse_url($url) );520 extract(parse_url($url), EXTR_SKIP); 525 521 526 522 if ( !isset($host) ) // Not an URL. This should never happen. … … 677 673 678 674 // original code by Mort (http://mort.mine.nu:8080) 675 $log = debug_fopen(ABSPATH . '/pingback.log', 'a'); 679 676 $post_links = array(); 677 debug_fwrite($log, 'BEGIN ' . date('YmdHis', time()) . "\n"); 680 678 681 679 $pung = get_pung($post_ID); … … 692 690 // http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php 693 691 preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp); 692 693 // Debug 694 debug_fwrite($log, 'Post contents:'); 695 debug_fwrite($log, $content."\n"); 694 696 695 697 // Step 2. … … 716 718 717 719 foreach ( (array) $post_links as $pagelinkedto ) { 720 debug_fwrite($log, "Processing -- $pagelinkedto\n"); 718 721 $pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048); 719 722 … … 721 724 @ set_time_limit( 60 ); 722 725 // Now, the RPC call 726 debug_fwrite($log, "Page Linked To: $pagelinkedto \n"); 727 debug_fwrite($log, 'Page Linked From: '); 723 728 $pagelinkedfrom = get_permalink($post_ID); 729 debug_fwrite($log, $pagelinkedfrom."\n"); 724 730 725 731 // using a timeout of 3 seconds should be enough to cover slow servers … … 733 739 if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto ) ) 734 740 add_ping( $post_ID, $pagelinkedto ); 735 } 736 } 741 else 742 debug_fwrite($log, "Error.\n Fault code: ".$client->getErrorCode()." : ".$client->getErrorMessage()."\n"); 743 } 744 } 745 746 debug_fwrite($log, "\nEND: ".time()."\n****************************\n"); 747 debug_fclose($log); 737 748 } 738 749 … … 771 782 $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4); 772 783 @fputs($fs, $http_request); 784 /* 785 $debug_file = 'trackback.log'; 786 $fp = fopen($debug_file, 'a'); 787 fwrite($fp, "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n"); 788 while(!@feof($fs)) { 789 fwrite($fp, @fgets($fs, 4096)); 790 } 791 fwrite($fp, "\n\n"); 792 fclose($fp); 793 */ 773 794 @fclose($fs); 774 795 trunk/wp-includes/compat.php
r972 r1005 74 74 * @author Stephan Schmidt <schst@php.net> 75 75 * @author Aidan Lister <aidan@php.net> 76 * @version $Revision: 4495$76 * @version $Revision: 5187 $ 77 77 * @since PHP 4.2.0 78 78 * @require PHP 4.0.0 (user_error) trunk/wp-includes/deprecated.php
r972 r1005 428 428 429 429 function wp_list_cats($args = '') { 430 $r = wp_parse_args( $args ); 430 if ( is_array($args) ) 431 $r = &$args; 432 else 433 parse_str($args, $r); 431 434 432 435 // Map to new names. trunk/wp-includes/feed-atom-comments.php
r972 r1005 41 41 } 42 42 ?></title> 43 <link rel="alternate" href="<?php comment_link(); ?>" type="<?php bloginfo_rss(' content_type'); ?>" />43 <link rel="alternate" href="<?php comment_link(); ?>" type="<?php bloginfo_rss('html_type'); ?>" /> 44 44 45 45 <author> trunk/wp-includes/feed.php
r972 r1005 152 152 $the_list = ''; 153 153 foreach ( (array) $categories as $category ) { 154 $cat egory->cat_name = convert_chars($category->cat_name);154 $cat_name = convert_chars($category->cat_name); 155 155 if ( 'rdf' == $type ) 156 $the_list .= "\n\t\t<dc:subject><![CDATA[$cat egory->cat_name]]></dc:subject>\n";156 $the_list .= "\n\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n"; 157 157 if ( 'atom' == $type ) 158 $the_list .= "<category scheme='$home' term='$category->cat_name' />";158 $the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', attribute_escape( apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ) ), attribute_escape( $category->cat_name ) ); 159 159 else 160 $the_list .= "\n\t\t<category><![CDATA[$cat egory->cat_name]]></category>\n";160 $the_list .= "\n\t\t<category><![CDATA[$cat_name]]></category>\n"; 161 161 } 162 162 return apply_filters('the_category_rss', $the_list, $type); trunk/wp-includes/formatting.php
r972 r1005 1104 1104 function js_escape($text) { 1105 1105 $safe_text = wp_specialchars($text, 'double'); 1106 $safe_text = str_replace(''', "'", $safe_text);1106 $safe_text = preg_replace('/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes($safe_text)); 1107 1107 $safe_text = preg_replace("/\r?\n/", "\\n", addslashes($safe_text)); 1108 1108 return apply_filters('js_escape', $safe_text, $text); … … 1119 1119 } 1120 1120 1121 function wp_parse_str( $string, &$array ) { 1122 parse_str( $string, $array ); 1123 if ( get_magic_quotes_gpc() ) 1124 $array = stripslashes_deep( $array ); // parse_str() adds slashes if magicquotes is on. See: http://php.net/parse_str 1125 $array = apply_filters( 'wp_parse_str', $array ); 1126 } 1127 1121 1128 ?> trunk/wp-includes/functions.php
r1003 r1005 82 82 $j = @date($dateformatstring, $i); 83 83 return $j; 84 }85 86 function number_format_i18n($number, $decimals = null) {87 global $wp_locale;88 // let the user override the precision only89 $decimals = is_null($decimals)? $wp_locale->number_format['decimals'] : intval($decimals);90 91 return number_format($number, $decimals, $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep']);92 84 } 93 85 … … 779 771 $ret = ''; 780 772 if ( is_array(func_get_arg(0)) ) { 781 if ( @func_num_args() < 2 || ''== @func_get_arg(1) )773 if ( @func_num_args() < 2 || false === @func_get_arg(1) ) 782 774 $uri = $_SERVER['REQUEST_URI']; 783 775 else 784 776 $uri = @func_get_arg(1); 785 777 } else { 786 if ( @func_num_args() < 3 || ''== @func_get_arg(2) )778 if ( @func_num_args() < 3 || false === @func_get_arg(2) ) 787 779 $uri = $_SERVER['REQUEST_URI']; 788 780 else … … 819 811 } 820 812 821 parse_str($query, $qs); 822 if ( get_magic_quotes_gpc() ) 823 $qs = stripslashes_deep($qs); // parse_str() adds slashes if magicquotes is on. See: http://php.net/parse_str 813 wp_parse_str($query, $qs); 824 814 $qs = urlencode_deep($qs); 825 815 if ( is_array(func_get_arg(0)) ) { … … 842 832 $ret = trim($ret, '?'); 843 833 $ret = $protocol . $base . $ret . $frag; 844 $ret = trim($ret, '?');834 $ret = rtrim($ret, '?'); 845 835 return $ret; 846 836 } … … 856 846 */ 857 847 858 function remove_query_arg($key, $query= '') {848 function remove_query_arg($key, $query=FALSE) { 859 849 if ( is_array($key) ) { // removing multiple keys 860 850 foreach ( (array) $key as $k ) … … 919 909 } 920 910 921 function get_status_header_desc( $code ) {922 global $wp_header_to_desc;923 924 $code = (int) $code;925 926 if ( isset( $wp_header_to_desc[$code] ) ) {927 return $wp_header_to_desc[$code];928 } else {929 return '';930 }931 }932 933 911 function status_header( $header ) { 934 $text = get_status_header_desc( $header ); 935 936 if ( empty( $text ) ) 937 return false; 912 if ( 200 == $header ) 913 $text = 'OK'; 914 elseif ( 301 == $header ) 915 $text = 'Moved Permanently'; 916 elseif ( 302 == $header ) 917 $text = 'Moved Temporarily'; 918 elseif ( 304 == $header ) 919 $text = 'Not Modified'; 920 elseif ( 404 == $header ) 921 $text = 'Not Found'; 922 elseif ( 410 == $header ) 923 $text = 'Gone'; 938 924 939 925 $protocol = $_SERVER["SERVER_PROTOCOL"]; … … 1217 1203 'pdf' => 'application/pdf', 1218 1204 'doc' => 'application/msword', 1219 'odt' => 'application/vnd.oasis.opendocument.text',1220 1205 'pot|pps|ppt' => 'application/vnd.ms-powerpoint', 1221 1206 'wri' => 'application/vnd.ms-write', … … 1505 1490 1506 1491 function wp_parse_args( $args, $defaults = '' ) { 1507 if ( is_array( $args ) ) {1492 if ( is_array( $args ) ) 1508 1493 $r =& $args; 1509 } else { 1510 parse_str( $args, $r ); 1511 if ( get_magic_quotes_gpc() ) { 1512 $r = stripslashes_deep( $r ); 1513 } 1514 } 1515 1516 if ( is_array( $defaults ) ) { 1494 else 1495 wp_parse_str( $args, $r ); 1496 1497 if ( is_array( $defaults ) ) 1517 1498 return array_merge( $defaults, $r ); 1518 } else {1499 else 1519 1500 return $r; 1520 }1521 1501 } 1522 1502 trunk/wp-includes/general-template.php
r972 r1005 64 64 65 65 // Don't filter URL's. 66 if (strpos($show, 'url') === false ||67 strpos($show, 'directory') === false ||66 if (strpos($show, 'url') === false && 67 strpos($show, 'directory') === false && 68 68 strpos($show, 'home') === false) { 69 69 $info = apply_filters('bloginfo', $info, $show); … … 110 110 case 'comments_atom_url': 111 111 $output = get_feed_link('comments_atom'); 112 break; 112 113 case 'comments_rss2_url': 113 114 $output = get_feed_link('comments_rss2'); … … 218 219 if ( is_single() || is_page() ) { 219 220 $post = $wp_query->get_queried_object(); 220 $title = apply_filters('single_post_title', $title); 221 $title = strip_tags($post->post_title); 221 $title = strip_tags( apply_filters( 'single_post_title', $post->post_title ) ); 222 222 } 223 223 … … 314 314 315 315 function wp_get_archives($args = '') { 316 global $wp db, $wp_locale;317 318 $defaults = array(319 'type' => 'monthly', 'limit' => '',320 'format' => 'html', 'before' => '',321 'after' => '', 'show_post_count' => false322 ); 323 324 $r = wp_parse_args( $args, $defaults);325 extract( $r);316 global $wp_locale, $wpdb; 317 318 if ( is_array($args) ) 319 $r = &$args; 320 else 321 parse_str($args, $r); 322 323 $defaults = array('type' => 'monthly', 'limit' => '', 'format' => 'html', 'before' => '', 'after' => '', 'show_post_count' => false); 324 $r = array_merge($defaults, $r); 325 extract($r, EXTR_SKIP); 326 326 327 327 if ( '' == $type ) … … 901 901 edCanvas = document.getElementById('<?php echo $id; ?>'); 902 902 <?php if ( $prev_id && user_can_richedit() ) : ?> 903 // If tinyMCE is defined. 904 if ( typeof tinyMCE != 'undefined' ) { 903 905 // This code is meant to allow tabbing from Title to Post (TinyMCE). 904 if ( tinyMCE.isMSIE ) 905 document.getElementById('<?php echo $prev_id; ?>').onkeydown = function (e) 906 { 906 if ( tinyMCE.isMSIE ) { 907 document.getElementById('<?php echo $prev_id; ?>').onkeydown = function (e) { 907 908 e = e ? e : window.event; 908 909 if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) { … … 917 918 } 918 919 } 919 else 920 document.getElementById('<?php echo $prev_id; ?>').onkeypress = function (e) 921 { 920 } else { 921 document.getElementById('<?php echo $prev_id; ?>').onkeypress = function (e) { 922 922 e = e ? e : window.event; 923 923 if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) { … … 932 932 } 933 933 } 934 } 935 } 934 936 <?php endif; ?> 935 937 //--> … … 957 959 } 958 960 959 function paginate_links( $arg = '' ) { 960 if ( is_array($arg) ) 961 $a = &$arg; 962 else 963 parse_str($arg, $a); 964 965 // Defaults 966 $base = '%_%'; // http://example.com/all_posts.php%_% : %_% is replaced by format (below) 967 $format = '?page=%#%'; // ?page=%#% : %#% is replaced by the page number 968 $total = 1; 969 $current = 0; 970 $show_all = false; 971 $prev_next = true; 972 $prev_text = __('« Previous'); 973 $next_text = __('Next »'); 974 $end_size = 1; // How many numbers on either end including the end 975 $mid_size = 2; // How many numbers to either side of current not including current 976 $type = 'plain'; 977 $add_args = false; // array of query args to aadd 978 979 extract($a); 961 function paginate_links( $args = '' ) { 962 $defaults = array( 963 'base' => '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below) 964 'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number 965 'total' => 1, 966 'current' => 0, 967 'show_all' => false, 968 'prev_next' => true, 969 'prev_text' => __('« Previous'), 970 'next_text' => __('Next »'), 971 'end_size' => 1, // How many numbers on either end including the end 972 'mid_size' => 2, // How many numbers to either side of current not including current 973 'type' => 'plain', 974 'add_args' => false // array of query args to aadd 975 ); 976 977 $args = wp_parse_args( $args, $defaults ); 978 extract($args, EXTR_SKIP); 980 979 981 980 // Who knows what else people pass in $args trunk/wp-includes/js/prototype.js
r972 r1005 1 /* Prototype JavaScript framework, version 1.5. 11 /* Prototype JavaScript framework, version 1.5.0 2 2 * (c) 2005-2007 Sam Stephenson 3 3 * 4 4 * Prototype is freely distributable under the terms of an MIT-style license. 5 * For details, see the Prototype web site: http:// www.prototypejs.org/5 * For details, see the Prototype web site: http://prototype.conio.net/ 6 6 * 7 7 /*--------------------------------------------------------------------------*/ 8 8 9 9 var Prototype = { 10 Version: '1.5.1', 11 12 Browser: { 13 IE: !!(window.attachEvent && !window.opera), 14 Opera: !!window.opera, 15 WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1, 16 Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1 17 }, 18 10 Version: '1.5.0', 19 11 BrowserFeatures: { 20 XPath: !!document.evaluate, 21 ElementExtensions: !!window.HTMLElement, 22 SpecificElementExtensions: 23 (document.createElement('div').__proto__ !== 24 document.createElement('form').__proto__) 25 }, 26 27 ScriptFragment: '<script[^>]*>([\u0001-\uFFFF]*?)</script>', 28 JSONFilter: /^\/\*-secure-\s*(.*)\s*\*\/\s*$/, 29 30 emptyFunction: function() { }, 12 XPath: !!document.evaluate 13 }, 14 15 ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)', 16 emptyFunction: function() {}, 31 17 K: function(x) { return x } 32 18 } … … 61 47 }, 62 48 63 toJSON: function(object) {64 var type = typeof object;65 switch(type) {66 case 'undefined':67 case 'function':68 case 'unknown': return;69 case 'boolean': return object.toString();70 }71 if (object === null) return 'null';72 if (object.toJSON) return object.toJSON();73 if (object.ownerDocument === document) return;74 var results = [];75 for (var property in object) {76 var value = Object.toJSON(object[property]);77 if (value !== undefined)78 results.push(property.toJSON() + ': ' + value);79 }80 return '{' + results.join(', ') + '}';81 },82 83 49 keys: function(object) { 84 50 var keys = []; … … 110 76 var __method = this, args = $A(arguments), object = args.shift(); 111 77 return function(event) { 112 return __method.apply(object, [ event || window.event].concat(args));78 return __method.apply(object, [( event || window.event)].concat(args).concat($A(arguments))); 113 79 } 114 80 } … … 116 82 Object.extend(Number.prototype, { 117 83 toColorPart: function() { 118 return this.toPaddedString(2, 16); 84 var digits = this.toString(16); 85 if (this < 16) return '0' + digits; 86 return digits; 119 87 }, 120 88 … … 126 94 $R(0, this, true).each(iterator); 127 95 return this; 128 },129 130 toPaddedString: function(length, radix) {131 var string = this.toString(radix || 10);132 return '0'.times(length - string.length) + string;133 },134 135 toJSON: function() {136 return isFinite(this) ? this.toString() : 'null';137 96 } 138 97 }); 139 140 Date.prototype.toJSON = function() {141 return '"' + this.getFullYear() + '-' +142 (this.getMonth() + 1).toPaddedString(2) + '-' +143 this.getDate().toPaddedString(2) + 'T' +144 this.getHours().toPaddedString(2) + ':' +145 this.getMinutes().toPaddedString(2) + ':' +146 this.getSeconds().toPaddedString(2) + '"';147 };148 98 149 99 var Try = { … … 196 146 } 197 147 } 198 Object.extend(String, { 199 interpret: function(value) { 200 return value == null ? '' : String(value); 201 }, 202 specialChar: { 203 '\b': '\\b', 204 '\t': '\\t', 205 '\n': '\\n', 206 '\f': '\\f', 207 '\r': '\\r', 208 '\\': '\\\\' 209 } 210 }); 148 String.interpret = function(value){ 149 return value == null ? '' : String(value); 150 } 211 151 212 152 Object.extend(String.prototype, { … … 274 214 275 215 escapeHTML: function() { 276 var self = arguments.callee; 277 self.text.data = this; 278 return self.div.innerHTML; 216 var div = document.createElement('div'); 217 var text = document.createTextNode(this); 218 div.appendChild(text); 219 return div.innerHTML; 279 220 }, 280 221 … … 283 224 div.innerHTML = this.stripTags(); 284 225 return div.childNodes[0] ? (div.childNodes.length > 1 ? 285 $A(div.childNodes).inject('', function(memo, node){ return memo+node.nodeValue }) :226 $A(div.childNodes).inject('',function(memo,node){ return memo+node.nodeValue }) : 286 227 div.childNodes[0].nodeValue) : ''; 287 228 }, … … 293 234 return match[1].split(separator || '&').inject({}, function(hash, pair) { 294 235 if ((pair = pair.split('='))[0]) { 295 var key = decodeURIComponent(pair.shift());296 var value = pair .length > 1 ? pair.join('=') : pair[0];297 if (value != undefined) value = decodeURIComponent(value); 298 299 if (key in hash) {300 if (hash[key].constructor != Array) hash[key] = [hash[key]];301 hash[key].push(value);236 var name = decodeURIComponent(pair[0]); 237 var value = pair[1] ? decodeURIComponent(pair[1]) : undefined; 238 239 if (hash[name] !== undefined) { 240 if (hash[name].constructor != Array) 241 hash[name] = [hash[name]]; 242 if (value) hash[name].push(value); 302 243 } 303 else hash[ key] = value;244 else hash[name] = value; 304 245 } 305 246 return hash; … … 316 257 }, 317 258 318 times: function(count) {319 var result = '';320 for (var i = 0; i < count; i++) result += this;321 return result;322 },323 324 259 camelize: function() { 325 260 var parts = this.split('-'), len = parts.length; … … 336 271 }, 337 272 338 capitalize: function() {273 capitalize: function(){ 339 274 return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); 340 275 }, … … 349 284 350 285 inspect: function(useDoubleQuotes) { 351 var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) { 352 var character = String.specialChar[match[0]]; 353 return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16); 354 }); 355 if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"'; 356 return "'" + escapedString.replace(/'/g, '\\\'') + "'"; 357 }, 358 359 toJSON: function() { 360 return this.inspect(true); 361 }, 362 363 unfilterJSON: function(filter) { 364 return this.sub(filter || Prototype.JSONFilter, '#{1}'); 365 }, 366 367 evalJSON: function(sanitize) { 368 var json = this.unfilterJSON(); 369 try { 370 if (!sanitize || (/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(json))) 371 return eval('(' + json + ')'); 372 } catch (e) { } 373 throw new SyntaxError('Badly formed JSON string: ' + this.inspect()); 374 }, 375 376 include: function(pattern) { 377 return this.indexOf(pattern) > -1; 378 }, 379 380 startsWith: function(pattern) { 381 return this.indexOf(pattern) === 0; 382 }, 383 384 endsWith: function(pattern) { 385 var d = this.length - pattern.length; 386 return d >= 0 && this.lastIndexOf(pattern) === d; 387 }, 388 389 empty: function() { 390 return this == ''; 391 }, 392 393 blank: function() { 394 return /^\s*$/.test(this); 395 } 396 }); 397 398 if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, { 399 escapeHTML: function() { 400 return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); 401 }, 402 unescapeHTML: function() { 403 return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); 286 var escapedString = this.replace(/\\/g, '\\\\'); 287 if (useDoubleQuotes) 288 return '"' + escapedString.replace(/"/g, '\\"') + '"'; 289 else 290 return "'" + escapedString.replace(/'/g, '\\\'') + "'"; 404 291 } 405 292 }); … … 412 299 413 300 String.prototype.parseQuery = String.prototype.toQueryParams; 414 415 Object.extend(String.prototype.escapeHTML, {416 div: document.createElement('div'),417 text: document.createTextNode('')418 });419 420 with (String.prototype.escapeHTML) div.appendChild(text);421 301 422 302 var Template = Class.create(); … … 437 317 } 438 318 439 var $break = {}, $continue = new Error('"throw $continue" is deprecated, use "return" instead'); 319 var $break = new Object(); 320 var $continue = new Object(); 440 321 441 322 var Enumerable = { … … 444 325 try { 445 326 this._each(function(value) { 446 iterator(value, index++); 327 try { 328 iterator(value, index++); 329 } catch (e) { 330 if (e != $continue) throw e; 331 } 447 332 }); 448 333 } catch (e) { … … 646 531 } 647 532 648 if (Prototype.Browser.WebKit) {649 $A = Array.from = function(iterable) {650 if (!iterable) return [];651 if (!(typeof iterable == 'function' && iterable == '[object NodeList]') &&652 iterable.toArray) {653 return iterable.toArray();654 } else {655 var results = [];656 for (var i = 0, length = iterable.length; i < length; i++)657 results.push(iterable[i]);658 return results;659 }660 }661 }662 663 533 Object.extend(Array.prototype, Enumerable); 664 534 … … 719 589 }, 720 590 721 uniq: function(sorted) { 722 return this.inject([], function(array, value, index) { 723 if (0 == index || (sorted ? array.last() != value : !array.include(value))) 724 array.push(value); 725 return array; 591 uniq: function() { 592 return this.inject([], function(array, value) { 593 return array.include(value) ? array : array.concat([value]); 726 594 }); 727 595 }, … … 737 605 inspect: function() { 738 606 return '[' + this.map(Object.inspect).join(', ') + ']'; 739 },740 741 toJSON: function() {742 var results = [];743 this.each(function(object) {744 var value = Object.toJSON(object);745 if (value !== undefined) results.push(value);746 });747 return '[' + results.join(', ') + ']';748 607 } 749 608 }); … … 751 610 Array.prototype.toArray = Array.prototype.clone; 752 611 753 function $w(string) {612 function $w(string){ 754 613 string = string.strip(); 755 614 return string ? string.split(/\s+/) : []; 756 615 } 757 616 758 if (Prototype.Browser.Opera){759 Array.prototype.concat = function() {617 if(window.opera){ 618 Array.prototype.concat = function(){ 760 619 var array = []; 761 for (var i = 0, length = this.length; i < length; i++) array.push(this[i]);762 for (var i = 0, length = arguments.length; i < length; i++) {763 if (arguments[i].constructor == Array) {764 for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++)620 for(var i = 0, length = this.length; i < length; i++) array.push(this[i]); 621 for(var i = 0, length = arguments.length; i < length; i++) { 622 if(arguments[i].constructor == Array) { 623 for(var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++) 765 624 array.push(arguments[i][j]); 766 625 } else { … … 771 630 } 772 631 } 773 var Hash = function(object) { 774 if (object instanceof Hash) this.merge(object); 775 else Object.extend(this, object || {}); 632 var Hash = function(obj) { 633 Object.extend(this, obj || {}); 776 634 }; 777 635 … … 779 637 toQueryString: function(obj) { 780 638 var parts = []; 781 parts.add = arguments.callee.addPair; 782 783 this.prototype._each.call(obj, function(pair) { 639 640 this.prototype._each.call(obj, function(pair) { 784 641 if (!pair.key) return; 785 var value = pair.value; 786 787 if (value && typeof value == 'object') { 788 if (value.constructor == Array) value.each(function(value) { 789 parts.add(pair.key, value); 790 }); 791 return; 642 643 if (pair.value && pair.value.constructor == Array) { 644 var values = pair.value.compact(); 645 if (values.length < 2) pair.value = values.reduce(); 646 else { 647 key = encodeURIComponent(pair.key); 648 values.each(function(value) { 649 value = value != undefined ? encodeURIComponent(value) : ''; 650 parts.push(key + '=' + encodeURIComponent(value)); 651 }); 652 return; 653 } 792 654 } 793 parts.add(pair.key, value); 794 }); 655 if (pair.value == undefined) pair[1] = ''; 656 parts.push(pair.map(encodeURIComponent).join('=')); 657 }); 795 658 796 659 return parts.join('&'); 797 },798 799 toJSON: function(object) {800 var results = [];801 this.prototype._each.call(object, function(pair) {802 var value = Object.toJSON(pair.value);803 if (value !== undefined) results.push(pair.key.toJSON() + ': ' + value);804 });805 return '{' + results.join(', ') + '}';806 660 } 807 661 }); 808 809 Hash.toQueryString.addPair = function(key, value, prefix) {810 key = encodeURIComponent(key);811 if (value === undefined) this.push(key);812 else this.push(key + '=' + (value == null ? '' : encodeURIComponent(value)));813 }814 662 815 663 Object.extend(Hash.prototype, Enumerable); … … 866 714 return pair.map(Object.inspect).join(': '); 867 715 }).join(', ') + '}>'; 868 },869 870 toJSON: function() {871 return Hash.toJSON(this);872 716 } 873 717 }); 874 718 875 719 function $H(object) { 876 if (object instanceofHash) return object;720 if (object && object.constructor == Hash) return object; 877 721 return new Hash(object); 878 };879 880 // Safari iterates over shadowed properties881 if (function() {882 var i = 0, Test = function(value) { this.key = value };883 Test.prototype.key = 'foo';884 for (var property in new Test('bar')) i++;885 return i > 1;886 }()) Hash.prototype._each = function(iterator) {887 var cache = [];888 for (var key in this) {889 var value = this[key];890 if ((value && value == Hash.prototype[key]) || cache.include(key)) continue;891 cache.push(key);892 var pair = [key, value];893 pair.key = key;894 pair.value = value;895 iterator(pair);896 }897 722 }; 898 723 ObjectRange = Class.create(); … … 1010 835 this.url = url; 1011 836 this.method = this.options.method; 1012 var params = Object.clone(this.options.parameters);837 var params = this.options.parameters; 1013 838 1014 839 if (!['get', 'post'].include(this.method)) { … … 1018 843 } 1019 844 1020 this.parameters = params; 1021 1022 if (params = Hash.toQueryString(params)) { 1023 // when GET, append parameters to URL 1024 if (this.method == 'get') 1025 this.url += (this.url.include('?') ? '&' : '?') + params; 1026 else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) 1027 params += '&_='; 1028 } 845 params = Hash.toQueryString(params); 846 if (params && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) params += '&_=' 847 848 // when GET, append parameters to URL 849 if (this.method == 'get' && params) 850 this.url += (this.url.indexOf('?') > -1 ? '&' : '?') + params; 1029 851 1030 852 try { 1031 if (this.options.onCreate) this.options.onCreate(this.transport);1032 853 Ajax.Responders.dispatch('onCreate', this, this.transport); 1033 854 … … 1041 862 this.setRequestHeaders(); 1042 863 1043 this.body = this.method == 'post' ? (this.options.postBody || params) : null; 1044 this.transport.send(this.body); 864 var body = this.method == 'post' ? (this.options.postBody || params) : null; 865 866 this.transport.send(body); 1045 867 1046 868 /* Force Firefox to handle ready state 4 for synchronous requests */ … … 1114 936 } 1115 937 1116 var contentType = this.getHeader('Content-type'); 1117 if (contentType && contentType.strip(). 938 if ((this.getHeader('Content-type') || 'text/javascript').strip(). 1118 939 match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i)) 1119 940 this.evalResponse(); … … 1142 963 try { 1143 964 var json = this.getHeader('X-JSON'); 1144 return json ? json.evalJSON() : null;965 return json ? eval('(' + json + ')') : null; 1145 966 } catch (e) { return null } 1146 967 }, … … 1148 969 evalResponse: function() { 1149 970 try { 1150 return eval( (this.transport.responseText || '').unfilterJSON());971 return eval(this.transport.responseText); 1151 972 } catch (e) { 1152 973 this.dispatchException(e); … … 1263 1084 return results; 1264 1085 }; 1265 1266 document.getElementsByClassName = function(className, parentElement) { 1086 } 1087 1088 document.getElementsByClassName = function(className, parentElement) { 1089 if (Prototype.BrowserFeatures.XPath) { 1267 1090 var q = ".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]"; 1268 1091 return document._getElementsByXPath(q, parentElement); 1269 } 1270 1271 } else document.getElementsByClassName = function(className, parentElement) { 1272 var children = ($(parentElement) || document.body).getElementsByTagName('*'); 1273 var elements = [], child; 1274 for (var i = 0, length = children.length; i < length; i++) { 1275 child = children[i]; 1276 if (Element.hasClassName(child, className)) 1277 elements.push(Element.extend(child)); 1278 } 1279 return elements; 1092 } else { 1093 var children = ($(parentElement) || document.body).getElementsByTagName('*'); 1094 var elements = [], child; 1095 for (var i = 0, length = children.length; i < length; i++) { 1096 child = children[i]; 1097 if (Element.hasClassName(child, className)) 1098 elements.push(Element.extend(child)); 1099 } 1100 return elements; 1101 } 1280 1102 }; 1281 1103 1282 1104 /*--------------------------------------------------------------------------*/ 1283 1105 1284 if (!window.Element) var Element = {}; 1106 if (!window.Element) 1107 var Element = new Object(); 1285 1108 1286 1109 Element.extend = function(element) { 1287 var F = Prototype.BrowserFeatures; 1288 if (!element || !element.tagName || element.nodeType == 3 || 1289 element._extended || F.SpecificElementExtensions || element == window) 1290 return element; 1291 1292 var methods = {}, tagName = element.tagName, cache = Element.extend.cache, 1293 T = Element.Methods.ByTag; 1294 1295 // extend methods for all tags (Safari doesn't need this) 1296 if (!F.ElementExtensions) { 1297 Object.extend(methods, Element.Methods), 1110 if (!element || _nativeExtensions || element.nodeType == 3) return element; 1111 1112 if (!element._extended && element.tagName && element != window) { 1113 var methods = Object.clone(Element.Methods), cache = Element.extend.cache; 1114 1115 if (element.tagName == 'FORM') 1116 Object.extend(methods, Form.Methods); 1117 if (['INPUT', 'TEXTAREA', 'SELECT'].include(element.tagName)) 1118 Object.extend(methods, Form.Element.Methods); 1119 1298 1120 Object.extend(methods, Element.Methods.Simulated); 1299 } 1300 1301 // extend methods for specific tags 1302 if (T[tagName]) Object.extend(methods, T[tagName]); 1303 1304 for (var property in methods) { 1305 var value = methods[property]; 1306 if (typeof value == 'function' && !(property in element)) 1307 element[property] = cache.findOrStore(value); 1308 } 1309 1310 element._extended = Prototype.emptyFunction; 1121 1122 for (var property in methods) { 1123 var value = methods[property]; 1124 if (typeof value == 'function' && !(property in element)) 1125 element[property] = cache.findOrStore(value); 1126 } 1127 } 1128 1129 element._extended = true; 1311 1130 return element; 1312 1131 }; … … 1394 1213 1395 1214 descendants: function(element) { 1396 return $A($(element).getElementsByTagName('*')).each(Element.extend); 1397 }, 1398 1399 firstDescendant: function(element) { 1400 element = $(element).firstChild; 1401 while (element && element.nodeType != 1) element = element.nextSibling; 1402 return $(element); 1215 return $A($(element).getElementsByTagName('*')); 1403 1216 }, 1404 1217 … … 1430 1243 1431 1244 up: function(element, expression, index) { 1432 element = $(element); 1433 if (arguments.length == 1) return $(element.parentNode); 1434 var ancestors = element.ancestors(); 1435 return expression ? Selector.findElement(ancestors, expression, index) : 1436 ancestors[index || 0]; 1245 return Selector.findElement($(element).ancestors(), expression, index); 1437 1246 }, 1438 1247 1439 1248 down: function(element, expression, index) { 1440 element = $(element); 1441 if (arguments.length == 1) return element.firstDescendant(); 1442 var descendants = element.descendants(); 1443 return expression ? Selector.findElement(descendants, expression, index) : 1444 descendants[index || 0]; 1249 return Selector.findElement($(element).descendants(), expression, index); 1445 1250 }, 1446 1251 1447 1252 previous: function(element, expression, index) { 1448 element = $(element); 1449 if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element)); 1450 var previousSiblings = element.previousSiblings(); 1451 return expression ? Selector.findElement(previousSiblings, expression, index) : 1452 previousSiblings[index || 0]; 1253 return Selector.findElement($(element).previousSiblings(), expression, index); 1453 1254 }, 1454 1255 1455 1256 next: function(element, expression, index) { 1456 element = $(element); 1457 if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element)); 1458 var nextSiblings = element.nextSiblings(); 1459 return expression ? Selector.findElement(nextSiblings, expression, index) : 1460 nextSiblings[index || 0]; 1257 return Selector.findElement($(element).nextSiblings(), expression, index); 1461 1258 }, 1462 1259 … … 1472 1269 readAttribute: function(element, name) { 1473 1270 element = $(element); 1474 if (Prototype.Browser.IE) { 1475 if (!element.attributes) return null; 1271 if (document.all && !window.opera) { 1476 1272 var t = Element._attributeTranslations; 1477 1273 if (t.values[name]) return t.values[name](element, name); 1478 1274 if (t.names[name]) name = t.names[name]; 1479 1275 var attribute = element.attributes[name]; 1480 return attribute ? attribute.nodeValue : null;1276 if(attribute) return attribute.nodeValue; 1481 1277 } 1482 1278 return element.getAttribute(name); … … 1547 1343 1548 1344 empty: function(element) { 1549 return $(element).innerHTML. blank();1345 return $(element).innerHTML.match(/^\s*$/); 1550 1346 }, 1551 1347 … … 1566 1362 getStyle: function(element, style) { 1567 1363 element = $(element); 1568 style = style == 'float' ? 'cssFloat' : style.camelize(); 1364 if (['float','cssFloat'].include(style)) 1365 style = (typeof element.style.styleFloat != 'undefined' ? 'styleFloat' : 'cssFloat'); 1366 style = style.camelize(); 1569 1367 var value = element.style[style]; 1570 1368 if (!value) { 1571 var css = document.defaultView.getComputedStyle(element, null); 1572 value = css ? css[style] : null; 1573 } 1574 if (style == 'opacity') return value ? parseFloat(value) : 1.0; 1369 if (document.defaultView && document.defaultView.getComputedStyle) { 1370 var css = document.defaultView.getComputedStyle(element, null); 1371 value = css ? css[style] : null; 1372 } else if (element.currentStyle) { 1373 value = element.currentStyle[style]; 1374 } 1375 } 1376 1377 if((value == 'auto') && ['width','height'].include(style) && (element.getStyle('display') != 'none')) 1378 value = element['offset'+style.capitalize()] + 'px'; 1379 1380 if (window.opera && ['left', 'top', 'right', 'bottom'].include(style)) 1381 if (Element.getStyle(element, 'position') == 'static') value = 'auto'; 1382 if(style == 'opacity') { 1383 if(value) return parseFloat(value); 1384 if(value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/)) 1385 if(value[1]) return parseFloat(value[1]) / 100; 1386 return 1.0; 1387 } 1575 1388 return value == 'auto' ? null : value; 1576 1389 }, 1577 1390 1578 getOpacity: function(element) { 1579 return $(element).getStyle('opacity'); 1580 }, 1581 1582 setStyle: function(element, styles, camelized) { 1391 setStyle: function(element, style) { 1583 1392 element = $(element); 1584 var elementStyle = element.style; 1585 1586 for (var property in styles) 1587 if (property == 'opacity') element.setOpacity(styles[property]) 1588 else 1589 elementStyle[(property == 'float' || property == 'cssFloat') ? 1590 (elementStyle.styleFloat === undefined ? 'cssFloat' : 'styleFloat') : 1591 (camelized ? property : property.camelize())] = styles[property]; 1592 1593 return element; 1594 }, 1595 1596 setOpacity: function(element, value) { 1597 element = $(element); 1598 element.style.opacity = (value == 1 || value === '') ? '' : 1599 (value < 0.00001) ? 0 : value; 1393 for (var name in style) { 1394 var value = style[name]; 1395 if(name == 'opacity') { 1396 if (value == 1) { 1397 value = (/Gecko/.test(navigator.userAgent) && 1398 !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 0.999999 : 1.0; 1399 if(/MSIE/.test(navigator.userAgent) && !window.opera) 1400 element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,''); 1401 } else if(value == '') { 1402 if(/MSIE/.test(navigator.userAgent) && !window.opera) 1403 element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,''); 1404 } else { 1405 if(value < 0.00001) value = 0; 1406 if(/MSIE/.test(navigator.userAgent) && !window.opera) 1407 element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'') + 1408 'alpha(opacity='+value*100+')'; 1409 } 1410 } else if(['float','cssFloat'].include(name)) name = (typeof element.style.styleFloat != 'undefined') ? 'styleFloat' : 'cssFloat'; 1411 element.style[name.camelize()] = value; 1412 } 1600 1413 return element; 1601 1414 }, … … 1671 1484 }; 1672 1485 1673 Object.extend(Element.Methods, { 1674 childOf: Element.Methods.descendantOf, 1675 childElements: Element.Methods.immediateDescendants 1486 Object.extend(Element.Methods, {childOf: Element.Methods.descendantOf}); 1487 1488 Element._attributeTranslations = {}; 1489 1490 Element._attributeTranslations.names = { 1491 colspan: "colSpan", 1492 rowspan: "rowSpan", 1493 valign: "vAlign", 1494 datetime: "dateTime", 1495 accesskey: "accessKey", 1496 tabindex: "tabIndex", 1497 enctype: "encType", 1498 maxlength: "maxLength", 1499 readonly: "readOnly", 1500 longdesc: "longDesc" 1501 }; 1502 1503 Element._attributeTranslations.values = { 1504 _getAttr: function(element, attribute) { 1505 return element.getAttribute(attribute, 2); 1506 }, 1507 1508 _flag: function(element, attribute) { 1509 return $(element).hasAttribute(attribute) ? attribute : null; 1510 }, 1511 1512 style: function(element) { 1513 return element.style.cssText.toLowerCase(); 1514 }, 1515 1516 title: function(element) { 1517 var node = element.getAttributeNode('title'); 1518 return node.specified ? node.nodeValue : null; 1519 } 1520 }; 1521 1522 Object.extend(Element._attributeTranslations.values, { 1523 href: Element._attributeTranslations.values._getAttr, 1524 src: Element._attributeTranslations.values._getAttr, 1525 disabled: Element._attributeTranslations.values._flag, 1526 checked: Element._attributeTranslations.values._flag, 1527 readonly: Element._attributeTranslations.values._flag, 1528 multiple: Element._attributeTranslations.values._flag 1676 1529 }); 1677 1530 1678 if (Prototype.Browser.Opera) { 1679 Element.Methods._getStyle = Element.Methods.getStyle; 1680 Element.Methods.getStyle = function(element, style) { 1681 switch(style) { 1682 case 'left': 1683 case 'top': 1684 case 'right': 1685 case 'bottom': 1686 if (Element._getStyle(element, 'position') == 'static') return null; 1687 default: return Element._getStyle(element, style); 1688 } 1689 }; 1690 } 1691 else if (Prototype.Browser.IE) { 1692 Element.Methods.getStyle = function(element, style) { 1693 element = $(element); 1694 style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize(); 1695 var value = element.style[style]; 1696 if (!value && element.currentStyle) value = element.currentStyle[style]; 1697 1698 if (style == 'opacity') { 1699 if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/)) 1700 if (value[1]) return parseFloat(value[1]) / 100; 1701 return 1.0; 1702 } 1703 1704 if (value == 'auto') { 1705 if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none')) 1706 return element['offset'+style.capitalize()] + 'px'; 1707 return null; 1708 } 1709 return value; 1710 }; 1711 1712 Element.Methods.setOpacity = function(element, value) { 1713 element = $(element); 1714 var filter = element.getStyle('filter'), style = element.style; 1715 if (value == 1 || value === '') { 1716 style.filter = filter.replace(/alpha\([^\)]*\)/gi,''); 1717 return element; 1718 } else if (value < 0.00001) value = 0; 1719 style.filter = filter.replace(/alpha\([^\)]*\)/gi, '') + 1720 'alpha(opacity=' + (value * 100) + ')'; 1721 return element; 1722 }; 1723 1724 // IE is missing .innerHTML support for TABLE-related elements 1531 Element.Methods.Simulated = { 1532 hasAttribute: function(element, attribute) { 1533 var t = Element._attributeTranslations; 1534 attribute = t.names[attribute] || attribute; 1535 return $(element).getAttributeNode(attribute).specified; 1536 } 1537 }; 1538 1539 // IE is missing .innerHTML support for TABLE-related elements 1540 if (document.all && !window.opera){ 1725 1541 Element.Methods.update = function(element, html) { 1726 1542 element = $(element); … … 1743 1559 depth = 4; 1744 1560 } 1745 $A(element.childNodes).each(function(node) { element.removeChild(node) }); 1746 depth.times(function() { div = div.firstChild }); 1747 $A(div.childNodes).each(function(node) { element.appendChild(node) }); 1561 $A(element.childNodes).each(function(node){ 1562 element.removeChild(node) 1563 }); 1564 depth.times(function(){ div = div.firstChild }); 1565 1566 $A(div.childNodes).each( 1567 function(node){ element.appendChild(node) }); 1748 1568 } else { 1749 1569 element.innerHTML = html.stripScripts(); 1750 1570 } 1751 setTimeout(function() { html.evalScripts()}, 10);1571 setTimeout(function() {html.evalScripts()}, 10); 1752 1572 return element; 1753 1573 } 1754 }1755 else if (Prototype.Browser.Gecko) {1756 Element.Methods.setOpacity = function(element, value) {1757 element = $(element);1758 element.style.opacity = (value == 1) ? 0.999999 :1759 (value === '') ? '' : (value < 0.00001) ? 0 : value;1760 return element;1761 };1762 }1763 1764 Element._attributeTranslations = {1765 names: {1766 colspan: "colSpan",1767 rowspan: "rowSpan",1768 valign: "vAlign",1769 datetime: "dateTime",1770 accesskey: "accessKey",1771 tabindex: "tabIndex",1772 enctype: "encType",1773 maxlength: "maxLength",1774 readonly: "readOnly",1775 longdesc: "longDesc"1776 },1777 values: {1778 _getAttr: function(element, attribute) {1779 return element.getAttribute(attribute, 2);1780 },1781 _flag: function(element, attribute) {1782 return $(element).hasAttribute(attribute) ? attribute : null;1783 },1784 style: function(element) {1785 return element.style.cssText.toLowerCase();1786 },1787 title: function(element) {1788 var node = element.getAttributeNode('title');1789 return node.specified ? node.nodeValue : null;1790 }1791 }1792 1574 }; 1793 1575 1794 (function() { 1795 Object.extend(this, { 1796 href: this._getAttr, 1797 src: this._getAttr, 1798 type: this._getAttr, 1799 disabled: this._flag, 1800 checked: this._flag, 1801 readonly: this._flag, 1802 multiple: this._flag 1576 Object.extend(Element, Element.Methods); 1577 1578 var _nativeExtensions = false; 1579 1580 if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)) 1581 ['', 'Form', 'Input', 'TextArea', 'Select'].each(function(tag) { 1582 var className = 'HTML' + tag + 'Element'; 1583 if(window[className]) return; 1584 var klass = window[className] = {}; 1585 klass.prototype = document.createElement(tag ? tag.toLowerCase() : 'div').__proto__; 1803 1586 }); 1804 }).call(Element._attributeTranslations.values);1805 1806 Element.Methods.Simulated = {1807 hasAttribute: function(element, attribute) {1808 var t = Element._attributeTranslations, node;1809 attribute = t.names[attribute] || attribute;1810 node = $(element).getAttributeNode(attribute);1811 return node && node.specified;1812 }1813 };1814 1815 Element.Methods.ByTag = {};1816 1817 Object.extend(Element, Element.Methods);1818 1819 if (!Prototype.BrowserFeatures.ElementExtensions &&1820 document.createElement('div').__proto__) {1821 window.HTMLElement = {};1822 window.HTMLElement.prototype = document.createElement('div').__proto__;1823 Prototype.BrowserFeatures.ElementExtensions = true;1824 }1825 1826 Element.hasAttribute = function(element, attribute) {1827 if (element.hasAttribute) return element.hasAttribute(attribute);1828 return Element.Methods.Simulated.hasAttribute(element, attribute);1829 };1830 1587 1831 1588 Element.addMethods = function(methods) { 1832 var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag; 1833 1834 if (!methods) { 1835 Object.extend(Form, Form.Methods); 1836 Object.extend(Form.Element, Form.Element.Methods); 1837 Object.extend(Element.Methods.ByTag, { 1838 "FORM": Object.clone(Form.Methods), 1839 "INPUT": Object.clone(Form.Element.Methods), 1840 "SELECT": Object.clone(Form.Element.Methods), 1841 "TEXTAREA": Object.clone(Form.Element.Methods) 1842 }); 1843 } 1844 1845 if (arguments.length == 2) { 1846 var tagName = methods; 1847 methods = arguments[1]; 1848 } 1849 1850 if (!tagName) Object.extend(Element.Methods, methods || {}); 1851 else { 1852 if (tagName.constructor == Array) tagName.each(extend); 1853 else extend(tagName); 1854 } 1855 1856 function extend(tagName) { 1857 tagName = tagName.toUpperCase(); 1858 if (!Element.Methods.ByTag[tagName]) 1859 Element.Methods.ByTag[tagName] = {}; 1860 Object.extend(Element.Methods.ByTag[tagName], methods); 1861 } 1589 Object.extend(Element.Methods, methods || {}); 1862 1590 1863 1591 function copy(methods, destination, onlyIfAbsent) { … … 1871 1599 } 1872 1600 1873 function findDOMClass(tagName) { 1874 var klass; 1875 var trans = { 1876 "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph", 1877 "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList", 1878 "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading", 1879 "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote", 1880 "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION": 1881 "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD": 1882 "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR": 1883 "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET": 1884 "FrameSet", "IFRAME": "IFrame" 1885 }; 1886 if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element'; 1887 if (window[klass]) return window[klass]; 1888 klass = 'HTML' + tagName + 'Element'; 1889 if (window[klass]) return window[klass]; 1890 klass = 'HTML' + tagName.capitalize() + 'Element'; 1891 if (window[klass]) return window[klass]; 1892 1893 window[klass] = {}; 1894 window[klass].prototype = document.createElement(tagName).__proto__; 1895 return window[klass]; 1896 } 1897 1898 if (F.ElementExtensions) { 1601 if (typeof HTMLElement != 'undefined') { 1899 1602 copy(Element.Methods, HTMLElement.prototype); 1900 1603 copy(Element.Methods.Simulated, HTMLElement.prototype, true); 1901 } 1902 1903 if (F.SpecificElementExtensions) { 1904 for (var tag in Element.Methods.ByTag) { 1905 var klass = findDOMClass(tag); 1906 if (typeof klass == "undefined") continue; 1907 copy(T[tag], klass.prototype); 1908 } 1909 } 1910 1911 Object.extend(Element, Element.Methods); 1912 delete Element.ByTag; 1913 }; 1914 1915 var Toggle = { display: Element.toggle }; 1604 copy(Form.Methods, HTMLFormElement.prototype); 1605 [HTMLInputElement, HTMLTextAreaElement, HTMLSelectElement].each(function(klass) { 1606 copy(Form.Element.Methods, klass.prototype); 1607 }); 1608 _nativeExtensions = true; 1609 } 1610 } 1611 1612 var Toggle = new Object(); 1613 Toggle.display = Element.toggle; 1916 1614 1917 1615 /*--------------------------------------------------------------------------*/ … … 2044 1742 2045 1743 Object.extend(Element.ClassNames.prototype, Enumerable); 2046 /* Portions of the Selector class are derived from Jack Slocum’s DomQuery,2047 * part of YUI-Ext version 0.40, distributed under the terms of an MIT-style2048 * license. Please see http://www.yui-ext.com/ for more information. */2049 2050 1744 var Selector = Class.create(); 2051 2052 1745 Selector.prototype = { 2053 1746 initialize: function(expression) { 2054 this.expression = expression.strip(); 1747 this.params = {classNames: []}; 1748 this.expression = expression.toString().strip(); 1749 this.parseExpression(); 2055 1750 this.compileMatcher(); 2056 1751 }, 2057 1752 1753 parseExpression: function() { 1754 function abort(message) { throw 'Parse error in selector: ' + message; } 1755 1756 if (this.expression == '') abort('empty expression'); 1757 1758 var params = this.params, expr = this.expression, match, modifier, clause, rest; 1759 while (match = expr.match(/^(.*)\[([a-z0-9_:-]+?)(?:([~\|!]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)) { 1760 params.attributes = params.attributes || []; 1761 params.attributes.push({name: match[2], operator: match[3], value: match[4] || match[5] || ''}); 1762 expr = match[1]; 1763 } 1764 1765 if (expr == '*') return this.params.wildcard = true; 1766 1767 while (match = expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+)(.*)/i)) { 1768 modifier = match[1], clause = match[2], rest = match[3]; 1769 switch (modifier) { 1770 case '#': params.id = clause; break; 1771 case '.': params.classNames.push(clause); break; 1772 case '': 1773 case undefined: params.tagName = clause.toUpperCase(); break; 1774 default: abort(expr.inspect()); 1775 } 1776 expr = rest; 1777 } 1778 1779 if (expr.length > 0) abort(expr.inspect()); 1780 }, 1781 1782 buildMatchExpression: function() { 1783 var params = this.params, conditions = [], clause; 1784 1785 if (params.wildcard) 1786 conditions.push('true'); 1787 if (clause = params.id) 1788 conditions.push('element.readAttribute("id") == ' + clause.inspect()); 1789 if (clause = params.tagName) 1790 conditions.push('element.tagName.toUpperCase() == ' + clause.inspect()); 1791 if ((clause = params.classNames).length > 0) 1792 for (var i = 0, length = clause.length; i < length; i++) 1793 conditions.push('element.hasClassName(' + clause[i].inspect() + ')'); 1794 if (clause = params.attributes) { 1795 clause.each(function(attribute) { 1796 var value = 'element.readAttribute(' + attribute.name.inspect() + ')'; 1797 var splitValueBy = function(delimiter) { 1798 return value + ' && ' + value + '.split(' + delimiter.inspect() + ')'; 1799 } 1800 1801 switch (attribute.operator) { 1802 case '=': conditions.push(value + ' == ' + attribute.value.inspect()); break; 1803 case '~=': conditions.push(splitValueBy(' ') + '.include(' + attribute.value.inspect() + ')'); break; 1804 case '|=': conditions.push( 1805 splitValueBy('-') + '.first().toUpperCase() == ' + attribute.value.toUpperCase().inspect() 1806 ); break; 1807 case '!=': conditions.push(value + ' != ' + attribute.value.inspect()); break; 1808 case '': 1809 case undefined: conditions.push('element.hasAttribute(' + attribute.name.inspect() + ')'); break; 1810 default: throw 'Unknown operator ' + attribute.operator + ' in selector'; 1811 } 1812 }); 1813 } 1814 1815 return conditions.join(' && '); 1816 }, 1817 2058 1818 compileMatcher: function() { 2059 // Selectors with namespaced attributes can't use the XPath version 2060 if (Prototype.BrowserFeatures.XPath && !(/\[[\w-]*?:/).test(this.expression)) 2061 return this.compileXPathMatcher(); 2062 2063 var e = this.expression, ps = Selector.patterns, h = Selector.handlers, 2064 c = Selector.criteria, le, p, m; 2065 2066 if (Selector._cache[e]) { 2067 this.matcher = Selector._cache[e]; return; 2068 } 2069 this.matcher = ["this.matcher = function(root) {", 2070 "var r = root, h = Selector.handlers, c = false, n;"]; 2071 2072 while (e && le != e && (/\S/).test(e)) { 2073 le = e; 2074 for (var i in ps) { 2075 p = ps[i]; 2076 if (m = e.match(p)) { 2077 this.matcher.push(typeof c[i] == 'function' ? c[i](m) : 2078 new Template(c[i]).evaluate(m)); 2079 e = e.replace(m[0], ''); 2080 break; 2081 } 2082 } 2083 } 2084 2085 this.matcher.push("return h.unique(n);\n}"); 2086 eval(this.matcher.join('\n')); 2087 Selector._cache[this.expression] = this.matcher; 2088 }, 2089 2090 compileXPathMatcher: function() { 2091 var e = this.expression, ps = Selector.patterns, 2092 x = Selector.xpath, le, m; 2093 2094 if (Selector._cache[e]) { 2095 this.xpath = Selector._cache[e]; return; 2096 } 2097 2098 this.matcher = ['.//*']; 2099 while (e && le != e && (/\S/).test(e)) { 2100 le = e; 2101 for (var i in ps) { 2102 if (m = e.match(ps[i])) { 2103 this.matcher.push(typeof x[i] == 'function' ? x[i](m) : 2104 new Template(x[i]).evaluate(m)); 2105 e = e.replace(m[0], ''); 2106 break; 2107 } 2108 } 2109 } 2110 2111 this.xpath = this.matcher.join(''); 2112 Selector._cache[this.expression] = this.xpath; 2113 }, 2114 2115 findElements: function(root) { 2116 root = root || document; 2117 if (this.xpath) return document._getElementsByXPath(this.xpath, root); 2118 return this.matcher(root); 2119 }, 2120 2121 match: function(element) { 2122 return this.findElements(document).include(element); 1819 this.match = new Function('element', 'if (!element.tagName) return false; \ 1820 element = $(element); \ 1821 return ' + this.buildMatchExpression()); 1822 }, 1823 1824 findElements: function(scope) { 1825 var element; 1826 1827 if (element = $(this.params.id)) 1828 if (this.match(element)) 1829 if (!scope || Element.childOf(element, scope)) 1830 return [element]; 1831 1832 scope = (scope || document).getElementsByTagName(this.params.tagName || '*'); 1833 1834 var results = []; 1835 for (var i = 0, length = scope.length; i < length; i++) 1836 if (this.match(element = scope[i])) 1837 results.push(Element.extend(element)); 1838 1839 return results; 2123 1840 }, 2124 1841 2125 1842 toString: function() { 2126 1843 return this.expression; 2127 }, 2128 2129 inspect: function() { 2130 return "#<Selector:" + this.expression.inspect() + ">"; 2131 } 2132 }; 1844 } 1845 } 2133 1846 2134 1847 Object.extend(Selector, { 2135 _cache: {}, 2136 2137 xpath: { 2138 descendant: "//*", 2139 child: "/*", 2140 adjacent: "/following-sibling::*[1]", 2141 laterSibling: '/following-sibling::*', 2142 tagName: function(m) { 2143 if (m[1] == '*') return ''; 2144 return "[local-name()='" + m[1].toLowerCase() + 2145 "' or local-name()='" + m[1].toUpperCase() + "']"; 2146 }, 2147 className: "[contains(concat(' ', @class, ' '), ' #{1} ')]", 2148 id: "[@id='#{1}']", 2149 attrPresence: "[@#{1}]", 2150 attr: function(m) { 2151 m[3] = m[5] || m[6]; 2152 return new Template(Selector.xpath.operators[m[2]]).evaluate(m); 2153 }, 2154 pseudo: function(m) { 2155 var h = Selector.xpath.pseudos[m[1]]; 2156 if (!h) return ''; 2157 if (typeof h === 'function') return h(m); 2158 return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m); 2159 }, 2160 operators: { 2161 '=': "[@#{1}='#{3}']", 2162 '!=': "[@#{1}!='#{3}']", 2163 '^=': "[starts-with(@#{1}, '#{3}')]", 2164 '$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']", 2165 '*=': "[contains(@#{1}, '#{3}')]", 2166 '~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]", 2167 '|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]" 2168 }, 2169 pseudos: { 2170 'first-child': '[not(preceding-sibling::*)]', 2171 'last-child': '[not(following-sibling::*)]', 2172 'only-child': '[not(preceding-sibling::* or following-sibling::*)]', 2173 'empty': "[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]", 2174 'checked': "[@checked]", 2175 'disabled': "[@disabled]", 2176 'enabled': "[not(@disabled)]", 2177 'not': function(m) { 2178 var e = m[6], p = Selector.patterns, 2179 x = Selector.xpath, le, m, v; 2180 2181 var exclusion = []; 2182 while (e && le != e && (/\S/).test(e)) { 2183 le = e; 2184 for (var i in p) { 2185 if (m = e.match(p[i])) { 2186 v = typeof x[i] == 'function' ? x[i](m) : new Template(x[i]).evaluate(m); 2187 exclusion.push("(" + v.substring(1, v.length - 1) + ")"); 2188 e = e.replace(m[0], ''); 2189 break; 2190 } 2191 } 2192 } 2193 return "[not(" + exclusion.join(" and ") + ")]"; 2194 }, 2195 'nth-child': function(m) { 2196 return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m); 2197 }, 2198 'nth-last-child': function(m) { 2199 return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m); 2200 }, 2201 'nth-of-type': function(m) { 2202 return Selector.xpath.pseudos.nth("position() ", m); 2203 }, 2204 'nth-last-of-type': function(m) { 2205 return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m); 2206 }, 2207 'first-of-type': function(m) { 2208 m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m); 2209 }, 2210 'last-of-type': function(m) { 2211 m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m); 2212 }, 2213 'only-of-type': function(m) { 2214 var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m); 2215 }, 2216 nth: function(fragment, m) { 2217 var mm, formula = m[6], predicate; 2218 if (formula == 'even') formula = '2n+0'; 2219 if (formula == 'odd') formula = '2n+1'; 2220 if (mm = formula.match(/^(\d+)$/)) // digit only 2221 return '[' + fragment + "= " + mm[1] + ']'; 2222 if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b 2223 if (mm[1] == "-") mm[1] = -1; 2224 var a = mm[1] ? Number(mm[1]) : 1; 2225 var b = mm[2] ? Number(mm[2]) : 0; 2226 predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " + 2227 "((#{fragment} - #{b}) div #{a} >= 0)]"; 2228 return new Template(predicate).evaluate({ 2229 fragment: fragment, a: a, b: b }); 2230 } 2231 } 2232 } 2233 }, 2234 2235 criteria: { 2236 tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;', 2237 className: 'n = h.className(n, r, "#{1}", c); c = false;', 2238 id: 'n = h.id(n, r, "#{1}", c); c = false;', 2239 attrPresence: 'n = h.attrPresence(n, r, "#{1}"); c = false;', 2240 attr: function(m) { 2241 m[3] = (m[5] || m[6]); 2242 return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}"); c = false;').evaluate(m); 2243 }, 2244 pseudo: function(m) { 2245 if (m[6]) m[6] = m[6].replace(/"/g, '\\"'); 2246 return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m); 2247 }, 2248 descendant: 'c = "descendant";', 2249 child: 'c = "child";', 2250 adjacent: 'c = "adjacent";', 2251 laterSibling: 'c = "laterSibling";' 2252 }, 2253 2254 patterns: { 2255 // combinators must be listed first 2256 // (and descendant needs to be last combinator) 2257 laterSibling: /^\s*~\s*/, 2258 child: /^\s*>\s*/, 2259 adjacent: /^\s*\+\s*/, 2260 descendant: /^\s/, 2261 2262 // selectors follow 2263 tagName: /^\s*(\*|[\w\-]+)(\b|$)?/, 2264 id: /^#([\w\-\*]+)(\b|$)/, 2265 className: /^\.([\w\-\*]+)(\b|$)/, 2266 pseudo: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|\s|(?=:))/, 2267 attrPresence: /^\[([\w]+)\]/, 2268 attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\]]*?)\4|([^'"][^\]]*?)))?\]/ 2269 }, 2270 2271 handlers: { 2272 // UTILITY FUNCTIONS 2273 // joins two collections 2274 concat: function(a, b) { 2275 for (var i = 0, node; node = b[i]; i++) 2276 a.push(node); 2277 return a; 2278 }, 2279 2280 // marks an array of nodes for counting 2281 mark: function(nodes) { 2282 for (var i = 0, node; node = nodes[i]; i++) 2283 node._counted = true; 2284 return nodes; 2285 }, 2286 2287 unmark: function(nodes) { 2288 for (var i = 0, node; node = nodes[i]; i++) 2289 node._counted = undefined; 2290 return nodes; 2291 }, 2292 2293 // mark each child node with its position (for nth calls) 2294 // "ofType" flag indicates whether we're indexing for nth-of-type 2295 // rather than nth-child 2296 index: function(parentNode, reverse, ofType) { 2297 parentNode._counted = true; 2298 if (reverse) { 2299 for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) { 2300 node = nodes[i]; 2301 if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++; 2302 } 2303 } else { 2304 for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++) 2305 if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++; 2306 } 2307 }, 2308 2309 // filters out duplicates and extends all nodes 2310 unique: function(nodes) { 2311 if (nodes.length == 0) return nodes; 2312 var results = [], n; 2313 for (var i = 0, l = nodes.length; i < l; i++) 2314 if (!(n = nodes[i])._counted) { 2315 n._counted = true; 2316 results.push(Element.extend(n)); 2317 } 2318 return Selector.handlers.unmark(results); 2319 }, 2320 2321 // COMBINATOR FUNCTIONS 2322 descendant: function(nodes) { 2323 var h = Selector.handlers; 2324 for (var i = 0, results = [], node; node = nodes[i]; i++) 2325 h.concat(results, node.getElementsByTagName('*')); 2326 return results; 2327 }, 2328 2329 child: function(nodes) { 2330 var h = Selector.handlers; 2331 for (var i = 0, results = [], node; node = nodes[i]; i++) { 2332 for (var j = 0, children = [], child; child = node.childNodes[j]; j++) 2333 if (child.nodeType == 1 && child.tagName != '!') results.push(child); 2334 } 2335 return results; 2336 }, 2337 2338 adjacent: function(nodes) { 2339 for (var i = 0, results = [], node; node = nodes[i]; i++) { 2340 var next = this.nextElementSibling(node); 2341 if (next) results.push(next); 2342 } 2343 return results; 2344 }, 2345 2346 laterSibling: function(nodes) { 2347 var h = Selector.handlers; 2348 for (var i = 0, results = [], node; node = nodes[i]; i++) 2349 h.concat(results, Element.nextSiblings(node)); 2350 return results; 2351 }, 2352 2353 nextElementSibling: function(node) { 2354 while (node = node.nextSibling) 2355 if (node.nodeType == 1) return node; 2356 return null; 2357 }, 2358 2359 previousElementSibling: function(node) { 2360 while (node = node.previousSibling) 2361 if (node.nodeType == 1) return node; 2362 return null; 2363 }, 2364 2365 // TOKEN FUNCTIONS 2366 tagName: function(nodes, root, tagName, combinator) { 2367 tagName = tagName.toUpperCase(); 2368 var results = [], h = Selector.handlers; 2369 if (nodes) { 2370 if (combinator) { 2371 // fastlane for ordinary descendant combinators 2372 if (combinator == "descendant") { 2373 for (var i = 0, node; node = nodes[i]; i++) 2374 h.concat(results, node.getElementsByTagName(tagName)); 2375 return results; 2376 } else nodes = this[combinator](nodes); 2377 if (tagName == "*") return nodes; 2378 } 2379 for (var i = 0, node; node = nodes[i]; i++) 2380 if (node.tagName.toUpperCase() == tagName) results.push(node); 2381 return results; 2382 } else return root.getElementsByTagName(tagName); 2383 }, 2384 2385 id: function(nodes, root, id, combinator) { 2386 var targetNode = $(id), h = Selector.handlers; 2387 if (!nodes && root == document) return targetNode ? [targetNode] : []; 2388 if (nodes) { 2389 if (combinator) { 2390 if (combinator == 'child') { 2391 for (var i = 0, node; node = nodes[i]; i++) 2392 if (targetNode.parentNode == node) return [targetNode]; 2393 } else if (combinator == 'descendant') { 2394 for (var i = 0, node; node = nodes[i]; i++) 2395 if (Element.descendantOf(targetNode, node)) return [targetNode]; 2396 } else if (combinator == 'adjacent') { 2397 for (var i = 0, node; node = nodes[i]; i++) 2398 if (Selector.handlers.previousElementSibling(targetNode) == node) 2399 return [targetNode]; 2400 } else nodes = h[combinator](nodes); 2401 } 2402 for (var i = 0, node; node = nodes[i]; i++) 2403 if (node == targetNode) return [targetNode]; 2404 return []; 2405 } 2406 return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : []; 2407 }, 2408 2409 className: function(nodes, root, className, combinator) { 2410 if (nodes && combinator) nodes = this[combinator](nodes); 2411 return Selector.handlers.byClassName(nodes, root, className); 2412 }, 2413 2414 byClassName: function(nodes, root, className) { 2415 if (!nodes) nodes = Selector.handlers.descendant([root]); 2416 var needle = ' ' + className + ' '; 2417 for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) { 2418 nodeClassName = node.className; 2419 if (nodeClassName.length == 0) continue; 2420 if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle)) 2421 results.push(node); 2422 } 2423 return results; 2424 }, 2425 2426 attrPresence: function(nodes, root, attr) { 2427 var results = []; 2428 for (var i = 0, node; node = nodes[i]; i++) 2429 if (Element.hasAttribute(node, attr)) results.push(node); 2430 return results; 2431 }, 2432 2433 attr: function(nodes, root, attr, value, operator) { 2434 if (!nodes) nodes = root.getElementsByTagName("*"); 2435 var handler = Selector.operators[operator], results = []; 2436 for (var i = 0, node; node = nodes[i]; i++) { 2437 var nodeValue = Element.readAttribute(node, attr); 2438 if (nodeValue === null) continue; 2439 if (handler(nodeValue, value)) results.push(node); 2440 } 2441 return results; 2442 }, 2443 2444 pseudo: function(nodes, name, value, root, combinator) { 2445 if (nodes && combinator) nodes = this[combinator](nodes); 2446 if (!nodes) nodes = root.getElementsByTagName("*"); 2447 return Selector.pseudos[name](nodes, value, root); 2448 } 2449 }, 2450 2451 pseudos: { 2452 'first-child': function(nodes, value, root) { 2453 for (var i = 0, results = [], node; node = nodes[i]; i++) { 2454 if (Selector.handlers.previousElementSibling(node)) continue; 2455 results.push(node); 2456 } 2457 return results; 2458 }, 2459 'last-child': function(nodes, value, root) { 2460 for (var i = 0, results = [], node; node = nodes[i]; i++) { 2461 if (Selector.handlers.nextElementSibling(node)) continue; 2462 results.push(node); 2463 } 2464 return results; 2465 }, 2466 'only-child': function(nodes, value, root) { 2467 var h = Selector.handlers; 2468 for (var i = 0, results = [], node; node = nodes[i]; i++) 2469 if (!h.previousElementSibling(node) && !h.nextElementSibling(node)) 2470 results.push(node); 2471 return results; 2472 }, 2473 'nth-child': function(nodes, formula, root) { 2474 return Selector.pseudos.nth(nodes, formula, root); 2475 }, 2476 'nth-last-child': function(nodes, formula, root) { 2477 return Selector.pseudos.nth(nodes, formula, root, true); 2478 }, 2479 'nth-of-type': function(nodes, formula, root) { 2480 return Selector.pseudos.nth(nodes, formula, root, false, true); 2481 }, 2482 'nth-last-of-type': function(nodes, formula, root) { 2483 return Selector.pseudos.nth(nodes, formula, root, true, true); 2484 }, 2485 'first-of-type': function(nodes, formula, root) { 2486 return Selector.pseudos.nth(nodes, "1", root, false, true); 2487 }, 2488 'last-of-type': function(nodes, formula, root) { 2489 return Selector.pseudos.nth(nodes, "1", root, true, true); 2490 }, 2491 'only-of-type': function(nodes, formula, root) { 2492 var p = Selector.pseudos; 2493 return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root); 2494 }, 2495 2496 // handles the an+b logic 2497 getIndices: function(a, b, total) { 2498 if (a == 0) return b > 0 ? [b] : []; 2499 return $R(1, total).inject([], function(memo, i) { 2500 if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i); 2501 return memo; 1848 matchElements: function(elements, expression) { 1849 var selector = new Selector(expression); 1850 return elements.select(selector.match.bind(selector)).map(Element.extend); 1851 }, 1852 1853 findElement: function(elements, expression, index) { 1854 if (typeof expression == 'number') index = expression, expression = false; 1855 return Selector.matchElements(elements, expression || '*')[index || 0]; 1856 }, 1857 1858 findChildElements: function(element, expressions) { 1859 return expressions.map(function(expression) { 1860 return expression.match(/[^\s"]+(?:"[^"]*"[^\s"]+)*/g).inject([null], function(results, expr) { 1861 var selector = new Selector(expr); 1862 return results.inject([], function(elements, result) { 1863 return elements.concat(selector.findElements(result || element)); 1864 }); 2502 1865 }); 2503 }, 2504 2505 // handles nth(-last)-child, nth(-last)-of-type, and (first|last)-of-type 2506 nth: function(nodes, formula, root, reverse, ofType) { 2507 if (nodes.length == 0) return []; 2508 if (formula == 'even') formula = '2n+0'; 2509 if (formula == 'odd') formula = '2n+1'; 2510 var h = Selector.handlers, results = [], indexed = [], m; 2511 h.mark(nodes); 2512 for (var i = 0, node; node = nodes[i]; i++) { 2513 if (!node.parentNode._counted) { 2514 h.index(node.parentNode, reverse, ofType); 2515 indexed.push(node.parentNode); 2516 } 2517 } 2518 if (formula.match(/^\d+$/)) { // just a number 2519 formula = Number(formula); 2520 for (var i = 0, node; node = nodes[i]; i++) 2521 if (node.nodeIndex == formula) results.push(node); 2522 } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b 2523 if (m[1] == "-") m[1] = -1; 2524 var a = m[1] ? Number(m[1]) : 1; 2525 var b = m[2] ? Number(m[2]) : 0; 2526 var indices = Selector.pseudos.getIndices(a, b, nodes.length); 2527 for (var i = 0, node, l = indices.length; node = nodes[i]; i++) { 2528 for (var j = 0; j < l; j++) 2529 if (node.nodeIndex == indices[j]) results.push(node); 2530 } 2531 } 2532 h.unmark(nodes); 2533 h.unmark(indexed); 2534 return results; 2535 }, 2536 2537 'empty': function(nodes, value, root) { 2538 for (var i = 0, results = [], node; node = nodes[i]; i++) { 2539 // IE treats comments as element nodes 2540 if (node.tagName == '!' || (node.firstChild && !node.innerHTML.match(/^\s*$/))) continue; 2541 results.push(node); 2542 } 2543 return results; 2544 }, 2545 2546 'not': function(nodes, selector, root) { 2547 var h = Selector.handlers, selectorType, m; 2548 var exclusions = new Selector(selector).findElements(root); 2549 h.mark(exclusions); 2550 for (var i = 0, results = [], node; node = nodes[i]; i++) 2551 if (!node._counted) results.push(node); 2552 h.unmark(exclusions); 2553 return results; 2554 }, 2555 2556 'enabled': function(nodes, value, root) { 2557 for (var i = 0, results = [], node; node = nodes[i]; i++) 2558 if (!node.disabled) results.push(node); 2559 return results; 2560 }, 2561 2562 'disabled': function(nodes, value, root) { 2563 for (var i = 0, results = [], node; node = nodes[i]; i++) 2564 if (node.disabled) results.push(node); 2565 return results; 2566 }, 2567 2568 'checked': function(nodes, value, root) { 2569 for (var i = 0, results = [], node; node = nodes[i]; i++) 2570 if (node.checked) results.push(node); 2571 return results; 2572 } 2573 }, 2574 2575 operators: { 2576 '=': function(nv, v) { return nv == v; }, 2577 '!=': function(nv, v) { return nv != v; }, 2578 '^=': function(nv, v) { return nv.startsWith(v); }, 2579 '$=': function(nv, v) { return nv.endsWith(v); }, 2580 '*=': function(nv, v) { return nv.include(v); }, 2581 '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); }, 2582 '|=': function(nv, v) { return ('-' + nv.toUpperCase() + '-').include('-' + v.toUpperCase() + '-'); } 2583 }, 2584 2585 matchElements: function(elements, expression) { 2586 var matches = new Selector(expression).findElements(), h = Selector.handlers; 2587 h.mark(matches); 2588 for (var i = 0, results = [], element; element = elements[i]; i++) 2589 if (element._counted) results.push(element); 2590 h.unmark(matches); 2591 return results; 2592 }, 2593 2594 findElement: function(elements, expression, index) { 2595 if (typeof expression == 'number') { 2596 index = expression; expression = false; 2597 } 2598 return Selector.matchElements(elements, expression || '*')[index || 0]; 2599 }, 2600 2601 findChildElements: function(element, expressions) { 2602 var exprs = expressions.join(','), expressions = []; 2603 exprs.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) { 2604 expressions.push(m[1].strip()); 2605 }); 2606 var results = [], h = Selector.handlers; 2607 for (var i = 0, l = expressions.length, selector; i < l; i++) { 2608 selector = new Selector(expressions[i].strip()); 2609 h.concat(results, selector.findElements(element)); 2610 } 2611 return (l > 1) ? h.unique(results) : results; 1866 }).flatten(); 2612 1867 } 2613 1868 }); … … 2626 1881 if (!element.disabled && element.name) { 2627 1882 var key = element.name, value = $(element).getValue(); 2628 if (value != null) {2629 if (key in result) {1883 if (value != undefined) { 1884 if (result[key]) { 2630 1885 if (result[key].constructor != Array) result[key] = [result[key]]; 2631 1886 result[key].push(value); … … 2674 1929 disable: function(form) { 2675 1930 form = $(form); 2676 Form.getElements(form).invoke('disable'); 1931 form.getElements().each(function(element) { 1932 element.blur(); 1933 element.disabled = 'true'; 1934 }); 2677 1935 return form; 2678 1936 }, … … 2680 1938 enable: function(form) { 2681 1939 form = $(form); 2682 Form.getElements(form).invoke('enable'); 1940 form.getElements().each(function(element) { 1941 element.disabled = ''; 1942 }); 2683 1943 return form; 2684 1944 }, … … 2695 1955 form.findFirstElement().activate(); 2696 1956 return form; 2697 }, 2698 2699 request: function(form, options) { 2700 form = $(form), options = Object.clone(options || {}); 2701 2702 var params = options.parameters; 2703 options.parameters = form.serialize(true); 2704 2705 if (params) { 2706 if (typeof params == 'string') params = params.toQueryParams(); 2707 Object.extend(options.parameters, params); 2708 } 2709 2710 if (form.hasAttribute('method') && !options.method) 2711 options.method = form.method; 2712 2713 return new Ajax.Request(form.readAttribute('action'), options); 2714 } 2715 } 1957 } 1958 } 1959 1960 Object.extend(Form, Form.Methods); 2716 1961 2717 1962 /*--------------------------------------------------------------------------*/ … … 2760 2005 activate: function(element) { 2761 2006 element = $(element); 2762 try { 2763 element.focus(); 2764 if (element.select && (element.tagName.toLowerCase() != 'input' || 2765 !['button', 'reset', 'submit'].include(element.type))) 2766 element.select(); 2767 } catch (e) {} 2007 element.focus(); 2008 if (element.select && ( element.tagName.toLowerCase() != 'input' || 2009 !['button', 'reset', 'submit'].include(element.type) ) ) 2010 element.select(); 2768 2011 return element; 2769 2012 }, … … 2771 2014 disable: function(element) { 2772 2015 element = $(element); 2773 element.blur();2774 2016 element.disabled = true; 2775 2017 return element; … … 2778 2020 enable: function(element) { 2779 2021 element = $(element); 2022 element.blur(); 2780 2023 element.disabled = false; 2781 2024 return element; … … 2783 2026 } 2784 2027 2785 /*--------------------------------------------------------------------------*/ 2786 2028 Object.extend(Form.Element, Form.Element.Methods); 2787 2029 var Field = Form.Element; 2788 var $F = Form.Element. Methods.getValue;2030 var $F = Form.Element.getValue; 2789 2031 2790 2032 /*--------------------------------------------------------------------------*/ … … 2953 2195 2954 2196 element: function(event) { 2955 return $(event.target || event.srcElement);2197 return event.target || event.srcElement; 2956 2198 }, 2957 2199 … … 3018 2260 3019 2261 if (name == 'keypress' && 3020 (Prototype.Browser.WebKit || element.attachEvent)) 2262 (navigator.appVersion.match(/Konqueror|Safari|KHTML/) 2263 || element.attachEvent)) 3021 2264 name = 'keydown'; 3022 2265 … … 3029 2272 3030 2273 if (name == 'keypress' && 3031 (Prototype.Browser.WebKit || element.attachEvent)) 2274 (navigator.appVersion.match(/Konqueror|Safari|KHTML/) 2275 || element.detachEvent)) 3032 2276 name = 'keydown'; 3033 2277 … … 3043 2287 3044 2288 /* prevent memory leaks in IE */ 3045 if ( Prototype.Browser.IE)2289 if (navigator.appVersion.match(/\bMSIE\b/)) 3046 2290 Event.observe(window, 'unload', Event.unloadCache, false); 3047 2291 var Position = { … … 3157 2401 3158 2402 // Safari fix 3159 if (element.offsetParent ==document.body)2403 if (element.offsetParent==document.body) 3160 2404 if (Element.getStyle(element,'position')=='absolute') break; 3161 2405 … … 3253 2497 // positioned. For performance reasons, redefine Position.cumulativeOffset for 3254 2498 // KHTML/WebKit only. 3255 if ( Prototype.Browser.WebKit) {2499 if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) { 3256 2500 Position.cumulativeOffset = function(element) { 3257 2501 var valueT = 0, valueL = 0; trunk/wp-includes/js/scriptaculous/builder.js
r972 r1005 1 // script.aculo.us builder.js v1.7. 1_beta2, Sat Apr 28 15:20:12 CEST 20071 // script.aculo.us builder.js v1.7.0, Fri Jan 19 19:16:36 CET 2007 2 2 3 // Copyright (c) 2005 -2007Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)3 // Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 4 4 // 5 5 // script.aculo.us is freely distributable under the terms of an MIT-style license. … … 49 49 if(arguments[1]) 50 50 if(this._isStringOrNumber(arguments[1]) || 51 (arguments[1] instanceof Array) || 52 arguments[1].tagName) { 51 (arguments[1] instanceof Array)) { 53 52 this._children(element, arguments[1]); 54 53 } else { … … 68 67 if(element.tagName.toUpperCase() != elementName) 69 68 element = parentElement.getElementsByTagName(elementName)[0]; 70 }69 } 71 70 } 72 71 … … 94 93 }, 95 94 _children: function(element, children) { 96 if(children.tagName) {97 element.appendChild(children);98 return;99 }100 95 if(typeof children=='object') { // array can hold nodes and text 101 96 children.flatten().each( function(e) { … … 107 102 }); 108 103 } else 109 if(Builder._isStringOrNumber(children)) 110 element.appendChild(Builder._text(children));104 if(Builder._isStringOrNumber(children)) 105 element.appendChild(Builder._text(children)); 111 106 }, 112 107 _isStringOrNumber: function(param) { trunk/wp-includes/js/scriptaculous/controls.js
r972 r1005 1 // script.aculo.us controls.js v1.7. 1_beta2, Sat Apr 28 15:20:12 CEST 20072 3 // Copyright (c) 2005 -2007Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)4 // (c) 2005 -2007Ivan Krstic (http://blogs.law.harvard.edu/ivan)5 // (c) 2005 -2007Jon Tirsen (http://www.tirsen.com)1 // script.aculo.us controls.js v1.7.0, Fri Jan 19 19:16:36 CET 2007 2 3 // Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 4 // (c) 2005, 2006 Ivan Krstic (http://blogs.law.harvard.edu/ivan) 5 // (c) 2005, 2006 Jon Tirsen (http://www.tirsen.com) 6 6 // Contributors: 7 7 // Richard Livsey … … 44 44 Autocompleter.Base.prototype = { 45 45 baseInitialize: function(element, update, options) { 46 element = $(element) 47 this.element = element; 46 this.element = $(element); 48 47 this.update = $(update); 49 48 this.hasFocus = false; … … 85 84 Element.hide(this.update); 86 85 87 Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this)); 88 Event.observe(this.element, 'keypress', this.onKeyPress.bindAsEventListener(this)); 89 90 // Turn autocomplete back on when the user leaves the page, so that the 91 // field's value will be remembered on Mozilla-based browsers. 92 Event.observe(window, 'beforeunload', function(){ 93 element.setAttribute('autocomplete', 'on'); 94 }); 86 Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this)); 87 Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this)); 95 88 }, 96 89 … … 98 91 if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update); 99 92 if(!this.iefix && 100 (Prototype.Browser.IE) && 93 (navigator.appVersion.indexOf('MSIE')>0) && 94 (navigator.userAgent.indexOf('Opera')<0) && 101 95 (Element.getStyle(this.update, 'position')=='absolute')) { 102 96 new Insertion.After(this.update, … … 148 142 this.markPrevious(); 149 143 this.render(); 150 if( Prototype.Browser.WebKit) Event.stop(event);144 if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event); 151 145 return; 152 146 case Event.KEY_DOWN: 153 147 this.markNext(); 154 148 this.render(); 155 if( Prototype.Browser.WebKit) Event.stop(event);149 if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event); 156 150 return; 157 151 } 158 152 else 159 153 if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN || 160 ( Prototype.Browser.WebKit> 0 && event.keyCode == 0)) return;154 (navigator.appVersion.indexOf('AppleWebKit') > 0 && event.keyCode == 0)) return; 161 155 162 156 this.changed = true; … … 204 198 Element.addClassName(this.getEntry(i),"selected") : 205 199 Element.removeClassName(this.getEntry(i),"selected"); 200 206 201 if(this.hasFocus) { 207 202 this.show(); … … 305 300 this.changed = false; 306 301 if(this.getToken().length>=this.options.minChars) { 302 this.startIndicator(); 307 303 this.getUpdatedChoices(); 308 304 } else { … … 345 341 346 342 getUpdatedChoices: function() { 347 this.startIndicator(); 348 349 var entry = encodeURIComponent(this.options.paramName) + '=' + 343 entry = encodeURIComponent(this.options.paramName) + '=' + 350 344 encodeURIComponent(this.getToken()); 351 345 … … 355 349 if(this.options.defaultParams) 356 350 this.options.parameters += '&' + this.options.defaultParams; 357 351 358 352 new Ajax.Request(this.url, this.options); 359 353 }, … … 484 478 paramName: "value", 485 479 okButton: true, 486 okLink: false,487 480 okText: "ok", 488 cancelButton: false,489 481 cancelLink: true, 490 482 cancelText: "cancel", 491 textBeforeControls: '',492 textBetweenControls: '',493 textAfterControls: '',494 483 savingText: "Saving...", 495 484 clickToEditText: "Click to edit",
