Changes from tags/2.1.3 at r5468 to tags/2.2 at r5480
- Location:
- tags
- Files:
-
- 29 added
- 8 deleted
- 163 edited
Legend:
- Unmodified
- Added
- Removed
-
tags/2.2/readme.html
r5468 r5480 9 9 <h1 id="logo" style="text-align: center"> 10 10 <img alt="WordPress" src="wp-admin/images/wordpress-logo.png" /> 11 <br /> Version 2. 111 <br /> Version 2.2 12 12 </h1> 13 13 <p style="text-align: center">Semantic Personal Publishing Platform</p> … … 30 30 <h1>Upgrading</h1> 31 31 <p>Before you upgrade anything, make sure you have backup copies of any files you may have modified such as <code>index.php</code>.</p> 32 <h2>Upgrading from any previous WordPress to 2. 1:</h2>32 <h2>Upgrading from any previous WordPress to 2.2:</h2> 33 33 <ol> 34 34 <li>Delete your old WP files, saving ones you've modified.</li> … … 52 52 <dd>If you've looked everywhere and still can't find an answer, the support forums are very active and have a large community ready to help. To help them help you be sure to use a descriptive thread title and describe your question in as much detail as possible.</dd> 53 53 <dt><a href="http://codex.wordpress.org/IRC">WordPress IRC Channel</a></dt> 54 <dd>Finally, there is an online chat channel that is used for discussion among people who use WordPress and occasionally support topics. The above wiki page should point you in the right direction. ( irc.freenode.net #wordpress)</dd>54 <dd>Finally, there is an online chat channel that is used for discussion among people who use WordPress and occasionally support topics. The above wiki page should point you in the right direction. (<a href="irc://irc.freenode.net/wordpress">irc.freenode.net #wordpress</a>)</dd> 55 55 </dl> 56 56 57 57 <h1>System Recommendations</h1> 58 58 <ul> 59 <li>PHP version <strong>4. 1</strong> or higher.</li>59 <li>PHP version <strong>4.2</strong> or higher.</li> 60 60 <li>MySQL version <strong>4.0</strong> or higher.</li> 61 61 <li>... and a link to <a href="http://wordpress.org/">http://wordpress.org</a> on your site.</li> … … 64 64 65 65 <h1>Upgrading from another system</h1> 66 <p>WordPress can <a href="http://codex.wordpress.org/Importing_ from_other_blogging_software">import from a number of systems</a>. First you need to get WordPress installed and working as described above.</p>66 <p>WordPress can <a href="http://codex.wordpress.org/Importing_Content">import from a number of systems</a>. First you need to get WordPress installed and working as described above.</p> 67 67 68 <h1>XML-RPC Interface</h1>69 <p>You can now post to your WordPress blog with tools like <a href="http:// ecto.kung-foo.tv/">Ecto</a>, <a href="http://blogbuddy.sourceforge.net">BlogBuddy</a>, <a href="http://bloggar.com/">Bloggar</a>, <a href="http://www.ubique.ch/wapblogger/">WapBlogger</a> (post from your Wap cellphone!), <a href="http://radio.userland.com">Radio Userland</a> (which means you can use Radio's email-to-blog feature), <a href="http://www.zempt.com/">Zempt</a>, <a href="http://www.newzcrawler.com/">NewzCrawler</a>, and other tools that support the Blogging APIs! :) You can read more about <a href="http://codex.wordpress.org/XML-RPC_Support">XML-RPC support on the Codex</a>.</p>68 <h1>XML-RPC and Atom Interface</h1> 69 <p>You can now post to your WordPress blog with tools like <a href="http://windowslivewriter.spaces.live.com/">Windows Live Writer</a>, <a href="http://ecto.kung-foo.tv/">Ecto</a>, <a href="http://bloggar.com/">Bloggar</a>, <a href="http://radio.userland.com">Radio Userland</a> (which means you can use Radio's email-to-blog feature), <a href="http://www.newzcrawler.com/">NewzCrawler</a>, and other tools that support the Blogging APIs! :) You can read more about <a href="http://codex.wordpress.org/XML-RPC_Support">XML-RPC support on the Codex</a>.</p> 70 70 71 71 <h1>Post via Email</h1> -
tags/2.2/wp-admin/admin-ajax.php
r5468 r5480 152 152 $x->send(); 153 153 break; 154 case 'add-comment' : 155 if ( !current_user_can( 'edit_post', $id ) ) 156 die('-1'); 157 $search = isset($_POST['s']) ? $_POST['s'] : false; 158 $start = isset($_POST['page']) ? intval($_POST['page']) * 25 : 25; 159 160 list($comments, $total) = _wp_get_comment_list( $search, $start, 1 ); 161 162 if ( !$comments ) 163 die('1'); 164 $x = new WP_Ajax_Response(); 165 foreach ( (array) $comments as $comment ) { 166 get_comment( $comment ); 167 ob_start(); 168 _wp_comment_list_item( $comment->comment_ID ); 169 $comment_list_item = ob_get_contents(); 170 ob_end_clean(); 171 $x->add( array( 172 'what' => 'comment', 173 'id' => $comment->comment_ID, 174 'data' => $comment_list_item 175 ) ); 176 } 177 $x->send(); 178 break; 154 179 case 'add-meta' : 155 180 if ( !current_user_can( 'edit_post', $id ) ) … … 227 252 $_POST['post_category'] = explode(",", $_POST['catslist']); 228 253 if($_POST['post_type'] == 'page' || empty($_POST['post_category'])) 229 unset($_POST['post_category']); 230 254 unset($_POST['post_category']); 255 231 256 if($_POST['post_ID'] < 0) { 232 257 $_POST['temp_ID'] = $_POST['post_ID']; -
tags/2.2/wp-admin/admin-db.php
r5468 r5480 149 149 clean_category_cache($cat_ID); 150 150 151 if ($update) 152 do_action('edited_category', $cat_ID); 153 else 154 do_action('created_category', $cat_ID); 155 151 156 return $cat_ID; 152 157 } … … 416 421 $wpdb->query("DELETE FROM $wpdb->link2cat WHERE link_id = '$link_id'"); 417 422 return $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$link_id'"); 423 424 do_action('deleted_link', $link_id); 418 425 } 419 426 -
tags/2.2/wp-admin/admin-functions.php
r5468 r5480 23 23 24 24 // Check for autosave collisions 25 $temp_id = false; 25 26 if ( isset($_POST['temp_ID']) ) { 26 27 $temp_id = (int) $_POST['temp_ID']; … … 34 35 $_POST['post_ID'] = $draft_ids[$temp_id]; 35 36 unset($_POST['temp_ID']); 36 relocate_children( $temp_id, $_POST['post_ID'] );37 37 update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids ); 38 38 return edit_post(); … … 113 113 114 114 // Reunite any orphaned attachments with their parent 115 if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) ) 116 $draft_ids = array(); 117 if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) ) 118 relocate_children( $draft_temp_id, $post_ID ); 119 if ( $temp_id && $temp_id != $draft_temp_id ) 120 relocate_children( $temp_id, $post_ID ); 121 115 122 // Update autosave collision detection 116 123 if ( $temp_id ) { 117 relocate_children( $temp_id, $post_ID );118 124 $draft_ids[$temp_id] = $post_ID; 119 125 update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids ); … … 280 286 add_meta( $post_ID ); 281 287 282 wp_update_post( $_POST); 288 wp_update_post( $_POST ); 289 290 // Reunite any orphaned attachments with their parent 291 if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) ) 292 $draft_ids = array(); 293 if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) ) 294 relocate_children( $draft_temp_id, $post_ID ); 283 295 284 296 // Now that we have an ID we can fix any attachment anchor hrefs … … 670 682 // No selected categories, strange 671 683 $checked_categories[] = $default; 672 } 684 } 673 685 } else { 674 686 $checked_categories[] = $default; … … 694 706 function write_nested_categories( $categories ) { 695 707 foreach ( $categories as $category ) { 696 echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : "" ), '/> ', wp_specialchars( $category['cat_name']), "</label></li>";708 echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : "" ), '/> ', wp_specialchars( apply_filters('the_category', $category['cat_name'] )), "</label></li>"; 697 709 698 710 if ( $category['children'] ) { … … 726 738 // No selected categories, strange 727 739 $checked_categories[] = $default; 728 } 740 } 729 741 } else { 730 742 $checked_categories[] = $default; … … 757 769 $categories = get_categories( 'hide_empty=0' ); 758 770 771 $children = _get_category_hierarchy(); 772 759 773 if ( $categories ) { 760 774 ob_start(); … … 762 776 if ( $category->category_parent == $parent) { 763 777 echo "\t" . _cat_row( $category, $level ); 764 cat_rows( $category->cat_ID, $level +1, $categories ); 778 if ( isset($children[$category->cat_ID]) ) 779 cat_rows( $category->cat_ID, $level +1, $categories ); 765 780 } 766 781 } 767 782 $output = ob_get_contents(); 768 783 ob_end_clean(); 769 784 770 785 $output = apply_filters('cat_rows', $output); 771 786 … … 786 801 787 802 if ( ($category->cat_ID != $default_cat_id ) && ($category->cat_ID != $default_link_cat_id ) ) 788 $edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&cat_ID=$category->cat_ID", 'delete-category_' . $category->cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . js_escape(sprintf( __("You are about to delete the category '%s'.\nAll of its posts will go into the default category of '%s'\nAll of its bookmarks will go into the default category of '%s'.\n'OK' to delete, 'Cancel' to stop." ), $category->cat_name, get_catname( $default_cat_id ), get_catname( $default_link_cat_id ) )) . "' );\" class='delete'>".__( 'Delete' )."</a>";803 $edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&cat_ID=$category->cat_ID", 'delete-category_' . $category->cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . js_escape(sprintf( __("You are about to delete the category '%s'.\nAll posts that were only assigned to this category will be assigned to the '%s' category.\nAll links that were only assigned to this category will be assigned to the '%s' category.\n'OK' to delete, 'Cancel' to stop." ), $category->cat_name, get_catname( $default_cat_id ), get_catname( $default_link_cat_id ) )) . "' );\" class='delete'>".__( 'Delete' )."</a>"; 789 804 else 790 805 $edit .= "<td style='text-align:center'>".__( "Default" ); … … 873 888 $r .= "</td>\n\t</tr>"; 874 889 return $r; 890 } 891 892 function _wp_get_comment_list( $s = false, $start, $num ) { 893 global $wpdb; 894 895 $start = (int) $start; 896 $num = (int) $num; 897 898 if ( $s ) { 899 $s = $wpdb->escape($s); 900 $comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE 901 (comment_author LIKE '%$s%' OR 902 comment_author_email LIKE '%$s%' OR 903 comment_author_url LIKE ('%$s%') OR 904 comment_author_IP LIKE ('%$s%') OR 905 comment_content LIKE ('%$s%') ) AND 906 comment_approved != 'spam' 907 ORDER BY comment_date DESC LIMIT $start, $num"); 908 } else { 909 $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start, $num" ); 910 } 911 912 $total = $wpdb->get_var( "SELECT FOUND_ROWS()" ); 913 914 return array($comments, $total); 915 } 916 917 function _wp_comment_list_item( $id, $alt = 0 ) { 918 global $authordata, $comment, $wpdb; 919 $id = (int) $id; 920 $comment =& get_comment( $id ); 921 $class = ''; 922 $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); 923 $comment_status = wp_get_comment_status($comment->comment_ID); 924 if ( 'unapproved' == $comment_status ) 925 $class .= ' unapproved'; 926 if ( $alt % 2 ) 927 $class .= ' alternate'; 928 echo "<li id='comment-$comment->comment_ID' class='$class'>"; 929 ?> 930 <p><strong><?php comment_author(); ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p> 931 932 <?php comment_text() ?> 933 934 <p><?php comment_date(__('M j, g:i A')); ?> — [ 935 <?php 936 if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 937 echo " <a href='comment.php?action=editcomment&c=".$comment->comment_ID."'>" . __('Edit') . '</a>'; 938 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> '; 939 if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { 940 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>'; 941 echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>'; 942 } 943 echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&dt=spam&p=" . $comment->comment_post_ID . "&c=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to mark as spam this comment by '%s'.\n'Cancel' to stop, 'OK' to mark as spam."), $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . "</a> "; 944 } 945 $post = get_post($comment->comment_post_ID); 946 $post_title = wp_specialchars( $post->post_title, 'double' ); 947 $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; 948 ?> 949 ] — <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo $post_title; ?></a></p> 950 </li> 951 <?php 875 952 } 876 953 … … 1132 1209 $state = true; 1133 1210 foreach ( $markerdata as $n => $markerline ) { 1134 if ( strstr( $markerline, "# BEGIN {$marker}" ))1211 if (strpos($markerline, '# BEGIN ' . $marker) !== false) 1135 1212 $state = false; 1136 1213 if ( $state ) { … … 1140 1217 fwrite( $f, "{$markerline}" ); 1141 1218 } 1142 if ( strstr( $markerline, "# END {$marker}" )) {1219 if (strpos($markerline, '# END ' . $marker) !== false) { 1143 1220 fwrite( $f, "# BEGIN {$marker}\n" ); 1144 1221 if ( is_array( $insertion )) … … 1178 1255 $state = false; 1179 1256 foreach ( $markerdata as $markerline ) { 1180 if ( strstr( $markerline, "# END {$marker}" ))1257 if (strpos($markerline, '# END ' . $marker) !== false) 1181 1258 $state = false; 1182 1259 if ( $state ) 1183 1260 $result[] = $markerline; 1184 if ( strstr( $markerline, "# BEGIN {$marker}" ))1261 if (strpos($markerline, '# BEGIN ' . $marker) !== false) 1185 1262 $state = true; 1186 1263 } … … 1305 1382 if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) ) 1306 1383 return false; 1307 1384 1308 1385 if ( empty( $parent) ) { 1309 1386 if ( isset( $_wp_menu_nopriv[$pagenow] ) ) … … 1317 1394 return false; 1318 1395 if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) ) 1319 return false; 1396 return false; 1320 1397 } 1321 1398 return true; … … 1439 1516 $parent_file = $_wp_real_parent_file[$parent_file]; 1440 1517 return $parent_file; 1441 } 1518 } 1442 1519 } 1443 1520 … … 1446 1523 if ( isset( $_wp_real_parent_file[$parent_file] ) ) 1447 1524 $parent_file = $_wp_real_parent_file[$parent_file]; 1448 return $parent_file; 1525 return $parent_file; 1449 1526 } 1450 1527 … … 1660 1737 } 1661 1738 1662 return array ('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1]);1739 return array('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version); 1663 1740 } 1664 1741 … … 1677 1754 if ( $plugins_dir ) { 1678 1755 while (($file = $plugins_dir->read() ) !== false ) { 1679 if ( preg_match( '|^\.+$|', $file ))1756 if ( substr($file, 0, 1) == '.' ) 1680 1757 continue; 1681 1758 if ( is_dir( $plugin_root.'/'.$file ) ) { … … 1683 1760 if ( $plugins_subdir ) { 1684 1761 while (($subfile = $plugins_subdir->read() ) !== false ) { 1685 if ( preg_match( '|^\.+$|', $subfile ))1762 if ( substr($subfile, 0, 1) == '.' ) 1686 1763 continue; 1687 if ( preg_match( '|\.php$|', $subfile ))1764 if ( substr($subfile, -4) == '.php' ) 1688 1765 $plugin_files[] = "$file/$subfile"; 1689 1766 } 1690 1767 } 1691 1768 } else { 1692 if ( preg_match( '|\.php$|', $file ))1769 if ( substr($file, -4) == '.php' ) 1693 1770 $plugin_files[] = $file; 1694 1771 } … … 1755 1832 '; 1756 1833 } 1757 if ( strstr( $_SERVER['HTTP_USER_AGENT'], 'MSIE' )) 1834 1835 if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) 1758 1836 add_action( 'admin_footer', 'browse_happy' ); 1759 1837 … … 1770 1848 function get_importers() { 1771 1849 global $wp_importers; 1772 1850 uasort($wp_importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);')); 1773 1851 return $wp_importers; 1774 1852 } … … 1894 1972 // Compute the URL 1895 1973 $url = $uploads['url'] . "/$filename"; 1896 1974 1897 1975 $return = apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ) ); 1898 1976 … … 1916 1994 $size = strtolower( ini_get( 'upload_max_filesize' ) ); 1917 1995 $bytes = 0; 1918 if ( strstr( $size, 'k' ))1996 if (strpos($size, 'k') !== false) 1919 1997 $bytes = $size * 1024; 1920 if ( strstr( $size, 'm' ))1998 if (strpos($size, 'm') !== false) 1921 1999 $bytes = $size * 1024 * 1024; 1922 if ( strstr( $size, 'g' ))2000 if (strpos($size, 'g') !== false) 1923 2001 $bytes = $size * 1024 * 1024 * 1024; 1924 2002 ?> 1925 2003 <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo attribute_escape($action) ?>"> 1926 2004 <p> 2005 <?php wp_nonce_field('import-upload'); ?> 1927 2006 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?> ) 1928 2007 <input type="file" id="upload" name="import" size="25" /> … … 2053 2132 wp_clearcookie(); 2054 2133 // Set cookies for new paths. 2055 wp_setcookie( $user_login, $user_pass_md5, true, get_option( 'home' ), get_option( 'siteurl' )); 2134 wp_setcookie( $user_login, $user_pass_md5, true, get_option( 'home' ), get_option( 'siteurl' )); 2056 2135 } 2057 2136 … … 2075 2154 } 2076 2155 2077 imageantialias( $dst, true ); 2156 if (function_exists('imageantialias')) 2157 imageantialias( $dst, true ); 2158 2078 2159 imagecopyresampled( $dst, $src, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h ); 2079 2160 … … 2195 2276 // If no filters change the filename, we'll do a default transformation. 2196 2277 if ( basename( $file ) == $thumb = apply_filters( 'thumbnail_filename', basename( $file ) ) ) 2197 $thumb = preg_replace( '!(\.[^.]+)?$!', __( '.thumbnail' ).'$1', basename( $file ), 1 );2278 $thumb = preg_replace( '!(\.[^.]+)?$!', '.thumbnail' . '$1', basename( $file ), 1 ); 2198 2279 2199 2280 $thumbpath = str_replace( basename( $file ), $thumb, $file ); -
tags/2.2/wp-admin/admin-header.php
r5468 r5480 14 14 ?> 15 15 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 16 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>16 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> 17 17 <head> 18 18 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> … … 45 45 <body> 46 46 <div id="wphead"> 47 <h1><?php echo wptexturize(get_option(('blogname'))); ?> <span>(<a href="<?php echo get_option('home') . '/'; ?>"><?php _e('View site »') ?></a>)</span></h1>47 <h1><?php bloginfo('name'); ?> <span>(<a href="<?php echo get_option('home') . '/'; ?>"><?php _e('View site »') ?></a>)</span></h1> 48 48 </div> 49 49 <div id="user_info"><p><?php printf(__('Howdy, <strong>%s</strong>.'), $user_identity) ?> [<a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="<?php _e('Log out of this account') ?>"><?php _e('Sign Out'); ?></a>, <a href="profile.php"><?php _e('My Profile'); ?></a>] </p></div> -
tags/2.2/wp-admin/admin.php
r5468 r5480 5 5 require_once('../wp-config.php'); 6 6 7 if ( get_option('db_version') != $wp_db_version ) 8 wp_die(sprintf(__("Your database is out-of-date. Please <a href='%s'>upgrade</a>."), get_option('siteurl') . '/wp-admin/upgrade.php')); 9 7 if ( get_option('db_version') != $wp_db_version ) { 8 wp_redirect(get_option('siteurl') . '/wp-admin/upgrade.php?_wp_http_referer=' . urlencode(stripslashes($_SERVER['REQUEST_URI']))); 9 exit; 10 } 11 10 12 require_once(ABSPATH . 'wp-admin/admin-functions.php'); 11 13 require_once(ABSPATH . 'wp-admin/admin-db.php'); -
tags/2.2/wp-admin/categories.js
r5468 r5480 3 3 document.forms.addcat.submit.onclick = function(e) {return killSubmit('theList.ajaxAdder("cat", "addcat");', e); }; 4 4 theList.addComplete = function(what, where, update, transport) { 5 var name = getNodeValue(transport.responseXML, 'name') ;5 var name = getNodeValue(transport.responseXML, 'name').unescapeHTML(); 6 6 var id = transport.responseXML.getElementsByTagName(what)[0].getAttribute('id'); 7 7 var options = document.forms['addcat'].category_parent.options; -
tags/2.2/wp-admin/categories.php
r5468 r5480 115 115 <?php if ( current_user_can('manage_categories') ) : ?> 116 116 <div class="wrap"> 117 <p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts and links in that category. Instead, posts in the deleted category are set to the category <strong>%s</strong> and links are set to <strong>%s</strong>.'), get_catname(get_option('default_category')), get_catname(get_option('default_link_category'))) ?></p>117 <p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts and links in that category. Instead, posts that were only assigned to the deleted category are set to the category <strong>%s</strong> and links that were only assigned to the deleted category are set to <strong>%s</strong>.'), apply_filters('the_category', get_catname(get_option('default_category'))), apply_filters('the_category', get_catname(get_option('default_link_category')))) ?></p> 118 118 </div> 119 119 -
tags/2.2/wp-admin/custom-header.php
-
Property
svn:eol-style
set to
native
r5468 r5480 18 18 function js_includes() { 19 19 wp_enqueue_script('cropper'); 20 wp_enqueue_script('colorpicker'); 20 wp_enqueue_script('colorpicker'); 21 21 } 22 22 … … 24 24 25 25 if ( isset( $_POST['textcolor'] ) ) { 26 check_admin_referer('custom-header'); 26 27 if ( 'blank' == $_POST['textcolor'] ) { 27 28 set_theme_mod('header_textcolor', 'blank'); … … 32 33 } 33 34 } 34 if ( isset($_POST['resetheader']) ) 35 if ( isset($_POST['resetheader']) ) { 36 check_admin_referer('custom-header'); 35 37 remove_theme_mods(); 38 } 36 39 ?> 37 40 <script type="text/javascript"> … … 116 119 pickColor('<?php echo HEADER_TEXTCOLOR; ?>'); 117 120 } 118 121 119 122 function hide_text() { 120 123 $('name').style.display = 'none'; … … 127 130 Event.observe( $('hidetext'), 'click', show_text ); 128 131 } 129 132 130 133 function show_text() { 131 134 $('name').style.display = 'block'; … … 135 138 $('textcolor').value = '<?php echo HEADER_TEXTCOLOR; ?>'; 136 139 $('hidetext').value = '<?php _e('Hide Text'); ?>'; 137 Event.stopObserving( $('hidetext'), 'click', show_text ); 140 Event.stopObserving( $('hidetext'), 'click', show_text ); 138 141 Event.observe( $('hidetext'), 'click', hide_text ); 139 142 } … … 158 161 <p><?php _e('This is your header image. You can change the text color or upload and crop a new image.'); ?></p> 159 162 160 <div id="headimg" style="background: url(<?php header_image() ?>) no-repeat;">163 <div id="headimg" style="background: url(<?php clean_url(header_image()) ?>) no-repeat;"> 161 164 <h1><a onclick="return false;" href="<?php bloginfo('url'); ?>" title="<?php bloginfo('name'); ?>" id="name"><?php bloginfo('name'); ?></a></h1> 162 165 <div id="desc"><?php bloginfo('description');?></div> … … 166 169 <input type="button" value="<?php _e('Hide Text'); ?>" onclick="hide_text()" id="hidetext" /> 167 170 <input type="button" value="<?php _e('Select a Text Color'); ?>" onclick="colorSelect($('textcolor'), 'pickcolor')" id="pickcolor" /><input type="button" value="<?php _e('Use Original Color'); ?>" onclick="colorDefault()" id="defaultcolor" /> 168 <input type="hidden" name="textcolor" id="textcolor" value="#<?php header_textcolor() ?>" /><input name="submit" type="submit" value="<?php _e('Save Changes'); ?> »" /></form> 171 <?php wp_nonce_field('custom-header') ?> 172 <input type="hidden" name="textcolor" id="textcolor" value="#<?php attribute_escape(header_textcolor()) ?>" /><input name="submit" type="submit" value="<?php _e('Save Changes'); ?> »" /></form> 169 173 <?php } ?> 170 174 … … 178 182 <label for="upload"><?php _e('Choose an image from your computer:'); ?></label><br /><input type="file" id="upload" name="import" /> 179 183 <input type="hidden" name="action" value="save" /> 184 <?php wp_nonce_field('custom-header') ?> 180 185 <p class="submit"> 181 186 <input type="submit" value="<?php _e('Upload'); ?> »" /> … … 190 195 <p><?php _e('This will restore the original header image and color. You will not be able to retrieve any customizations.') ?></p> 191 196 <form method="post" action="<?php echo attribute_escape(add_query_arg('step', 1)) ?>"> 197 <?php wp_nonce_field('custom-header'); ?> 192 198 <input type="submit" name="resetheader" value="<?php _e('Restore Original Header'); ?>" /> 193 199 </form> … … 198 204 199 205 function step_2() { 206 check_admin_referer('custom-header'); 200 207 $overrides = array('test_form' => false); 201 208 $file = wp_handle_upload($_FILES['import'], $overrides); … … 223 230 224 231 if ( $width == HEADER_IMAGE_WIDTH && $height == HEADER_IMAGE_HEIGHT ) { 225 set_theme_mod('header_image', $url);232 set_theme_mod('header_image', clean_url($url)); 226 233 $header = apply_filters('wp_create_file_in_uploads', $file, $id); // For replication 227 234 return $this->finished(); … … 257 264 <input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo $id; ?>" /> 258 265 <input type="hidden" name="oitar" id="oitar" value="<?php echo $oitar; ?>" /> 266 <?php wp_nonce_field('custom-header') ?> 259 267 <input type="submit" value="<?php _e('Crop Header »'); ?>" /> 260 268 </p> … … 266 274 267 275 function step_3() { 276 check_admin_referer('custom-header'); 268 277 if ( $_POST['oitar'] > 1 ) { 269 278 $_POST['x1'] = $_POST['x1'] * $_POST['oitar']; -
Property
svn:eol-style
set to
-
tags/2.2/wp-admin/edit-category-form.php
r5468 r5480 36 36 <th scope="row" valign="top"><label for="category_parent"><?php _e('Category parent:') ?></label></th> 37 37 <td> 38 <?php wp_dropdown_categories('hide_empty=0&name=category_parent& selected=' . $category->category_parent . '&hierarchical=1&show_option_none=' . __('None')); ?>38 <?php wp_dropdown_categories('hide_empty=0&name=category_parent&orderby=name&selected=' . $category->category_parent . '&hierarchical=1&show_option_none=' . __('None')); ?> 39 39 </td> 40 40 </tr> -
tags/2.2/wp-admin/edit-comments.js
r5468 r5480 3 3 if ( !theCommentList ) 4 4 return false; 5 6 theExtraCommentList = new listMan('the-extra-comment-list'); 7 if ( theExtraCommentList ) { 8 theExtraCommentList.showLink = 0; 9 theExtraCommentList.altOffset = 1; 10 if ( theExtraCommentList.theList && theExtraCommentList.theList.childNodes ) 11 var commentNum = $A(theExtraCommentList.theList.childNodes).findAll( function(i) { return Element.visible(i) } ).length; 12 else 13 var commentNum = 0; 14 var urlQ = document.location.href.split('?'); 15 var params = urlQ[1] ? urlQ[1].toQueryParams() : []; 16 var search = params['s'] ? params['s'] : ''; 17 var page = params['apage'] ? params['apage'] : 1; 18 } 19 5 20 theCommentList.dimComplete = function(what,id,dimClass) { 6 21 var m = document.getElementById('awaitmod'); 7 if ( document.getElementById(what + '-' + id).className.match(dimClass) ) m.innerHTML = parseInt(m.innerHTML,10) + 1; 8 else m.innerHTML = parseInt(m.innerHTML,10) - 1; 22 if ( document.getElementById(what + '-' + id).className.match(dimClass) ) 23 m.innerHTML = parseInt(m.innerHTML,10) + 1; 24 else 25 m.innerHTML = parseInt(m.innerHTML,10) - 1; 9 26 } 27 10 28 theCommentList.delComplete = function(what,id) { 11 29 var m = document.getElementById('awaitmod'); 12 if ( document.getElementById(what + '-' + id).className.match('unapproved') ) m.innerHTML = parseInt(m.innerHTML,10) - 1; 30 what = what.split('-')[0]; 31 if ( document.getElementById(what + '-' + id).className.match('unapproved') ) 32 m.innerHTML = parseInt(m.innerHTML,10) - 1; 33 if ( theExtraCommentList && commentNum ) { 34 var theMover = theExtraCommentList.theList.childNodes[0]; 35 Element.removeClassName(theMover,'alternate'); 36 theCommentList.theList.appendChild(theMover); 37 theExtraCommentList.inputData += '&page=' + page; 38 if ( search ) 39 theExtraCommentList.inputData += '&s=' + search; // trust the URL not the search box 40 theExtraCommentList.addComplete = function() { 41 if ( theExtraCommentList.theList.childNodes ) 42 var commentNum = $A(theExtraCommentList.theList.childNodes).findAll( function(i) { return Element.visible(i) } ).length; 43 else 44 var commentNum = 0; 45 } 46 theExtraCommentList.ajaxAdder( 'comment', 'ajax-response' ); // Dummy Request 47 } 13 48 } 49 14 50 if ( theList ) // the post list: edit.php 15 51 theList.delComplete = function() { -
tags/2.2/wp-admin/edit-comments.php
r5468 r5480 76 76 endif; 77 77 78 if (isset($_GET['s'])) { 79 $s = $wpdb->escape($_GET['s']); 80 $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE 81 (comment_author LIKE '%$s%' OR 82 comment_author_email LIKE '%$s%' OR 83 comment_author_url LIKE ('%$s%') OR 84 comment_author_IP LIKE ('%$s%') OR 85 comment_content LIKE ('%$s%') ) AND 86 comment_approved != 'spam' 87 ORDER BY comment_date DESC"); 88 } else { 89 if ( isset( $_GET['apage'] ) ) 90 $page = (int) $_GET['apage']; 91 else 92 $page = 1; 93 $start = $offset = ( $page - 1 ) * 20; 94 95 $comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start, 20" ); 96 $total = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1'" ); 97 } 98 ?> 99 <?php if ( $total > 20 ) { 100 $total_pages = ceil( $total / 20 ); 101 $r = ''; 102 if ( 1 < $page ) { 103 $args['apage'] = ( 1 == $page - 1 ) ? FALSE : $page - 1; 104 $r .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">« '. __('Previous Page') .'</a>' . "\n"; 105 } 106 if ( ( $total_pages = ceil( $total / 20 ) ) > 1 ) { 107 for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) : 108 if ( $page == $page_num ) : 109 $r .= "<span>$page_num</span>\n"; 110 else : 111 $p = false; 112 if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) : 113 $args['apage'] = ( 1 == $page_num ) ? FALSE : $page_num; 114 $r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n"; 115 $in = true; 116 elseif ( $in == true ) : 117 $r .= "...\n"; 118 $in = false; 119 endif; 120 endif; 121 endfor; 122 } 123 if ( ( $page ) * 20 < $total || -1 == $total ) { 124 $args['apage'] = $page + 1; 125 $r .= '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page') .' »</a>' . "\n"; 126 } 127 echo "<p class='pagenav'>$r</p>"; 128 ?> 129 130 <?php } ?> 131 132 <?php 78 if ( isset( $_GET['apage'] ) ) 79 $page = (int) $_GET['apage']; 80 else 81 $page = 1; 82 $start = $offset = ( $page - 1 ) * 20; 83 84 list($_comments, $total) = _wp_get_comment_list( isset($_GET['s']) ? $_GET['s'] : false, $start, 25 ); // Grab a few extra 85 86 $comments = array_slice($_comments, 0, 20); 87 $extra_comments = array_slice($_comments, 20); 88 89 $page_links = paginate_links( array( 90 'base' => 'edit-comments.php?%_%', 91 'format' => 'apage=%#%', 92 'total' => ceil($total / 20), 93 'current' => $page 94 )); 95 96 if ( $page_links ) 97 echo "<p class='pagenav'>$page_links</p>"; 98 133 99 if ('view' == $mode) { 134 100 if ($comments) { 135 ?> 136 <?php 137 $offset = $offset + 1; 138 $start = " start='$offset'"; 139 140 echo "<ol id='the-comment-list' class='commentlist' $start>"; 101 $offset = $offset + 1; 102 $start = " start='$offset'"; 103 104 echo "<ol id='the-comment-list' class='commentlist' $start>\n"; 141 105 $i = 0; 142 foreach ($comments as $comment) { 143 ++$i; $class = ''; 144 $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); 145 $comment_status = wp_get_comment_status($comment->comment_ID); 146 if ('unapproved' == $comment_status) 147 $class .= ' unapproved'; 148 if ($i % 2) 149 $class .= ' alternate'; 150 echo "<li id='comment-$comment->comment_ID' class='$class'>"; 151 ?> 152 <p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p> 153 154 <?php comment_text() ?> 155 156 <p><?php comment_date('M j, g:i A'); ?> — [ 157 <?php 158 if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 159 echo " <a href='comment.php?action=editcomment&c=".$comment->comment_ID."'>" . __('Edit') . '</a>'; 160 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> '; 161 if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { 162 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>'; 163 echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>'; 164 } 165 echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&dt=spam&p=" . $comment->comment_post_ID . "&c=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to mark as spam this comment by '%s'.\n'Cancel' to stop, 'OK' to mark as spam."), $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . "</a> "; 166 } 167 $post = get_post($comment->comment_post_ID); 168 $post_title = wp_specialchars( $post->post_title, 'double' ); 169 $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; 170 ?> 171 | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ]</p> 172 </li> 173 174 <?php } // end foreach($comment) ?> 175 </ol> 106 foreach ( $comments as $comment ) { 107 get_comment( $comment ); // Cache it 108 _wp_comment_list_item( $comment->comment_ID, ++$i ); 109 } 110 echo "</ol>\n\n"; 111 112 if ( $extra_comments ) : ?> 113 <div id="extra-comments" style="display:none"> 114 <ul id="the-extra-comment-list" class="commentlist"> 115 <?php 116 foreach ( $extra_comments as $comment ) { 117 get_comment( $comment ); // Cache it 118 _wp_comment_list_item( $comment->comment_ID, ++$i ); 119 } 120 ?> 121 </ul> 122 </div> 123 <?php endif; // $extra_comments ?> 176 124 177 125 <div id="ajax-response"></div> … … 243 191 } // end if ($comments) 244 192 } 245 ?> 246 <?php if ( $total > 20 ) { 247 $total_pages = ceil( $total / 20 ); 248 $r = ''; 249 if ( 1 < $page ) { 250 $args['apage'] = ( 1 == $page - 1 ) ? FALSE : $page - 1; 251 $r .= '<a class="prev" href="' . clean_url(add_query_arg( $args )) . '">« '. __('Previous Page') .'</a>' . "\n"; 252 } 253 if ( ( $total_pages = ceil( $total / 20 ) ) > 1 ) { 254 for ( $page_num = 1; $page_num <= $total_pages; $page_num++ ) : 255 if ( $page == $page_num ) : 256 $r .= "<span>$page_num</span>\n"; 257 else : 258 $p = false; 259 if ( $page_num < 3 || ( $page_num >= $page - 3 && $page_num <= $page + 3 ) || $page_num > $total_pages - 3 ) : 260 $args['apage'] = ( 1 == $page_num ) ? FALSE : $page_num; 261 $r .= '<a class="page-numbers" href="' . clean_url(add_query_arg($args)) . '">' . ( $page_num ) . "</a>\n"; 262 $in = true; 263 elseif ( $in == true ) : 264 $r .= "...\n"; 265 $in = false; 266 endif; 267 endif; 268 endfor; 269 } 270 if ( ( $page ) * 20 < $total || -1 == $total ) { 271 $args['apage'] = $page + 1; 272 $r .= '<a class="next" href="' . clean_url(add_query_arg($args)) . '">'. __('Next Page') .' »</a>' . "\n"; 273 } 274 echo "<p class='pagenav'>$r</p>"; 275 ?> 276 277 <?php } ?> 193 194 if ( $page_links ) 195 echo "<p class='pagenav'>$page_links</p>"; 196 197 ?> 278 198 279 199 </div> -
tags/2.2/wp-admin/edit-form-advanced.php
r5468 r5480 108 108 <?php if ( current_user_can('edit_posts') ) : ?> 109 109 <fieldset id="posttimestampdiv" class="dbx-box"> 110 <h3 class="dbx-handle"><?php _e('Post Timestamp'); ?> :</h3>110 <h3 class="dbx-handle"><?php _e('Post Timestamp'); ?></h3> 111 111 <div class="dbx-content"><?php touch_time(($action == 'edit')); ?></div> 112 112 </fieldset> … … 118 118 ?> 119 119 <fieldset id="authordiv" class="dbx-box"> 120 <h3 class="dbx-handle"><?php _e('Post Author'); ?> :</h3>120 <h3 class="dbx-handle"><?php _e('Post Author'); ?></h3> 121 121 <div class="dbx-content"> 122 122 <select name="post_author_override" id="post_author_override"> … … 145 145 146 146 <fieldset id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>"> 147 <legend><?php _e('Post') ?></legend> 147 <legend><?php _e('Post') ?> 148 149 <?php if ( 'publish' == $post->post_status ) { ?> 150 <a href="<?php echo clean_url(get_permalink($post->ID)); ?>" class="view-link" target="_blank"><?php _e('View »'); ?></a> 151 <?php } elseif ( 'edit' == $action ) { ?> 152 <a href="<?php echo clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" class="view-link" target="_blank"><?php _e('Preview »'); ?></a> 153 <?php } ?> 154 </legend> 148 155 149 156 <?php the_editor($post->post_content); ?> … … 245 252 246 253 <?php if ('edit' == $action) : $delete_nonce = wp_create_nonce( 'delete-post_' . $post_ID ); ?> 247 <input name="deletepost" class="button delete" type="submit" id="deletepost" tabindex="10" value="<?php _e('Delete this post') ?>" <?php echo "onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { document.forms.post._wpnonce.value = '$delete_nonce'; return true;}return false;\""; ?> />254 <input name="deletepost" class="button delete" type="submit" id="deletepost" tabindex="10" value="<?php echo ( 'draft' == $post->post_status ) ? __('Delete this draft') : __('Delete this post'); ?>" <?php echo "onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { document.forms.post._wpnonce.value = '$delete_nonce'; return true;}return false;\""; ?> /> 248 255 <?php endif; ?> 249 256 -
tags/2.2/wp-admin/edit-form-comment.php
r5468 r5480 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" id="URL"/>35 <input type="text" id="newcomment_author_url" name="newcomment_author_url" size="35" value="<?php echo $comment->comment_author_url ?>" tabindex="3" /> 36 36 </div> 37 37 </fieldset> -
tags/2.2/wp-admin/edit-link-form.php
r5468 r5480 23 23 24 24 if ('' == $value) { 25 if ('family' == $class && !strstr($link_rel, 'child') && !strstr($link_rel, 'parent') && !strstr($link_rel, 'sibling') && !strstr($link_rel, 'spouse') && !strstr($link_rel, 'kin')) echo ' checked="checked"';26 if ('friendship' == $class && !strstr($link_rel, 'friend') && !strstr($link_rel, 'acquaintance') && !strstr($link_rel, 'contact')) echo ' checked="checked"';27 if ('geographical' == $class && !strstr($link_rel, 'co-resident') && !strstr($link_rel, 'neighbor')) echo ' checked="checked"';25 if ('family' == $class && strpos($link_rel, 'child') === false && strpos($link_rel, 'parent') === false && strpos($link_rel, 'sibling') === false && strpos($link_rel, 'spouse') === false && strpos($link_rel, 'kin') === false) echo ' checked="checked"'; 26 if ('friendship' == $class && strpos($link_rel, 'friend') === false && strpos($link_rel, 'acquaintance') === false && strpos($link_rel, 'contact') === false) echo ' checked="checked"'; 27 if ('geographical' == $class && strpos($link_rel, 'co-resident') === false && strpos($link_rel, 'neighbor') === false) echo ' checked="checked"'; 28 28 if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"'; 29 29 } -
tags/2.2/wp-admin/edit-page-form.php
r5468 r5480 99 99 <?php if ( $authors = get_editable_authors( $current_user->id ) ) : // TODO: ROLE SYSTEM ?> 100 100 <fieldset id="authordiv" class="dbx-box"> 101 <h3 class="dbx-handle"><?php _e('Page Author'); ?> :</h3>101 <h3 class="dbx-handle"><?php _e('Page Author'); ?></h3> 102 102 <div class="dbx-content"> 103 103 <select name="post_author_override" id="post_author_override"> … … 132 132 133 133 <fieldset id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>"> 134 <legend><?php _e('Page Content') ?></legend> 134 <legend><?php _e('Page Content') ?> 135 136 <?php if ( 'publish' == $post->post_status ) { ?> 137 <a href="<?php echo clean_url(get_permalink($post->ID)); ?>" style="position: absolute; right: 2em; margin-right: 19em; text-decoration: underline;" target="_blank"><?php _e('View »'); ?></a> 138 <?php } elseif ( 'edit' == $action ) { ?> 139 <a href="<?php echo clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" style="position: absolute; right: 2em; margin-right: 19em; text-decoration: underline;" target="_blank"><?php _e('Preview »'); ?></a> 140 <?php } ?> 141 </legend> 135 142 <?php the_editor($post->post_content); ?> 136 143 </fieldset> -
tags/2.2/wp-admin/edit.php
r5468 r5480 22 22 if (0 != $i) 23 23 echo ', '; 24 $draft->post_title = stripslashes($draft->post_title);24 $draft->post_title = apply_filters('the_title', stripslashes($draft->post_title)); 25 25 if ($draft->post_title == '') 26 26 $draft->post_title = sprintf(__('Post #%s'), $draft->ID); … … 29 29 } 30 30 ?> 31 31 .</p> 32 32 <?php } ?> 33 33 … … 39 39 if (0 != $i) 40 40 echo ', '; 41 $draft->post_title = stripslashes($draft->post_title);41 $draft->post_title = apply_filters('the_title', stripslashes($draft->post_title)); 42 42 if ($draft->post_title == '') 43 43 $draft->post_title = sprintf(__('Post #%s'), $draft->ID); … … 65 65 } else { 66 66 if ( is_single() ) 67 printf(__('Comments on %s'), $post->post_title);67 printf(__('Comments on %s'), apply_filters( "the_title", $post->post_title)); 68 68 elseif ( ! is_paged() || get_query_var('paged') == 1 ) 69 69 _e('Last 15 Posts'); … … 178 178 case 'date': 179 179 ?> 180 <td><?php if ( '0000-00-00 00:00:00' ==$post->post_modified ) _e('Unpublished'); else the_time(_ ('Y-m-d \<\b\r \/\> g:i:s a')); ?></td>180 <td><?php if ( '0000-00-00 00:00:00' ==$post->post_modified ) _e('Unpublished'); else the_time(__('Y-m-d \<\b\r \/\> g:i:s a')); ?></td> 181 181 <?php 182 182 break; -
tags/2.2/wp-admin/export.php
r5468 r5480 123 123 echo '<wp:category_description>' . wxr_cdata($c->category_description) . '</wp:category_description>'; 124 124 } 125 ?> 126 <!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your blog. --> 127 <!-- It contains information about your blog's posts, comments, and categories. --> 128 <!-- You may use this file to transfer that content from one site to another. --> 129 <!-- This file is not intended to serve as a complete backup of your blog. --> 130 131 <!-- To import this information into a WordPress blog follow these steps. --> 132 <!-- 1. Log into that blog as an administrator. --> 133 <!-- 2. Go to Manage: Import in the blog's admin panels. --> 134 <!-- 3. Choose "WordPress" from the list. --> 135 <!-- 4. Upload this file using the form provided on that page. --> 136 <!-- 5. You will first be asked to map the authors in this export file to users --> 137 <!-- on the blog. For each author, you may choose to map to an --> 138 <!-- existing user on the blog or to create a new user --> 139 <!-- 6. WordPress will then import each of the posts, comments, and categories --> 140 <!-- contained in this file into your blog --> 125 126 print '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?' . ">\n"; 127 128 ?> 129 130 <!-- 131 This is a WordPress eXtended RSS file generated by WordPress as an export of 132 your blog. It contains information about your blog's posts, comments, and 133 categories. You may use this file to transfer that content from one site to 134 another. This file is not intended to serve as a complete backup of your 135 blog. 136 137 To import this information into a WordPress blog follow these steps: 138 139 1. Log into that blog as an administrator. 140 2. Go to Manage > Import in the blog's admin. 141 3. Choose "WordPress" from the list of importers. 142 4. Upload this file using the form provided on that page. 143 5. You will first be asked to map the authors in this export file to users 144 on the blog. For each author, you may choose to map an existing user on 145 the blog or to create a new user. 146 6. WordPress will then import each of the posts, comments, and categories 147 contained in this file onto your blog. 148 --> 141 149 142 150 <!-- generator="wordpress/<?php bloginfo_rss('version') ?>" created="<?php echo date('Y-m-d H:m'); ?>"--> … … 178 186 <wp:status><?php echo $post->post_status; ?></wp:status> 179 187 <wp:post_parent><?php echo $post->post_parent; ?></wp:post_parent> 188 <wp:menu_order><?php echo $post->menu_order; ?></wp:menu_order> 180 189 <wp:post_type><?php echo $post->post_type; ?></wp:post_type> 181 190 <?php -
tags/2.2/wp-admin/import.php
r5468 r5480 18 18 if ($imports_dir) { 19 19 while (($file = $imports_dir->read()) !== false) { 20 if ( preg_match('|^\.+$|', $file))20 if ($file{0} == '.') { 21 21 continue; 22 if (preg_match('|\.php$|', $file)) 23 require_once("$import_root/$file"); 22 } elseif (substr($file, -4) == '.php') { 23 require_once($import_root . '/' . $file); 24 } 24 25 } 25 26 } -
tags/2.2/wp-admin/import/blogger.php
r5468 r5480 1 1 <?php 2 2 3 define( 'MAX_RESULTS', 50 ); // How many records per GData query 4 define( 'MAX_EXECUTION_TIME', 20 ); // How many seconds to let the script run 5 define( 'STATUS_INTERVAL', 3 ); // How many seconds between status bar updates 6 3 7 class Blogger_Import { 4 8 5 var $lump_authors = false; 6 var $import = array(); 7 8 // Shows the welcome screen and the magic iframe. 9 // Shows the welcome screen and the magic auth link. 9 10 function greet() { 10 $title = __('Import Old Blogger'); 11 $welcome = __('Howdy! This importer allows you to import posts and comments from your Old Blogger account into your WordPress blog.'); 12 $noiframes = __('This feature requires iframe support.'); 13 $warning = js_escape(__('This will delete everything saved by the Blogger importer except your posts and comments. Are you sure you want to do this?')); 14 $reset = __('Reset this importer'); 15 $incompat = __('Your web server is not properly configured to use this importer. Please enable the CURL extension for PHP and then reload this page.'); 16 17 echo "<div class='wrap'><h2>$title</h2><p>$welcome</p>"; 18 echo "<p>" . __('Please note that this importer <em>does not work with new Blogger (using your Google account)</em>.') . "</p>"; 19 if ( function_exists('curl_init') ) 20 echo "<iframe src='admin.php?import=blogger&noheader=true' height='350px' width = '99%'>$noiframes</iframe><p><a href='admin.php?import=blogger&restart=true&noheader=true' onclick='return confirm(\"$warning\")'>$reset</a></p>"; 11 $next_url = get_option('siteurl') . '/wp-admin/index.php?import=blogger&noheader=true'; 12 $auth_url = "https://www.google.com/accounts/AuthSubRequest"; 13 $title = __('Import Blogger'); 14 $welcome = __('Howdy! This importer allows you to import posts and comments from your Blogger account into your WordPress blog.'); 15 $prereqs = __('To use this importer, you must have a Google account, an upgraded (New, was Beta) blog, and it must be on blogspot or a custom domain (not FTP).'); 16 $stepone = __('The first thing you need to do is tell Blogger to let WordPress access your account. You will be sent back here after providing authorization.'); 17 $auth = __('Authorize'); 18 19 echo " 20 <div class='wrap'><h2>$title</h2><p>$welcome</p><p>$prereqs</p><p>$stepone</p> 21 <form action='$auth_url' method='get'> 22 <p class='submit' style='text-align:left;'> 23 <input type='submit' value='$auth' /> 24 <input type='hidden' name='scope' value='http://www.blogger.com/feeds/' /> 25 <input type='hidden' name='session' value='1' /> 26 <input type='hidden' name='secure' value='0' /> 27 <input type='hidden' name='next' value='$next_url' /> 28 </p> 29 </form> 30 </div>\n"; 31 } 32 33 function uh_oh($title, $message, $info) { 34 echo "<div class='wrap'><h2>$title</h2><p>$message</p><pre>$info</pre></div>"; 35 } 36 37 function auth() { 38 // We have a single-use token that must be upgraded to a session token. 39 $token = preg_replace( '/[^-_0-9a-zA-Z]/', '', $_GET['token'] ); 40 $headers = array( 41 "GET /accounts/AuthSubSessionToken HTTP/1.0", 42 "Authorization: AuthSub token=\"$token\"" 43 ); 44 $request = join( "\r\n", $headers ) . "\r\n\r\n"; 45 $sock = $this->_get_auth_sock( ); 46 if ( ! $sock ) return false; 47 $response = $this->_txrx( $sock, $request ); 48 preg_match( '/token=([-_0-9a-z]+)/i', $response, $matches ); 49 if ( empty( $matches[1] ) ) { 50 $this->uh_oh( 51 __( 'Authorization failed' ), 52 __( 'Something went wrong. If the problem persists, send this info to support:' ), 53 htmlspecialchars($response) 54 ); 55 return false; 56 } 57 $this->token = $matches[1]; 58 59 wp_redirect( remove_query_arg( array( 'token', 'noheader' ) ) ); 60 } 61 62 function get_token_info() { 63 $headers = array( 64 "GET /accounts/AuthSubTokenInfo HTTP/1.0", 65 "Authorization: AuthSub token=\"$this->token\"" 66 ); 67 $request = join( "\r\n", $headers ) . "\r\n\r\n"; 68 $sock = $this->_get_auth_sock( ); 69 if ( ! $sock ) return; 70 $response = $this->_txrx( $sock, $request ); 71 return $this->parse_response($response); 72 } 73 74 function token_is_valid() { 75 $info = $this->get_token_info(); 76 77 if ( $info['code'] == 200 ) 78 return true; 79 80 return false; 81 } 82 83 function show_blogs($iter = 0) { 84 if ( empty($this->blogs) ) { 85 $headers = array( 86 "GET /feeds/default/blogs HTTP/1.0", 87 "Host: www2.blogger.com", 88 "Authorization: AuthSub token=\"$this->token\"" 89 ); 90 $request = join( "\r\n", $headers ) . "\r\n\r\n"; 91 $sock = $this->_get_blogger_sock( ); 92 if ( ! $sock ) return; 93 $response = $this->_txrx( $sock, $request ); 94 95 // Quick and dirty XML mining. 96 list( $headers, $xml ) = explode( "\r\n\r\n", $response ); 97 $p = xml_parser_create(); 98 xml_parse_into_struct($p, $xml, $vals, $index); 99 xml_parser_free($p); 100 101 $this->title = $vals[$index['TITLE'][0]]['value']; 102 103 // Give it a few retries... this step often flakes out the first time. 104 if ( empty( $index['ENTRY'] ) ) { 105 if ( $iter < 3 ) { 106 return $this->show_blogs($iter + 1); 107 } else { 108 $this->uh_oh( 109 __('Trouble signing in'), 110 __('We were not able to gain access to your account. Try starting over.'), 111 '' 112 ); 113 return false; 114 } 115 } 116 117 foreach ( $index['ENTRY'] as $i ) { 118 $blog = array(); 119 while ( ( $tag = $vals[$i] ) && ! ( $tag['tag'] == 'ENTRY' && $tag['type'] == 'close' ) ) { 120 if ( $tag['tag'] == 'TITLE' ) { 121 $blog['title'] = $tag['value']; 122 } elseif ( $tag['tag'] == 'SUMMARY' ) { 123 $blog['summary'] == $tag['value']; 124 } elseif ( $tag['tag'] == 'LINK' ) { 125 if ( $tag['attributes']['REL'] == 'alternate' && $tag['attributes']['TYPE'] == 'text/html' ) { 126 $parts = parse_url( $tag['attributes']['HREF'] ); 127 $blog['host'] = $parts['host']; 128 } elseif ( $tag['attributes']['REL'] == 'edit' ) 129 $blog['gateway'] = $tag['attributes']['HREF']; 130 } 131 ++$i; 132 } 133 if ( ! empty ( $blog ) ) { 134 $blog['total_posts'] = $this->get_total_results('posts', $blog['host']); 135 $blog['total_comments'] = $this->get_total_results('comments', $blog['host']); 136 $blog['mode'] = 'init'; 137 $this->blogs[] = $blog; 138 } 139 } 140 141 if ( empty( $this->blogs ) ) { 142 $this->uh_oh( 143 __('No blogs found'), 144 __('We were able to log in but there were no blogs. Try a different account next time.'), 145 '' 146 ); 147 return false; 148 } 149 } 150 //echo '<pre>'.print_r($this,1).'</pre>'; 151 $start = js_escape( __('Import') ); 152 $continue = js_escape( __('Continue') ); 153 $stop = js_escape( __('Importing...') ); 154 $authors = js_escape( __('Set Authors') ); 155 $loadauth = js_escape( __('Preparing author mapping form...') ); 156 $authhead = js_escape( __('Final Step: Author Mapping') ); 157 $nothing = js_escape( __('Nothing was imported. Had you already imported this blog?') ); 158 $title = __('Blogger Blogs'); 159 $name = __('Blog Name'); 160 $url = __('Blog URL'); 161 $action = __('The Magic Button'); 162 $posts = __('Posts'); 163 $comments = __('Comments'); 164 $noscript = __('This feature requires Javascript but it seems to be disabled. Please enable Javascript and then reload this page. Don\'t worry, you can turn it back off when you\'re done.'); 165 166 $interval = STATUS_INTERVAL * 1000; 167 168 foreach ( $this->blogs as $i => $blog ) { 169 if ( $blog['mode'] == 'init' ) 170 $value = $start; 171 elseif ( $blog['mode'] == 'posts' || $blog['mode'] == 'comments' ) 172 $value = $continue; 173 else 174 $value = $authors; 175 $blogtitle = js_escape( $blog['title'] ); 176 $pdone = isset($blog['posts_done']) ? (int) $blog['posts_done'] : 0; 177 $cdone = isset($blog['comments_done']) ? (int) $blog['comments_done'] : 0; 178 $init .= "blogs[$i]=new blog($i,'$blogtitle','{$blog['mode']}'," . $this->get_js_status($i) . ');'; 179 $pstat = "<div class='ind' id='pind$i'> </div><div id='pstat$i' class='stat'>$pdone/{$blog['total_posts']}</div>"; 180 $cstat = "<div class='ind' id='cind$i'> </div><div id='cstat$i' class='stat'>$cdone/{$blog['total_comments']}</div>"; 181 $rows .= "<tr id='blog$i'><td class='blogtitle'>$blogtitle</td><td class='bloghost'>{$blog['host']}</td><td class='bar'>$pstat</td><td class='bar'>$cstat</td><td class='submit'><input type='submit' id='submit$i' value='$value' /><input type='hidden' name='blog' value='$i' /></td></tr>\n"; 182 } 183 184 echo "<div class='wrap'><h2>$title</h2><noscript>$noscript</noscript><table cellpadding='5px'><thead><td>$name</td><td>$url</td><td>$posts</td><td>$comments</td><td>$action</td></thead>\n$rows</table></form></div>"; 185 echo " 186 <script type='text/javascript'> 187 var strings = {cont:'$continue',stop:'$stop',stopping:'$stopping',authors:'$authors',nothing:'$nothing'}; 188 var blogs = {}; 189 function blog(i, title, mode, status){ 190 this.blog = i; 191 this.mode = mode; 192 this.title = title; 193 this.status = status; 194 this.button = document.getElementById('submit'+this.blog); 195 }; 196 blog.prototype = { 197 start: function() { 198 this.cont = true; 199 this.kick(); 200 this.check(); 201 }, 202 kick: function() { 203 ++this.kicks; 204 var i = this.blog; 205 jQuery.post('admin.php?import=blogger&noheader=true',{blog:this.blog},function(text,result){blogs[i].kickd(text,result)}); 206 }, 207 check: function() { 208 ++this.checks; 209 var i = this.blog; 210 jQuery.post('admin.php?import=blogger&noheader=true&status=true',{blog:this.blog},function(text,result){blogs[i].checkd(text,result)}); 211 }, 212 kickd: function(text, result) { 213 if ( result == 'error' ) { 214 // TODO: exception handling 215 if ( this.cont ) 216 setTimeout('blogs['+this.blog+'].kick()', 1000); 217 } else { 218 if ( text == 'done' ) { 219 this.stop(); 220 this.done(); 221 } else if ( text == 'nothing' ) { 222 this.stop(); 223 this.nothing(); 224 } else if ( text == 'continue' ) { 225 this.kick(); 226 } else if ( this.mode = 'stopped' ) 227 jQuery(this.button).attr('value', strings.cont); 228 } 229 --this.kicks; 230 }, 231 checkd: function(text, result) { 232 if ( result == 'error' ) { 233 // TODO: exception handling 234 } else { 235 eval('this.status='+text); 236 jQuery('#pstat'+this.blog).empty().append(this.status.p1+'/'+this.status.p2); 237 jQuery('#cstat'+this.blog).empty().append(this.status.c1+'/'+this.status.c2); 238 this.update(); 239 if ( this.cont || this.kicks > 0 ) 240 setTimeout('blogs['+this.blog+'].check()', $interval); 241 } 242 --this.checks; 243 }, 244 update: function() { 245 jQuery('#pind'+this.blog).width(((this.status.p1>0&&this.status.p2>0)?(this.status.p1/this.status.p2*jQuery('#pind'+this.blog).parent().width()):1)+'px'); 246 jQuery('#cind'+this.blog).width(((this.status.c1>0&&this.status.c2>0)?(this.status.c1/this.status.c2*jQuery('#cind'+this.blog).parent().width()):1)+'px'); 247 }, 248 stop: function() { 249 this.cont = false; 250 }, 251 done: function() { 252 this.mode = 'authors'; 253 jQuery(this.button).attr('value', strings.authors); 254 }, 255 nothing: function() { 256 this.mode = 'nothing'; 257 jQuery(this.button).remove(); 258 alert(strings.nothing); 259 }, 260 getauthors: function() { 261 if ( jQuery('div.wrap').length > 1 ) 262 jQuery('div.wrap').gt(0).remove(); 263 jQuery('div.wrap').empty().append('<h2>$authhead</h2><h3>' + this.title + '</h3>'); 264 jQuery('div.wrap').append('<p id=\"auth\">$loadauth</p>'); 265 jQuery('p#auth').load('index.php?import=blogger&noheader=true&authors=1',{blog:this.blog}); 266 }, 267 init: function() { 268 this.update(); 269 var i = this.blog; 270 jQuery(this.button).bind('click', function(){return blogs[i].click();}); 271 this.kicks = 0; 272 this.checks = 0; 273 }, 274 click: function() { 275 if ( this.mode == 'init' || this.mode == 'stopped' || this.mode == 'posts' || this.mode == 'comments' ) { 276 this.mode = 'started'; 277 this.start(); 278 jQuery(this.button).attr('value', strings.stop); 279 } else if ( this.mode == 'started' ) { 280 return false; // let it run... 281 this.mode = 'stopped'; 282 this.stop(); 283 if ( this.checks > 0 || this.kicks > 0 ) { 284 this.mode = 'stopping'; 285 jQuery(this.button).attr('value', strings.stopping); 286 } else { 287 jQuery(this.button).attr('value', strings.cont); 288 } 289 } else if ( this.mode == 'authors' ) { 290 document.location = 'index.php?import=blogger&authors=1&blog='+this.blog; 291 //this.mode = 'authors2'; 292 //this.getauthors(); 293 } 294 return false; 295 } 296 }; 297 $init 298 jQuery.each(blogs, function(i, me){me.init();}); 299 </script>\n"; 300 } 301 302 // Handy function for stopping the script after a number of seconds. 303 function have_time() { 304 global $importer_started; 305 if ( time() - $importer_started > MAX_EXECUTION_TIME ) 306 die('continue'); 307 return true; 308 } 309 310 function get_total_results($type, $host) { 311 $headers = array( 312 "GET /feeds/$type/default?max-results=1&start-index=2 HTTP/1.0", 313 "Host: $host", 314 "Authorization: AuthSub token=\"$this->token\"" 315 ); 316 $request = join( "\r\n", $headers ) . "\r\n\r\n"; 317 $sock = $this->_get_blogger_sock( $host ); 318 if ( ! $sock ) return; 319 $response = $this->_txrx( $sock, $request ); 320 $response = $this->parse_response( $response ); 321 $parser = xml_parser_create(); 322 xml_parse_into_struct($parser, $response['body'], $struct, $index); 323 xml_parser_free($parser); 324 $total_results = $struct[$index['OPENSEARCH:TOTALRESULTS'][0]]['value']; 325 return (int) $total_results; 326 } 327 328 function import_blog($blogID) { 329 global $importing_blog; 330 $importing_blog = $blogID; 331 332 if ( isset($_GET['authors']) ) 333 return print($this->get_author_form()); 334 335 header('Content-Type: text/plain'); 336 337 if ( isset($_GET['status']) ) 338 die($this->get_js_status()); 339 340 if ( isset($_GET['saveauthors']) ) 341 die($this->save_authors()); 342 343 $blog = $this->blogs[$blogID]; 344 $total_results = $this->get_total_results('posts', $blog['host']); 345 $this->blogs[$importing_blog]['total_posts'] = $total_results; 346 347 $start_index = $total_results - MAX_RESULTS + 1; 348 349 if ( isset( $this->blogs[$importing_blog]['posts_start_index'] ) ) 350 $start_index = (int) $this->blogs[$importing_blog]['posts_start_index']; 351 elseif ( $total_results > MAX_RESULTS ) 352 $start_index = $total_results - MAX_RESULTS + 1; 21 353 else 22 echo "<p>$incompat</p>"; 23 echo "</div>\n"; 24 } 25 26 // Deletes saved data and redirect. 354 $start_index = 1; 355 356 // This will be positive until we have finished importing posts 357 if ( $start_index > 0 ) { 358 // Grab all the posts 359 $this->blogs[$importing_blog]['mode'] = 'posts'; 360 $query = "start-index=$start_index&max-results=" . MAX_RESULTS; 361 do { 362 $index = $struct = $entries = array(); 363 $headers = array( 364 "GET /feeds/posts/default?$query HTTP/1.0", 365 "Host: {$blog['host']}", 366 "Authorization: AuthSub token=\"$this->token\"" 367 ); 368 $request = join( "\r\n", $headers ) . "\r\n\r\n"; 369 $sock = $this->_get_blogger_sock( $blog['host'] ); 370 if ( ! $sock ) return; // TODO: Error handling 371 $response = $this->_txrx( $sock, $request ); 372 373 $response = $this->parse_response( $response ); 374 375 // Extract the entries and send for insertion 376 preg_match_all( '/<entry[^>]*>.*?<\/entry>/s', $response['body'], $matches ); 377 if ( count( $matches[0] ) ) { 378 $entries = array_reverse($matches[0]); 379 foreach ( $entries as $entry ) { 380 $entry = "<feed>$entry</feed>"; 381 $AtomParser = new AtomParser(); 382 $AtomParser->parse( $entry ); 383 $this->import_post($AtomParser->entry); 384 unset($AtomParser); 385 } 386 } else break; 387 388 // Get the 'previous' query string which we'll use on the next iteration 389 $query = ''; 390 $links = preg_match_all('/<link([^>]*)>/', $response['body'], $matches); 391 if ( count( $matches[1] ) ) 392 foreach ( $matches[1] as $match ) 393 if ( preg_match('/rel=.previous./', $match) ) 394 $query = html_entity_decode( preg_replace('/^.*href=[\'"].*\?(.+)[\'"].*$/', '$1', $match) ); 395 396 if ( $query ) { 397 parse_str($query, $q); 398 $this->blogs[$importing_blog]['posts_start_index'] = (int) $q['start-index']; 399 } else 400 $this->blogs[$importing_blog]['posts_start_index'] = 0; 401 $this->save_vars(); 402 } while ( !empty( $query ) && $this->have_time() ); 403 } 404 405 $total_results = $this->get_total_results( 'comments', $blog['host'] ); 406 $this->blogs[$importing_blog]['total_comments'] = $total_results; 407 408 if ( isset( $this->blogs[$importing_blog]['comments_start_index'] ) ) 409 $start_index = (int) $this->blogs[$importing_blog]['comments_start_index']; 410 elseif ( $total_results > MAX_RESULTS ) 411 $start_index = $total_results - MAX_RESULTS + 1; 412 else 413 $start_index = 1; 414 415 if ( $start_index > 0 ) { 416 // Grab all the comments 417 $this->blogs[$importing_blog]['mode'] = 'comments'; 418 $query = "start-index=$start_index&max-results=" . MAX_RESULTS; 419 do { 420 $index = $struct = $entries = array(); 421 $headers = array( 422 "GET /feeds/comments/default?$query HTTP/1.0", 423 "Host: {$blog['host']}", 424 "Authorization: AuthSub token=\"$this->token\"" 425 ); 426 $request = join( "\r\n", $headers ) . "\r\n\r\n"; 427 $sock = $this->_get_blogger_sock( $blog['host'] ); 428 if ( ! $sock ) return; // TODO: Error handling 429 $response = $this->_txrx( $sock, $request ); 430 431 $response = $this->parse_response( $response ); 432 433 // Extract the comments and send for insertion 434 preg_match_all( '/<entry[^>]*>.*?<\/entry>/s', $response['body'], $matches ); 435 if ( count( $matches[0] ) ) { 436 $entries = array_reverse( $matches[0] ); 437 foreach ( $entries as $entry ) { 438 $entry = "<feed>$entry</feed>"; 439 $AtomParser = new AtomParser(); 440 $AtomParser->parse( $entry ); 441 $this->import_comment($AtomParser->entry); 442 unset($AtomParser); 443 } 444 } 445 446 // Get the 'previous' query string which we'll use on the next iteration 447 $query = ''; 448 $links = preg_match_all('/<link([^>]*)>/', $response['body'], $matches); 449 if ( count( $matches[1] ) ) 450 foreach ( $matches[1] as $match ) 451 if ( preg_match('/rel=.previous./', $match) ) 452 $query = html_entity_decode( preg_replace('/^.*href=[\'"].*\?(.+)[\'"].*$/', '$1', $match) ); 453 454 parse_str($query, $q); 455 456 $this->blogs[$importing_blog]['comments_start_index'] = (int) $q['start-index']; 457 $this->save_vars(); 458 } while ( !empty( $query ) && $this->have_time() ); 459 } 460 $this->blogs[$importing_blog]['mode'] = 'authors'; 461 $this->save_vars(); 462 if ( !$this->blogs[$importing_blog]['posts_done'] && !$this->blogs[$importing_blog]['comments_done'] ) 463 die('nothing'); 464 do_action('import_done', 'blogger'); 465 die('done'); 466 } 467 468 function convert_date( $date ) { 469 preg_match('#([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:\.[0-9]+)?(Z|[\+|\-][0-9]{2,4}){0,1}#', $date, $date_bits); 470 $offset = iso8601_timezone_to_offset( $date_bits[7] ); 471 $timestamp = gmmktime($date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1]); 472 $timestamp -= $offset; // Convert from Blogger local time to GMT 473 $timestamp += get_option('gmt_offset') * 3600; // Convert from GMT to WP local time 474 return gmdate('Y-m-d H:i:s', $timestamp); 475 } 476 477 function no_apos( $string ) { 478 return str_replace( ''', "'", $string); 479 } 480 481 function min_whitespace( $string ) { 482 return preg_replace( '|\s+|', ' ', $string ); 483 } 484 485 function import_post( $entry ) { 486 global $wpdb, $importing_blog; 487 488 // The old permalink is all Blogger gives us to link comments to their posts. 489 if ( isset( $entry->draft ) ) 490 $rel = 'self'; 491 else 492 $rel = 'alternate'; 493 foreach ( $entry->links as $link ) { 494 if ( $link['rel'] == $rel ) { 495 $parts = parse_url( $link['href'] ); 496 $entry->old_permalink = $parts['path']; 497 break; 498 } 499 } 500 501 $post_date = $this->convert_date( $entry->published ); 502 $post_content = trim( addslashes( $this->no_apos( html_entity_decode( $entry->content ) ) ) ); 503 $post_title = trim( addslashes( $this->no_apos( $this->min_whitespace( $entry->title ) ) ) ); 504 $post_status = isset( $entry->draft ) ? 'draft' : 'publish'; 505 506 // Clean up content 507 $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); 508 $post_content = str_replace('<br>', '<br />', $post_content); 509 $post_content = str_replace('<hr>', '<hr />', $post_content); 510 511 // Checks for duplicates 512 if ( 513 isset( $this->blogs[$importing_blog]['posts'][$entry->old_permalink] ) || 514 post_exists( $post_title, $post_content, $post_date ) 515 ) { 516 ++$this->blogs[$importing_blog]['posts_skipped']; 517 } else { 518 $post = compact('post_date', 'post_content', 'post_title', 'post_status'); 519 520 $post_id = wp_insert_post($post); 521 522 wp_create_categories( array_map( 'addslashes', $entry->categories ), $post_id ); 523 524 $author = $this->no_apos( strip_tags( $entry->author ) ); 525 526 add_post_meta( $post_id, 'blogger_blog', $this->blogs[$importing_blog]['host'], true ); 527 add_post_meta( $post_id, 'blogger_author', $author, true ); 528 add_post_meta( $post_id, 'blogger_permalink', $entry->old_permalink, true ); 529 530 $this->blogs[$importing_blog]['posts'][$entry->old_permalink] = $post_id; 531 ++$this->blogs[$importing_blog]['posts_done']; 532 } 533 $this->save_vars(); 534 } 535 536 function import_comment( $entry ) { 537 global $importing_blog; 538 539 // Drop the #fragment and we have the comment's old post permalink. 540 foreach ( $entry->links as $link ) { 541 if ( $link['rel'] == 'alternate' ) { 542 $parts = parse_url( $link['href'] ); 543 $entry->old_permalink = $parts['fragment']; 544 $entry->old_post_permalink = $parts['path']; 545 break; 546 } 547 } 548 549 $comment_post_ID = (int) $this->blogs[$importing_blog]['posts'][$entry->old_post_permalink]; 550 preg_match('#<name>(.+?)</name>.*(?:\<uri>(.+?)</uri>)?#', $entry->author, $matches); 551 $comment_author = addslashes( $this->no_apos( strip_tags( (string) $matches[1] ) ) ); 552 $comment_author_url = addslashes( $this->no_apos( strip_tags( (string) $matches[2] ) ) ); 553 $comment_date = $this->convert_date( $entry->updated ); 554 $comment_content = addslashes( $this->no_apos( html_entity_decode( $entry->content ) ) ); 555 556 // Clean up content 557 $comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content); 558 $comment_content = str_replace('<br>', '<br />', $comment_content); 559 $comment_content = str_replace('<hr>', '<hr />', $comment_content); 560 561 // Checks for duplicates 562 if ( 563 isset( $this->blogs[$importing_blog]['comments'][$entry->old_permalink] ) || 564 comment_exists( $comment_author, $comment_date ) 565 ) { 566 ++$this->blogs[$importing_blog]['comments_skipped']; 567 } else { 568 $comment = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_date', 'comment_content'); 569 570 $comment_id = wp_insert_comment($comment); 571 572 $this->blogs[$importing_blog]['comments'][$entry->old_permalink] = $comment_id; 573 574 ++$this->blogs[$importing_blog]['comments_done']; 575 } 576 $this->save_vars(); 577 } 578 579 function get_js_status($blog = false) { 580 global $importing_blog; 581 if ( $blog === false ) 582 $blog = $this->blogs[$importing_blog]; 583 else 584 $blog = $this->blogs[$blog]; 585 $p1 = isset( $blog['posts_done'] ) ? (int) $blog['posts_done'] : 0; 586 $p2 = isset( $blog['total_posts'] ) ? (int) $blog['total_posts'] : 0; 587 $c1 = isset( $blog['comments_done'] ) ? (int) $blog['comments_done'] : 0; 588 $c2 = isset( $blog['total_comments'] ) ? (int) $blog['total_comments'] : 0; 589 return "{p1:$p1,p2:$p2,c1:$c1,c2:$c2}"; 590 } 591 592 function get_author_form($blog = false) { 593 global $importing_blog, $wpdb, $current_user; 594 if ( $blog === false ) 595 $blog = & $this->blogs[$importing_blog]; 596 else 597 $blog = & $this->blogs[$blog]; 598 599 if ( !isset( $blog['authors'] ) ) { 600 $post_ids = array_values($blog['posts']); 601 $authors = (array) $wpdb->get_col("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = 'blogger_author' AND post_id IN (" . join( ',', $post_ids ) . ")"); 602 $blog['authors'] = array_map(null, $authors, array_fill(0, count($authors), $current_user->ID)); 603 $this->save_vars(); 604 } 605 606 $directions = __('All posts were imported with the current user as author. Use this form to move each Blogger user\'s posts to a different WordPress user. You may <a href="users.php">add users</a> and then return to this page and complete the user mapping. This form may be used as many times as you like until you activate the "Restart" function below.'); 607 $heading = __('Author mapping'); 608 $blogtitle = "{$blog['title']} ({$blog['host']})"; 609 $mapthis = __('Blogger username'); 610 $tothis = __('WordPress login'); 611 $submit = js_escape( __('Save Changes »') ); 612 613 foreach ( $blog['authors'] as $i => $author ) 614 $rows .= "<tr><td><label for='authors[$i]'>{$author[0]}</label></td><td><select name='authors[$i]' id='authors[$i]'>" . $this->get_user_options($author[1]) . "</select></td></tr>"; 615 616 return "<div class='wrap'><h2>$heading</h2><h3>$blogtitle</h3><p>$directions</p><form action='index.php?import=blogger&noheader=true&saveauthors=1' method='post'><input type='hidden' name='blog' value='$importing_blog' /><table cellpadding='5'><thead><td>$mapthis</td><td>$tothis</td></thead>$rows<tr><td></td><td class='submit'><input type='submit' class='authorsubmit' value='$submit' /></td></tr></table></form></div>"; 617 } 618 619 function get_user_options($current) { 620 global $wpdb, $importer_users; 621 if ( ! isset( $importer_users ) ) 622 $importer_users = (array) get_users_of_blog(); 623 624 foreach ( $importer_users as $user ) { 625 $sel = ( $user->user_id == $current ) ? " selected='selected'" : ''; 626 $options .= "<option value='$user->user_id'$sel>$user->display_name</option>"; 627 } 628 629 return $options; 630 } 631 632 function save_authors() { 633 global $importing_blog, $wpdb; 634 $authors = (array) $_POST['authors']; 635 636 $host = $this->blogs[$importing_blog]['host']; 637 638 // Get an array of posts => authors 639 $post_ids = (array) $wpdb->get_col("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'blogger_blog' AND meta_value = '$host'"); 640 $post_ids = join( ',', $post_ids ); 641 $results = (array) $wpdb->get_results("SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = 'blogger_author' AND post_id IN ($post_ids)"); 642 foreach ( $results as $row ) 643 $authors_posts[$row->post_id] = $row->meta_value; 644 645 foreach ( $authors as $author => $user_id ) { 646 $user_id = (int) $user_id; 647 648 // Skip authors that haven't been changed 649 if ( $user_id == $this->blogs[$importing_blog]['authors'][$author][1] ) 650 continue; 651 652 // Get a list of the selected author's posts 653 $post_ids = (array) array_keys( $authors_posts, $this->blogs[$importing_blog]['authors'][$author][0] ); 654 $post_ids = join( ',', $post_ids); 655 656 $wpdb->query("UPDATE $wpdb->posts SET post_author = $user_id WHERE id IN ($post_ids)"); 657 $this->blogs[$importing_blog]['authors'][$author][1] = $user_id; 658 } 659 $this->save_vars(); 660 661 wp_redirect('edit.php'); 662 } 663 664 function _get_auth_sock() { 665 // Connect to https://www.google.com 666 if ( !$sock = @ fsockopen('ssl://www.google.com', 443, $errno, $errstr) ) { 667 $this->uh_oh( 668 __('Could not connect to https://www.google.com'), 669 __('There was a problem opening a secure connection to Google. This is what went wrong:'), 670 "$errstr ($errno)" 671 ); 672 return false; 673 } 674 return $sock; 675 } 676 677 function _get_blogger_sock($host = 'www2.blogger.com') { 678 if ( !$sock = @ fsockopen($host, 80, $errno, $errstr) ) { 679 $this->uh_oh( 680 sprintf( __('Could not connect to %s'), $host ), 681 __('There was a problem opening a connection to Blogger. This is what went wrong:'), 682 "$errstr ($errno)" 683 ); 684 return false; 685 } 686 return $sock; 687 } 688 689 function _txrx( $sock, $request ) { 690 fwrite( $sock, $request ); 691 while ( ! feof( $sock ) ) 692 $response .= @ fread ( $sock, 8192 ); 693 fclose( $sock ); 694 return $response; 695 } 696 697 function revoke($token) { 698 $headers = array( 699 "GET /accounts/AuthSubRevokeToken HTTP/1.0", 700 "Authorization: AuthSub token=\"$token\"" 701 ); 702 $request = join( "\r\n", $headers ) . "\r\n\r\n"; 703 $sock = $this->_get_auth_sock( ); 704 if ( ! $sock ) return false; 705 $this->_txrx( $sock, $request ); 706 } 707 27 708 function restart() { 28 delete_option('import-blogger'); 29 wp_redirect("admin.php?import=blogger"); 30 die(); 31 } 32 33 // Generates a string that will make the page reload in a specified interval. 34 function refresher($msec) { 35 if ( $msec ) 36 return "<html><head><script type='text/javascript'>window.onload=setTimeout('window.location.reload()', $msec);</script>\n</head>\n<body>\n"; 37 else 38 return "<html><head><script type='text/javascript'>window.onload=window.location.reload();</script>\n</head>\n<body>\n"; 709 global $wpdb; 710 $options = get_option( 'blogger_importer' ); 711 712 if ( isset( $options['token'] ) ) 713 $this->revoke( $options['token'] ); 714 715 delete_option('blogger_importer'); 716 $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key = 'blogger_author'"); 717 wp_redirect('?import=blogger'); 39 718 } 40 719 … … 63 742 } 64 743 65 // Prints a form for the user to enter Blogger creds.66 function login_form($text='') {67 echo '<h1>' . __('Log in to Blogger') . "</h1>\n$text\n";68 echo '<form method="post" action="admin.php?import=blogger&noheader=true&step=0"><table><tr><td>' . __('Username') . ':</td><td><input type="text" name="user" /></td></tr><tr><td>' . __('Password') . ':</td><td><input type="password" name="pass" /></td><td><input type="submit" value="' . __('Start') . '" /></td></tr></table></form>';69 die;70 }71 72 // Sends creds to Blogger, returns the session cookies an array of headers.73 function login_blogger($user, $pass) {74 $_url = 'http://www.blogger.com/login.do';75 $params = "username=$user&password=$pass";76 $ch = curl_init();77 curl_setopt($ch, CURLOPT_POST,1);78 curl_setopt($ch, CURLOPT_POSTFIELDS,$params);79 curl_setopt($ch, CURLOPT_URL,$_url);80 curl_setopt($ch, CURLOPT_USERAGENT, 'Blogger Exporter');81 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);82 curl_setopt($ch, CURLOPT_HEADER,1);83 curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);84 $response = curl_exec ($ch);85 86 $response = $this->parse_response($response);87 88 sleep(1);89 90 return $response['cookies'];91 }92 93 // Requests page from Blogger, returns the response array.94 function get_blogger($url, $header = '', $user=false, $pass=false) {95 $ch = curl_init();96 if ($user && $pass) curl_setopt($ch, CURLOPT_USERPWD,"{$user}:{$pass}");97 curl_setopt($ch, CURLOPT_URL,$url);98 curl_setopt($ch, CURLOPT_TIMEOUT, 10);99 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);100 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);101 curl_setopt($ch, CURLOPT_USERAGENT, 'Blogger Exporter');102 curl_setopt($ch, CURLOPT_HEADER,1);103 if (is_array($header)) curl_setopt($ch, CURLOPT_HTTPHEADER, $header);104 $response = curl_exec ($ch);105 106 $response = $this->parse_response($response);107 $response['url'] = $url;108 109 if (curl_errno($ch)) {110 print curl_error($ch);111 } else {112 curl_close($ch);113 }114 115 return $response;116 }117 118 // Posts data to Blogger, returns response array.119 function post_blogger($url, $header = false, $paramary = false, $parse=true) {120 $params = '';121 if ( is_array($paramary) ) {122 foreach($paramary as $key=>$value)123 if($key && $value != '')124 $params.=$key."=".urlencode(stripslashes($value))."&";125 }126 if ($user && $pass) $params .= "username=$user&password=$pass";127 $params = trim($params,'&');128 $ch = curl_init();129 curl_setopt($ch, CURLOPT_POST,1);130 curl_setopt($ch, CURLOPT_POSTFIELDS,$params);131 if ($user && $pass) curl_setopt($ch, CURLOPT_USERPWD,"{$user}:{$pass}");132 curl_setopt($ch, CURLOPT_URL,$url);133 curl_setopt($ch, CURLOPT_USERAGENT, 'Blogger Exporter');134 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);135 curl_setopt($ch, CURLOPT_HEADER,$parse);136 curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);137 if ($header) curl_setopt($ch, CURLOPT_HTTPHEADER, $header);138 $response = curl_exec ($ch);139 140 if ($parse) {141 $response = $this->parse_response($response);142 $response['url'] = $url;143 return $response;144 }145 146 return $response;147 }148 149 // Prints the list of blogs for import.150 function show_blogs() {151 global $import;152 echo '<h1>' . __('Selecting a Blog') . "</h1>\n<ul>";153 foreach ( $this->import['blogs'] as $blog ) {154 if (9 == $blog['nextstep']) $status = "100%";155 elseif (8 == $blog['nextstep']) $status = "90%";156 elseif (7 == $blog['nextstep']) $status = "82.5%";157 elseif (6 == $blog['nextstep']) $status = "75%";158 elseif (5 == $blog['nextstep']) $status = "57%";159 elseif (4 == $blog['nextstep']) $status = "28%";160 elseif (3 == $blog['nextstep']) $status = "14%";161 else $status = "0%";162 echo "\t<li><a href='admin.php?import=blogger&noheader=true&blog={$blog['id']}'>{$blog['title']}</a> $status</li>\n";163 }164 die("</ul>\n");165 }166 167 // Publishes.168 function publish_blogger($i, $text) {169 $head = $this->refresher(2000) . "<h1>$text</h1>\n";170 if ( ! strstr($this->import['blogs'][$_GET['blog']]['publish'][$i], 'http') ) {171 // First call. Start the publish process with a fresh set of cookies.172 $this->import['cookies'] = $this->login_blogger($this->import['user'], $this->import['pass']);173 update_option('import-blogger', $this->import);174 $paramary = array('blogID' => $_GET['blog'], 'all' => '1', 'republishAll' => 'Republish Entire Blog', 'publish' => '1', 'redirectUrl' => "/publish.do?blogID={$_GET['blog']}&inprogress=true");175 176 $response = $this->post_blogger("http://www.blogger.com/publish.do?blogID={$_GET['blog']}", $this->import['cookies'], $paramary);177 if ( $response['code'] == '302' ) {178 $url = str_replace('publish.g', 'publish-body.g', $response['header']['Location']);179 $this->import['blogs'][$_GET['blog']]['publish'][$i] = $url;180 update_option('import-blogger', $this->import);181 $response = $this->get_blogger($url, $this->import['cookies']);182 preg_match('#<p class="progressIndicator">.*</p>#U', $response['body'], $matches);183 $progress = $matches[0];184 die($head . $progress);185 } else {186 $this->import['blogs'][$_GET['blog']]['publish'][$i] = false;187 update_option('import-blogger', $this->import);188 die($head);189 }190 } else {191 // Subsequent call. Keep checking status until Blogger reports publish complete.192 $url = $this->import['blogs'][$_GET['blog']]['publish'][$i];193 $response = $this->get_blogger($url, $this->import['cookies']);194 if ( preg_match('#<p class="progressIndicator">.*</p>#U', $response['body'], $matches) ) {195 $progress = $matches[0];196 if ( strstr($progress, '100%') ) {197 $this->set_next_step($i);198 $progress .= '<p>'.__('Moving on...').'</p>';199 }200 die($head . $progress);201 } else {202 $this->import['blogs'][$_GET['blog']]['publish'][$i] = false;203 update_option('import-blogger', $this->import);204 die("$head<p>" . __('Trying again...') . '</p>');205 }206 }207 }208 209 // Sets next step, saves options210 function set_next_step($step) {211 $this->import['blogs'][$_GET['blog']]['nextstep'] = $step;212 update_option('import-blogger', $this->import);213 }214 215 // Redirects to next step216 function do_next_step() {217 wp_redirect("admin.php?import=blogger&noheader=true&blog={$_GET['blog']}");218 die();219 }220 221 // Step 0: Do Blogger login, get blogid/title pairs.222 function do_login() {223 if ( ( ! $this->import['user'] && ! is_array($this->import['cookies']) ) ) {224 // The user must provide a Blogger username and password.225 if ( ! ( $_POST['user'] && $_POST['pass'] ) ) {226 $this->login_form(__('The script will log into your Blogger account, change some settings so it can read your blog, and restore the original settings when it\'s done. Here\'s what you do:').'</p><ol><li>'.__('Back up your Blogger template.').'</li><li>'.__('Back up any other Blogger settings you might need later.').'</li><li>'.__('Log out of Blogger').'</li><li>'.__('Log in <em>here</em> with your Blogger username and password.').'</li><li>'.__('On the next screen, click one of your Blogger blogs.').'</li><li>'.__('Do not close this window or navigate away until the process is complete.').'</li></ol>');227 }228 229 // Try logging in. If we get an array of cookies back, we at least connected.230 $this->import['cookies'] = $this->login_blogger($_POST['user'], $_POST['pass']);231 if ( !is_array( $this->import['cookies'] ) ) {232 $this->login_form(__('Login failed. Please enter your credentials again.'));233 }234 235 // Save the password so we can log the browser in when it's time to publish.236 $this->import['pass'] = $_POST['pass'];237 $this->import['user'] = $_POST['user'];238 239 // Get the Blogger welcome page and scrape the blog numbers and names from it240 $response = $this->get_blogger('http://www.blogger.com/home', $this->import['cookies']);241 if (! stristr($response['body'], 'signed in as') ) $this->login_form(__('Login failed. Please re-enter your username and password.'));242 $blogsary = array();243 preg_match_all('#posts\.g\?blogID=(\d+)">([^<]+)</a>#U', $response['body'], $blogsary);244 if ( ! count( $blogsary[1] < 1 ) )245 wp_die(__('No blogs found for this user.'));246 $this->import['blogs'] = array();247 $template = '<MainPage><br /><br /><br /><p>'.__('Are you looking for %title%? It is temporarily out of service. Please try again in a few minutes. Meanwhile, discover <a href="http://wordpress.org/">a better blogging tool</a>.').'</p><BloggerArchives><a class="archive" href="<$BlogArchiveURL$>"><$BlogArchiveName$></a><br /></BloggerArchives></MainPage><ArchivePage><Blogger><wordpresspost><$BlogItemDateTime$>|W|P|<$BlogItemAuthorNickname$>|W|P|<$BlogItemBody$>|W|P|<$BlogItemNumber$>|W|P|<$BlogItemTitle$>|W|P|<$BlogItemAuthorEmail$><BlogItemCommentsEnabled><BlogItemComments><wordpresscomment><$BlogCommentDateTime$>|W|P|<$BlogCommentAuthor$>|W|P|<$BlogCommentBody$></BlogItemComments></BlogItemCommentsEnabled></Blogger></ArchivePage>';248 foreach ( $blogsary[1] as $key => $id ) {249 // Define the required Blogger options.250 $blog_opts = array(251 'blog-options-basic' => false,252 'blog-options-archiving' => array('archiveFrequency' => 'm'),253 'blog-publishing' => array('publishMode'=>'0', 'blogID' => "$id", 'subdomain' => mt_rand().mt_rand(), 'pingWeblogs' => 'false'),254 'blog-formatting' => array('timeStampFormat' => '0', 'encoding'=>'UTF-8', 'convertLineBreaks'=>'false', 'floatAlignment'=>'false'),255 'blog-comments' => array('commentsTimeStampFormat' => '0'),256 'template-edit' => array( 'templateText' => str_replace('%title%', trim($blogsary[2][$key]), $template) )257 );258 259 // Build the blog options array template260 foreach ($blog_opts as $blog_opt => $modify)261 $new_opts["$blog_opt"] = array('backup'=>false, 'modify' => $modify, 'error'=>false);262 263 $this->import['blogs']["$id"] = array(264 'id' => $id,265 'title' => trim($blogsary[2][$key]),266 'options' => $new_opts,267 'url' => false,268 'publish_cookies' => false,269 'published' => false,270 'archives' => false,271 'lump_authors' => false,272 'newusers' => array(),273 'nextstep' => 2274 );275 }276 update_option('import-blogger', $this->import);277 wp_redirect("admin.php?import=blogger&noheader=true&step=1");278 }279 die();280 }281 282 // Step 1: Select one of the blogs belonging to the user logged in.283 function select_blog() {284 if ( is_array($this->import['blogs']) ) {285 $this->show_blogs();286 die();287 } else {288 $this->restart();289 }290 }291 292 // Step 2: Backup the Blogger options pages, updating some of them.293 function backup_settings() {294 $output.= '<h1>'.__('Backing up Blogger options')."</h1>\n";295 $form = false;296 foreach ($this->import['blogs'][$_GET['blog']]['options'] as $blog_opt => $optary) {297 if ( $blog_opt == $_GET['form'] ) {298 // Save the posted form data299 $this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['backup'] = $_POST;300 update_option('import-blogger',$this->import);301 302 // Post the modified form data to Blogger303 if ( $optary['modify'] ) {304 $posturl = "http://www.blogger.com/{$blog_opt}.do";305 $headers = array_merge($this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['cookies'], $this->import['cookies']);306 if ( 'blog-publishing' == $blog_opt ) {307 if ( $_POST['publishMode'] > 0 ) {308 $response = $this->get_blogger("http://www.blogger.com/blog-publishing.g?blogID={$_GET['blog']}&publishMode=0", $headers);309 if ( $response['code'] >= 400 )310 wp_die('<h2>'.__('Failed attempt to change publish mode from FTP to BlogSpot.').'</h2><pre>' . addslashes(print_r($headers, 1)) . addslashes(print_r($response, 1)) . '</pre>');311 $this->import['blogs'][$_GET['blog']]['url'] = 'http://' . $optary['modify']['subdomain'] . '.blogspot.com/';312 sleep(2);313 } else {314 $this->import['blogs'][$_GET['blog']]['url'] = 'http://' . $_POST['subdomain'] . '.blogspot.com/';315 update_option('import-blogger', $this->import);316 $output .= "<del><p>$blog_opt</p></del>\n";317 continue;318 }319 $paramary = $optary['modify'];320 } else {321 $paramary = array_merge($_POST, $optary['modify']);322 }323 $response = $this->post_blogger($posturl, $headers, $paramary);324 if ( $response['code'] >= 400 || strstr($response['body'], 'There are errors on this form') )325 wp_die('<p>'.__('Error on form submission. Retry or reset the importer.').'</p>' . addslashes(print_r($response, 1)));326 }327 $output .= "<del><p>$blog_opt</p></del>\n";328 } elseif ( is_array($this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['backup']) ) {329 // This option set has already been backed up.330 $output .= "<del><p>$blog_opt</p></del>\n";331 } elseif ( ! $form ) {332 // This option page needs to be downloaded and given to the browser for submission back to this script.333 $response = $this->get_blogger("http://www.blogger.com/{$blog_opt}.g?blogID={$_GET['blog']}", $this->import['cookies']);334 $this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['cookies'] = $response['cookies'];335 update_option('import-blogger',$this->import);336 $body = $response['body'];337 $body = preg_replace("|\<!DOCTYPE.*\<body[^>]*>|ms","",$body);338 $body = preg_replace("|/?{$blog_opt}.do|","admin.php?import=blogger&noheader=true&step=2&blog={$_GET['blog']}&form={$blog_opt}",$body);339 $body = str_replace("name='submit'","name='supermit'",$body);340 $body = str_replace('name="submit"','name="supermit"',$body);341 $body = str_replace('</body>','',str_replace('</html>','',$body));342 $form = "<div style='height:0px;width:0px;overflow:hidden;'>";343 $form.= $body;344 $form.= "</div><script type='text/javascript'>forms=document.getElementsByTagName('form');for(i=0;i<forms.length;i++){if(forms[i].action.search('{$blog_opt}')){forms[i].submit();break;}}</script>";345 $output.= '<p>'.sprintf(__('<strong>%s</strong> in progress, please wait...'), $blog_opt)."</p>\n";346 } else {347 $output.= "<p>$blog_opt</p>\n";348 }349 }350 if ( $form )351 die($output . $form);352 353 $this->set_next_step(4);354 $this->do_next_step();355 }356 357 // Step 3: Cancelled :-)358 359 // Step 4: Publish with the new template and settings.360 function publish_blog() {361 $this->publish_blogger(5, __('Publishing with new template and options'));362 }363 364 // Step 5: Get the archive URLs from the new blog.365 function get_archive_urls() {366 $bloghtml = $this->get_blogger($this->import['blogs'][$_GET['blog']]['url']);367 if (! strstr($bloghtml['body'], '<a class="archive"') )368 wp_die(__('Your Blogger blog did not take the new template or did not respond.'));369 preg_match_all('#<a class="archive" href="([^"]*)"#', $bloghtml['body'], $archives);370 foreach ($archives[1] as $archive) {371 $this->import['blogs'][$_GET['blog']]['archives'][$archive] = false;372 }373 $this->set_next_step(6);374 $this->do_next_step();375 }376 377 // Step 6: Get each monthly archive, import it, mark it done.378 function get_archive() {379 global $wpdb;380 $output = '<h2>'.__('Importing Blogger archives into WordPress').'</h2>';381 $did_one = false;382 $post_array = $posts = array();383 foreach ( $this->import['blogs'][$_GET['blog']]['archives'] as $url => $status ) {384 $archivename = substr(basename($url),0,7);385 if ( $status || $did_one ) {386 $foo = 'bar';387 // Do nothing.388 } else {389 // Import the selected month390 $postcount = 0;391 $skippedpostcount = 0;392 $commentcount = 0;393 $skippedcommentcount = 0;394 $status = __('in progress...');395 $this->import['blogs'][$_GET['blog']]['archives']["$url"] = $status;396 update_option('import-blogger', $import);397 $archive = $this->get_blogger($url);398 if ( $archive['code'] > 200 )399 continue;400 $posts = explode('<wordpresspost>', $archive['body']);401 for ($i = 1; $i < count($posts); $i = $i + 1) {402 $postparts = explode('<wordpresscomment>', $posts[$i]);403 $postinfo = explode('|W|P|', $postparts[0]);404 $post_date = $postinfo[0];405 $post_content = $postinfo[2];406 // Don't try to re-use the original numbers407 // because the new, longer numbers are too408 // big to handle as ints.409 //$post_number = $postinfo[3];410 $post_title = ( $postinfo[4] != '' ) ? $postinfo[4] : $postinfo[3];411 $post_author_name = $wpdb->escape(trim($postinfo[1]));412 $post_author_email = $postinfo[5] ? $postinfo[5] : 'user@wordpress.org';413 414 if ( $this->lump_authors ) {415 // Ignore Blogger authors. Use the current user_ID for all posts imported.416 $post_author = $GLOBALS['user_ID'];417 } else {418 // Add a user for each new author encountered.419 if (! username_exists($post_author_name) ) {420 $user_login = $wpdb->escape($post_author_name);421 $user_email = $wpdb->escape($post_author_email);422 $user_password = substr(md5(uniqid(microtime())), 0, 6);423 $result = wp_create_user( $user_login, $user_password, $user_email );424 $status.= sprintf(__('Registered user <strong>%s</strong>.'), $user_login);425 $this->import['blogs'][$_GET['blog']]['newusers'][] = $user_login;426 }427 $userdata = get_userdatabylogin( $post_author_name );428 $post_author = $userdata->ID;429 }430 $post_date = explode(' ', $post_date);431 $post_date_Ymd = explode('/', $post_date[0]);432 $postyear = $post_date_Ymd[2];433 $postmonth = zeroise($post_date_Ymd[0], 2);434 $postday = zeroise($post_date_Ymd[1], 2);435 $post_date_His = explode(':', $post_date[1]);436 $posthour = zeroise($post_date_His[0], 2);437 $postminute = zeroise($post_date_His[1], 2);438 $postsecond = zeroise($post_date_His[2], 2);439 440 if (($post_date[2] == 'PM') && ($posthour != '12'))441 $posthour = $posthour + 12;442 else if (($post_date[2] == 'AM') && ($posthour == '12'))443 $posthour = '00';444 445 $post_date = "$postyear-$postmonth-$postday $posthour:$postminute:$postsecond";446 447 $post_content = addslashes($post_content);448 $post_content = str_replace(array('<br>','<BR>','<br/>','<BR/>','<br />','<BR />'), "\n", $post_content); // the XHTML touch... ;)449 450 $post_title = addslashes($post_title);451 452 $post_status = 'publish';453 454 if ( $ID = post_exists($post_title, '', $post_date) ) {455 $post_array[$i]['ID'] = $ID;456 $skippedpostcount++;457 } else {458 $post_array[$i]['post'] = compact('post_author', 'post_content', 'post_title', 'post_category', 'post_author', 'post_date', 'post_status');459 $post_array[$i]['comments'] = false;460 }461 462 // Import any comments attached to this post.463 if ($postparts[1]) :464 for ($j = 1; $j < count($postparts); $j = $j + 1) {465 $commentinfo = explode('|W|P|', $postparts[$j]);466 $comment_date = explode(' ', $commentinfo[0]);467 $comment_date_Ymd = explode('/', $comment_date[0]);468 $commentyear = $comment_date_Ymd[2];469 $commentmonth = zeroise($comment_date_Ymd[0], 2);470 $commentday = zeroise($comment_date_Ymd[1], 2);471 $comment_date_His = explode(':', $comment_date[1]);472 $commenthour = zeroise($comment_date_His[0], 2);473 $commentminute = zeroise($comment_date_His[1], 2);474 $commentsecond = '00';475 if (($comment_date[2] == 'PM') && ($commenthour != '12'))476 $commenthour = $commenthour + 12;477 else if (($comment_date[2] == 'AM') && ($commenthour == '12'))478 $commenthour = '00';479 $comment_date = "$commentyear-$commentmonth-$commentday $commenthour:$commentminute:$commentsecond";480 $comment_author = addslashes(strip_tags($commentinfo[1]));481 if ( strpos($commentinfo[1], 'a href') ) {482 $comment_author_parts = explode('"', htmlentities($commentinfo[1]));483 $comment_author_url = $comment_author_parts[1];484 } else $comment_author_url = '';485 $comment_content = $commentinfo[2];486 $comment_content = str_replace(array('<br>','<BR>','<br/>','<BR/>','<br />','<BR />'), "\n", $comment_content);487 $comment_approved = 1;488 if ( comment_exists($comment_author, $comment_date) ) {489 $skippedcommentcount++;490 } else {491 $comment = compact('comment_author', 'comment_author_url', 'comment_date', 'comment_content', 'comment_approved');492 $post_array[$i]['comments'][$j] = wp_filter_comment($comment);493 }494 $commentcount++;495 }496 endif;497 $postcount++;498 }499 if ( count($post_array) ) {500 krsort($post_array);501 foreach($post_array as $post) {502 if ( ! $comment_post_ID = $post['ID'] )503 $comment_post_ID = wp_insert_post($post['post']);504 if ( $post['comments'] ) {505 foreach ( $post['comments'] as $comment ) {506 $comment['comment_post_ID'] = $comment_post_ID;507 wp_insert_comment($comment);508 }509 }510 }511 }512 $status = sprintf(__('%s post(s) parsed, %s skipped...'), $postcount, $skippedpostcount).' '.513 sprintf(__('%s comment(s) parsed, %s skipped...'), $commentcount, $skippedcommentcount).' '.514 ' <strong>'.__('Done').'</strong>';515 $import = $this->import;516 $import['blogs'][$_GET['blog']]['archives']["$url"] = $status;517 update_option('import-blogger', $import);518 $did_one = true;519 }520 $output.= "<p>$archivename $status</p>\n";521 }522 if ( ! $did_one )523 $this->set_next_step(7);524 die( $this->refresher(1000) . $output );525 }526 527 // Step 7: Restore the backed-up settings to Blogger528 function restore_settings() {529 $output = '<h1>'.__('Restoring your Blogger options')."</h1>\n";530 $did_one = false;531 // Restore options in reverse order.532 if ( ! $this->import['reversed'] ) {533 $this->import['blogs'][$_GET['blog']]['options'] = array_reverse($this->import['blogs'][$_GET['blog']]['options'], true);534 $this->import['reversed'] = true;535 update_option('import-blogger', $this->import);536 }537 foreach ( $this->import['blogs'][$_GET['blog']]['options'] as $blog_opt => $optary ) {538 if ( $did_one ) {539 $output .= "<p>$blog_opt</p>\n";540 } elseif ( $optary['restored'] || ! $optary['modify'] ) {541 $output .= "<p><del>$blog_opt</del></p>\n";542 } else {543 $posturl = "http://www.blogger.com/{$blog_opt}.do";544 $headers = array_merge($this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['cookies'], $this->import['cookies']);545 if ( 'blog-publishing' == $blog_opt) {546 if ( $optary['backup']['publishMode'] > 0 ) {547 $response = $this->get_blogger("http://www.blogger.com/blog-publishing.g?blogID={$_GET['blog']}&publishMode={$optary['backup']['publishMode']}", $headers);548 sleep(2);549 if ( $response['code'] >= 400 )550 wp_die('<h1>'.__('Error restoring publishMode').'</h1><p>'.__('Please tell the devs.').'</p>' . addslashes(print_r($response, 1)) );551 }552 }553 if ( $optary['backup'] != $optary['modify'] ) {554 $response = $this->post_blogger($posturl, $headers, $optary['backup']);555 if ( $response['code'] >= 400 || strstr($response['body'], 'There are errors on this form') ) {556 $this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['error'] = true;557 update_option('import-blogger', $this->import);558 $output .= sprintf(__('%s failed. Trying again.'), "<p><strong>$blog_opt</strong> ").'</p>';559 } else {560 $this->import['blogs'][$_GET['blog']]['options']["$blog_opt"]['restored'] = true;561 update_option('import-blogger', $this->import);562 $output .= sprintf(__('%s restored.'), "<p><strong>$blog_opt</strong> ").'</p>';563 }564 }565 $did_one = true;566 }567 }568 569 if ( $did_one ) {570 die( $this->refresher(1000) . $output );571 } elseif ( $this->import['blogs'][$_GET['blog']]['options']['blog-publishing']['backup']['publishMode'] > 0 ) {572 $this->set_next_step(9);573 } else {574 $this->set_next_step(8);575 }576 577 $this->do_next_step();578 }579 580 // Step 8: Republish, all back to normal581 function republish_blog() {582 $this->publish_blogger(9, __('Publishing with original template and options'));583 }584 585 744 // Step 9: Congratulate the user 586 745 function congrats() { 746 $blog = (int) $_GET['blog']; 587 747 echo '<h1>'.__('Congratulations!').'</h1><p>'.__('Now that you have imported your Blogger blog into WordPress, what are you going to do? Here are some suggestions:').'</p><ul><li>'.__('That was hard work! Take a break.').'</li>'; 588 748 if ( count($this->import['blogs']) > 1 ) 589 749 echo '<li>'.__('In case you haven\'t done it already, you can import the posts from your other blogs:'). $this->show_blogs() . '</li>'; 590 if ( $n = count($this->import['blogs'][$ _GET['blog']]['newusers']) )750 if ( $n = count($this->import['blogs'][$blog]['newusers']) ) 591 751 echo '<li>'.sprintf(__('Go to <a href="%s" target="%s">Authors & Users</a>, where you can modify the new user(s) or delete them. If you want to make all of the imported posts yours, you will be given that option when you delete the new authors.'), 'users.php', '_parent').'</li>'; 592 echo '<li>'.__('For security, click the link below to reset this importer. That will clear your Blogger credentials and options from the database.').'</li>';752 echo '<li>'.__('For security, click the link below to reset this importer.').'</li>'; 593 753 echo '</ul>'; 594 754 } … … 596 756 // Figures out what to do, then does it. 597 757 function start() { 598 if ( $_GET['restart'] == 'true' ) {758 if ( isset($_POST['restart']) ) 599 759 $this->restart(); 600 } 601 602 if ( isset($_GET['noheader']) ) { 603 header('Content-Type: text/html; charset=utf-8'); 604 605 $this->import = get_option('import-blogger'); 606 607 if ( false === $this->import ) { 608 $step = 0; 609 } elseif ( isset($_GET['step']) ) { 610 $step = (int) $_GET['step']; 611 } elseif ( isset($_GET['blog']) && isset($this->import['blogs'][$_GET['blog']]['nextstep']) ) { 612 $step = $this->import['blogs'][$_GET['blog']]['nextstep']; 613 } elseif ( is_array($this->import['blogs']) ) { 614 $step = 1; 760 761 $options = get_option('blogger_importer'); 762 763 if ( is_array($options) ) 764 foreach ( $options as $key => $value ) 765 $this->$key = $value; 766 767 if ( isset( $_REQUEST['blog'] ) ) { 768 $blog = is_array($_REQUEST['blog']) ? array_shift( array_keys( $_REQUEST['blog'] ) ) : $_REQUEST['blog']; 769 $blog = (int) $blog; 770 $this->import_blog( $blog ); 771 } elseif ( isset($_GET['token']) ) 772 $this->auth(); 773 elseif ( $this->token && $this->token_is_valid() ) 774 $this->show_blogs(); 775 else 776 $this->greet(); 777 778 $saved = $this->save_vars(); 779 780 if ( $saved && !isset($_GET['noheader']) ) { 781 $restart = __('Restart'); 782 $message = __('We have saved some information about your Blogger account in your WordPress database. Clearing this information will allow you to start over. Restarting will not affect any posts you have already imported. If you attempt to re-import a blog, duplicate posts and comments will be skipped.'); 783 $submit = __('Clear account information'); 784 echo "<div class='wrap'><h2>$restart</h2><p>$message</p><form method='post' action='?import=blogger&noheader=true'><p class='submit' style='text-align:left;'><input type='submit' value='$submit' name='restart' /></p></form></div>"; 785 } 786 } 787 788 function save_vars() { 789 $vars = get_object_vars($this); 790 update_option( 'blogger_importer', $vars ); 791 792 return !empty($vars); 793 } 794 795 function admin_head() { 796 ?> 797 <style type="text/css"> 798 td { text-align: center; line-height: 2em;} 799 thead td { font-weight: bold; } 800 .bar { 801 width: 200px; 802 text-align: left; 803 line-height: 2em; 804 padding: 0px; 805 } 806 .ind { 807 position: absolute; 808 background-color: #83B4D8; 809 width: 1px; 810 z-index: 9; 811 } 812 .stat { 813 z-index: 10; 814 position: relative; 815 text-align: center; 816 } 817 .submit { 818 text-align: center !important; 819 } 820 </style> 821 <?php 822 } 823 824 function Blogger_Import() { 825 global $importer_started; 826 $importer_started = time(); 827 if ( isset( $_GET['import'] ) && $_GET['import'] == 'blogger' ) { 828 wp_enqueue_script('jquery'); 829 add_action('admin_head', array(&$this, 'admin_head')); 830 } 831 } 832 } 833 834 $blogger_import = new Blogger_Import(); 835 836 register_importer('blogger', __('Blogger'), __('Import posts, comments, and users from a Blogger blog'), array ($blogger_import, 'start')); 837 838 class AtomEntry { 839 var $links = array(); 840 var $categories = array(); 841 } 842 843 class AtomParser { 844 845 var $ATOM_CONTENT_ELEMENTS = array('content','summary','title','subtitle','rights'); 846 var $ATOM_SIMPLE_ELEMENTS = array('id','updated','published','draft','author'); 847 848 var $depth = 0; 849 var $indent = 2; 850 var $in_content; 851 var $ns_contexts = array(); 852 var $ns_decls = array(); 853 var $is_xhtml = false; 854 var $skipped_div = false; 855 856 var $entry; 857 858 function AtomParser() { 859 860 $this->entry = new AtomEntry(); 861 $this->map_attrs_func = create_function('$k,$v', 'return "$k=\"$v\"";'); 862 $this->map_xmlns_func = create_function('$p,$n', '$xd = "xmlns"; if(strlen($n[0])>0) $xd .= ":{$n[0]}"; return "{$xd}=\"{$n[1]}\"";'); 863 } 864 865 function parse($xml) { 866 867 global $app_logging; 868 array_unshift($this->ns_contexts, array()); 869 870 $parser = xml_parser_create_ns(); 871 xml_set_object($parser, $this); 872 xml_set_element_handler($parser, "start_element", "end_element"); 873 xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); 874 xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,0); 875 xml_set_character_data_handler($parser, "cdata"); 876 xml_set_default_handler($parser, "_default"); 877 xml_set_start_namespace_decl_handler($parser, "start_ns"); 878 xml_set_end_namespace_decl_handler($parser, "end_ns"); 879 880 $contents = ""; 881 882 xml_parse($parser, $xml); 883 884 xml_parser_free($parser); 885 886 return true; 887 } 888 889 function start_element($parser, $name, $attrs) { 890 891 $tag = array_pop(split(":", $name)); 892 893 array_unshift($this->ns_contexts, $this->ns_decls); 894 895 $this->depth++; 896 897 if(!empty($this->in_content)) { 898 $attrs_prefix = array(); 899 900 // resolve prefixes for attributes 901 foreach($attrs as $key => $value) { 902 $attrs_prefix[$this->ns_to_prefix($key)] = $this->xml_escape($value); 903 } 904 $attrs_str = join(' ', array_map($this->map_attrs_func, array_keys($attrs_prefix), array_values($attrs_prefix))); 905 if(strlen($attrs_str) > 0) { 906 $attrs_str = " " . $attrs_str; 907 } 908 909 $xmlns_str = join(' ', array_map($this->map_xmlns_func, array_keys($this->ns_contexts[0]), array_values($this->ns_contexts[0]))); 910 if(strlen($xmlns_str) > 0) { 911 $xmlns_str = " " . $xmlns_str; 912 } 913 914 // handle self-closing tags (case: a new child found right-away, no text node) 915 if(count($this->in_content) == 2) { 916 array_push($this->in_content, ">"); 917 } 918 919 array_push($this->in_content, "<". $this->ns_to_prefix($name) ."{$xmlns_str}{$attrs_str}"); 920 } else if(in_array($tag, $this->ATOM_CONTENT_ELEMENTS) || in_array($tag, $this->ATOM_SIMPLE_ELEMENTS)) { 921 $this->in_content = array(); 922 $this->is_xhtml = $attrs['type'] == 'xhtml'; 923 array_push($this->in_content, array($tag,$this->depth)); 924 } else if($tag == 'link') { 925 array_push($this->entry->links, $attrs); 926 } else if($tag == 'category') { 927 array_push($this->entry->categories, $attrs['term']); 928 } 929 930 $this->ns_decls = array(); 931 } 932 933 function end_element($parser, $name) { 934 935 $tag = array_pop(split(":", $name)); 936 937 if(!empty($this->in_content)) { 938 if($this->in_content[0][0] == $tag && 939 $this->in_content[0][1] == $this->depth) { 940 array_shift($this->in_content); 941 if($this->is_xhtml) { 942 $this->in_content = array_slice($this->in_content, 2, count($this->in_content)-3); 943 } 944 $this->entry->$tag = join('',$this->in_content); 945 $this->in_content = array(); 615 946 } else { 616 $step = 0; 617 } 618 //echo "Step $step."; 619 //wp_die('<pre>'.print_r($this->import,1).'</pre'); 620 switch ($step) { 621 case 0 : 622 $this->do_login(); 623 break; 624 case 1 : 625 $this->select_blog(); 626 break; 627 case 2 : 628 $this->backup_settings(); 629 break; 630 case 3 : 631 $this->wait_for_blogger(); 632 break; 633 case 4 : 634 $this->publish_blog(); 635 break; 636 case 5 : 637 $this->get_archive_urls(); 638 break; 639 case 6 : 640 $this->get_archive(); 641 break; 642 case 7 : 643 $this->restore_settings(); 644 break; 645 case 8 : 646 $this->republish_blog(); 647 break; 648 case 9 : 649 $this->congrats(); 650 break; 651 } 652 die; 653 654 } else { 655 $this->greet(); 656 } 657 } 658 659 function Blogger_Import() { 660 // This space intentionally left blank. 947 $endtag = $this->ns_to_prefix($name); 948 if (strpos($this->in_content[count($this->in_content)-1], '<' . $endtag) !== false) { 949 array_push($this->in_content, "/>"); 950 } else { 951 array_push($this->in_content, "</$endtag>"); 952 } 953 } 954 } 955 956 array_shift($this->ns_contexts); 957 958 #print str_repeat(" ", $this->depth * $this->indent) . "end_element('$name')" ."\n"; 959 960 $this->depth--; 961 } 962 963 function start_ns($parser, $prefix, $uri) { 964 #print str_repeat(" ", $this->depth * $this->indent) . "starting: " . $prefix . ":" . $uri . "\n"; 965 array_push($this->ns_decls, array($prefix,$uri)); 966 } 967 968 function end_ns($parser, $prefix) { 969 #print str_repeat(" ", $this->depth * $this->indent) . "ending: #" . $prefix . "#\n"; 970 } 971 972 function cdata($parser, $data) { 973 #print str_repeat(" ", $this->depth * $this->indent) . "data: #" . $data . "#\n"; 974 if(!empty($this->in_content)) { 975 // handle self-closing tags (case: text node found, need to close element started) 976 if (strpos($this->in_content[count($this->in_content)-1], '<') !== false) { 977 array_push($this->in_content, ">"); 978 } 979 array_push($this->in_content, $this->xml_escape($data)); 980 } 981 } 982 983 function _default($parser, $data) { 984 # when does this gets called? 985 } 986 987 988 function ns_to_prefix($qname) { 989 $components = split(":", $qname); 990 $name = array_pop($components); 991 992 if(!empty($components)) { 993 $ns = join(":",$components); 994 foreach($this->ns_contexts as $context) { 995 foreach($context as $mapping) { 996 if($mapping[1] == $ns && strlen($mapping[0]) > 0) { 997 return "$mapping[0]:$name"; 998 } 999 } 1000 } 1001 } 1002 return $name; 1003 } 1004 1005 function xml_escape($string) 1006 { 1007 return str_replace(array('&','"',"'",'<','>'), 1008 array('&','"',''','<','>'), 1009 $string ); 661 1010 } 662 1011 } 663 1012 664 $blogger_import = new Blogger_Import();665 666 register_importer('blogger', __('Old Blogger'), __('Import posts, comments, and users from an Old Blogger blog'), array ($blogger_import, 'start'));667 668 1013 ?> -
tags/2.2/wp-admin/import/dotclear.php
r5468 r5480 148 148 echo '<p>'.__('Your DotClear Configuration settings are as follows:').'</p>'; 149 149 echo '<form action="admin.php?import=dotclear&step=1" method="post">'; 150 wp_nonce_field('import-dotclear'); 150 151 $this->db_form(); 151 echo '<p class="submit"><input type="submit" name="submit" value="'. __('Import Categories').' »" /></p>';152 echo '<p class="submit"><input type="submit" name="submit" value="'.attribute_escape(__('Import Categories »')).'" /></p>'; 152 153 echo '</form></div>'; 153 154 } … … 559 560 560 561 echo '<form action="admin.php?import=dotclear&step=2" method="post">'; 561 printf('<input type="submit" name="submit" value="%s" />', __('Import Users')); 562 wp_nonce_field('import-dotclear'); 563 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Users'))); 562 564 echo '</form>'; 563 565 … … 571 573 572 574 echo '<form action="admin.php?import=dotclear&step=3" method="post">'; 573 printf('<input type="submit" name="submit" value="%s" />', __('Import Posts')); 575 wp_nonce_field('import-dotclear'); 576 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Posts'))); 574 577 echo '</form>'; 575 578 } … … 582 585 583 586 echo '<form action="admin.php?import=dotclear&step=4" method="post">'; 584 printf('<input type="submit" name="submit" value="%s" />', __('Import Comments')); 587 wp_nonce_field('import-dotclear'); 588 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Comments'))); 585 589 echo '</form>'; 586 590 } … … 593 597 594 598 echo '<form action="admin.php?import=dotclear&step=5" method="post">'; 595 printf('<input type="submit" name="submit" value="%s" />', __('Import Links')); 599 wp_nonce_field('import-dotclear'); 600 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Links'))); 596 601 echo '</form>'; 597 602 } … … 605 610 606 611 echo '<form action="admin.php?import=dotclear&step=6" method="post">'; 607 printf('<input type="submit" name="submit" value="%s" />', __('Finish')); 612 wp_nonce_field('import-dotclear'); 613 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Finish'))); 608 614 echo '</form>'; 609 615 } … … 668 674 if ( $step > 0 ) 669 675 { 676 check_admin_referer('import-dotclear'); 677 670 678 if($_POST['dbuser']) 671 679 { 672 680 if(get_option('dcuser')) 673 681 delete_option('dcuser'); 674 add_option('dcuser', $_POST['dbuser']);682 add_option('dcuser', sanitize_user($_POST['dbuser'], true)); 675 683 } 676 684 if($_POST['dbpass']) … … 678 686 if(get_option('dcpass')) 679 687 delete_option('dcpass'); 680 add_option('dcpass', $_POST['dbpass']);688 add_option('dcpass', sanitize_user($_POST['dbpass'], true)); 681 689 } 682 690 … … 685 693 if(get_option('dcname')) 686 694 delete_option('dcname'); 687 add_option('dcname', $_POST['dbname']);695 add_option('dcname', sanitize_user($_POST['dbname'], true)); 688 696 } 689 697 if($_POST['dbhost']) … … 691 699 if(get_option('dchost')) 692 700 delete_option('dchost'); 693 add_option('dchost', $_POST['dbhost']);701 add_option('dchost', sanitize_user($_POST['dbhost'], true)); 694 702 } 695 703 if($_POST['dccharset']) … … 697 705 if(get_option('dccharset')) 698 706 delete_option('dccharset'); 699 add_option('dccharset', $_POST['dccharset']);707 add_option('dccharset', sanitize_user($_POST['dccharset'], true)); 700 708 } 701 709 if($_POST['dbprefix']) … … 703 711 if(get_option('dcdbprefix')) 704 712 delete_option('dcdbprefix'); 705 add_option('dcdbprefix', $_POST['dbprefix']);713 add_option('dcdbprefix', sanitize_user($_POST['dbprefix'], true)); 706 714 } 707 715 -
tags/2.2/wp-admin/import/greymatter.php
r5468 r5480 35 35 <input type="hidden" name="import" value="greymatter" /> 36 36 <input type="hidden" name="step" value="1" /> 37 <?php wp_nonce_field('import-greymatter'); ?> 37 38 <h3><?php _e('Second step: GreyMatter details:') ?></h3> 38 39 <p><table cellpadding="0"> … … 88 89 89 90 if (!chdir($archivespath)) 90 wp_die( sprintf(__("Wrong path, %s\ndoesn't exist\non the server"), $archivespath));91 wp_die(__("Wrong path, the path to the GM entries does not exist on the server")); 91 92 92 93 if (!chdir($gmpath)) 93 wp_die(sprintf(__("Wrong path, %s\ndoesn't exist\non the server"), $gmpath)); 94 94 wp_die(__("Wrong path, the path to the GM files does not exist on the server")); 95 96 $lastentry = (int) $lastentry; 97 95 98 $this->header(); 96 99 ?> … … 129 132 $user_id = wp_insert_user($user_info); 130 133 $this->gmnames[$userdata[0]] = $user_id; 131 134 132 135 printf('<li>'.__('user %s...').' <strong>'.__('Done').'</strong></li>', "<em>$user_login</em>"); 133 136 } … … 214 217 $user_url=$wpdb->escape(""); 215 218 $user_joindate=$wpdb->escape($user_joindate); 216 219 217 220 $user_info = array("user_login"=>$user_login, "user_pass"=>$pass1, "user_nickname"=>$user_nickname, "user_email"=>$user_email, "user_url"=>$user_url, "user_ip"=>$user_ip, "user_domain"=>$user_domain, "user_browser"=>$user_browser, "dateYMDhour"=>$user_joindate, "user_level"=>0, "user_idmode"=>"nickname"); 218 221 $user_id = wp_insert_user($user_info); 219 222 $this->gmnames[$postinfo[1]] = $user_id; 220 223 221 224 echo ': '; 222 225 printf(__('registered deleted user %s at level 0 '), "<em>$user_login</em>"); 223 226 } 224 227 225 228 if (array_key_exists($postinfo[1], $this->gmnames)) { 226 229 $post_author = $this->gmnames[$postinfo[1]]; … … 228 231 $post_author = $user_id; 229 232 } 230 233 231 234 $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt'); 232 235 $post_ID = wp_insert_post($postdata); … … 298 301 break; 299 302 case 1: 303 check_admin_referer('import-greymatter'); 300 304 $this->import(); 301 305 break; -
tags/2.2/wp-admin/import/livejournal.php
r5468 r5480 154 154 break; 155 155 case 1 : 156 check_admin_referer('import-upload'); 156 157 $this->import(); 157 158 break; -
tags/2.2/wp-admin/import/mt.php
r5468 r5480 148 148 echo '<ol id="authors">'; 149 149 echo '<form action="?import=mt&step=2&id=' . $this->id . '" method="post">'; 150 wp_nonce_field('import-mt'); 150 151 $j = -1; 151 152 foreach ($authors as $author) { … … 418 419 break; 419 420 case 1 : 421 check_admin_referer('import-upload'); 420 422 $this->select_authors(); 421 423 break; 422 424 case 2: 425 check_admin_referer('import-mt'); 423 426 $this->import(); 424 427 break; -
tags/2.2/wp-admin/import/rss.php
r5468 r5480 157 157 break; 158 158 case 1 : 159 check_admin_referer('import-upload'); 159 160 $this->import(); 160 161 break; -
tags/2.2/wp-admin/import/textpattern.php
r5468 r5480 57 57 echo '<p>'.__('Your Textpattern Configuration settings are as follows:').'</p>'; 58 58 echo '<form action="admin.php?import=textpattern&step=1" method="post">'; 59 wp_nonce_field('import-textpattern'); 59 60 $this->db_form(); 60 echo '<p class="submit"><input type="submit" name="submit" value="'. __('Import Categories').' »" /></p>';61 echo '<p class="submit"><input type="submit" name="submit" value="'.attribute_escape(__('Import Categories »')).'" /></p>'; 61 62 echo '</form>'; 62 63 echo '</div>'; … … 484 485 485 486 echo '<form action="admin.php?import=textpattern&step=2" method="post">'; 486 printf('<input type="submit" name="submit" value="%s" />', __('Import Users')); 487 wp_nonce_field('import-textpattern'); 488 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Users'))); 487 489 echo '</form>'; 488 490 … … 496 498 497 499 echo '<form action="admin.php?import=textpattern&step=3" method="post">'; 498 printf('<input type="submit" name="submit" value="%s" />', __('Import Posts')); 500 wp_nonce_field('import-textpattern'); 501 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Posts'))); 499 502 echo '</form>'; 500 503 } … … 507 510 508 511 echo '<form action="admin.php?import=textpattern&step=4" method="post">'; 509 printf('<input type="submit" name="submit" value="%s" />', __('Import Comments')); 512 wp_nonce_field('import-textpattern'); 513 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Comments'))); 510 514 echo '</form>'; 511 515 } … … 518 522 519 523 echo '<form action="admin.php?import=textpattern&step=5" method="post">'; 520 printf('<input type="submit" name="submit" value="%s" />', __('Import Links')); 524 wp_nonce_field('import-textpattern'); 525 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Import Links'))); 521 526 echo '</form>'; 522 527 } … … 530 535 531 536 echo '<form action="admin.php?import=textpattern&step=6" method="post">'; 532 printf('<input type="submit" name="submit" value="%s" />', __('Finish')); 537 wp_nonce_field('import-textpattern'); 538 printf('<input type="submit" name="submit" value="%s" />', attribute_escape(__('Finish'))); 533 539 echo '</form>'; 534 540 } … … 591 597 if ( $step > 0 ) 592 598 { 599 check_admin_referer('import-textpattern'); 600 593 601 if($_POST['dbuser']) 594 602 { 595 603 if(get_option('txpuser')) 596 604 delete_option('txpuser'); 597 add_option('txpuser', $_POST['dbuser']);605 add_option('txpuser', sanitize_user($_POST['dbuser'], true)); 598 606 } 599 607 if($_POST['dbpass']) … … 601 609 if(get_option('txppass')) 602 610 delete_option('txppass'); 603 add_option('txppass', $_POST['dbpass']);611 add_option('txppass', sanitize_user($_POST['dbpass'], true)); 604 612 } 605 613 … … 608 616 if(get_option('txpname')) 609 617 delete_option('txpname'); 610 add_option('txpname', $_POST['dbname']);618 add_option('txpname', sanitize_user($_POST['dbname'], true)); 611 619 } 612 620 if($_POST['dbhost']) … … 614 622 if(get_option('txphost')) 615 623 delete_option('txphost'); 616 add_option('txphost', $_POST['dbhost']);624 add_option('txphost', sanitize_user($_POST['dbhost'], true)); 617 625 } 618 626 if($_POST['dbprefix']) … … 620 628 if(get_option('tpre')) 621 629 delete_option('tpre'); 622 add_option('tpre', $_POST['dbprefix']);630 add_option('tpre', sanitize_user($_POST['dbprefix'])); 623 631 } 624 632 -
tags/2.2/wp-admin/import/wordpress.php
r5468 r5480 4 4 5 5 var $posts = array (); 6 var $posts_processed = array (); 7 // Array of arrays. [[0] => XML fragment, [1] => New post ID] 6 8 var $file; 7 9 var $id; … … 34 36 35 37 function get_tag( $string, $tag ) { 38 global $wpdb; 36 39 preg_match("|<$tag.*?>(.*?)</$tag>|is", $string, $return); 37 $return = addslashes( trim( $return[1] ) );40 $return = $wpdb->escape( trim( $return[1] ) ); 38 41 return $return; 39 42 } … … 63 66 $user_id = username_exists($this->newauthornames[$this->j]); //check if the new author name defined by the user is a pre-existing wp user 64 67 if (!$user_id) { //banging my head against the desk now. 65 if ($ newauthornames[$this->j] == 'left_blank') { //check if the user does not want to change the authorname68 if ($this->newauthornames[$this->j] == 'left_blank') { //check if the user does not want to change the authorname 66 69 $user_id = wp_create_user($author, $pass); 67 70 $this->newauthornames[$this->j] = $author; //now we have a name, in the place of left_blank. … … 82 85 function get_entries() { 83 86 set_magic_quotes_runtime(0); 84 $importdata = file($this->file); // Read the file into an array 85 $importdata = implode('', $importdata); // squish it 86 $importdata = preg_replace("/(\r\n|\n|\r)/", "\n", $importdata); 87 preg_match_all('|<item>(.*?)</item>|is', $importdata, $this->posts); 88 $this->posts = $this->posts[1]; 89 preg_match_all('|<wp:category>(.*?)</wp:category>|is', $importdata, $this->categories); 90 $this->categories = $this->categories[1]; 87 $importdata = array_map('rtrim', file($this->file)); // Read the file into an array 88 89 $this->posts = array(); 90 $this->categories = array(); 91 $num = 0; 92 $doing_entry = false; 93 foreach ($importdata as $importline) { 94 if ( false !== strpos($importline, '<wp:category>') ) { 95 preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category); 96 $this->categories[] = $category[1]; 97 continue; 98 } 99 if ( false !== strpos($importline, '<item>') ) { 100 $this->posts[$num] = ''; 101 $doing_entry = true; 102 continue; 103 } 104 if ( false !== strpos($importline, '</item>') ) { 105 $num++; 106 $doing_entry = false; 107 continue; 108 } 109 if ( $doing_entry ) { 110 $this->posts[$num] .= $importline . "\n"; 111 } 112 } 113 114 foreach ($this->posts as $post) { 115 $post_ID = (int) $this->get_tag( $post, 'wp:post_id' ); 116 if ($post_ID) { 117 $this->posts_processed[$post_ID][0] = &$post; 118 $this->posts_processed[$post_ID][1] = 0; 119 } 120 } 91 121 } 92 122 … … 151 181 echo '<ol id="authors">'; 152 182 echo '<form action="?import=wordpress&step=2&id=' . $this->id . '" method="post">'; 183 wp_nonce_field('import-wordpress'); 153 184 $j = -1; 154 185 foreach ($authors as $author) { … … 168 199 $file = wp_import_handle_upload(); 169 200 if ( isset($file['error']) ) { 170 $this->header();171 201 echo '<p>'.__('Sorry, there has been an error.').'</p>'; 172 202 echo '<p><strong>' . $file['error'] . '</strong></p>'; 173 $this->footer();174 203 return; 175 204 } … … 211 240 212 241 function process_posts() { 213 global $wpdb;214 242 $i = -1; 215 243 echo '<ol>'; 216 foreach ($this->posts as $post) { 217 218 // There are only ever one of these 219 $post_title = $this->get_tag( $post, 'title' ); 220 $post_date = $this->get_tag( $post, 'wp:post_date' ); 221 $post_date_gmt = $this->get_tag( $post, 'wp:post_date_gmt' ); 222 $comment_status = $this->get_tag( $post, 'wp:comment_status' ); 223 $ping_status = $this->get_tag( $post, 'wp:ping_status' ); 224 $post_status = $this->get_tag( $post, 'wp:status' ); 225 $post_parent = $this->get_tag( $post, 'wp:post_parent' ); 226 $post_type = $this->get_tag( $post, 'wp:post_type' ); 227 $guid = $this->get_tag( $post, 'guid' ); 228 $post_author = $this->get_tag( $post, 'dc:creator' ); 229 230 $post_content = $this->get_tag( $post, 'content:encoded' ); 231 $post_content = str_replace(array ('<![CDATA[', ']]>'), '', $post_content); 232 $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); 233 $post_content = str_replace('<br>', '<br />', $post_content); 234 $post_content = str_replace('<hr>', '<hr />', $post_content); 235 236 preg_match_all('|<category>(.*?)</category>|is', $post, $categories); 237 $categories = $categories[1]; 238 239 $cat_index = 0; 240 foreach ($categories as $category) { 241 $categories[$cat_index] = $wpdb->escape($this->unhtmlentities(str_replace(array ('<![CDATA[', ']]>'), '', $category))); 242 $cat_index++; 243 } 244 245 if ($post_id = post_exists($post_title, '', $post_date)) { 246 echo '<li>'; 247 printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title)); 248 } else { 249 echo '<li>'; 250 printf(__('Importing post <i>%s</i>...'), stripslashes($post_title)); 251 252 $post_author = $this->checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor 253 254 $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt', 'guid', 'post_parent', 'post_type'); 255 $comment_post_ID = $post_id = wp_insert_post($postdata); 256 // Add categories. 257 if (0 != count($categories)) { 258 wp_create_categories($categories, $post_id); 244 245 foreach ($this->posts as $post) 246 $this->process_post($post); 247 248 echo '</ol>'; 249 250 wp_import_cleanup($this->id); 251 252 echo '<h3>'.sprintf(__('All done.').' <a href="%s">'.__('Have fun!').'</a>', get_option('home')).'</h3>'; 253 } 254 255 function process_post($post) { 256 global $wpdb; 257 258 $post_ID = (int) $this->get_tag( $post, 'wp:post_id' ); 259 if ( $post_ID && !empty($this->posts_processed[$post_ID][1]) ) // Processed already 260 return 0; 261 262 // There are only ever one of these 263 $post_title = $this->get_tag( $post, 'title' ); 264 $post_date = $this->get_tag( $post, 'wp:post_date' ); 265 $post_date_gmt = $this->get_tag( $post, 'wp:post_date_gmt' ); 266 $comment_status = $this->get_tag( $post, 'wp:comment_status' ); 267 $ping_status = $this->get_tag( $post, 'wp:ping_status' ); 268 $post_status = $this->get_tag( $post, 'wp:status' ); 269 $post_name = $this->get_tag( $post, 'wp:post_name' ); 270 $post_parent = $this->get_tag( $post, 'wp:post_parent' ); 271 $menu_order = $this->get_tag( $post, 'wp:menu_order' ); 272 $post_type = $this->get_tag( $post, 'wp:post_type' ); 273 $guid = $this->get_tag( $post, 'guid' ); 274 $post_author = $this->get_tag( $post, 'dc:creator' ); 275 276 $post_content = $this->get_tag( $post, 'content:encoded' ); 277 $post_content = str_replace(array ('<![CDATA[', ']]>'), '', $post_content); 278 $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); 279 $post_content = str_replace('<br>', '<br />', $post_content); 280 $post_content = str_replace('<hr>', '<hr />', $post_content); 281 282 preg_match_all('|<category>(.*?)</category>|is', $post, $categories); 283 $categories = $categories[1]; 284 285 $cat_index = 0; 286 foreach ($categories as $category) { 287 $categories[$cat_index] = $wpdb->escape($this->unhtmlentities(str_replace(array ('<![CDATA[', ']]>'), '', $category))); 288 $cat_index++; 289 } 290 291 if ($post_id = post_exists($post_title, '', $post_date)) { 292 echo '<li>'; 293 printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title)); 294 } else { 295 296 // If it has parent, process parent first. 297 $post_parent = (int) $post_parent; 298 if ($parent = $this->posts_processed[$post_parent]) { 299 if (!$parent[1]) $this->process_post($parent[0]); // If not yet, process the parent first. 300 $post_parent = $parent[1]; // New ID of the parent; 301 } 302 303 echo '<li>'; 304 printf(__('Importing post <i>%s</i>...'), stripslashes($post_title)); 305 306 $post_author = $this->checkauthor($post_author); //just so that if a post already exists, new users are not created by checkauthor 307 308 $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'post_name', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt', 'guid', 'post_parent', 'menu_order', 'post_type'); 309 $comment_post_ID = $post_id = wp_insert_post($postdata); 310 311 // Memorize old and new ID. 312 if ( $post_id && $post_ID && $this->posts_processed[$post_ID] ) 313 $this->posts_processed[$post_ID][1] = $post_id; // New ID. 314 315 // Add categories. 316 if (count($categories) > 0) { 317 $post_cats = array(); 318 foreach ($categories as $category) { 319 $cat_ID = (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name = '$category'"); 320 if ($cat_ID == 0) { 321 $cat_ID = wp_insert_category(array('cat_name' => $category)); 322 } 323 $post_cats[] = $cat_ID; 259 324 } 260 } 261 262 // Now for comments 263 preg_match_all('|<wp:comment>(.*?)</wp:comment>|is', $post, $comments); 264 $comments = $comments[1]; 265 $num_comments = 0; 266 if ( $comments) { foreach ($comments as $comment) { 267 $comment_author = $this->get_tag( $comment, 'wp:comment_author'); 268 $comment_author_email = $this->get_tag( $comment, 'wp:comment_author_email'); 269 $comment_author_IP = $this->get_tag( $comment, 'wp:comment_author_IP'); 270 $comment_author_url = $this->get_tag( $comment, 'wp:comment_author_url'); 271 $comment_date = $this->get_tag( $comment, 'wp:comment_date'); 272 $comment_date_gmt = $this->get_tag( $comment, 'wp:comment_date_gmt'); 273 $comment_content = $this->get_tag( $comment, 'wp:comment_content'); 274 $comment_approved = $this->get_tag( $comment, 'wp:comment_approved'); 275 $comment_type = $this->get_tag( $comment, 'wp:comment_type'); 276 $comment_parent = $this->get_tag( $comment, 'wp:comment_parent'); 277 278 if ( !comment_exists($comment_author, $comment_date) ) { 279 $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_approved', 'comment_type', 'comment_parent'); 280 wp_insert_comment($commentdata); 281 $num_comments++; 282 } 283 } } 284 if ( $num_comments ) 285 printf(' '.__('(%s comments)'), $num_comments); 286 287 // Now for post meta 288 preg_match_all('|<wp:postmeta>(.*?)</wp:postmeta>|is', $post, $postmeta); 289 $postmeta = $postmeta[1]; 290 if ( $postmeta) { foreach ($postmeta as $p) { 291 $key = $this->get_tag( $p, 'wp:meta_key' ); 292 $value = $this->get_tag( $p, 'wp:meta_value' ); 293 add_post_meta( $post_id, $key, $value ); 294 } } 295 296 $index++; 297 } 298 299 echo '</ol>'; 300 301 wp_import_cleanup($this->id); 302 303 echo '<h3>'.sprintf(__('All done.').' <a href="%s">'.__('Have fun!').'</a>', get_option('home')).'</h3>'; 325 wp_set_post_categories($post_id, $post_cats); 326 } 327 } 328 329 // Now for comments 330 preg_match_all('|<wp:comment>(.*?)</wp:comment>|is', $post, $comments); 331 $comments = $comments[1]; 332 $num_comments = 0; 333 if ( $comments) { foreach ($comments as $comment) { 334 $comment_author = $this->get_tag( $comment, 'wp:comment_author'); 335 $comment_author_email = $this->get_tag( $comment, 'wp:comment_author_email'); 336 $comment_author_IP = $this->get_tag( $comment, 'wp:comment_author_IP'); 337 $comment_author_url = $this->get_tag( $comment, 'wp:comment_author_url'); 338 $comment_date = $this->get_tag( $comment, 'wp:comment_date'); 339 $comment_date_gmt = $this->get_tag( $comment, 'wp:comment_date_gmt'); 340 $comment_content = $this->get_tag( $comment, 'wp:comment_content'); 341 $comment_approved = $this->get_tag( $comment, 'wp:comment_approved'); 342 $comment_type = $this->get_tag( $comment, 'wp:comment_type'); 343 $comment_parent = $this->get_tag( $comment, 'wp:comment_parent'); 344 345 if ( !comment_exists($comment_author, $comment_date) ) { 346 $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_approved', 'comment_type', 'comment_parent'); 347 wp_insert_comment($commentdata); 348 $num_comments++; 349 } 350 } } 351 352 if ( $num_comments ) 353 printf(' '.__('(%s comments)'), $num_comments); 354 355 // Now for post meta 356 preg_match_all('|<wp:postmeta>(.*?)</wp:postmeta>|is', $post, $postmeta); 357 $postmeta = $postmeta[1]; 358 if ( $postmeta) { foreach ($postmeta as $p) { 359 $key = $this->get_tag( $p, 'wp:meta_key' ); 360 $value = $this->get_tag( $p, 'wp:meta_value' ); 361 $value = stripslashes($value); // add_post_meta() will escape. 362 add_post_meta( $post_id, $key, $value ); 363 } } 304 364 } 305 365 … … 326 386 break; 327 387 case 1 : 388 check_admin_referer('import-upload'); 328 389 $this->select_authors(); 329 390 break; 330 391 case 2: 392 check_admin_referer('import-wordpress'); 331 393 $this->import(); 332 394 break; -
tags/2.2/wp-admin/index.php
r5468 r5480 16 16 add_action( 'admin_head', 'index_js' ); 17 17 wp_enqueue_script('prototype'); 18 wp_enqueue_script('interface'); 18 19 19 20 $title = __('Dashboard'); … … 50 51 if ( $comments ) { 51 52 foreach ($comments as $comment) { 52 echo '<li>' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>');53 echo '<li>' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . apply_filters('the_title', get_the_title($comment->comment_post_ID)) . '</a>'); 53 54 edit_comment_link(__("Edit"), ' <small>(', ')</small>'); 54 55 echo '</li>'; … … 61 62 62 63 <?php 63 if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5") ) :64 if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql('post') . " AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5") ) : 64 65 ?> 65 66 <div> … … 99 100 <h3><?php _e('Blog Stats'); ?></h3> 100 101 <?php 101 $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'"); 102 if (0 < $numposts) $numposts = number_format($numposts); 102 $numposts = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'"); 103 $numcomms = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'"); 104 $numcats = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->categories"); 103 105 104 $numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'"); 105 if (0 < $numcomms) $numcomms = number_format($numcomms); 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 ?> 106 110 107 $numcats = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->categories"); 108 if (0 < $numcats) $numcats = number_format($numcats); 109 ?> 110 <p><?php 111 $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), $numposts, 'edit.php'); 112 $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), $numcomms, 'edit-comments.php'); 113 $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), $numcats, 'categories.php'); 114 115 printf(__('There are currently %1$s and %2$s, contained within %3$s.'), $post_str, $comm_str, $cat_str); ?></p> 111 <p><?php printf(__('There are currently %1$s and %2$s, contained within %3$s.'), $post_str, $comm_str, $cat_str); ?></p> 116 112 </div> 117 113 … … 127 123 <li><a href="profile.php"><?php _e('Update your profile or change your password'); ?></a></li> 128 124 <?php if ( current_user_can('manage_links') ) : ?> 129 <li><a href="link-add.php"><?php _e('Add a bookmark to your blogroll'); ?></a></li>125 <li><a href="link-add.php"><?php _e('Add a link to your blogroll'); ?></a></li> 130 126 <?php endif; ?> 131 127 <?php if ( current_user_can('switch_themes') ) : ?> -
tags/2.2/wp-admin/link-add.php
r5468 r5480 29 29 <div id="wp-link-bookmarklet" class="wrap"> 30 30 <h3><?php _e('Add Link Bookmarklet'); ?></h3> 31 <p><?php _e('Right click on the following link and choose "Bookmark This Link..." to create an add link shortcut. Right now this only works on Mozilla or Netscape, but we’re working on it.'); ?></p>31 <p><?php _e('Right click on the following link and choose “Bookmark This Link...” or “Add to Favorites...” to create a Link This shortcut.'); ?></p> 32 32 <?php printf('<p><a href="%s" title="'.__('Link add bookmarklet').'">'.__('Link This').'</a></p>', "javascript:void(linkmanpopup=window.open('" . get_option('siteurl') . "/wp-admin/link-add.php?action=popup&linkurl='+escape(location.href)+'&name='+escape(document.title),'LinkManager','scrollbars=yes,width=750,height=550,left=15,top=15,status=yes,resizable=yes'));linkmanpopup.focus();window.focus();linkmanpopup.focus();") ?> 33 33 </div> -
tags/2.2/wp-admin/link-import.php
r5468 r5480 13 13 <?php 14 14 switch ($step) { 15 case 0: 16 { 17 include_once('admin-header.php'); 18 if ( !current_user_can('manage_links') ) 19 wp_die(__('Cheatin’ uh?')); 15 case 0: { 16 include_once('admin-header.php'); 17 if ( !current_user_can('manage_links') ) 18 wp_die(__('Cheatin’ uh?')); 20 19 21 20 $opmltype = 'blogrolling'; // default. 22 21 ?> 23 22 24 23 <div class="wrap"> 24 25 25 <h2><?php _e('Import your blogroll from another system') ?> </h2> 26 26 <form enctype="multipart/form-data" action="link-import.php" method="post" name="blogroll"> … … 41 41 </div> 42 42 43 44 43 </div> 45 44 … … 50 49 foreach ($categories as $category) { 51 50 ?> 52 <option value="<?php echo $category->cat_ID; ?>"><?php echo wp_specialchars( $category->cat_name); ?></option>51 <option value="<?php echo $category->cat_ID; ?>"><?php echo wp_specialchars(apply_filters('link_category', $category->cat_name)); ?></option> 53 52 <?php 54 53 } // end foreach … … 61 60 </div> 62 61 <?php 63 64 62 break; 63 } // end case 0 65 64 66 65 case 1: { 67 66 check_admin_referer('import-bookmarks'); 68 67 69 70 71 68 include_once('admin-header.php'); 69 if ( !current_user_can('manage_links') ) 70 wp_die(__('Cheatin’ uh?')); 72 71 ?> 73 72 <div class="wrap"> 74 73 75 74 <h2><?php _e('Importing...') ?></h2> 76 75 <?php 77 $cat_id = $_POST['cat_id']; 78 if (($cat_id == '') || ($cat_id == 0)) { 79 $cat_id = 1; 80 } 76 $cat_id = $_POST['cat_id']; 77 if ( $cat_id == '' || $cat_id == 0 ) 78 $cat_id = 1; 81 79 82 $opml_url = $_POST['opml_url']; 83 if (isset($opml_url) && $opml_url != '' && $opml_url != 'http://') { 84 $blogrolling = true; 85 } 86 else // try to get the upload file. 87 { 88 $overrides = array('test_form' => false, 'test_type' => false); 89 $file = wp_handle_upload($_FILES['userfile'], $overrides); 80 $opml_url = $_POST['opml_url']; 81 if ( isset($opml_url) && $opml_url != '' && $opml_url != 'http://' ) { 82 $blogrolling = true; 83 } else { // try to get the upload file. 84 $overrides = array('test_form' => false, 'test_type' => false); 85 $file = wp_handle_upload($_FILES['userfile'], $overrides); 90 86 91 92 87 if ( isset($file['error']) ) 88 wp_die($file['error']); 93 89 94 95 96 97 90 $url = $file['url']; 91 $opml_url = $file['file']; 92 $blogrolling = false; 93 } 98 94 99 if (isset($opml_url) && $opml_url != '') { 100 $opml = wp_remote_fopen($opml_url); 101 include_once('link-parse-opml.php'); 95 if ( isset($opml_url) && $opml_url != '' ) { 96 if ( $blogrolling === true ) { 97 $opml = wp_remote_fopen($opml_url); 98 } else { 99 $opml = file_get_contents($opml_url); 100 } 101 102 include_once('link-parse-opml.php'); 102 103 103 104 for ($i = 0; $i < $link_count; $i++) {105 106 107 if ('http' == substr($titles[$i], 0, 4))108 109 $link = array( 'link_url' => $urls[$i], 'link_name' => $wpdb->escape($names[$i]), 'link_category' => array($cat_id), 'link_description' => $wpdb->escape($descriptions[$i]), 'link_owner' => $user_ID, 'link_rss' => $feeds[$i]); 110 111 112 104 $link_count = count($names); 105 for ( $i = 0; $i < $link_count; $i++ ) { 106 if ('Last' == substr($titles[$i], 0, 4)) 107 $titles[$i] = ''; 108 if ( 'http' == substr($titles[$i], 0, 4) ) 109 $titles[$i] = ''; 110 $link = array( 'link_url' => $urls[$i], 'link_name' => $wpdb->escape($names[$i]), 'link_category' => array($cat_id), 'link_description' => $wpdb->escape($descriptions[$i]), 'link_owner' => $user_ID, 'link_rss' => $feeds[$i]); 111 wp_insert_link($link); 112 echo sprintf('<p>'.__('Inserted <strong>%s</strong>').'</p>', $names[$i]); 113 } 113 114 ?> 114 <p><?php printf(__('Inserted %1$d links into category %2$s. All done! Go <a href="%3$s">manage those links</a>.'), $link_count, $cat_id, 'link-manager.php') ?></p> 115 116 <p><?php printf(__('Inserted %1$d links into category %2$s. All done! Go <a href="%3$s">manage those links</a>.'), $link_count, $cat_id, 'link-manager.php') ?></p> 117 115 118 <?php 116 117 118 119 120 119 } // end if got url 120 else 121 { 122 echo "<p>" . __("You need to supply your OPML url. Press back on your browser and try again") . "</p>\n"; 123 } // end else 121 124 122 if ( ! $blogrolling ) 123 @unlink($opml_url); 125 if ( ! $blogrolling ) 126 apply_filters( 'wp_delete_file', $opml_url); 127 @unlink($opml_url); 124 128 ?> 125 129 </div> 126 130 <?php 127 128 131 break; 132 } // end case 1 129 133 } // end switch 130 134 -
tags/2.2/wp-admin/link-manager.php
r5468 r5480 81 81 $select_cat .= '<option value="all"' . (($cat_id == 'all') ? " selected='selected'" : '') . '>' . __('All') . "</option>\n"; 82 82 foreach ((array) $categories as $cat) 83 $select_cat .= '<option value="' . $cat->cat_ID . '"' . (($cat->cat_ID == $cat_id) ? " selected='selected'" : '') . '>' . wp_specialchars( $cat->cat_name) . "</option>\n";83 $select_cat .= '<option value="' . $cat->cat_ID . '"' . (($cat->cat_ID == $cat_id) ? " selected='selected'" : '') . '>' . wp_specialchars(apply_filters('link_category', $cat->cat_name)) . "</option>\n"; 84 84 $select_cat .= "</select>\n"; 85 85 … … 132 132 <?php 133 133 foreach ($links as $link) { 134 $link->link_name = attribute_escape( $link->link_name);135 $link->link_description = wp_specialchars( $link->link_description);134 $link->link_name = attribute_escape(apply_filters('link_title', $link->link_name)); 135 $link->link_description = wp_specialchars(apply_filters('link_description', $link->link_description)); 136 136 $link->link_url = clean_url($link->link_url); 137 137 $link->link_category = wp_get_link_cats($link->link_id); … … 161 161 foreach ($link->link_category as $category) { 162 162 $cat_name = get_the_category_by_ID($category); 163 $cat_name = wp_specialchars( $cat_name);163 $cat_name = wp_specialchars(apply_filters('link_category', $cat_name)); 164 164 if ( $cat_id != $category ) 165 165 $cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>"; … … 181 181 default: 182 182 ?> 183 <td><?php do_action('manage_link_custom_column', $column_name, $ id); ?></td>183 <td><?php do_action('manage_link_custom_column', $column_name, $link->link_id); ?></td> 184 184 <?php 185 185 break; -
tags/2.2/wp-admin/menu.php
r5468 r5480 7 7 $menu[0] = array(__('Dashboard'), 'read', 'index.php'); 8 8 9 if ( strstr($_SERVER['REQUEST_URI'], 'edit-pages.php'))9 if (strpos($_SERVER['REQUEST_URI'], 'edit-pages.php') !== false) 10 10 $menu[5] = array(__('Write'), 'edit_pages', 'page-new.php'); 11 11 else 12 12 $menu[5] = array(__('Write'), 'edit_posts', 'post-new.php'); 13 if ( strstr($_SERVER['REQUEST_URI'], 'page-new.php'))13 if (strpos($_SERVER['REQUEST_URI'], 'page-new.php') !== false) 14 14 $menu[10] = array(__('Manage'), 'edit_pages', 'edit-pages.php'); 15 15 else 16 16 $menu[10] = array(__('Manage'), 'edit_posts', 'edit.php'); 17 17 18 18 $menu[15] = array(__('Comments'), 'edit_posts', 'edit-comments.php'); 19 19 $menu[20] = array(__('Blogroll'), 'manage_links', 'link-manager.php'); … … 70 70 $submenu['themes.php'][10] = array(__('Theme Editor'), 'edit_themes', 'theme-editor.php'); 71 71 72 do_action('_admin_menu'); 73 72 74 // Create list of page plugin hook names. 73 75 foreach ($menu as $menu_page) { … … 105 107 $_wp_real_parent_file[$old_parent] = $new_parent; 106 108 $menu[$id][2] = $new_parent; 107 109 108 110 foreach ($submenu[$old_parent] as $index => $data) { 109 111 $submenu[$new_parent][$index] = $submenu[$old_parent][$index]; -
tags/2.2/wp-admin/moderation.php
r5468 r5480 122 122 <p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p> 123 123 <?php comment_text() ?> 124 <p><?php comment_date( 'M j, g:i A'); ?> — [ <?php124 <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 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> | "; ?> -
tags/2.2/wp-admin/options-general.php
r5468 r5480 26 26 <tr valign="top"> 27 27 <th scope="row"><?php _e('WordPress address (URL):') ?></th> 28 <td><input name="siteurl" type="text" id="siteurl" value="<?php form_option('siteurl'); ?>" size="40" class="code "/></td>28 <td><input name="siteurl" type="text" id="siteurl" value="<?php form_option('siteurl'); ?>" size="40" class="code<?php if ( defined( 'WP_SITEURL' ) ) : ?> disabled" disabled="disabled"<?php else: ?>"<?php endif; ?> /></td> 29 29 </tr> 30 30 <tr valign="top"> 31 31 <th scope="row"><?php _e('Blog address (URL):') ?></th> 32 <td><input name="home" type="text" id="home" value="<?php form_option('home'); ?>" size="40" class="code " /><br /><?php _e('If you want your blog homepage <a href="http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">to be different than the directory</a> you installed WordPress in, enter that address here.'); ?></td>32 <td><input name="home" type="text" id="home" value="<?php form_option('home'); ?>" size="40" class="code<?php if ( defined( 'WP_HOME' ) ) : ?> disabled" disabled="disabled"<?php else: ?>"<?php endif; ?> /><br /><?php _e('Enter the address here if you want your blog homepage <a href="http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">to be different from the directory</a> you installed WordPress.'); ?></td> 33 33 </tr> 34 34 <tr valign="top"> … … 98 98 <p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" /> 99 99 <input type="hidden" name="action" value="update" /> 100 <input type="hidden" name="page_options" value=" blogname,blogdescription,siteurl,admin_email,users_can_register,gmt_offset,date_format,time_format,home,start_of_week,comment_registration,default_role" />100 <input type="hidden" name="page_options" value="<?php if ( ! defined( 'WP_SITEURL' ) ) echo 'siteurl,'; if ( ! defined( 'WP_HOME' ) ) echo 'home,'; ?>blogname,blogdescription,admin_email,users_can_register,gmt_offset,date_format,time_format,start_of_week,comment_registration,default_role" /> 101 101 </p> 102 102 </form> -
tags/2.2/wp-admin/options-head.php
r5468 r5480 1 1 <?php wp_reset_vars(array('action', 'standalone', 'option_group_id')); ?> 2 3 <br clear="all" />4 2 5 3 <?php if (isset($_GET['updated'])) : ?> -
tags/2.2/wp-admin/options-misc.php
r5468 r5480 37 37 38 38 <p><input name="use_linksupdate" type="checkbox" id="use_linksupdate" value="1" <?php checked('1', get_option('use_linksupdate')); ?> /> 39 <label for="use_linksupdate"><?php _e('Track Bookmarks’ Update Times') ?></label></p>39 <label for="use_linksupdate"><?php _e('Track Links’ Update Times') ?></label></p> 40 40 <p> 41 41 <label><input type="checkbox" name="hack_file" value="1" <?php checked('1', get_option('hack_file')); ?> /> <?php _e('Use legacy <code>my-hacks.php</code> file support') ?></label> -
tags/2.2/wp-admin/options-writing.php
r5468 r5480 42 42 </tr> 43 43 <tr valign="top"> 44 <th scope="row"><?php _e('Default bookmark category:') ?></th>44 <th scope="row"><?php _e('Default link category:') ?></th> 45 45 <td><select name="default_link_category" id="default_link_category"> 46 46 <?php … … 104 104 <?php else : ?> 105 105 106 <p><?php printf(__('WordPress is not notifying any <a href="http://codex.wordpress.org/Update_Services">Update Services</a> because of your blog\'s <a href="%s">privacy settings</a> '), 'options-privacy.php'); ?>106 <p><?php printf(__('WordPress is not notifying any <a href="http://codex.wordpress.org/Update_Services">Update Services</a> because of your blog\'s <a href="%s">privacy settings</a>.'), 'options-privacy.php'); ?> 107 107 108 108 <?php endif; ?> -
tags/2.2/wp-admin/options.php
r5468 r5480 79 79 } 80 80 81 return $value; 81 return $value; 82 82 } 83 83 … … 149 149 <td>"; 150 150 151 if (str istr($value, "\n")) echo "<textarea class='$class' name='$option->option_name' id='$option->option_name' cols='30' rows='5'>$value</textarea>";151 if (strpos($value, "\n") !== false) echo "<textarea class='$class' name='$option->option_name' id='$option->option_name' cols='30' rows='5'>$value</textarea>"; 152 152 else echo "<input class='$class' type='text' name='$option->option_name' id='$option->option_name' size='30' value='" . $value . "'$disabled />"; 153 153 154 154 echo "</td> 155 155 <td>$option->option_description</td> -
tags/2.2/wp-admin/page-new.php
r5468 r5480 5 5 $editing = true; 6 6 wp_enqueue_script('prototype'); 7 wp_enqueue_script('interface'); 7 8 wp_enqueue_script('autosave'); 8 9 require_once('admin-header.php'); -
tags/2.2/wp-admin/page.php
r5468 r5480 53 53 if($post->post_status == 'draft') { 54 54 wp_enqueue_script('prototype'); 55 wp_enqueue_script('interface'); 55 56 wp_enqueue_script('autosave'); 56 57 } … … 61 62 62 63 include('edit-page-form.php'); 63 ?>64 <div id='preview' class='wrap'>65 <h2 id="preview-post"><?php _e('Page Preview (updated when page is saved)'); ?></h2>66 <iframe src="<?php echo clean_url(apply_filters('preview_page_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" width="100%" height="600" ></iframe>67 </div>68 <?php69 64 break; 70 65 … … 107 102 108 103 if ( isset($_POST['save']) ) 109 $location = "page.php?action=edit&post=$page_ID"; 104 $location = "page.php?action=edit&post=$page_ID"; 110 105 } else { 111 106 if ($_POST['save']) { … … 148 143 149 144 $sendback = wp_get_referer(); 150 if (str str($sendback, 'page.php')) $sendback = get_option('siteurl') .'/wp-admin/page.php';151 elseif (str str($sendback, 'attachments.php')) $sendback = get_option('siteurl') .'/wp-admin/attachments.php';145 if (strpos($sendback, 'page.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/page.php'; 146 elseif (strpos($sendback, 'attachments.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/attachments.php'; 152 147 $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); 153 148 wp_redirect($sendback); -
tags/2.2/wp-admin/plugin-editor.php
r5468 r5480 31 31 fwrite($f, $newcontent); 32 32 fclose($f); 33 34 // Deactivate so we can test it. 35 $current = get_option('active_plugins'); 36 if ( in_array($file, $current) || isset($_POST['phperror']) ) { 37 if ( in_array($file, $current) ) { 38 array_splice($current, array_search( $file, $current), 1 ); // Array-fu! 39 update_option('active_plugins', $current); 40 } 41 wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1")); 42 exit(); 43 } 33 44 wp_redirect("plugin-editor.php?file=$file&a=te"); 34 45 } else { … … 44 55 if ( !current_user_can('edit_plugins') ) 45 56 wp_die('<p>'.__('You do not have sufficient permissions to edit plugins for this blog.').'</p>'); 57 58 if ( $_GET['liveupdate'] ) { 59 check_admin_referer('edit-plugin-test_' . $file); 60 $current = get_option('active_plugins'); 61 $plugin = $file; 62 if ( validate_file($plugin) ) 63 wp_die(__('Invalid plugin.')); 64 if ( ! file_exists(ABSPATH . PLUGINDIR . '/' . $plugin) ) 65 wp_die(__('Plugin file does not exist.')); 66 if (!in_array($plugin, $current)) { 67 wp_redirect("plugin-editor.php?file=$file&phperror=1"); // we'll override this later if the plugin can be included without fatal error 68 @include(ABSPATH . PLUGINDIR . '/' . $plugin); 69 $current[] = $plugin; 70 sort($current); 71 update_option('active_plugins', $current); 72 } 73 wp_redirect("plugin-editor.php?file=$file&a=te"); 74 } 46 75 47 76 require_once('admin-header.php'); … … 61 90 <?php if (isset($_GET['a'])) : ?> 62 91 <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div> 92 <?php elseif (isset($_GET['phperror'])) : ?> 93 <div id="message" class="updated fade"><p><?php _e('This plugin has been deactivated because your changes resulted in a <strong>fatal error</strong>.') ?></p></div> 63 94 <?php endif; ?> 64 95 <div class="wrap"> 65 96 <?php 66 if (is_writeable($real_file)) { 67 echo '<h2>' . sprintf(__('Editing <strong>%s</strong>'), $file) . '</h2>'; 97 if ( in_array($file, (array) get_option('active_plugins')) ) { 98 if (is_writeable($real_file)) { 99 echo '<h2>' . sprintf(__('Editing <strong>%s</strong> (active)'), $file) . '</h2>'; 100 } else { 101 echo '<h2>' . sprintf(__('Browsing <strong>%s</strong> (active)'), $file) . '</h2>'; 102 } 68 103 } else { 69 echo '<h2>' . sprintf(__('Browsing <strong>%s</strong>'), $file) . '</h2>'; 104 if (is_writeable($real_file)) { 105 echo '<h2>' . sprintf(__('Editing <strong>%s</strong> (inactive)'), $file) . '</h2>'; 106 } else { 107 echo '<h2>' . sprintf(__('Browsing <strong>%s</strong> (inactive)'), $file) . '</h2>'; 108 } 70 109 } 71 110 ?> … … 91 130 </div> 92 131 <?php if ( is_writeable($real_file) ) : ?> 132 <?php if ( in_array($file, (array) get_option('active_plugins')) ) { ?> 133 <p><?php _e('<strong>Warning:</strong> Making changes to active plugins is not recommended. If your changes cause a fatal error, the plugin will be automatically deactivated.'); ?></p> 134 <?php } ?> 93 135 <p class="submit"> 94 136 <?php 95 echo "<input type='submit' name='submit' value=' " . __('Update File »') . "' tabindex='2' />"; 137 if ( isset($_GET['phperror']) ) 138 echo "<input type='hidden' name='phperror' value='1' /><input type='submit' name='submit' value='" . __('Update File and Attempt to Reactivate »') . "' tabindex='2' />"; 139 else 140 echo "<input type='submit' name='submit' value='" . __('Update File »') . "' tabindex='2' />"; 96 141 ?> 97 142 </p> -
tags/2.2/wp-admin/plugins.php
r5468 r5480 12 12 wp_die(__('Plugin file does not exist.')); 13 13 if (!in_array($plugin, $current)) { 14 wp_redirect('plugins.php?error=true'); // we'll override this later if the plugin can be included without fatal error 15 ob_start(); 16 @include(ABSPATH . PLUGINDIR . '/' . $plugin); 14 17 $current[] = $plugin; 15 18 sort($current); 16 19 update_option('active_plugins', $current); 17 include(ABSPATH . PLUGINDIR . '/' . $plugin);18 20 do_action('activate_' . $plugin); 21 ob_end_clean(); 19 22 } 20 wp_redirect('plugins.php?activate=true'); 23 wp_redirect('plugins.php?activate=true'); // overrides the ?error=true one above 21 24 } else if ('deactivate' == $_GET['action']) { 22 25 check_admin_referer('deactivate-plugin_' . $_GET['plugin']); … … 26 29 do_action('deactivate_' . trim( $_GET['plugin'] )); 27 30 wp_redirect('plugins.php?deactivate=true'); 31 } elseif ($_GET['action'] == 'deactivate-all') { 32 check_admin_referer('deactivate-all'); 33 $current = get_option('active_plugins'); 34 35 foreach ($current as $plugin) { 36 array_splice($current, array_search($plugin, $current), 1); 37 do_action('deactivate_' . $plugin); 38 } 39 40 update_option('active_plugins', array()); 41 wp_redirect('plugins.php?deactivate-all=true'); 28 42 } 29 43 exit; … … 59 73 ?> 60 74 61 <?php if (isset($_GET['activate'])) : ?> 62 <div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p> 63 </div> 64 <?php endif; ?> 65 <?php if (isset($_GET['deactivate'])) : ?> 66 <div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p> 67 </div> 75 <?php if ( isset($_GET['error']) ) : ?> 76 <div id="message" class="updated fade"><p><?php _e('Plugin could not be activated because it triggered a <strong>fatal error</strong>.') ?></p></div> 77 <?php elseif ( isset($_GET['activate']) ) : ?> 78 <div id="message" class="updated fade"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div> 79 <?php elseif ( isset($_GET['deactivate']) ) : ?> 80 <div id="message" class="updated fade"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div> 81 <?php elseif (isset($_GET['deactivate-all'])) : ?> 82 <div id="message" class="updated fade"><p><?php _e('All plugins <strong>deactivated</strong>.'); ?></p></div> 68 83 <?php endif; ?> 69 84 … … 117 132 if ( $style != '' ) 118 133 $style = 'class="' . $style . '"'; 119 if ( is_writable(ABSPATH . 'wp-content/plugins/' . $plugin_file) )134 if ( is_writable(ABSPATH . PLUGINDIR . '/' . $plugin_file) ) 120 135 $edit = "<a href='plugin-editor.php?file=$plugin_file' title='".__('Open this file in the Plugin Editor')."' class='edit'>".__('Edit')."</a>"; 121 136 else … … 136 151 ?> 137 152 153 <tr> 154 <td colspan="3"> </td> 155 <td colspan="2" style="width:12em;"><a href="<?php echo wp_nonce_url('plugins.php?action=deactivate-all', 'deactivate-all'); ?>" class="delete"><?php _e('Deactivate All Plugins'); ?></a></td> 156 </tr> 157 138 158 </table> 139 159 <?php -
tags/2.2/wp-admin/post-new.php
r5468 r5480 5 5 $editing = true; 6 6 wp_enqueue_script('prototype'); 7 wp_enqueue_script('interface'); 7 8 wp_enqueue_script('autosave'); 8 9 require_once ('./admin-header.php'); -
tags/2.2/wp-admin/post.php
r5468 r5480 48 48 $post_ID = $p = (int) $_GET['post']; 49 49 $post = get_post($post_ID); 50 50 51 51 if ( 'page' == $post->post_type ) { 52 52 wp_redirect("page.php?action=edit&post=$post_ID"); … … 67 67 include('edit-form-advanced.php'); 68 68 69 ?>70 <div id='preview' class='wrap'>71 <h2 id="preview-post"><?php _e('Post Preview (updated when post is saved)'); ?></h2>72 <iframe src="<?php echo clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" width="100%" height="600" ></iframe>73 </div>74 <?php75 69 break; 76 70 … … 120 114 $referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']); 121 115 $referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer()); 122 116 123 117 if ($_POST['save']) { 124 118 $location = "post.php?action=edit&post=$post_ID"; … … 161 155 162 156 $sendback = wp_get_referer(); 163 if (str str($sendback, 'post.php')) $sendback = get_option('siteurl') .'/wp-admin/post-new.php';164 elseif (str str($sendback, 'attachments.php')) $sendback = get_option('siteurl') .'/wp-admin/attachments.php';157 if (strpos($sendback, 'post.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/post-new.php'; 158 elseif (strpos($sendback, 'attachments.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/attachments.php'; 165 159 $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); 166 160 wp_redirect($sendback); -
tags/2.2/wp-admin/rtl.css
r5468 r5480 15 15 #wphead h1 { font-size: 2.4em; } 16 16 17 #postdiv , #titlediv, #guiddiv { margin: 0 0 0 8px; }17 #postdiv, #titlediv, #guiddiv, #tagdiv { margin: 0 0 0 8px; } 18 18 19 19 #ed_toolbar input { margin: 3px 0 2px 2px; } … … 43 43 #adminmenu { 44 44 padding: .2em 2em .3em .2em; 45 height: 30px; 46 } 45 height: 28px; 46 } 47 48 #adminmenu li { line-height: 160%; } 47 49 48 50 #adminmenu a { … … 57 59 } 58 60 59 #adminmenu li { line-height: 180%; } 60 61 #submenu, #minisub { padding: 3px 3em 0 2em; } 61 #submenu, #minisub { padding: 1px 3em 0 2em; } 62 63 #submenu { height: 28px; } 64 65 #submenu li { line-height: 160%; } 66 67 #submenu a { 68 margin: 0 0 0 10px; 69 display: block; 70 float: right; 71 } 62 72 63 73 #submenu .current { … … 66 76 } 67 77 68 #submenu a {69 padding: .3em .4em .4em .4em;70 margin: 0 0 0 10px;71 display: block;72 float: right;73 }74 75 #submenu li { line-height: 120%; }76 77 78 #currenttheme img { 78 79 float: right; … … 91 92 } 92 93 93 * html #postexcerpt .dbx-toggle-open, * html #postexcerpt .dbx-toggle-open, #postexcerpt div, #attachmentlinks div { 94 #postexcerpt div, #attachmentlinks div { 95 margin-right: auto; 96 margin-left: 8px; 97 } 98 99 * html #postexcerpt .dbx-toggle-open { 94 100 padding-right: 0; 95 101 padding-left: 8px; … … 191 197 margin-left: 3px; 192 198 } 199 200 a.view-link { 201 right:auto; 202 left:5%; 203 margin-right:0; 204 margin-left:220px; 205 } -
tags/2.2/wp-admin/setup-config.php
r5468 r5480 158 158 switch (substr($line,0,16)) { 159 159 case "define('DB_NAME'": 160 fwrite($handle, str_replace(" wordpress", $dbname, $line));160 fwrite($handle, str_replace("putyourdbnamehere", $dbname, $line)); 161 161 break; 162 162 case "define('DB_USER'": 163 fwrite($handle, str_replace("'username '", "'$uname'", $line));163 fwrite($handle, str_replace("'usernamehere'", "'$uname'", $line)); 164 164 break; 165 165 case "define('DB_PASSW": 166 fwrite($handle, str_replace("' password'", "'$passwrd'", $line));166 fwrite($handle, str_replace("'yourpasswordhere'", "'$passwrd'", $line)); 167 167 break; 168 168 case "define('DB_HOST'": -
tags/2.2/wp-admin/templates.php
r5468 r5480 53 53 wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>'); 54 54 55 if ( strstr( $file, 'wp-config.php' ))55 if (strpos($file, 'wp-config.php') !== false) 56 56 wp_die('<p>'.__('The config file cannot be edited or viewed through the web interface. Sorry!').'</p>'); 57 57 -
tags/2.2/wp-admin/themes.php
r5468 r5480 27 27 <div id="message1" class="updated fade"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div> 28 28 <?php elseif ( isset($_GET['activated']) ) : ?> 29 <div id="message2" class="updated fade"><p><?php printf(__('New theme activated. <a href="%s">View site »</a>'), get_bloginfo(' home') . '/'); ?></p></div>29 <div id="message2" class="updated fade"><p><?php printf(__('New theme activated. <a href="%s">View site »</a>'), get_bloginfo('url') . '/'); ?></p></div> 30 30 <?php endif; ?> 31 31 -
tags/2.2/wp-admin/upgrade-functions.php
r5468 r5480 22 22 update_option('blog_public', $public); 23 23 $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://'; 24 $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); 24 25 if ( defined('WP_SITEURL') && '' != WP_SITEURL ) 26 $guessurl = WP_SITEURL; 27 else 28 $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); 29 25 30 update_option('siteurl', $guessurl); 26 31 … … 171 176 upgrade_130(); 172 177 } 178 179 maybe_disable_automattic_widgets(); 173 180 174 181 if ( $wp_current_db_version < 3308 ) … … 653 660 function __get_option($setting) { 654 661 global $wpdb; 655 662 663 if ( $setting == 'home' && defined( 'WP_HOME' ) ) { 664 return preg_replace( '|/+$|', '', constant( 'WP_HOME' ) ); 665 } 666 667 if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) { 668 return preg_replace( '|/+$|', '', constant( 'WP_SITEURL' ) ); 669 } 670 656 671 $option = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting'"); 657 672 … … 923 938 if ($oldfile == 'index.php') { // Check to make sure it's not a new index 924 939 $index = implode('', file("$oldpath/$oldfile")); 925 if ( strstr( $index, 'WP_USE_THEMES' )) {940 if (strpos($index, 'WP_USE_THEMES') !== false) { 926 941 if (! @copy(ABSPATH . 'wp-content/themes/default/index.php', "$site_dir/$newfile")) 927 942 return false; … … 995 1010 996 1011 foreach ($stylelines as $line) { 997 if (str str($line, "Theme Name:")) $line = "Theme Name: $theme_name";998 elseif (str str($line, "Theme URI:")) $line = "Theme URI: " . __get_option('siteurl');999 elseif (str str($line, "Description:")) $line = "Description: Your theme";1000 elseif (str str($line, "Version:")) $line = "Version: 1";1001 elseif (str str($line, "Author:")) $line = "Author: You";1002 fwrite($f, "{$line}\n");1012 if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: ' . $theme_name; 1013 elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: ' . __get_option('url'); 1014 elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.'; 1015 elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1'; 1016 elseif (strpos($line, 'Author:') !== false) $line = 'Author: You'; 1017 fwrite($f, $line . "\n"); 1003 1018 } 1004 1019 fclose($f); … … 1095 1110 } 1096 1111 1112 function maybe_disable_automattic_widgets() { 1113 $plugins = __get_option( 'active_plugins' ); 1114 1115 foreach ( (array) $plugins as $plugin ) { 1116 if ( basename( $plugin ) == 'widgets.php' ) { 1117 array_splice( $plugins, array_search( $plugin, $plugins ), 1 ); 1118 update_option( 'active_plugins', $plugins ); 1119 break; 1120 } 1121 } 1122 } 1123 1097 1124 ?> -
tags/2.2/wp-admin/upgrade-schema.php
r5468 r5480 1 1 <?php 2 2 // Here we keep the DB structure and option values 3 4 $charset_collate = ''; 5 6 if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) { 7 if ( ! empty($wpdb->charset) ) 8 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 9 if ( ! empty($wpdb->collate) ) 10 $charset_collate .= " COLLATE $wpdb->collate"; 11 } 3 12 4 13 $wp_queries="CREATE TABLE $wpdb->categories ( … … 14 23 PRIMARY KEY (cat_ID), 15 24 KEY category_nicename (category_nicename) 16 ) ;25 ) $charset_collate; 17 26 CREATE TABLE $wpdb->comments ( 18 27 comment_ID bigint(20) unsigned NOT NULL auto_increment, … … 34 43 KEY comment_approved (comment_approved), 35 44 KEY comment_post_ID (comment_post_ID) 36 ) ;45 ) $charset_collate; 37 46 CREATE TABLE $wpdb->link2cat ( 38 47 rel_id bigint(20) NOT NULL auto_increment, … … 41 50 PRIMARY KEY (rel_id), 42 51 KEY link_id (link_id,category_id) 43 ) ;52 ) $charset_collate; 44 53 CREATE TABLE $wpdb->links ( 45 54 link_id bigint(20) NOT NULL auto_increment, … … 60 69 KEY link_category (link_category), 61 70 KEY link_visible (link_visible) 62 ) ;71 ) $charset_collate; 63 72 CREATE TABLE $wpdb->options ( 64 73 option_id bigint(20) NOT NULL auto_increment, … … 75 84 PRIMARY KEY (option_id,blog_id,option_name), 76 85 KEY option_name (option_name) 77 ) ;86 ) $charset_collate; 78 87 CREATE TABLE $wpdb->post2cat ( 79 88 rel_id bigint(20) NOT NULL auto_increment, … … 82 91 PRIMARY KEY (rel_id), 83 92 KEY post_id (post_id,category_id) 84 ) ;93 ) $charset_collate; 85 94 CREATE TABLE $wpdb->postmeta ( 86 95 meta_id bigint(20) NOT NULL auto_increment, … … 91 100 KEY post_id (post_id), 92 101 KEY meta_key (meta_key) 93 ) ;102 ) $charset_collate; 94 103 CREATE TABLE $wpdb->posts ( 95 104 ID bigint(20) unsigned NOT NULL auto_increment, … … 120 129 KEY post_name (post_name), 121 130 KEY type_status_date (post_type,post_status,post_date,ID) 122 ) ;131 ) $charset_collate; 123 132 CREATE TABLE $wpdb->users ( 124 133 ID bigint(20) unsigned NOT NULL auto_increment, … … 134 143 PRIMARY KEY (ID), 135 144 KEY user_login_key (user_login) 136 ) ;145 ) $charset_collate; 137 146 CREATE TABLE $wpdb->usermeta ( 138 147 umeta_id bigint(20) NOT NULL auto_increment, … … 143 152 KEY user_id (user_id), 144 153 KEY meta_key (meta_key) 145 ) ;";154 ) $charset_collate;"; 146 155 147 156 function populate_options() { -
tags/2.2/wp-admin/upgrade.php
r5468 r5480 9 9 10 10 if (isset($_GET['step'])) 11 $step = $_GET['step'];11 $step = (int) $_GET['step']; 12 12 else 13 13 $step = 0; … … 26 26 <body> 27 27 <h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1> 28 <?php 29 switch($step) { 28 29 <?php if ( get_option('db_version') == $wp_db_version ) : ?> 30 31 <h2><?php _e('No Upgrade Required'); ?></h2> 32 <p><?php _e('Your WordPress database is already up-to-date!'); ?></p> 33 <h2 class="step"><a href="<?php echo get_option('home'); ?>/"><?php _e('Continue »'); ?></a></h2> 34 35 <?php else : 36 switch($step) : 30 37 case 0: 31 38 $goback = clean_url(stripslashes(wp_get_referer())); 32 ?> 33 <p><?php _e('This file upgrades you from any previous version of WordPress to the latest. It may take a while though, so be patient.'); ?></p> 39 ?> 40 <h2><?php _e('Database Upgrade Required'); ?></h2> 41 <p><?php _e('Your WordPress database is out-of-date, and must be upgraded before you can continue.'); ?></p> 42 <p><?php _e('The upgrade process may take a while, so please be patient.'); ?></p> 34 43 <h2 class="step"><a href="upgrade.php?step=1&backto=<?php echo $goback; ?>"><?php _e('Upgrade WordPress »'); ?></a></h2> 35 44 <?php … … 39 48 40 49 if ( empty( $_GET['backto'] ) ) 41 $backto = __get_option('home') ;50 $backto = __get_option('home') . '/'; 42 51 else 43 52 $backto = clean_url(stripslashes($_GET['backto'])); 44 53 ?> 45 <h2><?php _e('Step 1'); ?></h2> 46 <p><?php printf(__("There's actually only one step. So if you see this, you're done. <a href='%s'>Have fun</a>!"), $backto); ?></p> 54 <h2><?php _e('Upgrade Complete'); ?></h2> 55 <p><?php _e('Your WordPress database has been successfully upgraded!'); ?></p> 56 <h2 class="step"><a href="<?php echo $backto; ?>"><?php _e('Continue »'); ?></a></h2> 47 57 48 58 <!-- … … 56 66 <?php 57 67 break; 58 } 68 endswitch; 69 endif; 59 70 ?> 60 71 </body> -
tags/2.2/wp-admin/upload-functions.php
r5468 r5480 14 14 if ( isset($attachment_data['width']) ) 15 15 list($width,$height) = wp_shrink_dimensions($attachment_data['width'], $attachment_data['height'], 171, 128); 16 16 17 17 ob_start(); 18 18 the_title(); 19 19 $post_title = attribute_escape(ob_get_contents()); 20 20 ob_end_clean(); 21 $post_content = a pply_filters( 'content_edit_pre', $post->post_content);22 21 $post_content = attribute_escape(apply_filters( 'content_edit_pre', $post->post_content )); 22 23 23 $class = 'text'; 24 24 $innerHTML = get_attachment_innerHTML( $id, false, $dims ); … … 36 36 37 37 if ( $href ) 38 $r .= "<a id='file-link-$id' href=' " . clean_url($href) ."' title='$post_title' class='file-link $class'>\n";38 $r .= "<a id='file-link-$id' href='$href' title='$post_title' class='file-link $class'>\n"; 39 39 if ( $href || $image_src ) 40 40 $r .= "\t\t\t$innerHTML"; … … 286 286 global $wpdb, $action, $paged; 287 287 $old_vars = compact( 'paged' ); 288 288 289 289 switch ( $action ) : 290 290 case 'edit' : … … 356 356 } 357 357 } 358 359 ?> -
tags/2.2/wp-admin/upload.css
r5468 r5480 45 45 46 46 #upload-menu li #current-tab-nav { 47 background: #f9fcfe; 47 48 float: left; 48 49 padding: 5px 5px 0 0; -
tags/2.2/wp-admin/upload.php
r5468 r5480 90 90 $href = add_query_arg( array('tab' => $t, 'ID' => '', 'action' => '', 'paged' => '') ); 91 91 if ( isset($tab_array[4]) && is_array($tab_array[4]) ) 92 add_query_arg( $tab_array[4], $href );92 $href = add_query_arg( $tab_array[4], $href ); 93 93 $_href = clean_url( $href); 94 94 $page_links = ''; -
tags/2.2/wp-admin/user-edit.php
r5468 r5480 56 56 <p><strong><?php _e('User updated.') ?></strong></p> 57 57 <?php if ( $wp_http_referer ) : ?> 58 <p><a href=" <?php echo clean_url($wp_http_referer); ?>"><?php _e('« Back to Authors and Users'); ?></a></p>58 <p><a href="users.php"><?php _e('« Back to Authors and Users'); ?></a></p> 59 59 <?php endif; ?> 60 60 </div> … … 83 83 <input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" /> 84 84 </p> 85 86 <p><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', $profileuser->rich_editing); ?> /> <?php _e('Use the visual editor when writing'); ?></label></p> 87 88 <p class="submit"><input type="submit" value="<?php _e('Update User »'); ?>" name="submit" /></p> 85 89 86 90 <fieldset> -
tags/2.2/wp-admin/users.php
r5468 r5480 86 86 'total' => ceil($this->total_users_for_query / $this->users_per_page), 87 87 'current' => $this->page, 88 'prev_text' => '« Previous Page',89 'next_text' => 'Next Page »',88 'prev_text' => __('« Previous Page'), 89 'next_text' => __('Next Page »'), 90 90 'base' => 'users.php?%_%', 91 91 'format' => 'userspage=%#%', … … 339 339 340 340 <form action="" method="get" name="search" id="search"> 341 <p><input type="text" name="usersearch" id="usersearch" value="<?php echo attribute_escape($wp_user_search->search_term); ?>" /> <input type="submit" value="<?php _e('Search users »'); ?>" class="button" /></p>341 <p><input type="text" name="usersearch" id="usersearch" value="<?php echo attribute_escape($wp_user_search->search_term); ?>" /> <input type="submit" value="<?php _e('Search Users »'); ?>" class="button" /></p> 342 342 </form> 343 343 … … 451 451 <div class="narrow"> 452 452 453 <?php echo '<p>'.sprintf(__('Users can <a href="%1$s">register themselves</a> or you can manually create users here.'), get_option('siteurl').'/wp-register.php').'</p>'; ?> 453 <?php 454 if ( get_option('users_can_register') ) 455 echo '<p>' . sprintf(__('Users can <a href="%1$s">register themselves</a> or you can manually create users here.'), get_option('siteurl').'/wp-register.php') . '</p>'; 456 else 457 echo '<p>' . sprintf(__('Users cannot currently <a href="%1$s">register themselves</a>, but you can manually create users here.'), get_option('siteurl').'/wp-admin/options-general.php#users_can_register') . '</p>'; 458 ?> 454 459 <form action="#add-new-user" method="post" name="adduser" id="adduser"> 455 460 <?php wp_nonce_field('add-user') ?> -
tags/2.2/wp-admin/wp-admin.css
r5468 r5480 202 202 border: 1px solid #b2b2b2; 203 203 color: #000; 204 font: 204 font: 13px Verdana, Arial, Helvetica, sans-serif; 205 205 margin: 1px; 206 206 padding: 3px; … … 209 209 #uploading { 210 210 border-style: none; 211 padding: 0 px;211 padding: 0; 212 212 margin-bottom: 16px; 213 213 height: 18em; … … 293 293 } 294 294 295 .commentlist li li { 296 border-bottom: 0px; 297 padding: 0; 298 } 299 295 300 .commentlist p { 296 301 padding: 0; … … 460 465 } 461 466 462 463 467 #adminmenu .current, #submenu .current { 464 468 font-weight: bold; … … 485 489 list-style: none; 486 490 text-align: center; 491 white-space: nowrap; 487 492 } 488 493 … … 530 535 } 531 536 532 533 537 #categorydiv input, #poststatusdiv input, #commentstatusdiv input, #pingstatusdiv input { 534 538 border: none; … … 537 541 #postdiv, #titlediv, #guiddiv { 538 542 margin: 0 8px 0 0; 539 padding: 0 px;543 padding: 0; 540 544 } 541 545 542 546 #postdivrich { 543 margin: 0 px;544 padding: 0 px;547 margin: 0; 548 padding: 0; 545 549 } 546 550 547 551 #content { 548 margin: 0 0 0 0;552 margin: 0; 549 553 width: 100%; 550 554 } 551 555 552 556 #postdivrich #content { 553 padding: .7em;557 padding: 5px; 554 558 line-height: 140%; 555 559 } 556 560 557 561 #titlediv input, #guiddiv input { 558 margin: 0 px;562 margin: 0; 559 563 width: 100%; 560 564 } … … 580 584 #postdivrich #quicktags { 581 585 background: #f0f0ee; 582 padding: 0 px;586 padding: 0; 583 587 border: 1px solid #ccc; 584 588 border-bottom: none; … … 594 598 595 599 #quicktags #ed_toolbar { 596 padding: 0 px2px;600 padding: 0 2px; 597 601 } 598 602 599 603 #ed_toolbar input { 600 background: #fff url( images/fade-butt.png ) repeat-x 0 px-2px;604 background: #fff url( images/fade-butt.png ) repeat-x 0 -2px; 601 605 margin: 3px 2px 2px; 602 606 } … … 626 630 #title { 627 631 font-size: 1.7em; 628 padding: 4px ;632 padding: 4px 3px; 629 633 } 630 634 … … 644 648 645 649 #excerpt, .attachmentlinks { 646 margin: 0 px;650 margin: 0; 647 651 height: 4em; 648 652 width: 100%; … … 729 733 display: block; 730 734 border-bottom: none; 731 } 732 733 #login .hide { 734 display: none; 735 text-indent: -9999px; 735 736 } 736 737 … … 815 816 #postcustom table { 816 817 border: 1px solid #ccc; 817 margin: 0 px;818 margin: 0; 818 819 width: 100%; 819 820 } … … 836 837 837 838 * html #template div { 838 margin-right: 0 px;839 margin-right: 0; 839 840 } 840 841 … … 891 892 letter-spacing: -.05em; 892 893 margin: 0; 893 font-family: Georgia, "Times New Roman", Times, serif 894 font-family: Georgia, "Times New Roman", Times, serif; 894 895 } 895 896 … … 968 969 set display:none; */ 969 970 .zerosize { 970 height: 0 px;971 width: 0 px;972 margin: 0 px;973 border: 0 px;974 padding: 0 px;971 height: 0; 972 width: 0; 973 margin: 0; 974 border: 0; 975 padding: 0; 975 976 overflow: hidden; 976 977 position: absolute; … … 979 980 /* Box stuff */ 980 981 .dbx-clone { 981 position: absolute;982 visibility: hidden;982 position: absolute; 983 visibility: hidden; 983 984 } 984 985 .dbx-clone, .dbx-clone .dbx-handle-cursor { 985 cursor: move !important;986 cursor: move !important; 986 987 } 987 988 .dbx-dummy { 988 display: block;989 width: 0;990 height: 0;991 overflow: hidden;989 display: block; 990 width: 0; 991 height: 0; 992 overflow: hidden; 992 993 } 993 994 .dbx-group, .dbx-box, .dbx-handle { 994 position: relative;995 display: block;995 position: relative; 996 display: block; 996 997 } 997 998 … … 1001 1002 1002 1003 * html #themeselect { 1003 padding: 0 px3px;1004 padding: 0 3px; 1004 1005 height: 22px; 1005 1006 } … … 1011 1012 *****************************************************************/ 1012 1013 .dbx-box { 1013 margin: 0;1014 padding: 0;1015 border: none;1014 margin: 0; 1015 padding: 0; 1016 border: none; 1016 1017 } 1017 1018 … … 1021 1022 } 1022 1023 #moremeta fieldset div { 1023 margin: 2px 0 0 0 px;1024 margin: 2px 0 0 0; 1024 1025 padding: 7px; 1025 1026 } … … 1084 1085 } 1085 1086 1086 #your-profile fieldset input 1087 #your-profile fieldset input { 1087 1088 width: 100%; 1088 1089 font-size: 20px; … … 1123 1124 /* handles */ 1124 1125 1125 .dbx-handle 1126 .dbx-handle { 1126 1127 background: #2685af; 1127 1128 padding: 6px 1em 2px; … … 1158 1159 margin-left: 8px; 1159 1160 background: url(images/box-bg-right.gif) repeat-y right; 1160 padding: 10px 10px 15px 0 px;1161 padding: 10px 10px 15px 0; 1161 1162 } 1162 1163 … … 1191 1192 } 1192 1193 1193 1194 1194 /* handle cursors */ 1195 1195 .dbx-handle-cursor { … … 1199 1199 /* toggle images */ 1200 1200 a.dbx-toggle, a.dbx-toggle:visited { 1201 display: block;1201 display: block; 1202 1202 overflow: hidden; 1203 1203 background-image: url( images/toggle.gif ); 1204 1204 position: absolute; 1205 top: 0 px;1206 right: 0 px;1205 top: 0; 1206 right: 0; 1207 1207 background-repeat: no-repeat; 1208 border: 0 px;1209 margin: 0 px;1210 padding: 0 px;1208 border: 0; 1209 margin: 0; 1210 padding: 0; 1211 1211 } 1212 1212 … … 1214 1214 height: 25px; 1215 1215 width: 27px; 1216 background-position: 0 0 px;1216 background-position: 0 0; 1217 1217 } 1218 1218 … … 1297 1297 1298 1298 #edButtons input, #edButtons input:active { 1299 margin: 0 px2px -1px;1299 margin: 0 2px -1px; 1300 1300 } 1301 1301 … … 1306 1306 1307 1307 #edButtons input.edButtonBack, #edButtons input.edButtonBack:active { 1308 background: #fff url( images/fade-butt.png ) repeat-x 0 px15px;1308 background: #fff url( images/fade-butt.png ) repeat-x 0 15px; 1309 1309 border-bottom: 1px solid #ccc; 1310 1310 } … … 1333 1333 margin: 0 6px; 1334 1334 } 1335 1336 a.view-link { 1337 position: absolute; 1338 right: 5%; 1339 margin-right: 220px; 1340 text-decoration:underline; 1341 } -
tags/2.2/wp-atom.php
r5468 r5480 6 6 } 7 7 8 header('Content-type: application/atom+xml; charset=' . get_option('blog_charset'), true); 9 $more = 1; 8 require (ABSPATH . WPINC . '/feed-atom.php'); 10 9 11 10 ?> 12 <?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>13 <feed version="0.3"14 xmlns="http://purl.org/atom/ns#"15 xmlns:dc="http://purl.org/dc/elements/1.1/"16 xml:lang="<?php echo get_option('rss_language'); ?>"17 <?php do_action('atom_ns'); ?>18 >19 <title><?php bloginfo_rss('name') ?></title>20 <link rel="alternate" type="text/html" href="<?php bloginfo_rss('home') ?>" />21 <tagline><?php bloginfo_rss("description") ?></tagline>22 <modified><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></modified>23 <copyright>Copyright <?php echo mysql2date('Y', get_lastpostdate('blog'), 0); ?></copyright>24 <generator url="http://wordpress.org/" version="<?php bloginfo_rss('version'); ?>">WordPress</generator>25 <?php do_action('atom_head'); ?>26 <?php while (have_posts()) : the_post(); ?>27 <entry>28 <author>29 <name><?php the_author() ?></name>30 </author>31 <title type="text/html" mode="escaped"><![CDATA[<?php the_title_rss() ?>]]></title>32 <link rel="alternate" type="text/html" href="<?php permalink_single_rss() ?>" />33 <id><?php the_guid(); ?></id>34 <modified><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></modified>35 <issued><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></issued>36 <?php the_category_rss('rdf') ?>37 <summary type="<?php bloginfo('html_type'); ?>" mode="escaped"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary>38 <?php if ( !get_option('rss_use_excerpt') ) : ?>39 <content type="<?php bloginfo('html_type'); ?>" mode="escaped" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_content('', 0, '') ?>]]></content>40 <?php endif; ?>41 <?php rss_enclosure(); ?>42 <?php do_action('atom_entry'); ?>43 </entry>44 <?php endwhile ; ?>45 </feed> -
tags/2.2/wp-blog-header.php
r5468 r5480 3 3 if (! isset($wp_did_header)): 4 4 if ( !file_exists( dirname(__FILE__) . '/wp-config.php') ) { 5 if ( strstr( $_SERVER['PHP_SELF'], 'wp-admin')) $path = '';5 if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $path = ''; 6 6 else $path = 'wp-admin/'; 7 7 8 require_once( dirname(__FILE__) . '/wp-includes/functions.php'); 9 wp_die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://codex.wordpress.org/Editing_wp-config.php'>We got it</a>. You can <a href='{$path}setup-config.php'>create a <code>wp-config.php</code> file through a web interface</a>, but this doesn't work for all server setups. The safest way is to manually create the file.", "WordPress › Error"); 8 require_once( dirname(__FILE__) . '/wp-includes/classes.php'); 9 require_once( dirname(__FILE__) . '/wp-includes/functions.php'); 10 require_once( dirname(__FILE__) . '/wp-includes/plugin.php'); 11 wp_die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://codex.wordpress.org/Editing_wp-config.php'>We got it</a>. You can <a href='{$path}setup-config.php'>create a <code>wp-config.php</code> file through a web interface</a>, but this doesn't work for all server setups. The safest way is to manually create the file.", "WordPress › Error"); 10 12 } 11 13 -
tags/2.2/wp-comments-post.php
r5468 r5480 1 1 <?php 2 if ($_SERVER["REQUEST_METHOD"] != "POST") { 3 header('Allow: POST'); 4 header("HTTP/1.1 405 Method Not Allowed"); 5 header("Content-type: text/plain"); 6 exit; 7 } 2 8 require( dirname(__FILE__) . '/wp-config.php' ); 3 9 … … 19 25 } 20 26 21 $comment_author = trim( $_POST['author']);27 $comment_author = trim(strip_tags($_POST['author'])); 22 28 $comment_author_email = trim($_POST['email']); 23 29 $comment_author_url = trim($_POST['url']); -
tags/2.2/wp-commentsrss2.php
r5468 r5480 6 6 } 7 7 8 header('Content-type: text/xml;charset=' . get_option('blog_charset'), true);8 require (ABSPATH . WPINC . '/feed-rss2-comments.php'); 9 9 10 echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';11 10 ?> 12 <!-- generator="wordpress/<?php echo $wp_version ?>" -->13 <rss version="2.0"14 xmlns:content="http://purl.org/rss/1.0/modules/content/">15 <channel>16 <?php17 $i = 0;18 if (have_posts()) :19 while (have_posts()) : the_post();20 if ($i < 1) {21 $i++;22 ?>23 <title><?php if (is_single() || is_page() ) { printf(__('Comments on: %s'), get_the_title_rss()); } else { printf(__('Comments for %s'), get_bloginfo_rss("name")); } ?></title>24 <link><?php (is_single()) ? permalink_single_rss() : bloginfo_rss("url") ?></link>25 <description><?php bloginfo_rss("description") ?></description>26 <pubDate><?php echo gmdate('r'); ?></pubDate>27 <generator>http://wordpress.org/?v=<?php echo $wp_version ?></generator>28 29 <?php30 if (is_single() || is_page()) {31 $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,32 comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,33 $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments34 LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '" . get_the_ID() . "'35 AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status = 'publish'36 AND post_date_gmt < '" . gmdate("Y-m-d H:i:59") . "'37 ORDER BY comment_date_gmt ASC" );38 } else { // if no post id passed in, we'll just ue the last 10 comments.39 $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,40 comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,41 $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments42 LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status = 'publish'43 AND $wpdb->comments.comment_approved = '1' AND post_date_gmt < '" . gmdate("Y-m-d H:i:s") . "'44 ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss') );45 }46 // this line is WordPress' motor, do not delete it.47 if ($comments) {48 foreach ($comments as $comment) {49 $GLOBALS['comment'] =& $comment;50 // Some plugins may need to know the metadata51 // associated with this comment's post:52 get_post_custom($comment->comment_post_ID);53 ?>54 <item>55 <title><?php if ( ! (is_single() || is_page()) ) {56 $title = get_the_title($comment->comment_post_ID);57 $title = apply_filters('the_title', $title);58 $title = apply_filters('the_title_rss', $title);59 printf(__('Comment on %1$s by %2$s'), $title, get_comment_author_rss());60 } else {61 printf(__('By: %s'), get_comment_author_rss());62 } ?></title>63 <link><?php comment_link() ?></link>64 <author><?php echo get_comment_author_rss() ?></author>65 <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true), false); ?></pubDate>66 <guid><?php comment_link() ?></guid>67 <?php68 if (!empty($comment->post_password) && $_COOKIE['wp-postpass'] != $comment->post_password) {69 ?>70 <description><?php _e('Protected Comments: Please enter your password to view comments.'); ?></description>71 <content:encoded><![CDATA[<?php echo get_the_password_form() ?>]]></content:encoded>72 <?php73 } else {74 ?>75 <description><?php comment_text_rss() ?></description>76 <content:encoded><![CDATA[<?php comment_text() ?>]]></content:encoded>77 <?php78 } // close check for password79 do_action('commentrss2_item', $comment->comment_ID, $comment->comment_post_ID);80 ?>81 </item>82 <?php83 }84 }85 }86 endwhile; endif;87 ?>88 </channel>89 </rss> -
tags/2.2/wp-config-sample.php
-
Property
svn:eol-style
changed from
native
toCRLF
r5468 r5480 1 1 <?php 2 2 // ** MySQL settings ** // 3 define('DB_NAME', ' wordpress'); // The name of the database4 define('DB_USER', 'username '); // Your MySQL username5 define('DB_PASSWORD', ' password'); // ...and password3 define('DB_NAME', 'putyourdbnamehere'); // The name of the database 4 define('DB_USER', 'usernamehere'); // Your MySQL username 5 define('DB_PASSWORD', 'yourpasswordhere'); // ...and password 6 6 define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value 7 define('DB_CHARSET', 'utf8'); 8 define('DB_COLLATE', ''); 7 9 8 10 // You can have multiple installations in one database if you give each a unique prefix … … 10 12 11 13 // Change this to localize WordPress. A corresponding MO file for the 12 // chosen language must be installed to wp- includes/languages.13 // For example, install de.mo to wp- includes/languages and set WPLANG to 'de'14 // chosen language must be installed to wp-content/languages. 15 // For example, install de.mo to wp-content/languages and set WPLANG to 'de' 14 16 // to enable German language support. 15 17 define ('WPLANG', ''); -
Property
svn:eol-style
changed from
-
tags/2.2/wp-content/index.php
-
Property
svn:eol-style
set to
native
-
Property
svn:eol-style
set to
-
tags/2.2/wp-content/themes/classic/comments-popup.php
r5468 r5480 22 22 <h2 id="comments"><?php _e("Comments"); ?></h2> 23 23 24 <p><a href="<?php echo get_ option('siteurl'); ?>/wp-commentsrss2.php?p=<?php echo $post->ID; ?>"><?php _e("<abbr title=\"Really Simple Syndication\">RSS</abbr> feed for comments on this post."); ?></a></p>24 <p><a href="<?php echo get_post_comments_feed_link($post->ID); ?>"><?php _e("<abbr title=\"Really Simple Syndication\">RSS</abbr> feed for comments on this post."); ?></a></p> 25 25 26 26 <?php if ('open' == $post->ping_status) { ?> … … 57 57 58 58 <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform"> 59 <?php if ( $user_ID ) : ?> 60 <p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">Logout »</a></p> 61 <?php else : ?> 59 62 <p> 60 63 <input type="text" name="author" id="author" class="textarea" value="<?php echo $comment_author; ?>" size="28" tabindex="1" /> … … 73 76 <label for="url"><?php _e("<abbr title=\"Universal Resource Locator\">URL</abbr>"); ?></label> 74 77 </p> 78 <?php endif; ?> 75 79 76 80 <p> -
tags/2.2/wp-content/themes/classic/sidebar.php
r5468 r5480 4 4 5 5 <ul> 6 <?php /* Widgetized sidebar, if you have the plugin installed. */ 7 if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?> 6 8 <?php wp_list_pages('title_li=' . __('Pages:')); ?> 7 9 <?php wp_list_bookmarks('title_after=&title_before='); ?> … … 33 35 </ul> 34 36 </li> 37 <?php endif; ?> 35 38 36 39 </ul> -
tags/2.2/wp-content/themes/default/archive.php
r5468 r5480 7 7 <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?> 8 8 <?php /* If this is a category archive */ if (is_category()) { ?> 9 <h2 class="pagetitle">Archive for the ‘<?php echosingle_cat_title(); ?>’ Category</h2>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()) { ?> -
tags/2.2/wp-content/themes/default/attachment.php
-
Property
svn:eol-style
set to
native
-
Property
svn:eol-style
set to
-
tags/2.2/wp-content/themes/default/comments-popup.php
r5468 r5480 22 22 <h2 id="comments">Comments</h2> 23 23 24 <p><a href="<?php echo get_ option('siteurl'); ?>/wp-commentsrss2.php?p=<?php echo $post->ID; ?>"><abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.</a></p>24 <p><a href="<?php echo get_post_comments_feed_link($post->ID); ?>"><abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.</a></p> 25 25 26 26 <?php if ('open' == $post->ping_status) { ?> … … 57 57 58 58 <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform"> 59 <?php if ( $user_ID ) : ?> 60 <p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">Logout »</a></p> 61 <?php else : ?> 59 62 <p> 60 63 <input type="text" name="author" id="author" class="textarea" value="<?php echo $comment_author; ?>" size="28" tabindex="1" /> … … 73 76 <label for="url"><abbr title="Universal Resource Locator">URL</abbr></label> 74 77 </p> 78 <?php endif; ?> 75 79 76 80 <p> -
tags/2.2/wp-content/themes/default/comments.php
r5468 r5480 7 7 ?> 8 8 9 <p class="nocomments">This post is password protected. Enter the password to view comments.< p>9 <p class="nocomments">This post is password protected. Enter the password to view comments.</p> 10 10 11 11 <?php … … 15 15 16 16 /* This variable is for alternating comment background */ 17 $oddcomment = ' alt';17 $oddcomment = 'class="alt" '; 18 18 ?> 19 19 … … 27 27 <?php foreach ($comments as $comment) : ?> 28 28 29 <li class="<?php echo $oddcomment; ?>"id="comment-<?php comment_ID() ?>">29 <li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>"> 30 30 <cite><?php comment_author_link() ?></cite> Says: 31 31 <?php if ($comment->comment_approved == '0') : ?> … … 34 34 <br /> 35 35 36 <small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?></a> <?php edit_comment_link('e ','',''); ?></small>36 <small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?></a> <?php edit_comment_link('edit',' ',''); ?></small> 37 37 38 38 <?php comment_text() ?> … … 40 40 </li> 41 41 42 <?php /* Changes every other comment to a different class */43 if ('alt' == $oddcomment) $oddcomment = '';44 else $oddcomment = 'alt';42 <?php 43 /* Changes every other comment to a different class */ 44 $oddcomment = ( empty( $oddcomment ) ) ? 'class="alt" ' : ''; 45 45 ?> 46 46 … … 89 89 <?php endif; ?> 90 90 91 <!--<p><small><strong>XHTML:</strong> You can use these tags: < ?php echo allowed_tags(); ?></small></p>-->91 <!--<p><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>--> 92 92 93 93 <p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p> -
tags/2.2/wp-content/themes/default/footer.php
r5468 r5480 2 2 <hr /> 3 3 <div id="footer"> 4 <!-- If you'd like to support WordPress, having the "powered by" link some one on your blog is the best way, it's our only promotion or advertising. -->4 <!-- If you'd like to support WordPress, having the "powered by" link somewhere on your blog is the best way, it's our only promotion or advertising. --> 5 5 <p> 6 6 <?php bloginfo('name'); ?> is proudly powered by -
tags/2.2/wp-content/themes/default/functions.php
r5468 r5480 1 1 <?php 2 if ( function_exists('register_sidebar') ) 3 register_sidebar(array( 4 'before_widget' => '<li id="%1$s" class="widget %2$s">', 5 'after_widget' => '</li>', 6 'before_title' => '<h2 class="widgettitle">', 7 'after_title' => '</h2>', 8 )); 2 9 3 10 function kubrick_head() { … … 26 33 27 34 function kubrick_upper_color() { 28 if ( strstr( $url = kubrick_header_image_url(), 'header-img.php?' )) {35 if (strpos($url = kubrick_header_image_url(), 'header-img.php?') !== false) { 29 36 parse_str(substr($url, strpos($url, '?') + 1), $q); 30 37 return $q['upper']; … … 34 41 35 42 function kubrick_lower_color() { 36 if ( strstr( $url = kubrick_header_image_url(), 'header-img.php?' )) {43 if (strpos($url = kubrick_header_image_url(), 'header-img.php?') !== false) { 37 44 parse_str(substr($url, strpos($url, '?') + 1), $q); 38 45 return $q['lower']; … … 76 83 if ( $_GET['page'] == basename(__FILE__) ) { 77 84 if ( 'save' == $_REQUEST['action'] ) { 85 check_admin_referer('kubrick-header'); 78 86 if ( isset($_REQUEST['njform']) ) { 79 87 if ( isset($_REQUEST['defaults']) ) { … … 84 92 if ( '' == $_REQUEST['njfontcolor'] ) 85 93 delete_option('kubrick_header_color'); 86 else 87 update_option('kubrick_header_color', $_REQUEST['njfontcolor']); 88 94 else { 95 $fontcolor = preg_replace('/^.*(#[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['njfontcolor']); 96 update_option('kubrick_header_color', $fontcolor); 97 } 89 98 if ( preg_match('/[0-9A-F]{6}|[0-9A-F]{3}/i', $_REQUEST['njuppercolor'], $uc) && preg_match('/[0-9A-F]{6}|[0-9A-F]{3}/i', $_REQUEST['njlowercolor'], $lc) ) { 90 99 $uc = ( strlen($uc[0]) == 3 ) ? $uc[0]{0}.$uc[0]{0}.$uc[0]{1}.$uc[0]{1}.$uc[0]{2}.$uc[0]{2} : $uc[0]; 91 100 $lc = ( strlen($lc[0]) == 3 ) ? $lc[0]{0}.$lc[0]{0}.$lc[0]{1}.$lc[0]{1}.$lc[0]{2}.$lc[0]{2} : $lc[0]; 92 update_option('kubrick_header_image', "header-img.php?upper=$uc& amp;lower=$lc");101 update_option('kubrick_header_image', "header-img.php?upper=$uc&lower=$lc"); 93 102 } 94 103 … … 103 112 104 113 if ( isset($_REQUEST['headerimage']) ) { 114 check_admin_referer('kubrick-header'); 105 115 if ( '' == $_REQUEST['headerimage'] ) 106 116 delete_option('kubrick_header_image'); 107 else 108 update_option('kubrick_header_image', $_REQUEST['headerimage']); 117 else { 118 $headerimage = preg_replace('/^.*?(header-img.php\?upper=[0-9a-fA-F]{6}&lower=[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['headerimage']); 119 update_option('kubrick_header_image', $headerimage); 120 } 109 121 } 110 122 111 123 if ( isset($_REQUEST['fontcolor']) ) { 124 check_admin_referer('kubrick-header'); 112 125 if ( '' == $_REQUEST['fontcolor'] ) 113 126 delete_option('kubrick_header_color'); 114 else 115 update_option('kubrick_header_color', $_REQUEST['fontcolor']); 127 else { 128 $fontcolor = preg_replace('/^.*?(#[0-9a-fA-F]{6})?.*$/', '$1', $_REQUEST['fontcolor']); 129 update_option('kubrick_header_color', $fontcolor); 130 } 116 131 } 117 132 118 133 if ( isset($_REQUEST['fontdisplay']) ) { 134 check_admin_referer('kubrick-header'); 119 135 if ( '' == $_REQUEST['fontdisplay'] || 'inline' == $_REQUEST['fontdisplay'] ) 120 136 delete_option('kubrick_header_display'); … … 129 145 add_action('admin_head', 'kubrick_theme_page_head'); 130 146 } 131 add_theme_page( 'Customize Header', 'Header Image and Color', 'edit_themes', basename(__FILE__), 'kubrick_theme_page');147 add_theme_page(__('Customize Header'), __('Header Image and Color'), 'edit_themes', basename(__FILE__), 'kubrick_theme_page'); 132 148 } 133 149 … … 142 158 } 143 159 function PopupWindow_populate(contents) { 144 contents += '<br /><p style="text-align:center;margin-top:0px;"><input type="button" value=" Close Color Picker" onclick="cp.hidePopup(\'prettyplease\')"></input></p>';160 contents += '<br /><p style="text-align:center;margin-top:0px;"><input type="button" value="<?php echo attribute_escape(__('Close Color Picker')); ?>" onclick="cp.hidePopup(\'prettyplease\')"></input></p>'; 145 161 this.contents = contents; 146 162 this.populated = false; … … 227 243 } 228 244 function kRevert() { 229 document.getElementById('headerimage').value = '<?php echo kubrick_header_image(); ?>';230 document.getElementById('advuppercolor').value = document.getElementById('uppercolor').value = '#<?php echo kubrick_upper_color(); ?>';231 document.getElementById('advlowercolor').value = document.getElementById('lowercolor').value = '#<?php echo kubrick_lower_color(); ?>';232 document.getElementById('header').style.background = 'url("<?php echo kubrick_header_image_url(); ?>") center no-repeat';245 document.getElementById('headerimage').value = '<?php echo js_escape(kubrick_header_image()); ?>'; 246 document.getElementById('advuppercolor').value = document.getElementById('uppercolor').value = '#<?php echo js_escape(kubrick_upper_color()); ?>'; 247 document.getElementById('advlowercolor').value = document.getElementById('lowercolor').value = '#<?php echo js_escape(kubrick_lower_color()); ?>'; 248 document.getElementById('header').style.background = 'url("<?php echo js_escape(kubrick_header_image_url()); ?>") center no-repeat'; 233 249 document.getElementById('header').style.color = ''; 234 document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value = '<?php echo kubrick_header_color_string(); ?>';235 document.getElementById('fontdisplay').value = '<?php echo kubrick_header_display_string(); ?>';250 document.getElementById('advfontcolor').value = document.getElementById('fontcolor').value = '<?php echo js_escape(kubrick_header_color_string()); ?>'; 251 document.getElementById('fontdisplay').value = '<?php echo js_escape(kubrick_header_display_string()); ?>'; 236 252 document.getElementById('headerimg').style.display = document.getElementById('fontdisplay').value; 237 253 } … … 339 355 340 356 function kubrick_theme_page() { 341 if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong> Options saved.</strong></p></div>';357 if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.__('Options saved.').'</strong></p></div>'; 342 358 ?> 343 359 <div class='wrap'> 344 360 <div id="kubrick-header"> 345 <h2>Header Image and Color</h2>361 <h2><?php _e('Header Image and Color'); ?></h2> 346 362 <div id="headwrap"> 347 363 <div id="header"> … … 355 371 <div id="nonJsForm"> 356 372 <form method="post" action=""> 357 <div class="zerosize"><input type="submit" name="defaultsubmit" value="Save" /></div> 358 <label for="njfontcolor">Font Color:</label><input type="text" name="njfontcolor" id="njfontcolor" value="<?php echo kubrick_header_color(); ?>" /> Any CSS color (<code>red</code> or <code>#FF0000</code> or <code>rgb(255, 0, 0)</code>)<br /> 359 <label for="njuppercolor">Upper Color:</label><input type="text" name="njuppercolor" id="njuppercolor" value="#<?php echo kubrick_upper_color(); ?>" /> HEX only (<code>#FF0000</code> or <code>#F00</code>)<br /> 360 <label for="njlowercolor">Lower Color:</label><input type="text" name="njlowercolor" id="njlowercolor" value="#<?php echo kubrick_lower_color(); ?>" /> HEX only (<code>#FF0000</code> or <code>#F00</code>)<br /> 361 <input type="hidden" name="hi" id="hi" value="<?php echo kubrick_header_image(); ?>" /> 362 <input type="submit" name="toggledisplay" id="toggledisplay" value="Toggle Text" /> 363 <input type="submit" name="defaults" value="Use Defaults" /> 364 <input type="submit" class="defbutton" name="submitform" value=" Save " /> 373 <?php wp_nonce_field('kubrick-header'); ?> 374 <div class="zerosize"><input type="submit" name="defaultsubmit" value="<?php echo attribute_escape(__('Save')); ?>" /></div> 375 <label for="njfontcolor"><?php _e('Font Color:'); ?></label><input type="text" name="njfontcolor" id="njfontcolor" value="<?php echo attribute_escape(kubrick_header_color()); ?>" /> <?php printf(__('Any CSS color (%s or %s or %s)'), '<code>red</code>', '<code>#FF0000</code>', '<code>rgb(255, 0, 0)</code>'); ?><br /> 376 <label for="njuppercolor"><?php _e('Upper Color:'); ?></label><input type="text" name="njuppercolor" id="njuppercolor" value="#<?php echo attribute_escape(kubrick_upper_color()); ?>" /> <?php printf(__('HEX only (%s or %s)'), '<code>#FF0000</code>', '<code>#F00</code>'); ?><br /> 377 <label for="njlowercolor"><?php _e('Lower Color:'); ?></label><input type="text" name="njlowercolor" id="njlowercolor" value="#<?php echo attribute_escape(kubrick_lower_color()); ?>" /> <?php printf(__('HEX only (%s or %s)'), '<code>#FF0000</code>', '<code>#F00</code>'); ?><br /> 378 <input type="hidden" name="hi" id="hi" value="<?php echo attribute_escape(kubrick_header_image()); ?>" /> 379 <input type="submit" name="toggledisplay" id="toggledisplay" value="<?php echo attribute_escape(__('Toggle Text')); ?>" /> 380 <input type="submit" name="defaults" value="<?php echo attribute_escape(__('Use Defaults')); ?>" /> 381 <input type="submit" class="defbutton" name="submitform" value=" <?php _e('Save'); ?> " /> 365 382 <input type="hidden" name="action" value="save" /> 366 383 <input type="hidden" name="njform" value="true" /> … … 369 386 <div id="jsForm"> 370 387 <form style="display:inline;" method="post" name="hicolor" id="hicolor" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> 371 <input type="button" onclick="tgt=document.getElementById('fontcolor');colorSelect(tgt,'pick1');return false;" name="pick1" id="pick1" value="Font Color"></input> 372 <input type="button" onclick="tgt=document.getElementById('uppercolor');colorSelect(tgt,'pick2');return false;" name="pick2" id="pick2" value="Upper Color"></input> 373 <input type="button" onclick="tgt=document.getElementById('lowercolor');colorSelect(tgt,'pick3');return false;" name="pick3" id="pick3" value="Lower Color"></input> 374 <input type="button" name="revert" value="Revert" onclick="kRevert()" /> 375 <input type="button" value="Advanced" onclick="toggleAdvanced()" /> 388 <?php wp_nonce_field('kubrick-header'); ?> 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> 390 <input type="button" onclick="tgt=document.getElementById('uppercolor');colorSelect(tgt,'pick2');return false;" name="pick2" id="pick2" value="<?php echo attribute_escape(__('Upper Color')); ?>"></input> 391 <input type="button" onclick="tgt=document.getElementById('lowercolor');colorSelect(tgt,'pick3');return false;" name="pick3" id="pick3" value="<?php echo attribute_escape(__('Lower Color')); ?>"></input> 392 <input type="button" name="revert" value="<?php echo attribute_escape(__('Revert')); ?>" onclick="kRevert()" /> 393 <input type="button" value="<?php echo attribute_escape(__('Advanced')); ?>" onclick="toggleAdvanced()" /> 376 394 <input type="hidden" name="action" value="save" /> 377 <input type="hidden" name="fontdisplay" id="fontdisplay" value="<?php echo kubrick_header_display(); ?>" />378 <input type="hidden" name="fontcolor" id="fontcolor" value="<?php echo kubrick_header_color(); ?>" />379 <input type="hidden" name="uppercolor" id="uppercolor" value="<?php echo kubrick_upper_color(); ?>" />380 <input type="hidden" name="lowercolor" id="lowercolor" value="<?php echo kubrick_lower_color(); ?>" />381 <input type="hidden" name="headerimage" id="headerimage" value="<?php echo kubrick_header_image(); ?>" />382 <p class="submit"><input type="submit" name="submitform" class="defbutton" value="<?php _e('Update Header »'); ?>" onclick="cp.hidePopup('prettyplease')" /></p>395 <input type="hidden" name="fontdisplay" id="fontdisplay" value="<?php echo attribute_escape(kubrick_header_display()); ?>" /> 396 <input type="hidden" name="fontcolor" id="fontcolor" value="<?php echo attribute_escape(kubrick_header_color()); ?>" /> 397 <input type="hidden" name="uppercolor" id="uppercolor" value="<?php echo attribute_escape(kubrick_upper_color()); ?>" /> 398 <input type="hidden" name="lowercolor" id="lowercolor" value="<?php echo attribute_escape(kubrick_lower_color()); ?>" /> 399 <input type="hidden" name="headerimage" id="headerimage" value="<?php echo attribute_escape(kubrick_header_image()); ?>" /> 400 <p class="submit"><input type="submit" name="submitform" class="defbutton" value="<?php echo attribute_escape(__('Update Header »')); ?>" onclick="cp.hidePopup('prettyplease')" /></p> 383 401 </form> 384 402 <div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;visibility:hidden;"> </div> 385 403 <div id="advanced"> 386 404 <form id="jsAdvanced" style="display:none;" action=""> 387 <label for="advfontcolor">Font Color (CSS): </label><input type="text" id="advfontcolor" onchange="advUpdate(this.value, 'fontcolor')" value="<?php echo kubrick_header_color(); ?>" /><br /> 388 <label for="advuppercolor">Upper Color (HEX): </label><input type="text" id="advuppercolor" onchange="advUpdate(this.value, 'uppercolor')" value="#<?php echo kubrick_upper_color(); ?>" /><br /> 389 <label for="advlowercolor">Lower Color (HEX): </label><input type="text" id="advlowercolor" onchange="advUpdate(this.value, 'lowercolor')" value="#<?php echo kubrick_lower_color(); ?>" /><br /> 390 <input type="button" name="default" value="Select Default Colors" onclick="kDefaults()" /><br /> 391 <input type="button" onclick="toggleDisplay();return false;" name="pick" id="pick" value="Toggle Text Display"></input><br /> 405 <?php wp_nonce_field('kubrick-header'); ?> 406 <label for="advfontcolor"><?php _e('Font Color (CSS):'); ?> </label><input type="text" id="advfontcolor" onchange="advUpdate(this.value, 'fontcolor')" value="<?php echo attribute_escape(kubrick_header_color()); ?>" /><br /> 407 <label for="advuppercolor"><?php _e('Upper Color (HEX):');?> </label><input type="text" id="advuppercolor" onchange="advUpdate(this.value, 'uppercolor')" value="#<?php echo attribute_escape(kubrick_upper_color()); ?>" /><br /> 408 <label for="advlowercolor"><?php _e('Lower Color (HEX):'); ?> </label><input type="text" id="advlowercolor" onchange="advUpdate(this.value, 'lowercolor')" value="#<?php echo attribute_escape(kubrick_lower_color()); ?>" /><br /> 409 <input type="button" name="default" value="<?php echo attribute_escape(__('Select Default Colors')); ?>" onclick="kDefaults()" /><br /> 410 <input type="button" onclick="toggleDisplay();return false;" name="pick" id="pick" value="<?php echo attribute_escape(__('Toggle Text Display')); ?>"></input><br /> 392 411 </form> 393 412 </div> -
tags/2.2/wp-content/themes/default/header.php
r5468 r5480 19 19 if ( !$withcomments && !is_single() ) { 20 20 ?> 21 #page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbg .jpg") repeat-y top; border: none; }21 #page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbg-<?php bloginfo('text_direction'); ?>.jpg") repeat-y top; border: none; } 22 22 <?php } else { // No sidebar ?> 23 23 #page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgwide.jpg") repeat-y top; border: none; } -
tags/2.2/wp-content/themes/default/searchform.php
r5468 r5480 1 <form method="get" id="searchform" action="<?php bloginfo(' home'); ?>/">1 <form method="get" id="searchform" action="<?php bloginfo('url'); ?>/"> 2 2 <div><input type="text" value="<?php the_search_query(); ?>" name="s" id="s" /> 3 3 <input type="submit" id="searchsubmit" value="Search" /> -
tags/2.2/wp-content/themes/default/sidebar.php
r5468 r5480 1 1 <div id="sidebar"> 2 2 <ul> 3 3 <?php /* Widgetized sidebar, if you have the plugin installed. */ 4 if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?> 4 5 <li> 5 6 <?php include (TEMPLATEPATH . '/searchform.php'); ?> … … 12 13 --> 13 14 14 <li> 15 <?php if ( is_404() || is_category() || is_day() || is_month() || 16 is_year() || is_search() || is_paged() ) { 17 ?> <li> 18 15 19 <?php /* If this is a 404 page */ if (is_404()) { ?> 16 20 <?php /* If this is a category archive */ } elseif (is_category()) { ?> … … 18 22 19 23 <?php /* If this is a yearly archive */ } elseif (is_day()) { ?> 20 <p>You are currently browsing the <a href="<?php bloginfo(' home'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives24 <p>You are currently browsing the <a href="<?php bloginfo('url'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives 21 25 for the day <?php the_time('l, F jS, Y'); ?>.</p> 22 26 23 27 <?php /* If this is a monthly archive */ } elseif (is_month()) { ?> 24 <p>You are currently browsing the <a href="<?php bloginfo(' home'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives28 <p>You are currently browsing the <a href="<?php bloginfo('url'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives 25 29 for <?php the_time('F, Y'); ?>.</p> 26 30 27 31 <?php /* If this is a yearly archive */ } elseif (is_year()) { ?> 28 <p>You are currently browsing the <a href="<?php bloginfo(' home'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives32 <p>You are currently browsing the <a href="<?php bloginfo('url'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives 29 33 for the year <?php the_time('Y'); ?>.</p> 30 34 31 35 <?php /* If this is a monthly archive */ } elseif (is_search()) { ?> 32 <p>You have searched the <a href="<?php echo bloginfo(' home'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives36 <p>You have searched the <a href="<?php echo bloginfo('url'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives 33 37 for <strong>'<?php the_search_query(); ?>'</strong>. If you are unable to find anything in these search results, you can try one of these links.</p> 34 38 35 39 <?php /* If this is a monthly archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?> 36 <p>You are currently browsing the <a href="<?php echo bloginfo(' home'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives.</p>40 <p>You are currently browsing the <a href="<?php echo bloginfo('url'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives.</p> 37 41 38 42 <?php } ?> 39 </li> 43 44 </li> <?php }?> 40 45 41 46 <?php wp_list_pages('title_li=<h2>Pages</h2>' ); ?> … … 63 68 </li> 64 69 <?php } ?> 65 70 71 <?php endif; ?> 66 72 </ul> 67 73 </div> -
tags/2.2/wp-cron.php
r5468 r5480 4 4 require_once('wp-config.php'); 5 5 6 if ( $_GET['check'] != md5(DB_PASS .'187425') )6 if ( $_GET['check'] != wp_hash('187425') ) 7 7 exit; 8 8 -
tags/2.2/wp-includes/author-template.php
r5468 r5480 174 174 175 175 function wp_list_authors($args = '') { 176 global $wpdb; 177 176 178 if ( is_array($args) ) 177 179 $r = &$args; … … 183 185 $r = array_merge($defaults, $r); 184 186 extract($r); 185 186 global $wpdb; 187 187 188 // TODO: Move select to get_authors(). 188 $query = "SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name"; 189 $authors = $wpdb->get_results($query); 189 $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name"); 190 191 $author_count = array(); 192 foreach ((array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_status = 'publish' GROUP BY post_author") as $row) { 193 $author_count[$row->post_author] = $row->count; 194 } 190 195 191 196 foreach ( (array) $authors as $author ) { 192 197 $author = get_userdata( $author->ID ); 193 $posts = get_usernumposts($author->ID);198 $posts = (isset($author_count[$author->ID])) ? $author_count[$author->ID] : 0; 194 199 $name = $author->nickname; 195 200 -
tags/2.2/wp-includes/bookmark-template.php
r5468 r5480 137 137 if ( $show_description && '' != $desc ) 138 138 $output .= $between . $desc; 139 140 if ($show_rating) { 141 $output .= $between . get_linkrating($row); 142 } 139 143 140 144 $output .= "$after\n"; … … 267 271 $rel = ' rel="' . $rel . '"'; 268 272 269 $desc = attribute_escape( $bookmark->link_description);270 $name = attribute_escape($bookmark->link_name); 271 $title = $desc;273 $desc = attribute_escape(apply_filters('link_description', $bookmark->link_description)); 274 $name = attribute_escape(apply_filters('link_title', $bookmark->link_name)); 275 $title = $desc; 272 276 273 277 if ( $show_updated ) … … 305 309 if ( $show_description && '' != $desc ) 306 310 $output .= $between . $desc; 311 312 if ($show_rating) { 313 $output .= $between . get_linkrating($bookmark); 314 } 315 307 316 $output .= "$after\n"; 308 317 } // end while … … 332 341 333 342 foreach ( (array) $cats as $cat ) { 334 $bookmarks = get_bookmarks("limit=$limit&category={$cat->cat_ID}&show_updated=$show_updated&orderby=$orderby&order=$order&hide_invisible=$hide_invisible&show_updated=$show_updated"); 343 $params = array_merge($r, array('category'=>$cat->cat_ID)); 344 $bookmarks = get_bookmarks($params); 335 345 if ( empty($bookmarks) ) 336 346 continue; 337 347 $output .= str_replace(array('%id', '%class'), array("linkcat-$cat->cat_ID", $class), $category_before); 338 $output .= "$title_before$cat->cat_name$title_after\n\t<ul>\n"; 348 $catname = apply_filters( "link_category", $cat->cat_name ); 349 $output .= "$title_before$catname$title_after\n\t<ul>\n"; 339 350 $output .= _walk_bookmarks($bookmarks, $r); 340 351 $output .= "\n\t</ul>\n$category_after\n"; … … 342 353 } else { 343 354 //output one single list using title_li for the title 344 $bookmarks = get_bookmarks( "limit=$limit&category=$category&show_updated=$show_updated&orderby=$orderby&order=$order&hide_invisible=$hide_invisible&show_updated=$show_updated");345 355 $bookmarks = get_bookmarks($r); 356 346 357 if ( !empty($bookmarks) ) { 347 358 if ( !empty( $title_li ) ){ -
tags/2.2/wp-includes/bookmark.php
r5468 r5480 74 74 if (!empty($exclusions)) 75 75 $exclusions .= ')'; 76 76 77 77 if ( ! empty($category_name) ) { 78 78 if ( $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category_name' LIMIT 1") ) … … 137 137 138 138 $cache[ $key ] = $results; 139 wp_cache_ set( 'get_bookmarks', $cache, 'bookmark' );139 wp_cache_add( 'get_bookmarks', $cache, 'bookmark' ); 140 140 141 141 return apply_filters('get_bookmarks', $results, $r); -
tags/2.2/wp-includes/cache.php
r5468 r5480 195 195 $this->cache['category'][$catt->cat_ID] = $catt; 196 196 } 197 } else 198 if ('options' == $group) { 199 $wpdb->hide_errors(); 200 if (!$options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'")) { 201 $options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options"); 202 } 203 $wpdb->show_errors(); 204 205 if ( ! $options ) 206 return; 207 208 foreach ($options as $option) { 209 $this->cache['options'][$option->option_name] = $option->option_value; 210 } 211 } 197 } 198 212 199 } 213 200 … … 354 341 fclose($fd); 355 342 if (!@ rename($temp_file, $cache_file)) { 356 if (@ copy($temp_file, $cache_file)) 357 @ unlink($temp_file); 358 else 343 if (!@ copy($temp_file, $cache_file)) 359 344 $errors++; 345 @ unlink($temp_file); 360 346 } 361 347 @ chmod($cache_file, $file_perms); … … 400 386 return $this->__construct(); 401 387 } 402 388 403 389 function __construct() { 404 390 global $blog_id; … … 443 429 function __destruct() { 444 430 $this->save(); 445 return true; 431 return true; 446 432 } 447 433 } -
tags/2.2/wp-includes/category-template.php
r5468 r5480 33 33 34 34 if ( $parent = $category->category_parent ) 35 $category_nicename = get_category_parents($parent, false, '/', true) . $category_nicename . '/';35 $category_nicename = get_category_parents($parent, false, '/', true) . $category_nicename; 36 36 37 37 $catlink = str_replace('%category%', $category_nicename, $catlink); 38 $catlink = get_option('home') . trailingslashit($catlink);38 $catlink = get_option('home') . user_trailingslashit($catlink, 'category'); 39 39 } 40 40 return apply_filters('category_link', $catlink, $category_id); … … 73 73 74 74 if ( !empty($categories) ) 75 sort($categories);75 usort($categories, '_get_the_category_usort'); 76 76 else 77 77 $categories = array(); 78 78 79 79 return $categories; 80 } 81 82 function _get_the_category_usort($a, $b) { 83 return strcmp($a->category_name, $b->category_name); 80 84 } 81 85 … … 87 91 88 92 function get_the_category_list($separator = '', $parents='') { 93 global $wp_rewrite; 89 94 $categories = get_the_category(); 90 95 if (empty($categories)) 91 96 return apply_filters('the_category', __('Uncategorized'), $separator, $parents); 97 98 $rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"'; 92 99 93 100 $thelist = ''; … … 100 107 if ($category->category_parent) 101 108 $thelist .= get_category_parents($category->category_parent, TRUE); 102 $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>';109 $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" ' . $rel . '>' . $category->cat_name.'</a></li>'; 103 110 break; 104 111 case 'single': 105 $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . ' rel="category tag">';112 $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" ' . $rel . '>'; 106 113 if ($category->category_parent) 107 114 $thelist .= get_category_parents($category->category_parent, FALSE); … … 110 117 case '': 111 118 default: 112 $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>';119 $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" ' . $rel . '>' . $category->cat_name.'</a></li>'; 113 120 } 114 121 } … … 123 130 if ( $category->category_parent ) 124 131 $thelist .= get_category_parents($category->category_parent, TRUE); 125 $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>';132 $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" ' . $rel . '>' . $category->cat_name.'</a>'; 126 133 break; 127 134 case 'single': 128 $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">';135 $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" ' . $rel . '>'; 129 136 if ( $category->category_parent ) 130 137 $thelist .= get_category_parents($category->category_parent, FALSE); … … 133 140 case '': 134 141 default: 135 $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>';142 $thelist .= '<a href="' . get_category_link($category->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" ' . $rel . '>' . $category->cat_name.'</a>'; 136 143 } 137 144 ++$i; … … 243 250 global $wp_query; 244 251 252 if( !empty($show_option_all) ) 253 if ('list' == $style ) 254 $output .= '<li><a href="' . get_bloginfo('url') . '">' . $show_option_all . '</a></li>'; 255 else 256 $output .= '<a href="' . get_bloginfo('url') . '">' . $show_option_all . '</a>'; 257 245 258 if ( is_category() ) 246 259 $r['current_category'] = $wp_query->get_queried_object_id(); -
tags/2.2/wp-includes/category.php
r5468 r5480 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 … … 106 106 } 107 107 108 if ( $child_of || $hierarchical ) 109 $categories = & _get_cat_children($child_of, $categories); 108 if ( $child_of || $hierarchical ) { 109 $children = _get_category_hierarchy(); 110 if ( ! empty($children) ) 111 $categories = & _get_cat_children($child_of, $categories); 112 } 110 113 111 114 // Update category counts to include children. … … 130 133 131 134 $cache[ $key ] = $categories; 132 wp_cache_set( 'get_categories', $cache, 'category' ); 133 134 return apply_filters('get_categories', $categories, $r); 135 wp_cache_add( 'get_categories', $cache, 'category' ); 136 137 $categories = apply_filters('get_categories', $categories, $r); 138 return $categories; 135 139 } 136 140 … … 150 154 if ( ! $_category = wp_cache_get($category, 'category') ) { 151 155 $_category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$category' LIMIT 1"); 152 wp_cache_ set($category, $_category, 'category');156 wp_cache_add($category, $_category, 'category'); 153 157 } 154 158 } … … 248 252 249 253 $category_list = array(); 254 $has_children = _get_category_hierarchy(); 255 256 if ( ( 0 != $category_id ) && ! isset($has_children[$category_id]) ) 257 return array(); 258 250 259 foreach ( $categories as $category ) { 251 260 if ( $category->cat_ID == $category_id ) … … 254 263 if ( $category->category_parent == $category_id ) { 255 264 $category_list[] = $category; 265 266 if ( !isset($has_children[$category->cat_ID]) ) 267 continue; 268 256 269 if ( $children = _get_cat_children($category->cat_ID, $categories) ) 257 270 $category_list = array_merge($category_list, $children); … … 301 314 } 302 315 316 function _get_category_hierarchy() { 317 $children = get_option('category_children'); 318 if ( is_array($children) ) 319 return $children; 320 321 $children = array(); 322 $categories = get_categories('hide_empty=0&hierarchical=0'); 323 foreach ( $categories as $cat ) { 324 if ( $cat->category_parent > 0 ) 325 $children[$cat->category_parent][] = $cat->cat_ID; 326 } 327 update_option('category_children', $children); 328 329 return $children; 330 } 303 331 ?> -
tags/2.2/wp-includes/class-pop3.php
r5468 r5480 4 4 * mail_fetch/setup.php 5 5 * 6 * Copyright (c) 1999-200 2The SquirrelMail Project Team6 * Copyright (c) 1999-2006 The SquirrelMail Project Team 7 7 * 8 8 * Copyright (c) 1999 CDI (cdi@thewebmasters.net) All Rights Reserved … … 41 41 // pop server - used for apop() 42 42 43 var $RFC1939 = TRUE; // Set by noop(). See rfc1939.txt44 //45 46 43 var $ALLOWAPOP = FALSE; // Allow or disallow apop() 47 44 // This must be set to true … … 60 57 settype($timeout,"integer"); 61 58 $this->TIMEOUT = $timeout; 59 if (!ini_get('safe_mode')) 62 60 set_time_limit($timeout); 63 61 } … … 66 64 67 65 function update_timer () { 66 if (!ini_get('safe_mode')) 68 67 set_time_limit($this->TIMEOUT); 69 68 return true; … … 76 75 // If MAILSERVER is set, override $server with it's value 77 76 77 if (!isset($port) || !$port) {$port = 110;} 78 78 if(!empty($this->MAILSERVER)) 79 79 $server = $this->MAILSERVER; … … 85 85 } 86 86 87 $fp = fsockopen("$server", $port, $errno, $errstr);87 $fp = @fsockopen("$server", $port, $errno, $errstr); 88 88 89 89 if(!$fp) { … … 106 106 $this->FP = $fp; 107 107 $this->BANNER = $this->parse_banner($reply); 108 $this->RFC1939 = $this->noop(); 109 if($this->RFC1939) { 110 $this->ERROR = _("POP3: premature NOOP OK, NOT an RFC 1939 Compliant server"); 111 $this->quit(); 112 return false; 113 } else 114 return true; 115 } 116 117 function noop () { 118 119 if(!isset($this->FP)) { 120 $this->ERROR = _("POP3 noop:") . ' ' . _("No connection to server"); 121 return false; 122 } else { 123 $cmd = "NOOP"; 124 $reply = $this->send_cmd( $cmd ); 125 return( $this->is_ok( $reply ) ); 126 } 108 return true; 127 109 } 128 110 … … 159 141 $reply = $this->send_cmd("PASS $pass"); 160 142 if(!$this->is_ok($reply)) { 161 $this->ERROR = _("POP3 pass:") . ' ' . _(" authentication failed ") . "[$reply]";143 $this->ERROR = _("POP3 pass:") . ' ' . _("Authentication failed ") . "[$reply]"; 162 144 $this->quit(); 163 145 return false; … … 166 148 $count = $this->last("count"); 167 149 $this->COUNT = $count; 168 $this->RFC1939 = $this->noop(); 169 if(!$this->RFC1939) { 170 $this->ERROR = _("POP3 pass:") . ' ' . _("NOOP failed. Server not RFC 1939 compliant"); 171 $this->quit(); 172 return false; 173 } else 174 return $count; 150 return $count; 175 151 } 176 152 } … … 215 191 $count = $this->last("count"); 216 192 $this->COUNT = $count; 217 $this->RFC1939 = $this->noop(); 218 if(!$this->RFC1939) { 219 $this->ERROR = _("POP3 apop:") . ' ' . _("NOOP failed. Server not RFC 1939 compliant"); 220 $this->quit(); 221 return false; 222 } else 223 return $count; 193 return $count; 224 194 } 225 195 } … … 331 301 return false; 332 302 } 333 list($junk,$num,$size) = explode(" ",$reply);303 list($junk,$num,$size) = preg_split('/\s+/',$reply); 334 304 return $size; 335 305 } … … 354 324 return false; 355 325 } 356 list($thisMsg,$msgSize) = explode(" ",$line);326 list($thisMsg,$msgSize) = preg_split('/\s+/',$line); 357 327 settype($thisMsg,"integer"); 358 328 if($thisMsg != $msgC) … … 394 364 $MsgArray = array(); 395 365 396 $line = fgets($fp,$buffer);366 $line = ""; 397 367 while ( !ereg("^\.\r\n",$line)) 398 368 { 369 $line = fgets($fp,$buffer); 370 if (preg_match("/^\s+/", $line) && $count > 0) { 371 $MsgArray[$count-1] .= $line; 372 continue; 373 } 374 if(empty($line)) { break; } 375 399 376 $MsgArray[$count] = $line; 400 377 $count++; 401 $line = fgets($fp,$buffer);402 if(empty($line)) { break; }403 378 } 404 379 return $MsgArray; … … 424 399 } 425 400 426 $Vars = explode(" ",$reply);401 $Vars = preg_split('/\s+/',$reply); 427 402 $count = $Vars[1]; 428 403 $size = $Vars[2]; … … 555 530 return false; 556 531 } 557 list ($ok,$num,$myUidl) = explode(" ",$reply);532 list ($ok,$num,$myUidl) = preg_split('/\s+/',$reply); 558 533 return $myUidl; 559 534 } else { … … 586 561 break; 587 562 } 588 list ($msg,$msgUidl) = explode(" ",$line);563 list ($msg,$msgUidl) = preg_split('/\s+/',$line); 589 564 $msgUidl = $this->strip_clf($msgUidl); 590 565 if($count == $msg) { … … 657 632 { 658 633 $digit = substr($server_text, $count, 1); 659 if ( false !== $digit) {634 if (!empty($digit)) { 660 635 if( (!$outside) && ($digit != '<') && ($digit != '>') ) 661 636 { -
tags/2.2/wp-includes/classes.php
r5468 r5480 59 59 // filename, if any. For 404 requests, this leaves us with the 60 60 // requested permalink. 61 $req_uri = str_replace($pathinfo, '', $req_uri);61 $req_uri = str_replace($pathinfo, '', rawurldecode($req_uri)); 62 62 $req_uri = trim($req_uri, '/'); 63 63 $req_uri = preg_replace("|^$home_path|", '', $req_uri); … … 121 121 122 122 // If req_uri is empty or if it is a request for ourself, unset error. 123 if ( empty($request) || $req_uri == $self || strstr($_SERVER['PHP_SELF'], 'wp-admin/')) {123 if (empty($request) || $req_uri == $self || strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false) { 124 124 if (isset($_GET['error'])) 125 125 unset($_GET['error']); … … 128 128 unset($error); 129 129 130 if ( isset($perma_query_vars) && strstr($_SERVER['PHP_SELF'], 'wp-admin/'))130 if (isset($perma_query_vars) && strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false) 131 131 unset($perma_query_vars); 132 132 … … 418 418 $output = call_user_func_array(array(&$this, 'start_el'), $cb_args); 419 419 } 420 420 421 421 // End the element. 422 422 if ( isset($element->$id_field) && $element->$id_field != 0 ) { … … 424 424 $output = call_user_func_array(array(&$this, 'end_el'), $cb_args); 425 425 } 426 427 continue; 428 } 429 426 427 continue; 428 } 429 430 430 // Walk the tree. 431 431 if ( !empty($previous_element) && ($element->$parent_field == $previous_element->$id_field) ) { … … 515 515 $css_class .= ' current_page_parent'; 516 516 517 $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . attribute_escape( $page->post_title) . '">' . $page->post_title. '</a>';518 517 $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . attribute_escape(apply_filters('the_title', $page->post_title)) . '">' . apply_filters('the_title', $page->post_title) . '</a>'; 518 519 519 if ( !empty($show_date) ) { 520 520 if ( 'modified' == $show_date ) … … 522 522 else 523 523 $time = $page->post_date; 524 524 525 525 $output .= " " . mysql2date($date_format, $time); 526 526 } … … 528 528 return $output; 529 529 } 530 530 531 531 function end_el($output, $page, $depth) { 532 532 $output .= "</li>\n"; … … 582 582 583 583 $cat_name = attribute_escape( $category->cat_name); 584 $cat_name = apply_filters( 'list_cats', $cat_name, $category ); 584 585 $link = '<a href="' . get_category_link( $category->cat_ID ) . '" '; 585 586 if ( $use_desc_for_title == 0 || empty($category->category_description) ) … … 588 589 $link .= 'title="' . attribute_escape( apply_filters( 'category_description', $category->category_description, $category )) . '"'; 589 590 $link .= '>'; 590 $link .= apply_filters( 'list_cats', $category->cat_name, $category ).'</a>';591 $link .= $cat_name . '</a>'; 591 592 592 593 if ( (! empty($feed_image)) || (! empty($feed)) ) { … … 617 618 $link .= ')'; 618 619 } 619 620 620 621 if ( isset($show_count) && $show_count ) 621 622 $link .= ' (' . intval($category->category_count) . ')'; 622 623 623 624 if ( isset($show_date) && $show_date ) { 624 625 $link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp); -
tags/2.2/wp-includes/comment-template.php
r5468 r5480 162 162 } 163 163 164 function comments_number( $zero = false, $one = false, $more = false, $ number= '' ) {164 function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) { 165 165 global $id; 166 166 $number = get_comments_number($id); … … 227 227 228 228 if ( '' != get_option('permalink_structure') ) 229 $tb_url = trailingslashit(get_permalink()) . 'trackback/';230 231 return $tb_url;229 $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback'); 230 231 return apply_filters('trackback_url', $tb_url); 232 232 } 233 233 function trackback_url( $display = true ) { … … 240 240 function trackback_rdf($timezone = 0) { 241 241 global $id; 242 if ( !stristr($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator')) {243 echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"244 xmlns:dc="http://purl.org/dc/elements/1.1/"245 xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">246 <rdf:Description rdf:about="';247 the_permalink();248 echo '"'."\n";249 echo ' dc:identifier="';250 the_permalink();251 echo '"'."\n";252 echo ' dc:title="'.str_replace('--', '--', wptexturize(strip_tags(get_the_title()))).'"'."\n";253 echo ' trackback:ping="'.trackback_url(0).'"'." />\n";254 echo '</rdf:RDF>';242 if (strpos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') !== false) { 243 echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 244 xmlns:dc="http://purl.org/dc/elements/1.1/" 245 xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"> 246 <rdf:Description rdf:about="'; 247 the_permalink(); 248 echo '"'."\n"; 249 echo ' dc:identifier="'; 250 the_permalink(); 251 echo '"'."\n"; 252 echo ' dc:title="'.str_replace('--', '--', wptexturize(strip_tags(get_the_title()))).'"'."\n"; 253 echo ' trackback:ping="'.trackback_url(0).'"'." />\n"; 254 echo '</rdf:RDF>'; 255 255 } 256 256 } … … 289 289 290 290 // TODO: Use API instead of SELECTs. 291 if ( empty($comment_author) ) { 291 if ( $user_ID) { 292 $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND (comment_approved = '1' OR ( user_id = '$user_ID' AND comment_approved = '0' ) ) ORDER BY comment_date"); 293 } else if ( empty($comment_author) ) { 292 294 $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date"); 293 295 } else { … … 297 299 } 298 300 299 $comments = apply_filters( 'comments_array', $comments, $post->ID ); 301 // keep $comments for legacy's sake (remember $table*? ;) ) 302 $comments = $wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID ); 303 $wp_query->comment_count = count($wp_query->comments); 300 304 301 305 define('COMMENTS_TEMPLATE', true); … … 330 334 331 335 if ( 0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status ) { 332 echo $none;336 echo '<span' . ((!empty($CSSclass)) ? ' class="' . $CSSclass . '"' : '') . '>' . $none . '</span>'; 333 337 return; 334 338 } -
tags/2.2/wp-includes/compat.php
r5468 r5480 119 119 } 120 120 121 // Added in PHP 5.0 122 if (!function_exists('stripos')) { 123 function stripos($haystack, $needle, $offset = 0) { 124 return strpos(strtolower($haystack), strtolower($needle), $offset); 125 } 126 } 127 121 128 ?> -
tags/2.2/wp-includes/cron.php
r5468 r5480 55 55 function wp_clear_scheduled_hook( $hook ) { 56 56 $args = array_slice( func_get_args(), 1 ); 57 57 58 58 while ( $timestamp = wp_next_scheduled( $hook, $args ) ) 59 59 wp_unschedule_event( $timestamp, $hook, $args ); … … 74 74 function spawn_cron() { 75 75 $crons = _get_cron_array(); 76 76 77 77 if ( !is_array($crons) ) 78 78 return; 79 79 80 80 $keys = array_keys( $crons ); 81 81 if ( array_shift( $keys ) > time() ) … … 84 84 $cron_url = get_option( 'siteurl' ) . '/wp-cron.php'; 85 85 $parts = parse_url( $cron_url ); 86 87 $argyle = @ fsockopen( $parts['host'], $_SERVER['SERVER_PORT'], $errno, $errstr, 0.01 ); 86 87 if ($parts['scheme'] == 'https') { 88 // support for SSL was added in 4.3.0 89 if (version_compare(phpversion(), '4.3.0', '>=') && function_exists('openssl_open')) { 90 $argyle = @fsockopen('ssl://' . $parts['host'], $_SERVER['SERVER_PORT'], $errno, $errstr, 0.01); 91 } else { 92 return false; 93 } 94 } else { 95 $argyle = @ fsockopen( $parts['host'], $_SERVER['SERVER_PORT'], $errno, $errstr, 0.01 ); 96 } 97 88 98 if ( $argyle ) 89 99 fputs( $argyle, 90 "GET {$parts['path']}?check=" . md5(DB_PASS .'187425') . " HTTP/1.0\r\n"100 "GET {$parts['path']}?check=" . wp_hash('187425') . " HTTP/1.0\r\n" 91 101 . "Host: {$_SERVER['HTTP_HOST']}\r\n\r\n" 92 102 ); … … 99 109 100 110 $crons = _get_cron_array(); 101 111 102 112 if ( !is_array($crons) ) 103 113 return; -
tags/2.2/wp-includes/default-filters.php
r5468 r5480 46 46 47 47 add_filter('comment_text', 'convert_chars'); 48 add_filter('comment_text', 'make_clickable' );48 add_filter('comment_text', 'make_clickable', 9); 49 49 add_filter('comment_text', 'force_balance_tags', 25); 50 50 add_filter('comment_text', 'wpautop', 30); … … 146 146 add_filter('option_ping_sites', 'privacy_ping_filter'); 147 147 add_filter('option_blog_charset', 'wp_specialchars'); 148 add_filter('option_home', '_config_wp_home'); 149 add_filter('option_siteurl', '_config_wp_siteurl'); 148 150 add_filter('mce_plugins', '_mce_load_rtl_plugin'); 149 151 add_filter('mce_buttons', '_mce_add_direction_buttons'); … … 171 173 add_action('admin_print_scripts', 'wp_print_scripts', 20); 172 174 add_action('mce_options', '_mce_set_direction'); 175 add_action('init', 'smilies_init', 5); 176 add_action( 'plugins_loaded', 'wp_maybe_load_widgets', 0 ); 177 add_action( 'shutdown', 'wp_ob_end_flush_all', 1); 178 173 179 ?> -
tags/2.2/wp-includes/deprecated.php
r5468 r5480 2 2 3 3 /* 4 * 4 * Deprecated global variables. 5 5 */ 6 6 7 7 $tableposts = $wpdb->posts; 8 8 $tableusers = $wpdb->users; … … 16 16 17 17 /* 18 * Deprecated functio s come here to die.18 * Deprecated functions come here to die. 19 19 */ 20 20 21 // Deprecated.Use get_post().21 // Use get_post(). 22 22 function get_postdata($postid) { 23 23 $post = &get_post($postid); … … 44 44 } 45 45 46 // Deprecated.Use the new post loop.46 // Use the new post loop. 47 47 function start_wp() { 48 48 global $wp_query, $post; … … 54 54 } 55 55 56 // Deprecated.57 56 function the_category_ID($echo = true) { 58 57 // Grab the first cat in the list. … … 66 65 } 67 66 68 // Deprecated.69 67 function the_category_head($before='', $after='') { 70 68 global $currentcat, $previouscat; … … 80 78 } 81 79 82 // Deprecated.Use previous_post_link().80 // Use previous_post_link(). 83 81 function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') { 84 82 … … 101 99 } 102 100 103 // Deprecated.Use next_post_link().101 // Use next_post_link(). 104 102 function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') { 105 103 … … 123 121 124 122 // 125 // These are deprecated. Use current_user_can().123 // Use current_user_can() for these. 126 124 // 127 125 … … 245 243 $args = add_query_arg('category', $cat_id, $args); 246 244 wp_get_links($args); 247 } // end wp_get_linksbyname245 } 248 246 249 247 /** function get_linkobjectsbyname() … … 422 420 } 423 421 422 // Use wp_list_cats(). 424 423 function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=FALSE, $child_of=0, $categories=0, $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=FALSE) { 425 424 $query = compact('optionall', 'all', 'sort_column', 'sort_order', 'file', 'list', 'optiondates', 'optioncount', 'hide_empty', 'use_desc_for_title', 'children', … … 470 469 } 471 470 472 // Deprecated. Use wp_print_scripts() or WP_Scripts instead.471 // Use wp_print_scripts() or WP_Scripts. 473 472 function tinymce_include() { 474 wp_print_script( 'wp_tiny_mce');473 wp_print_script('wp_tiny_mce'); 475 474 } 476 475 … … 488 487 } 489 488 489 // Use wp_get_archives(). 490 490 function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) { 491 491 $args = compact('type', 'limit', 'format', 'before', 'after', 'show_post_count'); … … 493 493 } 494 494 495 // Deprecated.Use get_author_posts_url().495 // Use get_author_posts_url(). 496 496 function get_author_link($echo = false, $author_id, $author_nicename = '') { 497 497 $link = get_author_posts_url($author_id, $author_nicename); … … 502 502 } 503 503 504 // Use wp_link_pages(). 504 505 function link_pages($before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', $pagelink='%', $more_file='') { 505 506 $args = compact('before', 'after', 'next_or_number', 'nextpagelink', 'previouspagelink', 'pagelink', 'more_file'); … … 507 508 } 508 509 510 // Use get_option(). 509 511 function get_settings($option) { 510 512 return get_option($option); -
tags/2.2/wp-includes/feed.php
r5468 r5480 3 3 function get_bloginfo_rss($show = '') { 4 4 $info = strip_tags(get_bloginfo($show)); 5 return apply_filters(' bloginfo_rss', convert_chars($info));5 return apply_filters('get_bloginfo_rss', convert_chars($info)); 6 6 } 7 7 8 8 9 9 function bloginfo_rss($show = '') { 10 echo get_bloginfo_rss($show); 11 } 12 10 echo apply_filters('bloginfo_rss', get_bloginfo_rss($show)); 11 } 12 13 function get_wp_title_rss($sep = '»') { 14 $title = wp_title($sep, false); 15 $title = apply_filters('get_wp_title_rss', $title); 16 return $title; 17 } 18 19 function wp_title_rss($sep = '»') { 20 echo apply_filters('wp_title_rss', get_wp_title_rss($sep)); 21 } 13 22 14 23 function get_the_title_rss() { … … 90 99 91 100 92 function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = ' ') {93 $url = comments_rss($commentsrssfilename);101 function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = 'nolongerused') { 102 $url = get_post_comments_feed_link(); 94 103 echo "<a href='$url'>$link_text</a>"; 95 104 } 96 105 97 106 98 function comments_rss($commentsrssfilename = '') { 99 global $id; 100 101 if ( '' != get_option('permalink_structure') ) 102 $url = trailingslashit( get_permalink() ) . 'feed/'; 103 else 104 $url = get_option('home') . "/$commentsrssfilename?feed=rss2&p=$id"; 105 106 return apply_filters('post_comments_feed_link', $url); 107 function comments_rss($commentsrssfilename = 'nolongerused') { 108 return get_post_comments_feed_link(); 107 109 } 108 110 … … 116 118 } else { 117 119 $link = get_author_posts_url($author_id, $author_nicename); 118 $link = $link . "feed/";120 $link = $link . user_trailingslashit('feed', 'feed'); 119 121 } 120 122 … … 134 136 } else { 135 137 $link = get_category_link($cat_ID); 136 $link = $link . "feed/";138 $link = $link . user_trailingslashit('feed', 'feed'); 137 139 } 138 140 … … 147 149 function get_the_category_rss($type = 'rss') { 148 150 $categories = get_the_category(); 151 $home = get_bloginfo_rss('home'); 149 152 $the_list = ''; 150 153 foreach ( (array) $categories as $category ) { … … 152 155 if ( 'rdf' == $type ) 153 156 $the_list .= "\n\t\t<dc:subject><![CDATA[$category->cat_name]]></dc:subject>\n"; 157 if ( 'atom' == $type ) 158 $the_list .= "<category scheme='$home' term='$category->cat_name' />"; 154 159 else 155 160 $the_list .= "\n\t\t<category><![CDATA[$category->cat_name]]></category>\n"; … … 161 166 function the_category_rss($type = 'rss') { 162 167 echo get_the_category_rss($type); 168 } 169 170 function html_type_rss() { 171 $type = get_bloginfo('html_type'); 172 if (strpos($type, 'xhtml') !== false) 173 $type = 'xhtml'; 174 else 175 $type = 'html'; 176 echo $type; 163 177 } 164 178 … … 169 183 return; 170 184 171 $custom_fields = get_post_custom(); 172 if ( is_array($custom_fields) ) { 173 while ( list($key, $val) = each($custom_fields) ) { 174 if ( $key == 'enclosure' ) { 175 if ( is_array($val) ) { 176 foreach ( (array) $val as $enc ) { 177 $enclosure = split( "\n", $enc ); 178 print "<enclosure url='".trim( htmlspecialchars($enclosure[ 0 ]) )."' length='".trim( $enclosure[ 1 ] )."' type='".trim( $enclosure[ 2 ] )."'/>\n"; 179 } 180 } 185 foreach (get_post_custom() as $key => $val) { 186 if ($key == 'enclosure') { 187 foreach ((array)$val as $enc) { 188 $enclosure = split("\n", $enc); 189 echo apply_filters('rss_enclosure', '<enclosure url="' . trim(htmlspecialchars($enclosure[0])) . '" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n"); 181 190 } 182 191 } … … 184 193 } 185 194 195 function atom_enclosure() { 196 global $id, $post; 197 if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) ) 198 return; 199 200 foreach (get_post_custom() as $key => $val) { 201 if ($key == 'enclosure') { 202 foreach ((array)$val as $enc) { 203 $enclosure = split("\n", $enc); 204 echo apply_filters('atom_enclosure', '<link href="' . trim(htmlspecialchars($enclosure[0])) . '" rel="enclosure" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n"); 205 } 206 } 207 } 208 } 209 186 210 ?> -
tags/2.2/wp-includes/formatting.php
r5468 r5480 22 22 23 23 $dynamic_characters = array('/\'(\d\d(?:’|\')?s)/', '/(\s|\A|")\'/', '/(\d+)"/', '/(\d+)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A)"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/(\d+)x(\d+)/'); 24 $dynamic_replacements = array('’$1','$1‘', '$1″', '$1′', '$1’$2', '$1“$2', '”$1', '’$1', '$1×$2'); 24 $dynamic_replacements = array('’$1','$1‘', '$1″', '$1′', '$1’$2', '$1“$2', '”$1', '’$1', '$1×$2'); 25 25 26 26 for ( $i = 0; $i < $stop; $i++ ) { … … 30 30 // static strings 31 31 $curl = str_replace($static_characters, $static_replacements, $curl); 32 33 32 // regular expressions 34 33 $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl); 35 } elseif ( strstr($curl, '<code') || strstr($curl, '<pre') || strstr($curl, '<kbd') || strstr($curl, '<style') || strstr($curl, '<script') ) {34 } elseif (strpos($curl, '<code') !== false || strpos($curl, '<pre') !== false || strpos($curl, '<kbd') !== false || strpos($curl, '<style') !== false || strpos($curl, '<script') !== false) { 36 35 $next = false; 37 36 } else { … … 57 56 $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee); 58 57 // Space things out a little 59 $allblocks = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form| blockquote|address|math|style|script|object|input|param|p|h[1-6])';58 $allblocks = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr)'; 60 59 $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee); 61 60 $pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee); … … 79 78 $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee); 80 79 $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee); 81 if ( strstr( $pee, '<pre' ))80 if (strpos($pee, '<pre') !== false) 82 81 $pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '</pre>' ", $pee); 83 82 $pee = preg_replace( "|\n</p>$|", '</p>', $pee ); … … 565 564 566 565 function trailingslashit($string) { 567 if ( '/' != substr($string, -1)) { 568 $string .= '/'; 569 } 570 return $string; 566 return untrailingslashit($string) . '/'; 567 } 568 569 function untrailingslashit($string) { 570 return rtrim($string, '/'); 571 571 } 572 572 … … 582 582 583 583 584 function stripslashes_deep($value) 585 { 584 function stripslashes_deep($value) { 586 585 $value = is_array($value) ? 587 array_map('stripslashes_deep', $value) : 588 stripslashes($value); 586 array_map('stripslashes_deep', $value) : 587 stripslashes($value); 588 589 return $value; 590 } 591 592 function urlencode_deep($value) { 593 $value = is_array($value) ? 594 array_map('urlencode_deep', $value) : 595 urlencode($value); 589 596 590 597 return $value; … … 659 666 function is_email($user_email) { 660 667 $chars = "/^([a-z0-9+_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,6}\$/i"; 661 if (strstr($user_email, '@') && strstr($user_email, '.')) {668 if (strpos($user_email, '@') !== false && strpos($user_email, '.') !== false) { 662 669 if (preg_match($chars, $user_email)) { 663 670 return true; … … 1075 1082 // Append http unless a relative link starting with / or a php file. 1076 1083 if ( strpos($url, '://') === false && 1077 substr( $url, 0, 1 ) != '/' && !preg_match('/^[a-z0-9 ]+?\.php/i', $url) )1084 substr( $url, 0, 1 ) != '/' && !preg_match('/^[a-z0-9-]+?\.php/i', $url) ) 1078 1085 $url = 'http://' . $url; 1079 1086 -
tags/2.2/wp-includes/functions.php
r5468 r5480 9 9 return false; 10 10 } 11 $i = mktime(substr($m,11,2),substr($m,14,2),substr($m,17,2),substr($m,5,2),substr($m,8,2),substr($m,0,4)); 11 $i = mktime( 12 (int) substr( $m, 11, 2 ), (int) substr( $m, 14, 2 ), (int) substr( $m, 17, 2 ), 13 (int) substr( $m, 5, 2 ), (int) substr( $m, 8, 2 ), (int) substr( $m, 0, 4 ) 14 ); 12 15 13 16 if( 'U' == $dateformatstring ) … … 204 207 global $wpdb; 205 208 206 $value = wp_cache_get($setting, 'options'); 207 208 if ( false === $value ) { 209 if ( defined('WP_INSTALLING') ) 210 $wpdb->hide_errors(); 211 $row = $wpdb->get_row("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting' LIMIT 1"); 212 if ( defined('WP_INSTALLING') ) 213 $wpdb->show_errors(); 214 215 if( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values 216 $value = $row->option_value; 217 wp_cache_set($setting, $value, 'options'); 218 } else { 219 return false; 209 // Allow plugins to short-circuit options. 210 $pre = apply_filters( 'pre_option_' . $setting, false ); 211 if ( $pre ) 212 return $pre; 213 214 // prevent non-existent options from triggering multiple queries 215 $notoptions = wp_cache_get('notoptions', 'options'); 216 if ( isset($notoptions[$setting]) ) 217 return false; 218 219 $alloptions = wp_load_alloptions(); 220 221 if ( isset($alloptions[$setting]) ) { 222 $value = $alloptions[$setting]; 223 } else { 224 $value = wp_cache_get($setting, 'options'); 225 226 if ( false === $value ) { 227 if ( defined('WP_INSTALLING') ) 228 $wpdb->hide_errors(); 229 $row = $wpdb->get_row("SELECT option_value FROM $wpdb->options WHERE option_name = '$setting' LIMIT 1"); 230 if ( defined('WP_INSTALLING') ) 231 $wpdb->show_errors(); 232 233 if( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values 234 $value = $row->option_value; 235 wp_cache_add($setting, $value, 'options'); 236 } else { // option does not exist, so we must cache its non-existence 237 $notoptions[$setting] = true; 238 wp_cache_set('notoptions', $notoptions, 'options'); 239 return false; 240 } 220 241 } 221 242 } … … 229 250 230 251 return apply_filters( 'option_' . $setting, maybe_unserialize($value) ); 252 } 253 254 function wp_protect_special_option($option) { 255 $protected = array('alloptions', 'notoptions'); 256 if ( in_array($option, $protected) ) 257 die(sprintf(__('%s is a protected WP option and may not be modified'), wp_specialchars($option))); 231 258 } 232 259 … … 258 285 } 259 286 287 function wp_load_alloptions() { 288 global $wpdb; 289 290 $alloptions = wp_cache_get('alloptions', 'options'); 291 292 if ( !$alloptions ) { 293 $wpdb->hide_errors(); 294 if ( !$alloptions_db = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'") ) 295 $alloptions_db = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options"); 296 $wpdb->show_errors(); 297 $alloptions = array(); 298 foreach ( (array) $alloptions_db as $o ) 299 $alloptions[$o->option_name] = $o->option_value; 300 wp_cache_add('alloptions', $alloptions, 'options'); 301 } 302 return $alloptions; 303 } 304 260 305 function update_option($option_name, $newvalue) { 261 306 global $wpdb; 262 307 308 wp_protect_special_option($option_name); 309 263 310 if ( is_string($newvalue) ) 264 311 $newvalue = trim($newvalue); … … 266 313 // If the new and old values are the same, no need to update. 267 314 $oldvalue = get_option($option_name); 268 if ( $newvalue == $oldvalue ) {315 if ( $newvalue === $oldvalue ) { 269 316 return false; 270 317 } … … 275 322 } 276 323 324 $notoptions = wp_cache_get('notoptions', 'options'); 325 if ( isset($notoptions[$option_name]) ) { 326 unset($notoptions[$option_name]); 327 wp_cache_set('notoptions', $notoptions, 'options'); 328 } 329 277 330 $_newvalue = $newvalue; 278 331 $newvalue = maybe_serialize($newvalue); 279 332 280 wp_cache_set($option_name, $newvalue, 'options'); 333 $alloptions = wp_load_alloptions(); 334 if ( isset($alloptions[$option_name]) ) { 335 $alloptions[$option_name] = $newvalue; 336 wp_cache_set('alloptions', $alloptions, 'options'); 337 } else { 338 wp_cache_set($option_name, $newvalue, 'options'); 339 } 281 340 282 341 $newvalue = $wpdb->escape($newvalue); … … 294 353 global $wpdb; 295 354 296 // Make sure the option doesn't already exist 297 if ( false !== get_option($name) ) 298 return; 355 wp_protect_special_option($name); 356 357 // Make sure the option doesn't already exist we can check the cache before we ask for a db query 358 $notoptions = wp_cache_get('notoptions', 'options'); 359 if ( isset($notoptions[$name]) ) { 360 unset($notoptions[$name]); 361 wp_cache_set('notoptions', $notoptions, 'options'); 362 } elseif ( false !== get_option($name) ) { 363 return; 364 } 299 365 300 366 $value = maybe_serialize($value); 301 367 302 wp_cache_set($name, $value, 'options'); 368 if ( 'yes' == $autoload ) { 369 $alloptions = wp_load_alloptions(); 370 $alloptions[$name] = $value; 371 wp_cache_set('alloptions', $alloptions, 'options'); 372 } else { 373 wp_cache_set($name, $value, 'options'); 374 } 303 375 304 376 $name = $wpdb->escape($name); … … 312 384 function delete_option($name) { 313 385 global $wpdb; 386 387 wp_protect_special_option($name); 388 314 389 // Get the ID, if no ID then return 315 $option _id = $wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = '$name'");316 if ( !$option _id ) return false;390 $option = $wpdb->get_row("SELECT option_id, autoload FROM $wpdb->options WHERE option_name = '$name'"); 391 if ( !$option->option_id ) return false; 317 392 $wpdb->query("DELETE FROM $wpdb->options WHERE option_name = '$name'"); 318 wp_cache_delete($name, 'options'); 393 if ( 'yes' == $option->autoload ) { 394 $alloptions = wp_load_alloptions(); 395 if ( isset($alloptions[$name]) ) { 396 unset($alloptions[$name]); 397 wp_cache_set('alloptions', $alloptions, 'options'); 398 } 399 } else { 400 wp_cache_delete($name, 'options'); 401 } 319 402 return true; 320 403 } … … 663 746 wp_cache_delete('all_category_ids', 'category'); 664 747 wp_cache_delete('get_categories', 'category'); 748 delete_option('category_children'); 665 749 } 666 750 … … 701 785 } 702 786 703 if ( strstr($uri, '?')) {787 if (strpos($uri, '?') !== false) { 704 788 $parts = explode('?', $uri, 2); 705 789 if ( 1 == count($parts) ) { … … 710 794 $query = $parts[1]; 711 795 } 712 } else if ( !empty($protocol) || strstr($uri, '/')) {796 } elseif (!empty($protocol) || strpos($uri, '/') !== false) { 713 797 $base = $uri . '?'; 714 798 $query = ''; … … 719 803 720 804 parse_str($query, $qs); 805 if ( get_magic_quotes_gpc() ) 806 $qs = stripslashes_deep($qs); // parse_str() adds slashes if magicquotes is on. See: http://php.net/parse_str 807 $qs = urlencode_deep($qs); 721 808 if ( is_array(func_get_arg(0)) ) { 722 809 $kayvees = func_get_arg(0); … … 736 823 } 737 824 } 825 $ret = trim($ret, '?'); 738 826 $ret = $protocol . $base . $ret . $frag; 739 if ( get_magic_quotes_gpc() ) 740 $ret = stripslashes($ret); // parse_str() adds slashes if magicquotes is on. See: http://php.net/parse_str 741 return trim($ret, '?'); 827 $ret = trim($ret, '?'); 828 return $ret; 742 829 } 743 830 … … 829 916 $text = 'Gone'; 830 917 831 if ( version_compare(phpversion(), '4.3.0', '>=') ) 832 @header("HTTP/1.1 $header $text", true, $header); 833 else 834 @header("HTTP/1.1 $header $text"); 918 $protocol = $_SERVER["SERVER_PROTOCOL"]; 919 if ( ('HTTP/1.1' != $protocol) && ('HTTP/1.0' != $protocol) ) 920 $protocol = 'HTTP/1.0'; 921 $status_header = "$protocol $header $text"; 922 $status_header = apply_filters('status_header', $status_header, $header, $text, $protocol); 923 924 if ( version_compare( phpversion(), '4.3.0', '>=' ) ) { 925 return @header( $status_header, true, $header ); 926 } else { 927 return @header( $status_header ); 928 } 835 929 } 836 930 … … 860 954 861 955 function do_feed() { 956 global $wp_query; 957 862 958 $feed = get_query_var('feed'); 863 959 … … 865 961 $feed = preg_replace('/^_+/', '', $feed); 866 962 867 if ($feed == '' || $feed == 'feed') 868 $feed = 'rss2'; 869 870 $for_comments = false; 871 if ( 1 != get_query_var('withoutcomments') && ( is_singular() || get_query_var('withcomments') == 1 || $feed == 'comments-rss2' ) ) { 963 if ( $feed == '' || $feed == 'feed' ) 872 964 $feed = 'rss2'; 873 $for_comments = true;874 }875 965 876 966 $hook = 'do_feed_' . $feed; 877 do_action($hook, $ for_comments);967 do_action($hook, $wp_query->is_comment_feed); 878 968 } 879 969 880 970 function do_feed_rdf() { 881 load_template(ABSPATH . 'wp-rdf.php');971 load_template(ABSPATH . WPINC . '/feed-rdf.php'); 882 972 } 883 973 884 974 function do_feed_rss() { 885 load_template(ABSPATH . 'wp-rss.php');975 load_template(ABSPATH . WPINC . '/feed-rss.php'); 886 976 } 887 977 888 978 function do_feed_rss2($for_comments) { 889 979 if ( $for_comments ) { 890 load_template(ABSPATH . 'wp-commentsrss2.php'); 891 } else { 892 load_template(ABSPATH . 'wp-rss2.php'); 893 } 894 } 895 896 function do_feed_atom() { 897 load_template(ABSPATH . 'wp-atom.php'); 980 load_template(ABSPATH . WPINC . '/feed-rss2-comments.php'); 981 } else { 982 load_template(ABSPATH . WPINC . '/feed-rss2.php'); 983 } 984 } 985 986 function do_feed_atom($for_comments) { 987 if ($for_comments) { 988 load_template(ABSPATH . WPINC . '/feed-atom-comments.php'); 989 } else { 990 load_template(ABSPATH . WPINC . '/feed-atom.php'); 991 } 898 992 } 899 993 900 994 function do_robots() { 995 header('Content-type: text/plain; charset=utf-8'); 996 901 997 do_action('do_robotstxt'); 998 902 999 if ( '0' == get_option('blog_public') ) { 903 1000 echo "User-agent: *\n"; … … 914 1011 $installed = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'"); 915 1012 $wpdb->show_errors(); 916 return $installed; 1013 1014 $install_status = !empty( $installed ) ? TRUE : FALSE; 1015 return $install_status; 917 1016 } 918 1017 … … 1143 1242 $trans['moderate']['comments'] = array(__('Are you sure you want to moderate comments?'), false); 1144 1243 1145 $trans['add']['bookmark'] = array(__('Are you sure you want to add this bookmark?'), false);1146 $trans['delete']['bookmark'] = array(__('Are you sure you want to delete this bookmark: "%s"?'), 'use_id');1147 $trans['update']['bookmark'] = array(__('Are you sure you want to edit this bookmark: "%s"?'), 'use_id');1148 $trans['bulk']['bookmarks'] = array(__('Are you sure you want to bulk modify bookmarks?'), false);1244 $trans['add']['bookmark'] = array(__('Are you sure you want to add this link?'), false); 1245 $trans['delete']['bookmark'] = array(__('Are you sure you want to delete this link: "%s"?'), 'use_id'); 1246 $trans['update']['bookmark'] = array(__('Are you sure you want to edit this link: "%s"?'), 'use_id'); 1247 $trans['bulk']['bookmarks'] = array(__('Are you sure you want to bulk modify links?'), false); 1149 1248 1150 1249 $trans['add']['page'] = array(__('Are you sure you want to add this page?'), false); … … 1216 1315 } 1217 1316 1218 function wp_die( $message, $title = '') {1317 function wp_die( $message, $title = '' ) { 1219 1318 global $wp_locale; 1220 1319 1221 header('Content-Type: text/html; charset=utf-8'); 1222 1223 if ( empty($title) ) 1224 $title = __('WordPress › Error'); 1225 1226 if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') ) 1320 if ( is_wp_error( $message ) ) { 1321 if ( empty($title) ) { 1322 $error_data = $message->get_error_data(); 1323 if ( is_array($error_data) && isset($error_data['title']) ) 1324 $title = $error_data['title']; 1325 } 1326 $errors = $message->get_error_messages(); 1327 switch ( count($errors) ) : 1328 case 0 : 1329 $message = ''; 1330 break; 1331 case 1 : 1332 $message = "<p>{$errors[0]}</p>"; 1333 break; 1334 default : 1335 $message = "<ul>\n\t\t<li>" . join( "</li>\n\t\t<li>", $errors ) . "</li>\n\t</ul>"; 1336 break; 1337 endswitch; 1338 } elseif ( is_string($message) ) { 1339 $message = "<p>$message</p>"; 1340 } 1341 1342 if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) 1227 1343 $admin_dir = ''; 1228 1344 else 1229 1345 $admin_dir = 'wp-admin/'; 1346 1347 if ( !did_action('admin_head') ) : 1348 header('Content-Type: text/html; charset=utf-8'); 1349 1350 if ( empty($title) ) 1351 $title = __('WordPress › Error'); 1352 1353 1230 1354 1231 1355 ?> … … 1236 1360 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 1237 1361 <link rel="stylesheet" href="<?php echo $admin_dir; ?>install.css" type="text/css" /> 1238 <?php if ( ('rtl' == $wp_locale->text_direction) ) : ?> 1362 <?php 1363 if ( ( $wp_locale ) && ('rtl' == $wp_locale->text_direction) ) : ?> 1239 1364 <link rel="stylesheet" href="<?php echo $admin_dir; ?>install-rtl.css" type="text/css" /> 1240 1365 <?php endif; ?> 1241 1366 </head> 1242 1367 <body> 1368 <?php endif; ?> 1243 1369 <h1 id="logo"><img alt="WordPress" src="<?php echo $admin_dir; ?>images/wordpress-logo.png" /></h1> 1244 <p><?php echo $message; ?></p> 1370 <?php echo $message; ?> 1371 1245 1372 </body> 1246 1373 </html> 1247 1374 <?php 1248 1249 1375 die(); 1376 } 1377 1378 function _config_wp_home($url = '') { 1379 if ( defined( 'WP_HOME' ) ) 1380 return WP_HOME; 1381 else return $url; 1382 } 1383 1384 function _config_wp_siteurl($url = '') { 1385 if ( defined( 'WP_SITEURL' ) ) 1386 return WP_SITEURL; 1387 else return $url; 1250 1388 } 1251 1389 … … 1278 1416 return $input; 1279 1417 } 1418 1419 function smilies_init() { 1420 global $wpsmiliestrans, $wp_smiliessearch, $wp_smiliesreplace; 1421 1422 // don't bother setting up smilies if they are disabled 1423 if ( !get_option('use_smilies') ) 1424 return; 1425 1426 if (!isset($wpsmiliestrans)) { 1427 $wpsmiliestrans = array( 1428 ':mrgreen:' => 'icon_mrgreen.gif', 1429 ':neutral:' => 'icon_neutral.gif', 1430 ':twisted:' => 'icon_twisted.gif', 1431 ':arrow:' => 'icon_arrow.gif', 1432 ':shock:' => 'icon_eek.gif', 1433 ':smile:' => 'icon_smile.gif', 1434 ':???:' => 'icon_confused.gif', 1435 ':cool:' => 'icon_cool.gif', 1436 ':evil:' => 'icon_evil.gif', 1437 ':grin:' => 'icon_biggrin.gif', 1438 ':idea:' => 'icon_idea.gif', 1439 ':oops:' => 'icon_redface.gif', 1440 ':razz:' => 'icon_razz.gif', 1441 ':roll:' => 'icon_rolleyes.gif', 1442 ':wink:' => 'icon_wink.gif', 1443 ':cry:' => 'icon_cry.gif', 1444 ':eek:' => 'icon_surprised.gif', 1445 ':lol:' => 'icon_lol.gif', 1446 ':mad:' => 'icon_mad.gif', 1447 ':sad:' => 'icon_sad.gif', 1448 '8-)' => 'icon_cool.gif', 1449 '8-O' => 'icon_eek.gif', 1450 ':-(' => 'icon_sad.gif', 1451 ':-)' => 'icon_smile.gif', 1452 ':-?' => 'icon_confused.gif', 1453 ':-D' => 'icon_biggrin.gif', 1454 ':-P' => 'icon_razz.gif', 1455 ':-o' => 'icon_surprised.gif', 1456 ':-x' => 'icon_mad.gif', 1457 ':-|' => 'icon_neutral.gif', 1458 ';-)' => 'icon_wink.gif', 1459 '8)' => 'icon_cool.gif', 1460 '8O' => 'icon_eek.gif', 1461 ':(' => 'icon_sad.gif', 1462 ':)' => 'icon_smile.gif', 1463 ':?' => 'icon_confused.gif', 1464 ':D' => 'icon_biggrin.gif', 1465 ':P' => 'icon_razz.gif', 1466 ':o' => 'icon_surprised.gif', 1467 ':x' => 'icon_mad.gif', 1468 ':|' => 'icon_neutral.gif', 1469 ';)' => 'icon_wink.gif', 1470 ':!:' => 'icon_exclaim.gif', 1471 ':?:' => 'icon_question.gif', 1472 ); 1473 } 1474 1475 $siteurl = get_option('siteurl'); 1476 foreach ( (array) $wpsmiliestrans as $smiley => $img ) { 1477 $wp_smiliessearch[] = '/(\s|^)'.preg_quote($smiley, '/').'(\s|$)/'; 1478 $smiley_masked = htmlspecialchars(trim($smiley), ENT_QUOTES); 1479 $wp_smiliesreplace[] = " <img src='$siteurl/wp-includes/images/smilies/$img' alt='$smiley_masked' class='wp-smiley' /> "; 1480 } 1481 } 1482 1483 function wp_parse_args( $args, $defaults = '' ) { 1484 if ( is_array($args) ) : 1485 $r =& $args; 1486 else : 1487 parse_str( $args, $r ); 1488 if ( get_magic_quotes_gpc() ) 1489 $r = stripslashes_deep( $r ); 1490 endif; 1491 1492 if ( is_array($defaults) ) : 1493 extract($defaults); 1494 extract($r); 1495 return compact(array_keys($defaults)); // only those options defined in $defaults 1496 else : 1497 return $r; 1498 endif; 1499 } 1500 1501 function wp_maybe_load_widgets() { 1502 if ( !function_exists( 'dynamic_sidebar' ) ) { 1503 require_once ABSPATH . WPINC . '/widgets.php'; 1504 add_action( '_admin_menu', 'wp_widgets_add_menu' ); 1505 } 1506 } 1507 1508 function wp_widgets_add_menu() { 1509 global $submenu; 1510 $submenu['themes.php'][7] = array( __( 'Widgets' ), 'edit_themes', 'widgets.php' ); 1511 ksort($submenu['themes.php'], SORT_NUMERIC); 1512 } 1513 1514 // For PHP 5.2, make sure all output buffers are flushed 1515 // before our singletons our destroyed. 1516 function wp_ob_end_flush_all() 1517 { 1518 while ( @ob_end_flush() ); 1519 } 1520 1280 1521 ?> -
tags/2.2/wp-includes/general-template.php
r5468 r5480 22 22 23 23 function get_sidebar() { 24 do_action( 'get_sidebar' ); 24 25 if ( file_exists( TEMPLATEPATH . '/sidebar.php') ) 25 26 load_template( TEMPLATEPATH . '/sidebar.php'); … … 61 62 function bloginfo($show='') { 62 63 $info = get_bloginfo($show); 63 if (!strstr($show, 'url') && //don't filter URLs 64 !strstr($show, 'directory') && 65 !strstr($show, 'home')) { 64 65 // Don't filter URL's. 66 if (strpos($show, 'url') === false || 67 strpos($show, 'directory') === false || 68 strpos($show, 'home') === false) { 66 69 $info = apply_filters('bloginfo', $info, $show); 67 70 $info = convert_chars($info); … … 73 76 } 74 77 75 78 /** 79 * Note: some of these values are DEPRECATED. Meaning they could be 80 * taken out at any time and shouldn't be relied upon. Options 81 * without "// DEPRECATED" are the preferred and recommended ways 82 * to get the information. 83 */ 76 84 function get_bloginfo($show='') { 77 85 78 86 switch($show) { 79 87 case 'url' : 80 case 'home' : 81 case 'siteurl' : 88 case 'home' : // DEPRECATED 89 case 'siteurl' : // DEPRECATED 82 90 $output = get_option('home'); 83 91 break; … … 100 108 $output = get_feed_link('atom'); 101 109 break; 110 case 'comments_atom_url': 111 $output = get_feed_link('comments_atom'); 102 112 case 'comments_rss2_url': 103 113 $output = get_feed_link('comments_rss2'); … … 156 166 $author = get_query_var('author'); 157 167 $author_name = get_query_var('author_name'); 158 $m = (int)get_query_var('m');159 $year = (int)get_query_var('year');160 $monthnum = (int)get_query_var('monthnum');161 $day = (int)get_query_var('day');168 $m = get_query_var('m'); 169 $year = get_query_var('year'); 170 $monthnum = get_query_var('monthnum'); 171 $day = get_query_var('day'); 162 172 $title = ''; 163 173 … … 167 177 if ( !stristr($cat,'-') ) 168 178 $title = apply_filters('single_cat_title', get_the_category_by_ID($cat)); 169 } 170 if ( !empty($category_name) ) { 179 } elseif ( !empty($category_name) ) { 171 180 if ( stristr($category_name,'/') ) { 172 181 $category_name = explode('/',$category_name); … … 193 202 if ( !empty($m) ) { 194 203 $my_year = substr($m, 0, 4); 195 $my_month = $wp_locale->get_month($m); 196 $title = "$my_year $sep $my_month"; 204 $my_month = $wp_locale->get_month(substr($m, 4, 2)); 205 $my_day = intval(substr($m, 6, 2)); 206 $title = "$my_year" . ($my_month ? "$sep $my_month" : "") . ($my_day ? "$sep $my_day" : ""); 197 207 } 198 208 … … 207 217 // If there is a post 208 218 if ( is_single() || is_page() ) { 209 $queried = $wp_query->get_queried_object(); 210 $title = strip_tags($queried->post_title); 219 $post = $wp_query->get_queried_object(); 211 220 $title = apply_filters('single_post_title', $title); 221 $title = strip_tags($post->post_title); 212 222 } 213 223 … … 263 273 global $wp_locale; 264 274 265 $m = (int)get_query_var('m');266 $year = (int)get_query_var('year');267 $monthnum = (int)get_query_var('monthnum');275 $m = get_query_var('m'); 276 $year = get_query_var('year'); 277 $monthnum = get_query_var('monthnum'); 268 278 269 279 if ( !empty($monthnum) && !empty($year) ) { … … 345 355 $add_minutes = intval(60 * (get_option('gmt_offset') - $add_hours)); 346 356 357 //filters 358 $where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r ); 359 $join = apply_filters('getarchives_join', "", $r); 360 347 361 if ( 'monthly' == $type ) { 348 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);362 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit); 349 363 if ( $arcresults ) { 350 364 $afterafter = $after; … … 358 372 } 359 373 } elseif ('yearly' == $type) { 360 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts WHERE post_type ='post' AND post_status = 'publish'GROUP BY YEAR(post_date) ORDER BY post_date DESC" . $limit);374 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date DESC" . $limit); 361 375 if ($arcresults) { 362 363 364 365 376 $afterafter = $after; 377 foreach ($arcresults as $arcresult) { 378 $url = get_year_link($arcresult->year); 379 $text = sprintf('%d', $arcresult->year); 366 380 if ($show_post_count) 367 368 369 370 } 381 $after = ' ('.$arcresult->posts.')' . $afterafter; 382 echo get_archives_link($url, $text, $format, $before, $after); 383 } 384 } 371 385 } elseif ( 'daily' == $type ) { 372 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC" . $limit);386 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC" . $limit); 373 387 if ( $arcresults ) { 374 388 $afterafter = $after; … … 384 398 } elseif ( 'weekly' == $type ) { 385 399 $start_of_week = get_option('start_of_week'); 386 $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd, count(ID) as posts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'GROUP BY WEEK(post_date, $start_of_week), YEAR(post_date) ORDER BY post_date DESC" . $limit);400 $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY WEEK(post_date, $start_of_week), YEAR(post_date) ORDER BY post_date DESC" . $limit); 387 401 $arc_w_last = ''; 388 402 $afterafter = $after; … … 405 419 } elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) { 406 420 ('alpha' == $type) ? $orderby = "post_title ASC " : $orderby = "post_date DESC "; 407 $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'ORDER BY $orderby $limit");421 $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit"); 408 422 if ( $arcresults ) { 409 423 foreach ( $arcresults as $arcresult ) { … … 412 426 $arc_title = $arcresult->post_title; 413 427 if ( $arc_title ) 414 $text = strip_tags( $arc_title);428 $text = strip_tags(apply_filters('the_title', $arc_title)); 415 429 else 416 430 $text = $arcresult->ID; … … 495 509 LIMIT 1"); 496 510 497 echo '<table id="wp-calendar" >511 echo '<table id="wp-calendar" summary="' . __('Calendar') . '"> 498 512 <caption>' . $wp_locale->get_month($thismonth) . ' ' . date('Y', $unixmonth) . '</caption> 499 513 <thead> … … 557 571 } 558 572 559 560 561 if ( strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') ) 573 if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') !== false) 562 574 $ak_title_separator = "\n"; 563 575 else … … 574 586 if ( $ak_post_titles ) { 575 587 foreach ( $ak_post_titles as $ak_post_title ) { 588 589 $post_title = apply_filters( "the_title", $ak_post_title->post_title ); 590 $post_title = str_replace('"', '"', wptexturize( $post_title )); 591 576 592 if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) ) 577 593 $ak_titles_for_day['day_'.$ak_post_title->dom] = ''; 578 594 if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one 579 $ak_titles_for_day["$ak_post_title->dom"] = str_replace('"', '"', wptexturize($ak_post_title->post_title));595 $ak_titles_for_day["$ak_post_title->dom"] = $post_title; 580 596 else 581 $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . str_replace('"', '"', wptexturize($ak_post_title->post_title));597 $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title; 582 598 } 583 599 } … … 620 636 echo $output; 621 637 $cache[ $key ] = $output; 622 wp_cache_ set( 'get_calendar', $cache, 'calendar' );638 wp_cache_add( 'get_calendar', $cache, 'calendar' ); 623 639 } 624 640 … … 794 810 function user_can_richedit() { 795 811 global $wp_rich_edit, $pagenow; 796 797 if ( !isset($wp_rich_edit) ) 798 $wp_rich_edit = ( 'true' == get_user_option('rich_editing') && !preg_match('!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT']) && 'comment.php' != $pagenow && rich_edit_exists() ) ? true : false; 812 813 if ( !isset( $wp_rich_edit) ) { 814 if ( get_user_option( 'rich_editing' ) == 'true' && 815 ( ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval($match[1]) >= 420 ) || 816 !preg_match( '!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT'] ) ) ) { 817 $wp_rich_edit = true; 818 } else { 819 $wp_rich_edit = false; 820 } 821 } 799 822 800 823 return apply_filters('user_can_richedit', $wp_rich_edit); -
tags/2.2/wp-includes/gettext.php
r5468 r5480 1 1 <?php 2 2 /* 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 3 Copyright (c) 2003 Danilo Segan <danilo@kvota.net>. 4 Copyright (c) 2005 Nico Kaiser <nico@siriux.net> 5 6 This file is part of PHP-gettext. 7 8 PHP-gettext is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2 of the License, or 11 (at your option) any later version. 12 13 PHP-gettext is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with PHP-gettext; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 21 22 22 */ 23 23 24 24 /** 25 25 * Provides a simple gettext replacement that works independently from … … 27 27 * It can read MO files and use them for translating strings. 28 28 * The files are passed to gettext_reader as a Stream (see streams.php) 29 * 29 * 30 30 * This version has the ability to cache all strings and translations to 31 31 * speed up the string lookup. … … 35 35 */ 36 36 class gettext_reader { 37 //public: 38 var $error = 0; // public variable that holds error code (0 if no error) 39 40 //private: 41 var $BYTEORDER = 0; // 0: low endian, 1: big endian 42 var $STREAM = NULL; 43 var $short_circuit = false; 44 var $enable_cache = false; 45 var $originals = NULL; // offset of original table 46 var $translations = NULL; // offset of translation table 47 var $pluralheader = NULL; // cache header field for plural forms 48 var $total = 0; // total string count 49 var $table_originals = NULL; // table for original strings (offsets) 50 var $table_translations = NULL; // table for translated strings (offsets) 51 var $cache_translations = NULL; // original -> translation mapping 52 53 54 /* Methods */ 55 56 57 /** 58 * Reads a 32bit Integer from the Stream 59 * 60 * @access private 61 * @return Integer from the Stream 62 */ 63 function readint() { 64 if ($this->BYTEORDER == 0) { 65 // low endian 66 $low_end = unpack('V', $this->STREAM->read(4)); 67 return array_shift($low_end); 68 } else { 69 // big endian 70 $big_end = unpack('N', $this->STREAM->read(4)); 71 return array_shift($big_end); 72 } 73 } 74 75 /** 76 * Reads an array of Integers from the Stream 77 * 78 * @param int count How many elements should be read 79 * @return Array of Integers 80 */ 81 function readintarray($count) { 82 if ($this->BYTEORDER == 0) { 83 // low endian 84 return unpack('V'.$count, $this->STREAM->read(4 * $count)); 85 } else { 86 // big endian 87 return unpack('N'.$count, $this->STREAM->read(4 * $count)); 88 } 89 } 90 91 /** 92 * Constructor 93 * 94 * @param object Reader the StreamReader object 95 * @param boolean enable_cache Enable or disable caching of strings (default on) 96 */ 97 function gettext_reader($Reader, $enable_cache = true) { 98 // If there isn't a StreamReader, turn on short circuit mode. 99 if (! $Reader || isset($Reader->error) ) { 100 $this->short_circuit = true; 101 return; 102 } 103 104 // Caching can be turned off 105 $this->enable_cache = $enable_cache; 106 107 // $MAGIC1 = (int)0x950412de; //bug in PHP 5.0.2, see https://savannah.nongnu.org/bugs/?func=detailitem&item_id=10565 108 $MAGIC1 = (int) - 1794895138; 109 // $MAGIC2 = (int)0xde120495; //bug 110 $MAGIC2 = (int) - 569244523; 111 112 $this->STREAM = $Reader; 113 $magic = $this->readint(); 114 if ($magic == ($MAGIC1 & 0xFFFFFFFF)) { // to make sure it works for 64-bit platforms 115 $this->BYTEORDER = 0; 116 } elseif ($magic == ($MAGIC2 & 0xFFFFFFFF)) { 117 $this->BYTEORDER = 1; 118 } else { 119 $this->error = 1; // not MO file 120 return false; 121 } 122 123 // FIXME: Do we care about revision? We should. 124 $revision = $this->readint(); 125 126 $this->total = $this->readint(); 127 $this->originals = $this->readint(); 128 $this->translations = $this->readint(); 129 } 130 131 /** 132 * Loads the translation tables from the MO file into the cache 133 * If caching is enabled, also loads all strings into a cache 134 * to speed up translation lookups 135 * 136 * @access private 137 */ 138 function load_tables() { 139 if (is_array($this->cache_translations) && 140 is_array($this->table_originals) && 141 is_array($this->table_translations)) 142 return; 143 144 /* get original and translations tables */ 145 $this->STREAM->seekto($this->originals); 146 $this->table_originals = $this->readintarray($this->total * 2); 147 $this->STREAM->seekto($this->translations); 148 $this->table_translations = $this->readintarray($this->total * 2); 149 150 if ($this->enable_cache) { 151 $this->cache_translations = array (); 152 /* read all strings in the cache */ 153 for ($i = 0; $i < $this->total; $i++) { 154 $this->STREAM->seekto($this->table_originals[$i * 2 + 2]); 155 $original = $this->STREAM->read($this->table_originals[$i * 2 + 1]); 156 $this->STREAM->seekto($this->table_translations[$i * 2 + 2]); 157 $translation = $this->STREAM->read($this->table_translations[$i * 2 + 1]); 158 $this->cache_translations[$original] = $translation; 159 } 160 } 161 } 162 163 /** 164 * Returns a string from the "originals" table 165 * 166 * @access private 167 * @param int num Offset number of original string 168 * @return string Requested string if found, otherwise '' 169 */ 170 function get_original_string($num) { 171 $length = $this->table_originals[$num * 2 + 1]; 172 $offset = $this->table_originals[$num * 2 + 2]; 173 if (! $length) 174 return ''; 175 $this->STREAM->seekto($offset); 176 $data = $this->STREAM->read($length); 177 return (string)$data; 178 } 179 180 /** 181 * Returns a string from the "translations" table 182 * 183 * @access private 184 * @param int num Offset number of original string 185 * @return string Requested string if found, otherwise '' 186 */ 187 function get_translation_string($num) { 188 $length = $this->table_translations[$num * 2 + 1]; 189 $offset = $this->table_translations[$num * 2 + 2]; 190 if (! $length) 191 return ''; 192 $this->STREAM->seekto($offset); 193 $data = $this->STREAM->read($length); 194 return (string)$data; 195 } 196 197 /** 198 * Binary search for string 199 * 200 * @access private 201 * @param string string 202 * @param int start (internally used in recursive function) 203 * @param int end (internally used in recursive function) 204 * @return int string number (offset in originals table) 205 */ 206 function find_string($string, $start = -1, $end = -1) { 207 if (($start == -1) or ($end == -1)) { 208 // find_string is called with only one parameter, set start end end 209 $start = 0; 210 $end = $this->total; 211 } 212 if (abs($start - $end) <= 1) { 213 // We're done, now we either found the string, or it doesn't exist 214 $txt = $this->get_original_string($start); 215 if ($string == $txt) 216 return $start; 217 else 218 return -1; 219 } else if ($start > $end) { 220 // start > end -> turn around and start over 221 return $this->find_string($string, $end, $start); 222 } else { 223 // Divide table in two parts 224 $half = (int)(($start + $end) / 2); 225 $cmp = strcmp($string, $this->get_original_string($half)); 226 if ($cmp == 0) 227 // string is exactly in the middle => return it 228 return $half; 229 else if ($cmp < 0) 230 // The string is in the upper half 231 return $this->find_string($string, $start, $half); 232 else 233 // The string is in the lower half 234 return $this->find_string($string, $half, $end); 235 } 236 } 237 238 /** 239 * Translates a string 240 * 241 * @access public 242 * @param string string to be translated 243 * @return string translated string (or original, if not found) 244 */ 245 function translate($string) { 246 if ($this->short_circuit) 247 return $string; 248 $this->load_tables(); 249 250 if ($this->enable_cache) { 251 // Caching enabled, get translated string from cache 252 if (array_key_exists($string, $this->cache_translations)) 253 return $this->cache_translations[$string]; 254 else 255 return $string; 256 } else { 257 // Caching not enabled, try to find string 258 $num = $this->find_string($string); 259 if ($num == -1) 260 return $string; 261 else 262 return $this->get_translation_string($num); 263 } 264 } 265 266 /** 267 * Get possible plural forms from MO header 268 * 269 * @access private 270 * @return string plural form header 271 */ 272 function get_plural_forms() { 273 // lets assume message number 0 is header 274 // this is true, right? 275 $this->load_tables(); 276 277 // cache header field for plural forms 278 if (! is_string($this->pluralheader)) { 279 if ($this->enable_cache) { 280 $header = $this->cache_translations[""]; 281 } else { 282 $header = $this->get_translation_string(0); 283 } 284 if (eregi("plural-forms: ([^\n]*)\n", $header, $regs)) 285 $expr = $regs[1]; 286 else 287 $expr = "nplurals=2; plural=n == 1 ? 0 : 1;"; 288 $this->pluralheader = $expr; 289 } 290 return $this->pluralheader; 291 } 292 293 /** 294 * Detects which plural form to take 295 * 296 * @access private 297 * @param n count 298 * @return int array index of the right plural form 299 */ 300 function select_string($n) { 301 $string = $this->get_plural_forms(); 302 $string = str_replace('nplurals',"\$total",$string); 303 $string = str_replace("n",$n,$string); 304 $string = str_replace('plural',"\$plural",$string); 305 306 # poEdit doesn't put any semicolons, which 307 # results in parse error in eval 308 $string .= ';'; 309 310 $total = 0; 311 $plural = 0; 312 313 eval("$string"); 314 if ($plural >= $total) $plural = $total - 1; 315 return $plural; 316 } 317 318 /** 319 * Plural version of gettext 320 * 321 * @access public 322 * @param string single 323 * @param string plural 324 * @param string number 325 * @return translated plural form 326 */ 327 function ngettext($single, $plural, $number) { 328 if ($this->short_circuit) { 329 if ($number != 1) 330 return $plural; 331 else 332 return $single; 333 } 334 335 // find out the appropriate form 336 $select = $this->select_string($number); 337 338 // this should contains all strings separated by NULLs 339 $key = $single.chr(0).$plural; 340 341 342 if ($this->enable_cache) { 343 if (! array_key_exists($key, $this->cache_translations)) { 344 return ($number != 1) ? $plural : $single; 345 } else { 346 $result = $this->cache_translations[$key]; 347 $list = explode(chr(0), $result); 348 return $list[$select]; 349 } 350 } else { 351 $num = $this->find_string($key); 352 if ($num == -1) { 353 return ($number != 1) ? $plural : $single; 354 } else { 355 $result = $this->get_translation_string($num); 356 $list = explode(chr(0), $result); 357 return $list[$select]; 358 } 359 } 360 } 37 //public: 38 var $error = 0; // public variable that holds error code (0 if no error) 39 40 //private: 41 var $BYTEORDER = 0; // 0: low endian, 1: big endian 42 var $STREAM = NULL; 43 var $short_circuit = false; 44 var $enable_cache = false; 45 var $originals = NULL; // offset of original table 46 var $translations = NULL; // offset of translation table 47 var $pluralheader = NULL; // cache header field for plural forms 48 var $select_string_function = NULL; // cache function, which chooses plural forms 49 var $total = 0; // total string count 50 var $table_originals = NULL; // table for original strings (offsets) 51 var $table_translations = NULL; // table for translated strings (offsets) 52 var $cache_translations = NULL; // original -> translation mapping 53 54 55 /* Methods */ 56 57 58 /** 59 * Reads a 32bit Integer from the Stream 60 * 61 * @access private 62 * @return Integer from the Stream 63 */ 64 function readint() { 65 if ($this->BYTEORDER == 0) { 66 // low endian 67 $low_end = unpack('V', $this->STREAM->read(4)); 68 return array_shift($low_end); 69 } else { 70 // big endian 71 $big_end = unpack('N', $this->STREAM->read(4)); 72 return array_shift($big_end); 73 } 74 } 75 76 /** 77 * Reads an array of Integers from the Stream 78 * 79 * @param int count How many elements should be read 80 * @return Array of Integers 81 */ 82 function readintarray($count) { 83 if ($this->BYTEORDER == 0) { 84 // low endian 85 return unpack('V'.$count, $this->STREAM->read(4 * $count)); 86 } else { 87 // big endian 88 return unpack('N'.$count, $this->STREAM->read(4 * $count)); 89 } 90 } 91 92 /** 93 * Constructor 94 * 95 * @param object Reader the StreamReader object 96 * @param boolean enable_cache Enable or disable caching of strings (default on) 97 */ 98 function gettext_reader($Reader, $enable_cache = true) { 99 // If there isn't a StreamReader, turn on short circuit mode. 100 if (! $Reader || isset($Reader->error) ) { 101 $this->short_circuit = true; 102 return; 103 } 104 105 // Caching can be turned off 106 $this->enable_cache = $enable_cache; 107 108 // $MAGIC1 = (int)0x950412de; //bug in PHP 5.0.2, see https://savannah.nongnu.org/bugs/?func=detailitem&item_id=10565 109 $MAGIC1 = (int) - 1794895138; 110 // $MAGIC2 = (int)0xde120495; //bug 111 $MAGIC2 = (int) - 569244523; 112 // 64-bit fix 113 $MAGIC3 = (int) 2500072158; 114 115 $this->STREAM = $Reader; 116 $magic = $this->readint(); 117 if ($magic == ($MAGIC1 & 0xFFFFFFFF) || $magic == ($MAGIC3 & 0xFFFFFFFF)) { // to make sure it works for 64-bit platforms 118 $this->BYTEORDER = 0; 119 } elseif ($magic == ($MAGIC2 & 0xFFFFFFFF)) { 120 $this->BYTEORDER = 1; 121 } else { 122 $this->error = 1; // not MO file 123 return false; 124 } 125 126 // FIXME: Do we care about revision? We should. 127 $revision = $this->readint(); 128 129 $this->total = $this->readint(); 130 $this->originals = $this->readint(); 131 $this->translations = $this->readint(); 132 } 133 134 /** 135 * Loads the translation tables from the MO file into the cache 136 * If caching is enabled, also loads all strings into a cache 137 * to speed up translation lookups 138 * 139 * @access private 140 */ 141 function load_tables() { 142 if (is_array($this->cache_translations) && 143 is_array($this->table_originals) && 144 is_array($this->table_translations)) 145 return; 146 147 /* get original and translations tables */ 148 $this->STREAM->seekto($this->originals); 149 $this->table_originals = $this->readintarray($this->total * 2); 150 $this->STREAM->seekto($this->translations); 151 $this->table_translations = $this->readintarray($this->total * 2); 152 153 if ($this->enable_cache) { 154 $this->cache_translations = array (); 155 /* read all strings in the cache */ 156 for ($i = 0; $i < $this->total; $i++) { 157 $this->STREAM->seekto($this->table_originals[$i * 2 + 2]); 158 $original = $this->STREAM->read($this->table_originals[$i * 2 + 1]); 159 $this->STREAM->seekto($this->table_translations[$i * 2 + 2]); 160 $translation = $this->STREAM->read($this->table_translations[$i * 2 + 1]); 161 $this->cache_translations[$original] = $translation; 162 } 163 } 164 } 165 166 /** 167 * Returns a string from the "originals" table 168 * 169 * @access private 170 * @param int num Offset number of original string 171 * @return string Requested string if found, otherwise '' 172 */ 173 function get_original_string($num) { 174 $length = $this->table_originals[$num * 2 + 1]; 175 $offset = $this->table_originals[$num * 2 + 2]; 176 if (! $length) 177 return ''; 178 $this->STREAM->seekto($offset); 179 $data = $this->STREAM->read($length); 180 return (string)$data; 181 } 182 183 /** 184 * Returns a string from the "translations" table 185 * 186 * @access private 187 * @param int num Offset number of original string 188 * @return string Requested string if found, otherwise '' 189 */ 190 function get_translation_string($num) { 191 $length = $this->table_translations[$num * 2 + 1]; 192 $offset = $this->table_translations[$num * 2 + 2]; 193 if (! $length) 194 return ''; 195 $this->STREAM->seekto($offset); 196 $data = $this->STREAM->read($length); 197 return (string)$data; 198 } 199 200 /** 201 * Binary search for string 202 * 203 * @access private 204 * @param string string 205 * @param int start (internally used in recursive function) 206 * @param int end (internally used in recursive function) 207 * @return int string number (offset in originals table) 208 */ 209 function find_string($string, $start = -1, $end = -1) { 210 if (($start == -1) or ($end == -1)) { 211 // find_string is called with only one parameter, set start end end 212 $start = 0; 213 $end = $this->total; 214 } 215 if (abs($start - $end) <= 1) { 216 // We're done, now we either found the string, or it doesn't exist 217 $txt = $this->get_original_string($start); 218 if ($string == $txt) 219 return $start; 220 else 221 return -1; 222 } else if ($start > $end) { 223 // start > end -> turn around and start over 224 return $this->find_string($string, $end, $start); 225 } else { 226 // Divide table in two parts 227 $half = (int)(($start + $end) / 2); 228 $cmp = strcmp($string, $this->get_original_string($half)); 229 if ($cmp == 0) 230 // string is exactly in the middle => return it 231 return $half; 232 else if ($cmp < 0) 233 // The string is in the upper half 234 return $this->find_string($string, $start, $half); 235 else 236 // The string is in the lower half 237 return $this->find_string($string, $half, $end); 238 } 239 } 240 241 /** 242 * Translates a string 243 * 244 * @access public 245 * @param string string to be translated 246 * @return string translated string (or original, if not found) 247 */ 248 function translate($string) { 249 if ($this->short_circuit) 250 return $string; 251 $this->load_tables(); 252 253 if ($this->enable_cache) { 254 // Caching enabled, get translated string from cache 255 if (array_key_exists($string, $this->cache_translations)) 256 return $this->cache_translations[$string]; 257 else 258 return $string; 259 } else { 260 // Caching not enabled, try to find string 261 $num = $this->find_string($string); 262 if ($num == -1) 263 return $string; 264 else 265 return $this->get_translation_string($num); 266 } 267 } 268 269 /** 270 * Get possible plural forms from MO header 271 * 272 * @access private 273 * @return string plural form header 274 */ 275 function get_plural_forms() { 276 // lets assume message number 0 is header 277 // this is true, right? 278 $this->load_tables(); 279 280 // cache header field for plural forms 281 if (! is_string($this->pluralheader)) { 282 if ($this->enable_cache) { 283 $header = $this->cache_translations[""]; 284 } else { 285 $header = $this->get_translation_string(0); 286 } 287 $header .= "\n"; //make sure our regex matches 288 if (eregi("plural-forms: ([^\n]*)\n", $header, $regs)) 289 $expr = $regs[1]; 290 else 291 $expr = "nplurals=2; plural=n == 1 ? 0 : 1;"; 292 293 // add parentheses 294 // important since PHP's ternary evaluates from left to right 295 $expr.= ';'; 296 $res= ''; 297 $p= 0; 298 for ($i= 0; $i < strlen($expr); $i++) { 299 $ch= $expr[$i]; 300 switch ($ch) { 301 case '?': 302 $res.= ' ? ('; 303 $p++; 304 break; 305 case ':': 306 $res.= ') : ('; 307 break; 308 case ';': 309 $res.= str_repeat( ')', $p) . ';'; 310 $p= 0; 311 break; 312 default: 313 $res.= $ch; 314 } 315 } 316 $this->pluralheader = $res; 317 } 318 319 return $this->pluralheader; 320 } 321 322 /** 323 * Detects which plural form to take 324 * 325 * @access private 326 * @param n count 327 * @return int array index of the right plural form 328 */ 329 function select_string($n) { 330 if (is_null($this->select_string_function)) { 331 $string = $this->get_plural_forms(); 332 if (preg_match("/nplurals\s*=\s*(\d+)\s*\;\s*plural\s*=\s*(.*?)\;+/", $string, $matches)) { 333 $nplurals = $matches[1]; 334 $expression = $matches[2]; 335 $expression = str_replace("n", '$n', $expression); 336 } else { 337 $nplurals = 2; 338 $expression = ' $n == 1 ? 0 : 1 '; 339 } 340 $func_body = " 341 \$plural = ($expression); 342 return (\$plural <= $nplurals)? \$plural : \$plural - 1;"; 343 $this->select_string_function = create_function('$n', $func_body); 344 } 345 return call_user_func($this->select_string_function, $n); 346 } 347 348 /** 349 * Plural version of gettext 350 * 351 * @access public 352 * @param string single 353 * @param string plural 354 * @param string number 355 * @return translated plural form 356 */ 357 function ngettext($single, $plural, $number) { 358 if ($this->short_circuit) { 359 if ($number != 1) 360 return $plural; 361 else 362 return $single; 363 } 364 365 // find out the appropriate form 366 $select = $this->select_string($number); 367 368 // this should contains all strings separated by NULLs 369 $key = $single.chr(0).$plural; 370 371 372 if ($this->enable_cache) { 373 if (! array_key_exists($key, $this->cache_translations)) { 374 return ($number != 1) ? $plural : $single; 375 } else { 376 $result = $this->cache_translations[$key]; 377 $list = explode(chr(0), $result); 378 return $list[$select]; 379 } 380 } else { 381 $num = $this->find_string($key); 382 if ($num == -1) { 383 return ($number != 1) ? $plural : $single; 384 } else { 385 $result = $this->get_translation_string($num); 386 $list = explode(chr(0), $result); 387 return $list[$select]; 388 } 389 } 390 } 361 391 362 392 } -
tags/2.2/wp-includes/js/crop/cropper.js
-
Property
svn:eol-style
set to
native
-
Property
svn:eol-style
set to
-
tags/2.2/wp-includes/js/prototype.js
-
Property
svn:eol-style
set to
native
r5468 r5480 1 /* Prototype JavaScript framework, version 1.5.0 _rc02 * (c) 2005 Sam Stephenson <sam@conio.net>1 /* Prototype JavaScript framework, version 1.5.0 2 * (c) 2005-2007 Sam Stephenson 3 3 * 4 4 * Prototype is freely distributable under the terms of an MIT-style license. … … 8 8 9 9 var Prototype = { 10 Version: '1.5.0_rc0', 10 Version: '1.5.0', 11 BrowserFeatures: { 12 XPath: !!document.evaluate 13 }, 14 11 15 ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)', 12 13 16 emptyFunction: function() {}, 14 K: function(x) { return x}17 K: function(x) { return x } 15 18 } 16 19 … … 32 35 } 33 36 34 Object.inspect = function(object) { 35 try { 36 if (object == undefined) return 'undefined'; 37 if (object == null) return 'null'; 38 return object.inspect ? object.inspect() : object.toString(); 39 } catch (e) { 40 if (e instanceof RangeError) return '...'; 41 throw e; 42 } 43 } 37 Object.extend(Object, { 38 inspect: function(object) { 39 try { 40 if (object === undefined) return 'undefined'; 41 if (object === null) return 'null'; 42 return object.inspect ? object.inspect() : object.toString(); 43 } catch (e) { 44 if (e instanceof RangeError) return '...'; 45 throw e; 46 } 47 }, 48 49 keys: function(object) { 50 var keys = []; 51 for (var property in object) 52 keys.push(property); 53 return keys; 54 }, 55 56 values: function(object) { 57 var values = []; 58 for (var property in object) 59 values.push(object[property]); 60 return values; 61 }, 62 63 clone: function(object) { 64 return Object.extend({}, object); 65 } 66 }); 44 67 45 68 Function.prototype.bind = function() { … … 51 74 52 75 Function.prototype.bindAsEventListener = function(object) { 53 var __method = this ;76 var __method = this, args = $A(arguments), object = args.shift(); 54 77 return function(event) { 55 return __method. call(object, event || window.event);78 return __method.apply(object, [( event || window.event)].concat(args).concat($A(arguments))); 56 79 } 57 80 } … … 78 101 var returnValue; 79 102 80 for (var i = 0 ; i < arguments.length; i++) {103 for (var i = 0, length = arguments.length; i < length; i++) { 81 104 var lambda = arguments[i]; 82 105 try { … … 103 126 104 127 registerCallback: function() { 105 setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); 128 this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); 129 }, 130 131 stop: function() { 132 if (!this.timer) return; 133 clearInterval(this.timer); 134 this.timer = null; 106 135 }, 107 136 … … 110 139 try { 111 140 this.currentlyExecuting = true; 112 this.callback( );141 this.callback(this); 113 142 } finally { 114 143 this.currentlyExecuting = false; … … 117 146 } 118 147 } 148 String.interpret = function(value){ 149 return value == null ? '' : String(value); 150 } 151 119 152 Object.extend(String.prototype, { 120 153 gsub: function(pattern, replacement) { … … 125 158 if (match = source.match(pattern)) { 126 159 result += source.slice(0, match.index); 127 result += (replacement(match) || '').toString();160 result += String.interpret(replacement(match)); 128 161 source = source.slice(match.index + match[0].length); 129 162 } else { … … 190 223 var div = document.createElement('div'); 191 224 div.innerHTML = this.stripTags(); 192 return div.childNodes[0] ? div.childNodes[0].nodeValue : ''; 193 }, 194 195 toQueryParams: function() { 196 var pairs = this.match(/^\??(.*)$/)[1].split('&'); 197 return pairs.inject({}, function(params, pairString) { 198 var pair = pairString.split('='); 199 params[pair[0]] = pair[1]; 200 return params; 225 return div.childNodes[0] ? (div.childNodes.length > 1 ? 226 $A(div.childNodes).inject('',function(memo,node){ return memo+node.nodeValue }) : 227 div.childNodes[0].nodeValue) : ''; 228 }, 229 230 toQueryParams: function(separator) { 231 var match = this.strip().match(/([^?#]*)(#.*)?$/); 232 if (!match) return {}; 233 234 return match[1].split(separator || '&').inject({}, function(hash, pair) { 235 if ((pair = pair.split('='))[0]) { 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); 243 } 244 else hash[name] = value; 245 } 246 return hash; 201 247 }); 202 248 }, … … 206 252 }, 207 253 254 succ: function() { 255 return this.slice(0, this.length - 1) + 256 String.fromCharCode(this.charCodeAt(this.length - 1) + 1); 257 }, 258 208 259 camelize: function() { 209 var oStringList = this.split('-'); 210 if (oStringList.length == 1) return oStringList[0]; 211 212 var camelizedString = this.indexOf('-') == 0 213 ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) 214 : oStringList[0]; 215 216 for (var i = 1, len = oStringList.length; i < len; i++) { 217 var s = oStringList[i]; 218 camelizedString += s.charAt(0).toUpperCase() + s.substring(1); 219 } 220 221 return camelizedString; 222 }, 223 224 inspect: function() { 225 return "'" + this.replace(/\\/g, '\\\\').replace(/'/g, '\\\'') + "'"; 260 var parts = this.split('-'), len = parts.length; 261 if (len == 1) return parts[0]; 262 263 var camelized = this.charAt(0) == '-' 264 ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1) 265 : parts[0]; 266 267 for (var i = 1; i < len; i++) 268 camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1); 269 270 return camelized; 271 }, 272 273 capitalize: function(){ 274 return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); 275 }, 276 277 underscore: function() { 278 return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase(); 279 }, 280 281 dasherize: function() { 282 return this.gsub(/_/,'-'); 283 }, 284 285 inspect: function(useDoubleQuotes) { 286 var escapedString = this.replace(/\\/g, '\\\\'); 287 if (useDoubleQuotes) 288 return '"' + escapedString.replace(/"/g, '\\"') + '"'; 289 else 290 return "'" + escapedString.replace(/'/g, '\\\'') + "'"; 226 291 } 227 292 }); … … 247 312 var before = match[1]; 248 313 if (before == '\\') return match[2]; 249 return before + (object[match[3]] || '').toString();314 return before + String.interpret(object[match[3]]); 250 315 }); 251 316 } … … 269 334 if (e != $break) throw e; 270 335 } 336 return this; 337 }, 338 339 eachSlice: function(number, iterator) { 340 var index = -number, slices = [], array = this.toArray(); 341 while ((index += number) < array.length) 342 slices.push(array.slice(index, index+number)); 343 return slices.map(iterator); 271 344 }, 272 345 … … 281 354 282 355 any: function(iterator) { 283 var result = true;356 var result = false; 284 357 this.each(function(value, index) { 285 358 if (result = !!(iterator || Prototype.K)(value, index)) … … 292 365 var results = []; 293 366 this.each(function(value, index) { 294 results.push( iterator(value, index));367 results.push((iterator || Prototype.K)(value, index)); 295 368 }); 296 369 return results; 297 370 }, 298 371 299 detect: function 372 detect: function(iterator) { 300 373 var result; 301 374 this.each(function(value, index) { … … 338 411 }, 339 412 413 inGroupsOf: function(number, fillWith) { 414 fillWith = fillWith === undefined ? null : fillWith; 415 return this.eachSlice(number, function(slice) { 416 while(slice.length < number) slice.push(fillWith); 417 return slice; 418 }); 419 }, 420 340 421 inject: function(memo, iterator) { 341 422 this.each(function(value, index) { … … 347 428 invoke: function(method) { 348 429 var args = $A(arguments).slice(1); 349 return this. collect(function(value) {430 return this.map(function(value) { 350 431 return value[method].apply(value, args); 351 432 }); … … 399 480 400 481 sortBy: function(iterator) { 401 return this. collect(function(value, index) {482 return this.map(function(value, index) { 402 483 return {value: value, criteria: iterator(value, index)}; 403 484 }).sort(function(left, right) { … … 408 489 409 490 toArray: function() { 410 return this. collect(Prototype.K);491 return this.map(); 411 492 }, 412 493 … … 420 501 return iterator(collections.pluck(index)); 421 502 }); 503 }, 504 505 size: function() { 506 return this.toArray().length; 422 507 }, 423 508 … … 440 525 } else { 441 526 var results = []; 442 for (var i = 0 ; i < iterable.length; i++)527 for (var i = 0, length = iterable.length; i < length; i++) 443 528 results.push(iterable[i]); 444 529 return results; … … 453 538 Object.extend(Array.prototype, { 454 539 _each: function(iterator) { 455 for (var i = 0 ; i < this.length; i++)540 for (var i = 0, length = this.length; i < length; i++) 456 541 iterator(this[i]); 457 542 }, … … 472 557 compact: function() { 473 558 return this.select(function(value) { 474 return value != undefined || value !=null;559 return value != null; 475 560 }); 476 561 }, … … 491 576 492 577 indexOf: function(object) { 493 for (var i = 0 ; i < this.length; i++)578 for (var i = 0, length = this.length; i < length; i++) 494 579 if (this[i] == object) return i; 495 580 return -1; … … 500 585 }, 501 586 587 reduce: function() { 588 return this.length > 1 ? this : this[0]; 589 }, 590 591 uniq: function() { 592 return this.inject([], function(array, value) { 593 return array.include(value) ? array : array.concat([value]); 594 }); 595 }, 596 597 clone: function() { 598 return [].concat(this); 599 }, 600 601 size: function() { 602 return this.length; 603 }, 604 502 605 inspect: function() { 503 606 return '[' + this.map(Object.inspect).join(', ') + ']'; 504 607 } 505 608 }); 506 var Hash = { 609 610 Array.prototype.toArray = Array.prototype.clone; 611 612 function $w(string){ 613 string = string.strip(); 614 return string ? string.split(/\s+/) : []; 615 } 616 617 if(window.opera){ 618 Array.prototype.concat = function(){ 619 var array = []; 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++) 624 array.push(arguments[i][j]); 625 } else { 626 array.push(arguments[i]); 627 } 628 } 629 return array; 630 } 631 } 632 var Hash = function(obj) { 633 Object.extend(this, obj || {}); 634 }; 635 636 Object.extend(Hash, { 637 toQueryString: function(obj) { 638 var parts = []; 639 640 this.prototype._each.call(obj, function(pair) { 641 if (!pair.key) 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 } 654 } 655 if (pair.value == undefined) pair[1] = ''; 656 parts.push(pair.map(encodeURIComponent).join('=')); 657 }); 658 659 return parts.join('&'); 660 } 661 }); 662 663 Object.extend(Hash.prototype, Enumerable); 664 Object.extend(Hash.prototype, { 507 665 _each: function(iterator) { 508 666 for (var key in this) { 509 667 var value = this[key]; 510 if ( typeof value == 'function') continue;668 if (value && value == Hash.prototype[key]) continue; 511 669 512 670 var pair = [key, value]; … … 526 684 527 685 merge: function(hash) { 528 return $H(hash).inject( $H(this), function(mergedHash, pair) {686 return $H(hash).inject(this, function(mergedHash, pair) { 529 687 mergedHash[pair.key] = pair.value; 530 688 return mergedHash; … … 532 690 }, 533 691 692 remove: function() { 693 var result; 694 for(var i = 0, length = arguments.length; i < length; i++) { 695 var value = this[arguments[i]]; 696 if (value !== undefined){ 697 if (result === undefined) result = value; 698 else { 699 if (result.constructor != Array) result = [result]; 700 result.push(value) 701 } 702 } 703 delete this[arguments[i]]; 704 } 705 return result; 706 }, 707 534 708 toQueryString: function() { 535 return this.map(function(pair) { 536 return pair.map(encodeURIComponent).join('='); 537 }).join('&'); 709 return Hash.toQueryString(this); 538 710 }, 539 711 … … 543 715 }).join(', ') + '}>'; 544 716 } 545 } 717 }); 546 718 547 719 function $H(object) { 548 var hash = Object.extend({}, object || {}); 549 Object.extend(hash, Enumerable); 550 Object.extend(hash, Hash); 551 return hash; 552 } 720 if (object && object.constructor == Hash) return object; 721 return new Hash(object); 722 }; 553 723 ObjectRange = Class.create(); 554 724 Object.extend(ObjectRange.prototype, Enumerable); … … 562 732 _each: function(iterator) { 563 733 var value = this.start; 564 do{734 while (this.include(value)) { 565 735 iterator(value); 566 736 value = value.succ(); 567 } while (this.include(value));737 } 568 738 }, 569 739 … … 600 770 }, 601 771 602 register: function(responder ToAdd) {603 if (!this.include(responder ToAdd))604 this.responders.push(responder ToAdd);605 }, 606 607 unregister: function(responder ToRemove) {608 this.responders = this.responders.without(responder ToRemove);772 register: function(responder) { 773 if (!this.include(responder)) 774 this.responders.push(responder); 775 }, 776 777 unregister: function(responder) { 778 this.responders = this.responders.without(responder); 609 779 }, 610 780 611 781 dispatch: function(callback, request, transport, json) { 612 782 this.each(function(responder) { 613 if ( responder[callback] &&typeof responder[callback] == 'function') {783 if (typeof responder[callback] == 'function') { 614 784 try { 615 785 responder[callback].apply(responder, [request, transport, json]); … … 626 796 Ajax.activeRequestCount++; 627 797 }, 628 629 798 onComplete: function() { 630 799 Ajax.activeRequestCount--; … … 639 808 asynchronous: true, 640 809 contentType: 'application/x-www-form-urlencoded', 810 encoding: 'UTF-8', 641 811 parameters: '' 642 812 } 643 813 Object.extend(this.options, options || {}); 644 }, 645 646 responseIsSuccess: function() { 647 return this.transport.status == undefined 648 || this.transport.status == 0 649 || (this.transport.status >= 200 && this.transport.status < 300); 650 }, 651 652 responseIsFailure: function() { 653 return !this.responseIsSuccess(); 814 815 this.options.method = this.options.method.toLowerCase(); 816 if (typeof this.options.parameters == 'string') 817 this.options.parameters = this.options.parameters.toQueryParams(); 654 818 } 655 819 } … … 660 824 661 825 Ajax.Request.prototype = Object.extend(new Ajax.Base(), { 826 _complete: false, 827 662 828 initialize: function(url, options) { 663 829 this.transport = Ajax.getTransport(); … … 667 833 668 834 request: function(url) { 669 var parameters = this.options.parameters || ''; 670 if (parameters.length > 0) parameters += '&_='; 835 this.url = url; 836 this.method = this.options.method; 837 var params = this.options.parameters; 838 839 if (!['get', 'post'].include(this.method)) { 840 // simulate other verbs over post 841 params['_method'] = this.method; 842 this.method = 'post'; 843 } 844 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; 671 851 672 852 try { 673 this.url = url;674 if (this.options.method == 'get' && parameters.length > 0)675 this.url += (this.url.match(/\?/) ? '&' : '?') + parameters;676 677 853 Ajax.Responders.dispatch('onCreate', this, this.transport); 678 854 679 this.transport.open(this. options.method, this.url,855 this.transport.open(this.method.toUpperCase(), this.url, 680 856 this.options.asynchronous); 681 857 682 if (this.options.asynchronous) { 683 this.transport.onreadystatechange = this.onStateChange.bind(this); 684 setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10); 858 if (this.options.asynchronous) 859 setTimeout(function() { this.respondToReadyState(1) }.bind(this), 10); 860 861 this.transport.onreadystatechange = this.onStateChange.bind(this); 862 this.setRequestHeaders(); 863 864 var body = this.method == 'post' ? (this.options.postBody || params) : null; 865 866 this.transport.send(body); 867 868 /* Force Firefox to handle ready state 4 for synchronous requests */ 869 if (!this.options.asynchronous && this.transport.overrideMimeType) 870 this.onStateChange(); 871 872 } 873 catch (e) { 874 this.dispatchException(e); 875 } 876 }, 877 878 onStateChange: function() { 879 var readyState = this.transport.readyState; 880 if (readyState > 1 && !((readyState == 4) && this._complete)) 881 this.respondToReadyState(this.transport.readyState); 882 }, 883 884 setRequestHeaders: function() { 885 var headers = { 886 'X-Requested-With': 'XMLHttpRequest', 887 'X-Prototype-Version': Prototype.Version, 888 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*' 889 }; 890 891 if (this.method == 'post') { 892 headers['Content-type'] = this.options.contentType + 893 (this.options.encoding ? '; charset=' + this.options.encoding : ''); 894 895 /* Force "Connection: close" for older Mozilla browsers to work 896 * around a bug where XMLHttpRequest sends an incorrect 897 * Content-length header. See Mozilla Bugzilla #246651. 898 */ 899 if (this.transport.overrideMimeType && 900 (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) 901 headers['Connection'] = 'close'; 902 } 903 904 // user-defined headers 905 if (typeof this.options.requestHeaders == 'object') { 906 var extras = this.options.requestHeaders; 907 908 if (typeof extras.push == 'function') 909 for (var i = 0, length = extras.length; i < length; i += 2) 910 headers[extras[i]] = extras[i+1]; 911 else 912 $H(extras).each(function(pair) { headers[pair.key] = pair.value }); 913 } 914 915 for (var name in headers) 916 this.transport.setRequestHeader(name, headers[name]); 917 }, 918 919 success: function() { 920 return !this.transport.status 921 || (this.transport.status >= 200 && this.transport.status < 300); 922 }, 923 924 respondToReadyState: function(readyState) { 925 var state = Ajax.Request.Events[readyState]; 926 var transport = this.transport, json = this.evalJSON(); 927 928 if (state == 'Complete') { 929 try { 930 this._complete = true; 931 (this.options['on' + this.transport.status] 932 || this.options['on' + (this.success() ? 'Success' : 'Failure')] 933 || Prototype.emptyFunction)(transport, json); 934 } catch (e) { 935 this.dispatchException(e); 685 936 } 686 937 687 this.setRequestHeaders(); 688 689 var body = this.options.postBody ? this.options.postBody : parameters; 690 this.transport.send(this.options.method == 'post' ? body : null); 691 938 if ((this.getHeader('Content-type') || 'text/javascript').strip(). 939 match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i)) 940 this.evalResponse(); 941 } 942 943 try { 944 (this.options['on' + state] || Prototype.emptyFunction)(transport, json); 945 Ajax.Responders.dispatch('on' + state, this, transport, json); 692 946 } catch (e) { 693 947 this.dispatchException(e); 694 948 } 695 }, 696 697 setRequestHeaders: function() { 698 var requestHeaders = 699 ['X-Requested-With', 'XMLHttpRequest', 700 'X-Prototype-Version', Prototype.Version, 701 'Accept', 'text/javascript, text/html, application/xml, text/xml, */*']; 702 703 if (this.options.method == 'post') { 704 requestHeaders.push('Content-type', this.options.contentType); 705 706 /* Force "Connection: close" for Mozilla browsers to work around 707 * a bug where XMLHttpReqeuest sends an incorrect Content-length 708 * header. See Mozilla Bugzilla #246651. 709 */ 710 if (this.transport.overrideMimeType) 711 requestHeaders.push('Connection', 'close'); 712 } 713 714 if (this.options.requestHeaders) 715 requestHeaders.push.apply(requestHeaders, this.options.requestHeaders); 716 717 for (var i = 0; i < requestHeaders.length; i += 2) 718 this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]); 719 }, 720 721 onStateChange: function() { 722 var readyState = this.transport.readyState; 723 if (readyState != 1) 724 this.respondToReadyState(this.transport.readyState); 725 }, 726 727 header: function(name) { 949 950 if (state == 'Complete') { 951 // avoid memory leak in MSIE: clean up 952 this.transport.onreadystatechange = Prototype.emptyFunction; 953 } 954 }, 955 956 getHeader: function(name) { 728 957 try { 729 958 return this.transport.getResponseHeader(name); 730 } catch (e) { }959 } catch (e) { return null } 731 960 }, 732 961 733 962 evalJSON: function() { 734 963 try { 735 return eval('(' + this.header('X-JSON') + ')'); 736 } catch (e) {} 964 var json = this.getHeader('X-JSON'); 965 return json ? eval('(' + json + ')') : null; 966 } catch (e) { return null } 737 967 }, 738 968 … … 745 975 }, 746 976 747 respondToReadyState: function(readyState) {748 var event = Ajax.Request.Events[readyState];749 var transport = this.transport, json = this.evalJSON();750 751 if (event == 'Complete') {752 try {753 (this.options['on' + this.transport.status]754 || this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')]755 || Prototype.emptyFunction)(transport, json);756 } catch (e) {757 this.dispatchException(e);758 }759 760 if ((this.header('Content-type') || '').match(/^text\/javascript/i))761 this.evalResponse();762 }763 764 try {765 (this.options['on' + event] || Prototype.emptyFunction)(transport, json);766 Ajax.Responders.dispatch('on' + event, this, transport, json);767 } catch (e) {768 this.dispatchException(e);769 }770 771 /* Avoid memory leak in MSIE: clean up the oncomplete event handler */772 if (event == 'Complete')773 this.transport.onreadystatechange = Prototype.emptyFunction;774 },775 776 977 dispatchException: function(exception) { 777 978 (this.options.onException || Prototype.emptyFunction)(this, exception); … … 784 985 Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), { 785 986 initialize: function(container, url, options) { 786 this.containers = { 787 success: container.success ? $(container.success) : $(container), 788 failure: container.failure ? $(container.failure) : 789 (container.success ? null : $(container)) 987 this.container = { 988 success: (container.success || container), 989 failure: (container.failure || (container.success ? null : container)) 790 990 } 791 991 … … 794 994 795 995 var onComplete = this.options.onComplete || Prototype.emptyFunction; 796 this.options.onComplete = (function(transport, object) {996 this.options.onComplete = (function(transport, param) { 797 997 this.updateContent(); 798 onComplete(transport, object);998 onComplete(transport, param); 799 999 }).bind(this); 800 1000 … … 803 1003 804 1004 updateContent: function() { 805 var receiver = this.responseIsSuccess() ? 806 this.containers.success : this.containers.failure; 1005 var receiver = this.container[this.success() ? 'success' : 'failure']; 807 1006 var response = this.transport.responseText; 808 1007 809 if (!this.options.evalScripts) 810 response = response.stripScripts(); 811 812 if (receiver) { 813 if (this.options.insertion) { 1008 if (!this.options.evalScripts) response = response.stripScripts(); 1009 1010 if (receiver = $(receiver)) { 1011 if (this.options.insertion) 814 1012 new this.options.insertion(receiver, response); 815 } else { 816 Element.update(receiver, response); 817 } 818 } 819 820 if (this.responseIsSuccess()) { 1013 else 1014 receiver.update(response); 1015 } 1016 1017 if (this.success()) { 821 1018 if (this.onComplete) 822 1019 setTimeout(this.onComplete.bind(this), 10); … … 847 1044 848 1045 stop: function() { 849 this.updater.o nComplete = undefined;1046 this.updater.options.onComplete = undefined; 850 1047 clearTimeout(this.timer); 851 1048 (this.onComplete || Prototype.emptyFunction).apply(this, arguments); … … 867 1064 } 868 1065 }); 869 function $() { 870 var results = [], element; 871 for (var i = 0; i < arguments.length; i++) { 872 element = arguments[i]; 873 if (typeof element == 'string') 874 element = document.getElementById(element); 875 results.push(Element.extend(element)); 876 } 877 return results.length < 2 ? results[0] : results; 1066 function $(element) { 1067 if (arguments.length > 1) { 1068 for (var i = 0, elements = [], length = arguments.length; i < length; i++) 1069 elements.push($(arguments[i])); 1070 return elements; 1071 } 1072 if (typeof element == 'string') 1073 element = document.getElementById(element); 1074 return Element.extend(element); 1075 } 1076 1077 if (Prototype.BrowserFeatures.XPath) { 1078 document._getElementsByXPath = function(expression, parentElement) { 1079 var results = []; 1080 var query = document.evaluate(expression, $(parentElement) || document, 1081 null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); 1082 for (var i = 0, length = query.snapshotLength; i < length; i++) 1083 results.push(query.snapshotItem(i)); 1084 return results; 1085 }; 878 1086 } 879 1087 880 1088 document.getElementsByClassName = function(className, parentElement) { 881 var children = ($(parentElement) || document.body).getElementsByTagName('*'); 882 return $A(children).inject([], function(elements, child) { 883 if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) 884 elements.push(Element.extend(child)); 1089 if (Prototype.BrowserFeatures.XPath) { 1090 var q = ".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]"; 1091 return document._getElementsByXPath(q, parentElement); 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 } 885 1100 return elements; 886 } );887 } 1101 } 1102 }; 888 1103 889 1104 /*--------------------------------------------------------------------------*/ … … 893 1108 894 1109 Element.extend = function(element) { 895 if (!element) return; 896 if (_nativeExtensions) return element; 1110 if (!element || _nativeExtensions || element.nodeType == 3) return element; 897 1111 898 1112 if (!element._extended && element.tagName && element != window) { 899 var methods = Element.Methods, cache = Element.extend.cache; 900 for (property in methods) { 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 1120 Object.extend(methods, Element.Methods.Simulated); 1121 1122 for (var property in methods) { 901 1123 var value = methods[property]; 902 if (typeof value == 'function' )1124 if (typeof value == 'function' && !(property in element)) 903 1125 element[property] = cache.findOrStore(value); 904 1126 } … … 907 1129 element._extended = true; 908 1130 return element; 909 } 1131 }; 910 1132 911 1133 Element.extend.cache = { … … 915 1137 } 916 1138 } 917 } 1139 }; 918 1140 919 1141 Element.Methods = { … … 922 1144 }, 923 1145 924 toggle: function() { 925 for (var i = 0; i < arguments.length; i++) { 926 var element = $(arguments[i]); 927 Element[Element.visible(element) ? 'hide' : 'show'](element); 928 } 929 }, 930 931 hide: function() { 932 for (var i = 0; i < arguments.length; i++) { 933 var element = $(arguments[i]); 934 element.style.display = 'none'; 935 } 936 }, 937 938 show: function() { 939 for (var i = 0; i < arguments.length; i++) { 940 var element = $(arguments[i]); 941 element.style.display = ''; 942 } 1146 toggle: function(element) { 1147 element = $(element); 1148 Element[Element.visible(element) ? 'hide' : 'show'](element); 1149 return element; 1150 }, 1151 1152 hide: function(element) { 1153 $(element).style.display = 'none'; 1154 return element; 1155 }, 1156 1157 show: function(element) { 1158 $(element).style.display = ''; 1159 return element; 943 1160 }, 944 1161 … … 946 1163 element = $(element); 947 1164 element.parentNode.removeChild(element); 1165 return element; 948 1166 }, 949 1167 950 1168 update: function(element, html) { 1169 html = typeof html == 'undefined' ? '' : html.toString(); 951 1170 $(element).innerHTML = html.stripScripts(); 952 1171 setTimeout(function() {html.evalScripts()}, 10); 1172 return element; 953 1173 }, 954 1174 955 1175 replace: function(element, html) { 956 1176 element = $(element); 1177 html = typeof html == 'undefined' ? '' : html.toString(); 957 1178 if (element.outerHTML) { 958 1179 element.outerHTML = html.stripScripts(); … … 964 1185 } 965 1186 setTimeout(function() {html.evalScripts()}, 10); 1187 return element; 1188 }, 1189 1190 inspect: function(element) { 1191 element = $(element); 1192 var result = '<' + element.tagName.toLowerCase(); 1193 $H({'id': 'id', 'className': 'class'}).each(function(pair) { 1194 var property = pair.first(), attribute = pair.last(); 1195 var value = (element[property] || '').toString(); 1196 if (value) result += ' ' + attribute + '=' + value.inspect(true); 1197 }); 1198 return result + '>'; 1199 }, 1200 1201 recursivelyCollect: function(element, property) { 1202 element = $(element); 1203 var elements = []; 1204 while (element = element[property]) 1205 if (element.nodeType == 1) 1206 elements.push(Element.extend(element)); 1207 return elements; 1208 }, 1209 1210 ancestors: function(element) { 1211 return $(element).recursivelyCollect('parentNode'); 1212 }, 1213 1214 descendants: function(element) { 1215 return $A($(element).getElementsByTagName('*')); 1216 }, 1217 1218 immediateDescendants: function(element) { 1219 if (!(element = $(element).firstChild)) return []; 1220 while (element && element.nodeType != 1) element = element.nextSibling; 1221 if (element) return [element].concat($(element).nextSiblings()); 1222 return []; 1223 }, 1224 1225 previousSiblings: function(element) { 1226 return $(element).recursivelyCollect('previousSibling'); 1227 }, 1228 1229 nextSiblings: function(element) { 1230 return $(element).recursivelyCollect('nextSibling'); 1231 }, 1232 1233 siblings: function(element) { 1234 element = $(element); 1235 return element.previousSiblings().reverse().concat(element.nextSiblings()); 1236 }, 1237 1238 match: function(element, selector) { 1239 if (typeof selector == 'string') 1240 selector = new Selector(selector); 1241 return selector.match($(element)); 1242 }, 1243 1244 up: function(element, expression, index) { 1245 return Selector.findElement($(element).ancestors(), expression, index); 1246 }, 1247 1248 down: function(element, expression, index) { 1249 return Selector.findElement($(element).descendants(), expression, index); 1250 }, 1251 1252 previous: function(element, expression, index) { 1253 return Selector.findElement($(element).previousSiblings(), expression, index); 1254 }, 1255 1256 next: function(element, expression, index) { 1257 return Selector.findElement($(element).nextSiblings(), expression, index); 1258 }, 1259 1260 getElementsBySelector: function() { 1261 var args = $A(arguments), element = $(args.shift()); 1262 return Selector.findChildElements(element, args); 1263 }, 1264 1265 getElementsByClassName: function(element, className) { 1266 return document.getElementsByClassName(className, element); 1267 }, 1268 1269 readAttribute: function(element, name) { 1270 element = $(element); 1271 if (document.all && !window.opera) { 1272 var t = Element._attributeTranslations; 1273 if (t.values[name]) return t.values[name](element, name); 1274 if (t.names[name]) name = t.names[name]; 1275 var attribute = element.attributes[name]; 1276 if(attribute) return attribute.nodeValue; 1277 } 1278 return element.getAttribute(name); 966 1279 }, 967 1280 968 1281 getHeight: function(element) { 969 element = $(element); 970 return element.offsetHeight; 1282 return $(element).getDimensions().height; 1283 }, 1284 1285 getWidth: function(element) { 1286 return $(element).getDimensions().width; 971 1287 }, 972 1288 … … 977 1293 hasClassName: function(element, className) { 978 1294 if (!(element = $(element))) return; 979 return Element.classNames(element).include(className); 1295 var elementClassName = element.className; 1296 if (elementClassName.length == 0) return false; 1297 if (elementClassName == className || 1298 elementClassName.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) 1299 return true; 1300 return false; 980 1301 }, 981 1302 982 1303 addClassName: function(element, className) { 983 1304 if (!(element = $(element))) return; 984 return Element.classNames(element).add(className); 1305 Element.classNames(element).add(className); 1306 return element; 985 1307 }, 986 1308 987 1309 removeClassName: function(element, className) { 988 1310 if (!(element = $(element))) return; 989 return Element.classNames(element).remove(className); 1311 Element.classNames(element).remove(className); 1312 return element; 1313 }, 1314 1315 toggleClassName: function(element, className) { 1316 if (!(element = $(element))) return; 1317 Element.classNames(element)[element.hasClassName(className) ? 'remove' : 'add'](className); 1318 return element; 1319 }, 1320 1321 observe: function() { 1322 Event.observe.apply(Event, arguments); 1323 return $A(arguments).first(); 1324 }, 1325 1326 stopObserving: function() { 1327 Event.stopObserving.apply(Event, arguments); 1328 return $A(arguments).first(); 990 1329 }, 991 1330 … … 993 1332 cleanWhitespace: function(element) { 994 1333 element = $(element); 995 for (var i = 0; i < element.childNodes.length; i++) { 996 var node = element.childNodes[i]; 1334 var node = element.firstChild; 1335 while (node) { 1336 var nextNode = node.nextSibling; 997 1337 if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) 998 Element.remove(node); 999 } 1338 element.removeChild(node); 1339 node = nextNode; 1340 } 1341 return element; 1000 1342 }, 1001 1343 … … 1004 1346 }, 1005 1347 1006 childOf: function(element, ancestor) {1348 descendantOf: function(element, ancestor) { 1007 1349 element = $(element), ancestor = $(ancestor); 1008 1350 while (element = element.parentNode) … … 1013 1355 scrollTo: function(element) { 1014 1356 element = $(element); 1015 var x = element.x ? element.x : element.offsetLeft,1016 y = element.y ? element.y : element.offsetTop;1017 window.scrollTo(x, y);1357 var pos = Position.cumulativeOffset(element); 1358 window.scrollTo(pos[0], pos[1]); 1359 return element; 1018 1360 }, 1019 1361 1020 1362 getStyle: function(element, style) { 1021 1363 element = $(element); 1022 var value = element.style[style.camelize()]; 1364 if (['float','cssFloat'].include(style)) 1365 style = (typeof element.style.styleFloat != 'undefined' ? 'styleFloat' : 'cssFloat'); 1366 style = style.camelize(); 1367 var value = element.style[style]; 1023 1368 if (!value) { 1024 1369 if (document.defaultView && document.defaultView.getComputedStyle) { 1025 1370 var css = document.defaultView.getComputedStyle(element, null); 1026 value = css ? css .getPropertyValue(style): null;1371 value = css ? css[style] : null; 1027 1372 } else if (element.currentStyle) { 1028 value = element.currentStyle[style .camelize()];1373 value = element.currentStyle[style]; 1029 1374 } 1030 1375 } 1376 1377 if((value == 'auto') && ['width','height'].include(style) && (element.getStyle('display') != 'none')) 1378 value = element['offset'+style.capitalize()] + 'px'; 1031 1379 1032 1380 if (window.opera && ['left', 'top', 'right', 'bottom'].include(style)) 1033 1381 if (Element.getStyle(element, 'position') == 'static') value = 'auto'; 1034 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 } 1035 1388 return value == 'auto' ? null : value; 1036 1389 }, … … 1038 1391 setStyle: function(element, style) { 1039 1392 element = $(element); 1040 for (var name in style) 1041 element.style[name.camelize()] = style[name]; 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 } 1413 return element; 1042 1414 }, 1043 1415 1044 1416 getDimensions: function(element) { 1045 1417 element = $(element); 1046 if (Element.getStyle(element, 'display') != 'none') 1418 var display = $(element).getStyle('display'); 1419 if (display != 'none' && display != null) // Safari bug 1047 1420 return {width: element.offsetWidth, height: element.offsetHeight}; 1048 1421 … … 1052 1425 var originalVisibility = els.visibility; 1053 1426 var originalPosition = els.position; 1427 var originalDisplay = els.display; 1054 1428 els.visibility = 'hidden'; 1055 1429 els.position = 'absolute'; 1056 els.display = ' ';1430 els.display = 'block'; 1057 1431 var originalWidth = element.clientWidth; 1058 1432 var originalHeight = element.clientHeight; 1059 els.display = 'none';1433 els.display = originalDisplay; 1060 1434 els.position = originalPosition; 1061 1435 els.visibility = originalVisibility; … … 1076 1450 } 1077 1451 } 1452 return element; 1078 1453 }, 1079 1454 … … 1088 1463 element.style.right = ''; 1089 1464 } 1465 return element; 1090 1466 }, 1091 1467 1092 1468 makeClipping: function(element) { 1093 1469 element = $(element); 1094 if (element._overflow) return ;1095 element._overflow = element.style.overflow ;1470 if (element._overflow) return element; 1471 element._overflow = element.style.overflow || 'auto'; 1096 1472 if ((Element.getStyle(element, 'overflow') || 'visible') != 'hidden') 1097 1473 element.style.overflow = 'hidden'; 1474 return element; 1098 1475 }, 1099 1476 1100 1477 undoClipping: function(element) { 1101 1478 element = $(element); 1102 if (element._overflow) return; 1103 element.style.overflow = element._overflow; 1104 element._overflow = undefined; 1105 } 1106 } 1479 if (!element._overflow) return element; 1480 element.style.overflow = element._overflow == 'auto' ? '' : element._overflow; 1481 element._overflow = null; 1482 return element; 1483 } 1484 }; 1485 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 1529 }); 1530 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){ 1541 Element.Methods.update = function(element, html) { 1542 element = $(element); 1543 html = typeof html == 'undefined' ? '' : html.toString(); 1544 var tagName = element.tagName.toUpperCase(); 1545 if (['THEAD','TBODY','TR','TD'].include(tagName)) { 1546 var div = document.createElement('div'); 1547 switch (tagName) { 1548 case 'THEAD': 1549 case 'TBODY': 1550 div.innerHTML = '<table><tbody>' + html.stripScripts() + '</tbody></table>'; 1551 depth = 2; 1552 break; 1553 case 'TR': 1554 div.innerHTML = '<table><tbody><tr>' + html.stripScripts() + '</tr></tbody></table>'; 1555 depth = 3; 1556 break; 1557 case 'TD': 1558 div.innerHTML = '<table><tbody><tr><td>' + html.stripScripts() + '</td></tr></tbody></table>'; 1559 depth = 4; 1560 } 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) }); 1568 } else { 1569 element.innerHTML = html.stripScripts(); 1570 } 1571 setTimeout(function() {html.evalScripts()}, 10); 1572 return element; 1573 } 1574 }; 1107 1575 1108 1576 Object.extend(Element, Element.Methods); … … 1110 1578 var _nativeExtensions = false; 1111 1579 1112 if(!HTMLElement && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) { 1113 var HTMLElement = {} 1114 HTMLElement.prototype = document.createElement('div').__proto__; 1115 } 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__; 1586 }); 1116 1587 1117 1588 Element.addMethods = function(methods) { 1118 1589 Object.extend(Element.Methods, methods || {}); 1119 1590 1120 if(typeof HTMLElement != 'undefined') { 1121 var methods = Element.Methods, cache = Element.extend.cache; 1122 for (property in methods) { 1591 function copy(methods, destination, onlyIfAbsent) { 1592 onlyIfAbsent = onlyIfAbsent || false; 1593 var cache = Element.extend.cache; 1594 for (var property in methods) { 1123 1595 var value = methods[property]; 1124 if (typeof value == 'function') 1125 HTMLElement.prototype[property] = cache.findOrStore(value); 1126 } 1596 if (!onlyIfAbsent || !(property in destination)) 1597 destination[property] = cache.findOrStore(value); 1598 } 1599 } 1600 1601 if (typeof HTMLElement != 'undefined') { 1602 copy(Element.Methods, HTMLElement.prototype); 1603 copy(Element.Methods.Simulated, HTMLElement.prototype, true); 1604 copy(Form.Methods, HTMLFormElement.prototype); 1605 [HTMLInputElement, HTMLTextAreaElement, HTMLSelectElement].each(function(klass) { 1606 copy(Form.Element.Methods, klass.prototype); 1607 }); 1127 1608 _nativeExtensions = true; 1128 1609 } 1129 1610 } 1130 1131 Element.addMethods();1132 1611 1133 1612 var Toggle = new Object(); … … 1149 1628 this.element.insertAdjacentHTML(this.adjacency, this.content); 1150 1629 } catch (e) { 1151 var tagName = this.element.tagName.to LowerCase();1152 if ( tagName == 'tbody' || tagName == 'tr') {1630 var tagName = this.element.tagName.toUpperCase(); 1631 if (['TBODY', 'TR'].include(tagName)) { 1153 1632 this.insertContent(this.contentFromAnonymousTable()); 1154 1633 } else { … … 1249 1728 add: function(classNameToAdd) { 1250 1729 if (this.include(classNameToAdd)) return; 1251 this.set( this.toArray().concat(classNameToAdd).join(' '));1730 this.set($A(this).concat(classNameToAdd).join(' ')); 1252 1731 }, 1253 1732 1254 1733 remove: function(classNameToRemove) { 1255 1734 if (!this.include(classNameToRemove)) return; 1256 this.set(this.select(function(className) { 1257 return className != classNameToRemove; 1258 }).join(' ')); 1735 this.set($A(this).without(classNameToRemove).join(' ')); 1259 1736 }, 1260 1737 1261 1738 toString: function() { 1262 return this.toArray().join(' ');1263 } 1264 } 1739 return $A(this).join(' '); 1740 } 1741 }; 1265 1742 1266 1743 Object.extend(Element.ClassNames.prototype, Enumerable); … … 1309 1786 conditions.push('true'); 1310 1787 if (clause = params.id) 1311 conditions.push('element. id== ' + clause.inspect());1788 conditions.push('element.readAttribute("id") == ' + clause.inspect()); 1312 1789 if (clause = params.tagName) 1313 1790 conditions.push('element.tagName.toUpperCase() == ' + clause.inspect()); 1314 1791 if ((clause = params.classNames).length > 0) 1315 for (var i = 0 ; i < clause.length; i++)1316 conditions.push(' Element.hasClassName(element,' + clause[i].inspect() + ')');1792 for (var i = 0, length = clause.length; i < length; i++) 1793 conditions.push('element.hasClassName(' + clause[i].inspect() + ')'); 1317 1794 if (clause = params.attributes) { 1318 1795 clause.each(function(attribute) { 1319 var value = 'element. getAttribute(' + attribute.name.inspect() + ')';1796 var value = 'element.readAttribute(' + attribute.name.inspect() + ')'; 1320 1797 var splitValueBy = function(delimiter) { 1321 1798 return value + ' && ' + value + '.split(' + delimiter.inspect() + ')'; … … 1330 1807 case '!=': conditions.push(value + ' != ' + attribute.value.inspect()); break; 1331 1808 case '': 1332 case undefined: conditions.push( value + ' != null'); break;1809 case undefined: conditions.push('element.hasAttribute(' + attribute.name.inspect() + ')'); break; 1333 1810 default: throw 'Unknown operator ' + attribute.operator + ' in selector'; 1334 1811 } … … 1341 1818 compileMatcher: function() { 1342 1819 this.match = new Function('element', 'if (!element.tagName) return false; \ 1820 element = $(element); \ 1343 1821 return ' + this.buildMatchExpression()); 1344 1822 }, … … 1355 1833 1356 1834 var results = []; 1357 for (var i = 0 ; i < scope.length; i++)1835 for (var i = 0, length = scope.length; i < length; i++) 1358 1836 if (this.match(element = scope[i])) 1359 1837 results.push(Element.extend(element)); … … 1367 1845 } 1368 1846 1847 Object.extend(Selector, { 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 }); 1865 }); 1866 }).flatten(); 1867 } 1868 }); 1869 1369 1870 function $$() { 1370 return $A(arguments).map(function(expression) { 1371 return expression.strip().split(/\s+/).inject([null], function(results, expr) { 1372 var selector = new Selector(expr); 1373 return results.map(selector.findElements.bind(selector)).flatten(); 1374 }); 1375 }).flatten(); 1376 } 1377 var Field = { 1378 clear: function() { 1379 for (var i = 0; i < arguments.length; i++) 1380 $(arguments[i]).value = ''; 1381 }, 1382 1871 return Selector.findChildElements(document, $A(arguments)); 1872 } 1873 var Form = { 1874 reset: function(form) { 1875 $(form).reset(); 1876 return form; 1877 }, 1878 1879 serializeElements: function(elements, getHash) { 1880 var data = elements.inject({}, function(result, element) { 1881 if (!element.disabled && element.name) { 1882 var key = element.name, value = $(element).getValue(); 1883 if (value != undefined) { 1884 if (result[key]) { 1885 if (result[key].constructor != Array) result[key] = [result[key]]; 1886 result[key].push(value); 1887 } 1888 else result[key] = value; 1889 } 1890 } 1891 return result; 1892 }); 1893 1894 return getHash ? data : Hash.toQueryString(data); 1895 } 1896 }; 1897 1898 Form.Methods = { 1899 serialize: function(form, getHash) { 1900 return Form.serializeElements(Form.getElements(form), getHash); 1901 }, 1902 1903 getElements: function(form) { 1904 return $A($(form).getElementsByTagName('*')).inject([], 1905 function(elements, child) { 1906 if (Form.Element.Serializers[child.tagName.toLowerCase()]) 1907 elements.push(Element.extend(child)); 1908 return elements; 1909 } 1910 ); 1911 }, 1912 1913 getInputs: function(form, typeName, name) { 1914 form = $(form); 1915 var inputs = form.getElementsByTagName('input'); 1916 1917 if (!typeName && !name) return $A(inputs).map(Element.extend); 1918 1919 for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) { 1920 var input = inputs[i]; 1921 if ((typeName && input.type != typeName) || (name && input.name != name)) 1922 continue; 1923 matchingInputs.push(Element.extend(input)); 1924 } 1925 1926 return matchingInputs; 1927 }, 1928 1929 disable: function(form) { 1930 form = $(form); 1931 form.getElements().each(function(element) { 1932 element.blur(); 1933 element.disabled = 'true'; 1934 }); 1935 return form; 1936 }, 1937 1938 enable: function(form) { 1939 form = $(form); 1940 form.getElements().each(function(element) { 1941 element.disabled = ''; 1942 }); 1943 return form; 1944 }, 1945 1946 findFirstElement: function(form) { 1947 return $(form).getElements().find(function(element) { 1948 return element.type != 'hidden' && !element.disabled && 1949 ['input', 'select', 'textarea'].include(element.tagName.toLowerCase()); 1950 }); 1951 }, 1952 1953 focusFirstElement: function(form) { 1954 form = $(form); 1955 form.findFirstElement().activate(); 1956 return form; 1957 } 1958 } 1959 1960 Object.extend(Form, Form.Methods); 1961 1962 /*--------------------------------------------------------------------------*/ 1963 1964 Form.Element = { 1383 1965 focus: function(element) { 1384 1966 $(element).focus(); 1385 }, 1386 1387 present: function() { 1388 for (var i = 0; i < arguments.length; i++) 1389 if ($(arguments[i]).value == '') return false; 1390 return true; 1967 return element; 1391 1968 }, 1392 1969 1393 1970 select: function(element) { 1394 1971 $(element).select(); 1972 return element; 1973 } 1974 } 1975 1976 Form.Element.Methods = { 1977 serialize: function(element) { 1978 element = $(element); 1979 if (!element.disabled && element.name) { 1980 var value = element.getValue(); 1981 if (value != undefined) { 1982 var pair = {}; 1983 pair[element.name] = value; 1984 return Hash.toQueryString(pair); 1985 } 1986 } 1987 return ''; 1988 }, 1989 1990 getValue: function(element) { 1991 element = $(element); 1992 var method = element.tagName.toLowerCase(); 1993 return Form.Element.Serializers[method](element); 1994 }, 1995 1996 clear: function(element) { 1997 $(element).value = ''; 1998 return element; 1999 }, 2000 2001 present: function(element) { 2002 return $(element).value != ''; 1395 2003 }, 1396 2004 … … 1398 2006 element = $(element); 1399 2007 element.focus(); 1400 if (element.select) 2008 if (element.select && ( element.tagName.toLowerCase() != 'input' || 2009 !['button', 'reset', 'submit'].include(element.type) ) ) 1401 2010 element.select(); 1402 } 1403 } 2011 return element; 2012 }, 2013 2014 disable: function(element) { 2015 element = $(element); 2016 element.disabled = true; 2017 return element; 2018 }, 2019 2020 enable: function(element) { 2021 element = $(element); 2022 element.blur(); 2023 element.disabled = false; 2024 return element; 2025 } 2026 } 2027 2028 Object.extend(Form.Element, Form.Element.Methods); 2029 var Field = Form.Element; 2030 var $F = Form.Element.getValue; 1404 2031 1405 2032 /*--------------------------------------------------------------------------*/ 1406 1407 var Form = {1408 serialize: function(form) {1409 var elements = Form.getElements($(form));1410 var queryComponents = new Array();1411 1412 for (var i = 0; i < elements.length; i++) {1413 var queryComponent = Form.Element.serialize(elements[i]);1414 if (queryComponent)1415 queryComponents.push(queryComponent);1416 }1417 1418 return queryComponents.join('&');1419 },1420 1421 getElements: function(form) {1422 form = $(form);1423 var elements = new Array();1424 1425 for (var tagName in Form.Element.Serializers) {1426 var tagElements = form.getElementsByTagName(tagName);1427 for (var j = 0; j < tagElements.length; j++)1428 elements.push(tagElements[j]);1429 }1430 return elements;1431 },1432 1433 getInputs: function(form, typeName, name) {1434 form = $(form);1435 var inputs = form.getElementsByTagName('input');1436 1437 if (!typeName && !name)1438 return inputs;1439 1440 var matchingInputs = new Array();1441 for (var i = 0; i < inputs.length; i++) {1442 var input = inputs[i];1443 if ((typeName && input.type != typeName) ||1444 (name && input.name != name))1445 continue;1446 matchingInputs.push(input);1447 }1448 1449 return matchingInputs;1450 },1451 1452 disable: function(form) {1453 var elements = Form.getElements(form);1454 for (var i = 0; i < elements.length; i++) {1455 var element = elements[i];1456 element.blur();1457 element.disabled = 'true';1458 }1459 },1460 1461 enable: function(form) {1462 var elements = Form.getElements(form);1463 for (var i = 0; i < elements.length; i++) {1464 var element = elements[i];1465 element.disabled = '';1466 }1467 },1468 1469 findFirstElement: function(form) {1470 return Form.getElements(form).find(function(element) {1471 return element.type != 'hidden' && !element.disabled &&1472 ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());1473 });1474 },1475 1476 focusFirstElement: function(form) {1477 Field.activate(Form.findFirstElement(form));1478 },1479 1480 reset: function(form) {1481 $(form).reset();1482 }1483 }1484 1485 Form.Element = {1486 serialize: function(element) {1487 element = $(element);1488 var method = element.tagName.toLowerCase();1489 var parameter = Form.Element.Serializers[method](element);1490 1491 if (parameter) {1492 var key = encodeURIComponent(parameter[0]);1493 if (key.length == 0) return;1494 1495 if (parameter[1].constructor != Array)1496 parameter[1] = [parameter[1]];1497 1498 return parameter[1].map(function(value) {1499 return key + '=' + encodeURIComponent(value);1500 }).join('&');1501 }1502 },1503 1504 getValue: function(element) {1505 element = $(element);1506 var method = element.tagName.toLowerCase();1507 var parameter = Form.Element.Serializers[method](element);1508 1509 if (parameter)1510 return parameter[1];1511 }1512 }1513 2033 1514 2034 Form.Element.Serializers = { 1515 2035 input: function(element) { 1516 2036 switch (element.type.toLowerCase()) { 1517 case 'submit':1518 case 'hidden':1519 case 'password':1520 case 'text':1521 return Form.Element.Serializers.textarea(element);1522 2037 case 'checkbox': 1523 2038 case 'radio': 1524 2039 return Form.Element.Serializers.inputSelector(element); 1525 } 1526 return false; 2040 default: 2041 return Form.Element.Serializers.textarea(element); 2042 } 1527 2043 }, 1528 2044 1529 2045 inputSelector: function(element) { 1530 if (element.checked) 1531 return [element.name, element.value]; 2046 return element.checked ? element.value : null; 1532 2047 }, 1533 2048 1534 2049 textarea: function(element) { 1535 return [element.name, element.value];2050 return element.value; 1536 2051 }, 1537 2052 1538 2053 select: function(element) { 1539 return Form.Element.Serializers[element.type == 'select-one' ?2054 return this[element.type == 'select-one' ? 1540 2055 'selectOne' : 'selectMany'](element); 1541 2056 }, 1542 2057 1543 2058 selectOne: function(element) { 1544 var value = '', opt, index = element.selectedIndex; 1545 if (index >= 0) { 1546 opt = element.options[index]; 1547 value = opt.value || opt.text; 1548 } 1549 return [element.name, value]; 2059 var index = element.selectedIndex; 2060 return index >= 0 ? this.optionValue(element.options[index]) : null; 1550 2061 }, 1551 2062 1552 2063 selectMany: function(element) { 1553 var value = []; 1554 for (var i = 0; i < element.length; i++) { 2064 var values, length = element.length; 2065 if (!length) return null; 2066 2067 for (var i = 0, values = []; i < length; i++) { 1555 2068 var opt = element.options[i]; 1556 if (opt.selected) 1557 value.push(opt.value || opt.text);1558 }1559 return [element.name, value];1560 } 1561 } 1562 1563 /*--------------------------------------------------------------------------*/ 1564 1565 var $F = Form.Element.getValue; 2069 if (opt.selected) values.push(this.optionValue(opt)); 2070 } 2071 return values; 2072 }, 2073 2074 optionValue: function(opt) { 2075 // extend element because hasAttribute may not be native 2076 return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text; 2077 } 2078 } 1566 2079 1567 2080 /*--------------------------------------------------------------------------*/ … … 1584 2097 onTimerEvent: function() { 1585 2098 var value = this.getValue(); 1586 if (this.lastValue != value) { 2099 var changed = ('string' == typeof this.lastValue && 'string' == typeof value 2100 ? this.lastValue != value : String(this.lastValue) != String(value)); 2101 if (changed) { 1587 2102 this.callback(this.element, value); 1588 2103 this.lastValue = value; … … 1629 2144 1630 2145 registerFormCallbacks: function() { 1631 var elements = Form.getElements(this.element); 1632 for (var i = 0; i < elements.length; i++) 1633 this.registerCallback(elements[i]); 2146 Form.getElements(this.element).each(this.registerCallback.bind(this)); 1634 2147 }, 1635 2148 … … 1641 2154 Event.observe(element, 'click', this.onElementEvent.bind(this)); 1642 2155 break; 1643 case 'password': 1644 case 'text': 1645 case 'textarea': 1646 case 'select-one': 1647 case 'select-multiple': 2156 default: 1648 2157 Event.observe(element, 'change', this.onElementEvent.bind(this)); 1649 2158 break; … … 1680 2189 KEY_DOWN: 40, 1681 2190 KEY_DELETE: 46, 2191 KEY_HOME: 36, 2192 KEY_END: 35, 2193 KEY_PAGEUP: 33, 2194 KEY_PAGEDOWN: 34, 1682 2195 1683 2196 element: function(event) { … … 1735 2248 unloadCache: function() { 1736 2249 if (!Event.observers) return; 1737 for (var i = 0 ; i < Event.observers.length; i++) {2250 for (var i = 0, length = Event.observers.length; i < length; i++) { 1738 2251 Event.stopObserving.apply(this, Event.observers[i]); 1739 2252 Event.observers[i][0] = null; … … 1743 2256 1744 2257 observe: function(element, name, observer, useCapture) { 1745 varelement = $(element);2258 element = $(element); 1746 2259 useCapture = useCapture || false; 1747 2260 … … 1751 2264 name = 'keydown'; 1752 2265 1753 this._observeAndCache(element, name, observer, useCapture);2266 Event._observeAndCache(element, name, observer, useCapture); 1754 2267 }, 1755 2268 1756 2269 stopObserving: function(element, name, observer, useCapture) { 1757 varelement = $(element);2270 element = $(element); 1758 2271 useCapture = useCapture || false; 1759 2272 … … 1822 2335 element = element.offsetParent; 1823 2336 if (element) { 1824 p = Element.getStyle(element, 'position'); 2337 if(element.tagName=='BODY') break; 2338 var p = Element.getStyle(element, 'position'); 1825 2339 if (p == 'relative' || p == 'absolute') break; 1826 2340 } … … 1878 2392 }, 1879 2393 1880 clone: function(source, target) {1881 source = $(source);1882 target = $(target);1883 target.style.position = 'absolute';1884 var offsets = this.cumulativeOffset(source);1885 target.style.top = offsets[1] + 'px';1886 target.style.left = offsets[0] + 'px';1887 target.style.width = source.offsetWidth + 'px';1888 target.style.height = source.offsetHeight + 'px';1889 },1890 1891 2394 page: function(forElement) { 1892 2395 var valueT = 0, valueL = 0; … … 1905 2408 element = forElement; 1906 2409 do { 1907 valueT -= element.scrollTop || 0; 1908 valueL -= element.scrollLeft || 0; 2410 if (!window.opera || element.tagName=='BODY') { 2411 valueT -= element.scrollTop || 0; 2412 valueL -= element.scrollLeft || 0; 2413 } 1909 2414 } while (element = element.parentNode); 1910 2415 … … 1967 2472 1968 2473 element.style.position = 'absolute'; 1969 element.style.top = top + 'px'; ;1970 element.style.left = left + 'px'; ;1971 element.style.width = width + 'px'; ;1972 element.style.height = height + 'px'; ;2474 element.style.top = top + 'px'; 2475 element.style.left = left + 'px'; 2476 element.style.width = width + 'px'; 2477 element.style.height = height + 'px'; 1973 2478 }, 1974 2479 … … 2007 2512 } 2008 2513 } 2514 2515 Element.addMethods(); -
Property
svn:eol-style
set to
-
tags/2.2/wp-includes/js/quicktags.js
r5468 r5480 169 169 170 170 function edShowLinks() { 171 var tempStr = '<select onchange="edQuickLink(this.options[this.selectedIndex].value, this);"><option value="-1" selected> (Quick Links)</option>';171 var tempStr = '<select onchange="edQuickLink(this.options[this.selectedIndex].value, this);"><option value="-1" selected>' + quicktagsL10n.quickLinks + '</option>'; 172 172 for (i = 0; i < edLinks.length; i++) { 173 173 tempStr += '<option value="' + i + '">' + edLinks[i].display + '</option>'; … … 249 249 } 250 250 if (word == '') { 251 word = prompt( 'Enter a word to look up:', '');251 word = prompt(quicktagsL10n.wordLookup, ''); 252 252 } 253 253 if (word !== null && /^\w[\w ]*$/.test(word)) { … … 261 261 edShowButton(edButtons[i], i); 262 262 } 263 document.write('<input type="button" id="ed_spell" class="ed_button" onclick="edSpell(edCanvas);" title=" Dictionary lookup" value="lookup" />');264 document.write('<input type="button" id="ed_close" class="ed_button" onclick="edCloseAllTags();" title=" Close all open tags" value="Close Tags" />');263 document.write('<input type="button" id="ed_spell" class="ed_button" onclick="edSpell(edCanvas);" title="' + quicktagsL10n.dictionaryLookup + '" value="' + quicktagsL10n.lookup + '" />'); 264 document.write('<input type="button" id="ed_close" class="ed_button" onclick="edCloseAllTags();" title="' + quicktagsL10n.closeAllOpenTags + '" value="' + quicktagsL10n.closeTags + '" />'); 265 265 // edShowLinks(); // disabled by default 266 266 document.write('</div>'); … … 367 367 } 368 368 if (!edCheckOpenTags(i)) { 369 var URL = prompt( 'Enter the URL' ,defaultValue);369 var URL = prompt(quicktagsL10n.enterURL, defaultValue); 370 370 if (URL) { 371 371 edButtons[i].tagStart = '<a href="' + URL + '">'; … … 379 379 380 380 function edInsertImage(myField) { 381 var myValue = prompt( 'Enter the URL of the image', 'http://');381 var myValue = prompt(quicktagsL10n.enterImageURL, 'http://'); 382 382 if (myValue) { 383 383 myValue = '<img src="' 384 384 + myValue 385 + '" alt="' + prompt( 'Enter a description of the image', '')385 + '" alt="' + prompt(quicktagsL10n.enterImageDescription, '') 386 386 + '" />'; 387 387 edInsertContent(myField, myValue); -
tags/2.2/wp-includes/js/scriptaculous/MIT-LICENSE
r5468 r5480 1 Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)1 Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 2 2 3 3 Permission is hereby granted, free of charge, to any person obtaining -
tags/2.2/wp-includes/js/scriptaculous/builder.js
r5468 r5480 1 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 1 // script.aculo.us builder.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) 2 4 // 3 // See scriptaculous.js for full license. 5 // script.aculo.us is freely distributable under the terms of an MIT-style license. 6 // For details, see the script.aculo.us web site: http://script.aculo.us/ 4 7 5 8 var Builder = { … … 34 37 35 38 // see if browser added wrapping tags 36 if(element && (element.tagName != elementName))39 if(element && (element.tagName.toUpperCase() != elementName)) 37 40 element = element.getElementsByTagName(elementName)[0]; 38 41 … … 62 65 element[attr == 'class' ? 'className' : attr] = arguments[1][attr]; 63 66 } 64 if(element.tagName != elementName)67 if(element.tagName.toUpperCase() != elementName) 65 68 element = parentElement.getElementsByTagName(elementName)[0]; 66 69 } … … 76 79 return document.createTextNode(text); 77 80 }, 81 82 ATTR_MAP: { 83 'className': 'class', 84 'htmlFor': 'for' 85 }, 86 78 87 _attributes: function(attributes) { 79 88 var attrs = []; 80 89 for(attribute in attributes) 81 attrs.push((attribute =='className' ? 'class': attribute) +90 attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) + 82 91 '="' + attributes[attribute].toString().escapeHTML() + '"'); 83 92 return attrs.join(" "); … … 98 107 _isStringOrNumber: function(param) { 99 108 return(typeof param=='string' || typeof param=='number'); 109 }, 110 build: function(html) { 111 var element = this.node('div'); 112 $(element).update(html.strip()); 113 return element.down(); 114 }, 115 dump: function(scope) { 116 if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope 117 118 var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " + 119 "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " + 120 "FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+ 121 "KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+ 122 "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+ 123 "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/); 124 125 tags.each( function(tag){ 126 scope[tag] = function() { 127 return Builder.node.apply(Builder, [tag].concat($A(arguments))); 128 } 129 }); 100 130 } 101 131 } -
tags/2.2/wp-includes/js/scriptaculous/controls.js
r5468 r5480 1 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 2 // (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan) 3 // (c) 2005 Jon 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) 4 6 // Contributors: 5 7 // Richard Livsey … … 7 9 // Rob Wills 8 10 // 9 // See scriptaculous.js for full license. 11 // script.aculo.us is freely distributable under the terms of an MIT-style license. 12 // For details, see the script.aculo.us web site: http://script.aculo.us/ 10 13 11 14 // Autocompleter.Base handles all the autocompletion functionality … … 33 36 // useful when one of the tokens is \n (a newline), as it 34 37 // allows smart autocompletion after linebreaks. 38 39 if(typeof Effect == 'undefined') 40 throw("controls.js requires including script.aculo.us' effects.js library"); 35 41 36 42 var Autocompleter = {} … … 46 52 this.entryCount = 0; 47 53 48 if 54 if(this.setOptions) 49 55 this.setOptions(options); 50 56 else … … 56 62 this.options.minChars = this.options.minChars || 1; 57 63 this.options.onShow = this.options.onShow || 58 function(element, update){ 59 if(!update.style.position || update.style.position=='absolute') { 60 update.style.position = 'absolute'; 61 Position.clone(element, update, {setHeight: false, offsetTop: element.offsetHeight}); 62 } 63 Effect.Appear(update,{duration:0.15}); 64 }; 64 function(element, update){ 65 if(!update.style.position || update.style.position=='absolute') { 66 update.style.position = 'absolute'; 67 Position.clone(element, update, { 68 setHeight: false, 69 offsetTop: element.offsetHeight 70 }); 71 } 72 Effect.Appear(update,{duration:0.15}); 73 }; 65 74 this.options.onHide = this.options.onHide || 66 function(element, update){ new Effect.Fade(update,{duration:0.15}) };67 68 if 75 function(element, update){ new Effect.Fade(update,{duration:0.15}) }; 76 77 if(typeof(this.options.tokens) == 'string') 69 78 this.options.tokens = new Array(this.options.tokens); 70 79 … … 95 104 96 105 fixIEOverlapping: function() { 97 Position.clone(this.update, this.iefix );106 Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)}); 98 107 this.iefix.style.zIndex = 1; 99 108 this.update.style.zIndex = 2; … … 203 212 if(this.index > 0) this.index-- 204 213 else this.index = this.entryCount-1; 214 this.getEntry(this.index).scrollIntoView(true); 205 215 }, 206 216 … … 208 218 if(this.index < this.entryCount-1) this.index++ 209 219 else this.index = 0; 220 this.getEntry(this.index).scrollIntoView(false); 210 221 }, 211 222 … … 255 266 this.update.innerHTML = choices; 256 267 Element.cleanWhitespace(this.update); 257 Element.cleanWhitespace(this.update. firstChild);258 259 if(this.update.firstChild && this.update. firstChild.childNodes) {268 Element.cleanWhitespace(this.update.down()); 269 270 if(this.update.firstChild && this.update.down().childNodes) { 260 271 this.entryCount = 261 this.update. firstChild.childNodes.length;272 this.update.down().childNodes.length; 262 273 for (var i = 0; i < this.entryCount; i++) { 263 274 var entry = this.getEntry(i); … … 270 281 271 282 this.stopIndicator(); 272 273 283 this.index = 0; 274 this.render(); 284 285 if(this.entryCount==1 && this.options.autoSelect) { 286 this.selectEntry(); 287 this.hide(); 288 } else { 289 this.render(); 290 } 275 291 } 276 292 }, … … 460 476 461 477 this.options = Object.extend({ 478 paramName: "value", 462 479 okButton: true, 463 480 okText: "ok", … … 532 549 this.createForm(); 533 550 this.element.parentNode.insertBefore(this.form, this.element); 534 Field.scrollFreeActivate(this.editField);551 if (!this.options.loadTextURL) Field.scrollFreeActivate(this.editField); 535 552 // stop the event to avoid a page refresh in Safari 536 553 if (evt) { … … 591 608 textField.obj = this; 592 609 textField.type = "text"; 593 textField.name = "value";610 textField.name = this.options.paramName; 594 611 textField.value = text; 595 612 textField.style.backgroundColor = this.options.highlightcolor; … … 604 621 var textArea = document.createElement("textarea"); 605 622 textArea.obj = this; 606 textArea.name = "value";623 textArea.name = this.options.paramName; 607 624 textArea.value = this.convertHTMLLineBreaks(text); 608 625 textArea.rows = this.options.rows; … … 637 654 this.editField.disabled = false; 638 655 this.editField.value = transport.responseText.stripTags(); 656 Field.scrollFreeActivate(this.editField); 639 657 }, 640 658 onclickCancel: function() { … … 773 791 optionTag = document.createElement("option"); 774 792 optionTag.value = (e instanceof Array) ? e[0] : e; 793 if((typeof this.options.value == 'undefined') && 794 ((e instanceof Array) ? this.element.innerHTML == e[1] : e == optionTag.value)) optionTag.selected = true; 775 795 if(this.options.value==optionTag.value) optionTag.selected = true; 776 796 optionTag.appendChild(document.createTextNode((e instanceof Array) ? e[1] : e)); -
tags/2.2/wp-includes/js/scriptaculous/dragdrop.js
r5468 r5480 1 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 2 // (c) 2005 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz) 1 // script.aculo.us dragdrop.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 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz) 3 5 // 4 // See scriptaculous.js for full license. 5 6 /*--------------------------------------------------------------------------*/ 6 // script.aculo.us is freely distributable under the terms of an MIT-style license. 7 // For details, see the script.aculo.us web site: http://script.aculo.us/ 8 9 if(typeof Effect == 'undefined') 10 throw("dragdrop.js requires including script.aculo.us' effects.js library"); 7 11 8 12 var Droppables = { … … 146 150 147 151 activate: function(draggable) { 148 window.focus(); // allows keypress events if window isn't currently focused, fails for Safari 149 this.activeDraggable = draggable; 152 if(draggable.options.delay) { 153 this._timeout = setTimeout(function() { 154 Draggables._timeout = null; 155 window.focus(); 156 Draggables.activeDraggable = draggable; 157 }.bind(this), draggable.options.delay); 158 } else { 159 window.focus(); // allows keypress events if window isn't currently focused, fails for Safari 160 this.activeDraggable = draggable; 161 } 150 162 }, 151 163 … … 161 173 if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return; 162 174 this._lastPointer = pointer; 175 163 176 this.activeDraggable.updateDrag(event, pointer); 164 177 }, 165 178 166 179 endDrag: function(event) { 180 if(this._timeout) { 181 clearTimeout(this._timeout); 182 this._timeout = null; 183 } 167 184 if(!this.activeDraggable) return; 168 185 this._lastPointer = null; … … 191 208 if(o[eventName]) o[eventName](eventName, draggable, event); 192 209 }); 210 if(draggable.options[eventName]) draggable.options[eventName](draggable, event); 193 211 }, 194 212 … … 205 223 206 224 var Draggable = Class.create(); 225 Draggable._dragging = {}; 226 207 227 Draggable.prototype = { 208 228 initialize: function(element) { 209 var options = Object.extend({229 var defaults = { 210 230 handle: false, 211 starteffect: function(element) {212 element._opacity = Element.getOpacity(element);213 new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});214 },215 231 reverteffect: function(element, top_offset, left_offset) { 216 232 var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02; 217 element._revert = new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur}); 233 new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur, 234 queue: {scope:'_draggable', position:'end'} 235 }); 218 236 }, 219 237 endeffect: function(element) { 220 var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0 221 new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity}); 238 var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0; 239 new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity, 240 queue: {scope:'_draggable', position:'end'}, 241 afterFinish: function(){ 242 Draggable._dragging[element] = false 243 } 244 }); 222 245 }, 223 246 zindex: 1000, … … 226 249 scrollSensitivity: 20, 227 250 scrollSpeed: 15, 228 snap: false // false, or xy or [x,y] or function(x,y){ return [x,y] } 229 }, arguments[1] || {}); 251 snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] } 252 delay: 0 253 }; 254 255 if(!arguments[1] || typeof arguments[1].endeffect == 'undefined') 256 Object.extend(defaults, { 257 starteffect: function(element) { 258 element._opacity = Element.getOpacity(element); 259 Draggable._dragging[element] = true; 260 new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7}); 261 } 262 }); 263 264 var options = Object.extend(defaults, arguments[1] || {}); 230 265 231 266 this.element = $(element); 232 267 233 if(options.handle && (typeof options.handle == 'string')) { 234 var h = Element.childrenWithClassName(this.element, options.handle, true); 235 if(h.length>0) this.handle = h[0]; 236 } 268 if(options.handle && (typeof options.handle == 'string')) 269 this.handle = this.element.down('.'+options.handle, 0); 270 237 271 if(!this.handle) this.handle = $(options.handle); 238 272 if(!this.handle) this.handle = this.element; 239 273 240 if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) 274 if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) { 241 275 options.scroll = $(options.scroll); 276 this._isScrollChild = Element.childOf(this.element, options.scroll); 277 } 242 278 243 279 Element.makePositioned(this.element); // fix IE … … 265 301 266 302 initDrag: function(event) { 303 if(typeof Draggable._dragging[this.element] != 'undefined' && 304 Draggable._dragging[this.element]) return; 267 305 if(Event.isLeftClick(event)) { 268 306 // abort on form elements, fixes a Firefox issue 269 307 var src = Event.element(event); 270 if( src.tagName&& (271 src.tagName=='INPUT' ||272 src.tagName=='SELECT' ||273 src.tagName=='OPTION' ||274 src.tagName=='BUTTON' ||275 src.tagName=='TEXTAREA')) return;308 if((tag_name = src.tagName.toUpperCase()) && ( 309 tag_name=='INPUT' || 310 tag_name=='SELECT' || 311 tag_name=='OPTION' || 312 tag_name=='BUTTON' || 313 tag_name=='TEXTAREA')) return; 276 314 277 if(this.element._revert) {278 this.element._revert.cancel();279 this.element._revert = null;280 }281 282 315 var pointer = [Event.pointerX(event), Event.pointerY(event)]; 283 316 var pos = Position.cumulativeOffset(this.element); … … 315 348 316 349 Draggables.notify('onStart', this, event); 350 317 351 if(this.options.starteffect) this.options.starteffect(this.element); 318 352 }, … … 323 357 Droppables.show(pointer, this.element); 324 358 Draggables.notify('onDrag', this, event); 359 325 360 this.draw(pointer); 326 361 if(this.options.change) this.options.change(this); … … 334 369 } else { 335 370 p = Position.page(this.options.scroll); 336 p[0] += this.options.scroll.scrollLeft ;337 p[1] += this.options.scroll.scrollTop ;371 p[0] += this.options.scroll.scrollLeft + Position.deltaX; 372 p[1] += this.options.scroll.scrollTop + Position.deltaY; 338 373 p.push(p[0]+this.options.scroll.offsetWidth); 339 374 p.push(p[1]+this.options.scroll.offsetHeight); … … 381 416 if(this.options.endeffect) 382 417 this.options.endeffect(this.element); 383 418 384 419 Draggables.deactivate(this); 385 420 Droppables.reset(); … … 401 436 draw: function(point) { 402 437 var pos = Position.cumulativeOffset(this.element); 438 if(this.options.ghosting) { 439 var r = Position.realOffset(this.element); 440 pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY; 441 } 442 403 443 var d = this.currentDelta(); 404 444 pos[0] -= d[0]; pos[1] -= d[1]; 405 445 406 if(this.options.scroll && (this.options.scroll != window )) {446 if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) { 407 447 pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft; 408 448 pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop; … … 431 471 if((!this.options.constraint) || (this.options.constraint=='vertical')) 432 472 style.top = p[1] + "px"; 473 433 474 if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering 434 475 }, … … 443 484 444 485 startScrolling: function(speed) { 486 if(!(speed[0] || speed[1])) return; 445 487 this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed]; 446 488 this.lastScrolled = new Date(); … … 467 509 Droppables.show(Draggables._lastPointer, this.element); 468 510 Draggables.notify('onDrag', this); 469 Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer); 470 Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000; 471 Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000; 472 if (Draggables._lastScrollPointer[0] < 0) 473 Draggables._lastScrollPointer[0] = 0; 474 if (Draggables._lastScrollPointer[1] < 0) 475 Draggables._lastScrollPointer[1] = 0; 476 this.draw(Draggables._lastScrollPointer); 511 if (this._isScrollChild) { 512 Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer); 513 Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000; 514 Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000; 515 if (Draggables._lastScrollPointer[0] < 0) 516 Draggables._lastScrollPointer[0] = 0; 517 if (Draggables._lastScrollPointer[1] < 0) 518 Draggables._lastScrollPointer[1] = 0; 519 this.draw(Draggables._lastScrollPointer); 520 } 477 521 478 522 if(this.options.change) this.options.change(this); … … 526 570 527 571 var Sortable = { 572 SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/, 573 528 574 sortables: {}, 529 575 530 576 _findRootElement: function(element) { 531 while (element.tagName != "BODY") {577 while (element.tagName.toUpperCase() != "BODY") { 532 578 if(element.id && Sortable.sortables[element.id]) return element; 533 579 element = element.parentNode; … … 566 612 handle: false, // or a CSS class 567 613 only: false, 614 delay: 0, 568 615 hoverclass: null, 569 616 ghosting: false, … … 571 618 scrollSensitivity: 20, 572 619 scrollSpeed: 15, 573 format: /^[^_]*_(.*)$/,620 format: this.SERIALIZE_RULE, 574 621 onChange: Prototype.emptyFunction, 575 622 onUpdate: Prototype.emptyFunction … … 585 632 scrollSpeed: options.scrollSpeed, 586 633 scrollSensitivity: options.scrollSensitivity, 634 delay: options.delay, 587 635 ghosting: options.ghosting, 588 636 constraint: options.constraint, … … 613 661 hoverclass: options.hoverclass, 614 662 onHover: Sortable.onHover 615 //greedy: !options.dropOnEmpty616 663 } 617 664 … … 638 685 // handles are per-draggable 639 686 var handle = options.handle ? 640 Element.childrenWithClassName(e, options.handle)[0]: e;687 $(e).down('.'+options.handle,0) : e; 641 688 options.draggables.push( 642 689 new Draggable(e, Object.extend(options_for_draggable, { handle: handle }))); … … 709 756 var index; 710 757 711 var children = Sortable.findElements(dropon, {tag: droponOptions.tag });758 var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only}); 712 759 var child = null; 713 760 … … 736 783 737 784 unmark: function() { 738 if(Sortable._marker) Element.hide(Sortable._marker);785 if(Sortable._marker) Sortable._marker.hide(); 739 786 }, 740 787 … … 745 792 746 793 if(!Sortable._marker) { 747 Sortable._marker = $('dropmarker') || document.createElement('DIV'); 748 Element.hide(Sortable._marker); 749 Element.addClassName(Sortable._marker, 'dropmarker'); 750 Sortable._marker.style.position = 'absolute'; 794 Sortable._marker = 795 ($('dropmarker') || Element.extend(document.createElement('DIV'))). 796 hide().addClassName('dropmarker').setStyle({position:'absolute'}); 751 797 document.getElementsByTagName("body").item(0).appendChild(Sortable._marker); 752 798 } 753 799 var offsets = Position.cumulativeOffset(dropon); 754 Sortable._marker.style.left = offsets[0] + 'px'; 755 Sortable._marker.style.top = offsets[1] + 'px'; 800 Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'}); 756 801 757 802 if(position=='after') 758 803 if(sortable.overlap == 'horizontal') 759 Sortable._marker.s tyle.left = (offsets[0]+dropon.clientWidth) + 'px';804 Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'}); 760 805 else 761 Sortable._marker.s tyle.top = (offsets[1]+dropon.clientHeight) + 'px';762 763 Element.show(Sortable._marker);806 Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'}); 807 808 Sortable._marker.show(); 764 809 }, 765 810 … … 776 821 element: element, 777 822 parent: parent, 778 children: new Array,823 children: [], 779 824 position: parent.children.length, 780 container: Sortable._findChildrenElement(children[i], options.treeTag.toUpperCase())825 container: $(children[i]).down(options.treeTag) 781 826 } 782 827 … … 789 834 790 835 return parent; 791 },792 793 /* Finds the first element of the given tag type within a parent element.794 Used for finding the first LI[ST] within a L[IST]I[TEM].*/795 _findChildrenElement: function (element, containerTag) {796 if (element && element.hasChildNodes)797 for (var i = 0; i < element.childNodes.length; ++i)798 if (element.childNodes[i].tagName == containerTag)799 return element.childNodes[i];800 801 return null;802 836 }, 803 837 … … 816 850 id: null, 817 851 parent: null, 818 children: new Array,852 children: [], 819 853 container: element, 820 854 position: 0 821 855 } 822 856 823 return Sortable._tree 857 return Sortable._tree(element, options, root); 824 858 }, 825 859 … … 870 904 if (options.tree) { 871 905 return Sortable.tree(element, arguments[1]).children.map( function (item) { 872 return [name + Sortable._constructIndex(item) + " =" +906 return [name + Sortable._constructIndex(item) + "[id]=" + 873 907 encodeURIComponent(item.id)].concat(item.children.map(arguments.callee)); 874 908 }).flatten().join('&'); … … 881 915 } 882 916 883 / * Returns true if child is contained within element */917 // Returns true if child is contained within element 884 918 Element.isParent = function(child, element) { 885 919 if (!child.parentNode || child == element) return false; 886 887 920 if (child.parentNode == element) return true; 888 889 921 return Element.isParent(child.parentNode, element); 890 922 } … … 909 941 910 942 Element.offsetSize = function (element, type) { 911 if (type == 'vertical' || type == 'height') 912 return element.offsetHeight; 913 else 914 return element.offsetWidth; 943 return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')]; 915 944 } -
tags/2.2/wp-includes/js/scriptaculous/effects.js
r5468 r5480 1 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 1 // script.aculo.us effects.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) 2 4 // Contributors: 3 5 // Justin Palmer (http://encytemedia.com/) … … 5 7 // Martin Bialasinki 6 8 // 7 // See scriptaculous.js for full license. 9 // script.aculo.us is freely distributable under the terms of an MIT-style license. 10 // For details, see the script.aculo.us web site: http://script.aculo.us/ 8 11 9 12 // converts rgb() and #xxx to #xxxxxx format, 10 13 // returns self (or first argument) if not convertable 11 14 String.prototype.parseColor = function() { 12 var color = '#'; 15 var color = '#'; 13 16 if(this.slice(0,4) == 'rgb(') { 14 17 var cols = this.slice(4,this.length-1).split(','); … … 42 45 Element.setContentZoom = function(element, percent) { 43 46 element = $(element); 44 Element.setStyle(element,{fontSize: (percent/100) + 'em'});47 element.setStyle({fontSize: (percent/100) + 'em'}); 45 48 if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0); 46 } 47 48 Element.getOpacity = function(element){ 49 var opacity; 50 if (opacity = Element.getStyle(element, 'opacity')) 51 return parseFloat(opacity); 52 if (opacity = (Element.getStyle(element, 'filter') || '').match(/alpha\(opacity=(.*)\)/)) 53 if(opacity[1]) return parseFloat(opacity[1]) / 100; 54 return 1.0; 55 } 56 57 Element.setOpacity = function(element, value){ 58 element= $(element); 59 if (value == 1){ 60 Element.setStyle(element, { opacity: 61 (/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 62 0.999999 : null }); 63 if(/MSIE/.test(navigator.userAgent)) 64 Element.setStyle(element, {filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')}); 65 } else { 66 if(value < 0.00001) value = 0; 67 Element.setStyle(element, {opacity: value}); 68 if(/MSIE/.test(navigator.userAgent)) 69 Element.setStyle(element, 70 { filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') + 71 'alpha(opacity='+value*100+')' }); 72 } 73 } 74 75 Element.getInlineOpacity = function(element){ 49 return element; 50 } 51 52 Element.getOpacity = function(element){ 53 return $(element).getStyle('opacity'); 54 } 55 56 Element.setOpacity = function(element, value){ 57 return $(element).setStyle({opacity:value}); 58 } 59 60 Element.getInlineOpacity = function(element){ 76 61 return $(element).style.opacity || ''; 77 }78 79 Element.childrenWithClassName = function(element, className, findFirst) {80 var classNameRegExp = new RegExp("(^|\\s)" + className + "(\\s|$)");81 var results = $A($(element).getElementsByTagName('*'))[findFirst ? 'detect' : 'select']( function(c) {82 return (c.className && c.className.match(classNameRegExp));83 });84 if(!results) results = [];85 return results;86 62 } 87 63 … … 105 81 106 82 var Effect = { 83 _elementDoesNotExistError: { 84 name: 'ElementDoesNotExistError', 85 message: 'The specified DOM element does not exist, but is required for this effect to operate' 86 }, 107 87 tagifyText: function(element) { 88 if(typeof Builder == 'undefined') 89 throw("Effect.tagifyText requires including script.aculo.us' builder.js library"); 90 108 91 var tagifyStyle = 'position:relative'; 109 if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1'; 92 if(/MSIE/.test(navigator.userAgent) && !window.opera) tagifyStyle += ';zoom:1'; 93 110 94 element = $(element); 111 95 $A(element.childNodes).each( function(child) { … … 160 144 /* ------------- transitions ------------- */ 161 145 162 Effect.Transitions = {} 163 164 Effect.Transitions.linear = function(pos) { 165 return pos; 166 } 167 Effect.Transitions.sinoidal = function(pos) { 168 return (-Math.cos(pos*Math.PI)/2) + 0.5; 169 } 170 Effect.Transitions.reverse = function(pos) { 171 return 1-pos; 172 } 173 Effect.Transitions.flicker = function(pos) { 174 return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4; 175 } 176 Effect.Transitions.wobble = function(pos) { 177 return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5; 178 } 179 Effect.Transitions.pulse = function(pos) { 180 return (Math.floor(pos*10) % 2 == 0 ? 181 (pos*10-Math.floor(pos*10)) : 1-(pos*10-Math.floor(pos*10))); 182 } 183 Effect.Transitions.none = function(pos) { 184 return 0; 185 } 186 Effect.Transitions.full = function(pos) { 187 return 1; 188 } 146 Effect.Transitions = { 147 linear: Prototype.K, 148 sinoidal: function(pos) { 149 return (-Math.cos(pos*Math.PI)/2) + 0.5; 150 }, 151 reverse: function(pos) { 152 return 1-pos; 153 }, 154 flicker: function(pos) { 155 return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4; 156 }, 157 wobble: function(pos) { 158 return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5; 159 }, 160 pulse: function(pos, pulses) { 161 pulses = pulses || 5; 162 return ( 163 Math.round((pos % (1/pulses)) * pulses) == 0 ? 164 ((pos * pulses * 2) - Math.floor(pos * pulses * 2)) : 165 1 - ((pos * pulses * 2) - Math.floor(pos * pulses * 2)) 166 ); 167 }, 168 none: function(pos) { 169 return 0; 170 }, 171 full: function(pos) { 172 return 1; 173 } 174 }; 189 175 190 176 /* ------------- core effects ------------- */ … … 213 199 }); 214 200 break; 201 case 'with-last': 202 timestamp = this.effects.pluck('startOn').max() || timestamp; 203 break; 215 204 case 'end': 216 205 // start effect after last queued effect has finished … … 226 215 227 216 if(!this.interval) 228 this.interval = setInterval(this.loop.bind(this), 40);217 this.interval = setInterval(this.loop.bind(this), 15); 229 218 }, 230 219 remove: function(effect) { … … 237 226 loop: function() { 238 227 var timePos = new Date().getTime(); 239 this.effects.invoke('loop', timePos); 228 for(var i=0, len=this.effects.length;i<len;i++) 229 if(this.effects[i]) this.effects[i].loop(timePos); 240 230 } 241 231 }); … … 257 247 transition: Effect.Transitions.sinoidal, 258 248 duration: 1.0, // seconds 259 fps: 25.0, // max. 25fps due to Effect.Queue implementation249 fps: 60.0, // max. 60fps due to Effect.Queue implementation 260 250 sync: false, // true for combining 261 251 from: 0.0, … … 325 315 }, 326 316 inspect: function() { 327 return '#<Effect:' + $H(this).inspect() + ',options:' + $H(this.options).inspect() + '>'; 317 var data = $H(); 318 for(property in this) 319 if(typeof this[property] != 'function') data[property] = this[property]; 320 return '#<Effect:' + data.inspect() + ',options:' + $H(this.options).inspect() + '>'; 328 321 } 329 322 } … … 349 342 }); 350 343 344 Effect.Event = Class.create(); 345 Object.extend(Object.extend(Effect.Event.prototype, Effect.Base.prototype), { 346 initialize: function() { 347 var options = Object.extend({ 348 duration: 0 349 }, arguments[0] || {}); 350 this.start(options); 351 }, 352 update: Prototype.emptyFunction 353 }); 354 351 355 Effect.Opacity = Class.create(); 352 356 Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), { 353 357 initialize: function(element) { 354 358 this.element = $(element); 359 if(!this.element) throw(Effect._elementDoesNotExistError); 355 360 // make this work on IE on elements without 'layout' 356 if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout))361 if(/MSIE/.test(navigator.userAgent) && !window.opera && (!this.element.currentStyle.hasLayout)) 357 362 this.element.setStyle({zoom: 1}); 358 363 var options = Object.extend({ … … 371 376 initialize: function(element) { 372 377 this.element = $(element); 378 if(!this.element) throw(Effect._elementDoesNotExistError); 373 379 var options = Object.extend({ 374 380 x: 0, … … 394 400 update: function(position) { 395 401 this.element.setStyle({ 396 left: this.options.x * position + this.originalLeft+ 'px',397 top: this.options.y * position + this.originalTop+ 'px'402 left: Math.round(this.options.x * position + this.originalLeft) + 'px', 403 top: Math.round(this.options.y * position + this.originalTop) + 'px' 398 404 }); 399 405 } … … 409 415 Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), { 410 416 initialize: function(element, percent) { 411 this.element = $(element) 417 this.element = $(element); 418 if(!this.element) throw(Effect._elementDoesNotExistError); 412 419 var options = Object.extend({ 413 420 scaleX: true, … … 434 441 435 442 var fontSize = this.element.getStyle('font-size') || '100%'; 436 ['em','px','%' ].each( function(fontSizeType) {443 ['em','px','%','pt'].each( function(fontSizeType) { 437 444 if(fontSize.indexOf(fontSizeType)>0) { 438 445 this.fontSize = parseFloat(fontSize); … … 459 466 }, 460 467 finish: function(position) { 461 if 468 if(this.restoreAfterFinish) this.element.setStyle(this.originalStyle); 462 469 }, 463 470 setDimensions: function(height, width) { 464 471 var d = {}; 465 if(this.options.scaleX) d.width = width+ 'px';466 if(this.options.scaleY) d.height = height+ 'px';472 if(this.options.scaleX) d.width = Math.round(width) + 'px'; 473 if(this.options.scaleY) d.height = Math.round(height) + 'px'; 467 474 if(this.options.scaleFromCenter) { 468 475 var topd = (height - this.dims[0])/2; … … 484 491 initialize: function(element) { 485 492 this.element = $(element); 493 if(!this.element) throw(Effect._elementDoesNotExistError); 486 494 var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {}); 487 495 this.start(options); … … 491 499 if(this.element.getStyle('display')=='none') { this.cancel(); return; } 492 500 // Disable background image during the effect 493 this.oldStyle = { 494 backgroundImage: this.element.getStyle('background-image') }; 495 this.element.setStyle({backgroundImage: 'none'}); 501 this.oldStyle = {}; 502 if (!this.options.keepBackgroundImage) { 503 this.oldStyle.backgroundImage = this.element.getStyle('background-image'); 504 this.element.setStyle({backgroundImage: 'none'}); 505 } 496 506 if(!this.options.endcolor) 497 507 this.options.endcolor = this.element.getStyle('background-color').parseColor('#ffffff'); … … 548 558 afterFinishInternal: function(effect) { 549 559 if(effect.options.to!=0) return; 550 effect.element.hide(); 551 effect.element.setStyle({opacity: oldOpacity}); 560 effect.element.hide().setStyle({opacity: oldOpacity}); 552 561 }}, arguments[1] || {}); 553 562 return new Effect.Opacity(element,options); … … 564 573 }, 565 574 beforeSetup: function(effect) { 566 effect.element.setOpacity(effect.options.from); 567 effect.element.show(); 575 effect.element.setOpacity(effect.options.from).show(); 568 576 }}, arguments[1] || {}); 569 577 return new Effect.Opacity(element,options); … … 572 580 Effect.Puff = function(element) { 573 581 element = $(element); 574 var oldStyle = { opacity: element.getInlineOpacity(), position: element.getStyle('position') }; 582 var oldStyle = { 583 opacity: element.getInlineOpacity(), 584 position: element.getStyle('position'), 585 top: element.style.top, 586 left: element.style.left, 587 width: element.style.width, 588 height: element.style.height 589 }; 575 590 return new Effect.Parallel( 576 591 [ new Effect.Scale(element, 200, … … 579 594 Object.extend({ duration: 1.0, 580 595 beforeSetupInternal: function(effect) { 581 effect.effects[0].element.setStyle({position: 'absolute'}); }, 596 Position.absolutize(effect.effects[0].element) 597 }, 582 598 afterFinishInternal: function(effect) { 583 effect.effects[0].element.hide(); 584 effect.effects[0].element.setStyle(oldStyle); } 599 effect.effects[0].element.hide().setStyle(oldStyle); } 585 600 }, arguments[1] || {}) 586 601 ); … … 590 605 element = $(element); 591 606 element.makeClipping(); 592 return new Effect.Scale(element, 0, 607 return new Effect.Scale(element, 0, 593 608 Object.extend({ scaleContent: false, 594 609 scaleX: false, 595 610 restoreAfterFinish: true, 596 611 afterFinishInternal: function(effect) { 597 effect.element.hide(); 598 effect.element.undoClipping(); 612 effect.element.hide().undoClipping(); 599 613 } 600 614 }, arguments[1] || {}) … … 605 619 element = $(element); 606 620 var elementDimensions = element.getDimensions(); 607 return new Effect.Scale(element, 100, 608 Object.extend({ scaleContent: false, 609 scaleX: false, 610 scaleFrom: 0, 611 scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, 612 restoreAfterFinish: true, 613 afterSetup: function(effect) { 614 effect.element.makeClipping(); 615 effect.element.setStyle({height: '0px'}); 616 effect.element.show(); 617 }, 618 afterFinishInternal: function(effect) { 619 effect.element.undoClipping(); 620 } 621 }, arguments[1] || {}) 622 ); 621 return new Effect.Scale(element, 100, Object.extend({ 622 scaleContent: false, 623 scaleX: false, 624 scaleFrom: 0, 625 scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, 626 restoreAfterFinish: true, 627 afterSetup: function(effect) { 628 effect.element.makeClipping().setStyle({height: '0px'}).show(); 629 }, 630 afterFinishInternal: function(effect) { 631 effect.element.undoClipping(); 632 } 633 }, arguments[1] || {})); 623 634 } 624 635 … … 626 637 element = $(element); 627 638 var oldOpacity = element.getInlineOpacity(); 628 return new Effect.Appear(element, {639 return new Effect.Appear(element, Object.extend({ 629 640 duration: 0.4, 630 641 from: 0, … … 635 646 scaleX: false, scaleContent: false, restoreAfterFinish: true, 636 647 beforeSetup: function(effect) { 637 effect.element.makePositioned(); 638 effect.element.makeClipping(); 648 effect.element.makePositioned().makeClipping(); 639 649 }, 640 650 afterFinishInternal: function(effect) { 641 effect.element.hide(); 642 effect.element.undoClipping(); 643 effect.element.undoPositioned(); 644 effect.element.setStyle({opacity: oldOpacity}); 651 effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity}); 645 652 } 646 653 }) 647 654 } 648 } );655 }, arguments[1] || {})); 649 656 } 650 657 … … 664 671 }, 665 672 afterFinishInternal: function(effect) { 666 effect.effects[0].element.hide(); 667 effect.effects[0].element.undoPositioned(); 668 effect.effects[0].element.setStyle(oldStyle); 673 effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle); 669 674 } 670 675 }, arguments[1] || {})); … … 688 693 new Effect.Move(effect.element, 689 694 { x: -20, y: 0, duration: 0.05, afterFinishInternal: function(effect) { 690 effect.element.undoPositioned(); 691 effect.element.setStyle(oldStyle); 695 effect.element.undoPositioned().setStyle(oldStyle); 692 696 }}) }}) }}) }}) }}) }}); 693 697 } 694 698 695 699 Effect.SlideDown = function(element) { 696 element = $(element); 697 element.cleanWhitespace(); 700 element = $(element).cleanWhitespace(); 698 701 // SlideDown need to have the content of the element wrapped in a container element with fixed height! 699 var oldInnerBottom = $(element.firstChild).getStyle('bottom');702 var oldInnerBottom = element.down().getStyle('bottom'); 700 703 var elementDimensions = element.getDimensions(); 701 704 return new Effect.Scale(element, 100, Object.extend({ … … 707 710 afterSetup: function(effect) { 708 711 effect.element.makePositioned(); 709 effect.element. firstChild.makePositioned();712 effect.element.down().makePositioned(); 710 713 if(window.opera) effect.element.setStyle({top: ''}); 711 effect.element.makeClipping(); 712 effect.element.setStyle({height: '0px'}); 713 effect.element.show(); }, 714 effect.element.makeClipping().setStyle({height: '0px'}).show(); 715 }, 714 716 afterUpdateInternal: function(effect) { 715 effect.element. firstChild.setStyle({bottom:717 effect.element.down().setStyle({bottom: 716 718 (effect.dims[0] - effect.element.clientHeight) + 'px' }); 717 719 }, 718 720 afterFinishInternal: function(effect) { 719 effect.element.undoClipping(); 720 // IE will crash if child is undoPositioned first 721 if(/MSIE/.test(navigator.userAgent)){ 722 effect.element.undoPositioned(); 723 effect.element.firstChild.undoPositioned(); 724 }else{ 725 effect.element.firstChild.undoPositioned(); 726 effect.element.undoPositioned(); 727 } 728 effect.element.firstChild.setStyle({bottom: oldInnerBottom}); } 721 effect.element.undoClipping().undoPositioned(); 722 effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); } 729 723 }, arguments[1] || {}) 730 724 ); 731 725 } 732 726 733 727 Effect.SlideUp = function(element) { 734 element = $(element); 735 element.cleanWhitespace(); 736 var oldInnerBottom = $(element.firstChild).getStyle('bottom'); 728 element = $(element).cleanWhitespace(); 729 var oldInnerBottom = element.down().getStyle('bottom'); 737 730 return new Effect.Scale(element, window.opera ? 0 : 1, 738 731 Object.extend({ scaleContent: false, … … 743 736 beforeStartInternal: function(effect) { 744 737 effect.element.makePositioned(); 745 effect.element. firstChild.makePositioned();738 effect.element.down().makePositioned(); 746 739 if(window.opera) effect.element.setStyle({top: ''}); 747 effect.element.makeClipping() ;748 effect.element.show();},740 effect.element.makeClipping().show(); 741 }, 749 742 afterUpdateInternal: function(effect) { 750 effect.element.firstChild.setStyle({bottom: 751 (effect.dims[0] - effect.element.clientHeight) + 'px' }); }, 743 effect.element.down().setStyle({bottom: 744 (effect.dims[0] - effect.element.clientHeight) + 'px' }); 745 }, 752 746 afterFinishInternal: function(effect) { 753 effect.element.hide(); 754 effect.element.undoClipping(); 755 effect.element.firstChild.undoPositioned(); 756 effect.element.undoPositioned(); 757 effect.element.setStyle({bottom: oldInnerBottom}); } 747 effect.element.hide().undoClipping().undoPositioned().setStyle({bottom: oldInnerBottom}); 748 effect.element.down().undoPositioned(); 749 } 758 750 }, arguments[1] || {}) 759 751 ); … … 762 754 // Bug in opera makes the TD containing this element expand for a instance after finish 763 755 Effect.Squish = function(element) { 764 return new Effect.Scale(element, window.opera ? 1 : 0, 765 { restoreAfterFinish: true, 766 beforeSetup: function(effect) { 767 effect.element.makeClipping(effect.element); }, 768 afterFinishInternal: function(effect) { 769 effect.element.hide(effect.element); 770 effect.element.undoClipping(effect.element); } 756 return new Effect.Scale(element, window.opera ? 1 : 0, { 757 restoreAfterFinish: true, 758 beforeSetup: function(effect) { 759 effect.element.makeClipping(); 760 }, 761 afterFinishInternal: function(effect) { 762 effect.element.hide().undoClipping(); 763 } 771 764 }); 772 765 } … … 824 817 duration: 0.01, 825 818 beforeSetup: function(effect) { 826 effect.element.hide(); 827 effect.element.makeClipping(); 828 effect.element.makePositioned(); 819 effect.element.hide().makeClipping().makePositioned(); 829 820 }, 830 821 afterFinishInternal: function(effect) { … … 837 828 ], Object.extend({ 838 829 beforeSetup: function(effect) { 839 effect.effects[0].element.setStyle({height: '0px'}); 840 effect.effects[0].element.show(); 830 effect.effects[0].element.setStyle({height: '0px'}).show(); 841 831 }, 842 832 afterFinishInternal: function(effect) { 843 effect.effects[0].element.undoClipping(); 844 effect.effects[0].element.undoPositioned(); 845 effect.effects[0].element.setStyle(oldStyle); 833 effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle); 846 834 } 847 835 }, options) … … 897 885 ], Object.extend({ 898 886 beforeStartInternal: function(effect) { 899 effect.effects[0].element.makePositioned() ;900 effect.effects[0].element.makeClipping();},887 effect.effects[0].element.makePositioned().makeClipping(); 888 }, 901 889 afterFinishInternal: function(effect) { 902 effect.effects[0].element.hide(); 903 effect.effects[0].element.undoClipping(); 904 effect.effects[0].element.undoPositioned(); 905 effect.effects[0].element.setStyle(oldStyle); } 890 effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); } 906 891 }, options) 907 892 ); … … 913 898 var oldOpacity = element.getInlineOpacity(); 914 899 var transition = options.transition || Effect.Transitions.sinoidal; 915 var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos )) };900 var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos, options.pulses)) }; 916 901 reverser.bind(transition); 917 902 return new Effect.Opacity(element, 918 Object.extend(Object.extend({ duration: 3.0, from: 0,903 Object.extend(Object.extend({ duration: 2.0, from: 0, 919 904 afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); } 920 905 }, options), {transition: reverser})); … … 928 913 width: element.style.width, 929 914 height: element.style.height }; 930 Element.makeClipping(element);915 element.makeClipping(); 931 916 return new Effect.Scale(element, 5, Object.extend({ 932 917 scaleContent: false, … … 937 922 scaleY: false, 938 923 afterFinishInternal: function(effect) { 939 effect.element.hide(); 940 effect.element.undoClipping(); 941 effect.element.setStyle(oldStyle); 924 effect.element.hide().undoClipping().setStyle(oldStyle); 942 925 } }); 943 926 }}, arguments[1] || {})); 944 927 }; 945 928 929 Effect.Morph = Class.create(); 930 Object.extend(Object.extend(Effect.Morph.prototype, Effect.Base.prototype), { 931 initialize: function(element) { 932 this.element = $(element); 933 if(!this.element) throw(Effect._elementDoesNotExistError); 934 var options = Object.extend({ 935 style: {} 936 }, arguments[1] || {}); 937 if (typeof options.style == 'string') { 938 if(options.style.indexOf(':') == -1) { 939 var cssText = '', selector = '.' + options.style; 940 $A(document.styleSheets).reverse().each(function(styleSheet) { 941 if (styleSheet.cssRules) cssRules = styleSheet.cssRules; 942 else if (styleSheet.rules) cssRules = styleSheet.rules; 943 $A(cssRules).reverse().each(function(rule) { 944 if (selector == rule.selectorText) { 945 cssText = rule.style.cssText; 946 throw $break; 947 } 948 }); 949 if (cssText) throw $break; 950 }); 951 this.style = cssText.parseStyle(); 952 options.afterFinishInternal = function(effect){ 953 effect.element.addClassName(effect.options.style); 954 effect.transforms.each(function(transform) { 955 if(transform.style != 'opacity') 956 effect.element.style[transform.style.camelize()] = ''; 957 }); 958 } 959 } else this.style = options.style.parseStyle(); 960 } else this.style = $H(options.style) 961 this.start(options); 962 }, 963 setup: function(){ 964 function parseColor(color){ 965 if(!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff'; 966 color = color.parseColor(); 967 return $R(0,2).map(function(i){ 968 return parseInt( color.slice(i*2+1,i*2+3), 16 ) 969 }); 970 } 971 this.transforms = this.style.map(function(pair){ 972 var property = pair[0].underscore().dasherize(), value = pair[1], unit = null; 973 974 if(value.parseColor('#zzzzzz') != '#zzzzzz') { 975 value = value.parseColor(); 976 unit = 'color'; 977 } else if(property == 'opacity') { 978 value = parseFloat(value); 979 if(/MSIE/.test(navigator.userAgent) && !window.opera && (!this.element.currentStyle.hasLayout)) 980 this.element.setStyle({zoom: 1}); 981 } else if(Element.CSS_LENGTH.test(value)) 982 var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/), 983 value = parseFloat(components[1]), unit = (components.length == 3) ? components[2] : null; 984 985 var originalValue = this.element.getStyle(property); 986 return $H({ 987 style: property, 988 originalValue: unit=='color' ? parseColor(originalValue) : parseFloat(originalValue || 0), 989 targetValue: unit=='color' ? parseColor(value) : value, 990 unit: unit 991 }); 992 }.bind(this)).reject(function(transform){ 993 return ( 994 (transform.originalValue == transform.targetValue) || 995 ( 996 transform.unit != 'color' && 997 (isNaN(transform.originalValue) || isNaN(transform.targetValue)) 998 ) 999 ) 1000 }); 1001 }, 1002 update: function(position) { 1003 var style = $H(), value = null; 1004 this.transforms.each(function(transform){ 1005 value = transform.unit=='color' ? 1006 $R(0,2).inject('#',function(m,v,i){ 1007 return m+(Math.round(transform.originalValue[i]+ 1008 (transform.targetValue[i] - transform.originalValue[i])*position)).toColorPart() }) : 1009 transform.originalValue + Math.round( 1010 ((transform.targetValue - transform.originalValue) * position) * 1000)/1000 + transform.unit; 1011 style[transform.style] = value; 1012 }); 1013 this.element.setStyle(style); 1014 } 1015 }); 1016 1017 Effect.Transform = Class.create(); 1018 Object.extend(Effect.Transform.prototype, { 1019 initialize: function(tracks){ 1020 this.tracks = []; 1021 this.options = arguments[1] || {}; 1022 this.addTracks(tracks); 1023 }, 1024 addTracks: function(tracks){ 1025 tracks.each(function(track){ 1026 var data = $H(track).values().first(); 1027 this.tracks.push($H({ 1028 ids: $H(track).keys().first(), 1029 effect: Effect.Morph, 1030 options: { style: data } 1031 })); 1032 }.bind(this)); 1033 return this; 1034 }, 1035 play: function(){ 1036 return new Effect.Parallel( 1037 this.tracks.map(function(track){ 1038 var elements = [$(track.ids) || $$(track.ids)].flatten(); 1039 return elements.map(function(e){ return new track.effect(e, Object.extend({ sync:true }, track.options)) }); 1040 }).flatten(), 1041 this.options 1042 ); 1043 } 1044 }); 1045 1046 Element.CSS_PROPERTIES = $w( 1047 'backgroundColor backgroundPosition borderBottomColor borderBottomStyle ' + 1048 'borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth ' + 1049 'borderRightColor borderRightStyle borderRightWidth borderSpacing ' + 1050 'borderTopColor borderTopStyle borderTopWidth bottom clip color ' + 1051 'fontSize fontWeight height left letterSpacing lineHeight ' + 1052 'marginBottom marginLeft marginRight marginTop markerOffset maxHeight '+ 1053 'maxWidth minHeight minWidth opacity outlineColor outlineOffset ' + 1054 'outlineWidth paddingBottom paddingLeft paddingRight paddingTop ' + 1055 'right textIndent top width wordSpacing zIndex'); 1056 1057 Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/; 1058 1059 String.prototype.parseStyle = function(){ 1060 var element = Element.extend(document.createElement('div')); 1061 element.innerHTML = '<div style="' + this + '"></div>'; 1062 var style = element.down().style, styleRules = $H(); 1063 1064 Element.CSS_PROPERTIES.each(function(property){ 1065 if(style[property]) styleRules[property] = style[property]; 1066 }); 1067 if(/MSIE/.test(navigator.userAgent) && !window.opera && this.indexOf('opacity') > -1) { 1068 styleRules.opacity = this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]; 1069 } 1070 return styleRules; 1071 }; 1072 1073 Element.morph = function(element, style) { 1074 new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || {})); 1075 return element; 1076 }; 1077 946 1078 ['setOpacity','getOpacity','getInlineOpacity','forceRerendering','setContentZoom', 947 'collectTextNodes','collectTextNodesIgnoreClass',' childrenWithClassName'].each(1079 'collectTextNodes','collectTextNodesIgnoreClass','morph'].each( 948 1080 function(f) { Element.Methods[f] = Element[f]; } 949 1081 ); -
tags/2.2/wp-includes/js/scriptaculous/prototype.js
r5468 r5480 1 /* Prototype JavaScript framework, version 1.5.0 _rc02 * (c) 2005 Sam Stephenson <sam@conio.net>1 /* Prototype JavaScript framework, version 1.5.0 2 * (c) 2005-2007 Sam Stephenson 3 3 * 4 4 * Prototype is freely distributable under the terms of an MIT-style license. … … 8 8 9 9 var Prototype = { 10 Version: '1.5.0_rc0', 10 Version: '1.5.0', 11 BrowserFeatures: { 12 XPath: !!document.evaluate 13 }, 14 11 15 ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)', 12 13 16 emptyFunction: function() {}, 14 K: function(x) { return x}17 K: function(x) { return x } 15 18 } 16 19 … … 32 35 } 33 36 34 Object.inspect = function(object) { 35 try { 36 if (object == undefined) return 'undefined'; 37 if (object == null) return 'null'; 38 return object.inspect ? object.inspect() : object.toString(); 39 } catch (e) { 40 if (e instanceof RangeError) return '...'; 41 throw e; 42 } 43 } 37 Object.extend(Object, { 38 inspect: function(object) { 39 try { 40 if (object === undefined) return 'undefined'; 41 if (object === null) return 'null'; 42 return object.inspect ? object.inspect() : object.toString(); 43 } catch (e) { 44 if (e instanceof RangeError) return '...'; 45 throw e; 46 } 47 }, 48 49 keys: function(object) { 50 var keys = []; 51 for (var property in object) 52 keys.push(property); 53 return keys; 54 }, 55 56 values: function(object) { 57 var values = []; 58 for (var property in object) 59 values.push(object[property]); 60 return values; 61 }, 62 63 clone: function(object) { 64 return Object.extend({}, object); 65 } 66 }); 44 67 45 68 Function.prototype.bind = function() { … … 51 74 52 75 Function.prototype.bindAsEventListener = function(object) { 53 var __method = this ;76 var __method = this, args = $A(arguments), object = args.shift(); 54 77 return function(event) { 55 return __method. call(object, event || window.event);78 return __method.apply(object, [( event || window.event)].concat(args).concat($A(arguments))); 56 79 } 57 80 } … … 78 101 var returnValue; 79 102 80 for (var i = 0 ; i < arguments.length; i++) {103 for (var i = 0, length = arguments.length; i < length; i++) { 81 104 var lambda = arguments[i]; 82 105 try { … … 103 126 104 127 registerCallback: function() { 105 setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); 128 this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); 129 }, 130 131 stop: function() { 132 if (!this.timer) return; 133 clearInterval(this.timer); 134 this.timer = null; 106 135 }, 107 136 … … 110 139 try { 111 140 this.currentlyExecuting = true; 112 this.callback( );141 this.callback(this); 113 142 } finally { 114 143 this.currentlyExecuting = false; … … 117 146 } 118 147 } 148 String.interpret = function(value){ 149 return value == null ? '' : String(value); 150 } 151 119 152 Object.extend(String.prototype, { 120 153 gsub: function(pattern, replacement) { … … 125 158 if (match = source.match(pattern)) { 126 159 result += source.slice(0, match.index); 127 result += (replacement(match) || '').toString();160 result += String.interpret(replacement(match)); 128 161 source = source.slice(match.index + match[0].length); 129 162 } else { … … 190 223 var div = document.createElement('div'); 191 224 div.innerHTML = this.stripTags(); 192 return div.childNodes[0] ? div.childNodes[0].nodeValue : ''; 193 }, 194 195 toQueryParams: function() { 196 var pairs = this.match(/^\??(.*)$/)[1].split('&'); 197 return pairs.inject({}, function(params, pairString) { 198 var pair = pairString.split('='); 199 params[pair[0]] = pair[1]; 200 return params; 225 return div.childNodes[0] ? (div.childNodes.length > 1 ? 226 $A(div.childNodes).inject('',function(memo,node){ return memo+node.nodeValue }) : 227 div.childNodes[0].nodeValue) : ''; 228 }, 229 230 toQueryParams: function(separator) { 231 var match = this.strip().match(/([^?#]*)(#.*)?$/); 232 if (!match) return {}; 233 234 return match[1].split(separator || '&').inject({}, function(hash, pair) { 235 if ((pair = pair.split('='))[0]) { 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); 243 } 244 else hash[name] = value; 245 } 246 return hash; 201 247 }); 202 248 }, … … 206 252 }, 207 253 254 succ: function() { 255 return this.slice(0, this.length - 1) + 256 String.fromCharCode(this.charCodeAt(this.length - 1) + 1); 257 }, 258 208 259 camelize: function() { 209 var oStringList = this.split('-'); 210 if (oStringList.length == 1) return oStringList[0]; 211 212 var camelizedString = this.indexOf('-') == 0 213 ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) 214 : oStringList[0]; 215 216 for (var i = 1, len = oStringList.length; i < len; i++) { 217 var s = oStringList[i]; 218 camelizedString += s.charAt(0).toUpperCase() + s.substring(1); 219 } 220 221 return camelizedString; 222 }, 223 224 inspect: function() { 225 return "'" + this.replace(/\\/g, '\\\\').replace(/'/g, '\\\'') + "'"; 260 var parts = this.split('-'), len = parts.length; 261 if (len == 1) return parts[0]; 262 263 var camelized = this.charAt(0) == '-' 264 ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1) 265 : parts[0]; 266 267 for (var i = 1; i < len; i++) 268 camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1); 269 270 return camelized; 271 }, 272 273 capitalize: function(){ 274 return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); 275 }, 276 277 underscore: function() { 278 return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase(); 279 }, 280 281 dasherize: function() { 282 return this.gsub(/_/,'-'); 283 }, 284 285 inspect: function(useDoubleQuotes) { 286 var escapedString = this.replace(/\\/g, '\\\\'); 287 if (useDoubleQuotes) 288 return '"' + escapedString.replace(/"/g, '\\"') + '"'; 289 else 290 return "'" + escapedString.replace(/'/g, '\\\'') + "'"; 226 291 } 227 292 }); … … 247 312 var before = match[1]; 248 313 if (before == '\\') return match[2]; 249 return before + (object[match[3]] || '').toString();314 return before + String.interpret(object[match[3]]); 250 315 }); 251 316 } … … 269 334 if (e != $break) throw e; 270 335 } 336 return this; 337 }, 338 339 eachSlice: function(number, iterator) { 340 var index = -number, slices = [], array = this.toArray(); 341 while ((index += number) < array.length) 342 slices.push(array.slice(index, index+number)); 343 return slices.map(iterator); 271 344 }, 272 345 … … 281 354 282 355 any: function(iterator) { 283 var result = true;356 var result = false; 284 357 this.each(function(value, index) { 285 358 if (result = !!(iterator || Prototype.K)(value, index)) … … 292 365 var results = []; 293 366 this.each(function(value, index) { 294 results.push( iterator(value, index));367 results.push((iterator || Prototype.K)(value, index)); 295 368 }); 296 369 return results; 297 370 }, 298 371 299 detect: function 372 detect: function(iterator) { 300 373 var result; 301 374 this.each(function(value, index) { … … 338 411 }, 339 412 413 inGroupsOf: function(number, fillWith) { 414 fillWith = fillWith === undefined ? null : fillWith; 415 return this.eachSlice(number, function(slice) { 416 while(slice.length < number) slice.push(fillWith); 417 return slice; 418 }); 419 }, 420 340 421 inject: function(memo, iterator) { 341 422 this.each(function(value, index) { … … 347 428 invoke: function(method) { 348 429 var args = $A(arguments).slice(1); 349 return this. collect(function(value) {430 return this.map(function(value) { 350 431 return value[method].apply(value, args); 351 432 }); … … 399 480 400 481 sortBy: function(iterator) { 401 return this. collect(function(value, index) {482 return this.map(function(value, index) { 402 483 return {value: value, criteria: iterator(value, index)}; 403 484 }).sort(function(left, right) { … … 408 489 409 490 toArray: function() { 410 return this. collect(Prototype.K);491 return this.map(); 411 492 }, 412 493 … … 420 501 return iterator(collections.pluck(index)); 421 502 }); 503 }, 504 505 size: function() { 506 return this.toArray().length; 422 507 }, 423 508 … … 440 525 } else { 441 526 var results = []; 442 for (var i = 0 ; i < iterable.length; i++)527 for (var i = 0, length = iterable.length; i < length; i++) 443 528 results.push(iterable[i]); 444 529 return results; … … 453 538 Object.extend(Array.prototype, { 454 539 _each: function(iterator) { 455 for (var i = 0 ; i < this.length; i++)540 for (var i = 0, length = this.length; i < length; i++) 456 541 iterator(this[i]); 457 542 }, … … 472 557 compact: function() { 473 558 return this.select(function(value) { 474 return value != undefined || value !=null;559 return value != null; 475 560 }); 476 561 }, … … 491 576 492 577 indexOf: function(object) { 493 for (var i = 0 ; i < this.length; i++)578 for (var i = 0, length = this.length; i < length; i++) 494 579 if (this[i] == object) return i; 495 580 return -1; … … 500 585 }, 501 586 587 reduce: function() { 588 return this.length > 1 ? this : this[0]; 589 }, 590 591 uniq: function() { 592 return this.inject([], function(array, value) { 593 return array.include(value) ? array : array.concat([value]); 594 }); 595 }, 596 597 clone: function() { 598 return [].concat(this); 599 }, 600 601 size: function() { 602 return this.length; 603 }, 604 502 605 inspect: function() { 503 606 return '[' + this.map(Object.inspect).join(', ') + ']'; 504 607 } 505 608 }); 506 var Hash = { 609 610 Array.prototype.toArray = Array.prototype.clone; 611 612 function $w(string){ 613 string = string.strip(); 614 return string ? string.split(/\s+/) : []; 615 } 616 617 if(window.opera){ 618 Array.prototype.concat = function(){ 619 var array = []; 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++) 624 array.push(arguments[i][j]); 625 } else { 626 array.push(arguments[i]); 627 } 628 } 629 return array; 630 } 631 } 632 var Hash = function(obj) { 633 Object.extend(this, obj || {}); 634 }; 635 636 Object.extend(Hash, { 637 toQueryString: function(obj) { 638 var parts = []; 639 640 this.prototype._each.call(obj, function(pair) { 641 if (!pair.key) 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 } 654 } 655 if (pair.value == undefined) pair[1] = ''; 656 parts.push(pair.map(encodeURIComponent).join('=')); 657 }); 658 659 return parts.join('&'); 660 } 661 }); 662 663 Object.extend(Hash.prototype, Enumerable); 664 Object.extend(Hash.prototype, { 507 665 _each: function(iterator) { 508 666 for (var key in this) { 509 667 var value = this[key]; 510 if ( typeof value == 'function') continue;668 if (value && value == Hash.prototype[key]) continue; 511 669 512 670 var pair = [key, value]; … … 526 684 527 685 merge: function(hash) { 528 return $H(hash).inject( $H(this), function(mergedHash, pair) {686 return $H(hash).inject(this, function(mergedHash, pair) { 529 687 mergedHash[pair.key] = pair.value; 530 688 return mergedHash; … … 532 690 }, 533 691 692 remove: function() { 693 var result; 694 for(var i = 0, length = arguments.length; i < length; i++) { 695 var value = this[arguments[i]]; 696 if (value !== undefined){ 697 if (result === undefined) result = value; 698 else { 699 if (result.constructor != Array) result = [result]; 700 result.push(value) 701 } 702 } 703 delete this[arguments[i]]; 704 } 705 return result; 706 }, 707 534 708 toQueryString: function() { 535 return this.map(function(pair) { 536 return pair.map(encodeURIComponent).join('='); 537 }).join('&'); 709 return Hash.toQueryString(this); 538 710 }, 539 711 … … 543 715 }).join(', ') + '}>'; 544 716 } 545 } 717 }); 546 718 547 719 function $H(object) { 548 var hash = Object.extend({}, object || {}); 549 Object.extend(hash, Enumerable); 550 Object.extend(hash, Hash); 551 return hash; 552 } 720 if (object && object.constructor == Hash) return object; 721 return new Hash(object); 722 }; 553 723 ObjectRange = Class.create(); 554 724 Object.extend(ObjectRange.prototype, Enumerable); … … 562 732 _each: function(iterator) { 563 733 var value = this.start; 564 do{734 while (this.include(value)) { 565 735 iterator(value); 566 736 value = value.succ(); 567 } while (this.include(value));737 } 568 738 }, 569 739 … … 600 770 }, 601 771 602 register: function(responder ToAdd) {603 if (!this.include(responder ToAdd))604 this.responders.push(responder ToAdd);605 }, 606 607 unregister: function(responder ToRemove) {608 this.responders = this.responders.without(responder ToRemove);772 register: function(responder) { 773 if (!this.include(responder)) 774 this.responders.push(responder); 775 }, 776 777 unregister: function(responder) { 778 this.responders = this.responders.without(responder); 609 779 }, 610 780 611 781 dispatch: function(callback, request, transport, json) { 612 782 this.each(function(responder) { 613 if ( responder[callback] &&typeof responder[callback] == 'function') {783 if (typeof responder[callback] == 'function') { 614 784 try { 615 785 responder[callback].apply(responder, [request, transport, json]); … … 626 796 Ajax.activeRequestCount++; 627 797 }, 628 629 798 onComplete: function() { 630 799 Ajax.activeRequestCount--; … … 639 808 asynchronous: true, 640 809 contentType: 'application/x-www-form-urlencoded', 810 encoding: 'UTF-8', 641 811 parameters: '' 642 812 } 643 813 Object.extend(this.options, options || {}); 644 }, 645 646 responseIsSuccess: function() { 647 return this.transport.status == undefined 648 || this.transport.status == 0 649 || (this.transport.status >= 200 && this.transport.status < 300); 650 }, 651 652 responseIsFailure: function() { 653 return !this.responseIsSuccess(); 814 815 this.options.method = this.options.method.toLowerCase(); 816 if (typeof this.options.parameters == 'string') 817 this.options.parameters = this.options.parameters.toQueryParams(); 654 818 } 655 819 } … … 660 824 661 825 Ajax.Request.prototype = Object.extend(new Ajax.Base(), { 826 _complete: false, 827 662 828 initialize: function(url, options) { 663 829 this.transport = Ajax.getTransport(); … … 667 833 668 834 request: function(url) { 669 var parameters = this.options.parameters || ''; 670 if (parameters.length > 0) parameters += '&_='; 835 this.url = url; 836 this.method = this.options.method; 837 var params = this.options.parameters; 838 839 if (!['get', 'post'].include(this.method)) { 840 // simulate other verbs over post 841 params['_method'] = this.method; 842 this.method = 'post'; 843 } 844 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; 671 851 672 852 try { 673 this.url = url;674 if (this.options.method == 'get' && parameters.length > 0)675 this.url += (this.url.match(/\?/) ? '&' : '?') + parameters;676 677 853 Ajax.Responders.dispatch('onCreate', this, this.transport); 678 854 679 this.transport.open(this. options.method, this.url,855 this.transport.open(this.method.toUpperCase(), this.url, 680 856 this.options.asynchronous); 681 857 682 if (this.options.asynchronous) { 683 this.transport.onreadystatechange = this.onStateChange.bind(this); 684 setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10); 858 if (this.options.asynchronous) 859 setTimeout(function() { this.respondToReadyState(1) }.bind(this), 10); 860 861 this.transport.onreadystatechange = this.onStateChange.bind(this); 862 this.setRequestHeaders(); 863 864 var body = this.method == 'post' ? (this.options.postBody || params) : null; 865 866 this.transport.send(body); 867 868 /* Force Firefox to handle ready state 4 for synchronous requests */ 869 if (!this.options.asynchronous && this.transport.overrideMimeType) 870 this.onStateChange(); 871 872 } 873 catch (e) { 874 this.dispatchException(e); 875 } 876 }, 877 878 onStateChange: function() { 879 var readyState = this.transport.readyState; 880 if (readyState > 1 && !((readyState == 4) && this._complete)) 881 this.respondToReadyState(this.transport.readyState); 882 }, 883 884 setRequestHeaders: function() { 885 var headers = { 886 'X-Requested-With': 'XMLHttpRequest', 887 'X-Prototype-Version': Prototype.Version, 888 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*' 889 }; 890 891 if (this.method == 'post') { 892 headers['Content-type'] = this.options.contentType + 893 (this.options.encoding ? '; charset=' + this.options.encoding : ''); 894 895 /* Force "Connection: close" for older Mozilla browsers to work 896 * around a bug where XMLHttpRequest sends an incorrect 897 * Content-length header. See Mozilla Bugzilla #246651. 898 */ 899 if (this.transport.overrideMimeType && 900 (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) 901 headers['Connection'] = 'close'; 902 } 903 904 // user-defined headers 905 if (typeof this.options.requestHeaders == 'object') { 906 var extras = this.options.requestHeaders; 907 908 if (typeof extras.push == 'function') 909 for (var i = 0, length = extras.length; i < length; i += 2) 910 headers[extras[i]] = extras[i+1]; 911 else 912 $H(extras).each(function(pair) { headers[pair.key] = pair.value }); 913 } 914 915 for (var name in headers) 916 this.transport.setRequestHeader(name, headers[name]); 917 }, 918 919 success: function() { 920 return !this.transport.status 921 || (this.transport.status >= 200 && this.transport.status < 300); 922 }, 923 924 respondToReadyState: function(readyState) { 925 var state = Ajax.Request.Events[readyState]; 926 var transport = this.transport, json = this.evalJSON(); 927 928 if (state == 'Complete') { 929 try { 930 this._complete = true; 931 (this.options['on' + this.transport.status] 932 || this.options['on' + (this.success() ? 'Success' : 'Failure')] 933 || Prototype.emptyFunction)(transport, json); 934 } catch (e) { 935 this.dispatchException(e); 685 936 } 686 937 687 this.setRequestHeaders(); 688 689 var body = this.options.postBody ? this.options.postBody : parameters; 690 this.transport.send(this.options.method == 'post' ? body : null); 691 938 if ((this.getHeader('Content-type') || 'text/javascript').strip(). 939 match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i)) 940 this.evalResponse(); 941 } 942 943 try { 944 (this.options['on' + state] || Prototype.emptyFunction)(transport, json); 945 Ajax.Responders.dispatch('on' + state, this, transport, json); 692 946 } catch (e) { 693 947 this.dispatchException(e); 694 948 } 695 }, 696 697 setRequestHeaders: function() { 698 var requestHeaders = 699 ['X-Requested-With', 'XMLHttpRequest', 700 'X-Prototype-Version', Prototype.Version, 701 'Accept', 'text/javascript, text/html, application/xml, text/xml, */*']; 702 703 if (this.options.method == 'post') { 704 requestHeaders.push('Content-type', this.options.contentType); 705 706 /* Force "Connection: close" for Mozilla browsers to work around 707 * a bug where XMLHttpReqeuest sends an incorrect Content-length 708 * header. See Mozilla Bugzilla #246651. 709 */ 710 if (this.transport.overrideMimeType) 711 requestHeaders.push('Connection', 'close'); 712 } 713 714 if (this.options.requestHeaders) 715 requestHeaders.push.apply(requestHeaders, this.options.requestHeaders); 716 717 for (var i = 0; i < requestHeaders.length; i += 2) 718 this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]); 719 }, 720 721 onStateChange: function() { 722 var readyState = this.transport.readyState; 723 if (readyState != 1) 724 this.respondToReadyState(this.transport.readyState); 725 }, 726 727 header: function(name) { 949 950 if (state == 'Complete') { 951 // avoid memory leak in MSIE: clean up 952 this.transport.onreadystatechange = Prototype.emptyFunction; 953 } 954 }, 955 956 getHeader: function(name) { 728 957 try { 729 958 return this.transport.getResponseHeader(name); 730 } catch (e) { }959 } catch (e) { return null } 731 960 }, 732 961 733 962 evalJSON: function() { 734 963 try { 735 return eval('(' + this.header('X-JSON') + ')'); 736 } catch (e) {} 964 var json = this.getHeader('X-JSON'); 965 return json ? eval('(' + json + ')') : null; 966 } catch (e) { return null } 737 967 }, 738 968 … … 745 975 }, 746 976 747 respondToReadyState: function(readyState) {748 var event = Ajax.Request.Events[readyState];749 var transport = this.transport, json = this.evalJSON();750 751 if (event == 'Complete') {752 try {753 (this.options['on' + this.transport.status]754 || this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')]755 || Prototype.emptyFunction)(transport, json);756 } catch (e) {757 this.dispatchException(e);758 }759 760 if ((this.header('Content-type') || '').match(/^text\/javascript/i))761 this.evalResponse();762 }763 764 try {765 (this.options['on' + event] || Prototype.emptyFunction)(transport, json);766 Ajax.Responders.dispatch('on' + event, this, transport, json);767 } catch (e) {768 this.dispatchException(e);769 }770 771 /* Avoid memory leak in MSIE: clean up the oncomplete event handler */772 if (event == 'Complete')773 this.transport.onreadystatechange = Prototype.emptyFunction;774 },775 776 977 dispatchException: function(exception) { 777 978 (this.options.onException || Prototype.emptyFunction)(this, exception); … … 784 985 Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), { 785 986 initialize: function(container, url, options) { 786 this.containers = { 787 success: container.success ? $(container.success) : $(container), 788 failure: container.failure ? $(container.failure) : 789 (container.success ? null : $(container)) 987 this.container = { 988 success: (container.success || container), 989 failure: (container.failure || (container.success ? null : container)) 790 990 } 791 991 … … 794 994 795 995 var onComplete = this.options.onComplete || Prototype.emptyFunction; 796 this.options.onComplete = (function(transport, object) {996 this.options.onComplete = (function(transport, param) { 797 997 this.updateContent(); 798 onComplete(transport, object);998 onComplete(transport, param); 799 999 }).bind(this); 800 1000 … … 803 1003 804 1004 updateContent: function() { 805 var receiver = this.responseIsSuccess() ? 806 this.containers.success : this.containers.failure; 1005 var receiver = this.container[this.success() ? 'success' : 'failure']; 807 1006 var response = this.transport.responseText; 808 1007 809 if (!this.options.evalScripts) 810 response = response.stripScripts(); 811 812 if (receiver) { 813 if (this.options.insertion) { 1008 if (!this.options.evalScripts) response = response.stripScripts(); 1009 1010 if (receiver = $(receiver)) { 1011 if (this.options.insertion) 814 1012 new this.options.insertion(receiver, response); 815 } else { 816 Element.update(receiver, response); 817 } 818 } 819 820 if (this.responseIsSuccess()) { 1013 else 1014 receiver.update(response); 1015 } 1016 1017 if (this.success()) { 821 1018 if (this.onComplete) 822 1019 setTimeout(this.onComplete.bind(this), 10); … … 847 1044 848 1045 stop: function() { 849 this.updater.o nComplete = undefined;1046 this.updater.options.onComplete = undefined; 850 1047 clearTimeout(this.timer); 851 1048 (this.onComplete || Prototype.emptyFunction).apply(this, arguments); … … 867 1064 } 868 1065 }); 869 function $() { 870 var results = [], element; 871 for (var i = 0; i < arguments.length; i++) { 872 element = arguments[i]; 873 if (typeof element == 'string') 874 element = document.getElementById(element); 875 results.push(Element.extend(element)); 876 } 877 return results.length < 2 ? results[0] : results; 1066 function $(element) { 1067 if (arguments.length > 1) { 1068 for (var i = 0, elements = [], length = arguments.length; i < length; i++) 1069 elements.push($(arguments[i])); 1070 return elements; 1071 } 1072 if (typeof element == 'string') 1073 element = document.getElementById(element); 1074 return Element.extend(element); 1075 } 1076 1077 if (Prototype.BrowserFeatures.XPath) { 1078 document._getElementsByXPath = function(expression, parentElement) { 1079 var results = []; 1080 var query = document.evaluate(expression, $(parentElement) || document, 1081 null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); 1082 for (var i = 0, length = query.snapshotLength; i < length; i++) 1083 results.push(query.snapshotItem(i)); 1084 return results; 1085 }; 878 1086 } 879 1087 880 1088 document.getElementsByClassName = function(className, parentElement) { 881 var children = ($(parentElement) || document.body).getElementsByTagName('*'); 882 return $A(children).inject([], function(elements, child) { 883 if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) 884 elements.push(Element.extend(child)); 1089 if (Prototype.BrowserFeatures.XPath) { 1090 var q = ".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]"; 1091 return document._getElementsByXPath(q, parentElement); 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 } 885 1100 return elements; 886 } );887 } 1101 } 1102 }; 888 1103 889 1104 /*--------------------------------------------------------------------------*/ … … 893 1108 894 1109 Element.extend = function(element) { 895 if (!element) return; 896 if (_nativeExtensions) return element; 1110 if (!element || _nativeExtensions || element.nodeType == 3) return element; 897 1111 898 1112 if (!element._extended && element.tagName && element != window) { 899 var methods = Element.Methods, cache = Element.extend.cache; 900 for (property in methods) { 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 1120 Object.extend(methods, Element.Methods.Simulated); 1121 1122 for (var property in methods) { 901 1123 var value = methods[property]; 902 if (typeof value == 'function' )1124 if (typeof value == 'function' && !(property in element)) 903 1125 element[property] = cache.findOrStore(value); 904 1126 } … … 907 1129 element._extended = true; 908 1130 return element; 909 } 1131 }; 910 1132 911 1133 Element.extend.cache = { … … 915 1137 } 916 1138 } 917 } 1139 }; 918 1140 919 1141 Element.Methods = { … … 922 1144 }, 923 1145 924 toggle: function() { 925 for (var i = 0; i < arguments.length; i++) { 926 var element = $(arguments[i]); 927 Element[Element.visible(element) ? 'hide' : 'show'](element); 928 } 929 }, 930 931 hide: function() { 932 for (var i = 0; i < arguments.length; i++) { 933 var element = $(arguments[i]); 934 element.style.display = 'none'; 935 } 936 }, 937 938 show: function() { 939 for (var i = 0; i < arguments.length; i++) { 940 var element = $(arguments[i]); 941 element.style.display = ''; 942 } 1146 toggle: function(element) { 1147 element = $(element); 1148 Element[Element.visible(element) ? 'hide' : 'show'](element); 1149 return element; 1150 }, 1151 1152 hide: function(element) { 1153 $(element).style.display = 'none'; 1154 return element; 1155 }, 1156 1157 show: function(element) { 1158 $(element).style.display = ''; 1159 return element; 943 1160 }, 944 1161 … … 946 1163 element = $(element); 947 1164 element.parentNode.removeChild(element); 1165 return element; 948 1166 }, 949 1167 950 1168 update: function(element, html) { 1169 html = typeof html == 'undefined' ? '' : html.toString(); 951 1170 $(element).innerHTML = html.stripScripts(); 952 1171 setTimeout(function() {html.evalScripts()}, 10); 1172 return element; 953 1173 }, 954 1174 955 1175 replace: function(element, html) { 956 1176 element = $(element); 1177 html = typeof html == 'undefined' ? '' : html.toString(); 957 1178 if (element.outerHTML) { 958 1179 element.outerHTML = html.stripScripts(); … … 964 1185 } 965 1186 setTimeout(function() {html.evalScripts()}, 10); 1187 return element; 1188 }, 1189 1190 inspect: function(element) { 1191 element = $(element); 1192 var result = '<' + element.tagName.toLowerCase(); 1193 $H({'id': 'id', 'className': 'class'}).each(function(pair) { 1194 var property = pair.first(), attribute = pair.last(); 1195 var value = (element[property] || '').toString(); 1196 if (value) result += ' ' + attribute + '=' + value.inspect(true); 1197 }); 1198 return result + '>'; 1199 }, 1200 1201 recursivelyCollect: function(element, property) { 1202 element = $(element); 1203 var elements = []; 1204 while (element = element[property]) 1205 if (element.nodeType == 1) 1206 elements.push(Element.extend(element)); 1207 return elements; 1208 }, 1209 1210 ancestors: function(element) { 1211 return $(element).recursivelyCollect('parentNode'); 1212 }, 1213 1214 descendants: function(element) { 1215 return $A($(element).getElementsByTagName('*')); 1216 }, 1217 1218 immediateDescendants: function(element) { 1219 if (!(element = $(element).firstChild)) return []; 1220 while (element && element.nodeType != 1) element = element.nextSibling; 1221 if (element) return [element].concat($(element).nextSiblings()); 1222 return []; 1223 }, 1224 1225 previousSiblings: function(element) { 1226 return $(element).recursivelyCollect('previousSibling'); 1227 }, 1228 1229 nextSiblings: function(element) { 1230 return $(element).recursivelyCollect('nextSibling'); 1231 }, 1232 1233 siblings: function(element) { 1234 element = $(element); 1235 return element.previousSiblings().reverse().concat(element.nextSiblings()); 1236 }, 1237 1238 match: function(element, selector) { 1239 if (typeof selector == 'string') 1240 selector = new Selector(selector); 1241 return selector.match($(element)); 1242 }, 1243 1244 up: function(element, expression, index) { 1245 return Selector.findElement($(element).ancestors(), expression, index); 1246 }, 1247 1248 down: function(element, expression, index) { 1249 return Selector.findElement($(element).descendants(), expression, index); 1250 }, 1251 1252 previous: function(element, expression, index) { 1253 return Selector.findElement($(element).previousSiblings(), expression, index); 1254 }, 1255 1256 next: function(element, expression, index) { 1257 return Selector.findElement($(element).nextSiblings(), expression, index); 1258 }, 1259 1260 getElementsBySelector: function() { 1261 var args = $A(arguments), element = $(args.shift()); 1262 return Selector.findChildElements(element, args); 1263 }, 1264 1265 getElementsByClassName: function(element, className) { 1266 return document.getElementsByClassName(className, element); 1267 }, 1268 1269 readAttribute: function(element, name) { 1270 element = $(element); 1271 if (document.all && !window.opera) { 1272 var t = Element._attributeTranslations; 1273 if (t.values[name]) return t.values[name](element, name); 1274 if (t.names[name]) name = t.names[name]; 1275 var attribute = element.attributes[name]; 1276 if(attribute) return attribute.nodeValue; 1277 } 1278 return element.getAttribute(name); 966 1279 }, 967 1280 968 1281 getHeight: function(element) { 969 element = $(element); 970 return element.offsetHeight; 1282 return $(element).getDimensions().height; 1283 }, 1284 1285 getWidth: function(element) { 1286 return $(element).getDimensions().width; 971 1287 }, 972 1288 … … 977 1293 hasClassName: function(element, className) { 978 1294 if (!(element = $(element))) return; 979 return Element.classNames(element).include(className); 1295 var elementClassName = element.className; 1296 if (elementClassName.length == 0) return false; 1297 if (elementClassName == className || 1298 elementClassName.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) 1299 return true; 1300 return false; 980 1301 }, 981 1302 982 1303 addClassName: function(element, className) { 983 1304 if (!(element = $(element))) return; 984 return Element.classNames(element).add(className); 1305 Element.classNames(element).add(className); 1306 return element; 985 1307 }, 986 1308 987 1309 removeClassName: function(element, className) { 988 1310 if (!(element = $(element))) return; 989 return Element.classNames(element).remove(className); 1311 Element.classNames(element).remove(className); 1312 return element; 1313 }, 1314 1315 toggleClassName: function(element, className) { 1316 if (!(element = $(element))) return; 1317 Element.classNames(element)[element.hasClassName(className) ? 'remove' : 'add'](className); 1318 return element; 1319 }, 1320 1321 observe: function() { 1322 Event.observe.apply(Event, arguments); 1323 return $A(arguments).first(); 1324 }, 1325 1326 stopObserving: function() { 1327 Event.stopObserving.apply(Event, arguments); 1328 return $A(arguments).first(); 990 1329 }, 991 1330 … … 993 1332 cleanWhitespace: function(element) { 994 1333 element = $(element); 995 for (var i = 0; i < element.childNodes.length; i++) { 996 var node = element.childNodes[i]; 1334 var node = element.firstChild; 1335 while (node) { 1336 var nextNode = node.nextSibling; 997 1337 if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) 998 Element.remove(node); 999 } 1338 element.removeChild(node); 1339 node = nextNode; 1340 } 1341 return element; 1000 1342 }, 1001 1343 … … 1004 1346 }, 1005 1347 1006 childOf: function(element, ancestor) {1348 descendantOf: function(element, ancestor) { 1007 1349 element = $(element), ancestor = $(ancestor); 1008 1350 while (element = element.parentNode) … … 1013 1355 scrollTo: function(element) { 1014 1356 element = $(element); 1015 var x = element.x ? element.x : element.offsetLeft,1016 y = element.y ? element.y : element.offsetTop;1017 window.scrollTo(x, y);1357 var pos = Position.cumulativeOffset(element); 1358 window.scrollTo(pos[0], pos[1]); 1359 return element; 1018 1360 }, 1019 1361 1020 1362 getStyle: function(element, style) { 1021 1363 element = $(element); 1022 var value = element.style[style.camelize()]; 1364 if (['float','cssFloat'].include(style)) 1365 style = (typeof element.style.styleFloat != 'undefined' ? 'styleFloat' : 'cssFloat'); 1366 style = style.camelize(); 1367 var value = element.style[style]; 1023 1368 if (!value) { 1024 1369 if (document.defaultView && document.defaultView.getComputedStyle) { 1025 1370 var css = document.defaultView.getComputedStyle(element, null); 1026 value = css ? css .getPropertyValue(style): null;1371 value = css ? css[style] : null; 1027 1372 } else if (element.currentStyle) { 1028 value = element.currentStyle[style .camelize()];1373 value = element.currentStyle[style]; 1029 1374 } 1030 1375 } 1376 1377 if((value == 'auto') && ['width','height'].include(style) && (element.getStyle('display') != 'none')) 1378 value = element['offset'+style.capitalize()] + 'px'; 1031 1379 1032 1380 if (window.opera && ['left', 'top', 'right', 'bottom'].include(style)) 1033 1381 if (Element.getStyle(element, 'position') == 'static') value = 'auto'; 1034 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 } 1035 1388 return value == 'auto' ? null : value; 1036 1389 }, … … 1038 1391 setStyle: function(element, style) { 1039 1392 element = $(element); 1040 for (var name in style) 1041 element.style[name.camelize()] = style[name]; 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 } 1413 return element; 1042 1414 }, 1043 1415 1044 1416 getDimensions: function(element) { 1045 1417 element = $(element); 1046 if (Element.getStyle(element, 'display') != 'none') 1418 var display = $(element).getStyle('display'); 1419 if (display != 'none' && display != null) // Safari bug 1047 1420 return {width: element.offsetWidth, height: element.offsetHeight}; 1048 1421 … … 1052 1425 var originalVisibility = els.visibility; 1053 1426 var originalPosition = els.position; 1427 var originalDisplay = els.display; 1054 1428 els.visibility = 'hidden'; 1055 1429 els.position = 'absolute'; 1056 els.display = ' ';1430 els.display = 'block'; 1057 1431 var originalWidth = element.clientWidth; 1058 1432 var originalHeight = element.clientHeight; 1059 els.display = 'none';1433 els.display = originalDisplay; 1060 1434 els.position = originalPosition; 1061 1435 els.visibility = originalVisibility; … … 1076 1450 } 1077 1451 } 1452 return element; 1078 1453 }, 1079 1454 … … 1088 1463 element.style.right = ''; 1089 1464 } 1465 return element; 1090 1466 }, 1091 1467 1092 1468 makeClipping: function(element) { 1093 1469 element = $(element); 1094 if (element._overflow) return ;1095 element._overflow = element.style.overflow ;1470 if (element._overflow) return element; 1471 element._overflow = element.style.overflow || 'auto'; 1096 1472 if ((Element.getStyle(element, 'overflow') || 'visible') != 'hidden') 1097 1473 element.style.overflow = 'hidden'; 1474 return element; 1098 1475 }, 1099 1476 1100 1477 undoClipping: function(element) { 1101 1478 element = $(element); 1102 if (element._overflow) return; 1103 element.style.overflow = element._overflow; 1104 element._overflow = undefined; 1105 } 1106 } 1479 if (!element._overflow) return element; 1480 element.style.overflow = element._overflow == 'auto' ? '' : element._overflow; 1481 element._overflow = null; 1482 return element; 1483 } 1484 }; 1485 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 1529 }); 1530 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){ 1541 Element.Methods.update = function(element, html) { 1542 element = $(element); 1543 html = typeof html == 'undefined' ? '' : html.toString(); 1544 var tagName = element.tagName.toUpperCase(); 1545 if (['THEAD','TBODY','TR','TD'].include(tagName)) { 1546 var div = document.createElement('div'); 1547 switch (tagName) { 1548 case 'THEAD': 1549 case 'TBODY': 1550 div.innerHTML = '<table><tbody>' + html.stripScripts() + '</tbody></table>'; 1551 depth = 2; 1552 break; 1553 case 'TR': 1554 div.innerHTML = '<table><tbody><tr>' + html.stripScripts() + '</tr></tbody></table>'; 1555 depth = 3; 1556 break; 1557 case 'TD': 1558 div.innerHTML = '<table><tbody><tr><td>' + html.stripScripts() + '</td></tr></tbody></table>'; 1559 depth = 4; 1560 } 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) }); 1568 } else { 1569 element.innerHTML = html.stripScripts(); 1570 } 1571 setTimeout(function() {html.evalScripts()}, 10); 1572 return element; 1573 } 1574 }; 1107 1575 1108 1576 Object.extend(Element, Element.Methods); … … 1110 1578 var _nativeExtensions = false; 1111 1579 1112 if(!HTMLElement && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) { 1113 var HTMLElement = {} 1114 HTMLElement.prototype = document.createElement('div').__proto__; 1115 } 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__; 1586 }); 1116 1587 1117 1588 Element.addMethods = function(methods) { 1118 1589 Object.extend(Element.Methods, methods || {}); 1119 1590 1120 if(typeof HTMLElement != 'undefined') { 1121 var methods = Element.Methods, cache = Element.extend.cache; 1122 for (property in methods) { 1591 function copy(methods, destination, onlyIfAbsent) { 1592 onlyIfAbsent = onlyIfAbsent || false; 1593 var cache = Element.extend.cache; 1594 for (var property in methods) { 1123 1595 var value = methods[property]; 1124 if (typeof value == 'function') 1125 HTMLElement.prototype[property] = cache.findOrStore(value); 1126 } 1596 if (!onlyIfAbsent || !(property in destination)) 1597 destination[property] = cache.findOrStore(value); 1598 } 1599 } 1600 1601 if (typeof HTMLElement != 'undefined') { 1602 copy(Element.Methods, HTMLElement.prototype); 1603 copy(Element.Methods.Simulated, HTMLElement.prototype, true); 1604 copy(Form.Methods, HTMLFormElement.prototype); 1605 [HTMLInputElement, HTMLTextAreaElement, HTMLSelectElement].each(function(klass) { 1606 copy(Form.Element.Methods, klass.prototype); 1607 }); 1127 1608 _nativeExtensions = true; 1128 1609 } 1129 1610 } 1130 1131 Element.addMethods();1132 1611 1133 1612 var Toggle = new Object(); … … 1149 1628 this.element.insertAdjacentHTML(this.adjacency, this.content); 1150 1629 } catch (e) { 1151 var tagName = this.element.tagName.to LowerCase();1152 if ( tagName == 'tbody' || tagName == 'tr') {1630 var tagName = this.element.tagName.toUpperCase(); 1631 if (['TBODY', 'TR'].include(tagName)) { 1153 1632 this.insertContent(this.contentFromAnonymousTable()); 1154 1633 } else { … … 1249 1728 add: function(classNameToAdd) { 1250 1729 if (this.include(classNameToAdd)) return; 1251 this.set( this.toArray().concat(classNameToAdd).join(' '));1730 this.set($A(this).concat(classNameToAdd).join(' ')); 1252 1731 }, 1253 1732 1254 1733 remove: function(classNameToRemove) { 1255 1734 if (!this.include(classNameToRemove)) return; 1256 this.set(this.select(function(className) { 1257 return className != classNameToRemove; 1258 }).join(' ')); 1735 this.set($A(this).without(classNameToRemove).join(' ')); 1259 1736 }, 1260 1737 1261 1738 toString: function() { 1262 return this.toArray().join(' ');1263 } 1264 } 1739 return $A(this).join(' '); 1740 } 1741 }; 1265 1742 1266 1743 Object.extend(Element.ClassNames.prototype, Enumerable); … … 1309 1786 conditions.push('true'); 1310 1787 if (clause = params.id) 1311 conditions.push('element. id== ' + clause.inspect());1788 conditions.push('element.readAttribute("id") == ' + clause.inspect()); 1312 1789 if (clause = params.tagName) 1313 1790 conditions.push('element.tagName.toUpperCase() == ' + clause.inspect()); 1314 1791 if ((clause = params.classNames).length > 0) 1315 for (var i = 0 ; i < clause.length; i++)1316 conditions.push(' Element.hasClassName(element,' + clause[i].inspect() + ')');1792 for (var i = 0, length = clause.length; i < length; i++) 1793 conditions.push('element.hasClassName(' + clause[i].inspect() + ')'); 1317 1794 if (clause = params.attributes) { 1318 1795 clause.each(function(attribute) { 1319 var value = 'element. getAttribute(' + attribute.name.inspect() + ')';1796 var value = 'element.readAttribute(' + attribute.name.inspect() + ')'; 1320 1797 var splitValueBy = function(delimiter) { 1321 1798 return value + ' && ' + value + '.split(' + delimiter.inspect() + ')'; … … 1330 1807 case '!=': conditions.push(value + ' != ' + attribute.value.inspect()); break; 1331 1808 case '': 1332 case undefined: conditions.push( value + ' != null'); break;1809 case undefined: conditions.push('element.hasAttribute(' + attribute.name.inspect() + ')'); break; 1333 1810 default: throw 'Unknown operator ' + attribute.operator + ' in selector'; 1334 1811 } … … 1341 1818 compileMatcher: function() { 1342 1819 this.match = new Function('element', 'if (!element.tagName) return false; \ 1820 element = $(element); \ 1343 1821 return ' + this.buildMatchExpression()); 1344 1822 }, … … 1355 1833 1356 1834 var results = []; 1357 for (var i = 0 ; i < scope.length; i++)1835 for (var i = 0, length = scope.length; i < length; i++) 1358 1836 if (this.match(element = scope[i])) 1359 1837 results.push(Element.extend(element)); … … 1367 1845 } 1368 1846 1847 Object.extend(Selector, { 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 }); 1865 }); 1866 }).flatten(); 1867 } 1868 }); 1869 1369 1870 function $$() { 1370 return $A(arguments).map(function(expression) { 1371 return expression.strip().split(/\s+/).inject([null], function(results, expr) { 1372 var selector = new Selector(expr); 1373 return results.map(selector.findElements.bind(selector)).flatten(); 1374 }); 1375 }).flatten(); 1376 } 1377 var Field = { 1378 clear: function() { 1379 for (var i = 0; i < arguments.length; i++) 1380 $(arguments[i]).value = ''; 1381 }, 1382 1871 return Selector.findChildElements(document, $A(arguments)); 1872 } 1873 var Form = { 1874 reset: function(form) { 1875 $(form).reset(); 1876 return form; 1877 }, 1878 1879 serializeElements: function(elements, getHash) { 1880 var data = elements.inject({}, function(result, element) { 1881 if (!element.disabled && element.name) { 1882 var key = element.name, value = $(element).getValue(); 1883 if (value != undefined) { 1884 if (result[key]) { 1885 if (result[key].constructor != Array) result[key] = [result[key]]; 1886 result[key].push(value); 1887 } 1888 else result[key] = value; 1889 } 1890 } 1891 return result; 1892 }); 1893 1894 return getHash ? data : Hash.toQueryString(data); 1895 } 1896 }; 1897 1898 Form.Methods = { 1899 serialize: function(form, getHash) { 1900 return Form.serializeElements(Form.getElements(form), getHash); 1901 }, 1902 1903 getElements: function(form) { 1904 return $A($(form).getElementsByTagName('*')).inject([], 1905 function(elements, child) { 1906 if (Form.Element.Serializers[child.tagName.toLowerCase()]) 1907 elements.push(Element.extend(child)); 1908 return elements; 1909 } 1910 ); 1911 }, 1912 1913 getInputs: function(form, typeName, name) { 1914 form = $(form); 1915 var inputs = form.getElementsByTagName('input'); 1916 1917 if (!typeName && !name) return $A(inputs).map(Element.extend); 1918 1919 for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) { 1920 var input = inputs[i]; 1921 if ((typeName && input.type != typeName) || (name && input.name != name)) 1922 continue; 1923 matchingInputs.push(Element.extend(input)); 1924 } 1925 1926 return matchingInputs; 1927 }, 1928 1929 disable: function(form) { 1930 form = $(form); 1931 form.getElements().each(function(element) { 1932 element.blur(); 1933 element.disabled = 'true'; 1934 }); 1935 return form; 1936 }, 1937 1938 enable: function(form) { 1939 form = $(form); 1940 form.getElements().each(function(element) { 1941 element.disabled = ''; 1942 }); 1943 return form; 1944 }, 1945 1946 findFirstElement: function(form) { 1947 return $(form).getElements().find(function(element) { 1948 return element.type != 'hidden' && !element.disabled && 1949 ['input', 'select', 'textarea'].include(element.tagName.toLowerCase()); 1950 }); 1951 }, 1952 1953 focusFirstElement: function(form) { 1954 form = $(form); 1955 form.findFirstElement().activate(); 1956 return form; 1957 } 1958 } 1959 1960 Object.extend(Form, Form.Methods); 1961 1962 /*--------------------------------------------------------------------------*/ 1963 1964 Form.Element = { 1383 1965 focus: function(element) { 1384 1966 $(element).focus(); 1385 }, 1386 1387 present: function() { 1388 for (var i = 0; i < arguments.length; i++) 1389 if ($(arguments[i]).value == '') return false; 1390 return true; 1967 return element; 1391 1968 }, 1392 1969 1393 1970 select: function(element) { 1394 1971 $(element).select(); 1972 return element; 1973 } 1974 } 1975 1976 Form.Element.Methods = { 1977 serialize: function(element) { 1978 element = $(element); 1979 if (!element.disabled && element.name) { 1980 var value = element.getValue(); 1981 if (value != undefined) { 1982 var pair = {}; 1983 pair[element.name] = value; 1984 return Hash.toQueryString(pair); 1985 } 1986 } 1987 return ''; 1988 }, 1989 1990 getValue: function(element) { 1991 element = $(element); 1992 var method = element.tagName.toLowerCase(); 1993 return Form.Element.Serializers[method](element); 1994 }, 1995 1996 clear: function(element) { 1997 $(element).value = ''; 1998 return element; 1999 }, 2000 2001 present: function(element) { 2002 return $(element).value != ''; 1395 2003 }, 1396 2004 … … 1398 2006 element = $(element); 1399 2007 element.focus(); 1400 if (element.select) 2008 if (element.select && ( element.tagName.toLowerCase() != 'input' || 2009 !['button', 'reset', 'submit'].include(element.type) ) ) 1401 2010 element.select(); 1402 } 1403 } 2011 return element; 2012 }, 2013 2014 disable: function(element) { 2015 element = $(element); 2016 element.disabled = true; 2017 return element; 2018 }, 2019 2020 enable: function(element) { 2021 element = $(element); 2022 element.blur(); 2023 element.disabled = false; 2024 return element; 2025 } 2026 } 2027 2028 Object.extend(Form.Element, Form.Element.Methods); 2029 var Field = Form.Element; 2030 var $F = Form.Element.getValue; 1404 2031 1405 2032 /*--------------------------------------------------------------------------*/ 1406 1407 var Form = {1408 serialize: function(form) {1409 var elements = Form.getElements($(form));1410 var queryComponents = new Array();1411 1412 for (var i = 0; i < elements.length; i++) {1413 var queryComponent = Form.Element.serialize(elements[i]);1414 if (queryComponent)1415 queryComponents.push(queryComponent);1416 }1417 1418 return queryComponents.join('&');1419 },1420 1421 getElements: function(form) {1422 form = $(form);1423 var elements = new Array();1424 1425 for (var tagName in Form.Element.Serializers) {1426 var tagElements = form.getElementsByTagName(tagName);1427 for (var j = 0; j < tagElements.length; j++)1428 elements.push(tagElements[j]);1429 }1430 return elements;1431 },1432 1433 getInputs: function(form, typeName, name) {1434 form = $(form);1435 var inputs = form.getElementsByTagName('input');1436 1437 if (!typeName && !name)1438 return inputs;1439 1440 var matchingInputs = new Array();1441 for (var i = 0; i < inputs.length; i++) {1442 var input = inputs[i];1443 if ((typeName && input.type != typeName) ||1444 (name && input.name != name))1445 continue;1446 matchingInputs.push(input);1447 }1448 1449 return matchingInputs;1450 },1451 1452 disable: function(form) {1453 var elements = Form.getElements(form);1454 for (var i = 0; i < elements.length; i++) {1455 var element = elements[i];1456 element.blur();1457 element.disabled = 'true';1458 }1459 },1460 1461 enable: function(form) {1462 var elements = Form.getElements(form);1463 for (var i = 0; i < elements.length; i++) {1464 var element = elements[i];1465 element.disabled = '';1466 }1467 },1468 1469 findFirstElement: function(form) {1470 return Form.getElements(form).find(function(element) {1471 return element.type != 'hidden' && !element.disabled &&1472 ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());1473 });1474 },1475 1476 focusFirstElement: function(form) {1477 Field.activate(Form.findFirstElement(form));1478 },1479 1480 reset: function(form) {1481 $(form).reset();1482 }1483 }1484 1485 Form.Element = {1486 serialize: function(element) {1487 element = $(element);1488 var method = element.tagName.toLowerCase();1489 var parameter = Form.Element.Serializers[method](element);1490 1491 if (parameter) {1492 var key = encodeURIComponent(parameter[0]);1493 if (key.length == 0) return;1494 1495 if (parameter[1].constructor != Array)1496 parameter[1] = [parameter[1]];1497 1498 return parameter[1].map(function(value) {1499 return key + '=' + encodeURIComponent(value);1500 }).join('&');1501 }1502 },1503 1504 getValue: function(element) {1505 element = $(element);1506 var method = element.tagName.toLowerCase();1507 var parameter = Form.Element.Serializers[method](element);1508 1509 if (parameter)1510 return parameter[1];1511 }1512 }1513 2033 1514 2034 Form.Element.Serializers = { 1515 2035 input: function(element) { 1516 2036 switch (element.type.toLowerCase()) { 1517 case 'submit':1518 case 'hidden':1519 case 'password':1520 case 'text':1521 return Form.Element.Serializers.textarea(element);1522 2037 case 'checkbox': 1523 2038 case 'radio': 1524 2039 return Form.Element.Serializers.inputSelector(element); 1525 } 1526 return false; 2040 default: 2041 return Form.Element.Serializers.textarea(element); 2042 } 1527 2043 }, 1528 2044 1529 2045 inputSelector: function(element) { 1530 if (element.checked) 1531 return [element.name, element.value]; 2046 return element.checked ? element.value : null; 1532 2047 }, 1533 2048 1534 2049 textarea: function(element) { 1535 return [element.name, element.value];2050 return element.value; 1536 2051 }, 1537 2052 1538 2053 select: function(element) { 1539 return Form.Element.Serializers[element.type == 'select-one' ?2054 return this[element.type == 'select-one' ? 1540 2055 'selectOne' : 'selectMany'](element); 1541 2056 }, 1542 2057 1543 2058 selectOne: function(element) { 1544 var value = '', opt, index = element.selectedIndex; 1545 if (index >= 0) { 1546 opt = element.options[index]; 1547 value = opt.value || opt.text; 1548 } 1549 return [element.name, value]; 2059 var index = element.selectedIndex; 2060 return index >= 0 ? this.optionValue(element.options[index]) : null; 1550 2061 }, 1551 2062 1552 2063 selectMany: function(element) { 1553 var value = []; 1554 for (var i = 0; i < element.length; i++) { 2064 var values, length = element.length; 2065 if (!length) return null; 2066 2067 for (var i = 0, values = []; i < length; i++) { 1555 2068 var opt = element.options[i]; 1556 if (opt.selected) 1557 value.push(opt.value || opt.text);1558 }1559 return [element.name, value];1560 } 1561 } 1562 1563 /*--------------------------------------------------------------------------*/ 1564 1565 var $F = Form.Element.getValue; 2069 if (opt.selected) values.push(this.optionValue(opt)); 2070 } 2071 return values; 2072 }, 2073 2074 optionValue: function(opt) { 2075 // extend element because hasAttribute may not be native 2076 return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text; 2077 } 2078 } 1566 2079 1567 2080 /*--------------------------------------------------------------------------*/ … … 1584 2097 onTimerEvent: function() { 1585 2098 var value = this.getValue(); 1586 if (this.lastValue != value) { 2099 var changed = ('string' == typeof this.lastValue && 'string' == typeof value 2100 ? this.lastValue != value : String(this.lastValue) != String(value)); 2101 if (changed) { 1587 2102 this.callback(this.element, value); 1588 2103 this.lastValue = value; … … 1629 2144 1630 2145 registerFormCallbacks: function() { 1631 var elements = Form.getElements(this.element); 1632 for (var i = 0; i < elements.length; i++) 1633 this.registerCallback(elements[i]); 2146 Form.getElements(this.element).each(this.registerCallback.bind(this)); 1634 2147 }, 1635 2148 … … 1641 2154 Event.observe(element, 'click', this.onElementEvent.bind(this)); 1642 2155 break; 1643 case 'password': 1644 case 'text': 1645 case 'textarea': 1646 case 'select-one': 1647 case 'select-multiple': 2156 default: 1648 2157 Event.observe(element, 'change', this.onElementEvent.bind(this)); 1649 2158 break; … … 1680 2189 KEY_DOWN: 40, 1681 2190 KEY_DELETE: 46, 2191 KEY_HOME: 36, 2192 KEY_END: 35, 2193 KEY_PAGEUP: 33, 2194 KEY_PAGEDOWN: 34, 1682 2195 1683 2196 element: function(event) { … … 1735 2248 unloadCache: function() { 1736 2249 if (!Event.observers) return; 1737 for (var i = 0 ; i < Event.observers.length; i++) {2250 for (var i = 0, length = Event.observers.length; i < length; i++) { 1738 2251 Event.stopObserving.apply(this, Event.observers[i]); 1739 2252 Event.observers[i][0] = null; … … 1743 2256 1744 2257 observe: function(element, name, observer, useCapture) { 1745 varelement = $(element);2258 element = $(element); 1746 2259 useCapture = useCapture || false; 1747 2260 … … 1751 2264 name = 'keydown'; 1752 2265 1753 this._observeAndCache(element, name, observer, useCapture);2266 Event._observeAndCache(element, name, observer, useCapture); 1754 2267 }, 1755 2268 1756 2269 stopObserving: function(element, name, observer, useCapture) { 1757 varelement = $(element);2270 element = $(element); 1758 2271 useCapture = useCapture || false; 1759 2272 … … 1822 2335 element = element.offsetParent; 1823 2336 if (element) { 1824 p = Element.getStyle(element, 'position'); 2337 if(element.tagName=='BODY') break; 2338 var p = Element.getStyle(element, 'position'); 1825 2339 if (p == 'relative' || p == 'absolute') break; 1826 2340 } … … 1878 2392 }, 1879 2393 1880 clone: function(source, target) {1881 source = $(source);1882 target = $(target);1883 target.style.position = 'absolute';1884 var offsets = this.cumulativeOffset(source);1885 target.style.top = offsets[1] + 'px';1886 target.style.left = offsets[0] + 'px';1887 target.style.width = source.offsetWidth + 'px';1888 target.style.height = source.offsetHeight + 'px';1889 },1890 1891 2394 page: function(forElement) { 1892 2395 var valueT = 0, valueL = 0; … … 1905 2408 element = forElement; 1906 2409 do { 1907 valueT -= element.scrollTop || 0; 1908 valueL -= element.scrollLeft || 0; 2410 if (!window.opera || element.tagName=='BODY') { 2411 valueT -= element.scrollTop || 0; 2412 valueL -= element.scrollLeft || 0; 2413 } 1909 2414 } while (element = element.parentNode); 1910 2415 … … 1967 2472 1968 2473 element.style.position = 'absolute'; 1969 element.style.top = top + 'px'; ;1970 element.style.left = left + 'px'; ;1971 element.style.width = width + 'px'; ;1972 element.style.height = height + 'px'; ;2474 element.style.top = top + 'px'; 2475 element.style.left = left + 'px'; 2476 element.style.width = width + 'px'; 2477 element.style.height = height + 'px'; 1973 2478 }, 1974 2479 … … 2007 2512 } 2008 2513 } 2514 2515 Element.addMethods(); -
tags/2.2/wp-includes/js/scriptaculous/scriptaculous.js
r5468 r5480 1 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 1 // script.aculo.us scriptaculous.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) 2 4 // 3 5 // Permission is hereby granted, free of charge, to any person obtaining … … 19 21 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 // 24 // For details, see the script.aculo.us web site: http://script.aculo.us/ 21 25 22 26 var Scriptaculous = { 23 Version: '1. 6.1',27 Version: '1.7.0', 24 28 require: function(libraryName) { 25 29 // inserting via DOM fails in Safari 2.0, so brute force approach -
tags/2.2/wp-includes/js/scriptaculous/slider.js
r5468 r5480 1 // Copyright (c) 2005 Marty Haught, Thomas Fuchs 1 // script.aculo.us slider.js v1.7.0, Fri Jan 19 19:16:36 CET 2007 2 3 // Copyright (c) 2005, 2006 Marty Haught, Thomas Fuchs 2 4 // 3 // See http://script.aculo.us for more info 4 // 5 // Permission is hereby granted, free of charge, to any person obtaining 6 // a copy of this software and associated documentation files (the 7 // "Software"), to deal in the Software without restriction, including 8 // without limitation the rights to use, copy, modify, merge, publish, 9 // distribute, sublicense, and/or sell copies of the Software, and to 10 // permit persons to whom the Software is furnished to do so, subject to 11 // the following conditions: 12 // 13 // The above copyright notice and this permission notice shall be 14 // included in all copies or substantial portions of the Software. 15 // 16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 5 // script.aculo.us is freely distributable under the terms of an MIT-style license. 6 // For details, see the script.aculo.us web site: http://script.aculo.us/ 23 7 24 8 if(!Control) var Control = {}; … … 65 49 66 50 this.trackLength = this.maximumOffset() - this.minimumOffset(); 67 this.handleLength = this.isVertical() ? this.handles[0].offsetHeight : this.handles[0].offsetWidth; 51 52 this.handleLength = this.isVertical() ? 53 (this.handles[0].offsetHeight != 0 ? 54 this.handles[0].offsetHeight : this.handles[0].style.height.replace(/px$/,"")) : 55 (this.handles[0].offsetWidth != 0 ? this.handles[0].offsetWidth : 56 this.handles[0].style.width.replace(/px$/,"")); 68 57 69 58 this.active = false; … … 138 127 setValue: function(sliderValue, handleIdx){ 139 128 if(!this.active) { 140 this.activeHandle = this.handles[handleIdx];141 this.activeHandle Idx = handleIdx;129 this.activeHandleIdx = handleIdx || 0; 130 this.activeHandle = this.handles[this.activeHandleIdx]; 142 131 this.updateStyles(); 143 132 } … … 181 170 }, 182 171 maximumOffset: function(){ 183 return(this.isVertical() ? 184 this.track.offsetHeight - this.alignY : this.track.offsetWidth - this.alignX); 172 return(this.isVertical() ? 173 (this.track.offsetHeight != 0 ? this.track.offsetHeight : 174 this.track.style.height.replace(/px$/,"")) - this.alignY : 175 (this.track.offsetWidth != 0 ? this.track.offsetWidth : 176 this.track.style.width.replace(/px$/,"")) - this.alignY); 185 177 }, 186 178 isVertical: function(){ … … 218 210 var handle = Event.element(event); 219 211 var pointer = [Event.pointerX(event), Event.pointerY(event)]; 220 if(handle==this.track) { 212 var track = handle; 213 if(track==this.track) { 221 214 var offsets = Position.cumulativeOffset(this.track); 222 215 this.event = event; … … 231 224 while((this.handles.indexOf(handle) == -1) && handle.parentNode) 232 225 handle = handle.parentNode; 233 234 this.activeHandle = handle; 235 this.activeHandleIdx = this.handles.indexOf(this.activeHandle); 236 this.updateStyles(); 237 238 var offsets = Position.cumulativeOffset(this.activeHandle); 239 this.offsetX = (pointer[0] - offsets[0]); 240 this.offsetY = (pointer[1] - offsets[1]); 226 227 if(this.handles.indexOf(handle)!=-1) { 228 this.activeHandle = handle; 229 this.activeHandleIdx = this.handles.indexOf(this.activeHandle); 230 this.updateStyles(); 231 232 var offsets = Position.cumulativeOffset(this.activeHandle); 233 this.offsetX = (pointer[0] - offsets[0]); 234 this.offsetY = (pointer[1] - offsets[1]); 235 } 241 236 } 242 237 } -
tags/2.2/wp-includes/js/scriptaculous/unittest.js
r5468 r5480 1 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 2 // (c) 2005 Jon Tirsen (http://www.tirsen.com) 3 // (c) 2005 Michael Schuerig (http://www.schuerig.de/michael/) 1 // script.aculo.us unittest.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 Jon Tirsen (http://www.tirsen.com) 5 // (c) 2005, 2006 Michael Schuerig (http://www.schuerig.de/michael/) 4 6 // 5 // Permission is hereby granted, free of charge, to any person obtaining 6 // a copy of this software and associated documentation files (the 7 // "Software"), to deal in the Software without restriction, including 8 // without limitation the rights to use, copy, modify, merge, publish, 9 // distribute, sublicense, and/or sell copies of the Software, and to 10 // permit persons to whom the Software is furnished to do so, subject to 11 // the following conditions: 12 // 13 // The above copyright notice and this permission notice shall be 14 // included in all copies or substantial portions of the Software. 15 // 16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 7 // script.aculo.us is freely distributable under the terms of an MIT-style license. 8 // For details, see the script.aculo.us web site: http://script.aculo.us/ 24 9 25 10 // experimental, Firefox-only … … 28 13 pointerX: 0, 29 14 pointerY: 0, 30 buttons: 0 15 buttons: 0, 16 ctrlKey: false, 17 altKey: false, 18 shiftKey: false, 19 metaKey: false 31 20 }, arguments[2] || {}); 32 21 var oEvent = document.createEvent("MouseEvents"); 33 22 oEvent.initMouseEvent(eventName, true, true, document.defaultView, 34 23 options.buttons, options.pointerX, options.pointerY, options.pointerX, options.pointerY, 35 false, false, false, false, 0, $(element));24 options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, 0, $(element)); 36 25 37 26 if(this.mark) Element.remove(this.mark); … … 99 88 this.statusCell = document.createElement('td'); 100 89 this.nameCell = document.createElement('td'); 90 this.nameCell.className = "nameCell"; 101 91 this.nameCell.appendChild(document.createTextNode(testName)); 102 92 this.messageCell = document.createElement('td'); … … 111 101 this.statusCell.innerHTML = status; 112 102 this.messageCell.innerHTML = this._toHTML(summary); 103 this.addLinksToResults(); 113 104 }, 114 105 message: function(message) { … … 132 123 _toHTML: function(txt) { 133 124 return txt.escapeHTML().replace(/\n/g,"<br/>"); 125 }, 126 addLinksToResults: function(){ 127 $$("tr.failed .nameCell").each( function(td){ // todo: limit to children of this.log 128 td.title = "Run only this test" 129 Event.observe(td, 'click', function(){ window.location.search = "?tests=" + td.innerHTML;}); 130 }); 131 $$("tr.passed .nameCell").each( function(td){ // todo: limit to children of this.log 132 td.title = "Run all tests" 133 Event.observe(td, 'click', function(){ window.location.search = "";}); 134 }); 134 135 } 135 136 } … … 142 143 }, arguments[1] || {}); 143 144 this.options.resultsURL = this.parseResultsURLQueryParameter(); 145 this.options.tests = this.parseTestsQueryParameter(); 144 146 if (this.options.testLog) { 145 147 this.options.testLog = $(this.options.testLog) || null; … … 159 161 for(var testcase in testcases) { 160 162 if(/^test/.test(testcase)) { 161 this.tests.push(new Test.Unit.Testcase(testcase, testcases[testcase], testcases["setup"], testcases["teardown"])); 163 this.tests.push( 164 new Test.Unit.Testcase( 165 this.options.context ? ' -> ' + this.options.titles[testcase] : testcase, 166 testcases[testcase], testcases["setup"], testcases["teardown"] 167 )); 162 168 } 163 169 } … … 170 176 parseResultsURLQueryParameter: function() { 171 177 return window.location.search.parseQuery()["resultsURL"]; 178 }, 179 parseTestsQueryParameter: function(){ 180 if (window.location.search.parseQuery()["tests"]){ 181 return window.location.search.parseQuery()["tests"].split(','); 182 }; 172 183 }, 173 184 // Returns: … … 230 241 } 231 242 return ( 243 (this.options.context ? this.options.context + ': ': '') + 232 244 this.tests.length + " tests, " + 233 245 assertions + " assertions, " + … … 284 296 catch(e) { this.error(e); } 285 297 }, 298 assertInspect: function(expected, actual) { 299 var message = arguments[2] || "assertInspect"; 300 try { (expected == actual.inspect()) ? this.pass() : 301 this.fail(message + ': expected "' + Test.Unit.inspect(expected) + 302 '", actual "' + Test.Unit.inspect(actual) + '"'); } 303 catch(e) { this.error(e); } 304 }, 286 305 assertEnumEqual: function(expected, actual) { 287 306 var message = arguments[2] || "assertEnumEqual"; … … 298 317 catch(e) { this.error(e); } 299 318 }, 319 assertIdentical: function(expected, actual) { 320 var message = arguments[2] || "assertIdentical"; 321 try { (expected === actual) ? this.pass() : 322 this.fail(message + ': expected "' + Test.Unit.inspect(expected) + 323 '", actual "' + Test.Unit.inspect(actual) + '"'); } 324 catch(e) { this.error(e); } 325 }, 326 assertNotIdentical: function(expected, actual) { 327 var message = arguments[2] || "assertNotIdentical"; 328 try { !(expected === actual) ? this.pass() : 329 this.fail(message + ': expected "' + Test.Unit.inspect(expected) + 330 '", actual "' + Test.Unit.inspect(actual) + '"'); } 331 catch(e) { this.error(e); } 332 }, 300 333 assertNull: function(obj) { 301 334 var message = arguments[1] || 'assertNull' … … 304 337 catch(e) { this.error(e); } 305 338 }, 339 assertMatch: function(expected, actual) { 340 var message = arguments[2] || 'assertMatch'; 341 var regex = new RegExp(expected); 342 try { (regex.exec(actual)) ? this.pass() : 343 this.fail(message + ' : regex: "' + Test.Unit.inspect(expected) + ' did not match: ' + Test.Unit.inspect(actual) + '"'); } 344 catch(e) { this.error(e); } 345 }, 306 346 assertHidden: function(element) { 307 347 var message = arguments[1] || 'assertHidden'; … … 311 351 var message = arguments[1] || 'assertNotNull'; 312 352 this.assert(object != null, message); 353 }, 354 assertType: function(expected, actual) { 355 var message = arguments[2] || 'assertType'; 356 try { 357 (actual.constructor == expected) ? this.pass() : 358 this.fail(message + ': expected "' + Test.Unit.inspect(expected) + 359 '", actual "' + (actual.constructor) + '"'); } 360 catch(e) { this.error(e); } 361 }, 362 assertNotOfType: function(expected, actual) { 363 var message = arguments[2] || 'assertNotOfType'; 364 try { 365 (actual.constructor != expected) ? this.pass() : 366 this.fail(message + ': expected "' + Test.Unit.inspect(expected) + 367 '", actual "' + (actual.constructor) + '"'); } 368 catch(e) { this.error(e); } 313 369 }, 314 370 assertInstanceOf: function(expected, actual) { … … 325 381 this.fail(message + ": object was an instance of the not expected type"); } 326 382 catch(e) { this.error(e); } 383 }, 384 assertRespondsTo: function(method, obj) { 385 var message = arguments[2] || 'assertRespondsTo'; 386 try { 387 (obj[method] && typeof obj[method] == 'function') ? this.pass() : 388 this.fail(message + ": object doesn't respond to [" + method + "]"); } 389 catch(e) { this.error(e); } 390 }, 391 assertReturnsTrue: function(method, obj) { 392 var message = arguments[2] || 'assertReturnsTrue'; 393 try { 394 var m = obj[method]; 395 if(!m) m = obj['is'+method.charAt(0).toUpperCase()+method.slice(1)]; 396 m() ? this.pass() : 397 this.fail(message + ": method returned false"); } 398 catch(e) { this.error(e); } 399 }, 400 assertReturnsFalse: function(method, obj) { 401 var message = arguments[2] || 'assertReturnsFalse'; 402 try { 403 var m = obj[method]; 404 if(!m) m = obj['is'+method.charAt(0).toUpperCase()+method.slice(1)]; 405 !m() ? this.pass() : 406 this.fail(message + ": method returned true"); } 407 catch(e) { this.error(e); } 408 }, 409 assertRaise: function(exceptionName, method) { 410 var message = arguments[2] || 'assertRaise'; 411 try { 412 method(); 413 this.fail(message + ": exception expected but none was raised"); } 414 catch(e) { 415 ((exceptionName == null) || (e.name==exceptionName)) ? this.pass() : this.error(e); 416 } 417 }, 418 assertElementsMatch: function() { 419 var expressions = $A(arguments), elements = $A(expressions.shift()); 420 if (elements.length != expressions.length) { 421 this.fail('assertElementsMatch: size mismatch: ' + elements.length + ' elements, ' + expressions.length + ' expressions'); 422 return false; 423 } 424 elements.zip(expressions).all(function(pair, index) { 425 var element = $(pair.first()), expression = pair.last(); 426 if (element.match(expression)) return true; 427 this.fail('assertElementsMatch: (in index ' + index + ') expected ' + expression.inspect() + ' but got ' + element.inspect()); 428 }.bind(this)) && this.pass(); 429 }, 430 assertElementMatches: function(element, expression) { 431 this.assertElementsMatch([element], expression); 432 }, 433 benchmark: function(operation, iterations) { 434 var startAt = new Date(); 435 (iterations || 1).times(operation); 436 var timeTaken = ((new Date())-startAt); 437 this.info((arguments[2] || 'Operation') + ' finished ' + 438 iterations + ' iterations in ' + (timeTaken/1000)+'s' ); 439 return timeTaken; 327 440 }, 328 441 _isVisible: function(element) { … … 356 469 Test.Unit.Assertions.prototype.initialize.bind(this)(); 357 470 this.name = name; 358 this.test = test || function() {}; 471 472 if(typeof test == 'string') { 473 test = test.gsub(/(\.should[^\(]+\()/,'#{0}this,'); 474 test = test.gsub(/(\.should[^\(]+)\(this,\)/,'#{1}(this)'); 475 this.test = function() { 476 eval('with(this){'+test+'}'); 477 } 478 } else { 479 this.test = test || function() {}; 480 } 481 359 482 this.setup = setup || function() {}; 360 483 this.teardown = teardown || function() {}; … … 382 505 } 383 506 }); 507 508 // *EXPERIMENTAL* BDD-style testing to please non-technical folk 509 // This draws many ideas from RSpec http://rspec.rubyforge.org/ 510 511 Test.setupBDDExtensionMethods = function(){ 512 var METHODMAP = { 513 shouldEqual: 'assertEqual', 514 shouldNotEqual: 'assertNotEqual', 515 shouldEqualEnum: 'assertEnumEqual', 516 shouldBeA: 'assertType', 517 shouldNotBeA: 'assertNotOfType', 518 shouldBeAn: 'assertType', 519 shouldNotBeAn: 'assertNotOfType', 520 shouldBeNull: 'assertNull', 521 shouldNotBeNull: 'assertNotNull', 522 523 shouldBe: 'assertReturnsTrue', 524 shouldNotBe: 'assertReturnsFalse', 525 shouldRespondTo: 'assertRespondsTo' 526 }; 527 Test.BDDMethods = {}; 528 for(m in METHODMAP) { 529 Test.BDDMethods[m] = eval( 530 'function(){'+ 531 'var args = $A(arguments);'+ 532 'var scope = args.shift();'+ 533 'scope.'+METHODMAP[m]+'.apply(scope,(args || []).concat([this])); }'); 534 } 535 [Array.prototype, String.prototype, Number.prototype].each( 536 function(p){ Object.extend(p, Test.BDDMethods) } 537 ); 538 } 539 540 Test.context = function(name, spec, log){ 541 Test.setupBDDExtensionMethods(); 542 543 var compiledSpec = {}; 544 var titles = {}; 545 for(specName in spec) { 546 switch(specName){ 547 case "setup": 548 case "teardown": 549 compiledSpec[specName] = spec[specName]; 550 break; 551 default: 552 var testName = 'test'+specName.gsub(/\s+/,'-').camelize(); 553 var body = spec[specName].toString().split('\n').slice(1); 554 if(/^\{/.test(body[0])) body = body.slice(1); 555 body.pop(); 556 body = body.map(function(statement){ 557 return statement.strip() 558 }); 559 compiledSpec[testName] = body.join('\n'); 560 titles[testName] = specName; 561 } 562 } 563 new Test.Unit.Runner(compiledSpec, { titles: titles, testLog: log || 'testlog', context: name }); 564 }; -
tags/2.2/wp-includes/js/scriptaculous/wp-scriptaculous.js
r5468 r5480 13 13 14 14 var Scriptaculous = { 15 Version: '1. 6.1',15 Version: '1.7.0', 16 16 require: function(libraryName) { 17 17 // inserting via DOM fails in Safari 2.0, so brute force approach -
tags/2.2/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js
r5468 r5480 1 1 /** 2 * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $2 * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ 3 3 * 4 4 * @author Moxiecode 5 * @copyright Copyright © 2004-200 6, Moxiecode Systems AB, All rights reserved.5 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. 6 6 */ 7 7 … … 15 15 author : 'Moxiecode Systems AB', 16 16 authorurl : 'http://tinymce.moxiecode.com', 17 infourl : 'http:// tinymce.moxiecode.com/tinymce/docs/plugin_autosave.html',17 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autosave', 18 18 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion 19 19 }; -
tags/2.2/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js
r5468 r5480 1 1 /** 2 * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $2 * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ 3 3 * 4 4 * @author Moxiecode 5 * @copyright Copyright © 2004-200 6, Moxiecode Systems AB, All rights reserved.5 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. 6 6 */ 7 7 … … 15 15 author : 'Moxiecode Systems AB', 16 16 authorurl : 'http://tinymce.moxiecode.com', 17 infourl : 'http:// tinymce.moxiecode.com/tinymce/docs/plugin_directionality.html',17 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/directionality', 18 18 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion 19 19 }; -
tags/2.2/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js
r5468 r5480 1 1 /** 2 * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $2 * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ 3 3 * 4 4 * Moxiecode DHTML Windows script. 5 5 * 6 6 * @author Moxiecode 7 * @copyright Copyright © 2004-200 6, Moxiecode Systems AB, All rights reserved.7 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. 8 8 */ 9 9 … … 16 16 author : 'Moxiecode Systems AB', 17 17 authorurl : 'http://tinymce.moxiecode.com', 18 infourl : 'http:// tinymce.moxiecode.com/tinymce/docs/plugin_inlinepopups.html',18 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/inlinepopups', 19 19 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion 20 20 }; … … 27 27 28 28 TinyMCE_Engine.prototype.orgOpenWindow = TinyMCE_Engine.prototype.openWindow; 29 TinyMCE_Engine.prototype.orgCloseWindow = TinyMCE_Engine.prototype.closeWindow; 29 30 30 31 TinyMCE_Engine.prototype.openWindow = function(template, args) { … … 53 54 height = 200; 54 55 56 if (!(minWidth = parseInt(template['minWidth']))) 57 minWidth = 100; 58 59 if (!(minHeight = parseInt(template['minHeight']))) 60 minHeight = 100; 61 55 62 resizable = (args && args['resizable']) ? args['resizable'] : "no"; 56 63 scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no"; … … 67 74 68 75 var elm = document.getElementById(this.selectedInstance.editorId + '_parent'); 69 var pos = tinyMCE.getAbsPosition(elm); 76 77 if (tinyMCE.hasPlugin('fullscreen') && this.selectedInstance.getData('fullscreen').enabled) 78 pos = { absLeft: 0, absTop: 0 }; 79 else 80 pos = tinyMCE.getAbsPosition(elm); 70 81 71 82 // Center div in editor area … … 73 84 pos.absTop += Math.round((elm.firstChild.clientHeight / 2) - (height / 2)); 74 85 75 url += tinyMCE.settings['imp_version'] ? (url.indexOf('?')==-1?'?':'&') + 'ver=' + tinyMCE.settings['imp_version'] : ''; 76 77 mcWindows.open(url, mcWindows.idCounter++, "modal=yes,width=" + width+ ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",statusbar=" + resizable + ",left=" + pos.absLeft + ",top=" + pos.absTop); 78 }; 79 80 TinyMCE_Engine.prototype.orgCloseWindow = TinyMCE_Engine.prototype.closeWindow; 86 url += tinyMCE.settings['imp_version'] ? (url.indexOf('?')==-1?'?':'&') + 'ver=' + tinyMCE.settings['imp_version'] : ''; // WordPress cache buster 87 88 mcWindows.open(url, mcWindows.idCounter++, "modal=yes,width=" + width+ ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",statusbar=" + resizable + ",left=" + pos.absLeft + ",top=" + pos.absTop + ",minWidth=" + minWidth + ",minHeight=" + minHeight ); 89 }; 81 90 82 91 TinyMCE_Engine.prototype.closeWindow = function(win) { 83 if (mcWindows.selectedWindow != null) 84 mcWindows.selectedWindow.close(); 85 else 92 var gotit = false, n, w; 93 for (n in mcWindows.windows) { 94 w = mcWindows.windows[n]; 95 if (typeof(w) == 'function') continue; 96 if (win.name == w.id + '_iframe') { 97 w.close(); 98 gotit = true; 99 } 100 } 101 if (!gotit) 86 102 this.orgCloseWindow(win); 103 104 tinyMCE.selectedInstance.getWin().focus(); 87 105 }; 88 106 … … 112 130 this.selectedWindow = null; 113 131 this.lastSelectedWindow = null; 114 this.zindex = 100 ;132 this.zindex = 1001; 115 133 this.mouseDownScreenX = 0; 116 134 this.mouseDownScreenY = 0; … … 132 150 this.addEvent(document, "mouseup", mcWindows.eventDispatcher); 133 151 152 this.addEvent(window, "resize", mcWindows.eventDispatcher); 153 this.addEvent(document, "scroll", mcWindows.eventDispatcher); 154 134 155 this.doc = document; 156 }; 157 158 TinyMCE_Windows.prototype.getBounds = function() { 159 if (!this.bounds) { 160 var vp = tinyMCE.getViewPort(window); 161 var top, left, bottom, right, docEl = this.doc.documentElement; 162 163 top = vp.top; 164 left = vp.left; 165 bottom = vp.height + top - 2; 166 right = vp.width + left - 22; // TODO this number is platform dependant 167 // x1, y1, x2, y2 168 this.bounds = [left, top, right, bottom]; 169 } 170 return this.bounds; 171 }; 172 173 TinyMCE_Windows.prototype.clampBoxPosition = function(x, y, w, h, minW, minH) { 174 var bounds = this.getBounds(); 175 176 x = Math.max(bounds[0], Math.min(bounds[2], x + w) - w); 177 y = Math.max(bounds[1], Math.min(bounds[3], y + h) - h); 178 179 return this.clampBoxSize(x, y, w, h, minW, minH); 180 }; 181 182 TinyMCE_Windows.prototype.clampBoxSize = function(x, y, w, h, minW, minH) { 183 var bounds = this.getBounds(); 184 185 return [ 186 x, y, 187 Math.max(minW, Math.min(bounds[2], x + w) - x), 188 Math.max(minH, Math.min(bounds[3], y + h) - y) 189 ]; 135 190 }; 136 191 … … 183 238 mcWindows.selectedWindow.onFocus(e); 184 239 break; 240 case "scroll": 241 case "resize": 242 if (mcWindows.clampUpdateTimeout) 243 clearTimeout(mcWindows.clampUpdateTimeout); 244 mcWindows.clampEventType = e.type; 245 mcWindows.clampUpdateTimeout = 246 setTimeout(function () {mcWindows.updateClamping()}, 100); 247 break; 248 } 249 }; 250 251 TinyMCE_Windows.prototype.updateClamping = function () { 252 var clamp, oversize, etype = mcWindows.clampEventType; 253 254 this.bounds = null; // Recalc window bounds on resize/scroll 255 this.clampUpdateTimeout = null; 256 257 for (var n in this.windows) { 258 win = this.windows[n]; 259 if (typeof(win) == 'function' || ! win.winElement) continue; 260 261 clamp = mcWindows.clampBoxPosition( 262 win.left, win.top, 263 win.winElement.scrollWidth, 264 win.winElement.scrollHeight, 265 win.features.minWidth, 266 win.features.minHeight 267 ); 268 oversize = ( 269 clamp[2] != win.winElement.scrollWidth || 270 clamp[3] != win.winElement.scrollHeight 271 ) ? true : false; 272 273 if (!oversize || win.features.resizable == "yes" || etype != "scroll") 274 win.moveTo(clamp[0], clamp[1]); 275 if (oversize && win.features.resizable == "yes") 276 win.resizeTo(clamp[2], clamp[3]); 185 277 } 186 278 }; … … 190 282 obj.attachEvent("on" + name, handler); 191 283 else 192 obj.addEventListener(name, handler, true);284 obj.addEventListener(name, handler, false); 193 285 }; 194 286 … … 214 306 options['width'] = "300"; 215 307 options['height'] = "300"; 308 options['minwidth'] = "100"; 309 options['minheight'] = "100"; 216 310 options['resizable'] = "yes"; 217 311 options['minimizable'] = "yes"; … … 237 331 options['width'] = parseInt(options['width']); 238 332 options['height'] = parseInt(options['height']); 333 options['minWidth'] = parseInt(options['minwidth']); 334 options['minHeight'] = parseInt(options['minheight']); 239 335 240 336 return options; … … 249 345 250 346 features = this.parseFeatures(features); 347 348 // Clamp specified dimensions 349 var clamp = mcWindows.clampBoxPosition( 350 features['left'], features['top'], 351 features['width'], features['height'], 352 features['minWidth'], features['minHeight'] 353 ); 354 355 features['left'] = clamp[0]; 356 features['top'] = clamp[1]; 357 358 if (features['resizable'] == "yes") { 359 features['width'] = clamp[2]; 360 features['height'] = clamp[3]; 361 } 251 362 252 363 // Create div … … 282 393 html += '<head>'; 283 394 html += '<title>Wrapper iframe</title>'; 395 if (this.isMac) html += '<style type="text/css">.mceWindowTitle{float:none;margin:0;width:100%;text-align:center;}.mceWindowClose{float:none;position:absolute;left:0px;top:0px;}</style>'; 284 396 html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'; 285 397 html += '<link href="' + this.getParam("css_file") + '" rel="stylesheet" type="text/css" />'; 286 if ( this.isMac ) html += '<style type="text/css">.mceWindowTitle{float:none;margin:0;text-align:center;}.mceWindowClose{float:none;position:absolute;left:0px;top:0px;}</style>';287 398 html += '</head>'; 288 399 html += '<body onload="parent.mcWindows.onLoad(\'' + name + '\');">'; … … 294 405 html += ' <div class="mceWindowHeadTools">'; 295 406 html += ' <a href="javascript:parent.mcWindows.windows[\'' + name + '\'].close();" target="_self" onmousedown="return false;" class="mceWindowClose"><img border="0" src="' + imgPath + '/window_close.gif" /></a>'; 296 // html += ' <a href="javascript:mcWindows.windows[\'' + name + '\'].maximize();" target="_self" onmousedown="return false;" class="mceWindowMaximize"></a>'; 297 // html += ' <a href="javascript:mcWindows.windows[\'' + name + '\'].minimize();" target="_self" onmousedown="return false;" class="mceWindowMinimize"></a>'; 407 if (features['resizable'] == "yes" && features['maximizable'] == "yes") 408 html += ' <a href="javascript:parent.mcWindows.windows[\'' + name + '\'].maximize();" target="_self" onmousedown="return false;" class="mceWindowMaximize"><img border="0" src="' + imgPath + '/window_maximize.gif" /></a>'; 409 // html += ' <a href="javascript:mcWindows.windows[\'' + name + '\'].minimize();" target="_self" onmousedown="return false;" class="mceWindowMinimize"></a>'; 298 410 html += ' </div>'; 299 411 html += '</div><div id="' + id + '_body" class="mceWindowBody" style="width: ' + width + 'px; height: ' + height + 'px;">'; … … 324 436 // Blocks the document events by placing a image over the whole document 325 437 TinyMCE_Windows.prototype.setDocumentLock = function(state) { 438 var elm = document.getElementById('mcWindowEventBlocker'); 439 326 440 if (state) { 327 var elm = document.getElementById('mcWindowEventBlocker');328 441 if (elm == null) { 329 442 elm = document.createElement("div"); … … 349 462 elm.style.zIndex = mcWindows.zindex-1; 350 463 elm.style.display = "block"; 351 } else { 352 var elm = document.getElementById('mcWindowEventBlocker'); 353 464 } else if (elm != null) { 354 465 if (mcWindows.windows.length == 0) 355 466 elm.parentNode.removeChild(elm); … … 445 556 div.setAttribute("height", (height)); 446 557 div.style.position = "absolute"; 558 447 559 div.style.left = left + "px"; 448 560 div.style.top = top + "px"; … … 471 583 iframe.setAttribute("width", iframeWidth); 472 584 iframe.setAttribute("height", iframeHeight); 473 //iframe.setAttribute("src", "../jscripts/tiny_mce/blank.htm");585 // iframe.setAttribute("src", "../jscripts/tiny_mce/blank.htm"); 474 586 // iframe.setAttribute("allowtransparency", "false"); 475 587 iframe.setAttribute("scrolling", "no"); … … 520 632 521 633 TinyMCE_Window.prototype.maximize = function() { 522 634 if (this.restoreSize) { 635 this.moveTo(this.restoreSize[0], this.restoreSize[1]); 636 this.resizeTo(this.restoreSize[2], this.restoreSize[3]); 637 this.updateClamping(); 638 this.restoreSize = null; 639 } else { 640 var bounds = mcWindows.getBounds(); 641 this.restoreSize = [ 642 this.left, this.top, 643 this.winElement.scrollWidth, 644 this.winElement.scrollHeight 645 ]; 646 this.moveTo(bounds[0], bounds[1]); 647 this.resizeTo( 648 bounds[2] - bounds[0], 649 bounds[3] - bounds[1] 650 ); 651 } 523 652 }; 524 653 … … 550 679 mcWindows.windows = mcWindowsNew; 551 680 552 //alert(mcWindows.doc.getElementById(this.id + "_iframe"));681 // alert(mcWindows.doc.getElementById(this.id + "_iframe")); 553 682 554 683 var e = mcWindows.doc.getElementById(this.id + "_iframe"); … … 559 688 560 689 mcWindows.setDocumentLock(false); 561 562 tinyMCE.selectedInstance.getWin().focus();563 690 }; 564 691 565 692 TinyMCE_Window.prototype.onMouseMove = function(e) { 566 var scrollX = 0;//this.doc.body.scrollLeft; 567 var scrollY = 0;//this.doc.body.scrollTop; 568 693 var clamp; 569 694 // Calculate real X, Y 570 695 var dx = e.screenX - mcWindows.mouseDownScreenX; … … 573 698 switch (mcWindows.action) { 574 699 case "resize": 575 width = mcWindows.mouseDownWidth + (e.screenX - mcWindows.mouseDownScreenX); 576 height = mcWindows.mouseDownHeight + (e.screenY - mcWindows.mouseDownScreenY); 577 578 width = width < 100 ? 100 : width; 579 height = height < 100 ? 100 : height; 580 581 this.wrapperIFrameElement.style.width = width+2; 582 this.wrapperIFrameElement.style.height = height+2; 583 this.wrapperIFrameElement.width = width+2; 584 this.wrapperIFrameElement.height = height+2; 585 this.winElement.style.width = width; 586 this.winElement.style.height = height; 587 588 height = height - this.deltaHeight; 589 590 this.containerElement.style.width = width; 591 592 this.iframeElement.style.width = width; 593 this.iframeElement.style.height = height; 594 this.bodyElement.style.width = width; 595 this.bodyElement.style.height = height; 596 this.headElement.style.width = width; 597 //this.statusElement.style.width = width; 700 clamp = mcWindows.clampBoxSize( 701 this.left, this.top, 702 mcWindows.mouseDownWidth + (e.screenX - mcWindows.mouseDownScreenX), 703 mcWindows.mouseDownHeight + (e.screenY - mcWindows.mouseDownScreenY), 704 this.features.minWidth, this.features.minHeight 705 ); 706 707 this.resizeTo(clamp[2], clamp[3]); 598 708 599 709 mcWindows.cancelEvent(e); … … 603 713 this.left = mcWindows.mouseDownLayerX + (e.screenX - mcWindows.mouseDownScreenX); 604 714 this.top = mcWindows.mouseDownLayerY + (e.screenY - mcWindows.mouseDownScreenY); 605 this.winElement.style.left = this.left + "px"; 606 this.winElement.style.top = this.top + "px"; 715 this.updateClamping(); 607 716 608 717 mcWindows.cancelEvent(e); 609 718 break; 610 719 } 720 }; 721 722 TinyMCE_Window.prototype.moveTo = function (x, y) { 723 this.left = x; 724 this.top = y; 725 726 this.winElement.style.left = this.left + "px"; 727 this.winElement.style.top = this.top + "px"; 728 }; 729 730 TinyMCE_Window.prototype.resizeTo = function (width, height) { 731 this.wrapperIFrameElement.style.width = (width+2) + 'px'; 732 this.wrapperIFrameElement.style.height = (height+2) + 'px'; 733 this.wrapperIFrameElement.width = width+2; 734 this.wrapperIFrameElement.height = height+2; 735 this.winElement.style.width = width + 'px'; 736 this.winElement.style.height = height + 'px'; 737 738 height = height - this.deltaHeight; 739 740 this.containerElement.style.width = width + 'px'; 741 this.iframeElement.style.width = width + 'px'; 742 this.iframeElement.style.height = height + 'px'; 743 this.bodyElement.style.width = width + 'px'; 744 this.bodyElement.style.height = height + 'px'; 745 this.headElement.style.width = width + 'px'; 746 //this.statusElement.style.width = width + 'px'; 747 }; 748 749 TinyMCE_Window.prototype.updateClamping = function () { 750 var clamp, oversize; 751 752 clamp = mcWindows.clampBoxPosition( 753 this.left, this.top, 754 this.winElement.scrollWidth, 755 this.winElement.scrollHeight, 756 this.features.minWidth, this.features.minHeight 757 ); 758 oversize = ( 759 clamp[2] != this.winElement.scrollWidth || 760 clamp[3] != this.winElement.scrollHeight 761 ) ? true : false; 762 763 this.moveTo(clamp[0], clamp[1]); 764 if (this.features.resizable == "yes" && oversize) 765 this.resizeTo(clamp[2], clamp[3]); 611 766 }; 612 767 … … 637 792 TinyMCE_Window.prototype.onMouseDown = function(e) { 638 793 var elm = mcWindows.isMSIE ? this.wrapperFrame.event.srcElement : e.target; 639 640 var scrollX = 0;//this.doc.body.scrollLeft;641 var scrollY = 0;//this.doc.body.scrollTop;642 794 643 795 mcWindows.mouseDownScreenX = e.screenX; -
tags/2.2/wp-includes/js/tinymce/plugins/paste/editor_plugin.js
r5468 r5480 1 1 /** 2 * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $2 * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ 3 3 * 4 4 * @author Moxiecode 5 * @copyright Copyright © 2004-200 6, Moxiecode Systems AB, All rights reserved.5 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. 6 6 */ 7 7 … … 15 15 author : 'Moxiecode Systems AB', 16 16 authorurl : 'http://tinymce.moxiecode.com', 17 infourl : 'http:// tinymce.moxiecode.com/tinymce/docs/plugin_paste.html',17 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste', 18 18 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion 19 19 }; … … 23 23 if (tinyMCE.isMSIE && tinyMCE.getParam("paste_auto_cleanup_on_paste", false)) 24 24 tinyMCE.addEvent(inst.getBody(), "paste", TinyMCE_PastePlugin._handlePasteEvent); 25 }, 26 27 handleEvent : function(e) { 28 // Force paste dialog if non IE browser 29 if (!tinyMCE.isRealIE && tinyMCE.getParam("paste_auto_cleanup_on_paste", false) && e.ctrlKey && e.keyCode == 86 && e.type == "keydown") { 30 window.setTimeout('tinyMCE.selectedInstance.execCommand("mcePasteText",true)', 1); 31 return tinyMCE.cancelEvent(e); 32 } 33 34 return true; 25 35 }, 26 36 -
tags/2.2/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php
r5468 r5480 1 1 <?php 2 /* * 2 /* * 3 3 * Tiny Spelling Interface for TinyMCE Spell Checking. 4 4 * 5 5 * Copyright © 2006 Moxiecode Systems AB 6 6 */ 7 8 require_once("HttpClient.class.php");9 7 10 8 class TinyGoogleSpell { … … 23 21 24 22 for ($i=0; $i<count($matches); $i++) 25 $words[] = substr($wordstr, $matches[$i][1], $matches[$i][2]);23 $words[] = $this->unhtmlentities(mb_substr($wordstr, $matches[$i][1], $matches[$i][2], "UTF-8")); 26 24 27 25 return $words; 26 } 27 28 function unhtmlentities($string) { 29 $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); 30 $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string); 31 32 $trans_tbl = get_html_translation_table(HTML_ENTITIES); 33 $trans_tbl = array_flip($trans_tbl); 34 35 return strtr($string, $trans_tbl); 28 36 } 29 37 … … 35 43 36 44 if (count($matches) > 0) 37 $sug = explode("\t", $matches[0][4]);45 $sug = explode("\t", utf8_encode($this->unhtmlentities($matches[0][4]))); 38 46 39 47 return $sug; 40 48 } 41 49 50 function _xmlChars($string) { 51 $trans = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES); 52 53 foreach ($trans as $k => $v) 54 $trans[$k] = "&#".ord($k).";"; 55 56 return strtr($string, $trans); 57 } 58 42 59 function _getMatches($word_list) { 43 $xml = ""; 44 45 // Setup HTTP Client 46 $client = new HttpClient('www.google.com'); 47 $client->setUserAgent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR'); 48 $client->setHandleRedirects(false); 49 $client->setDebug(false); 60 $server = "www.google.com"; 61 $port = 443; 62 $path = "/tbproxy/spell?lang=" . $this->lang . "&hl=en"; 63 $host = "www.google.com"; 64 $url = "https://" . $server; 50 65 51 66 // Setup XML request 52 $xml .= '<?xml version="1.0" encoding="utf-8" ?>'; 53 $xml .= '<spellrequest textalreadyclipped="0" ignoredups="0" ignoredigits="1" ignoreallcaps="1">'; 54 $xml .= '<text>' . htmlentities($word_list) . '</text></spellrequest>'; 67 $xml = '<?xml version="1.0" encoding="utf-8" ?><spellrequest textalreadyclipped="0" ignoredups="0" ignoredigits="1" ignoreallcaps="1"><text>' . $word_list . '</text></spellrequest>'; 55 68 56 // Execute HTTP Post to Google 57 if (!$client->post('/tbproxy/spell?lang=' . $this->lang, $xml)) { 58 $this->errorMsg[] = 'An error occurred: ' . $client->getError(); 59 return array(); 69 $header = "POST ".$path." HTTP/1.0 \r\n"; 70 $header .= "MIME-Version: 1.0 \r\n"; 71 $header .= "Content-type: application/PTI26 \r\n"; 72 $header .= "Content-length: ".strlen($xml)." \r\n"; 73 $header .= "Content-transfer-encoding: text \r\n"; 74 $header .= "Request-number: 1 \r\n"; 75 $header .= "Document-type: Request \r\n"; 76 $header .= "Interface-Version: Test 1.4 \r\n"; 77 $header .= "Connection: close \r\n\r\n"; 78 $header .= $xml; 79 //$this->_debugData($xml); 80 81 // Use curl if it exists 82 if (function_exists('curl_init')) { 83 // Use curl 84 $ch = curl_init(); 85 curl_setopt($ch, CURLOPT_URL,$url); 86 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 87 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header); 88 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 89 $xml = curl_exec($ch); 90 curl_close($ch); 91 } else { 92 // Use raw sockets 93 $fp = fsockopen("ssl://" . $server, $port, $errno, $errstr, 30); 94 if ($fp) { 95 // Send request 96 fwrite($fp, $header); 97 98 // Read response 99 $xml = ""; 100 while (!feof($fp)) 101 $xml .= fgets($fp, 128); 102 103 fclose($fp); 104 } else 105 echo "Could not open SSL connection to google."; 60 106 } 61 107 108 //$this->_debugData($xml); 109 62 110 // Grab and parse content 63 $xml = $client->getContent();64 111 preg_match_all('/<c o="([^"]*)" l="([^"]*)" s="([^"]*)">([^<]*)<\/c>/', $xml, $matches, PREG_SET_ORDER); 65 112 66 113 return $matches; 114 } 115 116 function _debugData($data) { 117 $fh = @fopen("debug.log", 'a+'); 118 @fwrite($fh, $data); 119 @fclose($fh); 67 120 } 68 121 } -
tags/2.2/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php
r5468 r5480 6 6 * 7 7 */ 8 8 9 9 10 class TinyPspellShell { … … 28 29 29 30 $this->tmpfile = tempnam($config['tinypspellshell.tmp'], "tinyspell"); 30 $this->cmd = "cat ". $this->tmpfile ." | " . $config['tinypspellshell.aspell'] . " -a --lang=". $this->lang; 31 32 if(preg_match("#win#i",php_uname())) 33 $this->cmd = $config['tinypspellshell.aspell'] . " -a --lang=". $this->lang." --encoding=utf-8 -H < $this->tmpfile 2>&1"; 34 else 35 $this->cmd = "cat ". $this->tmpfile ." | " . $config['tinypspellshell.aspell'] . " -a --encoding=utf-8 -H --lang=". $this->lang; 31 36 } 32 37 … … 37 42 foreach($wordArray as $key => $value) 38 43 fwrite($fh, "^" . $value . "\n"); 39 40 44 fclose($fh); 41 45 } else { … … 45 49 46 50 $data = shell_exec($this->cmd); 47 @unlink($this->tmpfile); 51 @unlink($this->tmpfile); 52 48 53 $returnData = array(); 49 54 $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); … … 67 72 // Returns array with suggestions or false if failed. 68 73 function getSuggestion($word) { 74 if (function_exists("mb_convert_encoding")) 75 $word = mb_convert_encoding($word, "ISO-8859-1", mb_detect_encoding($word, "UTF-8")); 76 else 77 $word = utf8_encode($word); 78 69 79 if ($fh = fopen($this->tmpfile, "w")) { 70 80 fwrite($fh, "!\n"); … … 72 82 fclose($fh); 73 83 } else 74 wp_die("Error opening tmp file.");84 die("Error opening tmp file."); 75 85 76 86 $data = shell_exec($this->cmd); 77 @unlink($this->tmpfile); 87 88 @unlink($this->tmpfile); 89 78 90 $returnData = array(); 79 91 $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); … … 95 107 return $returnData; 96 108 } 109 110 function _debugData($data) { 111 $fh = @fopen("debug.log", 'a+'); 112 @fwrite($fh, $data); 113 @fclose($fh); 114 } 115 97 116 } 98 117 -
tags/2.2/wp-includes/js/tinymce/plugins/spellchecker/config.php
r5468 r5480 2 2 $spellCheckerConfig = array(); 3 3 4 // Spellchecker class use 5 // require_once("classes/TinyPspellShell.class.php"); // Command line pspell 6 require_once("classes/TinyGoogleSpell.class.php"); // Google web service 7 // require_once("classes/TinyPspell.class.php"); // Internal PHP version 8 4 9 // General settings 5 10 $spellCheckerConfig['enabled'] = true; 6 7 // Pspell shell specific settings8 $spellCheckerConfig['tinypspellshell.aspell'] = '/usr/bin/aspell';9 $spellCheckerConfig['tinypspellshell.tmp'] = '/tmp/tinyspell/0';10 11 11 12 // Default settings … … 18 19 $spellCheckerConfig['default.encoding'] = ""; 19 20 20 // Spellchecker class use 21 if ( function_exists('pspell_new') ) 22 require_once("classes/TinyPspell.class.php"); // Internal PHP version 23 24 elseif ( file_exists($spellCheckerConfig['tinypspellshell.aspell']) ) 25 require_once("classes/TinyPspellShell.class.php"); // Command line pspell 26 27 else 28 require_once("classes/TinyGoogleSpell.class.php"); // Google web service 21 // Pspell shell specific settings 22 $spellCheckerConfig['tinypspellshell.aspell'] = '/usr/bin/aspell'; 23 $spellCheckerConfig['tinypspellshell.tmp'] = '/tmp'; 29 24 ?> -
tags/2.2/wp-includes/js/tinymce/plugins/spellchecker/css/content.css
r5468 r5480 1 1 .mceItemHiddenSpellWord { 2 2 background: url('../images/wline.gif') repeat-x bottom left; 3 bo2rder-bottom: 1px dashed red;4 3 cursor: default; 5 4 } -
tags/2.2/wp-includes/js/tinymce/plugins/spellchecker/css/spellchecker.css
r5468 r5480 32 32 font-weight: bold; 33 33 font-size: 11px; 34 background-color: #FFF; 34 35 } -
tags/2.2/wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js
r5468 r5480 1 /** 2 * $RCSfile: editor_plugin_src.js,v $ 3 * $Revision: 1.4 $ 4 * $Date: 2006/03/24 17:24:50 $ 5 * 6 * @author Moxiecode 7 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved. 8 */ 9 10 tinyMCE.importPluginLanguagePack('spellchecker', 'en,sv,nn,nb'); 11 12 // Plucin static class 13 var TinyMCE_SpellCheckerPlugin = { 14 _contextMenu : new TinyMCE_Menu(), 15 _menu : new TinyMCE_Menu(), 16 _counter : 0, 17 18 getInfo : function() { 19 return { 20 longname : 'Spellchecker', 21 author : 'Moxiecode Systems AB', 22 authorurl : 'http://tinymce.moxiecode.com', 23 infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_spellchecker.html', 24 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion 25 }; 26 }, 27 28 handleEvent : function(e) { 29 var elm = tinyMCE.isMSIE ? e.srcElement : e.target; 30 var inst = tinyMCE.selectedInstance, args = ''; 31 var self = TinyMCE_SpellCheckerPlugin; 32 var cm = self._contextMenu; 33 var p, p2, x, y, sx, sy, h, elm; 34 35 // Handle click on word 36 if ((e.type == "click" || e.type == "contextmenu") && elm) { 37 do { 38 if (tinyMCE.getAttrib(elm, 'class') == "mceItemHiddenSpellWord") { 39 inst.spellCheckerElm = elm; 40 41 // Setup arguments 42 args += 'id=' + inst.editorId + "|" + (++self._counter); 43 args += '&cmd=suggest&check=' + escape(elm.innerHTML); 44 args += '&lang=' + escape(inst.spellCheckerLang); 45 46 elm = inst.spellCheckerElm; 47 p = tinyMCE.getAbsPosition(inst.iframeElement); 48 p2 = tinyMCE.getAbsPosition(elm); 49 h = parseInt(elm.offsetHeight); 50 sx = inst.getBody().scrollLeft; 51 sy = inst.getBody().scrollTop; 52 x = p.absLeft + p2.absLeft - sx; 53 y = p.absTop + p2.absTop - sy + h; 54 55 cm.clear(); 56 cm.addTitle(tinyMCE.getLang('lang_spellchecker_wait', '', true)); 57 cm.show(); 58 cm.moveTo(x, y); 59 60 inst.selection.selectNode(elm, false, false); 61 62 self._sendAjax(self.baseURL + "/tinyspell.php", self._ajaxResponse, 'post', args); 63 64 tinyMCE.cancelEvent(e); 65 return false; 66 } 67 } while ((elm = elm.parentNode)); 68 } 69 70 return true; 71 }, 72 73 initInstance : function(inst) { 74 var self = TinyMCE_SpellCheckerPlugin, m = self._menu, cm = self._contextMenu, e; 75 76 tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/spellchecker/css/content.css"); 77 78 if (!tinyMCE.hasMenu('spellcheckercontextmenu')) { 79 tinyMCE.importCSS(document, tinyMCE.baseURL + "/plugins/spellchecker/css/spellchecker.css"); 80 81 cm.init({drop_menu : false}); 82 tinyMCE.addMenu('spellcheckercontextmenu', cm); 83 } 84 85 if (!tinyMCE.hasMenu('spellcheckermenu')) { 86 m.init({}); 87 tinyMCE.addMenu('spellcheckermenu', m); 88 } 89 90 inst.spellCheckerLang = 'en'; 91 self._buildSettingsMenu(inst, null); 92 93 e = self._getBlockBoxLayer(inst).create('div', 'mceBlockBox', document.getElementById(inst.editorId + '_parent')); 94 self._getMsgBoxLayer(inst).create('div', 'mceMsgBox', document.getElementById(inst.editorId + '_parent')); 95 }, 96 97 _getMsgBoxLayer : function(inst) { 98 if (!inst.spellCheckerMsgBoxL) 99 inst.spellCheckerMsgBoxL = new TinyMCE_Layer(inst.editorId + '_spellcheckerMsgBox', false); 100 101 return inst.spellCheckerMsgBoxL; 102 }, 103 104 _getBlockBoxLayer : function(inst) { 105 if (!inst.spellCheckerBoxL) 106 inst.spellCheckerBoxL = new TinyMCE_Layer(inst.editorId + '_spellcheckerBlockBox', false); 107 108 return inst.spellCheckerBoxL; 109 }, 110 111 _buildSettingsMenu : function(inst, lang) { 112 var i, ar = tinyMCE.getParam('spellchecker_languages', '+English=en').split(','), p; 113 var self = TinyMCE_SpellCheckerPlugin, m = self._menu, c; 114 115 m.clear(); 116 m.addTitle(tinyMCE.getLang('lang_spellchecker_langs', '', true)); 117 118 for (i=0; i<ar.length; i++) { 119 if (ar[i] != '') { 120 p = ar[i].split('='); 121 c = 'mceMenuCheckItem'; 122 123 if (p[0].charAt(0) == '+') { 124 p[0] = p[0].substring(1); 125 126 if (lang == null) { 127 c = 'mceMenuSelectedItem'; 128 inst.spellCheckerLang = p[1]; 129 } 130 } 131 132 if (lang == p[1]) 133 c = 'mceMenuSelectedItem'; 134 135 m.add({text : p[0], js : "tinyMCE.execInstanceCommand('" + inst.editorId + "','mceSpellCheckerSetLang',false,'" + p[1] + "');", class_name : c}); 136 } 137 } 138 }, 139 140 setupContent : function(editor_id, body, doc) { 141 TinyMCE_SpellCheckerPlugin._removeWords(doc); 142 }, 143 144 getControlHTML : function(cn) { 145 switch (cn) { 146 case "spellchecker": 147 return TinyMCE_SpellCheckerPlugin._getMenuButtonHTML(cn, 'lang_spellchecker_desc', '{$pluginurl}/images/spellchecker.gif', 'lang_spellchecker_desc', 'mceSpellCheckerMenu', 'mceSpellCheck'); 148 } 149 150 return ""; 151 }, 152 153 /** 154 * Returns the HTML code for a normal button control. 155 * 156 * @param {string} id Button control id, this will be the suffix for the element id, the prefix is the editor id. 157 * @param {string} lang Language variable key name to insert as the title/alt of the button image. 158 * @param {string} img Image URL to insert, {$themeurl} and {$pluginurl} will be replaced. 159 * @param {string} mlang Language variable key name to insert as the title/alt of the menu button image. 160 * @param {string} mid Menu by id to display when the menu button is pressed. 161 * @param {string} cmd Command to execute when the user clicks the button. 162 * @param {string} ui Optional user interface boolean for command. 163 * @param {string} val Optional value for command. 164 * @return HTML code for a normal button based in input information. 165 * @type string 166 */ 167 _getMenuButtonHTML : function(id, lang, img, mlang, mid, cmd, ui, val) { 168 var h = '', m, x; 169 170 cmd = 'tinyMCE.hideMenus();tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + cmd + '\''; 171 172 if (typeof(ui) != "undefined" && ui != null) 173 cmd += ',' + ui; 174 175 if (typeof(val) != "undefined" && val != null) 176 cmd += ",'" + val + "'"; 177 178 cmd += ');'; 179 180 // Use tilemaps when enabled and found and never in MSIE since it loads the tile each time from cache if cahce is disabled 181 if (tinyMCE.getParam('button_tile_map') && (!tinyMCE.isMSIE || tinyMCE.isOpera) && (m = tinyMCE.buttonMap[id]) != null && (tinyMCE.getParam("language") == "en" || img.indexOf('$lang') == -1)) { 182 // Tiled button 183 x = 0 - (m * 20) == 0 ? '0' : 0 - (m * 20); 184 h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceTiledButton mceButtonNormal" target="_self">'; 185 h += '<img src="{$themeurl}/images/spacer.gif" style="background-position: ' + x + 'px 0" title="{$' + lang + '}" />'; 186 h += '<img src="{$themeurl}/images/button_menu.gif" title="{$' + lang + '}" class="mceMenuButton" onclick="' + mcmd + 'return false;" />'; 187 h += '</a>'; 188 } else { 189 if (tinyMCE.isMSIE && !tinyMCE.isOpera) 190 h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton" onmouseover="tinyMCE.plugins.spellchecker._menuButtonEvent(\'over\',this);" onmouseout="tinyMCE.plugins.spellchecker._menuButtonEvent(\'out\',this);">'; 191 else 192 h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton">'; 193 194 h += '<a href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceMenuButtonNormal" target="_self">'; 195 h += '<img src="' + img + '" title="{$' + lang + '}" /></a>'; 196 h += '<a href="#" onclick="tinyMCE.plugins.spellchecker._toggleMenu(\'{$editor_id}\',\'' + mid + '\');return false;" onmousedown="return false;"><img src="{$themeurl}/images/button_menu.gif" title="{$' + lang + '}" class="mceMenuButton" />'; 197 h += '</a></span>'; 198 } 199 200 return h; 201 }, 202 203 _menuButtonEvent : function(e, o) { 204 if (o.className == 'mceMenuButtonFocus') 205 return; 206 207 if (e == 'over') 208 o.className = o.className + ' mceMenuHover'; 209 else 210 o.className = o.className.replace(/\s.*$/, ''); 211 }, 212 213 _toggleMenu : function(editor_id, id) { 214 var self = TinyMCE_SpellCheckerPlugin; 215 var e = document.getElementById(editor_id + '_spellchecker'); 216 var inst = tinyMCE.getInstanceById(editor_id); 217 218 if (self._menu.isVisible()) { 219 tinyMCE.hideMenus(); 220 return; 221 } 222 223 tinyMCE.lastMenuBtnClass = e.className.replace(/\s.*$/, ''); 224 tinyMCE.switchClass(editor_id + '_spellchecker', 'mceMenuButtonFocus'); 225 226 self._menu.moveRelativeTo(e, 'bl'); 227 self._menu.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? 0 : 1, -1); 228 229 if (tinyMCE.isOpera) 230 self._menu.moveBy(0, -2); 231 232 self._onMenuEvent(inst, self._menu, 'show'); 233 234 self._menu.show(); 235 236 tinyMCE.lastSelectedMenuBtn = editor_id + '_spellchecker'; 237 }, 238 239 _onMenuEvent : function(inst, m, n) { 240 TinyMCE_SpellCheckerPlugin._buildSettingsMenu(inst, inst.spellCheckerLang); 241 }, 242 243 execCommand : function(editor_id, element, command, user_interface, value) { 244 var inst = tinyMCE.getInstanceById(editor_id), self = TinyMCE_SpellCheckerPlugin, args = '', co, bb, mb, nl, i, e; 245 246 // Handle commands 247 switch (command) { 248 case "mceSpellCheck": 249 if (!inst.spellcheckerOn) { 250 inst.spellCheckerBookmark = inst.selection.getBookmark(); 251 252 // Setup arguments 253 args += 'id=' + inst.editorId + "|" + (++self._counter); 254 args += '&cmd=spell&check=' + escape(self._getWordList(inst.getBody())).replace(/%20/g, '+'); 255 args += '&lang=' + escape(inst.spellCheckerLang); 256 257 co = document.getElementById(inst.editorId + '_parent').firstChild; 258 bb = self._getBlockBoxLayer(inst); 259 bb.moveRelativeTo(co, 'tl'); 260 bb.resizeTo(co.offsetWidth, co.offsetHeight); 261 bb.show(); 262 263 // Setup message box 264 mb = self._getMsgBoxLayer(inst); 265 e = mb.getElement(); 266 e.innerHTML = '<span>' + tinyMCE.getLang('lang_spellchecker_swait', '', true) + '</span>'; 267 mb.show(); 268 mb.moveRelativeTo(co, 'cc'); 269 270 if (tinyMCE.isMSIE && !tinyMCE.isOpera) { 271 nl = co.getElementsByTagName('select'); 272 for (i=0; i<nl.length; i++) 273 nl[i].disabled = true; 274 } 275 276 inst.spellcheckerOn = true; 277 tinyMCE.switchClass(editor_id + '_spellchecker', 'mceMenuButtonSelected'); 278 279 self._sendAjax(self.baseURL + "/tinyspell.php", self._ajaxResponse, 'post', args); 280 } else { 281 self._removeWords(inst.getDoc()); 282 inst.spellcheckerOn = false; 283 tinyMCE.switchClass(editor_id + '_spellchecker', 'mceMenuButton'); 284 } 285 286 return true; 287 288 case "mceSpellCheckReplace": 289 if (inst.spellCheckerElm) 290 tinyMCE.setOuterHTML(inst.spellCheckerElm, value); 291 292 self._checkDone(inst); 293 self._contextMenu.hide(); 294 self._menu.hide(); 295 296 return true; 297 298 case "mceSpellCheckIgnore": 299 if (inst.spellCheckerElm) 300 self._removeWord(inst.spellCheckerElm); 301 302 self._checkDone(inst); 303 self._contextMenu.hide(); 304 self._menu.hide(); 305 return true; 306 307 case "mceSpellCheckIgnoreAll": 308 if (inst.spellCheckerElm) 309 self._removeWords(inst.getDoc(), inst.spellCheckerElm.innerHTML); 310 311 self._checkDone(inst); 312 self._contextMenu.hide(); 313 self._menu.hide(); 314 return true; 315 316 case "mceSpellCheckerSetLang": 317 tinyMCE.hideMenus(); 318 inst.spellCheckerLang = value; 319 self._removeWords(inst.getDoc()); 320 inst.spellcheckerOn = false; 321 tinyMCE.switchClass(editor_id + '_spellchecker', 'mceMenuButton'); 322 return true; 323 } 324 325 // Pass to next handler in chain 326 return false; 327 }, 328 329 cleanup : function(type, content, inst) { 330 switch (type) { 331 case "get_from_editor_dom": 332 TinyMCE_SpellCheckerPlugin._removeWords(content); 333 inst.spellcheckerOn = false; 334 break; 335 } 336 337 return content; 338 }, 339 340 // Private plugin specific methods 341 342 _displayUI : function(inst) { 343 var self = TinyMCE_SpellCheckerPlugin; 344 var bb = self._getBlockBoxLayer(inst); 345 var mb = self._getMsgBoxLayer(inst); 346 var nl, i; 347 var co = document.getElementById(inst.editorId + '_parent').firstChild; 348 349 if (tinyMCE.isMSIE && !tinyMCE.isOpera) { 350 nl = co.getElementsByTagName('select'); 351 for (i=0; i<nl.length; i++) 352 nl[i].disabled = false; 353 } 354 355 bb.hide(); 356 mb.hide(); 357 }, 358 359 _ajaxResponse : function(xml) { 360 var el = xml ? xml.documentElement : null; 361 var inst = tinyMCE.selectedInstance, self = TinyMCE_SpellCheckerPlugin; 362 var cmd = el ? el.getAttribute("cmd") : null, err, id = el ? el.getAttribute("id") : null; 363 364 if (id) 365 inst = tinyMCE.getInstanceById(id.substring(0, id.indexOf('|'))); 366 367 self._displayUI(inst); 368 369 // Ignore suggestions for other ajax responses 370 if (cmd == "suggest" && id != inst.editorId + "|" + self._counter) 371 return; 372 373 if (!el) { 374 inst.spellcheckerOn = false; 375 tinyMCE.switchClass(inst.editorId + '_spellchecker', 'mceMenuButton'); 376 alert("Could not execute AJAX call, server didn't return valid a XML."); 377 return; 378 } 379 380 err = el.getAttribute("error"); 381 382 if (err == "true") { 383 inst.spellcheckerOn = false; 384 tinyMCE.switchClass(inst.editorId + '_spellchecker', 'mceMenuButton'); 385 alert(el.getAttribute("msg")); 386 return; 387 } 388 389 switch (cmd) { 390 case "spell": 391 if (xml.documentElement.firstChild) { 392 self._markWords(inst.getDoc(), inst.getBody(), el.firstChild.nodeValue.split(' ')); 393 inst.selection.moveToBookmark(inst.spellCheckerBookmark); 394 } else 395 alert(tinyMCE.getLang('lang_spellchecker_no_mpell', '', true)); 396 397 self._checkDone(inst); 398 399 break; 400 401 case "suggest": 402 self._buildMenu(el.firstChild ? el.firstChild.nodeValue.split(' ') : null, 10); 403 self._contextMenu.show(); 404 break; 405 } 406 }, 407 408 _getWordSeparators : function() { 409 var i, re = '', ch = tinyMCE.getParam('spellchecker_word_separator_chars', '\\s!"#$%&()*+,-./:;<=>?@[\]^_{|}§©«®±¶·¸»¼½¾¿×÷¤\u201d\u201c'); 410 411 for (i=0; i<ch.length; i++) 412 re += '\\' + ch.charAt(i); 413 414 return re; 415 }, 416 417 _getWordList : function(n) { 418 var i, x, s, nv = '', nl = tinyMCE.getNodeTree(n, new Array(), 3), wl = new Array(); 419 var re = TinyMCE_SpellCheckerPlugin._getWordSeparators(); 420 421 for (i=0; i<nl.length; i++) 422 nv += nl[i].nodeValue + " "; 423 424 nv = nv.replace(new RegExp('([0-9]|[' + re + '])', 'g'), ' '); 425 nv = tinyMCE.trim(nv.replace(/(\s+)/g, ' ')); 426 427 nl = nv.split(/\s+/); 428 for (i=0; i<nl.length; i++) { 429 s = false; 430 for (x=0; x<wl.length; x++) { 431 if (wl[x] == nl[i]) { 432 s = true; 433 break; 434 } 435 } 436 437 if (!s) 438 wl[wl.length] = nl[i]; 439 } 440 441 return wl.join(' '); 442 }, 443 444 _removeWords : function(doc, word) { 445 var i, c, nl = doc.getElementsByTagName("span"); 446 var self = TinyMCE_SpellCheckerPlugin; 447 var inst = tinyMCE.selectedInstance, b = inst ? inst.selection.getBookmark() : null; 448 449 word = typeof(word) == 'undefined' ? null : word; 450 451 for (i=nl.length-1; i>=0; i--) { 452 c = tinyMCE.getAttrib(nl[i], 'class'); 453 454 if ((c == 'mceItemHiddenSpellWord' || c == 'mceItemHidden') && (word == null || nl[i].innerHTML == word)) 455 self._removeWord(nl[i]); 456 } 457 458 if (b) 459 inst.selection.moveToBookmark(b); 460 }, 461 462 _checkDone : function(inst) { 463 var i, w = 0, nl = inst.getDoc().getElementsByTagName("span") 464 var self = TinyMCE_SpellCheckerPlugin; 465 466 for (i=nl.length-1; i>=0; i--) { 467 c = tinyMCE.getAttrib(nl[i], 'class'); 468 469 if (c == 'mceItemHiddenSpellWord') 470 w++; 471 } 472 473 if (w == 0) { 474 self._removeWords(inst.getDoc()); 475 inst.spellcheckerOn = false; 476 tinyMCE.switchClass(inst.editorId + '_spellchecker', 'mceMenuButton'); 477 } 478 }, 479 480 _removeWord : function(e) { 481 tinyMCE.setOuterHTML(e, e.innerHTML); 482 }, 483 484 _markWords : function(doc, n, wl) { 485 var i, nv, nn, nl = tinyMCE.getNodeTree(n, new Array(), 3); 486 var r1, r2, r3, r4, r5, w = ''; 487 var re = TinyMCE_SpellCheckerPlugin._getWordSeparators(); 488 489 for (i=0; i<wl.length; i++) 490 w += wl[i] + ((i == wl.length-1) ? '' : '|'); 491 492 r1 = new RegExp('([' + re + '])(' + w + ')([' + re + '])', 'g'); 493 r2 = new RegExp('^(' + w + ')', 'g'); 494 r3 = new RegExp('(' + w + ')([' + re + ']?)$', 'g'); 495 r4 = new RegExp('^(' + w + ')([' + re + ']?)$', 'g'); 496 r5 = new RegExp('(' + w + ')([' + re + '])', 'g'); 497 498 for (i=0; i<nl.length; i++) { 499 nv = nl[i].nodeValue; 500 if (r1.test(nv) || r2.test(nv) || r3.test(nv) || r4.test(nv)) { 501 nv = tinyMCE.xmlEncode(nv); 502 nv = nv.replace(r5, '<span class="mceItemHiddenSpellWord">$1</span>$2'); 503 nv = nv.replace(r3, '<span class="mceItemHiddenSpellWord">$1</span>$2'); 504 505 nn = doc.createElement('span'); 506 nn.className = "mceItemHidden"; 507 nn.innerHTML = nv; 508 509 // Remove old text node 510 nl[i].parentNode.replaceChild(nn, nl[i]); 511 } 512 } 513 }, 514 515 _buildMenu : function(sg, max) { 516 var i, self = TinyMCE_SpellCheckerPlugin, cm = self._contextMenu; 517 518 cm.clear(); 519 520 if (sg != null) { 521 cm.addTitle(tinyMCE.getLang('lang_spellchecker_sug', '', true)); 522 523 for (i=0; i<sg.length && i<max; i++) 524 cm.addItem(sg[i], 'tinyMCE.execCommand("mceSpellCheckReplace",false,"' + sg[i] + '");'); 525 526 cm.addSeparator(); 527 cm.addItem(tinyMCE.getLang('lang_spellchecker_ignore_word', '', true), 'tinyMCE.execCommand(\'mceSpellCheckIgnore\');'); 528 cm.addItem(tinyMCE.getLang('lang_spellchecker_ignore_words', '', true), 'tinyMCE.execCommand(\'mceSpellCheckIgnoreAll\');'); 529 } else 530 cm.addTitle(tinyMCE.getLang('lang_spellchecker_no_sug', '', true)); 531 532 cm.update(); 533 }, 534 535 _getAjaxHTTP : function() { 536 try { 537 return new ActiveXObject('Msxml2.XMLHTTP') 538 } catch (e) { 539 try { 540 return new ActiveXObject('Microsoft.XMLHTTP') 541 } catch (e) { 542 return new XMLHttpRequest(); 543 } 544 } 545 }, 546 547 /** 548 * Perform AJAX call. 549 * 550 * @param {string} u URL of AJAX service. 551 * @param {function} f Function to call when response arrives. 552 * @param {string} m Request method post or get. 553 * @param {Array} a Array with arguments to send. 554 */ 555 _sendAjax : function(u, f, m, a) { 556 var x = TinyMCE_SpellCheckerPlugin._getAjaxHTTP(); 557 558 x.open(m, u, true); 559 560 x.onreadystatechange = function() { 561 if (x.readyState == 4) 562 f(x.responseXML); 563 }; 564 565 if (m == 'post') 566 x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); 567 568 x.send(a); 569 } 570 }; 571 572 // Register plugin 573 tinyMCE.addPlugin('spellchecker', TinyMCE_SpellCheckerPlugin); 1 tinyMCE.importPluginLanguagePack('spellchecker','en,fr,sv,nn,nb');var TinyMCE_SpellCheckerPlugin={_contextMenu:new TinyMCE_Menu(),_menu:new TinyMCE_Menu(),_counter:0,_ajaxPage:'/tinyspell.php',getInfo:function(){return{longname:'Spellchecker PHP',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_spellchecker.html',version:"1.0.3"};},handleEvent:function(e){var elm=tinyMCE.isMSIE?e.srcElement:e.target;var inst=tinyMCE.selectedInstance,args='';var self=TinyMCE_SpellCheckerPlugin;var cm=self._contextMenu;var p,p2,x,y,sx,sy,h,elm;if((e.type=="click"||e.type=="contextmenu")&&elm){do{if(tinyMCE.getAttrib(elm,'class')=="mceItemHiddenSpellWord"){inst.spellCheckerElm=elm;args+='id='+inst.editorId+"|"+(++self._counter);args+='&cmd=suggest&check='+encodeURIComponent(elm.innerHTML);args+='&lang='+escape(inst.spellCheckerLang);elm=inst.spellCheckerElm;p=tinyMCE.getAbsPosition(inst.iframeElement);p2=tinyMCE.getAbsPosition(elm);h=parseInt(elm.offsetHeight);sx=inst.getBody().scrollLeft;sy=inst.getBody().scrollTop;x=p.absLeft+p2.absLeft-sx;y=p.absTop+p2.absTop-sy+h;cm.clear();cm.addTitle(tinyMCE.getLang('lang_spellchecker_wait','',true));cm.show();cm.moveTo(x,y);inst.selection.selectNode(elm,false,false);self._sendAjax(self.baseURL+self._ajaxPage,self._ajaxResponse,'post',args);tinyMCE.cancelEvent(e);return false;}}while((elm=elm.parentNode));}return true;},initInstance:function(inst){var self=TinyMCE_SpellCheckerPlugin,m=self._menu,cm=self._contextMenu,e;tinyMCE.importCSS(inst.getDoc(),tinyMCE.baseURL+"/plugins/spellchecker/css/content.css");if(!tinyMCE.hasMenu('spellcheckercontextmenu')){tinyMCE.importCSS(document,tinyMCE.baseURL+"/plugins/spellchecker/css/spellchecker.css");cm.init({drop_menu:false});tinyMCE.addMenu('spellcheckercontextmenu',cm);}if(!tinyMCE.hasMenu('spellcheckermenu')){m.init({});tinyMCE.addMenu('spellcheckermenu',m);}inst.spellCheckerLang='en';self._buildSettingsMenu(inst,null);e=self._getBlockBoxLayer(inst).create('div','mceBlockBox',document.getElementById(inst.editorId+'_parent'));self._getMsgBoxLayer(inst).create('div','mceMsgBox',document.getElementById(inst.editorId+'_parent'));},_getMsgBoxLayer:function(inst){if(!inst.spellCheckerMsgBoxL)inst.spellCheckerMsgBoxL=new TinyMCE_Layer(inst.editorId+'_spellcheckerMsgBox',false);return inst.spellCheckerMsgBoxL;},_getBlockBoxLayer:function(inst){if(!inst.spellCheckerBoxL)inst.spellCheckerBoxL=new TinyMCE_Layer(inst.editorId+'_spellcheckerBlockBox',false);return inst.spellCheckerBoxL;},_buildSettingsMenu:function(inst,lang){var i,ar=tinyMCE.getParam('spellchecker_languages','+English=en').split(','),p;var self=TinyMCE_SpellCheckerPlugin,m=self._menu,c;m.clear();m.addTitle(tinyMCE.getLang('lang_spellchecker_langs','',true));for(i=0;i<ar.length;i++){if(ar[i]!=''){p=ar[i].split('=');c='mceMenuCheckItem';if(p[0].charAt(0)=='+'){p[0]=p[0].substring(1);if(lang==null){c='mceMenuSelectedItem';inst.spellCheckerLang=p[1];}}if(lang==p[1])c='mceMenuSelectedItem';m.add({text:p[0],js:"tinyMCE.execInstanceCommand('"+inst.editorId+"','mceSpellCheckerSetLang',false,'"+p[1]+"');",class_name:c});}}},setupContent:function(editor_id,body,doc){TinyMCE_SpellCheckerPlugin._removeWords(doc,null,true);},getControlHTML:function(cn){switch(cn){case"spellchecker":return TinyMCE_SpellCheckerPlugin._getMenuButtonHTML(cn,'lang_spellchecker_desc','{$pluginurl}/images/spellchecker.gif','lang_spellchecker_desc','mceSpellCheckerMenu','mceSpellCheck');}return"";},_getMenuButtonHTML:function(id,lang,img,mlang,mid,cmd,ui,val){var h='',m,x;cmd='tinyMCE.hideMenus();tinyMCE.execInstanceCommand(\'{$editor_id}\',\''+cmd+'\'';if(typeof(ui)!="undefined"&&ui!=null)cmd+=','+ui;if(typeof(val)!="undefined"&&val!=null)cmd+=",'"+val+"'";cmd+=');';if(tinyMCE.getParam('button_tile_map')&&(!tinyMCE.isMSIE||tinyMCE.isOpera)&&(m=tinyMCE.buttonMap[id])!=null&&(tinyMCE.getParam("language")=="en"||img.indexOf('$lang')==-1)){x=0-(m*20)==0?'0':0-(m*20);h+='<a id="{$editor_id}_'+id+'" href="javascript:'+cmd+'" onclick="'+cmd+'return false;" onmousedown="return false;" class="mceTiledButton mceButtonNormal" target="_self">';h+='<img src="{$themeurl}/images/spacer.gif" style="background-position: '+x+'px 0" title="{$'+lang+'}" />';h+='<img src="{$themeurl}/images/button_menu.gif" title="{$'+lang+'}" class="mceMenuButton" onclick="'+mcmd+'return false;" />';h+='</a>';}else{if(tinyMCE.isMSIE&&!tinyMCE.isOpera)h+='<span id="{$editor_id}_'+id+'" class="mceMenuButton" onmouseover="tinyMCE.plugins.spellchecker._menuButtonEvent(\'over\',this);" onmouseout="tinyMCE.plugins.spellchecker._menuButtonEvent(\'out\',this);">';else h+='<span id="{$editor_id}_'+id+'" class="mceMenuButton">';h+='<a href="javascript:'+cmd+'" onclick="'+cmd+'return false;" onmousedown="return false;" class="mceMenuButtonNormal" target="_self">';h+='<img src="'+img+'" title="{$'+lang+'}" /></a>';h+='<a href="#" onclick="tinyMCE.plugins.spellchecker._toggleMenu(\'{$editor_id}\',\''+mid+'\');return false;" onmousedown="return false;"><img src="{$themeurl}/images/button_menu.gif" title="{$'+lang+'}" class="mceMenuButton" />';h+='</a></span>';}return h;},_menuButtonEvent:function(e,o){var t=this;window.setTimeout(function(){t._menuButtonEvent2(e,o);},1);},_menuButtonEvent2:function(e,o){if(o.className=='mceMenuButtonFocus')return;if(e=='over')o.className=o.className+' mceMenuHover';else o.className=o.className.replace(/\s.*$/,'');},_toggleMenu:function(editor_id,id){var self=TinyMCE_SpellCheckerPlugin;var e=document.getElementById(editor_id+'_spellchecker');var inst=tinyMCE.getInstanceById(editor_id);if(self._menu.isVisible()){tinyMCE.hideMenus();return;}tinyMCE.lastMenuBtnClass=e.className.replace(/\s.*$/,'');tinyMCE.switchClass(editor_id+'_spellchecker','mceMenuButtonFocus');self._menu.moveRelativeTo(e,'bl');self._menu.moveBy(tinyMCE.isMSIE&&!tinyMCE.isOpera?0:1,-1);if(tinyMCE.isOpera)self._menu.moveBy(0,-2);self._onMenuEvent(inst,self._menu,'show');self._menu.show();tinyMCE.lastSelectedMenuBtn=editor_id+'_spellchecker';},_onMenuEvent:function(inst,m,n){TinyMCE_SpellCheckerPlugin._buildSettingsMenu(inst,inst.spellCheckerLang);},execCommand:function(editor_id,element,command,user_interface,value){var inst=tinyMCE.getInstanceById(editor_id),self=TinyMCE_SpellCheckerPlugin,args='',co,bb,mb,nl,i,e,mbs;switch(command){case"mceSpellCheck":if(!inst.spellcheckerOn){inst.spellCheckerBookmark=inst.selection.getBookmark();if(tinyMCE.isRealIE)tinyMCE.setInnerHTML(inst.getBody(),inst.getBody().innerHTML);args+='id='+inst.editorId+"|"+(++self._counter);args+='&cmd=spell&check='+encodeURIComponent(self._getWordList(inst.getBody())).replace(/\'/g,'%27');args+='&lang='+escape(inst.spellCheckerLang);co=document.getElementById(inst.editorId+'_parent').firstChild;bb=self._getBlockBoxLayer(inst);bb.moveRelativeTo(co,'tl');bb.resizeTo(co.offsetWidth,co.offsetHeight);bb.show();mb=self._getMsgBoxLayer(inst);e=mb.getElement();if(e.childNodes[0])e.removeChild(e.childNodes[0]);mbs=document.createElement("span");mbs.innerHTML='<span>'+tinyMCE.getLang('lang_spellchecker_swait','',true)+'</span>';e.appendChild(mbs);mb.show();mb.moveRelativeTo(co,'cc');if(tinyMCE.isMSIE&&!tinyMCE.isOpera){nl=co.getElementsByTagName('select');for(i=0;i<nl.length;i++)nl[i].disabled=true;}inst.spellcheckerOn=true;tinyMCE.switchClass(editor_id+'_spellchecker','mceMenuButtonSelected');self._sendAjax(self.baseURL+self._ajaxPage,self._ajaxResponse,'post',args);}else{self._removeWords(inst.getDoc());inst.spellcheckerOn=false;tinyMCE.switchClass(editor_id+'_spellchecker','mceMenuButton');}return true;case"mceSpellCheckReplace":if(inst.spellCheckerElm)tinyMCE.setOuterHTML(inst.spellCheckerElm,value);self._checkDone(inst);self._contextMenu.hide();self._menu.hide();return true;case"mceSpellCheckIgnore":if(inst.spellCheckerElm)self._removeWord(inst.spellCheckerElm);self._checkDone(inst);self._contextMenu.hide();self._menu.hide();return true;case"mceSpellCheckIgnoreAll":if(inst.spellCheckerElm)self._removeWords(inst.getDoc(),inst.spellCheckerElm.innerHTML);self._checkDone(inst);self._contextMenu.hide();self._menu.hide();return true;case"mceSpellCheckerSetLang":tinyMCE.hideMenus();inst.spellCheckerLang=value;self._removeWords(inst.getDoc());inst.spellcheckerOn=false;tinyMCE.switchClass(editor_id+'_spellchecker','mceMenuButton');return true;}return false;},cleanup:function(type,content,inst){switch(type){case"get_from_editor_dom":TinyMCE_SpellCheckerPlugin._removeWords(content,null,true);inst.spellcheckerOn=false;break;}return content;},_displayUI:function(inst){var self=TinyMCE_SpellCheckerPlugin;var bb=self._getBlockBoxLayer(inst);var mb=self._getMsgBoxLayer(inst);var nl,i;var co=document.getElementById(inst.editorId+'_parent').firstChild;if(tinyMCE.isMSIE&&!tinyMCE.isOpera){nl=co.getElementsByTagName('select');for(i=0;i<nl.length;i++)nl[i].disabled=false;}bb.hide();mb.hide();},_ajaxResponse:function(xml){var el=xml?xml.documentElement:null;var inst=tinyMCE.selectedInstance,self=TinyMCE_SpellCheckerPlugin;var cmd=el?el.getAttribute("cmd"):null,err,id=el?el.getAttribute("id"):null;if(id)inst=tinyMCE.getInstanceById(id.substring(0,id.indexOf('|')));self._displayUI(inst);if(cmd=="suggest"&&id!=inst.editorId+"|"+self._counter)return;if(!el){inst.spellcheckerOn=false;tinyMCE.switchClass(inst.editorId+'_spellchecker','mceMenuButton');alert("Could not execute AJAX call, server didn't return valid a XML.");return;}err=el.getAttribute("error");if(err=="true"){inst.spellcheckerOn=false;tinyMCE.switchClass(inst.editorId+'_spellchecker','mceMenuButton');alert(el.getAttribute("msg"));return;}switch(cmd){case"spell":if(xml.documentElement.firstChild){self._markWords(inst.getDoc(),inst.getBody(),decodeURIComponent(el.firstChild.nodeValue).split('+'));inst.selection.moveToBookmark(inst.spellCheckerBookmark);if(tinyMCE.getParam('spellchecker_report_misspellings',false))alert(tinyMCE.getLang('lang_spellchecker_mpell_found','',true,{words:self._countWords(inst)}));}else alert(tinyMCE.getLang('lang_spellchecker_no_mpell','',true));self._checkDone(inst);inst.useCSS=false;break;case"suggest":self._buildMenu(el.firstChild?decodeURIComponent(el.firstChild.nodeValue).split('+'):null,10);self._contextMenu.show();break;}},_getWordSeparators:function(){var i,re='',ch=tinyMCE.getParam('spellchecker_word_separator_chars','\\s!"#$%&()*+,-./:;<=>?@[\]^_{|}\u201d\u201c');for(i=0;i<ch.length;i++)re+='\\'+ch.charAt(i);return re;},_getWordList:function(n){var i,x,s,nv='',nl=tinyMCE.getNodeTree(n,new Array(),3),wl=new Array();var re=TinyMCE_SpellCheckerPlugin._getWordSeparators();for(i=0;i<nl.length;i++){if(!new RegExp('/SCRIPT|STYLE/').test(nl[i].parentNode.nodeName))nv+=nl[i].nodeValue+" ";}nv=nv.replace(new RegExp('([0-9]|['+re+'])','g'),' ');nv=tinyMCE.trim(nv.replace(/(\s+)/g,' '));nl=nv.split(/\s+/);for(i=0;i<nl.length;i++){s=false;for(x=0;x<wl.length;x++){if(wl[x]==nl[i]){s=true;break;}}if(!s&&nl[i].length>0)wl[wl.length]=nl[i];}return wl.join(' ');},_removeWords:function(doc,word,cleanup){var i,c,nl=doc.getElementsByTagName("span");var self=TinyMCE_SpellCheckerPlugin;var inst=tinyMCE.selectedInstance,b=inst?inst.selection.getBookmark():null;word=typeof(word)=='undefined'?null:word;for(i=nl.length-1;i>=0;i--){c=tinyMCE.getAttrib(nl[i],'class');if((c=='mceItemHiddenSpellWord'||c=='mceItemHidden')&&(word==null||nl[i].innerHTML==word))self._removeWord(nl[i]);}if(b&&!cleanup)inst.selection.moveToBookmark(b);},_checkDone:function(inst){var self=TinyMCE_SpellCheckerPlugin;var w=self._countWords(inst);if(w==0){self._removeWords(inst.getDoc());inst.spellcheckerOn=false;tinyMCE.switchClass(inst.editorId+'_spellchecker','mceMenuButton');}},_countWords:function(inst){var i,w=0,nl=inst.getDoc().getElementsByTagName("span"),c;var self=TinyMCE_SpellCheckerPlugin;for(i=nl.length-1;i>=0;i--){c=tinyMCE.getAttrib(nl[i],'class');if(c=='mceItemHiddenSpellWord')w++;}return w;},_removeWord:function(e){if(e!=null)tinyMCE.setOuterHTML(e,e.innerHTML);},_markWords:function(doc,n,wl){var i,nv,nn,nl=tinyMCE.getNodeTree(n,new Array(),3);var r1,r2,r3,r4,r5,w='';var re=TinyMCE_SpellCheckerPlugin._getWordSeparators();for(i=0;i<wl.length;i++){if(wl[i].length>0)w+=wl[i]+((i==wl.length-1)?'':'|');}for(i=0;i<nl.length;i++){nv=nl[i].nodeValue;r1=new RegExp('(['+re+'])('+w+')(['+re+'])','g');r2=new RegExp('^('+w+')','g');r3=new RegExp('('+w+')(['+re+']?)$','g');r4=new RegExp('^('+w+')(['+re+']?)$','g');r5=new RegExp('('+w+')(['+re+'])','g');if(r1.test(nv)||r2.test(nv)||r3.test(nv)||r4.test(nv)){nv=tinyMCE.xmlEncode(nv);nv=nv.replace(r5,'<span class="mceItemHiddenSpellWord">$1</span>$2');nv=nv.replace(r3,'<span class="mceItemHiddenSpellWord">$1</span>$2');nn=doc.createElement('span');nn.className="mceItemHidden";nn.innerHTML=nv;nl[i].parentNode.replaceChild(nn,nl[i]);}}},_buildMenu:function(sg,max){var i,self=TinyMCE_SpellCheckerPlugin,cm=self._contextMenu;cm.clear();if(sg!=null){cm.addTitle(tinyMCE.getLang('lang_spellchecker_sug','',true));for(i=0;i<sg.length&&i<max;i++)cm.addItem(sg[i],'tinyMCE.execCommand("mceSpellCheckReplace",false,"'+sg[i]+'");');cm.addSeparator();}else cm.addTitle(tinyMCE.getLang('lang_spellchecker_no_sug','',true));cm.addItem(tinyMCE.getLang('lang_spellchecker_ignore_word','',true),'tinyMCE.execCommand(\'mceSpellCheckIgnore\');');cm.addItem(tinyMCE.getLang('lang_spellchecker_ignore_words','',true),'tinyMCE.execCommand(\'mceSpellCheckIgnoreAll\');');cm.update();},_getAjaxHTTP:function(){try{return new ActiveXObject('Msxml2.XMLHTTP')}catch(e){try{return new ActiveXObject('Microsoft.XMLHTTP')}catch(e){return new XMLHttpRequest();}}},_sendAjax:function(u,f,m,a){var x=TinyMCE_SpellCheckerPlugin._getAjaxHTTP();x.open(m,u,true);x.onreadystatechange=function(){if(x.readyState==4)f(x.responseXML);};if(m=='post')x.setRequestHeader('Content-type','application/x-www-form-urlencoded');x.send(a);}};tinyMCE.addPlugin('spellchecker',TinyMCE_SpellCheckerPlugin); -
tags/2.2/wp-includes/js/tinymce/plugins/spellchecker/langs/en.js
r5468 r5480 11 11 sug : 'Suggestions', 12 12 no_sug : 'No suggestions', 13 no_mpell : 'No misspellings found.' 13 no_mpell : 'No misspellings found.', 14 mpell_found : 'Found {$words} misspellings.' 14 15 }); -
tags/2.2/wp-includes/js/tinymce/plugins/spellchecker/tinyspell.php
r5468 r5480 8 8 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved. 9 9 */ 10 11 // Ignore the Notice errors for now. 12 error_reporting(E_ALL ^ E_NOTICE); 10 13 11 14 require_once("config.php"); … … 31 34 // Get input parameters. 32 35 33 $check = $_POST['check'];34 $cmd = sanitize($_ POST['cmd']);35 $lang = sanitize($_ POST['lang'], "strict");36 $mode = sanitize($_ POST['mode'], "strict");37 $spelling = sanitize($_ POST['spelling'], "strict");38 $jargon = sanitize($_ POST['jargon'], "strict");39 $encoding = sanitize($_ POST['encoding'], "strict");40 $sg = sanitize($_ POST['sg'], "bool");36 $check = urldecode($_REQUEST['check']); 37 $cmd = sanitize($_REQUEST['cmd']); 38 $lang = sanitize($_REQUEST['lang'], "strict"); 39 $mode = sanitize($_REQUEST['mode'], "strict"); 40 $spelling = sanitize($_REQUEST['spelling'], "strict"); 41 $jargon = sanitize($_REQUEST['jargon'], "strict"); 42 $encoding = sanitize($_REQUEST['encoding'], "strict"); 43 $sg = sanitize($_REQUEST['sg'], "bool"); 41 44 $words = array(); 42 45 … … 91 94 $result = $tinyspell->checkWords($words); 92 95 break; 96 93 97 case "suggest": 94 98 $result = $tinyspell->getSuggestion($check); 95 99 break; 100 96 101 default: 97 102 // Just use this for now. … … 110 115 case "xml": 111 116 header('Content-type: text/xml; charset=utf-8'); 112 echo '<?xml version="1.0" encoding="utf-8" ?>'; 113 echo "\n"; 117 $body = '<?xml version="1.0" encoding="utf-8" ?>'; 118 $body .= "\n"; 119 114 120 if (count($result) == 0) 115 echo'<res id="' . $id . '" cmd="'. $cmd .'" />';121 $body .= '<res id="' . $id . '" cmd="'. $cmd .'" />'; 116 122 else 117 echo '<res id="' . $id . '" cmd="'. $cmd .'">'. utf8_encode(implode(" ", $result)) .'</res>';123 $body .= '<res id="' . $id . '" cmd="'. $cmd .'">'. urlencode(implode(" ", $result)) .'</res>'; 118 124 125 echo $body; 119 126 break; 120 127 case "xmlerror"; 121 128 header('Content-type: text/xml; charset=utf-8'); 122 echo '<?xml version="1.0" encoding="utf-8" ?>'; 123 echo "\n"; 124 echo '<res id="' . $id . '" cmd="'. $cmd .'" error="true" msg="'. implode(" ", $tinyspell->errorMsg) .'" />'; 129 $body = '<?xml version="1.0" encoding="utf-8" ?>'; 130 $body .= "\n"; 131 $body .= '<res id="' . $id . '" cmd="'. $cmd .'" error="true" msg="'. implode(" ", $tinyspell->errorMsg) .'" />'; 132 echo $body; 125 133 break; 126 134 case "html": … … 131 139 break; 132 140 } 133 ?> 141 142 ?> -
tags/2.2/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
r5468 r5480 516 516 517 517 // Tweak the widths 518 ta.parentNode.style.paddingRight = ' 2px';518 ta.parentNode.style.paddingRight = '12px'; 519 519 520 520 if ( tinyMCE.isMSIE && !tinyMCE.isOpera ) { -
tags/2.2/wp-includes/js/tinymce/plugins/wordpress/langs/en.js
r5468 r5480 30 30 numlist_desc : 'Ordered list (' + metaKey + '+o)', 31 31 outdent_desc : 'Outdent (' + metaKey + '+w)', 32 indent_desc : 'Indent List/Blockquote (' + metaKey + '+q)'32 indent_desc : 'Indent list/blockquote (' + metaKey + '+q)' 33 33 }); -
tags/2.2/wp-includes/js/tinymce/plugins/wordpress/wordpress.css
r5468 r5480 49 49 overflow: hidden; 50 50 padding-left: 12px; 51 background-image: url('../images/anchor_symbol.gif');52 51 background-position: bottom; 53 52 background-repeat: no-repeat; -
tags/2.2/wp-includes/js/tinymce/themes/advanced/about.htm
r5468 r5480 22 22 <p>TinyMCE is a platform independent web based Javascript HTML WYSIWYG editor control released as Open Source under <a href="../../license.txt" target="_blank">LGPL</a> 23 23 by Moxiecode Systems AB. It has the ability to convert HTML TEXTAREA fields or other HTML elements to editor instances.</p> 24 <p>Copyright © 2003-200 6, <a href="http://www.moxiecode.com" target="_blank">Moxiecode Systems AB</a>, All rights reserved.</p>24 <p>Copyright © 2003-2007, <a href="http://www.moxiecode.com" target="_blank">Moxiecode Systems AB</a>, All rights reserved.</p> 25 25 <p>For more information about this software visit the <a href="http://tinymce.moxiecode.com" target="_blank">TinyMCE website</a>.</p> 26 26 -
tags/2.2/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css
r5468 r5480 1 1 /* This file contains the CSS data for the editor UI of TinyMCE instances */ 2 2 3 .mceToolbarTop a, .mceToolbarTop a:visited, .mceToolbarTop a:hover, .mceToolbarBottom a, .mceToolbarBottom a:visited, .mceToolbarBottom a:hover {border: 0; margin: 0; padding: 0;background: transparent;}3 .mceToolbarTop a, .mceToolbarTop a:visited, .mceToolbarTop a:hover, .mceToolbarBottom a, .mceToolbarBottom a:visited, .mceToolbarBottom a:hover {border: 0; margin: 0; padding: 0; background: transparent;} 4 4 .mceSeparatorLine {border: 0; padding: 0; margin-left: 4px; margin-right: 2px;} 5 5 .mceSelectList {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 7pt !important; font-weight: normal; margin-top: 3px; padding: 0; display: inline; vertical-align: top; background-color: #F0F0EE;} 6 6 .mceLabel, .mceLabelDisabled {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 9pt;} 7 7 .mceLabel {color: #000000;} 8 .mceLabelDisabled {cursor: text; 9 .mceEditor {background: #F0F0EE; border: 1px solid #cccccc; padding: 0;margin: 0;}10 .mceEditorArea { font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; background: #FFFFFF; padding: 0; margin: 0;}11 .mceToolbarTop, .mceToolbarBottom {background: #F0F0EE; line-height: 1px;font-size: 1px;}8 .mceLabelDisabled {cursor: text; color: #999999;} 9 .mceEditor {background: #F0F0EE; border: 1px solid #cccccc; padding: 0; margin: 0;} 10 .mceEditorArea { font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; background: #FFFFFF; padding: 0; margin: 0; } 11 .mceToolbarTop, .mceToolbarBottom {background: #F0F0EE; line-height: 1px; font-size: 1px;} 12 12 .mceToolbarTop {border-bottom: 1px solid #cccccc; padding-bottom: 1px;} 13 13 .mceToolbarBottom {border-top: 1px solid #cccccc;} 14 .mceToolbarContainer { position: relative; left: 0; top: 0; display: block;}14 .mceToolbarContainer {display: block; position: relative; left: 0; top: 0; width: 100%;} 15 15 .mceStatusbarTop, .mceStatusbarBottom, .mceStatusbar {height: 20px;} 16 .mceStatusbarTop .mceStatusbarPathText, .mceStatusbarBottom .mceStatusbarPathText, .mceStatusbar .mceStatusbarPathText {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 9pt; padding: 2px; line-height: 16px;overflow: visible;}16 .mceStatusbarTop .mceStatusbarPathText, .mceStatusbarBottom .mceStatusbarPathText, .mceStatusbar .mceStatusbarPathText {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 9pt; padding: 2px; line-height: 16px; overflow: visible;} 17 17 .mceStatusbarTop {border-bottom: 1px solid #cccccc;} 18 18 .mceStatusbarBottom {border-top: 1px solid #cccccc;} 19 19 .mceStatusbar {border-bottom: 1px solid #cccccc;} 20 .mcePathItem, .mcePathItem:link, .mcePathItem:visited, .mcePathItem:hover {text-decoration: none; font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 9pt;color: #000000;}20 .mcePathItem, .mcePathItem:link, .mcePathItem:visited, .mcePathItem:hover {text-decoration: none; font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 9pt; color: #000000;} 21 21 .mcePathItem:hover {text-decoration: underline;} 22 22 .mceStatusbarPathText {float: left;} 23 .mceStatusbarResize {float: right; background-image: url('../images/statusbar_resize.gif'); background-repeat: no-repeat; width: 11px; height: 20px;cursor: se-resize;}24 .mceResizeBox {width: 10px; height: 10px; display: none; border: 1px dotted gray; margin: 0;padding: 0;}23 .mceStatusbarResize {float: right; background-image: url('../images/statusbar_resize.gif'); background-repeat: no-repeat; width: 11px; height: 20px; cursor: se-resize;} 24 .mceResizeBox {width: 10px; height: 10px; display: none; border: 1px dotted gray; margin: 0; padding: 0;} 25 25 .mceEditorIframe {border: 0;} 26 26 27 27 /* Button CSS rules */ 28 28 29 a.mceButtonDisabled img, a.mceButtonNormal img, a.mceButtonSelected img {width: 20px; height: 20px; cursor: default; margin-top: 1px;margin-left: 1px;}29 a.mceButtonDisabled img, a.mceButtonNormal img, a.mceButtonSelected img {width: 20px; height: 20px; cursor: default; margin-top: 1px; margin-left: 1px;} 30 30 a.mceButtonDisabled img {border: 0 !important;} 31 31 a.mceButtonNormal img, a.mceButtonSelected img {border: 1px solid #F0F0EE !important;} 32 a.mceButtonSelected img {border: 1px solid #6779AA !important; 33 a.mceButtonNormal img:hover, a.mceButtonSelected img:hover {border: 1px solid #0A246A !important; cursor: default;background-color: #B6BDD2;}34 a.mceButtonDisabled img {-moz-opacity:0.3; opacity: 0.3; border: 1px solid #F0F0EE !important;cursor: default;}35 a.mceTiledButton img {background-image: url('../images/buttons.gif'); 32 a.mceButtonSelected img {border: 1px solid #6779AA !important; background-color: #D4D5D8;} 33 a.mceButtonNormal img:hover, a.mceButtonSelected img:hover {border: 1px solid #0A246A !important; cursor: default; background-color: #B6BDD2;} 34 a.mceButtonDisabled img {-moz-opacity:0.3; opacity: 0.3; border: 1px solid #F0F0EE !important; cursor: default;} 35 a.mceTiledButton img {background-image: url('../images/buttons.gif'); background-repeat: no-repeat;} 36 36 37 37 /* Menu button CSS rules */ 38 38 39 span.mceMenuButton img, span.mceMenuButtonSelected img {border: 1px solid #F0F0EE; 40 span.mceMenuButtonSelected img {border: 1px solid #6779AA; 41 span.mceMenuButtonSelected img.mceMenuButton {border: 1px solid #F0F0EE; 42 span.mceMenuButton img.mceMenuButton, span.mceMenuButtonSelected img.mceMenuButton {border-left: 0; 43 span.mceMenuButton:hover img, span.mceMenuButtonSelected:hover img {border: 1px solid #0A246A; 39 span.mceMenuButton img, span.mceMenuButtonSelected img {border: 1px solid #F0F0EE; margin-left: 1px;} 40 span.mceMenuButtonSelected img {border: 1px solid #6779AA; background-color: #B6BDD2;} 41 span.mceMenuButtonSelected img.mceMenuButton {border: 1px solid #F0F0EE; background-color: transparent;} 42 span.mceMenuButton img.mceMenuButton, span.mceMenuButtonSelected img.mceMenuButton {border-left: 0; margin-left: 0;} 43 span.mceMenuButton:hover img, span.mceMenuButtonSelected:hover img {border: 1px solid #0A246A; background-color: #B6BDD2;} 44 44 span.mceMenuButton:hover img.mceMenuButton, span.mceMenuButtonSelected:hover img.mceMenuButton {border-left: 0;} 45 span.mceMenuButtonFocus img {border: 1px solid gray; border-right: 0; margin-left: 1px;background-color: #F5F4F2;}46 span.mceMenuButtonFocus img.mceMenuButton {border: 1px solid gray; border-left: 1px solid #F5F4F2;margin-left: 0;}47 span.mceMenuHover img {border: 1px solid #0A246A; 48 span.mceMenuButtonSelected.mceMenuHover img.mceMenuButton {border: 1px solid #0A246A; background-color: #B6BDD2;border-left: 0;}45 span.mceMenuButtonFocus img {border: 1px solid gray; border-right: 0; margin-left: 1px; background-color: #F5F4F2;} 46 span.mceMenuButtonFocus img.mceMenuButton {border: 1px solid gray; border-left: 1px solid #F5F4F2; margin-left: 0;} 47 span.mceMenuHover img {border: 1px solid #0A246A; background-color: #B6BDD2;} 48 span.mceMenuButtonSelected.mceMenuHover img.mceMenuButton {border: 1px solid #0A246A; background-color: #B6BDD2; border-left: 0;} 49 49 50 50 /* Menu */ 51 51 52 .mceMenu {position: absolute; left: 0; top: 0; display: none; z-index: 100; background-color: white; border: 1px solid gray;font-weight: normal;}53 .mceMenu a, .mceMenuTitle, .mceMenuDisabled {display: block; width: 100%; text-decoration: none; background-color: white; font-family: Tahoma, Verdana, Arial, Helvetica; font-size: 11px; line-height: 20px;color: black;}54 .mceMenu a:hover {background-color: #B6BDD2; color: black;text-decoration: none !important;}55 .mceMenu span {padding-left: 10px; padding-right: 10px; display: block;line-height: 20px;}56 .mceMenuSeparator {border-bottom: 1px solid gray; background-color: gray;height: 1px;}52 .mceMenu {position: absolute; left: 0; top: 0; display: none; z-index: 1000; background-color: white; border: 1px solid gray; font-weight: normal;} 53 .mceMenu a, .mceMenuTitle, .mceMenuDisabled {display: block; width: 100%; text-decoration: none; background-color: white; font-family: Tahoma, Verdana, Arial, Helvetica; font-size: 11px; line-height: 20px; color: black;} 54 .mceMenu a:hover {background-color: #B6BDD2; color: black; text-decoration: none !important;} 55 .mceMenu span {padding-left: 10px; padding-right: 10px; display: block; line-height: 20px;} 56 .mceMenuSeparator {border-bottom: 1px solid gray; background-color: gray; height: 1px;} 57 57 .mceMenuTitle span {padding-left: 5px;} 58 .mceMenuTitle {background-color: #DDDDDD; 58 .mceMenuTitle {background-color: #DDDDDD; font-weight: bold;} 59 59 .mceMenuDisabled {color: gray;} 60 span.mceMenuSelectedItem {background-image: url('../images/menu_check.gif'); background-repeat: no-repeat; background-position: 5px 8px;padding-left: 20px;}60 span.mceMenuSelectedItem {background-image: url('../images/menu_check.gif'); background-repeat: no-repeat; background-position: 5px 8px; padding-left: 20px;} 61 61 span.mceMenuCheckItem {padding-left: 20px;} 62 span.mceMenuLine {display: block; position: absolute; left: 0; top: -1px; background-color: #F5F4F2; width: 30px; height: 1px; overflow: hidden; padding-left: 0;padding-right: 0;}63 .mceColors table, .mceColors td {margin: 0; 64 a.mceMoreColors {width: 130px; margin: 0; padding: 0; margin-left: 3px; margin-bottom: 3px; text-align: center; border: 1px solid white;}65 .mceColorPreview {position: absolute; left: 0; top: 0; margin-left: 3px; margin-top: 15px; width: 16px; height: 4px;background-color: red;}62 span.mceMenuLine {display: block; position: absolute; left: 0; top: -1px; background-color: #F5F4F2; width: 30px; height: 1px; overflow: hidden; padding-left: 0; padding-right: 0;} 63 .mceColors table, .mceColors td {margin: 0; padding: 2px;} 64 a.mceMoreColors {width: auto; padding: 0; margin: 0 3px 3px 3px; text-align: center; border: 1px solid white; text-decoration: none !important;} 65 .mceColorPreview {position: absolute; overflow:hidden; left: 0; top: 0; margin-left: 3px; margin-top: 15px; width: 16px; height: 4px; background-color: red;} 66 66 a.mceMoreColors:hover {border: 1px solid #0A246A;} 67 .mceColors td a {width: 9px; height: 9px; overflow: hidden;border: 1px solid #808080;}67 .mceColors td a {width: 9px; height: 9px; overflow: hidden; border: 1px solid #808080;} 68 68 69 69 /* MSIE 6 specific rules */ 70 70 71 * html a.mceButtonNormal img, * html a.mceButtonSelected img, * html a.mceButtonDisabled img {border: 0 !important; margin-top: 2px;margin-bottom: 1px;}72 * html a.mceButtonDisabled img {filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30); 71 * html a.mceButtonNormal img, * html a.mceButtonSelected img, * html a.mceButtonDisabled img {border: 0 !important; margin-top: 2px; margin-bottom: 1px;} 72 * html a.mceButtonDisabled img {filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30); border: 0 !important;} 73 73 * html a.mceButtonDisabled {border: 1px solid #F0F0EE !important;} 74 * html a.mceButtonNormal, * html a.mceButtonSelected {border: 1px solid #F0F0EE !important; 75 * html a.mceButtonSelected {border: 1px solid #6779AA !important; 76 * html a.mceButtonNormal:hover, * html a.mceButtonSelected:hover {border: 1px solid #0A246A !important; background-color: #B6BDD2;cursor: default;}74 * html a.mceButtonNormal, * html a.mceButtonSelected {border: 1px solid #F0F0EE !important; cursor: default;} 75 * html a.mceButtonSelected {border: 1px solid #6779AA !important; background-color: #D4D5D8;} 76 * html a.mceButtonNormal:hover, * html a.mceButtonSelected:hover {border: 1px solid #0A246A !important; background-color: #B6BDD2; cursor: default;} 77 77 * html .mceSelectList {margin-top: 2px;} 78 * html span.mceMenuButton, * html span.mceMenuButtonFocus {position: relative; left: 0;top: 0;}79 * html span.mceMenuButton img, * html span.mceMenuButtonSelected img, * html span.mceMenuButtonFocus img {position: relative; 80 * html a.mceMoreColors {width: 132px;}81 * html .mceColors td a {width: 10px; 82 * html .mceColorPreview {margin-left: 2px; 78 * html span.mceMenuButton, * html span.mceMenuButtonFocus {position: relative; left: 0; top: 0;} 79 * html span.mceMenuButton img, * html span.mceMenuButtonSelected img, * html span.mceMenuButtonFocus img {position: relative; top: 1px;} 80 * html a.mceMoreColors {width: auto;} 81 * html .mceColors td a {width: 10px; height: 10px;} 82 * html .mceColorPreview {margin-left: 2px; margin-top: 14px;} 83 83 84 84 /* MSIE 7 specific rules */ 85 85 86 *:first-child+html a.mceButtonNormal img, *:first-child+html a.mceButtonSelected img, *:first-child+html a.mceButtonDisabled img {border: 0 !important; margin-top: 2px;margin-bottom: 1px;}87 *:first-child+html a.mceButtonDisabled img {filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30); 86 *:first-child+html a.mceButtonNormal img, *:first-child+html a.mceButtonSelected img, *:first-child+html a.mceButtonDisabled img {border: 0 !important; margin-top: 2px; margin-bottom: 1px;} 87 *:first-child+html a.mceButtonDisabled img {filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30); border: 0 !important;} 88 88 *:first-child+html a.mceButtonDisabled {border: 1px solid #F0F0EE !important;} 89 *:first-child+html a.mceButtonNormal, *:first-child+html a.mceButtonSelected {border: 1px solid #F0F0EE !important; 90 *:first-child+html a.mceButtonSelected {border: 1px solid #6779AA !important; 91 *:first-child+html a.mceButtonNormal:hover, *:first-child+html a.mceButtonSelected:hover {border: 1px solid #0A246A !important; background-color: #B6BDD2;cursor: default;}89 *:first-child+html a.mceButtonNormal, *:first-child+html a.mceButtonSelected {border: 1px solid #F0F0EE !important; cursor: default;} 90 *:first-child+html a.mceButtonSelected {border: 1px solid #6779AA !important; background-color: #D4D5D8;} 91 *:first-child+html a.mceButtonNormal:hover, *:first-child+html a.mceButtonSelected:hover {border: 1px solid #0A246A !important; background-color: #B6BDD2; cursor: default;} 92 92 *:first-child+html .mceSelectList {margin-top: 2px;} 93 *:first-child+html span.mceMenuButton, *:first-child+html span.mceMenuButtonFocus {position: relative; left: 0;top: 0;}94 *:first-child+html span.mceMenuButton img, *:first-child+html span.mceMenuButtonSelected img, *:first-child+html span.mceMenuButtonFocus img {position: relative; 95 *:first-child+html a.mceMoreColors {width: 13 2px;}96 *:first-child+html .mceColors td a {width: 10px; 97 *:first-child+html .mceColorPreview {margin: 0; padding-left: 4px; 93 *:first-child+html span.mceMenuButton, *:first-child+html span.mceMenuButtonFocus {position: relative; left: 0; top: 0;} 94 *:first-child+html span.mceMenuButton img, *:first-child+html span.mceMenuButtonSelected img, *:first-child+html span.mceMenuButtonFocus img {position: relative; top: 1px;} 95 *:first-child+html a.mceMoreColors {width: 137px;} 96 *:first-child+html .mceColors td a {width: 10px; height: 10px;} 97 *:first-child+html .mceColorPreview {margin: 0; padding-left: 4px; margin-top: 14px; width: 14px;} -
tags/2.2/wp-includes/js/tinymce/themes/advanced/editor_template.js
r5468 r5480 1 1 /** 2 * $Id: editor_template_src.js 129 2006-10-23 09:45:17Z spocke $2 * $Id: editor_template_src.js 218 2007-02-13 11:08:01Z spocke $ 3 3 * 4 4 * @author Moxiecode 5 * @copyright Copyright © 2004-200 6, Moxiecode Systems AB, All rights reserved.5 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. 6 6 */ 7 7 … … 44 44 ['sup', 'sup.gif', 'lang_theme_sup_desc', 'superscript'], 45 45 ['forecolor', 'forecolor.gif', 'lang_theme_forecolor_desc', 'forecolor', true], 46 ['forecolorpicker', 'forecolor.gif', 'lang_theme_forecolor_desc', 'forecolorpicker', true], 46 47 ['backcolor', 'backcolor.gif', 'lang_theme_backcolor_desc', 'HiliteColor', true], 48 ['backcolorpicker', 'backcolor.gif', 'lang_theme_backcolor_desc', 'backcolorpicker', true], 47 49 ['charmap', 'charmap.gif', 'lang_theme_charmap_desc', 'mceCharMap'], 48 50 ['visualaid', 'visualaid.gif', 'lang_theme_visualaid_desc', 'mceToggleVisualAid'], … … 357 359 return false; 358 360 361 case "forecolorpicker": 362 this._pickColor(editor_id, 'forecolor'); 363 return true; 364 359 365 case "forecolorMenu": 360 366 TinyMCE_AdvancedTheme._hideMenus(editor_id); … … 421 427 ml.show(); 422 428 return true; 429 430 case "backcolorpicker": 431 this._pickColor(editor_id, 'HiliteColor'); 432 return true; 423 433 424 434 case "mceColorPicker": 425 435 if (user_interface) { 426 var template = new Array(); 427 var inputColor = value['document'].getElementById(value['element_id']).value; 436 var template = []; 437 438 if (!value['callback'] && !value['color']) 439 value['color'] = value['document'].getElementById(value['element_id']).value; 428 440 429 441 template['file'] = 'color_picker.htm'; 430 template['width'] = 220;431 template['height'] = 190;442 template['width'] = 380; 443 template['height'] = 250; 432 444 template['close_previous'] = "no"; 433 445 … … 439 451 440 452 tinyMCE.lastColorPickerValue = value; 441 tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : inputColor});453 tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : value['color']}); 442 454 } else { 443 var savedVal = tinyMCE.lastColorPickerValue; 444 var elm = savedVal['document'].getElementById(savedVal['element_id']); 455 var savedVal = tinyMCE.lastColorPickerValue, elm; 456 457 if (savedVal['callback']) { 458 savedVal['callback'](value); 459 return true; 460 } 461 462 elm = savedVal['document'].getElementById(savedVal['element_id']); 445 463 elm.value = value; 446 464 … … 600 618 template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width_style};height:{$height_style}"><tbody>'; 601 619 602 if (toolbarLocation == "top") { 603 template['html'] += '<tr><td class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>'; 604 } 620 if (toolbarLocation == "top") 621 template['html'] += '<tr><td dir="ltr" class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>'; 605 622 606 623 if (statusbarLocation == "top") { … … 611 628 template['html'] += '<tr><td align="center"><span id="{$editor_id}"></span></td></tr>'; 612 629 613 if (toolbarLocation == "bottom") { 614 template['html'] += '<tr><td class="mceToolbarBottom" align="' + toolbarAlign + '" height="1"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>'; 615 } 630 if (toolbarLocation == "bottom") 631 template['html'] += '<tr><td dir="ltr" class="mceToolbarBottom" align="' + toolbarAlign + '" height="1"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>'; 616 632 617 633 // External toolbar changes … … 714 730 715 731 template['html'] = tinyMCE.replaceVar(template['html'], 'style_select_options', styleSelectHTML); 716 template['delta_width'] = 0; 717 template['delta_height'] = deltaHeight; 732 733 // Set to default values 734 if (!template['delta_width']) 735 template['delta_width'] = 0; 736 737 if (!template['delta_height']) 738 template['delta_height'] = deltaHeight; 718 739 719 740 return template; … … 733 754 }, 734 755 756 removeInstance : function(inst) { 757 new TinyMCE_Layer(inst.editorId + '_fcMenu').remove(); 758 new TinyMCE_Layer(inst.editorId + '_bcMenu').remove(); 759 }, 760 761 hideInstance : function(inst) { 762 TinyMCE_AdvancedTheme._hideMenus(inst.editorId); 763 }, 764 735 765 _handleMenuEvent : function(e) { 736 766 var te = tinyMCE.isMSIE ? window.event.srcElement : e.target; … … 781 811 782 812 return false; 783 };784 785 function getAttrib(elm, name) {786 return elm.getAttribute(name) ? elm.getAttribute(name) : "";787 813 }; 788 814 … … 840 866 if (st != "") { 841 867 st = tinyMCE.serializeStyle(tinyMCE.parseStyle(st)); 842 nodeData += "style: " + st+ " ";868 nodeData += "style: " + tinyMCE.xmlEncode(st) + " "; 843 869 } 844 870 } … … 850 876 var face = tinyMCE.getAttrib(path[i], "face"); 851 877 if (face != "") 852 nodeData += "font: " + face+ " ";878 nodeData += "font: " + tinyMCE.xmlEncode(face) + " "; 853 879 854 880 var size = tinyMCE.getAttrib(path[i], "size"); 855 881 if (size != "") 856 nodeData += "size: " + size+ " ";882 nodeData += "size: " + tinyMCE.xmlEncode(size) + " "; 857 883 858 884 var color = tinyMCE.getAttrib(path[i], "color"); 859 885 if (color != "") 860 nodeData += "color: " + color+ " ";861 } 862 863 if ( getAttrib(path[i], 'id') != "") {886 nodeData += "color: " + tinyMCE.xmlEncode(color) + " "; 887 } 888 889 if (tinyMCE.getAttrib(path[i], 'id') != "") { 864 890 nodeData += "id: " + path[i].getAttribute('id') + " "; 865 891 } … … 869 895 nodeData += "class: " + className + " "; 870 896 871 if ( getAttrib(path[i], 'src') != "") {897 if (tinyMCE.getAttrib(path[i], 'src') != "") { 872 898 var src = tinyMCE.getAttrib(path[i], "mce_src"); 873 899 … … 875 901 src = tinyMCE.getAttrib(path[i], "src"); 876 902 877 nodeData += "src: " + src+ " ";878 } 879 880 if (path[i].nodeName == 'A' && getAttrib(path[i], 'href') != "") {903 nodeData += "src: " + tinyMCE.xmlEncode(src) + " "; 904 } 905 906 if (path[i].nodeName == 'A' && tinyMCE.getAttrib(path[i], 'href') != "") { 881 907 var href = tinyMCE.getAttrib(path[i], "mce_href"); 882 908 … … 884 910 href = tinyMCE.getAttrib(path[i], "href"); 885 911 886 nodeData += "href: " + href+ " ";912 nodeData += "href: " + tinyMCE.xmlEncode(href) + " "; 887 913 } 888 914 … … 895 921 if (nodeName == "a" && (anchor = tinyMCE.getAttrib(path[i], "name")) != "") { 896 922 nodeName = "a"; 897 nodeName += "#" + anchor;923 nodeName += "#" + tinyMCE.xmlEncode(anchor); 898 924 nodeData = ""; 899 925 } 900 926 901 if ( getAttrib(path[i], 'name').indexOf("mce_") != 0) {927 if (tinyMCE.getAttrib(path[i], 'name').indexOf("mce_") != 0) { 902 928 var className = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i], "class"), false); 903 929 if (className != "" && className.indexOf('mceItem') == -1) { … … 1125 1151 1126 1152 case "IMG": 1127 if ( getAttrib(node, 'name').indexOf('mce_') != 0 && tinyMCE.getAttrib(node, 'class').indexOf('mceItem') == -1) {1153 if (tinyMCE.getAttrib(node, 'name').indexOf('mce_') != 0 && tinyMCE.getAttrib(node, 'class').indexOf('mceItem') == -1) { 1128 1154 tinyMCE.switchClass(editor_id + '_image', 'mceButtonSelected'); 1129 1155 } … … 1218 1244 tableElm.style.width = w + "px"; 1219 1245 1246 if ( !tinyMCE.isMSIE || tinyMCE.isMSIE7 || tinyMCE.isOpera ) // WordPress: do this later to avoid creeping toolbar bug in MSIE6 1220 1247 tableElm.style.height = h + "px"; 1221 1248 … … 1226 1253 ih = ih < 1 ? 30 : ih; 1227 1254 1255 /* WordPress found that this led to a shrinking editor with every resize. (Gray background creeps in 1px at a time.) 1228 1256 if (tinyMCE.isGecko) { 1229 1257 iw -= 2; 1230 1258 ih -= 2; 1231 1259 } 1260 */ 1232 1261 1233 1262 if (set_w) … … 1246 1275 } 1247 1276 } 1277 1278 tableElm.style.height = h + "px"; // WordPress: see above 1248 1279 1249 1280 // Remove pesky table controls … … 1372 1403 1373 1404 h += '</tr></table>'; 1374 /* 1375 h += '<a href="" class="mceMoreColors">More colors</a>';1376 */1405 1406 if (tinyMCE.getParam("theme_advanced_more_colors", true)) 1407 h += '<a href="#" onclick="TinyMCE_AdvancedTheme._pickColor(\'' + id + '\',\'' + cm + '\');" class="mceMoreColors">' + tinyMCE.getLang('lang_more_colors') + '</a>'; 1377 1408 1378 1409 return h; 1410 }, 1411 1412 _pickColor : function(id, cm) { 1413 var inputColor, inst = tinyMCE.selectedInstance; 1414 1415 if (cm == 'forecolor' && inst) 1416 inputColor = inst.foreColor; 1417 1418 if ((cm == 'backcolor' || cm == 'HiliteColor') && inst) 1419 inputColor = inst.backColor; 1420 1421 tinyMCE.execCommand('mceColorPicker', true, {color : inputColor, callback : function(c) { 1422 tinyMCE.execInstanceCommand(id, cm, false, c); 1423 }}); 1379 1424 }, 1380 1425 -
tags/2.2/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js
r5468 r5480 1 function init() { 2 if (tinyMCE.isMSIE) 3 tinyMCEPopup.resizeToInnerSize(); 4 } 5 6 function selectColor() { 7 var color = document.getElementById("selectedColorBox").value; 8 9 tinyMCEPopup.execCommand(tinyMCE.getWindowArg('command'), false, color); 10 tinyMCEPopup.close(); 11 } 12 13 function showColor(color) { 14 document.getElementById("selectedColor").style.backgroundColor = color; 15 document.getElementById("selectedColorBox").value = color; 16 } 1 var detail = 50, strhex = "0123456789abcdef", i, isMouseDown = false, isMouseOver = false; 17 2 18 3 var colors = new Array( … … 46 31 ); 47 32 33 var named = { 34 '#F0F8FF':'AliceBlue','#FAEBD7':'AntiqueWhite','#00FFFF':'Aqua','#7FFFD4':'Aquamarine','#F0FFFF':'Azure','#F5F5DC':'Beige', 35 '#FFE4C4':'Bisque','#000000':'Black','#FFEBCD':'BlanchedAlmond','#0000FF':'Blue','#8A2BE2':'BlueViolet','#A52A2A':'Brown', 36 '#DEB887':'BurlyWood','#5F9EA0':'CadetBlue','#7FFF00':'Chartreuse','#D2691E':'Chocolate','#FF7F50':'Coral','#6495ED':'CornflowerBlue', 37 '#FFF8DC':'Cornsilk','#DC143C':'Crimson','#00FFFF':'Cyan','#00008B':'DarkBlue','#008B8B':'DarkCyan','#B8860B':'DarkGoldenRod', 38 '#A9A9A9':'DarkGray','#A9A9A9':'DarkGrey','#006400':'DarkGreen','#BDB76B':'DarkKhaki','#8B008B':'DarkMagenta','#556B2F':'DarkOliveGreen', 39 '#FF8C00':'Darkorange','#9932CC':'DarkOrchid','#8B0000':'DarkRed','#E9967A':'DarkSalmon','#8FBC8F':'DarkSeaGreen','#483D8B':'DarkSlateBlue', 40 '#2F4F4F':'DarkSlateGray','#2F4F4F':'DarkSlateGrey','#00CED1':'DarkTurquoise','#9400D3':'DarkViolet','#FF1493':'DeepPink','#00BFFF':'DeepSkyBlue', 41 '#696969':'DimGray','#696969':'DimGrey','#1E90FF':'DodgerBlue','#B22222':'FireBrick','#FFFAF0':'FloralWhite','#228B22':'ForestGreen', 42 '#FF00FF':'Fuchsia','#DCDCDC':'Gainsboro','#F8F8FF':'GhostWhite','#FFD700':'Gold','#DAA520':'GoldenRod','#808080':'Gray','#808080':'Grey', 43 '#008000':'Green','#ADFF2F':'GreenYellow','#F0FFF0':'HoneyDew','#FF69B4':'HotPink','#CD5C5C':'IndianRed','#4B0082':'Indigo','#FFFFF0':'Ivory', 44 '#F0E68C':'Khaki','#E6E6FA':'Lavender','#FFF0F5':'LavenderBlush','#7CFC00':'LawnGreen','#FFFACD':'LemonChiffon','#ADD8E6':'LightBlue', 45 '#F08080':'LightCoral','#E0FFFF':'LightCyan','#FAFAD2':'LightGoldenRodYellow','#D3D3D3':'LightGray','#D3D3D3':'LightGrey','#90EE90':'LightGreen', 46 '#FFB6C1':'LightPink','#FFA07A':'LightSalmon','#20B2AA':'LightSeaGreen','#87CEFA':'LightSkyBlue','#778899':'LightSlateGray','#778899':'LightSlateGrey', 47 '#B0C4DE':'LightSteelBlue','#FFFFE0':'LightYellow','#00FF00':'Lime','#32CD32':'LimeGreen','#FAF0E6':'Linen','#FF00FF':'Magenta','#800000':'Maroon', 48 '#66CDAA':'MediumAquaMarine','#0000CD':'MediumBlue','#BA55D3':'MediumOrchid','#9370D8':'MediumPurple','#3CB371':'MediumSeaGreen','#7B68EE':'MediumSlateBlue', 49 '#00FA9A':'MediumSpringGreen','#48D1CC':'MediumTurquoise','#C71585':'MediumVioletRed','#191970':'MidnightBlue','#F5FFFA':'MintCream','#FFE4E1':'MistyRose','#FFE4B5':'Moccasin', 50 '#FFDEAD':'NavajoWhite','#000080':'Navy','#FDF5E6':'OldLace','#808000':'Olive','#6B8E23':'OliveDrab','#FFA500':'Orange','#FF4500':'OrangeRed','#DA70D6':'Orchid', 51 '#EEE8AA':'PaleGoldenRod','#98FB98':'PaleGreen','#AFEEEE':'PaleTurquoise','#D87093':'PaleVioletRed','#FFEFD5':'PapayaWhip','#FFDAB9':'PeachPuff', 52 '#CD853F':'Peru','#FFC0CB':'Pink','#DDA0DD':'Plum','#B0E0E6':'PowderBlue','#800080':'Purple','#FF0000':'Red','#BC8F8F':'RosyBrown','#4169E1':'RoyalBlue', 53 '#8B4513':'SaddleBrown','#FA8072':'Salmon','#F4A460':'SandyBrown','#2E8B57':'SeaGreen','#FFF5EE':'SeaShell','#A0522D':'Sienna','#C0C0C0':'Silver', 54 '#87CEEB':'SkyBlue','#6A5ACD':'SlateBlue','#708090':'SlateGray','#708090':'SlateGrey','#FFFAFA':'Snow','#00FF7F':'SpringGreen', 55 '#4682B4':'SteelBlue','#D2B48C':'Tan','#008080':'Teal','#D8BFD8':'Thistle','#FF6347':'Tomato','#40E0D0':'Turquoise','#EE82EE':'Violet', 56 '#F5DEB3':'Wheat','#FFFFFF':'White','#F5F5F5':'WhiteSmoke','#FFFF00':'Yellow','#9ACD32':'YellowGreen' 57 }; 58 59 function init() { 60 var inputColor = convertRGBToHex(tinyMCE.getWindowArg('input_color')); 61 62 if (tinyMCE.isMSIE) 63 tinyMCEPopup.resizeToInnerSize(); 64 65 generatePicker(); 66 67 if (inputColor) { 68 changeFinalColor(inputColor); 69 70 col = convertHexToRGB(inputColor); 71 72 if (col) 73 updateLight(col.r, col.g, col.b); 74 } 75 } 76 77 function insertAction() { 78 var color = document.getElementById("color").value; 79 80 tinyMCEPopup.execCommand(tinyMCE.getWindowArg('command'), false, color); 81 tinyMCEPopup.close(); 82 } 83 84 function showColor(color, name) { 85 if (name) 86 document.getElementById("colorname").innerHTML = name; 87 88 document.getElementById("preview").style.backgroundColor = color; 89 document.getElementById("color").value = color; 90 } 91 48 92 function convertRGBToHex(col) { 49 93 var re = new RegExp("rgb\\s*\\(\\s*([0-9]+).*,\\s*([0-9]+).*,\\s*([0-9]+).*\\)", "gi"); 94 95 if (!col) 96 return col; 50 97 51 98 var rgb = col.replace(re, "$1,$2,$3").split(','); … … 73 120 b = parseInt(col.substring(4, 6), 16); 74 121 75 return "rgb(" + r + "," + g + "," + b + ")"; 76 } 77 78 return col; 79 } 80 81 function renderColorMap() { 82 var html = ""; 83 var inputColor = convertRGBToHex(tinyMCE.getWindowArg('input_color')); 84 85 html += '<table border="0" cellspacing="1" cellpadding="0">' 122 return {r : r, g : g, b : b}; 123 } 124 125 return null; 126 } 127 128 function generatePicker() { 129 var el = document.getElementById('light'), h = '', i; 130 131 for (i = 0; i < detail; i++){ 132 h += '<div id="gs'+i+'" style="background-color:#000000; width:15px; height:3px; border-style:none; border-width:0px;"' 133 + ' onclick="changeFinalColor(this.style.backgroundColor)"' 134 + ' onmousedown="isMouseDown = true; return false;"' 135 + ' onmouseup="isMouseDown = false;"' 136 + ' onmousemove="if (isMouseDown && isMouseOver) changeFinalColor(this.style.backgroundColor); return false;"' 137 + ' onmouseover="isMouseOver = true;"' 138 + ' onmouseout="isMouseOver = false;"' 139 + '></div>'; 140 } 141 142 el.innerHTML = h; 143 } 144 145 function generateWebColors() { 146 var el = document.getElementById('webcolors'), h = '', i; 147 148 if (el.className == 'generated') 149 return; 150 151 h += '<table border="0" cellspacing="1" cellpadding="0">' 86 152 + '<tr>'; 87 for (var i=0; i<colors.length; i++) { 88 html += '<td bgcolor="' + colors[i] + '">' 153 154 for (i=0; i<colors.length; i++) { 155 h += '<td bgcolor="' + colors[i] + '">' 89 156 + '<a href="javascript:selectColor();" onfocus="showColor(\'' + colors[i] + '\');" onmouseover="showColor(\'' + colors[i] + '\');">' 90 157 + '<img border="0" src="images/spacer.gif" width="10" height="10" title="' + colors[i] + '" alt="' + colors[i] + '" /></a></td>'; 91 158 if ((i+1) % 18 == 0) 92 html += '</tr><tr>'; 93 } 94 html += '<tr><td colspan="18">' 95 + '<table width="100%" border="0" cellspacing="0" cellpadding="0">' 96 + '<tr><td>' 97 + '<img id="selectedColor" style="background-color:' + tinyMCE.getWindowArg('input_color') + '" border="0" src="images/spacer.gif" width="80" height="16" />' 98 + '</td><td align="right">' 99 + '<input id="selectedColorBox" name="selectedColorBox" type="text" size="7" maxlength="7" style="width:65px" value="' + inputColor + '" />' 100 + '</td></tr>' 101 + '</table>' 102 + '<div style="float: left"><input type="button" id="insert" name="insert" value="{$lang_theme_colorpicker_apply}" style="margin-top:3px" onclick="selectColor();"></div>' 103 + '<div style="float: right"><input type="button" name="cancel" value="{$lang_cancel}" style="margin-top:3px" onclick="tinyMCEPopup.close();" id="cancel" /></div>' 104 + '</td></tr>' 105 + '</table>'; 106 107 document.write(html); 108 } 159 h += '</tr><tr>'; 160 } 161 162 h += '</table>'; 163 164 el.innerHTML = h; 165 el.className = 'generated'; 166 } 167 168 function generateNamedColors() { 169 var el = document.getElementById('namedcolors'), h = '', n, v, i = 0; 170 171 if (el.className == 'generated') 172 return; 173 174 for (n in named) { 175 v = named[n]; 176 h += '<a href="javascript:selectColor();" onmouseover="showColor(\'' + n + '\',\'' + v + '\');" style="background-color: ' + n + '"><!-- IE --></a>' 177 } 178 179 el.innerHTML = h; 180 el.className = 'generated'; 181 } 182 183 function selectColor() { 184 var color = document.getElementById("color").value; 185 186 if(window.opener) 187 window.opener.tinyMCE.execInstanceCommand(tinyMCE.getWindowArg('editor_id'),tinyMCE.getWindowArg('command'),false,color); 188 189 window.close(); 190 } 191 192 function dechex(n) { 193 return strhex.charAt(Math.floor(n / 16)) + strhex.charAt(n % 16); 194 } 195 196 function computeColor(e) { 197 var x, y, partWidth, partDetail, imHeight, r, g, b, coef, i, finalCoef, finalR, finalG, finalB; 198 199 x = e.offsetX ? e.offsetX : (e.target ? e.clientX - e.target.x : 0); 200 y = e.offsetY ? e.offsetY : (e.target ? e.clientY - e.target.y : 0); 201 202 partWidth = document.getElementById('colorpicker').width / 6; 203 partDetail = detail / 2; 204 imHeight = document.getElementById('colorpicker').height; 205 206 r = (x >= 0)*(x < partWidth)*255 + (x >= partWidth)*(x < 2*partWidth)*(2*255 - x * 255 / partWidth) + (x >= 4*partWidth)*(x < 5*partWidth)*(-4*255 + x * 255 / partWidth) + (x >= 5*partWidth)*(x < 6*partWidth)*255; 207 g = (x >= 0)*(x < partWidth)*(x * 255 / partWidth) + (x >= partWidth)*(x < 3*partWidth)*255 + (x >= 3*partWidth)*(x < 4*partWidth)*(4*255 - x * 255 / partWidth); 208 b = (x >= 2*partWidth)*(x < 3*partWidth)*(-2*255 + x * 255 / partWidth) + (x >= 3*partWidth)*(x < 5*partWidth)*255 + (x >= 5*partWidth)*(x < 6*partWidth)*(6*255 - x * 255 / partWidth); 209 210 coef = (imHeight - y) / imHeight; 211 r = 128 + (r - 128) * coef; 212 g = 128 + (g - 128) * coef; 213 b = 128 + (b - 128) * coef; 214 215 changeFinalColor('#' + dechex(r) + dechex(g) + dechex(b)); 216 updateLight(r, g, b); 217 } 218 219 function updateLight(r, g, b) { 220 var i, partDetail = detail / 2, finalCoef, finalR, finalG, finalB, color; 221 222 for (i=0; i<detail; i++) { 223 if ((i>=0) && (i<partDetail)) { 224 finalCoef = i / partDetail; 225 finalR = dechex(255 - (255 - r) * finalCoef); 226 finalG = dechex(255 - (255 - g) * finalCoef); 227 finalB = dechex(255 - (255 - b) * finalCoef); 228 } else { 229 finalCoef = 2 - i / partDetail; 230 finalR = dechex(r * finalCoef); 231 finalG = dechex(g * finalCoef); 232 finalB = dechex(b * finalCoef); 233 } 234 235 color = finalR + finalG + finalB; 236 237 document.getElementById('gs' + i).style.backgroundColor = '#'+color; 238 } 239 } 240 241 function changeFinalColor(color) { 242 if (color.indexOf('#') == -1) 243 color = convertRGBToHex(color); 244 245 document.getElementById('preview').style.backgroundColor = color; 246 document.getElementById('color').value = color; 247 } 248 249 window.focus(); -
tags/2.2/wp-includes/js/tinymce/themes/advanced/jscripts/link.js
r5468 r5480 28 28 document.forms[0].href.value = tinyMCE.getWindowArg('href') || 'http://'; 29 29 document.forms[0].href.select(); 30 document.forms[0].href.focus(); 30 31 document.forms[0].linktitle.value = tinyMCE.getWindowArg('title'); 31 32 document.forms[0].insert.value = tinyMCE.getLang('lang_' + tinyMCE.getWindowArg('action'), 'Insert', true); … … 58 59 var style_class = document.forms[0].styleSelect ? document.forms[0].styleSelect.value : ""; 59 60 var dummy; 60 61 // Make anchors absolute61 62 // WordPress: Make anchors absolute; 62 63 if (href.charAt(0) == '#') 63 64 href = tinyMCE.settings['document_base_url'] + href; -
tags/2.2/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js
r5468 r5480 26 26 s.wrap = val; 27 27 28 if (tinyMCE.isGecko ) {28 if (tinyMCE.isGecko || tinyMCE.isOpera) { 29 29 var v = s.value; 30 30 var n = s.cloneNode(false); … … 48 48 49 49 if (!tinyMCE.isMSIE) { 50 wHeight = self.innerHeight -80;51 wWidth = self.innerWidth -16;50 wHeight = self.innerHeight - 60; 51 wWidth = self.innerWidth - 16; 52 52 } else { 53 wHeight = document.body.clientHeight - 80;53 wHeight = document.body.clientHeight - 60; 54 54 wWidth = document.body.clientWidth - 16; 55 55 } … … 58 58 el.style.width = Math.abs(wWidth) + 'px'; 59 59 } 60 -
tags/2.2/wp-includes/js/tinymce/themes/advanced/langs/en.js
r5468 r5480 79 79 close : 'Close', 80 80 toolbar_focus : 'Jump to tool buttons - Alt+Q, Jump to editor - Alt-Z, Jump to element path - Alt-X', 81 invalid_data : 'Error: Invalid values entered, these are marked in red.' 81 invalid_data : 'Error: Invalid values entered, these are marked in red.', 82 more_colors : 'More colors', 83 color_picker_tab : 'Picker', 84 color_picker : 'Color picker', 85 web_colors_tab : 'Web safe', 86 web_colors : 'Web safe colors', 87 named_colors_tab : 'Named', 88 named_colors : 'Named colors', 89 color : 'Color:', 90 color_name : 'Name:' 82 91 }); -
tags/2.2/wp-includes/js/tinymce/tiny_mce.js
r5468 r5480 6 6 7 7 this.majorVersion = "2"; 8 this.minorVersion = " 0.8";9 this.releaseDate = "200 6-10-23";8 this.minorVersion = "1.0"; 9 this.releaseDate = "2007-02-13"; 10 10 11 11 this.instances = new Array(); … … 187 187 this._def("convert_on_click", false); 188 188 this._def("content_css", ''); 189 this._def("fix_list_elements", false);189 this._def("fix_list_elements", true); 190 190 this._def("fix_table_elements", false); 191 191 this._def("strict_loading_mode", document.contentType == 'application/xhtml+xml'); … … 193 193 this._def("display_tab_class", ''); 194 194 this._def("gecko_spellcheck", false); 195 this._def("hide_selects_on_submit", true); 195 196 196 197 // Force strict loading mode to false on non Gecko browsers … … 241 242 this.blockRegExp = new RegExp("^(" + this.blockElms + ")$", "i"); 242 243 this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40); 243 this.uniqueURL = 'javascript: TINYMCE_UNIQUEURL();'; // Make unique URL non real URL244 this.uniqueURL = 'javascript:void(091039730);'; // Make unique URL non real URL 244 245 this.uniqueTag = '<div id="mceTMPElement" style="display: none">TMP</div>'; 245 this.callbacks = new Array('onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup' );246 this.callbacks = new Array('onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup', 'removeInstance'); 246 247 247 248 // Theme url … … 339 340 } 340 341 } 342 343 // Setup XML encoding regexps 344 this.xmlEncodeAposRe = new RegExp('[<>&"\']', 'g'); 345 this.xmlEncodeRe = new RegExp('[<>&"]', 'g'); 346 // this.xmlEncodeEnts = {'&':'&','"':'"',"'":''','<':'<','>':'>'}; 341 347 }, 342 348 … … 571 577 tinyMCE.undoIndex = n.length; 572 578 579 // Dispatch remove instance call 580 tinyMCE.dispatchCallback(ti, 'remove_instance_callback', 'removeInstance', ti); 581 573 582 return ti; 574 583 }, … … 730 739 case "mceRemoveEditor": 731 740 tinyMCE.removeMCEControl(value); 741 return; 742 743 case "mceToggleEditor": 744 var inst = tinyMCE.getInstanceById(value), pe, te; 745 746 if (inst) { 747 pe = document.getElementById(inst.editorId + '_parent'); 748 te = inst.oldTargetElement; 749 750 if (typeof(inst.enabled) == 'undefined') 751 inst.enabled = true; 752 753 inst.enabled = !inst.enabled; 754 755 if (!inst.enabled) { 756 pe.style.display = 'none'; 757 te.value = inst.getHTML(); 758 te.style.display = inst.oldTargetDisplay; 759 tinyMCE.dispatchCallback(inst, 'hide_instance_callback', 'hideInstance', inst); 760 } else { 761 pe.style.display = 'block'; 762 te.style.display = 'none'; 763 inst.setHTML(te.value); 764 inst.useCSS = false; 765 tinyMCE.dispatchCallback(inst, 'show_instance_callback', 'showInstance', inst); 766 } 767 } else 768 tinyMCE.addMCEControl(tinyMCE._getElementById(value), value); 769 732 770 return; 733 771 … … 837 875 } 838 876 877 tinyMCE.selectedInstance = inst; 839 878 inst.switchSettings(); 840 879 … … 952 991 //inst.getDoc().designMode = inst.getDoc().designMode; 953 992 954 // Setup element references955 var parentElm = inst.targetDoc.getElementById(inst.editorId + '_parent');956 inst.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling;957 958 993 tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings['visual'], inst); 959 994 tinyMCE.dispatchCallback(inst, 'setupcontent_callback', 'setupContent', editor_id, inst.getBody(), inst.getDoc()); … … 1016 1051 storeAwayURLs : function(s) { 1017 1052 // Remove all mce_src, mce_href and replace them with new ones 1018 //s = s.replace(new RegExp('mce_src\\s*=\\s*\"[^ >\"]*\"', 'gi'), '');1019 //s = s.replace(new RegExp('mce_href\\s*=\\s*\"[^ >\"]*\"', 'gi'), '');1053 // s = s.replace(new RegExp('mce_src\\s*=\\s*\"[^ >\"]*\"', 'gi'), ''); 1054 // s = s.replace(new RegExp('mce_href\\s*=\\s*\"[^ >\"]*\"', 'gi'), ''); 1020 1055 1021 1056 if (!s.match(/(mce_src|mce_href)/gi, s)) { … … 1039 1074 }, 1040 1075 1076 removeTinyMCEFormElements : function(form_obj) { 1077 var i, elementId; 1078 1079 // Skip form element removal 1080 if (!tinyMCE.getParam('hide_selects_on_submit')) 1081 return; 1082 1083 // Check if form is valid 1084 if (typeof(form_obj) == "undefined" || form_obj == null) 1085 return; 1086 1087 // If not a form, find the form 1088 if (form_obj.nodeName != "FORM") { 1089 if (form_obj.form) 1090 form_obj = form_obj.form; 1091 else 1092 form_obj = tinyMCE.getParentElement(form_obj, "form"); 1093 } 1094 1095 // Still nothing 1096 if (form_obj == null) 1097 return; 1098 1099 // Disable all UI form elements that TinyMCE created 1100 for (i=0; i<form_obj.elements.length; i++) { 1101 elementId = form_obj.elements[i].name ? form_obj.elements[i].name : form_obj.elements[i].id; 1102 1103 if (elementId.indexOf('mce_editor_') == 0) 1104 form_obj.elements[i].disabled = true; 1105 } 1106 }, 1107 1041 1108 handleEvent : function(e) { 1042 1109 var inst = tinyMCE.selectedInstance; … … 1087 1154 1088 1155 case "submit": 1156 tinyMCE.removeTinyMCEFormElements(tinyMCE.isMSIE ? window.event.srcElement : e.target); 1089 1157 tinyMCE.triggerSave(); 1090 1158 tinyMCE.isNotDirty = true; … … 1403 1471 } else { 1404 1472 if (tinyMCE.isRealIE) 1405 h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton" onmouseover="tinyMCE._menuButtonEvent(\'over\',this);tinyMCE.lastHover = this;" onmouseout="tinyMCE._menuButtonEvent(\'out\',this);">';1473 h += '<span id="{$editor_id}_' + id + '" dir="ltr" class="mceMenuButton" onmouseover="tinyMCE._menuButtonEvent(\'over\',this);tinyMCE.lastHover = this;" onmouseout="tinyMCE._menuButtonEvent(\'out\',this);">'; 1406 1474 else 1407 h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton">';1475 h += '<span id="{$editor_id}_' + id + '" dir="ltr" class="mceMenuButton">'; 1408 1476 1409 1477 h += '<a href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceMenuButtonNormal" target="_self">'; … … 1434 1502 1435 1503 submitPatch : function() { 1504 tinyMCE.removeTinyMCEFormElements(this); 1436 1505 tinyMCE.triggerSave(); 1437 1506 tinyMCE.isNotDirty = true; … … 1650 1719 1651 1720 triggerNodeChange : function(focus, setup_content) { 1721 var elm, inst, editorId, undoIndex = -1, undoLevels = -1, doc, anySelection = false, st; 1722 1652 1723 if (tinyMCE.selectedInstance) { 1653 var inst = tinyMCE.selectedInstance; 1654 var editorId = inst.editorId; 1655 var elm = (typeof(setup_content) != "undefined" && setup_content) ? tinyMCE.selectedElement : inst.getFocusElement(); 1656 var undoIndex = -1, doc; 1657 var undoLevels = -1; 1658 var anySelection = false; 1659 var selectedText = inst.selection.getSelectedText(); 1724 inst = tinyMCE.selectedInstance; 1725 elm = (typeof(setup_content) != "undefined" && setup_content) ? tinyMCE.selectedElement : inst.getFocusElement(); 1726 1727 /* if (elm == inst.lastTriggerEl) 1728 return; 1729 1730 inst.lastTriggerEl = elm;*/ 1731 1732 editorId = inst.editorId; 1733 st = inst.selection.getSelectedText(); 1660 1734 1661 1735 if (tinyMCE.settings.auto_resize) … … 1668 1742 1669 1743 if (tinyMCE.selectedElement) 1670 anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (s electedText && selectedText.length > 0);1744 anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (st && st.length > 0); 1671 1745 1672 1746 if (tinyMCE.settings['custom_undo_redo']) { … … 1754 1828 openWindow : function(template, args) { 1755 1829 var html, width, height, x, y, resizable, scrollbars, url; 1830 1831 args = !args ? {} : args; 1756 1832 1757 1833 args['mce_template_file'] = template['file']; … … 2130 2206 2131 2207 getCSSClasses : function(editor_id, doc) { 2132 var output = new Array();2208 var inst = tinyMCE.getInstanceById(editor_id); 2133 2209 2134 2210 // Is cached, use that 2135 if ( typeof(tinyMCE.cssClasses) != "undefined")2136 return tinyMCE.cssClasses;2211 if (inst && inst.cssClasses.length > 0) 2212 return inst.cssClasses; 2137 2213 2138 2214 if (typeof(editor_id) == "undefined" && typeof(doc) == "undefined") { … … 2192 2268 var addClass = true; 2193 2269 2194 for (var p=0; p< output.length && addClass; p++) {2195 if ( output[p] == cssClass)2270 for (var p=0; p<inst.cssClasses.length && addClass; p++) { 2271 if (inst.cssClasses[p] == cssClass) 2196 2272 addClass = false; 2197 2273 } 2198 2274 2199 2275 if (addClass) 2200 output[output.length] = cssClass;2276 inst.cssClasses[inst.cssClasses.length] = cssClass; 2201 2277 } 2202 2278 } … … 2207 2283 } 2208 2284 2209 // Cache em 2210 if (output.length > 0) 2211 tinyMCE.cssClasses = output; 2212 2213 return output; 2285 return inst.cssClasses; 2214 2286 }, 2215 2287 … … 2239 2311 2240 2312 getControlHTML : function(c) { 2241 var i, l, n, o, v ;2313 var i, l, n, o, v, rtl = tinyMCE.getLang('lang_dir') == 'rtl'; 2242 2314 2243 2315 l = tinyMCE.plugins; … … 2245 2317 o = l[n]; 2246 2318 2247 if (o.getControlHTML && (v = o.getControlHTML(c)) != '') 2319 if (o.getControlHTML && (v = o.getControlHTML(c)) != '') { 2320 if (rtl) 2321 return '<span dir="rtl">' + tinyMCE.replaceVar(v, "pluginurl", o.baseURL) + '</span>'; 2322 2248 2323 return tinyMCE.replaceVar(v, "pluginurl", o.baseURL); 2324 } 2249 2325 } 2250 2326 2251 2327 o = tinyMCE.themes[tinyMCE.settings['theme']]; 2252 if (o.getControlHTML && (v = o.getControlHTML(c)) != '') 2328 if (o.getControlHTML && (v = o.getControlHTML(c)) != '') { 2329 if (rtl) 2330 return '<span dir="rtl">' + v + '</span>'; 2331 2253 2332 return v; 2333 } 2254 2334 2255 2335 return ''; … … 2257 2337 2258 2338 evalFunc : function(f, idx, a, o) { 2259 var s = '(', i; 2260 2261 for (i=idx; i<a.length; i++) { 2262 s += 'a[' + i + ']'; 2263 2264 if (i < a.length-1) 2265 s += ','; 2266 } 2267 2268 s += ');'; 2269 2270 return o ? eval("o." + f + s) : eval("f" + s); 2339 o = !o ? window : o; 2340 f = typeof(f) == 'function' ? f : o[f]; 2341 2342 return f.apply(o, Array.prototype.slice.call(a, idx)); 2271 2343 }, 2272 2344 … … 2290 2362 l = tinyMCE.getParam(p, ''); 2291 2363 2292 if (l != '' && (v = tinyMCE.evalFunc( typeof(l) == "function" ? l : eval(l), 3, a)) == s && m > 0)2364 if (l != '' && (v = tinyMCE.evalFunc(l, 3, a)) == s && m > 0) 2293 2365 return true; 2294 2366 … … 2313 2385 }, 2314 2386 2315 xmlEncode : function(s ) {2316 return s ? ('' + s).replace( new RegExp('[<>&"\']', 'g'), function (c, b) {2387 xmlEncode : function(s, skip_apos) { 2388 return s ? ('' + s).replace(!skip_apos ? this.xmlEncodeAposRe : this.xmlEncodeRe, function (c, b) { 2317 2389 switch (c) { 2318 2390 case '&': … … 2391 2463 this.foreColor = this.backColor = "#999999"; 2392 2464 this.data = {}; 2465 this.cssClasses = []; 2393 2466 2394 2467 this.cleanup.init({ … … 2399 2472 entity_encoding : s.entity_encoding, 2400 2473 debug : s.cleanup_debug, 2401 url_converter : 'TinyMCE_Cleanup.prototype._urlConverter',2402 2474 indent : s.apply_source_formatting, 2403 2475 invalid_elements : s.invalid_elements, 2404 2476 verify_html : s.verify_html, 2405 fix_content_duplication : s.fix_content_duplication 2477 fix_content_duplication : s.fix_content_duplication, 2478 convert_fonts_to_spans : s.convert_fonts_to_spans 2406 2479 }); 2407 2480 … … 2594 2667 2595 2668 handleShortcut : function(e) { 2596 var i, s = this.shortcuts, o; 2669 var i, s, o; 2670 2671 // Normal key press, then ignore it 2672 if (!e.altKey && !e.ctrlKey) 2673 return false; 2674 2675 s = this.shortcuts; 2597 2676 2598 2677 for (i=0; i<s.length; i++) { … … 2703 2782 this.contentDocument = doc; // <-- Strange, unless this is applied Mozilla 1.3 breaks 2704 2783 2705 if (tinyMCE.execCommandCallback(this, 'execcommand_callback', 'execCommand', this.editorId, this.getBody(), command, user_interface, value)) 2706 return; 2784 // Don't dispatch key commands 2785 if (!/mceStartTyping|mceEndTyping/.test(command)) { 2786 if (tinyMCE.execCommandCallback(this, 'execcommand_callback', 'execCommand', this.editorId, this.getBody(), command, user_interface, value)) 2787 return; 2788 } 2707 2789 2708 2790 // Fix align on images … … 2814 2896 focusElm = tinyMCE.getParentElement(focusElm, 'A'); 2815 2897 2816 if (focusElm && this.getRng(0).endOffset > 0 && this.getRng(0).endOffset != focusElm.innerHTML.length)2898 if (focusElm) 2817 2899 this.selection.selectNode(focusElm, false); 2818 2900 } … … 2825 2907 2826 2908 return true; 2827 2828 case "FormatBlock":2829 if (!this.cleanup.isValid(value))2830 return true;2831 2832 this.getDoc().execCommand(command, user_interface, value);2833 tinyMCE.triggerNodeChange();2834 break;2835 2909 2836 2910 case "InsertUnorderedList": … … 2858 2932 this.execCommand("mceRemoveNode", false, elm); 2859 2933 } else { 2934 if (!this.cleanup.isValid(value)) 2935 return true; 2936 2860 2937 if (tinyMCE.isGecko && new RegExp('<(div|blockquote|code|dt|dd|dl|samp)>', 'gi').test(value)) 2861 2938 value = value.replace(/[^a-z]/gi, ''); … … 2916 2993 break; 2917 2994 2995 case "mceSetStyleInfo": 2918 2996 case "SetStyleInfo": 2919 2997 var rng = this.getRng(); … … 3247 3325 3248 3326 case "mceSetCSSClass": 3249 this.execCommand(" SetStyleInfo", false, {command : "setattrib", name : "class", value : value});3327 this.execCommand("mceSetStyleInfo", false, {command : "setattrib", name : "class", value : value}); 3250 3328 break; 3251 3329 … … 3479 3557 break; 3480 3558 3559 case "RemoveFormat": 3481 3560 case "removeformat": 3482 3561 var text = this.selection.getSelectedText(); … … 3495 3574 } 3496 3575 3497 this.execCommand(" SetStyleInfo", false, {command : "removeformat"});3576 this.execCommand("mceSetStyleInfo", false, {command : "removeformat"}); 3498 3577 } else { 3499 3578 this.getDoc().execCommand(command, user_interface, value); 3500 3579 3501 this.execCommand(" SetStyleInfo", false, {command : "removeformat"});3580 this.execCommand("mceSetStyleInfo", false, {command : "removeformat"}); 3502 3581 } 3503 3582 … … 3642 3721 } else { 3643 3722 hc = '<input type="hidden" id="' + form_element_name + '" name="' + form_element_name + '" />'; 3723 this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline'); 3644 3724 this.oldTargetElement.style.display = "none"; 3645 3725 } … … 3667 3747 this.oldTargetElement = replace_element; 3668 3748 3669 if (!tinyMCE.settings['debug']) 3749 if (!tinyMCE.settings['debug']) { 3750 this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline'); 3670 3751 this.oldTargetElement.style.display = "none"; 3752 } 3671 3753 3672 3754 // Output HTML and set editable … … 3741 3823 if (tinyMCE.isIE) 3742 3824 window.setTimeout("tinyMCE.addEventHandlers(tinyMCE.instances[\"" + this.editorId + "\"]);", 1); 3825 3826 // Setup element references 3827 var parentElm = this.targetDoc.getElementById(this.editorId + '_parent'); 3828 this.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling; 3743 3829 3744 3830 tinyMCE.setupContent(this.editorId, true); … … 3998 4084 val = tinyMCE.convertRGBToHex(val, true); 3999 4085 4086 val = val.replace(/\"/g, '\''); 4087 4000 4088 if (val != "url('')") 4001 4089 str += key.toLowerCase() + ": " + val + "; "; … … 4044 4132 var sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(','); 4045 4133 4046 var h = doc.body.innerHTML;4134 /*var h = doc.body.innerHTML; 4047 4135 h = h.replace(/<span/gi, '<font'); 4048 4136 h = h.replace(/<\/span/gi, '</font'); 4049 tinyMCE.setInnerHTML(doc.body, h); 4050 4051 var s = doc.getElementsByTagName("font");4137 tinyMCE.setInnerHTML(doc.body, h);*/ 4138 4139 var s = tinyMCE.selectElements(doc, 'span,font'); 4052 4140 for (var i=0; i<s.length; i++) { 4053 4141 var size = tinyMCE.trim(s[i].style.fontSize).toLowerCase(); … … 4083 4171 var sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(','); 4084 4172 4085 var h = doc.body.innerHTML;4173 /* var h = doc.body.innerHTML; 4086 4174 h = h.replace(/<font/gi, '<span'); 4087 4175 h = h.replace(/<\/font/gi, '</span'); 4088 tinyMCE.setInnerHTML(doc.body, h); 4176 tinyMCE.setInnerHTML(doc.body, h);*/ 4089 4177 4090 4178 var fsClasses = tinyMCE.getParam('font_size_classes'); … … 4094 4182 fsClasses = null; 4095 4183 4096 var s = doc.getElementsByTagName("span");4184 var s = tinyMCE.selectElements(doc, 'span,font'); 4097 4185 for (var i=0; i<s.length; i++) { 4098 4186 var fSize, fFace, fColor; … … 4183 4271 n = nl[i]; 4184 4272 4185 if ((p = tinyMCE.getParentElement(n, 'p, div,h1,h2,h3,h4,h5,h6')) != null) {4273 if ((p = tinyMCE.getParentElement(n, 'p,h1,h2,h3,h4,h5,h6')) != null) { 4186 4274 np = p.cloneNode(false); 4187 4275 np.removeAttribute('id'); … … 4381 4469 this.fillStr = s.entity_encoding == "named" ? " " : " "; 4382 4470 this.idCount = 0; 4471 this.xmlEncodeRe = new RegExp('[\u007F-\uFFFF<>&"]', 'g'); 4472 this.xmlEncodeAposRe = new RegExp('[\u007F-\uFFFF<>&"\']', 'g'); 4383 4473 }, 4384 4474 … … 4404 4494 isValid : function(n) { 4405 4495 this._setupRules(); // Will initialize cleanup rules 4496 4497 // Empty is true since it removes formatting 4498 if (!n) 4499 return true; 4406 4500 4407 4501 // Clean the name up a bit … … 4607 4701 var xd, el, i, l, cn, at, no, hc = false; 4608 4702 4609 if (t his._isDuplicate(n))4703 if (tinyMCE.isRealIE && this._isDuplicate(n)) 4610 4704 return; 4611 4705 … … 4650 4744 4651 4745 serializeNodeAsHTML : function(n, inn) { 4652 var en, no, h = '', i, l, t, st, r, cn, va = false, f = false, at, hc, cr ;4746 var en, no, h = '', i, l, t, st, r, cn, va = false, f = false, at, hc, cr, nn; 4653 4747 4654 4748 this._setupRules(); // Will initialize cleanup rules 4655 4749 4656 if (t his._isDuplicate(n))4750 if (tinyMCE.isRealIE && this._isDuplicate(n)) 4657 4751 return ''; 4658 4752 … … 4678 4772 break; 4679 4773 4680 if (this.vElementsRe.test(n.nodeName) && (!this.iveRe || !this.iveRe.test(n.nodeName)) && !inn) { 4774 nn = n.nodeName; 4775 4776 // Convert fonts to spans 4777 if (this.settings.convert_fonts_to_spans) { 4778 // On get content FONT -> SPAN 4779 if (this.settings.on_save && nn == 'FONT') 4780 nn = 'SPAN'; 4781 4782 // On insert content SPAN -> FONT 4783 if (!this.settings.on_save && nn == 'SPAN') 4784 nn = 'FONT'; 4785 } 4786 4787 if (this.vElementsRe.test(nn) && (!this.iveRe || !this.iveRe.test(nn)) && !inn) { 4681 4788 va = true; 4682 4789 4683 r = this.rules[n .nodeName];4790 r = this.rules[nn]; 4684 4791 if (!r) { 4685 4792 at = this.rules; 4686 4793 for (no in at) { 4687 if (at[no] && at[no].validRe.test(n .nodeName)) {4794 if (at[no] && at[no].validRe.test(nn)) { 4688 4795 r = at[no]; 4689 4796 break; … … 4692 4799 } 4693 4800 4694 en = r.isWild ? n .nodeName.toLowerCase() : r.oTagName;4801 en = r.isWild ? nn.toLowerCase() : r.oTagName; 4695 4802 f = r.fill; 4696 4803 … … 4729 4836 4730 4837 // Close these 4731 if (t != null && this.closeElementsRe.test(n .nodeName))4838 if (t != null && this.closeElementsRe.test(nn)) 4732 4839 return t + ' />'; 4733 4840 … … 4735 4842 h += t + '>'; 4736 4843 4737 if (this.isIE && this.codeElementsRe.test(n .nodeName))4844 if (this.isIE && this.codeElementsRe.test(nn)) 4738 4845 h += n.innerHTML; 4739 4846 } … … 4796 4903 av = t; 4797 4904 4798 if (os && av.length != 0 && this.settings.url_converter.length != 0 &&/^(src|href|longdesc)$/.test(an))4799 av = eval(this.settings.url_converter + '(this, n, av)');4905 if (os && av.length != 0 && /^(src|href|longdesc)$/.test(an)) 4906 av = this._urlConverter(this, n, av); 4800 4907 4801 4908 if (av.length != 0 && r.validAttribValues && r.validAttribValues[an] && !r.validAttribValues[an].test(av)) … … 4807 4914 if (av.length != 0) { 4808 4915 if (an.indexOf('on') != 0) 4809 av = this.xmlEncode(av );4916 av = this.xmlEncode(av, 1); 4810 4917 4811 4918 return " " + an + "=" + '"' + av + '"'; … … 4853 4960 }, 4854 4961 4855 xmlEncode : function(s ) {4856 var cl = this ;4962 xmlEncode : function(s, skip_apos) { 4963 var cl = this, re = !skip_apos ? this.xmlEncodeAposRe : this.xmlEncodeRe; 4857 4964 4858 4965 this._setupEntities(); // Will intialize lookup table … … 4860 4967 switch (this.settings.entity_encoding) { 4861 4968 case "raw": 4862 return tinyMCE.xmlEncode(s );4969 return tinyMCE.xmlEncode(s, skip_apos); 4863 4970 4864 4971 case "named": 4865 return s.replace( new RegExp('[\u007F-\uFFFF<>&"\']', 'g'), function (c, b) {4972 return s.replace(re, function (c, b) { 4866 4973 b = cl.entities[c.charCodeAt(0)]; 4867 4974 … … 4870 4977 4871 4978 case "numeric": 4872 return s.replace( new RegExp('[\u007F-\uFFFF<>&"\']', 'g'), function (c, b) {4979 return s.replace(re, function (c, b) { 4873 4980 return b ? '&#' + c.charCodeAt(0) + ';' : c; 4874 4981 }); … … 4899 5006 4900 5007 _getAttrib : function(e, n, d) { 5008 var v, ex, nn; 5009 4901 5010 if (typeof(d) == "undefined") 4902 5011 d = ""; … … 4905 5014 return d; 4906 5015 4907 var v = e.getAttribute(n, 0); 5016 try { 5017 v = e.getAttribute(n, 0); 5018 } catch (ex) { 5019 // IE 7 may cast exception on invalid attributes 5020 v = e.getAttribute(n, 2); 5021 } 4908 5022 4909 5023 if (n == "class" && !v) 4910 5024 v = e.className; 4911 5025 4912 if (this.isIE && n == "http-equiv") 4913 v = e.httpEquiv; 4914 4915 if (this.isIE && e.nodeName == "FORM" && n == "enctype" && v == "application/x-www-form-urlencoded") 4916 v = ""; 4917 4918 if (this.isIE && e.nodeName == "INPUT" && n == "size" && v == "20") 4919 v = ""; 4920 4921 if (this.isIE && e.nodeName == "INPUT" && n == "maxlength" && v == "2147483647") 4922 v = ""; 4923 4924 if (n == "style" && !tinyMCE.isOpera) 4925 v = e.style.cssText; 4926 4927 if (n == 'style') 5026 if (this.isIE) { 5027 if (n == "http-equiv") 5028 v = e.httpEquiv; 5029 5030 nn = e.nodeName; 5031 5032 // Skip the default values that IE returns 5033 if (nn == "FORM" && n == "enctype" && v == "application/x-www-form-urlencoded") 5034 v = ""; 5035 5036 if (nn == "INPUT" && n == "size" && v == "20") 5037 v = ""; 5038 5039 if (nn == "INPUT" && n == "maxlength" && v == "2147483647") 5040 v = ""; 5041 } 5042 5043 if (n == 'style' && v) { 5044 if (!tinyMCE.isOpera) 5045 v = e.style.cssText; 5046 4928 5047 v = tinyMCE.serializeStyle(tinyMCE.parseStyle(v)); 5048 } 4929 5049 4930 5050 if (this.settings.on_save && n.indexOf('on') != -1 && this.settings.on_save && v && v != "") … … 4937 5057 if (!c.settings.on_save) 4938 5058 return tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, v); 4939 else if (tinyMCE.getParam('convert_urls')) 4940 return eval(tinyMCE.settings.urlconverter_callback + "(v, n, true);"); 5059 else if (tinyMCE.getParam('convert_urls')) { 5060 if (!this.urlConverter) 5061 this.urlConverter = eval(tinyMCE.settings.urlconverter_callback); 5062 5063 return this.urlConverter(v, n, true); 5064 } 4941 5065 4942 5066 return v; … … 5100 5224 // Convert all strong/em to b/i in Gecko 5101 5225 if (tinyMCE.isGecko) { 5102 h = h.replace(/<strong/gi, '<b'); 5103 h = h.replace(/<em(\/?)/gi, '<i'); 5104 h = h.replace(/<em /gi, '<i'); 5226 h = h.replace(/<embed([^>]*)>/gi, '<tmpembed$1>'); 5227 h = h.replace(/<em([^>]*)>/gi, '<i$1>'); 5228 h = h.replace(/<tmpembed([^>]*)>/gi, '<embed$1>'); 5229 h = h.replace(/<strong([^>]*)>/gi, '<b$1>'); 5105 5230 h = h.replace(/<\/strong>/gi, '</b>'); 5106 5231 h = h.replace(/<\/em>/gi, '</i>'); … … 5226 5351 return dv; 5227 5352 5228 v = elm.getAttribute(name); 5353 try { 5354 v = elm.getAttribute(name, 0); 5355 } catch (ex) { 5356 // IE 7 may cast exception on invalid attributes 5357 v = elm.getAttribute(name, 2); 5358 } 5229 5359 5230 5360 // Try className for class attrib … … 5410 5540 height : w.innerHeight || (m ? de.clientHeight : b.clientHeight) 5411 5541 }; 5542 }; 5543 5544 TinyMCE_Engine.prototype.getStyle = function(n, na, d) { 5545 if (!n) 5546 return false; 5547 5548 // Gecko 5549 if (tinyMCE.isGecko && n.ownerDocument.defaultView) { 5550 try { 5551 return n.ownerDocument.defaultView.getComputedStyle(n, null).getPropertyValue(na); 5552 } catch (n) { 5553 // Old safari might fail 5554 return null; 5555 } 5556 } 5557 5558 // Camelcase it, if needed 5559 na = na.replace(/-(\D)/g, function(a, b){ 5560 return b.toUpperCase(); 5561 }); 5562 5563 // IE & Opera 5564 if (n.currentStyle) 5565 return n.currentStyle[na]; 5566 5567 return false; 5412 5568 }; 5413 5569 … … 5877 6033 f(doc, ot[i], tinyMCE.handleEvent); 5878 6034 5879 eval('try { doc.designMode = "On"; } catch(e) {}'); // Force designmode 6035 // Force designmode 6036 try { 6037 doc.designMode = "On"; 6038 } catch (e) { 6039 // Ignore 6040 } 5880 6041 } 5881 6042 }; … … 6048 6209 6049 6210 // When editing always use fonts internaly 6050 if (tinyMCE.getParam("convert_fonts_to_spans"))6051 tinyMCE.convertSpansToFonts(inst.getDoc());6211 //if (tinyMCE.getParam("convert_fonts_to_spans")) 6212 // tinyMCE.convertSpansToFonts(inst.getDoc()); 6052 6213 6053 6214 return h; … … 6252 6413 6253 6414 if (tinyMCE.isGecko || tinyMCE.isOpera) { 6415 if (!sel) 6416 return false; 6417 6254 6418 if (bookmark.rng) { 6255 6419 sel.removeAllRanges(); … … 6463 6627 return '' + window.getSelection(); 6464 6628 6465 return s.getRangeAt(0); 6629 if (s.rangeCount > 0) 6630 return s.getRangeAt(0); 6631 6632 return null; 6633 }, 6634 6635 isCollapsed : function() { 6636 var r = this.getRng(); 6637 6638 if (r.item) 6639 return false; 6640 6641 return r.boundingWidth == 0 || this.getSel().isCollapsed; 6642 }, 6643 6644 collapse : function(b) { 6645 var r = this.getRng(), s = this.getSel(); 6646 6647 if (r.select) { 6648 r.collapse(b); 6649 r.select(); 6650 } else { 6651 if (b) 6652 s.collapseToStart(); 6653 else 6654 s.collapseToEnd(); 6655 } 6466 6656 }, 6467 6657 … … 7007 7197 7008 7198 show : function() { 7009 this.getElement().style.display = 'block'; 7010 this.updateBlocker(); 7199 var el = this.getElement(); 7200 7201 if (el) { 7202 el.style.display = 'block'; 7203 this.updateBlocker(); 7204 } 7011 7205 }, 7012 7206 7013 7207 hide : function() { 7014 this.getElement().style.display = 'none'; 7015 this.updateBlocker(); 7208 var el = this.getElement(); 7209 7210 if (el) { 7211 el.style.display = 'none'; 7212 this.updateBlocker(); 7213 } 7016 7214 }, 7017 7215 … … 7118 7316 7119 7317 return parseInt(s); 7318 }, 7319 7320 remove : function() { 7321 var e = this.getElement(), b = this.getBlocker(); 7322 7323 if (e) 7324 e.parentNode.removeChild(e); 7325 7326 if (b) 7327 b.parentNode.removeChild(b); 7120 7328 } 7121 7329 … … 7209 7417 7210 7418 default: 7211 h += '<tr><td><a href=" #" onclick="return tinyMCE.cancelEvent(event);" onmousedown="return tinyMCE.cancelEvent(event);" onmouseup="' + tinyMCE.xmlEncode(m[i].js) + ';return tinyMCE.cancelEvent(event);"><span' + c +'>' + t + '</span></a>';7419 h += '<tr><td><a href="' + tinyMCE.xmlEncode(m[i].js) + '" onmousedown="' + tinyMCE.xmlEncode(m[i].js) + ';return tinyMCE.cancelEvent(event);" onclick="return tinyMCE.cancelEvent(event);" onmouseup="return tinyMCE.cancelEvent(event);"><span' + c +'>' + t + '</span></a>'; 7212 7420 } 7213 7421 -
tags/2.2/wp-includes/js/tinymce/tiny_mce_config.php
r5468 r5480 41 41 $mce_browsers = apply_filters('mce_browsers', array('msie', 'gecko', 'opera', 'safari')); 42 42 $mce_browsers = implode($mce_browsers, ','); 43 43 44 44 $mce_popups_css = get_option('siteurl') . '/wp-includes/js/tinymce/plugins/wordpress/popups.css'; 45 45 $mce_css = get_option('siteurl') . '/wp-includes/js/tinymce/plugins/wordpress/wordpress.css'; … … 49 49 $mce_popups_css = str_replace('http://', 'https://', $mce_popups_css); 50 50 } 51 52 $mce_locale = ( '' == get_locale() ) ? 'en' : strtolower(get_locale()); 51 53 ?> 52 54 … … 59 61 theme_advanced_buttons2 : "<?php echo $mce_buttons_2; ?>", 60 62 theme_advanced_buttons3 : "<?php echo $mce_buttons_3; ?>", 61 language : "<?php echo strtolower(get_locale()); ?>",63 language : "<?php echo $mce_locale; ?>", 62 64 theme_advanced_toolbar_location : "top", 63 65 theme_advanced_toolbar_align : "left", … … 77 79 gecko_spellcheck : true, 78 80 entities : "38,amp,60,lt,62,gt", 81 button_tile_map : true, 79 82 content_css : "<?php echo $mce_css; ?>", 80 83 valid_elements : "<?php echo $valid_elements; ?>", -
tags/2.2/wp-includes/js/tinymce/tiny_mce_gzip.php
r5468 r5480 1 1 <?php 2 2 /** 3 * $RCSfile: tiny_mce_gzip.php,v $ 4 * $Revision: $ 5 * $Date: $ 3 * $Id: tiny_mce_gzip.php 158 2006-12-21 14:32:19Z spocke $ 6 4 * 7 * @version 1.088 5 * @author Moxiecode 9 6 * @copyright Copyright 2005-2006, Moxiecode Systems AB, All rights reserved. … … 14 11 */ 15 12 16 @require_once('../../../wp-config.php'); 17 18 // gzip_compression(); 19 20 function wp_tinymce_lang($path) { 21 global $language; 22 23 $text = ''; 24 25 // Look for xx_YY.js, xx_yy.js, xx.js 26 $file = realpath(sprintf($path, $language)); 27 if ( file_exists($file) ) 28 $text = file_get_contents($file); 29 $file = realpath(sprintf($path, strtolower($language))); 30 if ( file_exists($file) ) 31 $text = file_get_contents($file); 32 $file = realpath(sprintf($path, substr($language, 0, 2))); 33 if ( file_exists($file) ) 34 $text = file_get_contents($file); 35 36 37 // Fall back on en.js 38 $file = realpath(sprintf($path, 'en')); 39 if ( empty($text) && file_exists($file) ) 40 $text = file_get_contents($file); 41 42 // Send lang file through gettext 43 if ( function_exists('__') && strtolower(substr($language, 0, 2)) != 'en' ) { 44 $search1 = "/^tinyMCELang\\[(['\"])(.*)\\1\]( ?= ?)(['\"])(.*)\\4/Uem"; 45 $replace1 = "'tinyMCELang[\\1\\2\\1]\\3'.stripslashes('\\4').__('\\5').stripslashes('\\4')"; 46 47 $search2 = "/\\s:\\s(['\"])(.*)\\1(,|\\s*})/Uem"; 48 $replace2 = "' : '.stripslashes('\\1').__('\\2').stripslashes('\\1').'\\3'"; 49 50 $search = array($search1, $search2); 51 $replace = array($replace1, $replace2); 52 53 $text = preg_replace($search, $replace, $text); 54 55 return $text; 56 } 57 58 return $text; 59 } 60 61 function wp_compact_tinymce_js($text) { 62 // This function was custom-made for TinyMCE 2.0, not expected to work with any other JS. 63 64 // Strip comments 65 $text = preg_replace("!(^|\s+)//.*$!m", '', $text); 66 $text = preg_replace("!/\*.*?\*/!s", '', $text); 67 68 // Strip leading tabs, carriage returns and unnecessary line breaks. 69 $text = preg_replace("!^\t+!m", '', $text); 70 $text = str_replace("\r", '', $text); 71 $text = preg_replace("!(^|{|}|;|:|\))\n!m", '\\1', $text); 72 73 return "$text\n"; 74 } 75 76 77 // General options 78 $suffix = ""; // Set to "_src" to use source version 79 $expiresOffset = 3600 * 24 * 10; // 10 days util client cache expires 80 $diskCache = false; // If you enable this option gzip files will be cached on disk. 81 $cacheDir = realpath("."); // Absolute directory path to where cached gz files will be stored 82 $debug = false; // Enable this option if you need debuging info 83 84 // Headers 85 header("Content-Type: text/javascript; charset=" . get_bloginfo('charset')); 86 // header("Cache-Control: must-revalidate"); 87 header("Vary: Accept-Encoding"); // Handle proxies 88 header("Expires: " . gmdate("D, d M Y H:i:s", time() + $expiresOffset) . " GMT"); 89 90 // Get data to load 91 $theme = isset($_GET['theme']) ? TinyMCE_cleanInput($_GET['theme']) : ""; 92 $language = isset($_GET['language']) ? TinyMCE_cleanInput($_GET['language']) : ""; 93 $plugins = isset($_GET['plugins']) ? TinyMCE_cleanInput($_GET['plugins']) : ""; 94 $lang = isset($_GET['lang']) ? TinyMCE_cleanInput($_GET['lang']) : "en"; 95 $index = isset($_GET['index']) ? TinyMCE_cleanInput($_GET['index']) : -1; 96 $cacheKey = md5($theme . $language . $plugins . $lang . $index . $debug); 97 $cacheFile = $cacheDir == "" ? "" : $cacheDir . "/" . "tinymce_" . $cacheKey . ".gz"; 98 $cacheData = ""; 99 100 // Patch older versions of PHP < 4.3.0 101 if (!function_exists('file_get_contents')) { 102 function file_get_contents($filename) { 103 $fd = fopen($filename, 'rb'); 104 $content = fread($fd, filesize($filename)); 105 fclose($fd); 106 return $content; 107 } 108 } 109 110 // Security check function, can only contain a-z 0-9 , _ - and whitespace. 111 function TinyMCE_cleanInput($str) { 112 return preg_replace("/[^0-9a-z\-_,]+/i", "", $str); // Remove anything but 0-9,a-z,-_ 113 } 114 115 function TinyMCE_echo($str) { 116 global $cacheData, $diskCache; 117 118 if ($diskCache) 119 $cacheData .= $str; 120 else 121 echo $str; 122 } 123 124 // Only gzip the contents if clients and server support it 125 $encodings = array(); 126 127 if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) 128 $encodings = explode(',', strtolower(preg_replace("/\s+/", "", $_SERVER['HTTP_ACCEPT_ENCODING']))); 129 130 // Check for gzip header or northon internet securities 131 if ((in_array('gzip', $encodings) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------'])) && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression')) { 132 $enc = in_array('x-gzip', $encodings) ? "x-gzip" : "gzip"; 133 134 // Use cached file if it exists but not in debug mode 135 if (file_exists($cacheFile) && !$debug) { 136 header("Content-Encoding: " . $enc); 137 echo file_get_contents($cacheFile); 138 die; 139 } 140 141 if (!$diskCache) 142 ob_start("ob_gzhandler"); 143 } else 13 @require_once('../../../wp-config.php'); // For get_bloginfo(). 14 15 // Get input 16 $plugins = explode(',', getParam("plugins", "")); 17 $languages = explode(',', getParam("languages", "")); 18 $themes = explode(',', getParam("themes", "")); 19 $diskCache = getParam("diskcache", "") == "true"; 20 $isJS = getParam("js", "") == "true"; 21 $compress = getParam("compress", "true") == "true"; 22 $suffix = getParam("suffix", "_src") == "_src" ? "_src" : ""; 23 $cachePath = realpath("."); // Cache path, this is where the .gz files will be stored 24 $expiresOffset = 3600 * 24 * 10; // Cache for 10 days in browser cache 25 $content = ""; 26 $encodings = array(); 27 $supportsGzip = false; 28 $enc = ""; 29 $cacheKey = ""; 30 31 // Custom extra javascripts to pack 32 $custom = array(/* 33 "some custom .js file", 34 "some custom .js file" 35 */); 36 37 // WP 38 $index = getParam("index", -1); 39 $theme = getParam("theme", ""); 40 $themes = array($theme); 41 $language = getParam("language", "en"); 42 if ( empty($language) ) 43 $language = 'en'; 44 $languages = array($language); 45 if ( $language != strtolower($language) ) 46 $languages[] = strtolower($language); 47 if ( $language != substr($language, 0, 2) ) 48 $languages[] = substr($language, 0, 2); 144 49 $diskCache = false; 50 $isJS = true; 51 $suffix = ''; 52 53 // Headers 54 header("Content-Type: text/javascript; charset=" . get_bloginfo('charset')); 55 header("Vary: Accept-Encoding"); // Handle proxies 56 header("Expires: " . gmdate("D, d M Y H:i:s", time() + $expiresOffset) . " GMT"); 57 58 // Is called directly then auto init with default settings 59 if (!$isJS) { 60 echo getFileContents("tiny_mce_gzip.js"); 61 echo "tinyMCE_GZ.init({});"; 62 die(); 63 } 64 65 // Setup cache info 66 if ($diskCache) { 67 if (!$cachePath) 68 die("alert('Real path failed.');"); 69 70 $cacheKey = getParam("plugins", "") . getParam("languages", "") . getParam("themes", ""); 71 72 foreach ($custom as $file) 73 $cacheKey .= $file; 74 75 $cacheKey = md5($cacheKey); 76 77 if ($compress) 78 $cacheFile = $cachePath . "/tiny_mce_" . $cacheKey . ".gz"; 79 else 80 $cacheFile = $cachePath . "/tiny_mce_" . $cacheKey . ".js"; 81 } 82 83 // Check if it supports gzip 84 if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) 85 $encodings = explode(',', strtolower(preg_replace("/\s+/", "", $_SERVER['HTTP_ACCEPT_ENCODING']))); 86 87 if ((in_array('gzip', $encodings) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------'])) && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression') && ini_get('output_handler') != 'ob_gzhandler') { 88 $enc = in_array('x-gzip', $encodings) ? "x-gzip" : "gzip"; 89 $supportsGzip = true; 90 } 91 92 // Use cached file disk cache 93 if ($diskCache && $supportsGzip && file_exists($cacheFile)) { 94 if ($compress) 95 header("Content-Encoding: " . $enc); 96 97 echo getFileContents($cacheFile); 98 die(); 99 } 145 100 146 101 if ($index > -1) { 147 102 // Write main script and patch some things 148 if ($index == 0) { 149 TinyMCE_echo(wp_compact_tinymce_js(file_get_contents(realpath("tiny_mce" . $suffix . ".js")))); // WP 150 TinyMCE_echo('TinyMCE.prototype.orgLoadScript = TinyMCE.prototype.loadScript;'); 151 TinyMCE_echo('TinyMCE.prototype.loadScript = function() {};var realTinyMCE = tinyMCE;'); 103 if ( $index == 0 ) { 104 // Add core 105 $content .= wp_compact_tinymce_js(getFileContents("tiny_mce" . $suffix . ".js")); 106 $content .= 'TinyMCE.prototype.orgLoadScript = TinyMCE.prototype.loadScript;'; 107 $content .= 'TinyMCE.prototype.loadScript = function() {};var realTinyMCE = tinyMCE;'; 152 108 } else 153 TinyMCE_echo('tinyMCE = realTinyMCE;'); 154 109 $content .= 'tinyMCE = realTinyMCE;'; 110 111 // Patch loading functions 112 //$content .= "tinyMCE_GZ.start();"; 113 155 114 // Do init based on index 156 TinyMCE_echo("tinyMCE.init(tinyMCECompressed.configs[" . $index . "]);");115 $content .= "tinyMCE.init(tinyMCECompressed.configs[" . $index . "]);"; 157 116 158 117 // Load external plugins 159 if ($index == 0) 160 TinyMCE_echo("tinyMCECompressed.loadPlugins();"); 161 162 // Load theme, language pack and theme language packs 163 if ($theme) { 164 TinyMCE_echo(wp_compact_tinymce_js(file_get_contents(realpath("themes/" . $theme . "/editor_template" . $suffix . ".js")))); // WP 165 TinyMCE_echo(wp_tinymce_lang("themes/" . $theme . "/langs/%s.js")); // WP 166 } 167 168 /* WP if ($language) WP */ 169 TinyMCE_echo(wp_tinymce_lang("langs/%s.js")); // WP 170 171 // Load all plugins and their language packs 172 $plugins = explode(",", $plugins); 118 if ( $index == 0 ) 119 $content .= "tinyMCECompressed.loadPlugins();"; 120 121 // Add core languages 122 $lang_content = ''; 123 foreach ($languages as $lang) 124 $lang_content .= getFileContents("langs/" . $lang . ".js"); 125 if ( empty($lang_content) ) 126 $lang_content .= getFileContents("langs/en.js"); 127 $content .= $lang_content; 128 129 // Add themes 130 foreach ($themes as $theme) { 131 $content .= wp_compact_tinymce_js(getFileContents( "themes/" . $theme . "/editor_template" . $suffix . ".js")); 132 133 $lang_content = ''; 134 foreach ($languages as $lang) 135 $lang_content .= getFileContents("themes/" . $theme . "/langs/" . $lang . ".js"); 136 if ( empty($lang_content) ) 137 $lang_content .= getFileContents("themes/" . $theme . "/langs/en.js"); 138 $content .= $lang_content; 139 } 140 141 // Add plugins 173 142 foreach ($plugins as $plugin) { 174 $pluginFile = realpath("plugins/" . $plugin . "/editor_plugin" . $suffix . ".js"); 175 /* WP $languageFile = realpath("plugins/" . $plugin . "/langs/" . $lang . ".js"); WP */ 176 177 if ($pluginFile) 178 TinyMCE_echo(file_get_contents($pluginFile)); 179 180 /* WP if ($languageFile) WP */ 181 TinyMCE_echo(wp_tinymce_lang("plugins/" . $plugin . "/langs/%s.js")); // WP 182 } 143 $content .= getFileContents("plugins/" . $plugin . "/editor_plugin" . $suffix . ".js"); 144 145 $lang_content = ''; 146 foreach ($languages as $lang) 147 $lang_content .= getFileContents("plugins/" . $plugin . "/langs/" . $lang . ".js"); 148 if ( empty($lang_content) ) 149 $lang_content .= getFileContents("plugins/" . $plugin . "/langs/en.js"); 150 $content .= $lang_content; 151 } 152 153 // Add custom files 154 foreach ($custom as $file) 155 $content .= getFileContents($file); 183 156 184 157 // Reset tinyMCE compressor engine 185 TinyMCE_echo("tinyMCE = tinyMCECompressed;"); 186 187 // Write to cache 188 if ($diskCache) { 189 // Calculate compression ratio and debug target output path 190 if ($debug) { 191 $ratio = round(100 - strlen(gzencode($cacheData, 9, FORCE_GZIP)) / strlen($cacheData) * 100.0); 192 TinyMCE_echo("alert('TinyMCE was compressed by " . $ratio . "%.\\nOutput cache file: " . $cacheFile . "');"); 193 } 194 195 $cacheData = gzencode($cacheData, 9, FORCE_GZIP); 196 197 // Write to file if possible 198 $fp = @fopen($cacheFile, "wb"); 158 $content .= "tinyMCE = tinyMCECompressed;"; 159 160 // Restore loading functions 161 //$content .= "tinyMCE_GZ.end();"; 162 163 // Generate GZIP'd content 164 if ($supportsGzip) { 165 if ($compress) { 166 header("Content-Encoding: " . $enc); 167 $cacheData = gzencode($content, 9, FORCE_GZIP); 168 } else 169 $cacheData = $content; 170 171 // Write gz file 172 if ($diskCache && $cacheKey != "") 173 putFileContents($cacheFile, $cacheData); 174 175 // Stream to client 176 echo $cacheData; 177 } else { 178 // Stream uncompressed content 179 echo $content; 180 } 181 182 die; 183 } 184 185 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 186 187 function getParam($name, $def = false) { 188 if (!isset($_GET[$name])) 189 return $def; 190 191 return preg_replace("/[^0-9a-z\-_,]+/i", "", $_GET[$name]); // Remove anything but 0-9,a-z,-_ 192 } 193 194 function getFileContents($path) { 195 $path = realpath($path); 196 197 if (!$path || !@is_file($path)) 198 return ""; 199 200 if (function_exists("file_get_contents")) 201 return @file_get_contents($path); 202 203 $content = ""; 204 $fp = @fopen($path, "r"); 205 if (!$fp) 206 return ""; 207 208 while (!feof($fp)) 209 $content .= fgets($fp); 210 211 fclose($fp); 212 213 return $content; 214 } 215 216 function putFileContents($path, $content) { 217 if (function_exists("file_put_contents")) 218 return @file_put_contents($path, $content); 219 220 $fp = @fopen($path, "wb"); 199 221 if ($fp) { 200 fwrite($fp, $c acheData);222 fwrite($fp, $content); 201 223 fclose($fp); 202 224 } 203 204 // Output 205 header("Content-Encoding: " . $enc); 206 echo $cacheData; 207 } 208 209 die; 210 } 225 } 226 227 // WP specific 228 function wp_compact_tinymce_js($text) { 229 // This function was custom-made for TinyMCE 2.0, not expected to work with any other JS. 230 231 // Strip comments 232 $text = preg_replace("!(^|\s+)//.*$!m", '', $text); 233 $text = preg_replace("!/\*.*?\*/!s", '', $text); 234 235 // Strip leading tabs, carriage returns and unnecessary line breaks. 236 $text = preg_replace("!^\t+!m", '', $text); 237 $text = str_replace("\r", '', $text); 238 $text = preg_replace("!(^|{|}|;|:|\))\n!m", '\\1', $text); 239 240 return "$text\n"; 241 } 211 242 ?> 212 243 -
tags/2.2/wp-includes/js/tinymce/utils/form_utils.js
r5468 r5480 1 1 /** 2 * $Id: form_utils.js 43 2006-08-08 16:10:07Z spocke $2 * $Id: form_utils.js 162 2007-01-03 16:16:52Z spocke $ 3 3 * 4 4 * Various form utilitiy functions. 5 5 * 6 6 * @author Moxiecode 7 * @copyright Copyright © 2004-200 6, Moxiecode Systems AB, All rights reserved.7 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. 8 8 */ 9 9 -
tags/2.2/wp-includes/js/tinymce/utils/mclayer.js
r5468 r5480 1 1 /** 2 * $Id: mclayer.js 1 8 2006-06-29 14:11:23Z spocke $2 * $Id: mclayer.js 162 2007-01-03 16:16:52Z spocke $ 3 3 * 4 4 * Moxiecode floating layer script. 5 5 * 6 6 * @author Moxiecode 7 * @copyright Copyright © 2004-200 6, Moxiecode Systems AB, All rights reserved.7 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. 8 8 */ 9 9 -
tags/2.2/wp-includes/js/tinymce/utils/mctabs.js
r5468 r5480 1 1 /** 2 * $Id: mctabs.js 1 8 2006-06-29 14:11:23Z spocke $2 * $Id: mctabs.js 162 2007-01-03 16:16:52Z spocke $ 3 3 * 4 4 * Moxiecode DHTML Tabs script. 5 5 * 6 6 * @author Moxiecode 7 * @copyright Copyright © 2004-200 6, Moxiecode Systems AB, All rights reserved.7 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. 8 8 */ 9 9 -
tags/2.2/wp-includes/js/tinymce/utils/validate.js
r5468 r5480 1 1 /** 2 * $Id: validate.js 65 2006-08-24 15:54:55Z spocke $2 * $Id: validate.js 162 2007-01-03 16:16:52Z spocke $ 3 3 * 4 4 * Various form validation methods. 5 5 * 6 6 * @author Moxiecode 7 * @copyright Copyright © 2004-200 6, Moxiecode Systems AB, All rights reserved.7 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. 8 8 */ 9 9 -
tags/2.2/wp-includes/js/tinymce/wp-mce-help.php
r5468 r5480 167 167 <div id="content4" class="hidden"> 168 168 <h2><?php _e('About TinyMCE'); ?></h2> 169 <p><?php printf(__('Version: %s'), '2.0. 8') ?></p>170 <p><?php printf(__('TinyMCE is a platform independent web based Javascript HTML WYSIWYG editor control released as Open Source under %sLGPL</a> by Moxiecode Systems AB. It has the ability to convert HTML TEXTAREA fields or other HTML elements to editor instances.'), '<a href="'.get_bloginfo(' home').'/wp-includes/js/tinymce/license.txt" target="_blank" title="'.__('GNU Library General Public Licence').'">') ?></p>169 <p><?php printf(__('Version: %s'), '2.0.9') ?></p> 170 <p><?php printf(__('TinyMCE is a platform independent web based Javascript HTML WYSIWYG editor control released as Open Source under %sLGPL</a> by Moxiecode Systems AB. It has the ability to convert HTML TEXTAREA fields or other HTML elements to editor instances.'), '<a href="'.get_bloginfo('url').'/wp-includes/js/tinymce/license.txt" target="_blank" title="'.__('GNU Library General Public Licence').'">') ?></p> 171 171 <p><?php _e('Copyright © 2005, <a href="http://www.moxiecode.com" target="_blank">Moxiecode Systems AB</a>, All rights reserved.') ?></p> 172 172 <p><?php _e('For more information about this software visit the <a href="http://tinymce.moxiecode.com" target="_blank">TinyMCE website</a>.') ?></p> -
tags/2.2/wp-includes/l10n.php
r5468 r5480 18 18 } 19 19 20 // Return a translated string. 21 function __($text, $domain = 'default') { 20 function translate($text, $domain) { 22 21 global $l10n; 23 22 … … 28 27 } 29 28 29 // Return a translated string. 30 function __($text, $domain = 'default') { 31 return translate($text, $domain); 32 } 33 30 34 // Echo a translated string. 31 35 function _e($text, $domain = 'default') { 32 global $l10n; 36 echo translate($text, $domain); 37 } 33 38 34 if (isset($l10n[$domain])) 35 echo apply_filters('gettext', $l10n[$domain]->translate($text), $text); 36 else 37 echo $text; 39 function _c($text, $domain = 'default') { 40 $whole = translate($text, $domain); 41 $last_bar = strrpos($whole, '|'); 42 if ( false == $last_bar ) { 43 return $whole; 44 } else { 45 return substr($whole, 0, $last_bar); 46 } 38 47 } 39 48 … … 43 52 44 53 if (isset($l10n[$domain])) { 45 return $l10n[$domain]->ngettext($single, $plural, $number);54 return apply_filters('ngettext', $l10n[$domain]->ngettext($single, $plural, $number), $single, $plural, $number); 46 55 } else { 47 56 if ($number != 1) -
tags/2.2/wp-includes/link-template.php
r5468 r5480 9 9 function permalink_link() { // For backwards compatibility 10 10 echo apply_filters('the_permalink', get_permalink()); 11 } 12 13 14 /** 15 * Conditionally adds a trailing slash if the permalink structure 16 * has a trailing slash, strips the trailing slash if not 17 * @global object Uses $wp_rewrite 18 * @param $string string a URL with or without a trailing slash 19 * @param $type_of_url string the type of URL being considered (e.g. single, category, etc) for use in the filter 20 * @return string 21 */ 22 function user_trailingslashit($string, $type_of_url = '') { 23 global $wp_rewrite; 24 if ( $wp_rewrite->use_trailing_slashes ) 25 $string = trailingslashit($string); 26 else 27 $string = untrailingslashit($string); 28 29 // Note that $type_of_url can be one of following: 30 // single, single_trackback, single_feed, single_paged, feed, category, page, year, month, day, paged 31 $string = apply_filters('user_trailingslashit', $string, $type_of_url); 32 return $string; 11 33 } 12 34 … … 54 76 55 77 $category = ''; 56 if ( strstr($permalink, '%category%')) {78 if (strpos($permalink, '%category%') !== false) { 57 79 $cats = get_the_category($post->ID); 58 80 $category = $cats[0]->category_nicename; … … 78 100 $post->post_name, 79 101 ); 80 return apply_filters('post_link', get_option('home') . str_replace($rewritecode, $rewritereplace, $permalink), $post); 102 $permalink = get_option('home') . str_replace($rewritecode, $rewritereplace, $permalink); 103 $permalink = user_trailingslashit($permalink, 'single'); 104 return apply_filters('post_link', $permalink, $post); 81 105 } else { // if they're not using the fancy permalink option 82 106 $permalink = get_option('home') . '/?p=' . $post->ID; … … 118 142 $link = get_page_uri($id); 119 143 $link = str_replace('%pagename%', $link, $pagestruct); 120 $link = get_option('home') . "/$link/"; 144 $link = get_option('home') . "/$link"; 145 $link = user_trailingslashit($link, 'page'); 121 146 } else { 122 147 $link = get_option('home') . "/?page_id=$id"; … … 142 167 else 143 168 $parentlink = get_permalink( $object->post_parent ); 144 if ( ! strstr($parentlink, '?'))169 if (strpos($parentlink, '?') === false) 145 170 $link = trim($parentlink, '/') . '/' . $object->post_name . '/'; 146 171 } 147 172 148 173 if (! $link ) { 149 $link = get_bloginfo(' home') . "/?attachment_id=$id";174 $link = get_bloginfo('url') . "/?attachment_id=$id"; 150 175 } 151 176 … … 160 185 if ( !empty($yearlink) ) { 161 186 $yearlink = str_replace('%year%', $year, $yearlink); 162 return apply_filters('year_link', get_option('home') . trailingslashit($yearlink), $year);187 return apply_filters('year_link', get_option('home') . user_trailingslashit($yearlink, 'year'), $year); 163 188 } else { 164 189 return apply_filters('year_link', get_option('home') . '/?m=' . $year, $year); … … 176 201 $monthlink = str_replace('%year%', $year, $monthlink); 177 202 $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink); 178 return apply_filters('month_link', get_option('home') . trailingslashit($monthlink), $year, $month);203 return apply_filters('month_link', get_option('home') . user_trailingslashit($monthlink, 'month'), $year, $month); 179 204 } else { 180 205 return apply_filters('month_link', get_option('home') . '/?m=' . $year . zeroise($month, 2), $year, $month); … … 196 221 $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink); 197 222 $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink); 198 return apply_filters('day_link', get_option('home') . trailingslashit($daylink), $year, $month, $day);223 return apply_filters('day_link', get_option('home') . user_trailingslashit($daylink, 'day'), $year, $month, $day); 199 224 } else { 200 225 return apply_filters('day_link', get_option('home') . '/?m=' . $year . zeroise($month, 2) . zeroise($day, 2), $year, $month, $day); … … 219 244 220 245 $permalink = str_replace('%feed%', $feed, $permalink); 221 $permalink = preg_replace('#/+#', '/', "/$permalink /");222 $output = get_option('home') . $permalink;246 $permalink = preg_replace('#/+#', '/', "/$permalink"); 247 $output = get_option('home') . user_trailingslashit($permalink, 'feed'); 223 248 } else { 224 249 if ( false !== strpos($feed, 'comments_') ) … … 229 254 230 255 return apply_filters('feed_link', $output, $feed); 256 } 257 258 function get_post_comments_feed_link($post_id = '', $feed = 'rss2') { 259 global $id; 260 261 if ( empty($post_id) ) 262 $post_id = (int) $id; 263 264 if ( '' != get_option('permalink_structure') ) { 265 $url = trailingslashit( get_permalink() ) . 'feed'; 266 if ( 'rss2' != $feed ) 267 $url .= "/$feed"; 268 $url = user_trailingslashit($url, 'single_feed'); 269 } else { 270 $url = get_option('home') . "/?feed=$feed&p=$id"; 271 } 272 273 return apply_filters('post_comments_feed_link', $url); 231 274 } 232 275 … … 399 442 400 443 // if we already have a QUERY style page string 401 if ( stri str( $qstr, $page_querystring )) {444 if ( stripos( $qstr, $page_querystring ) !== false ) { 402 445 $replacement = "$page_querystring=$pagenum"; 403 446 $qstr = preg_replace("/".$page_querystring."[^\d]+\d+/", $replacement, $qstr); … … 412 455 // we need to know the way queries are being written 413 456 // if there's a querystring_start (a "?" usually), it's definitely not mod_rewritten 414 if ( stri str( $qstr, '?' )) {457 if ( stripos( $qstr, '?' ) !== false ) { 415 458 // so append the query string (using &, since we already have ?) 416 459 $qstr .= '&' . $page_querystring . '=' . $pagenum; … … 437 480 $qstr = preg_replace('|^/+|', '', $qstr); 438 481 if ( $permalink ) 439 $qstr = trailingslashit($qstr);482 $qstr = user_trailingslashit($qstr, 'paged'); 440 483 $qstr = preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', trailingslashit( get_option('home') ) . $qstr ); 441 484 442 485 // showing /page/1/ or ?paged=1 is redundant 443 486 if ( 1 === $pagenum ) { 444 $qstr = str_replace('page/1/', '', $qstr); // for mod_rewrite style 487 $qstr = str_replace(user_trailingslashit('index.php/page/1', 'paged'), '', $qstr); // for PATHINFO style 488 $qstr = str_replace(user_trailingslashit('page/1', 'paged'), '', $qstr); // for mod_rewrite style 445 489 $qstr = remove_query_arg('paged', $qstr); // for query style 446 490 } -
tags/2.2/wp-includes/locale.php
r5468 r5480 13 13 var $meridiem; 14 14 15 var $text_direction = ' ';15 var $text_direction = 'ltr'; 16 16 var $locale_vars = array('text_direction'); 17 17 -
tags/2.2/wp-includes/pluggable.php
r5468 r5480 97 97 98 98 wp_cache_add($user_id, $user, 'users'); 99 wp_cache_add($user->user_login, $user, 'userlogins'); 100 99 wp_cache_add($user->user_login, $user_id, 'userlogins'); 101 100 return $user; 102 101 } … … 117 116 return false; 118 117 119 $userdata = wp_cache_get($user_login, 'userlogins'); 118 $user_id = wp_cache_get($user_login, 'userlogins'); 119 $userdata = wp_cache_get($user_id, 'users'); 120 120 121 if ( $userdata ) 121 122 return $userdata; 123 124 $user_login = $wpdb->escape($user_login); 122 125 123 126 if ( !$user = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE user_login = '$user_login'") ) … … 148 151 149 152 wp_cache_add($user->ID, $user, 'users'); 150 wp_cache_add($user->user_login, $user, 'userlogins'); 151 153 wp_cache_add($user->user_login, $user->ID, 'userlogins'); 152 154 return $user; 153 155 … … 157 159 if ( !function_exists('wp_mail') ) : 158 160 function wp_mail($to, $subject, $message, $headers = '') { 159 if( $headers == '' ) { 161 global $phpmailer; 162 163 if ( !is_object( $phpmailer ) ) { 164 require_once(ABSPATH . WPINC . '/class-phpmailer.php'); 165 require_once(ABSPATH . WPINC . '/class-smtp.php'); 166 $phpmailer = new PHPMailer(); 167 } 168 169 $mail = compact('to', 'subject', 'message', 'headers'); 170 $mail = apply_filters('wp_mail', $mail); 171 extract($mail); 172 173 if ( $headers == '' ) { 160 174 $headers = "MIME-Version: 1.0\n" . 161 "From: wordpress@" . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])) . "\n" .175 "From: " . apply_filters('wp_mail_from', "wordpress@" . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']))) . "\n" . 162 176 "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; 163 177 } 164 178 165 return @mail($to, $subject, $message, $headers); 179 $phpmailer->ClearAddresses(); 180 $phpmailer->ClearCCs(); 181 $phpmailer->ClearBCCs(); 182 $phpmailer->ClearReplyTos(); 183 $phpmailer->ClearAllRecipients(); 184 $phpmailer->ClearCustomHeaders(); 185 186 $phpmailer->FromName = "WordPress"; 187 $phpmailer->AddAddress("$to", ""); 188 $phpmailer->Subject = $subject; 189 $phpmailer->Body = $message; 190 $phpmailer->IsHTML(false); 191 $phpmailer->IsMail(); // set mailer to use php mail() 192 193 do_action_ref_array('phpmailer_init', array(&$phpmailer)); 194 195 $mailheaders = (array) explode( "\n", $headers ); 196 foreach ( $mailheaders as $line ) { 197 $header = explode( ":", $line ); 198 switch ( trim( $header[0] ) ) { 199 case "From": 200 $from = trim( str_replace( '"', '', $header[1] ) ); 201 if ( strpos( $from, '<' ) ) { 202 $phpmailer->FromName = str_replace( '"', '', substr( $header[1], 0, strpos( $header[1], '<' ) - 1 ) ); 203 $from = trim( substr( $from, strpos( $from, '<' ) + 1 ) ); 204 $from = str_replace( '>', '', $from ); 205 } else { 206 $phpmailer->FromName = $from; 207 } 208 $phpmailer->From = trim( $from ); 209 break; 210 default: 211 if ( $line != '' && $header[0] != 'MIME-Version' && $header[0] != 'Content-Type' ) 212 $phpmailer->AddCustomHeader( $line ); 213 break; 214 } 215 } 216 217 $result = @$phpmailer->Send(); 218 219 return $result; 166 220 } 167 221 endif; … … 229 283 $referer = strtolower(wp_get_referer()); 230 284 if ( !wp_verify_nonce($_REQUEST['_wpnonce'], $action) && 231 !(-1 == $action && str str($referer, $adminurl))) {285 !(-1 == $action && strpos($referer, $adminurl) !== false)) { 232 286 wp_nonce_ays($action); 233 287 die(); … … 371 425 } 372 426 $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n"; 373 $notify_message .= sprintf( __(' To delete this comment, visit: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&c=$comment_id" ) . "\r\n";374 $notify_message .= sprintf( __(' To mark this comment as spam, visit: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&dt=spam&c=$comment_id" ) . "\r\n";427 $notify_message .= sprintf( __('Delete it: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&c=$comment_id" ) . "\r\n"; 428 $notify_message .= sprintf( __('Spam it: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&dt=spam&c=$comment_id" ) . "\r\n"; 375 429 376 430 $wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); -
tags/2.2/wp-includes/plugin.php
r5468 r5480 1 1 <?php 2 2 3 // 4 // Filter functions, the core of the WP plugin architecture. 5 // 6 3 /** 4 * Hooks a function to a specific filter action. 5 * 6 * Filters are the hooks that WordPress launches to modify text of various types 7 * before adding it to the database or sending it to the browser screen. Plugins 8 * can specify that one or more of its PHP functions is executed to 9 * modify specific types of text at these times, using the Filter API. 10 * See the [Plugin API] for a list of filter hooks. 11 * 12 * @param string $tag The name of the filter to hook the <tt>$function_to_add</tt> to. 13 * @param callback $function_to_add The name of the function to be called when the filter is applied. 14 * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action. 15 * @param int $accepted_args optional. The number of arguments the function accept (default 1). In WordPress 1.5.1+, hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run. 16 * @return boolean true if the <tt>$function_to_add</tt> is added succesfully to filter <tt>$tag</tt>. How many arguments your function takes. In WordPress 1.5.1+, hooked functions can take extra arguments that are set when the matching <tt>do_action()</tt> or <tt>apply_filters()</tt> call is run. For example, the action <tt>comment_id_not_found</tt> will pass any functions that hook onto it the ID of the requested comment. 17 */ 7 18 function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) { 8 global $wp_filter; 9 10 // check that we don't already have the same filter at the same priority 11 if ( isset($wp_filter[$tag]["$priority"]) ) { 12 foreach ( $wp_filter[$tag]["$priority"] as $filter ) { 13 // uncomment if we want to match function AND accepted_args 14 // if ( $filter == array($function, $accepted_args) ) { 15 if ( $filter['function'] == $function_to_add ) 16 return true; 17 } 18 } 19 20 // So the format is wp_filter['tag']['array of priorities']['array of ['array (functions, accepted_args)]'] 21 $wp_filter[$tag]["$priority"][] = array('function'=>$function_to_add, 'accepted_args'=>$accepted_args); 19 global $wp_filter, $merged_filters; 20 21 // So the format is wp_filter['tag']['array of priorities']['array of functions serialized']['array of ['array (functions, accepted_args)]'] 22 $wp_filter[$tag][$priority][serialize($function_to_add)] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); 23 unset( $merged_filters[ $tag ] ); 22 24 return true; 23 25 } 24 26 27 /** 28 * Call the functions added to a filter hook. 29 * 30 * The callback functions attached to filter hook <tt>$tag</tt> are invoked by 31 * calling this function. This function can be used to create a new filter hook 32 * by simply calling this function with the name of the new hook specified using 33 * the <tt>$tag</a> parameter. 34 * @uses merge_filters Merges the filter hooks using this function. 35 * @param string $tag The name of the filter hook. 36 * @param string $string The text on which the filters hooked to <tt>$tag</tt> are applied on. 37 * @param mixed $var,... Additional variables passed to the functions hooked to <tt>$tag</tt>. 38 * @return string The text in <tt>$string</tt> after all hooked functions are applied to it. 39 */ 25 40 function apply_filters($tag, $string) { 26 global $wp_filter; 27 28 $args = array(); 29 for ( $a = 2; $a < func_num_args(); $a++ ) 30 $args[] = func_get_arg($a); 31 32 merge_filters($tag); 41 global $wp_filter, $merged_filters; 42 43 if ( !isset( $merged_filters[ $tag ] ) ) 44 merge_filters($tag); 33 45 34 46 if ( !isset($wp_filter[$tag]) ) 35 47 return $string; 36 48 37 foreach ( (array) $wp_filter[$tag] as $priority => $functions ) { 38 if ( !is_null($functions) ) { 39 foreach ( (array) $functions as $function ) { 40 $function_name = $function['function']; 41 $accepted_args = $function['accepted_args']; 42 $the_args = $args; 43 array_unshift($the_args, $string); 44 if ( $accepted_args > 0 ) 45 $the_args = array_slice($the_args, 0, $accepted_args); 46 elseif ( 0 == $accepted_args ) 47 $the_args = NULL; 48 $string = call_user_func_array($function_name, $the_args); 49 reset( $wp_filter[ $tag ] ); 50 51 $args = func_get_args(); 52 53 do{ 54 foreach( (array) current($wp_filter[$tag]) as $the_ ) 55 if ( !is_null($the_['function']) ){ 56 $args[1] = $string; 57 $string = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args'])); 49 58 } 50 } 59 60 } while ( next($wp_filter[$tag]) ); 61 62 return $string; 63 } 64 65 /** 66 * Merge the filter functions of a specific filter hook with generic filter functions. 67 * 68 * It is possible to defined generic filter functions using the filter hook 69 * <em>all</e>. These functions are called for every filter tag. This function 70 * merges the functions attached to the <em>all</em> hook with the functions 71 * of a specific hoook defined by <tt>$tag</tt>. 72 * @param string $tag The filter hook of which the functions should be merged. 73 */ 74 function merge_filters($tag) { 75 global $wp_filter, $merged_filters; 76 77 if ( isset($wp_filter['all']) && is_array($wp_filter['all']) ) 78 $wp_filter[$tag] = array_merge($wp_filter['all'], (array) $wp_filter[$tag]); 79 80 if ( isset($wp_filter[$tag]) ){ 81 reset($wp_filter[$tag]); 82 uksort($wp_filter[$tag], "strnatcasecmp"); 51 83 } 52 return $string; 53 } 54 55 function merge_filters($tag) { 56 global $wp_filter; 57 if ( isset($wp_filter['all']) ) { 58 foreach ( (array) $wp_filter['all'] as $priority => $functions ) { 59 if ( isset($wp_filter[$tag][$priority]) ) 60 $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], $wp_filter[$tag][$priority]); 61 else 62 $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], array()); 63 $wp_filter[$tag][$priority] = array_unique($wp_filter[$tag][$priority]); 64 } 65 } 66 67 if ( isset($wp_filter[$tag]) ) 68 uksort( $wp_filter[$tag], "strnatcasecmp" ); 69 } 70 84 $merged_filters[ $tag ] = true; 85 } 86 87 /** 88 * Removes a function from a specified filter hook. 89 * 90 * This function removes a function attached to a specified filter hook. This 91 * method can be used to remove default functions attached to a specific filter 92 * hook and possibly replace them with a substitute. 93 * @param string $tag The filter hook to which the function to be removed is hooked. 94 * @param callback $function_to_remove The name of the function which should be removed. 95 * @param int $priority optional. The priority of the function (default: 10). 96 * @param int $accepted_args optional. The number of arguments the function accpets (default: 1). 97 * @return boolean Whether the function is removed. 98 */ 71 99 function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) { 72 global $wp_filter; 73 74 // rebuild the list of filters 75 if ( isset($wp_filter[$tag]["$priority"]) ) { 76 $new_function_list = array(); 77 foreach ( (array) $wp_filter[$tag]["$priority"] as $filter ) { 78 if ( $filter['function'] != $function_to_remove ) 79 $new_function_list[] = $filter; 80 } 81 $wp_filter[$tag]["$priority"] = $new_function_list; 82 } 100 global $wp_filter, $merged_filters; 101 102 unset($GLOBALS['wp_filter'][$tag][$priority][serialize($function_to_remove)]); 103 unset( $merged_filters[ $tag ] ); 104 83 105 return true; 84 106 } 85 107 86 // 87 // Action functions 88 // 89 108 /** 109 * Hooks a function on to a specific action. 110 * 111 * Actions are the hooks that the WordPress core launches at specific points 112 * during execution, or when specific events occur. Plugins can specify that 113 * one or more of its PHP functions are executed at these points, using the 114 * Action API. 115 * 116 * @param string $tag The name of the action to which the <tt>$function_to-add</tt> is hooked. 117 * @param callback $function_to_add The name of the function you wish to be called. Note: any of the syntaxes explained in the PHP documentation for the 'callback' type (http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback) are valid. 118 * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action. 119 * @param int $accepted_args optional. The number of arguments the function accept (default 1). In WordPress 1.5.1+, hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run. 120 * @return boolean Always true. 121 */ 90 122 function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) { 91 123 add_filter($tag, $function_to_add, $priority, $accepted_args); 92 124 } 93 125 126 /** 127 * Execute functions hooked on a specific action hook. 128 * 129 * This function invokes all functions attached to action hook <tt>$tag</tt>. 130 * It is possible to create new action hooks by simply calling this function, 131 * specifying the name of the new hook using the <tt>$tag</tt> parameter. 132 * @uses merge_filters 133 * @param string $tag The name of the action to be executed. 134 * @param mixed $arg,... Optional additional arguments which are passed on to the functions hooked to the action. 135 */ 94 136 function do_action($tag, $arg = '') { 95 137 global $wp_filter, $wp_actions; 138 139 if ( is_array($wp_actions) ) 140 $wp_actions[] = $tag; 141 else 142 $wp_actions = array($tag); 96 143 97 144 $args = array(); … … 108 155 return; 109 156 110 foreach ( (array) $wp_filter[$tag] as $priority => $functions ) { 111 if ( !is_null($functions) ) { 112 foreach ( (array) $functions as $function ) { 113 $function_name = $function['function']; 114 $accepted_args = $function['accepted_args']; 115 116 if ( $accepted_args > 0 ) 117 $the_args = array_slice($args, 0, $accepted_args); 118 elseif ( $accepted_args == 0 ) 119 $the_args = NULL; 120 else 121 $the_args = $args; 122 123 call_user_func_array($function_name, $the_args); 124 } 125 } 126 } 127 128 if ( is_array($wp_actions) ) 129 $wp_actions[] = $tag; 130 else 131 $wp_actions = array($tag); 132 } 133 134 // Returns the number of times an action has been done 157 do{ 158 foreach( (array) current($wp_filter[$tag]) as $the_ ) 159 if ( !is_null($the_['function']) ) 160 call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); 161 162 } while ( next($wp_filter[$tag]) ); 163 164 } 165 166 /** 167 * Return the number times an action is fired. 168 * @param string $tag The name of the action hook. 169 * @return int The number of times action hook <tt>$tag</tt> is fired 170 */ 135 171 function did_action($tag) { 136 172 global $wp_actions; 137 173 174 if ( empty($wp_actions) ) 175 return 0; 176 138 177 return count(array_keys($wp_actions, $tag)); 139 178 } 140 179 180 /** 181 * Execute functions hooked on a specific action hook, specifying arguments in a array. 182 * 183 * This function is identical to {@link do_action}, but the argumetns passe to 184 * the functions hooked to <tt>$tag</tt> are supplied using an array. 185 * @param string $tag The name of the action to be executed. 186 * @param array $args The arguments supplied to the functions hooked to <tt>$tag</tt> 187 */ 141 188 function do_action_ref_array($tag, $args) { 142 189 global $wp_filter, $wp_actions; … … 152 199 return; 153 200 154 foreach ( (array) $wp_filter[$tag] as $priority => $functions ) { 155 if ( !is_null($functions) ) { 156 foreach ( (array) $functions as $function ) { 157 $function_name = $function['function']; 158 $accepted_args = $function['accepted_args']; 159 if ( $accepted_args > 0 ) 160 $the_args = array_slice($args, 0, $accepted_args); 161 elseif ( 0 == $accepted_args ) 162 $the_args = NULL; 163 else 164 $the_args = $args; 165 166 call_user_func_array($function_name, $the_args); 167 } 168 } 169 } 170 } 171 201 do{ 202 foreach( (array) current($wp_filter[$tag]) as $the_ ) 203 if ( !is_null($the_['function']) ) 204 call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); 205 206 } while ( next($wp_filter[$tag]) ); 207 208 } 209 210 /** 211 * Removes a function from a specified action hook. 212 * 213 * This function removes a function attached to a specified action hook. This 214 * method can be used to remove default functions attached to a specific filter 215 * hook and possibly replace them with a substitute. 216 * @param string $tag The action hook to which the function to be removed is hooked. 217 * @param callback $function_to_remove The name of the function which should be removed. 218 * @param int $priority optional The priority of the function (default: 10). 219 * @param int $accepted_args optional. The number of arguments the function accpets (default: 1). 220 * @return boolean Whether the function is removed. 221 */ 172 222 function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args = 1) { 173 223 remove_filter($tag, $function_to_remove, $priority, $accepted_args); … … 178 228 // 179 229 230 /** 231 * Gets the basename of a plugin. 232 * 233 * This method extract the name of a plugin from its filename. 234 * @param string $file The filename of plugin. 235 * @return string The name of a plugin. 236 */ 180 237 function plugin_basename($file) { 181 238 $file = preg_replace('|\\\\+|', '\\\\', $file); … … 184 241 } 185 242 243 /** 244 * Hook a function on a plugin activation action hook. 245 * 246 * When a plugin is activated, the action 'activate_PLUGINNAME' hook is 247 * activated. In the name of this hook, PLUGINNAME is replaced with the name of 248 * the plugin, including the optional subdirectory. For example, when the plugin 249 * is located in <tt>wp-content/plugin/sampleplugin/sample.php</tt>, then the 250 * name of this hook will become 'activate_sampleplugin/sample.php'. 251 * When the plugin consists of only one file and is (as by default) located at 252 * <tt>wp-content/plugin/sample.php</tt> the name of this hook will be 253 * 'activate_sample.php'. 254 * @param string $file The filename of the plugin including the path. 255 * @param string $function the function hooked to the 'activate_PLUGIN' action. 256 */ 186 257 function register_activation_hook($file, $function) { 187 258 $file = plugin_basename($file); … … 189 260 } 190 261 262 /** 263 * Hook a function on a plugin deactivation action hook. 264 * 265 * When a plugin is deactivated, the action 'deactivate_PLUGINNAME' hook is 266 * deactivated. In the name of this hook, PLUGINNAME is replaced with the name of 267 * the plugin, including the optional subdirectory. For example, when the plugin 268 * is located in <tt>wp-content/plugin/sampleplugin/sample.php</tt>, then the 269 * name of this hook will become 'activate_sampleplugin/sample.php'. 270 * When the plugin consists of only one file and is (as by default) located at 271 * <tt>wp-content/plugin/sample.php</tt> the name of this hook will be 272 * 'activate_sample.php'. 273 * @param string $file The filename of the plugin including the path. 274 * @param string $function the function hooked to the 'activate_PLUGIN' action. 275 */ 191 276 function register_deactivation_hook($file, $function) { 192 277 $file = plugin_basename($file); -
tags/2.2/wp-includes/post-template.php
r5468 r5480 81 81 82 82 $content = $pages[$page-1]; 83 if ( preg_match('/<!--more(. +?)?-->/', $content, $matches) ) {83 if ( preg_match('/<!--more(.*?)?-->/', $content, $matches) ) { 84 84 $content = explode($matches[0], $content, 2); 85 85 if ( !empty($matches[1]) && !empty($more_link_text) ) … … 96 96 if ( count($content) > 1 ) { 97 97 if ( $more ) { 98 $output .= '< a id="more-'.$id.'"></a>'.$content[1];98 $output .= '<span id="more-'.$id.'"></span>'.$content[1]; 99 99 } else { 100 100 $output = balanceTags($output); … … 102 102 $output .= ' <a href="'. get_permalink() . "#more-$id\" class=\"more-link\">$more_link_text</a>"; 103 103 } 104 104 105 105 } 106 106 if ( $preview ) // preview fix for javascript bug with foreign languages … … 132 132 133 133 function wp_link_pages($args = '') { 134 global $post; 135 134 136 if ( is_array($args) ) 135 137 $r = &$args; … … 156 158 $output .= ' '; 157 159 if ( ($i != $page) || ((!$more) && ($page==1)) ) { 158 if ( '' == get_option('permalink_structure') ) 159 $output .= '<a href="' . get_permalink() . '&page=' . $i . '">'; 160 else 161 $output .= '<a href="' . trailingslashit(get_permalink()) . $i . '/">'; 160 if ( 1 == $i ) { 161 $output .= '<a href="' . get_permalink() . '">'; 162 } else { 163 if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status ) 164 $output .= '<a href="' . get_permalink() . '&page=' . $i . '">'; 165 else 166 $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">'; 167 } 162 168 } 163 169 $output .= $j; … … 171 177 $i = $page - 1; 172 178 if ( $i && $more ) { 173 if ( '' == get_option('permalink_structure') ) 174 $output .= '<a href="' . get_permalink() . '&page=' . $i . '">' . $previouspagelink . '</a>'; 175 else 176 $output .= '<a href="' . get_permalink() . $i . '/">'.$previouspagelink.'</a>'; 179 if ( 1 == $i ) { 180 $output .= '<a href="' . get_permalink() . '">' . $previouspagelink . '</a>'; 181 } else { 182 if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status ) 183 $output .= '<a href="' . get_permalink() . '&page=' . $i . '">' . $previouspagelink . '</a>'; 184 else 185 $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">' . $previouspagelink . '</a>'; 186 } 177 187 } 178 188 $i = $page + 1; 179 189 if ( $i <= $numpages && $more ) { 180 if ( '' == get_option('permalink_structure') ) 181 $output .= '<a href="' . get_permalink() . '&page=' . $i . '">'.$nextpagelink.'</a>'; 182 else 183 $output .= '<a href="' . trailingslashit(get_permalink()) . $i . '/">' . $nextpagelink . '</a>'; 190 if ( 1 == $i ) { 191 $output .= '<a href="' . get_permalink() . '">' . $nextpagelink . '</a>'; 192 } else { 193 if ( '' == get_option('permalink_structure') || 'draft' == $post->post_status ) 194 $output .= '<a href="' . get_permalink() . '&page=' . $i . '">' . $nextpagelink . '</a>'; 195 else 196 $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">' . $nextpagelink . '</a>'; 197 } 184 198 } 185 199 $output .= $after; … … 222 236 $values = array_map('trim', get_post_custom_values($key)); 223 237 $value = implode($values,', '); 224 echo "<li><span class='post-meta-key'>$key:</span> $value</li>\n";238 echo apply_filters('the_meta_key', "<li><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value); 225 239 } 226 240 echo "</ul>\n"; … … 270 284 271 285 $defaults = array('depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), 272 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '' );286 'child_of' => 0, 'exclude' => '', 'title_li' => __('Pages'), 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title'); 273 287 $r = array_merge($defaults, $r); 274 288 … … 334 348 $_post = & get_post($id); 335 349 336 if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url( ) )350 if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) ) 337 351 return __('Missing Attachment'); 338 352 -
tags/2.2/wp-includes/post.php
r5468 r5480 75 75 function get_extended($post) { 76 76 //Match the new style more links 77 if ( preg_match('/<!--more(.*?) -->/', $post, $matches) ) {77 if ( preg_match('/<!--more(.*?)?-->/', $post, $matches) ) { 78 78 list($main, $extended) = explode($matches[0], $post, 2); 79 79 } else { … … 81 81 $extended = ''; 82 82 } 83 83 84 84 // Strip leading and trailing whitespace 85 85 $main = preg_replace('/^[\s]*(.*)[\s]*$/', '\\1', $main); … … 107 107 } else { 108 108 $post = (int) $post; 109 if ( $_post = wp_cache_get($post, 'pages') ) 109 if ( isset($post_cache[$blog_id][$post]) ) 110 $_post = & $post_cache[$blog_id][$post]; 111 elseif ( $_post = wp_cache_get($post, 'pages') ) 110 112 return get_page($_post, $output); 111 elseif ( isset($post_cache[$blog_id][$post]) )112 $_post = & $post_cache[$blog_id][$post];113 113 else { 114 114 $query = "SELECT * FROM $wpdb->posts WHERE ID = '$post' LIMIT 1"; … … 226 226 $exclusions .= ')'; 227 227 228 $query ="SELECT DISTINCT * FROM $wpdb->posts " ;229 $query .= ( empty( $category ) ? "" : ", $wpdb->post2cat " );230 $query .= ( empty( $meta_key ) ? "" : ", $wpdb->postmeta " );231 $query .= " WHERE (post_type = 'post' AND post_status = 'publish') $exclusions $inclusions ";232 $query .= ( empty( $category ) ? "" : "AND ($wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $category. ") " );233 $query .= ( empty( $meta_key ) | empty($meta_value) ? "" : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )" );234 $query .= " GROUP BY $wpdb->posts.ID ORDER BY " . $orderby . " " . $order . " LIMIT " . $offset . ',' . $numberposts;235 236 228 $query = "SELECT DISTINCT * FROM $wpdb->posts "; 237 229 $query .= empty( $category ) ? '' : ", $wpdb->post2cat "; … … 444 436 } 445 437 438 do_action('deleted_post', $postid); 439 446 440 return $post; 447 441 } … … 562 556 $post_date_gmt = get_gmt_from_date($post_date); 563 557 } 564 558 565 559 if ( 'publish' == $post_status ) { 566 560 $now = gmdate('Y-m-d H:i:59'); … … 679 673 if ( defined('XMLRPC_REQUEST') ) 680 674 do_action('xmlrpc_publish_post', $post_ID); 675 if ( defined('APP_REQUEST') ) 676 do_action('app_publish_post', $post_ID); 681 677 682 678 if ( !defined('WP_IMPORTING') ) { … … 709 705 if ( 'future' == $post_status ) 710 706 wp_schedule_single_event(strtotime($post_date_gmt. ' GMT'), 'publish_future_post', array($post_ID)); 711 707 712 708 do_action('save_post', $post_ID); 713 709 do_action('wp_insert_post', $post_ID); … … 912 908 if ( ! $page_ids = wp_cache_get('all_page_ids', 'pages') ) { 913 909 $page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'page'"); 914 wp_cache_ set('all_page_ids', $page_ids, 'pages');910 wp_cache_add('all_page_ids', $page_ids, 'pages'); 915 911 } 916 912 … … 955 951 // Potential issue: we're not checking to see if the post_type = 'page' 956 952 // So all non-'post' posts will get cached as pages. 957 wp_cache_ set($_page->ID, $_page, 'pages');953 wp_cache_add($_page->ID, $_page, 'pages'); 958 954 } 959 955 } … … 1116 1112 if (!empty($authors)) { 1117 1113 $post_authors = preg_split('/[\s,]+/',$authors); 1118 1114 1119 1115 if ( count($post_authors) ) { 1120 1116 foreach ( $post_authors as $post_author ) { … … 1207 1203 1208 1204 function is_local_attachment($url) { 1209 if ( !strstr($url, get_bloginfo('home') ))1210 return false; 1211 if ( strstr($url, get_bloginfo('home') . '/?attachment_id='))1205 if (strpos($url, get_bloginfo('url')) === false) 1206 return false; 1207 if (strpos($url, get_bloginfo('url') . '/?attachment_id=') !== false) 1212 1208 return true; 1213 1209 if ( $id = url_to_postid($url) ) { … … 1565 1561 } 1566 1562 1563 /** 1564 * This function provides a standardized way to appropriately select on 1565 * the post_status of posts/pages. The function will return a piece of 1566 * SQL code that can be added to a WHERE clause; this SQL is constructed 1567 * to allow all published posts, and all private posts to which the user 1568 * has access. 1569 * 1570 * @param string $post_type currently only supports 'post' or 'page'. 1571 * @return string SQL code that can be added to a where clause. 1572 */ 1573 function get_private_posts_cap_sql($post_type) { 1574 global $user_ID; 1575 $cap = ''; 1576 1577 // Private posts 1578 if ($post_type == 'post') { 1579 $cap = 'read_private_posts'; 1580 // Private pages 1581 } elseif ($post_type == 'page') { 1582 $cap = 'read_private_pages'; 1583 // Dunno what it is, maybe plugins have their own post type? 1584 } else { 1585 $cap = apply_filters('pub_priv_sql_capability', $cap); 1586 1587 if (empty($cap)) { 1588 // We don't know what it is, filters don't change anything, 1589 // so set the SQL up to return nothing. 1590 return '1 = 0'; 1591 } 1592 } 1593 1594 $sql = '(post_status = \'publish\''; 1595 1596 if (current_user_can($cap)) { 1597 // Does the user have the capability to view private posts? Guess so. 1598 $sql .= ' OR post_status = \'private\''; 1599 } elseif (is_user_logged_in()) { 1600 // Users can view their own private posts. 1601 $sql .= ' OR post_status = \'private\' AND post_author = \'' . $user_ID . '\''; 1602 } 1603 1604 $sql .= ')'; 1605 1606 return $sql; 1607 } 1608 1567 1609 ?> -
tags/2.2/wp-includes/query.php
r5468 r5480 9 9 10 10 return $wp_query->get($var); 11 } 12 13 function set_query_var($var, $value) { 14 global $wp_query; 15 16 return $wp_query->set($var, $value); 11 17 } 12 18 … … 24 30 global $wp_query; 25 31 26 return ( $wp_query->is_admin || strstr($_SERVER['REQUEST_URI'], 'wp-admin/'));32 return ($wp_query->is_admin || (strpos($_SERVER['REQUEST_URI'], 'wp-admin/') !== false)); 27 33 } 28 34 … … 195 201 global $wp_query; 196 202 197 return $wp_query->is_singular; 203 return $wp_query->is_singular; 198 204 } 199 205 … … 249 255 $wp_query->the_post(); 250 256 } 257 258 /* 259 * Comments loop. 260 */ 261 262 function have_comments() { 263 global $wp_query; 264 return $wp_query->have_comments(); 265 } 266 267 function the_comment() { 268 global $wp_query; 269 return $wp_query->the_comment(); 270 } 251 271 252 272 /* … … 266 286 var $in_the_loop = false; 267 287 var $post; 288 289 var $comments; 290 var $comment_count = 0; 291 var $current_comment = -1; 292 var $comment; 268 293 269 294 var $found_posts = 0; … … 283 308 var $is_search = false; 284 309 var $is_feed = false; 310 var $is_comment_feed = false; 285 311 var $is_trackback = false; 286 312 var $is_home = false; … … 306 332 $this->is_search = false; 307 333 $this->is_feed = false; 334 $this->is_comment_feed = false; 308 335 $this->is_trackback = false; 309 336 $this->is_home = false; … … 334 361 $this->parse_query(''); 335 362 } 336 363 337 364 function fill_query_vars($array) { 338 365 $keys = array( … … 369 396 $array[$key] = ''; 370 397 } 371 398 372 399 return $array; 373 400 } … … 378 405 $this->init(); 379 406 if ( is_array($query) ) 380 $ qv = &$query;407 $this->query_vars = $query; 381 408 else 382 parse_str($query, $ qv);409 parse_str($query, $this->query_vars); 383 410 $this->query = $query; 384 $this->query_vars = $qv;385 } 386 387 $qv = $this->fill_query_vars($qv);388 411 } 412 413 $this->query_vars = $this->fill_query_vars($this->query_vars); 414 $qv = &$this->query_vars; 415 389 416 if ( ! empty($qv['robots']) ) { 390 417 $this->is_robots = true; … … 400 427 } 401 428 429 $qv['p'] = (int) $qv['p']; 430 $qv['page_id'] = (int) $qv['page_id']; 431 $qv['year'] = (int) $qv['year']; 432 $qv['monthnum'] = (int) $qv['monthnum']; 433 $qv['day'] = (int) $qv['day']; 434 $qv['w'] = (int) $qv['w']; 402 435 $qv['m'] = (int) $qv['m']; 403 $qv['p'] = (int) $qv['p']; 436 if ( '' != $qv['hour'] ) $qv['hour'] = (int) $qv['hour']; 437 if ( '' != $qv['minute'] ) $qv['minute'] = (int) $qv['minute']; 438 if ( '' != $qv['second'] ) $qv['second'] = (int) $qv['second']; 404 439 405 440 // Compat. Map subpost to attachment. … … 409 444 $qv['attachment_id'] = $qv['subpost_id']; 410 445 411 if ( ('' != $qv['attachment']) || (int) $qv['attachment_id'] ) { 446 $qv['attachment_id'] = (int) $qv['attachment_id']; 447 448 if ( ('' != $qv['attachment']) || !empty($qv['attachment_id']) ) { 412 449 $this->is_single = true; 413 450 $this->is_attachment = true; 414 } elseif ( '' != $qv['name']) {451 } elseif ( '' != $qv['name'] ) { 415 452 $this->is_single = true; 416 453 } elseif ( $qv['p'] ) { 417 454 $this->is_single = true; 418 } elseif ( ('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) {455 } elseif ( ('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day']) ) { 419 456 // If year, month, day, hour, minute, and second are set, a single 420 457 // post is being queried. 421 458 $this->is_single = true; 422 } elseif ( '' != $qv['static'] || '' != $qv['pagename'] || (int) $qv['page_id']) {459 } elseif ( '' != $qv['static'] || '' != $qv['pagename'] || !empty($qv['page_id']) ) { 423 460 $this->is_page = true; 424 461 $this->is_single = false; 425 } elseif ( !empty($qv['s'])) {462 } elseif ( !empty($qv['s']) ) { 426 463 $this->is_search = true; 427 464 } else { 428 465 // Look for archive queries. Dates, categories, authors. 429 466 430 if ( (int) $qv['second']) {467 if ( '' != $qv['second'] ) { 431 468 $this->is_time = true; 432 469 $this->is_date = true; 433 470 } 434 471 435 if ( (int) $qv['minute']) {472 if ( '' != $qv['minute'] ) { 436 473 $this->is_time = true; 437 474 $this->is_date = true; 438 475 } 439 476 440 if ( (int) $qv['hour']) {477 if ( '' != $qv['hour'] ) { 441 478 $this->is_time = true; 442 479 $this->is_date = true; 443 480 } 444 481 445 if ( (int) $qv['day']) {482 if ( $qv['day'] ) { 446 483 if (! $this->is_date) { 447 484 $this->is_day = true; … … 450 487 } 451 488 452 if ( (int) $qv['monthnum']) {489 if ( $qv['monthnum'] ) { 453 490 if (! $this->is_date) { 454 491 $this->is_month = true; … … 457 494 } 458 495 459 if ( (int) $qv['year']) {496 if ( $qv['year'] ) { 460 497 if (! $this->is_date) { 461 498 $this->is_year = true; … … 464 501 } 465 502 466 if ( (int) $qv['m']) {503 if ( $qv['m'] ) { 467 504 $this->is_date = true; 468 505 if (strlen($qv['m']) > 9) { … … 481 518 } 482 519 483 if ( empty($qv['cat']) || ($qv['cat'] == '0')) {520 if ( empty($qv['cat']) || ($qv['cat'] == '0') ) { 484 521 $this->is_category = false; 485 522 } else { 486 if (str istr($qv['cat'],'-')) {523 if (strpos($qv['cat'], '-') !== false) { 487 524 $this->is_category = false; 488 525 } else { … … 491 528 } 492 529 493 if ( '' != $qv['category_name']) {530 if ( '' != $qv['category_name'] ) { 494 531 $this->is_category = true; 495 532 } 496 533 497 if ( (empty($qv['author'])) || ($qv['author'] == '0')) {534 if ( empty($qv['author']) || ($qv['author'] == '0') ) { 498 535 $this->is_author = false; 499 536 } else { … … 501 538 } 502 539 503 if ( '' != $qv['author_name']) {540 if ( '' != $qv['author_name'] ) { 504 541 $this->is_author = true; 505 542 } 506 543 507 if ( ($this->is_date || $this->is_author || $this->is_category) ) {544 if ( ($this->is_date || $this->is_author || $this->is_category) ) 508 545 $this->is_archive = true; 509 } 510 } 511 512 if ('' != $qv['feed']) { 546 } 547 548 if ( '' != $qv['feed'] ) 513 549 $this->is_feed = true; 514 } 515 516 if ('' != $qv['tb']) { 550 551 if ( '' != $qv['tb'] ) 517 552 $this->is_trackback = true; 518 } 519 520 if ('' != $qv['paged']) { 553 554 if ( '' != $qv['paged'] ) 521 555 $this->is_paged = true; 522 } 523 524 if ('' != $qv['comments_popup']) { 556 557 if ( '' != $qv['comments_popup'] ) 525 558 $this->is_comments_popup = true; 526 } 527 528 //if we're previewing inside the write screen 529 if ('' != $qv['preview']) { 559 560 // if we're previewing inside the write screen 561 if ('' != $qv['preview']) 530 562 $this->is_preview = true; 531 } 532 533 if (strstr($_SERVER['PHP_SELF'], 'wp-admin/')) { 563 564 if ( strpos($_SERVER['PHP_SELF'], 'wp-admin/') !== false ) 534 565 $this->is_admin = true; 535 } 536 537 if ( $this->is_single || $this->is_page || $this->is_attachment ) 538 $this->is_singular = true; 539 540 if ( ! ($this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup)) { 566 567 if ( false !== strpos($qv['feed'], 'comments-') ) { 568 $qv['feed'] = str_replace('comments-', '', $qv['feed']); 569 $qv['withcomments'] = 1; 570 } 571 572 $this->is_singular = $this->is_single || $this->is_page || $this->is_attachment; 573 574 if ( $this->is_feed && ( !empty($qv['withcomments']) || ( empty($qv['withoutcomments']) && $this->is_singular ) ) ) 575 $this->is_comment_feed = true; 576 577 if ( !( $this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup ) ) 541 578 $this->is_home = true; 542 } 543 544 if ( !empty($query) ) { 579 580 // Correct is_* for page_on_front and page_for_posts 581 if ( $this->is_home && ( empty($this->query) || $qv['preview'] == 'true' ) && 'page' == get_option('show_on_front') && get_option('page_on_front') ) { 582 $this->is_page = true; 583 $this->is_home = false; 584 $qv['page_id'] = get_option('page_on_front'); 585 } 586 587 if ( '' != $qv['pagename'] ) { 588 $this->queried_object =& get_page_by_path($qv['pagename']); 589 if ( !empty($this->queried_object) ) 590 $this->queried_object_id = (int) $this->queried_object->ID; 591 else 592 unset($this->queried_object); 593 594 if ( 'page' == get_option('show_on_front') && isset($this->queried_object_id) && $this->queried_object_id == get_option('page_for_posts') ) { 595 $this->is_page = false; 596 $this->is_home = true; 597 $this->is_posts_page = true; 598 } 599 } 600 601 if ( $qv['page_id'] ) { 602 if ( 'page' == get_option('show_on_front') && $qv['page_id'] == get_option('page_for_posts') ) { 603 $this->is_page = false; 604 $this->is_home = true; 605 $this->is_posts_page = true; 606 } 607 } 608 609 if ( $this->is_posts_page && !$qv['withcomments'] ) 610 $this->is_comment_feed = false; 611 612 $this->is_singular = $this->is_single || $this->is_page || $this->is_attachment; 613 // Done correcting is_* for page_on_front and page_for_posts 614 615 if ( !empty($query) ) 545 616 do_action_ref_array('parse_query', array(&$this)); 546 }547 617 } 548 618 … … 575 645 // Shorthand. 576 646 $q = &$this->query_vars; 577 647 578 648 $q = $this->fill_query_vars($q); 579 649 … … 635 705 636 706 // If a month is specified in the querystring, load that month 637 if ( (int)$q['m'] ) {707 if ( $q['m'] ) { 638 708 $q['m'] = '' . preg_replace('|[^0-9]|', '', $q['m']); 639 709 $where .= ' AND YEAR(post_date)=' . substr($q['m'], 0, 4); … … 650 720 } 651 721 652 if ( (int) $q['hour'] ) { 653 $q['hour'] = '' . intval($q['hour']); 722 if ( '' != $q['hour'] ) 654 723 $where .= " AND HOUR(post_date)='" . $q['hour'] . "'"; 655 } 656 657 if ( (int) $q['minute'] ) { 658 $q['minute'] = '' . intval($q['minute']); 724 725 if ( '' != $q['minute'] ) 659 726 $where .= " AND MINUTE(post_date)='" . $q['minute'] . "'"; 660 } 661 662 if ( (int) $q['second'] ) { 663 $q['second'] = '' . intval($q['second']); 727 728 if ( '' != $q['second'] ) 664 729 $where .= " AND SECOND(post_date)='" . $q['second'] . "'"; 665 } 666 667 if ( (int) $q['year'] ) { 668 $q['year'] = '' . intval($q['year']); 730 731 if ( $q['year'] ) 669 732 $where .= " AND YEAR(post_date)='" . $q['year'] . "'"; 670 } 671 672 if ( (int) $q['monthnum'] ) { 673 $q['monthnum'] = '' . intval($q['monthnum']); 733 734 if ( $q['monthnum'] ) 674 735 $where .= " AND MONTH(post_date)='" . $q['monthnum'] . "'"; 675 } 676 677 if ( (int) $q['day'] ) { 678 $q['day'] = '' . intval($q['day']); 736 737 if ( $q['day'] ) 679 738 $where .= " AND DAYOFMONTH(post_date)='" . $q['day'] . "'"; 680 }681 682 // Compat. Map subpost to attachment.683 if ( '' != $q['subpost'] )684 $q['attachment'] = $q['subpost'];685 if ( '' != $q['subpost_id'] )686 $q['attachment_id'] = $q['subpost_id'];687 739 688 740 if ('' != $q['name']) { … … 690 742 $where .= " AND post_name = '" . $q['name'] . "'"; 691 743 } else if ('' != $q['pagename']) { 692 $reqpage = get_page_by_path($q['pagename']); 693 if ( !empty($reqpage) ) 694 $reqpage = $reqpage->ID; 695 else 696 $reqpage = 0; 697 698 if ( ('page' == get_option('show_on_front') ) && ( $reqpage == get_option('page_for_posts') ) ) { 699 $this->is_singular = false; 700 $this->is_page = false; 701 $this->is_home = true; 702 $this->is_posts_page = true; 703 } else { 744 if ( isset($this->queried_object_id) ) 745 $reqpage = $this->queried_object_id; 746 else { 747 $reqpage = get_page_by_path($q['pagename']); 748 if ( !empty($reqpage) ) 749 $reqpage = $reqpage->ID; 750 else 751 $reqpage = 0; 752 } 753 754 if ( ('page' != get_option('show_on_front') ) || ( $reqpage != get_option('page_for_posts') ) ) { 704 755 $q['pagename'] = str_replace('%2F', '/', urlencode(urldecode($q['pagename']))); 705 756 $page_paths = '/' . trim($q['pagename'], '/'); … … 716 767 } 717 768 718 if ( (int) $q['w'] ) { 719 $q['w'] = ''.intval($q['w']); 769 if ( $q['w'] ) 720 770 $where .= " AND WEEK(post_date, 1)='" . $q['w'] . "'"; 721 }722 771 723 772 if ( intval($q['comments_popup']) ) 724 773 $q['p'] = intval($q['comments_popup']); 725 774 726 // If a attachment is requested by number, let it supercede any post number.727 if ( ($q['attachment_id'] != '') && (intval($q['attachment_id']) != 0))728 $q['p'] = (int)$q['attachment_id'];775 // If an attachment is requested by number, let it supercede any post number. 776 if ( $q['attachment_id'] ) 777 $q['p'] = $q['attachment_id']; 729 778 730 779 // If a post number is specified, load that post 731 if (($q['p'] != '') && intval($q['p']) != 0) { 732 $q['p'] = (int) $q['p']; 780 if ( $q['p'] ) 733 781 $where = ' AND ID = ' . $q['p']; 734 } 735 736 if (($q['page_id'] != '') && (intval($q['page_id']) != 0)) { 737 $q['page_id'] = intval($q['page_id']); 738 if ( ('page' == get_option('show_on_front') ) && ( $q['page_id'] == get_option('page_for_posts') ) ) { 739 $this->is_singular = false; 740 $this->is_page = false; 741 $this->is_home = true; 742 $this->is_posts_page = true; 743 } else { 782 783 if ( $q['page_id'] ) { 784 if ( ('page' != get_option('show_on_front') ) || ( $q['page_id'] != get_option('page_for_posts') ) ) { 744 785 $q['p'] = $q['page_id']; 745 $where = ' AND ID = ' .$q['page_id'];786 $where = ' AND ID = ' . $q['page_id']; 746 787 } 747 788 } 748 789 749 790 // If a search pattern is specified, load the posts that match 750 if ( !empty($q['s'])) {791 if ( !empty($q['s']) ) { 751 792 // added slashes screw with quote grouping when done early, so done later 752 793 $q['s'] = stripslashes($q['s']); … … 775 816 // Category stuff 776 817 777 if ( (empty($q['cat'])) || ($q['cat'] == '0') ||818 if ( empty($q['cat']) || ($q['cat'] == '0') || 778 819 // Bypass cat checks if fetching specific posts 779 ( $this->is_single || $this->is_page )) {780 $whichcat ='';820 $this->is_singular ) { 821 $whichcat = ''; 781 822 } else { 782 823 $q['cat'] = ''.urldecode($q['cat']).''; … … 787 828 foreach ( $cat_array as $cat ) { 788 829 $cat = intval($cat); 789 $in = strstr($cat, '-') ? false : true;830 $in = (strpos($cat, '-') !== false) ? false : true; 790 831 $cat = trim($cat, '-'); 791 832 if ( $in ) … … 815 856 816 857 // Category stuff for nice URLs 817 if ( '' != $q['category_name']) {858 if ( '' != $q['category_name'] ) { 818 859 $reqcat = get_category_by_path($q['category_name']); 819 860 $q['category_name'] = str_replace('%2F', '/', urlencode(urldecode($q['category_name']))); … … 848 889 } 849 890 891 892 850 893 // Author/user stuff 851 894 852 if ( (empty($q['author'])) || ($q['author'] == '0')) {895 if ( empty($q['author']) || ($q['author'] == '0') ) { 853 896 $whichauthor=''; 854 897 } else { 855 898 $q['author'] = ''.urldecode($q['author']).''; 856 899 $q['author'] = addslashes_gpc($q['author']); 857 if (str istr($q['author'], '-')) {900 if (strpos($q['author'], '-') !== false) { 858 901 $eq = '!='; 859 902 $andor = 'AND'; … … 875 918 876 919 if ('' != $q['author_name']) { 877 if (str istr($q['author_name'],'/')) {920 if (strpos($q['author_name'], '/') !== false) { 878 921 $q['author_name'] = explode('/',$q['author_name']); 879 922 if ($q['author_name'][count($q['author_name'])-1]) { … … 890 933 $where .= $search.$whichcat.$whichauthor; 891 934 892 if ((empty($q['order'])) || ((strtoupper($q['order']) != 'ASC') && (strtoupper($q['order']) != 'DESC'))) { 893 $q['order']='DESC'; 894 } 935 if ( empty($q['order']) || ((strtoupper($q['order']) != 'ASC') && (strtoupper($q['order']) != 'DESC')) ) 936 $q['order'] = 'DESC'; 895 937 896 938 // Order by 897 if ( empty($q['orderby'])) {939 if ( empty($q['orderby']) ) { 898 940 $q['orderby'] = 'post_date '.$q['order']; 899 941 } else { … … 951 993 952 994 // Paging 953 if ( empty($q['nopaging']) && !$this->is_singular) {995 if ( empty($q['nopaging']) && !$this->is_singular ) { 954 996 $page = abs(intval($q['paged'])); 955 997 if (empty($page)) { … … 966 1008 $limits = 'LIMIT ' . $pgstrt . $q['posts_per_page']; 967 1009 } 1010 } 1011 1012 // Comments feeds 1013 if ( $this->is_comment_feed && ( $this->is_archive || $this->is_search || !$this->is_singular ) ) { 1014 if ( $this->is_archive || $this->is_search ) { 1015 $cjoin = "LEFT JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) $join "; 1016 $cwhere = "WHERE comment_approved = '1' $where"; 1017 $cgroupby = "GROUP BY $wpdb->comments.comment_id"; 1018 } else { // Other non singular e.g. front 1019 $cjoin = "LEFT JOIN $wpdb->posts ON ( $wpdb->comments.comment_post_ID = $wpdb->posts.ID )"; 1020 $cwhere = "WHERE post_status = 'publish' AND comment_approved = '1'"; 1021 $cgroupby = ''; 1022 } 1023 1024 $cjoin = apply_filters('comment_feed_join', $cjoin); 1025 $cwhere = apply_filters('comment_feed_where', $cwhere); 1026 $cgroupby = apply_filters('comment_feed_groupby', $cgroupby); 1027 1028 $this->comments = (array) $wpdb->get_results("SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss')); 1029 $this->comment_count = count($this->comments); 1030 1031 $post_ids = array(); 1032 1033 foreach ($this->comments as $comment) 1034 $post_ids[] = (int) $comment->comment_post_ID; 1035 1036 $post_ids = join(',', $post_ids); 1037 $join = ''; 1038 if ( $post_ids ) 1039 $where = "AND $wpdb->posts.ID IN ($post_ids) "; 1040 else 1041 $where = "AND 0"; 968 1042 } 969 1043 … … 987 1061 988 1062 $this->posts = $wpdb->get_results($this->request); 1063 1064 if ( $this->is_comment_feed && $this->is_singular ) { 1065 $cjoin = apply_filters('comment_feed_join', ''); 1066 $cwhere = apply_filters('comment_feed_where', "WHERE comment_post_ID = {$this->posts[0]->ID} AND comment_approved = '1'"); 1067 $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss'); 1068 $this->comments = $wpdb->get_results($comments_request); 1069 $this->comment_count = count($this->comments); 1070 } 1071 989 1072 if ( !empty($limits) ) { 990 1073 $found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' ); … … 993 1076 $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); 994 1077 } 1078 995 1079 // Check post status to determine if post should be displayed. 996 1080 if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) { … … 1073 1157 } 1074 1158 1159 function next_comment() { 1160 $this->current_comment++; 1161 1162 $this->comment = $this->comments[$this->current_comment]; 1163 return $this->comment; 1164 } 1165 1166 function the_comment() { 1167 global $comment; 1168 1169 $comment = $this->next_comment(); 1170 1171 if ($this->current_comment == 0) { 1172 do_action('comment_loop_start'); 1173 } 1174 } 1175 1176 function have_comments() { 1177 if ($this->current_comment + 1 < $this->comment_count) { 1178 return true; 1179 } elseif ($this->current_comment + 1 == $this->comment_count) { 1180 $this->rewind_comments(); 1181 } 1182 1183 return false; 1184 } 1185 1186 function rewind_comments() { 1187 $this->current_comment = -1; 1188 if ($this->comment_count > 0) { 1189 $this->comment = $this->comments[0]; 1190 } 1191 } 1192 1075 1193 function &query($query) { 1076 1194 $this->parse_query($query); … … 1090 1208 $category = &get_category($cat); 1091 1209 $this->queried_object = &$category; 1092 $this->queried_object_id = $cat;1210 $this->queried_object_id = (int) $cat; 1093 1211 } else if ($this->is_posts_page) { 1094 1212 $this->queried_object = & get_page(get_option('page_for_posts')); 1095 $this->queried_object_id = $this->queried_object->ID;1213 $this->queried_object_id = (int) $this->queried_object->ID; 1096 1214 } else if ($this->is_single) { 1097 1215 $this->queried_object = $this->post; 1098 $this->queried_object_id = $this->post->ID;1216 $this->queried_object_id = (int) $this->post->ID; 1099 1217 } else if ($this->is_page) { 1100 1218 $this->queried_object = $this->post; 1101 $this->queried_object_id = $this->post->ID;1219 $this->queried_object_id = (int) $this->post->ID; 1102 1220 } else if ($this->is_author) { 1103 $author_id = $this->get('author');1221 $author_id = (int) $this->get('author'); 1104 1222 $author = get_userdata($author_id); 1105 1223 $this->queried_object = $author; … … 1170 1288 global $pagenow; 1171 1289 1172 $id = $post->ID;1290 $id = (int) $post->ID; 1173 1291 1174 1292 $authordata = get_userdata($post->post_author); -
tags/2.2/wp-includes/registration-functions.php
-
Property
svn:eol-style
set to
native
-
Property
svn:eol-style
set to
-
tags/2.2/wp-includes/rewrite.php
r5468 r5480 51 51 //pseudo-places 52 52 define('EP_NONE', 0 ); 53 define('EP_ALL', 255);53 define('EP_ALL', 4095); 54 54 55 55 //and an endpoint, like /trackback/ … … 63 63 function url_to_postid($url) { 64 64 global $wp_rewrite; 65 66 $url = apply_filters('url_to_postid', $url); 65 67 66 68 // First, check to see if there is a 'p=N' or 'page_id=N' to match against … … 149 151 class WP_Rewrite { 150 152 var $permalink_structure; 153 var $use_trailing_slashes; 151 154 var $category_base; 152 155 var $category_structure; … … 582 585 $rewrite = array_merge($rewrite, array($pagematch => $pagequery)); 583 586 587 //do endpoints 588 if ($endpoints) { 589 foreach ($ep_query_append as $regex => $ep) { 590 //add the endpoints on if the mask fits 591 if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific) { 592 $rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2); 593 } 594 } 595 } 596 584 597 //if we've got some tags in this dir 585 598 if ($num_toks) { … … 591 604 //2) post ID, 3) page name, 4) timestamp (year, month, day, hour, second and 592 605 //minute all present). Set these flags now as we need them for the endpoints. 593 if (str str($struct, '%postname%') || strstr($struct, '%post_id%')594 || str str($struct, '%pagename%')595 || (str str($struct, '%year%') && strstr($struct, '%monthnum%') && strstr($struct, '%day%') && strstr($struct, '%hour%') && strstr($struct, '%minute') && strstr($struct, '%second%'))) {606 if (strpos($struct, '%postname%') !== false || strpos($struct, '%post_id%') !== false 607 || strpos($struct, '%pagename%') !== false 608 || (strpos($struct, '%year%') !== false && strpos($struct, '%monthnum%') !== false && strpos($struct, '%day%') !== false && strpos($struct, '%hour%') !== false && strpos($struct, '%minute%') !== false && strpos($struct, '%second%') !== false)) { 596 609 $post = true; 597 if ( strstr($struct, '%pagename%'))610 if (strpos($struct, '%pagename%') !== false) 598 611 $page = true; 599 }600 601 //do endpoints602 if ($endpoints) {603 foreach ($ep_query_append as $regex => $ep) {604 //add the endpoints on if the mask fits605 if ($ep[0] & $ep_mask || $ep[0] & $ep_mask_specific) {606 $rewrite[$match . $regex] = $index . '?' . $query . $ep[1] . $this->preg_index($num_toks + 2);607 }608 }609 612 } 610 613 … … 809 812 } 810 813 811 if (str str($query, $this->index)) {814 if (strpos($query, $this->index) !== false) { 812 815 $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n"; 813 816 } else { … … 877 880 unset($this->feed_structure); 878 881 unset($this->comment_feed_structure); 882 $this->use_trailing_slashes = ( substr($this->permalink_structure, -1, 1) == '/' ) ? true : false; 879 883 } 880 884 -
tags/2.2/wp-includes/rss-functions.php
-
Property
svn:eol-style
set to
native
-
Property
svn:eol-style
set to
-
tags/2.2/wp-includes/script-loader.php
r5468 r5480 14 14 $this->add( 'fat', '/wp-includes/js/fat.js', false, '1.0-RC1_3660' ); 15 15 $this->add( 'sack', '/wp-includes/js/tw-sack.js', false, '1.6.1' ); 16 $this->add( 'quicktags', '/wp-includes/js/quicktags.js', false, '3517' ); 16 $this->add( 'quicktags', '/wp-includes/js/quicktags.js', false, '3958' ); 17 $this->localize( 'quicktags', 'quicktagsL10n', array( 18 'quickLinks' => __('(Quick Links)'), 19 'wordLookup' => __('Enter a word to look up:'), 20 'dictionaryLookup' => attribute_escape(__('Dictionary lookup')), 21 'lookup' => attribute_escape(__('lookup')), 22 'closeAllOpenTags' => attribute_escape(__('Close all open tags')), 23 'closeTags' => attribute_escape(__('close tags')), 24 'enterURL' => __('Enter the URL'), 25 'enterImageURL' => __('Enter the URL of the image'), 26 'enterImageDescription' => __('Enter a description of the image') 27 ) ); 17 28 $this->add( 'colorpicker', '/wp-includes/js/colorpicker.js', false, '3517' ); 18 $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '200 61113' );29 $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '20070326' ); 19 30 $mce_config = apply_filters('tiny_mce_config_url', '/wp-includes/js/tinymce/tiny_mce_config.php'); 20 31 $this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20070225' ); 21 $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.0'); 22 $this->add( 'autosave', '/wp-includes/js/autosave-js.php', array('prototype', 'sack'), '20070116'); 23 $this->add( 'wp-ajax', '/wp-includes/js/wp-ajax-js.php', array('prototype'), '20070118'); 24 $this->add( 'listman', '/wp-includes/js/list-manipulation-js.php', array('wp-ajax', 'fat'), '20070118'); 25 $this->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.6.1'); 26 $this->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.6.1'); 27 $this->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder'), '1.6.1'); 28 $this->add( 'scriptaculous-effects', '/wp-includes/js/scriptaculous/effects.js', array('scriptaculous-root'), '1.6.1'); 29 $this->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/slider.js', array('scriptaculous-effects'), '1.6.1'); 30 $this->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.6.1'); 31 $this->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.6.1'); 32 $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.0-0'); 33 $this->add( 'autosave', '/wp-includes/js/autosave.js', array('prototype', 'sack'), '20070306'); 34 $this->localize( 'autosave', 'autosaveL10n', array( 35 'autosaveInterval' => apply_filters('autosave_interval', '120'), 36 'errorText' => __('Error: %response%'), 37 'saveText' => __('Saved at %time%.'), 38 'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php', 39 'savingText' => __('Saving Draft...') 40 ) ); 41 $this->add( 'wp-ajax', '/wp-includes/js/wp-ajax.js', array('prototype'), '20070306'); 42 $this->localize( 'wp-ajax', 'WPAjaxL10n', array( 43 'defaultUrl' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php', 44 'permText' => __("You don't have permission to do that."), 45 'strangeText' => __("Something strange happened. Try refreshing the page."), 46 'whoaText' => __("Slow down, I'm still sending your data!") 47 ) ); 48 $this->add( 'listman', '/wp-includes/js/list-manipulation.js', array('wp-ajax', 'fat'), '20070306' ); 49 $this->localize( 'listman', 'listManL10n', array( 50 'jumpText' => __('Jump to new item'), 51 'delText' => __('Are you sure you want to delete this %thing%?') 52 ) ); 53 $this->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.7.0'); 54 $this->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.7.0'); 55 $this->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder', 'scriptaculous-effects'), '1.7.0'); 56 $this->add( 'scriptaculous-effects', '/wp-includes/js/scriptaculous/effects.js', array('scriptaculous-root'), '1.7.0'); 57 $this->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/slider.js', array('scriptaculous-effects'), '1.7.0'); 58 $this->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.7.0'); 59 $this->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.7.0'); 32 60 $this->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop'), '20070118'); 61 $this->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.1.2'); 62 $this->add( 'interface', '/wp-includes/js/jquery/interface.js', array('jquery'), '1.2'); 33 63 if ( is_admin() ) { 34 $this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key-js.php', array('dbx'), '3651' ); 35 $this->add( 'ajaxcat', '/wp-admin/cat-js.php', array('listman'), '20070118' ); 64 global $pagenow; 65 $man = false; 66 switch ( $pagenow ) : 67 case 'post.php' : 68 case 'post-new.php' : 69 $man = 'postmeta'; 70 break; 71 case 'page.php' : 72 case 'page-new.php' : 73 $man = 'pagemeta'; 74 break; 75 case 'link-add.php' : 76 case 'link.php' : 77 $man = 'linkmeta'; 78 break; 79 endswitch; 80 if ( $man ) { 81 $this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key.js', array('dbx'), '20070417' ); 82 $this->localize( 'dbx-admin-key', 'dbxL10n', array( 83 'manager' => $man, 84 'open' => __('open'), 85 'close' => __('close'), 86 'moveMouse' => __('click-down and drag to move this box'), 87 'toggleMouse' => __('click to %toggle% this box'), 88 'moveKey' => __('use the arrow keys to move this box'), 89 'toggleKey' => __(', or press the enter key to %toggle% it'), 90 ) ); 91 } 92 $this->add( 'ajaxcat', '/wp-admin/cat.js', array('listman'), '20070417' ); 93 $this->localize( 'ajaxcat', 'catL10n', array( 94 'add' => attribute_escape(__('Add')), 95 'how' => __('Separate multiple categories with commas.') 96 ) ); 36 97 $this->add( 'admin-categories', '/wp-admin/categories.js', array('listman'), '3684' ); 37 98 $this->add( 'admin-custom-fields', '/wp-admin/custom-fields.js', array('listman'), '3733' ); 38 $this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), ' 3847' );99 $this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '20070327' ); 39 100 $this->add( 'admin-users', '/wp-admin/users.js', array('listman'), '4583' ); 40 101 $this->add( 'xfn', '/wp-admin/xfn.js', false, '3517' ); 41 $this->add( 'upload', '/wp-admin/upload-js.php', array('prototype'), '20070118' ); 102 $this->add( 'upload', '/wp-admin/upload.js', array('prototype'), '20070306' ); 103 $this->localize( 'upload', 'uploadL10n', array( 104 'browseTitle' => attribute_escape(__('Browse your files')), 105 'back' => __('« Back'), 106 'directTitle' => attribute_escape(__('Direct link to file')), 107 'edit' => __('Edit'), 108 'thumb' => __('Thumbnail'), 109 'full' => __('Full size'), 110 'icon' => __('Icon'), 111 'title' => __('Title'), 112 'show' => __('Show:'), 113 'link' => __('Link to:'), 114 'file' => __('File'), 115 'page' => __('Page'), 116 'none' => __('None'), 117 'editorText' => attribute_escape(__('Send to editor »')), 118 'insert' => __('Insert'), 119 'urlText' => __('URL'), 120 'desc' => __('Description'), 121 'deleteText' => attribute_escape(__('Delete File')), 122 'saveText' => attribute_escape(__('Save »')), 123 'confirmText' => __("Are you sure you want to delete the file '%title%'?\nClick ok to delete or cancel to go back.") 124 ) ); 42 125 } 43 126 } … … 79 162 $ver .= '&' . $this->args[$handle]; 80 163 $src = 0 === strpos($this->scripts[$handle]->src, 'http://') ? $this->scripts[$handle]->src : get_option( 'siteurl' ) . $this->scripts[$handle]->src; 81 $src = clean_url(add_query_arg('ver', $ver, $src)); 164 $src = $this->scripts[$handle]->src; 165 166 if (!preg_match('|^https?://|', $src)) { 167 $src = get_option('siteurl') . $src; 168 } 169 170 $src = add_query_arg('ver', $ver, $src); 171 $src = clean_url(apply_filters( 'script_loader_src', $src )); 82 172 echo "<script type='text/javascript' src='$src'></script>\n"; 173 $this->print_scripts_l10n( $handle ); 83 174 } 84 175 $this->printed[] = $handle; … … 87 178 } 88 179 180 function print_scripts_l10n( $handle ) { 181 if ( empty($this->scripts[$handle]->l10n_object) || empty($this->scripts[$handle]->l10n) || !is_array($this->scripts[$handle]->l10n) ) 182 return; 183 184 $object_name = $this->scripts[$handle]->l10n_object; 185 186 echo "<script type='text/javascript'>\n"; 187 echo "/* <![CDATA[ */\n"; 188 echo "\t$object_name = {\n"; 189 $eol = ''; 190 foreach ( $this->scripts[$handle]->l10n as $var => $val ) { 191 echo "$eol\t\t$var: \"" . js_escape( $val ) . '"'; 192 $eol = ",\n"; 193 } 194 echo "\n\t}\n"; 195 echo "/* ]]> */\n"; 196 echo "</script>\n"; 197 } 89 198 90 199 /** … … 138 247 } 139 248 249 /** 250 * Localizes a script 251 * 252 * Localizes only if script has already been added 253 * 254 * @param string handle Script name 255 * @param string object_name Name of JS object to hold l10n info 256 * @param array l10n Array of JS var name => localized string 257 * @return bool Successful localization 258 */ 259 function localize( $handle, $object_name, $l10n ) { 260 if ( !isset($this->scripts[$handle]) ) 261 return false; 262 return $this->scripts[$handle]->localize( $object_name, $l10n ); 263 } 264 140 265 function remove( $handles ) { 141 266 foreach ( (array) $handles as $handle ) … … 180 305 var $deps = array(); 181 306 var $ver = false; 182 var $args = false; 307 var $l10n_object = ''; 308 var $l10n = array(); 183 309 184 310 function _WP_Script() { … … 189 315 $this->ver = false; 190 316 } 317 318 function localize( $object_name, $l10n ) { 319 if ( !$object_name || !is_array($l10n) ) 320 return false; 321 $this->l10n_object = $object_name; 322 $this->l10n = $l10n; 323 return true; 324 } 191 325 } 192 326 … … 225 359 } 226 360 361 /** 362 * Localizes a script 363 * 364 * Localizes only if script has already been added 365 * 366 * @see WP_Script::localize() 367 */ 368 function wp_localize_script( $handle, $object_name, $l10n ) { 369 global $wp_scripts; 370 if ( !is_a($wp_scripts, 'WP_Scripts') ) 371 return false; 372 373 return $wp_scripts->localize( $handle, $object_name, $l10n ); 374 } 375 227 376 function wp_deregister_script( $handle ) { 228 377 global $wp_scripts; -
tags/2.2/wp-includes/template-loader.php
r5468 r5480 4 4 if ( is_robots() ) { 5 5 do_action('do_robots'); 6 exit;6 return; 7 7 } else if ( is_feed() ) { 8 8 do_feed(); 9 exit;9 return; 10 10 } else if ( is_trackback() ) { 11 11 include(ABSPATH . '/wp-trackback.php'); 12 exit;12 return; 13 13 } else if ( is_404() && $template = get_404_template() ) { 14 14 include($template); 15 exit;15 return; 16 16 } else if ( is_search() && $template = get_search_template() ) { 17 17 include($template); 18 exit;18 return; 19 19 } else if ( is_home() && $template = get_home_template() ) { 20 20 include($template); 21 exit;21 return; 22 22 } else if ( is_attachment() && $template = get_attachment_template() ) { 23 23 include($template); 24 exit;24 return; 25 25 } else if ( is_single() && $template = get_single_template() ) { 26 26 if ( is_attachment() ) 27 27 add_filter('the_content', 'prepend_attachment'); 28 28 include($template); 29 exit;29 return; 30 30 } else if ( is_page() && $template = get_page_template() ) { 31 31 if ( is_attachment() ) 32 32 add_filter('the_content', 'prepend_attachment'); 33 33 include($template); 34 exit;34 return; 35 35 } else if ( is_category() && $template = get_category_template()) { 36 36 include($template); 37 exit;37 return; 38 38 } else if ( is_author() && $template = get_author_template() ) { 39 39 include($template); 40 exit;40 return; 41 41 } else if ( is_date() && $template = get_date_template() ) { 42 42 include($template); 43 exit;43 return; 44 44 } else if ( is_archive() && $template = get_archive_template() ) { 45 45 include($template); 46 exit;46 return; 47 47 } else if ( is_comments_popup() && $template = get_comments_popup_template() ) { 48 48 include($template); 49 exit;49 return; 50 50 } else if ( is_paged() && $template = get_paged_template() ) { 51 51 include($template); 52 exit;52 return; 53 53 } else if ( file_exists(TEMPLATEPATH . "/index.php") ) { 54 54 if ( is_attachment() ) 55 55 add_filter('the_content', 'prepend_attachment'); 56 56 include(TEMPLATEPATH . "/index.php"); 57 exit;57 return; 58 58 } 59 59 } else { … … 61 61 if ( is_robots() ) { 62 62 do_action('do_robots'); 63 exit;63 return; 64 64 } else if ( is_feed() ) { 65 65 do_feed(); 66 exit;66 return; 67 67 } else if ( is_trackback() ) { 68 68 include(ABSPATH . '/wp-trackback.php'); 69 exit;69 return; 70 70 } 71 71 } -
tags/2.2/wp-includes/theme.php
r5468 r5480 79 79 $name = trim( $name ); 80 80 $theme = $name; 81 $theme_uri = trim( $theme_uri[1] ); 81 82 82 83 if ( '' == $author_uri[1] ) { … … 86 87 } 87 88 88 return array( 'Name' => $name, 'Title' => $theme, ' Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1], 'Status' => $status );89 return array( 'Name' => $name, 'Title' => $theme, 'URI' => $theme_uri, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1], 'Status' => $status ); 89 90 } 90 91 … … 163 164 $stylesheet = dirname($theme_file); 164 165 166 $screenshot = false; 165 167 foreach ( array('png', 'gif', 'jpg', 'jpeg') as $ext ) { 166 168 if (file_exists("$theme_root/$stylesheet/screenshot.$ext")) { … … 187 189 $parent_dir = dirname(dirname($theme_file)); 188 190 if ( file_exists("$theme_root/$parent_dir/$template/index.php") ) { 189 $template = "$parent_dir/$template"; 191 $template = "$parent_dir/$template"; 190 192 } else { 191 193 $wp_broken_themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => __('Template is missing.')); … … 441 443 442 444 if ( isset($mods[$name]) ) 443 return $mods[$name];444 445 return sprintf($default, get_template_directory_uri());445 return apply_filters( "theme_mod_$name", $mods[$name] ); 446 447 return apply_filters( "theme_mod_$name", sprintf($default, get_template_directory_uri()) ); 446 448 } 447 449 … … 485 487 486 488 function header_textcolor() { 487 echo get_header_textcolor(); 489 echo get_header_textcolor(); 488 490 } 489 491 … … 493 495 494 496 function header_image() { 495 echo get_header_image(); 497 echo get_header_image(); 496 498 } 497 499 -
tags/2.2/wp-includes/user.php
r5468 r5480 11 11 global $wpdb; 12 12 $userid = (int) $userid; 13 return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$userid' AND post_type = 'post' AND post_status = 'publish'");13 return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$userid' AND post_type = 'post' AND " . get_private_posts_cap_sql('post')); 14 14 } 15 15 … … 50 50 $option_name = $wpdb->prefix . $option_name; 51 51 return update_usermeta( $user_id, $option_name, $newvalue ); 52 } 53 54 // Get users with capabilities for the current blog. 55 // For setups that use the multi-blog feature. 56 function get_users_of_blog( $id = '' ) { 57 global $wpdb, $blog_id; 58 if ( empty($id) ) 59 $id = (int) $blog_id; 60 $users = $wpdb->get_results( "SELECT user_id, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE " . $wpdb->users . ".ID = " . $wpdb->usermeta . ".user_id AND meta_key = '" . $wpdb->prefix . "capabilities' ORDER BY {$wpdb->usermeta}.user_id" ); 61 return $users; 52 62 } 53 63 -
tags/2.2/wp-includes/vars.php
r5468 r5480 14 14 15 15 // Simple browser detection 16 // We should probably be doing true/false instead of 1/0 here ~ Mark 17 $is_lynx = 0; $is_gecko = 0; $is_winIE = 0; $is_macIE = 0; $is_opera = 0; $is_NS4 = 0; 16 $is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = false; 18 17 19 if ( preg_match('/Lynx/', $_SERVER['HTTP_USER_AGENT']) ) 20 $is_lynx = 1; 21 elseif ( preg_match('/Gecko/', $_SERVER['HTTP_USER_AGENT']) ) 22 $is_gecko = 1; 23 elseif ( preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT']) && preg_match('/Win/', $_SERVER['HTTP_USER_AGENT']) ) 24 $is_winIE = 1; 25 elseif ( preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT']) && preg_match('/Mac/', $_SERVER['HTTP_USER_AGENT']) ) 26 $is_macIE = 1; 27 elseif ( preg_match('/Opera/', $_SERVER['HTTP_USER_AGENT']) ) 28 $is_opera = 1; 29 elseif ( preg_match('/Nav/', $_SERVER['HTTP_USER_AGENT']) || preg_match('/Mozilla\/4\./', $_SERVER['HTTP_USER_AGENT']) ) 30 $is_NS4 = 1; 18 if (strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false) { 19 $is_lynx = true; 20 } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false) { 21 $is_gecko = true; 22 } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Win') !== false) { 23 $is_winIE = true; 24 } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) { 25 $is_macIE = true; 26 } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false) { 27 $is_opera = true; 28 } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Nav') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.') !== false) { 29 $is_NS4 = true; 30 } 31 31 32 32 $is_IE = ( $is_macIE || $is_winIE ); 33 33 34 34 // Server detection 35 $is_apache = ( strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') || strstr($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') ) ? 1 : 0; 36 $is_IIS = strstr($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') ? 1 : 0; 37 38 // if the config file does not provide the smilies array, let's define it here 39 if (!isset($wpsmiliestrans)) { 40 $wpsmiliestrans = array( 41 ':mrgreen:' => 'icon_mrgreen.gif', 42 ':neutral:' => 'icon_neutral.gif', 43 ':twisted:' => 'icon_twisted.gif', 44 ':arrow:' => 'icon_arrow.gif', 45 ':shock:' => 'icon_eek.gif', 46 ':smile:' => 'icon_smile.gif', 47 ':???:' => 'icon_confused.gif', 48 ':cool:' => 'icon_cool.gif', 49 ':evil:' => 'icon_evil.gif', 50 ':grin:' => 'icon_biggrin.gif', 51 ':idea:' => 'icon_idea.gif', 52 ':oops:' => 'icon_redface.gif', 53 ':razz:' => 'icon_razz.gif', 54 ':roll:' => 'icon_rolleyes.gif', 55 ':wink:' => 'icon_wink.gif', 56 ':cry:' => 'icon_cry.gif', 57 ':eek:' => 'icon_surprised.gif', 58 ':lol:' => 'icon_lol.gif', 59 ':mad:' => 'icon_mad.gif', 60 ':sad:' => 'icon_sad.gif', 61 '8-)' => 'icon_cool.gif', 62 '8-O' => 'icon_eek.gif', 63 ':-(' => 'icon_sad.gif', 64 ':-)' => 'icon_smile.gif', 65 ':-?' => 'icon_confused.gif', 66 ':-D' => 'icon_biggrin.gif', 67 ':-P' => 'icon_razz.gif', 68 ':-o' => 'icon_surprised.gif', 69 ':-x' => 'icon_mad.gif', 70 ':-|' => 'icon_neutral.gif', 71 ';-)' => 'icon_wink.gif', 72 '8)' => 'icon_cool.gif', 73 '8O' => 'icon_eek.gif', 74 ':(' => 'icon_sad.gif', 75 ':)' => 'icon_smile.gif', 76 ':?' => 'icon_confused.gif', 77 ':D' => 'icon_biggrin.gif', 78 ':P' => 'icon_razz.gif', 79 ':o' => 'icon_surprised.gif', 80 ':x' => 'icon_mad.gif', 81 ':|' => 'icon_neutral.gif', 82 ';)' => 'icon_wink.gif', 83 ':!:' => 'icon_exclaim.gif', 84 ':?:' => 'icon_question.gif', 85 ); 86 } 87 88 // generates smilies' search & replace arrays 89 foreach ( (array) $wpsmiliestrans as $smiley => $img ) { 90 $wp_smiliessearch[] = '/(\s|^)'.preg_quote($smiley, '/').'(\s|$)/'; 91 $smiley_masked = htmlspecialchars(trim($smiley), ENT_QUOTES); 92 $wp_smiliesreplace[] = " <img src='" . get_option('siteurl') . "/wp-includes/images/smilies/$img' alt='$smiley_masked' class='wp-smiley' /> "; 93 } 35 $is_apache = ((strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) || (strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false)) ? true : false; 36 $is_IIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false) ? true : false; 94 37 95 38 ?> -
tags/2.2/wp-includes/version.php
r5468 r5480 3 3 // This holds the version number in a separate file so we can bump it without cluttering the SVN 4 4 5 $wp_version = '2. 1.3';6 $wp_db_version = 4773;5 $wp_version = '2.2'; 6 $wp_db_version = 5183; 7 7 8 8 ?> -
tags/2.2/wp-includes/wp-db.php
r5468 r5480 36 36 var $postmeta; 37 37 38 var $charset; 39 var $collate; 40 38 41 /** 39 42 * Connects to the database server and selects a database … … 46 49 return $this->__construct($dbuser, $dbpassword, $dbname, $dbhost); 47 50 } 48 51 49 52 function __construct($dbuser, $dbpassword, $dbname, $dbhost) { 50 53 register_shutdown_function(array(&$this, "__destruct")); 54 55 if ( defined('DB_CHARSET') ) 56 $this->charset = DB_CHARSET; 57 58 if ( defined('DB_COLLATE') ) 59 $this->collate = DB_COLLATE; 51 60 52 61 $this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword); … … 64 73 } 65 74 75 if ( !empty($this->charset) && version_compare(mysql_get_server_info(), '4.1.0', '>=') ) 76 $this->query("SET NAMES '$this->charset'"); 77 66 78 $this->select($dbname); 67 79 } 68 80 69 81 function __destruct() { 70 return true; 82 return true; 71 83 } 72 84 … … 170 182 $this->result = @mysql_query($query, $this->dbh); 171 183 ++$this->num_queries; 172 184 173 185 if (SAVEQUERIES) 174 186 $this->queries[] = array( $query, $this->timer_stop() ); … … 181 193 182 194 if ( preg_match("/^\\s*(insert|delete|update|replace) /i",$query) ) { 183 $this->rows_affected = mysql_affected_rows( );195 $this->rows_affected = mysql_affected_rows($this->dbh); 184 196 // Take note of the insert_id 185 197 if ( preg_match("/^\\s*(insert|replace) /i",$query) ) { … … 244 256 if ( $query ) 245 257 $this->query($query); 246 258 247 259 if ( !isset($this->last_result[$y]) ) 248 260 return null; … … 361 373 header('Content-Type: text/html; charset=utf-8'); 362 374 363 if ( strstr($_SERVER['PHP_SELF'], 'wp-admin'))375 if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) 364 376 $admin_dir = ''; 365 377 else -
tags/2.2/wp-links-opml.php
r5468 r5480 18 18 <opml version="1.0"> 19 19 <head> 20 <title>Links for <?php echo get_bloginfo('name').$cat_name?></title>20 <title>Links for <?php echo attribute_escape(get_bloginfo('name').$cat_name); ?></title> 21 21 <dateCreated><?php echo gmdate("D, d M Y H:i:s"); ?> GMT</dateCreated> 22 22 </head> … … 30 30 31 31 foreach ((array) $cats as $cat) { 32 $catname = apply_filters('link_category', $cat->cat_name); 33 32 34 ?> 33 <outline type="category" title="<?php echo attribute_escape($cat ->cat_name); ?>">35 <outline type="category" title="<?php echo attribute_escape($catname); ?>"> 34 36 <?php 35 37 36 38 $bookmarks = get_bookmarks("category={$cat->cat_ID}"); 37 39 foreach ((array) $bookmarks as $bookmark) { 40 $title = attribute_escape(apply_filters('link_title', $bookmark->link_name)); 38 41 ?> 39 <outline text="<?php echo attribute_escape($bookmark->link_name); ?>" type="link" xmlUrl="<?php echo attribute_escape($bookmark->link_rss); ?>" htmlUrl="<?php echo attribute_escape($bookmark->link_url); ?>" updated="<?php if ('0000-00-00 00:00:00' != $bookmark->link_updated) echo $bookmark->link_updated; ?>" />42 <outline text="<?php echo $title; ?>" type="link" xmlUrl="<?php echo attribute_escape($bookmark->link_rss); ?>" htmlUrl="<?php echo attribute_escape($bookmark->link_url); ?>" updated="<?php if ('0000-00-00 00:00:00' != $bookmark->link_updated) echo $bookmark->link_updated; ?>" /> 40 43 <?php 41 44 -
tags/2.2/wp-login.php
r5468 r5480 47 47 <body class="login"> 48 48 49 <div id="login"><h1><a href="<?php echo apply_filters('login_headerurl', 'http://wordpress.org/'); ?>" title="<?php echo apply_filters('login_headertitle', __('Powered by WordPress')); ?>">< span class="hide"><?php bloginfo('name'); ?></span></a></h1>49 <div id="login"><h1><a href="<?php echo apply_filters('login_headerurl', 'http://wordpress.org/'); ?>" title="<?php echo apply_filters('login_headertitle', __('Powered by WordPress')); ?>"><?php bloginfo('name'); ?></a></h1> 50 50 <?php 51 51 if ( !empty( $message ) ) echo apply_filters('login_message', $message) . "\n"; … … 97 97 98 98 do_action('lostpassword_post'); 99 99 100 100 if ( empty( $errors ) ) { 101 101 $user_data = get_userdatabylogin(trim($_POST['user_login'])); … … 146 146 </p> 147 147 <?php do_action('lostpassword_form'); ?> 148 <p class="submit"><input type="submit" name=" submit" id="submit" value="<?php _e('Get New Password »'); ?>" tabindex="100" /></p>148 <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" value="<?php _e('Get New Password »'); ?>" tabindex="100" /></p> 149 149 </form> 150 150 </div> … … 154 154 <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li> 155 155 <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=register"><?php _e('Register') ?></a></li> 156 <li><a href="<?php bloginfo(' home'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('Back to %s'), get_bloginfo('title')); ?></a></li>156 <li><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('Back to %s'), get_bloginfo('title')); ?></a></li> 157 157 <?php else : ?> 158 <li><a href="<?php bloginfo(' home'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('Back to %s'), get_bloginfo('title')); ?></a></li>158 <li><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('Back to %s'), get_bloginfo('title')); ?></a></li> 159 159 <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li> 160 160 <?php endif; ?> … … 195 195 } else { 196 196 // send a copy of password change notification to the admin 197 $message = sprintf(__('Password Lost and Changed for user: %s'), $user->user_login) . "\r\n"; 198 wp_mail(get_option('admin_email'), sprintf(__('[%s] Password Lost/Changed'), get_option('blogname')), $message); 197 // but check to see if it's the admin whose password we're changing, and skip this 198 if ($user->user_email != get_option('admin_email')) { 199 $message = sprintf(__('Password Lost and Changed for user: %s'), $user->user_login) . "\r\n"; 200 wp_mail(get_option('admin_email'), sprintf(__('[%s] Password Lost/Changed'), get_option('blogname')), $message); 201 } 199 202 200 203 wp_redirect('wp-login.php?checkemail=newpass'); … … 266 269 <?php do_action('register_form'); ?> 267 270 <p id="reg_passmail"><?php _e('A password will be e-mailed to you.') ?></p> 268 <p class="submit"><input type="submit" name=" submit" id="submit" value="<?php _e('Register »'); ?>" tabindex="100" /></p>271 <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" value="<?php _e('Register »'); ?>" tabindex="100" /></p> 269 272 </form> 270 273 </div> … … 273 276 <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a></li> 274 277 <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=lostpassword" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a></li> 275 <li><a href="<?php bloginfo(' home'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('Back to %s'), get_bloginfo('title')); ?></a></li>278 <li><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('Back to %s'), get_bloginfo('title')); ?></a></li> 276 279 </ul> 277 280 … … 326 329 } 327 330 } 328 331 329 332 if ( $_POST && empty( $user_login ) ) 330 333 $errors['user_login'] = __('<strong>ERROR</strong>: The username field is empty.'); … … 354 357 <p><label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90" /> <?php _e('Remember me'); ?></label></p> 355 358 <p class="submit"> 356 <input type="submit" name=" submit" id="submit" value="<?php _e('Login'); ?> »" tabindex="100" />359 <input type="submit" name="wp-submit" id="wp-submit" value="<?php _e('Login'); ?> »" tabindex="100" /> 357 360 <input type="hidden" name="redirect_to" value="<?php echo attribute_escape($redirect_to); ?>" /> 358 361 </p> … … 364 367 <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=register"><?php _e('Register') ?></a></li> 365 368 <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=lostpassword" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a></li> 366 <li><a href="<?php bloginfo(' home'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('Back to %s'), get_bloginfo('title')); ?></a></li>369 <li><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('Back to %s'), get_bloginfo('title')); ?></a></li> 367 370 <?php else : ?> 368 <li><a href="<?php bloginfo(' home'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('Back to %s'), get_bloginfo('title')); ?></a></li>371 <li><a href="<?php bloginfo('url'); ?>/" title="<?php _e('Are you lost?') ?>"><?php printf(__('Back to %s'), get_bloginfo('title')); ?></a></li> 369 372 <li><a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=lostpassword" title="<?php _e('Password Lost and Found') ?>"><?php _e('Lost your password?') ?></a></li> 370 373 <?php endif; ?> -
tags/2.2/wp-mail.php
r5468 r5480 25 25 $content = ''; 26 26 $content_type = ''; 27 $content_transfer_encoding = ''; 27 28 $boundary = ''; 28 29 $bodysignal = 0; 29 $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 30 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); 30 $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); 31 31 foreach ($message as $line) : 32 32 if (strlen($line) < 3) $bodysignal = 1; … … 40 40 $content_type = explode(';', $content_type); 41 41 $content_type = $content_type[0]; 42 } 43 if (preg_match('/Content-Transfer-Encoding: /i', $line)) { 44 $content_transfer_encoding = trim($line); 45 $content_transfer_encoding = substr($content_transfer_encoding, 27, strlen($content_transfer_encoding)-14); 46 $content_transfer_encoding = explode(';', $content_transfer_encoding); 47 $content_transfer_encoding = $content_transfer_encoding[0]; 42 48 } 43 49 if (($content_type == 'multipart/alternative') && (preg_match('/boundary="/', $line)) && ($boundary == '')) { … … 57 63 // Set the author using the email address (To or Reply-To, the last used) 58 64 // otherwise use the site admin 59 if (preg_match('/From: /', $line) | preg_match(' Reply-To: /', $line)) {65 if (preg_match('/From: /', $line) | preg_match('/Reply-To: /', $line)) { 60 66 $author=trim($line); 61 67 if ( ereg("([a-zA-Z0-9\_\-\.]+@[\a-zA-z0-9\_\-\.]+)", $author , $regs) ) { … … 112 118 } 113 119 $content = trim($content); 120 121 if (stripos($content_transfer_encoding, "quoted-printable") !== false) { 122 $content = quoted_printable_decode($content); 123 } 124 114 125 // Captures any text in the body after $phone_delim as the body 115 126 $content = explode($phone_delim, $content); 116 127 $content[1] ? $content = $content[1] : $content = $content[0]; 117 128 118 echo "<p><b>Content-type:</b> $content_type, <b> boundary:</b> $boundary</p>\n";129 echo "<p><b>Content-type:</b> $content_type, <b>Content-Transfer-Encoding:</b> $content_transfer_encoding, <b>boundary:</b> $boundary</p>\n"; 119 130 echo "<p><b>Raw content:</b><br /><pre>".$content.'</pre></p>'; 120 131 -
tags/2.2/wp-rdf.php
r5468 r5480 6 6 } 7 7 8 header('Content-type: application/rdf+xml; charset=' . get_option('blog_charset'), true); 9 $more = 1; 8 require (ABSPATH . WPINC . '/feed-rdf.php'); 10 9 11 10 ?> 12 <?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>13 <!-- generator="wordpress/<?php echo $wp_version ?>" -->14 <rdf:RDF15 xmlns="http://purl.org/rss/1.0/"16 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"17 xmlns:dc="http://purl.org/dc/elements/1.1/"18 xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"19 xmlns:admin="http://webns.net/mvcb/"20 xmlns:content="http://purl.org/rss/1.0/modules/content/"21 <?php do_action('rdf_ns'); ?>22 >23 <channel rdf:about="<?php bloginfo_rss("url") ?>">24 <title><?php bloginfo_rss('name') ?></title>25 <link><?php bloginfo_rss('url') ?></link>26 <description><?php bloginfo_rss('description') ?></description>27 <dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></dc:date>28 <admin:generatorAgent rdf:resource="http://wordpress.org/?v=<?php echo $wp_version ?>"/>29 <sy:updatePeriod>hourly</sy:updatePeriod>30 <sy:updateFrequency>1</sy:updateFrequency>31 <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>32 <?php do_action('rdf_header'); ?>33 <items>34 <rdf:Seq>35 <?php while (have_posts()): the_post(); ?>36 <rdf:li rdf:resource="<?php permalink_single_rss() ?>"/>37 <?php endwhile; ?>38 </rdf:Seq>39 </items>40 </channel>41 <?php rewind_posts(); while (have_posts()): the_post(); ?>42 <item rdf:about="<?php permalink_single_rss() ?>">43 <title><?php the_title_rss() ?></title>44 <link><?php permalink_single_rss() ?></link>45 <dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', $post->post_date_gmt, false); ?></dc:date>46 <dc:creator><?php the_author() ?></dc:creator>47 <?php the_category_rss('rdf') ?>48 <?php if (get_option('rss_use_excerpt')) : ?>49 <description><?php the_excerpt_rss() ?></description>50 <?php else : ?>51 <description><?php the_content_rss('', 0, '', get_option('rss_excerpt_length'), 2) ?></description>52 <content:encoded><![CDATA[<?php the_content('', 0, '') ?>]]></content:encoded>53 <?php endif; ?>54 <?php do_action('rdf_item'); ?>55 </item>56 <?php endwhile; ?>57 </rdf:RDF> -
tags/2.2/wp-rss.php
r5468 r5480 6 6 } 7 7 8 header('Content-type: text/xml; charset=' . get_option('blog_charset'), true); 9 $more = 1; 8 require (ABSPATH . WPINC . '/feed-rss.php'); 10 9 11 10 ?> 12 <?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>13 <!-- generator="wordpress/<?php echo $wp_version ?>" -->14 <rss version="0.92">15 <channel>16 <title><?php bloginfo_rss('name') ?></title>17 <link><?php bloginfo_rss('url') ?></link>18 <description><?php bloginfo_rss('description') ?></description>19 <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>20 <docs>http://backend.userland.com/rss092</docs>21 <language><?php echo get_option('rss_language'); ?></language>22 <?php do_action('rss_head'); ?>23 24 <?php while (have_posts()) : the_post(); ?>25 <item>26 <title><?php the_title_rss() ?></title>27 <?php if (get_option('rss_use_excerpt')) { ?>28 <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>29 <?php } else { // use content ?>30 <description><?php the_content_rss('', 0, '', get_option('rss_excerpt_length')) ?></description>31 <?php } ?>32 <link><?php permalink_single_rss() ?></link>33 <?php do_action('rss_item'); ?>34 </item>35 <?php endwhile; ?>36 </channel>37 </rss> -
tags/2.2/wp-rss2.php
r5468 r5480 6 6 } 7 7 8 header('Content-type: text/xml; charset=' . get_option('blog_charset'), true); 9 $more = 1; 8 require (ABSPATH . WPINC . '/feed-rss2.php'); 10 9 11 10 ?> 12 <?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>13 14 <!-- generator="wordpress/<?php bloginfo_rss('version') ?>" -->15 <rss version="2.0"16 xmlns:content="http://purl.org/rss/1.0/modules/content/"17 xmlns:wfw="http://wellformedweb.org/CommentAPI/"18 xmlns:dc="http://purl.org/dc/elements/1.1/"19 <?php do_action('rss2_ns'); ?>20 >21 22 <channel>23 <title><?php bloginfo_rss('name'); ?></title>24 <link><?php bloginfo_rss('url') ?></link>25 <description><?php bloginfo_rss("description") ?></description>26 <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></pubDate>27 <generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>28 <language><?php echo get_option('rss_language'); ?></language>29 <?php do_action('rss2_head'); ?>30 <?php while( have_posts()) : the_post(); ?>31 <item>32 <title><?php the_title_rss() ?></title>33 <link><?php permalink_single_rss() ?></link>34 <comments><?php comments_link(); ?></comments>35 <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>36 <dc:creator><?php the_author() ?></dc:creator>37 <?php the_category_rss() ?>38 39 <guid isPermaLink="false"><?php the_guid(); ?></guid>40 <?php if (get_option('rss_use_excerpt')) : ?>41 <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>42 <?php else : ?>43 <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>44 <?php if ( strlen( $post->post_content ) > 0 ) : ?>45 <content:encoded><![CDATA[<?php the_content() ?>]]></content:encoded>46 <?php else : ?>47 <content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>48 <?php endif; ?>49 <?php endif; ?>50 <wfw:commentRss><?php echo comments_rss(); ?></wfw:commentRss>51 <?php rss_enclosure(); ?>52 <?php do_action('rss2_item'); ?>53 </item>54 <?php endwhile; ?>55 </channel>56 </rss> -
tags/2.2/wp-settings.php
r5468 r5480 41 41 42 42 // Fix for Dreamhost and other PHP as CGI hosts 43 if ( strstr( $_SERVER['SCRIPT_NAME'], 'php.cgi' ))43 if (strpos($_SERVER['SCRIPT_NAME'], 'php.cgi') !== false) 44 44 unset($_SERVER['PATH_INFO']); 45 45 … … 123 123 $wpdb->usermeta = CUSTOM_USER_META_TABLE; 124 124 125 // To be removed in 2.2126 $tableposts = $tableusers = $tablecategories = $tablepost2cat = $tablecomments = $tablelink2cat = $tablelinks = $tablelinkcategories = $tableoptions = $tablepostmeta = '';127 128 125 if ( file_exists(ABSPATH . 'wp-content/object-cache.php') ) 129 126 require (ABSPATH . 'wp-content/object-cache.php'); … … 134 131 135 132 require (ABSPATH . WPINC . '/functions.php'); 133 require (ABSPATH . WPINC . '/classes.php'); 136 134 require (ABSPATH . WPINC . '/plugin.php'); 137 135 require (ABSPATH . WPINC . '/default-filters.php'); … … 140 138 require_once (ABSPATH . WPINC . '/l10n.php'); 141 139 142 if ( !is_blog_installed() && ( !strstr($_SERVER['PHP_SELF'], 'install.php')&& !defined('WP_INSTALLING')) ) {143 if ( strstr($_SERVER['PHP_SELF'], 'wp-admin'))140 if ( !is_blog_installed() && (strpos($_SERVER['PHP_SELF'], 'install.php') === false && !defined('WP_INSTALLING')) ) { 141 if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) 144 142 $link = 'install.php'; 145 143 else … … 150 148 require (ABSPATH . WPINC . '/formatting.php'); 151 149 require (ABSPATH . WPINC . '/capabilities.php'); 152 require (ABSPATH . WPINC . '/classes.php');153 150 require (ABSPATH . WPINC . '/query.php'); 154 151 require (ABSPATH . WPINC . '/theme.php'); … … 173 170 require (ABSPATH . WPINC . '/script-loader.php'); 174 171 175 if ( !strstr($_SERVER['PHP_SELF'], 'install.php')) :172 if (strpos($_SERVER['PHP_SELF'], 'install.php') === false) { 176 173 // Used to guarantee unique hash cookies 177 174 $cookiehash = md5(get_option('siteurl')); 178 175 define('COOKIEHASH', $cookiehash); 179 endif; 176 } 180 177 181 178 if ( !defined('USER_COOKIE') ) … … 202 199 if ( is_array($current_plugins) ) { 203 200 foreach ($current_plugins as $plugin) { 204 if ('' != $plugin && file_exists(ABSPATH . 'wp-content/plugins/' . $plugin))205 include_once(ABSPATH . 'wp-content/plugins/' . $plugin);201 if ('' != $plugin && file_exists(ABSPATH . PLUGINDIR . '/' . $plugin)) 202 include_once(ABSPATH . PLUGINDIR . '/' . $plugin); 206 203 } 207 204 } -
tags/2.2/wp-trackback.php
r5468 r5480 67 67 } 68 68 69 if ( !empty($tb_url) && !empty($title) && !empty($tb_url)) {69 if ( !empty($tb_url) && !empty($title) ) { 70 70 header('Content-Type: text/xml; charset=' . get_option('blog_charset') ); 71 71 -
tags/2.2/xmlrpc.php
r5468 r5480 5 5 // Some browser-embedded clients send cookies. We don't want them. 6 6 $_COOKIE = array(); 7 8 // A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default, 9 // but we can do it ourself. 10 if ( !isset( $HTTP_RAW_POST_DATA ) ) { 11 $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' ); 12 } 7 13 8 14 # fix for mozBlog and other cases where '<?xml' isn't on the very first line … … 23 29 <homePageLink><?php bloginfo_rss('url') ?></homePageLink> 24 30 <apis> 31 <api name="WordPress" blogID="1" preferred="false" apiLink="<?php bloginfo_rss('url') ?>/xmlrpc.php" /> 25 32 <api name="Movable Type" blogID="1" preferred="true" apiLink="<?php bloginfo_rss('url') ?>/xmlrpc.php" /> 26 33 <api name="MetaWeblog" blogID="1" preferred="false" apiLink="<?php bloginfo_rss('url') ?>/xmlrpc.php" /> … … 68 75 function wp_xmlrpc_server() { 69 76 $this->methods = array( 77 // WordPress API 78 'wp.getPage' => 'this:wp_getPage', 79 'wp.getPages' => 'this:wp_getPages', 80 'wp.newPage' => 'this:wp_newPage', 81 'wp.deletePage' => 'this:wp_deletePage', 82 'wp.editPage' => 'this:wp_editPage', 83 'wp.getPageList' => 'this:wp_getPageList', 84 'wp.getAuthors' => 'this:wp_getAuthors', 85 'wp.getCategories' => 'this:mw_getCategories', // Alias 86 'wp.newCategory' => 'this:wp_newCategory', 87 'wp.suggestCategories' => 'this:wp_suggestCategories', 88 'wp.uploadFile' => 'this:mw_newMediaObject', // Alias 89 70 90 // Blogger API 71 91 'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs', … … 127 147 function login_pass_ok($user_login, $user_pass) { 128 148 if (!user_pass_ok($user_login, $user_pass)) { 129 $this->error = new IXR_Error(403, 'Bad login/pass combination.');149 $this->error = new IXR_Error(403, __('Bad login/pass combination.')); 130 150 return false; 131 151 } … … 136 156 global $wpdb; 137 157 138 foreach ( (array) $array as $k => $v ) { 139 if (is_array($v)) { 140 $this->escape($array[$k]); 141 } else if (is_object($v)) { 142 //skip 143 } else { 144 $array[$k] = $wpdb->escape($v); 158 if(!is_array($array)) { 159 return($wpdb->escape($array)); 160 } 161 else { 162 foreach ( (array) $array as $k => $v ) { 163 if (is_array($v)) { 164 $this->escape($array[$k]); 165 } else if (is_object($v)) { 166 //skip 167 } else { 168 $array[$k] = $wpdb->escape($v); 169 } 145 170 } 146 171 } 147 172 } 173 174 /** 175 * WordPress XML-RPC API 176 * wp_getPage 177 */ 178 function wp_getPage($args) { 179 $this->escape($args); 180 181 $blog_id = (int) $args[0]; 182 $page_id = (int) $args[1]; 183 $username = $args[2]; 184 $password = $args[3]; 185 186 if(!$this->login_pass_ok($username, $password)) { 187 return($this->error); 188 } 189 190 // Lookup page info. 191 $page = get_page($page_id); 192 193 // If we found the page then format the data. 194 if($page->ID && ($page->post_type == "page")) { 195 // Get all of the page content and link. 196 $full_page = get_extended($page->post_content); 197 $link = post_permalink($page->ID); 198 199 // Get info the page parent if there is one. 200 $parent_title = ""; 201 if(!empty($page->post_parent)) { 202 $parent = get_page($page->post_parent); 203 $parent_title = $parent->post_title; 204 } 205 206 // Determine comment and ping settings. 207 $allow_comments = ("open" == $page->comment_status) ? 1 : 0; 208 $allow_pings = ("open" == $page->ping_status) ? 1 : 0; 209 210 // Format page date. 211 $page_date = mysql2date("Ymd\TH:i:s", $page->post_date_gmt); 212 213 // Pull the categories info together. 214 $categories = array(); 215 foreach(wp_get_post_categories($page->ID) as $cat_id) { 216 $categories[] = get_cat_name($cat_id); 217 } 218 219 // Get the author info. 220 $author = get_userdata($page->post_author); 221 222 $page_struct = array( 223 "dateCreated" => new IXR_Date($page_date), 224 "userid" => $page->post_author, 225 "page_id" => $page->ID, 226 "page_status" => $page->post_status, 227 "description" => $full_page["main"], 228 "title" => $page->post_title, 229 "link" => $link, 230 "permaLink" => $link, 231 "categories" => $categories, 232 "excerpt" => $page->post_excerpt, 233 "text_more" => $full_page["extended"], 234 "mt_allow_comments" => $allow_comments, 235 "mt_allow_pings" => $allow_pings, 236 "wp_slug" => $page->post_name, 237 "wp_password" => $page->post_password, 238 "wp_author" => $author->display_name, 239 "wp_page_parent_id" => $page->post_parent, 240 "wp_page_parent_title" => $parent_title, 241 "wp_page_order" => $page->menu_order, 242 "wp_author_id" => $author->ID, 243 "wp_author_display_name" => $author->display_name 244 ); 245 246 return($page_struct); 247 } 248 // If the page doesn't exist indicate that. 249 else { 250 return(new IXR_Error(404, __("Sorry, no such page."))); 251 } 252 } 253 254 /** 255 * WordPress XML-RPC API 256 * wp_getPages 257 */ 258 function wp_getPages($args) { 259 $this->escape($args); 260 261 $blog_id = (int) $args[0]; 262 $username = $args[1]; 263 $password = $args[2]; 264 265 if(!$this->login_pass_ok($username, $password)) { 266 return($this->error); 267 } 268 269 // Lookup info on pages. 270 $pages = get_pages(); 271 $num_pages = count($pages); 272 273 // If we have pages, put together their info. 274 if($num_pages >= 1) { 275 $pages_struct = array(); 276 277 for($i = 0; $i < $num_pages; $i++) { 278 $page = wp_xmlrpc_server::wp_getPage(array( 279 $blog_id, $pages[$i]->ID, $username, $password 280 )); 281 $pages_struct[] = $page; 282 } 283 284 return($pages_struct); 285 } 286 // If no pages were found return an error. 287 else { 288 return(array()); 289 } 290 } 291 292 /** 293 * WordPress XML-RPC API 294 * wp_newPage 295 */ 296 function wp_newPage($args) { 297 // Items not escaped here will be escaped in newPost. 298 $username = $this->escape($args[1]); 299 $password = $this->escape($args[2]); 300 $page = $args[3]; 301 $publish = $args[4]; 302 303 if(!$this->login_pass_ok($username, $password)) { 304 return($this->error); 305 } 306 307 // Set the user context and check if they are allowed 308 // to add new pages. 309 $user = set_current_user(0, $username); 310 if(!current_user_can("publish_pages")) { 311 return(new IXR_Error(401, __("Sorry, you can not add new pages."))); 312 } 313 314 // Mark this as content for a page. 315 $args[3]["post_type"] = "page"; 316 317 // Let mw_newPost do all of the heavy lifting. 318 return($this->mw_newPost($args)); 319 } 320 321 /** 322 * WordPress XML-RPC API 323 * wp_deletePage 324 */ 325 function wp_deletePage($args) { 326 $this->escape($args); 327 328 $blog_id = (int) $args[0]; 329 $username = $args[1]; 330 $password = $args[2]; 331 $page_id = (int) $args[3]; 332 333 if(!$this->login_pass_ok($username, $password)) { 334 return($this->error); 335 } 336 337 // Get the current page based on the page_id and 338 // make sure it is a page and not a post. 339 $actual_page = wp_get_single_post($page_id, ARRAY_A); 340 if( 341 !$actual_page 342 || ($actual_page["post_type"] != "page") 343 ) { 344 return(new IXR_Error(404, __("Sorry, no such page."))); 345 } 346 347 // Set the user context and make sure they can delete pages. 348 set_current_user(0, $username); 349 if(!current_user_can("delete_page", $page_id)) { 350 return(new IXR_Error(401, __("Sorry, you do not have the right to delete this page."))); 351 } 352 353 // Attempt to delete the page. 354 $result = wp_delete_post($page_id); 355 if(!$result) { 356 return(new IXR_Error(500, __("Failed to delete the page."))); 357 } 358 359 return(true); 360 } 361 362 /** 363 * WordPress XML-RPC API 364 * wp_editPage 365 */ 366 function wp_editPage($args) { 367 // Items not escaped here will be escaped in editPost. 368 $blog_id = (int) $args[0]; 369 $page_id = (int) $this->escape($args[1]); 370 $username = $this->escape($args[2]); 371 $password = $this->escape($args[3]); 372 $content = $args[4]; 373 $publish = $args[5]; 374 375 if(!$this->login_pass_ok($username, $password)) { 376 return($this->error); 377 } 378 379 // Get the page data and make sure it is a page. 380 $actual_page = wp_get_single_post($page_id, ARRAY_A); 381 if( 382 !$actual_page 383 || ($actual_page["post_type"] != "page") 384 ) { 385 return(new IXR_Error(404, __("Sorry, no such page."))); 386 } 387 388 // Set the user context and make sure they are allowed to edit pages. 389 set_current_user(0, $username); 390 if(!current_user_can("edit_page", $page_id)) { 391 return(new IXR_Error(401, __("Sorry, you do not have the right to edit this page."))); 392 } 393 394 // Mark this as content for a page. 395 $content["post_type"] = "page"; 396 397 // Arrange args in the way mw_editPost understands. 398 $args = array( 399 $page_id, 400 $username, 401 $password, 402 $content, 403 $publish 404 ); 405 406 // Let mw_editPost do all of the heavy lifting. 407 return($this->mw_editPost($args)); 408 } 409 410 /** 411 * WordPress XML-RPC API 412 * wp_getPageList 413 */ 414 function wp_getPageList($args) { 415 global $wpdb; 416 417 $this->escape($args); 418 419 $blog_id = (int) $args[0]; 420 $username = $args[1]; 421 $password = $args[2]; 422 423 if(!$this->login_pass_ok($username, $password)) { 424 return($this->error); 425 } 426 427 // Get list of pages ids and titles 428 $page_list = $wpdb->get_results(" 429 SELECT ID page_id, 430 post_title page_title, 431 post_parent page_parent_id, 432 post_date_gmt 433 FROM {$wpdb->posts} 434 WHERE post_type = 'page' 435 ORDER BY ID 436 "); 437 438 // The date needs to be formated properly. 439 $num_pages = count($page_list); 440 for($i = 0; $i < $num_pages; $i++) { 441 $post_date = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date_gmt); 442 $page_list[$i]->dateCreated = new IXR_Date($post_date); 443 444 unset($page_list[$i]->post_date_gmt); 445 } 446 447 return($page_list); 448 } 449 450 /** 451 * WordPress XML-RPC API 452 * wp_getAuthors 453 */ 454 function wp_getAuthors($args) { 455 global $wpdb; 456 457 $this->escape($args); 458 459 $blog_id = (int) $args[0]; 460 $username = $args[1]; 461 $password = $args[2]; 462 463 if(!$this->login_pass_ok($username, $password)) { 464 return($this->error); 465 } 466 467 return(get_users_of_blog()); 468 } 469 470 /** 471 * WordPress XML-RPC API 472 * wp_newCategory 473 */ 474 function wp_newCategory($args) { 475 $this->escape($args); 476 477 $blog_id = (int) $args[0]; 478 $username = $args[1]; 479 $password = $args[2]; 480 $category = $args[3]; 481 482 if(!$this->login_pass_ok($username, $password)) { 483 return($this->error); 484 } 485 486 // Set the user context and make sure they are 487 // allowed to add a category. 488 set_current_user(0, $username); 489 if(!current_user_can("manage_categories", $page_id)) { 490 return(new IXR_Error(401, __("Sorry, you do not have the right to add a category."))); 491 } 492 493 // We need this to make use of the wp_insert_category() 494 // funciton. 495 require_once(ABSPATH . "wp-admin/admin-db.php"); 496 497 // If no slug was provided make it empty so that 498 // WordPress will generate one. 499 if(empty($category["slug"])) { 500 $category["slug"] = ""; 501 } 502 503 // If no parent_id was provided make it empty 504 // so that it will be a top level page (no parent). 505 if ( !isset($category["parent_id"]) ) 506 $category["parent_id"] = ""; 507 508 // If no description was provided make it empty. 509 if(empty($category["description"])) { 510 $category["description"] = ""; 511 } 512 513 $new_category = array( 514 "cat_name" => $category["name"], 515 "category_nicename" => $category["slug"], 516 "category_parent" => $category["parent_id"], 517 "category_description" => $category["description"] 518 ); 519 520 $cat_id = wp_insert_category($new_category); 521 if(!$cat_id) { 522 return(new IXR_Error(500, __("Sorry, the new category failed."))); 523 } 524 525 return($cat_id); 526 } 527 528 /** 529 * WordPress XML-RPC API 530 * wp_suggestCategories 531 */ 532 function wp_suggestCategories($args) { 533 global $wpdb; 534 535 $this->escape($args); 536 537 $blog_id = (int) $args[0]; 538 $username = $args[1]; 539 $password = $args[2]; 540 $category = $args[3]; 541 $max_results = $args[4]; 542 543 if(!$this->login_pass_ok($username, $password)) { 544 return($this->error); 545 } 546 547 // Only set a limit if one was provided. 548 $limit = ""; 549 if(!empty($max_results)) { 550 $limit = "LIMIT {$max_results}"; 551 } 552 553 $category_suggestions = $wpdb->get_results(" 554 SELECT cat_ID category_id, 555 cat_name category_name 556 FROM {$wpdb->categories} 557 WHERE cat_name LIKE '{$category}%' 558 {$limit} 559 "); 560 561 return($category_suggestions); 562 } 563 148 564 149 565 /* Blogger API functions … … 157 573 $this->escape($args); 158 574 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 575 $user_login = $args[1]; 576 $user_pass = $args[2]; 577 578 if (!$this->login_pass_ok($user_login, $user_pass)) { 579 return $this->error; 580 } 581 582 set_current_user(0, $user_login); 583 $is_admin = current_user_can('level_8'); 584 585 $struct = array( 586 'isAdmin' => $is_admin, 587 'url' => get_option('home') . '/', 588 'blogid' => '1', 589 'blogName' => get_option('blogname') 590 ); 591 592 return array($struct); 177 593 } 178 594 … … 257 673 258 674 if (!$posts_list) { 259 $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');675 $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); 260 676 return $this->error; 261 677 } … … 304 720 set_current_user(0, $user_login); 305 721 if ( !current_user_can('edit_themes') ) { 306 return new IXR_Error(401, 'Sorry, this user can not edit the template.');722 return new IXR_Error(401, __('Sorry, this user can not edit the template.')); 307 723 } 308 724 … … 339 755 set_current_user(0, $user_login); 340 756 if ( !current_user_can('edit_themes') ) { 341 return new IXR_Error(401, 'Sorry, this user can not edit the template.');757 return new IXR_Error(401, __('Sorry, this user can not edit the template.')); 342 758 } 343 759 … … 350 766 fclose($f); 351 767 } else { 352 return new IXR_Error(500, 'Either the file is not writable, or something wrong happened. The file has not been updated.');768 return new IXR_Error(500, __('Either the file is not writable, or something wrong happened. The file has not been updated.')); 353 769 } 354 770 … … 377 793 $user = set_current_user(0, $user_login); 378 794 if ( !current_user_can($cap) ) 379 return new IXR_Error(401, 'Sorry, you can not post on this weblog or category.');795 return new IXR_Error(401, __('Sorry, you can not post on this weblog or category.')); 380 796 381 797 $post_status = ($publish) ? 'publish' : 'draft'; … … 395 811 396 812 if (!$post_ID) { 397 return new IXR_Error(500, 'Sorry, your entry could not be posted. Something wrong happened.');813 return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.')); 398 814 } 399 815 $this->attach_uploads( $post_ID, $post_content ); … … 425 841 426 842 if (!$actual_post) { 427 return new IXR_Error(404, 'Sorry, no such post.');843 return new IXR_Error(404, __('Sorry, no such post.')); 428 844 } 429 845 … … 432 848 set_current_user(0, $user_login); 433 849 if ( !current_user_can('edit_post', $post_ID) ) 434 return new IXR_Error(401, 'Sorry, you do not have the right to edit this post.');850 return new IXR_Error(401, __('Sorry, you do not have the right to edit this post.')); 435 851 436 852 extract($actual_post); 437 853 438 854 if ( ('publish' == $post_status) && !current_user_can('publish_posts') ) 439 return new IXR_Error(401, 'Sorry, you do not have the right to publish this post.');855 return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.')); 440 856 441 857 $post_title = xmlrpc_getposttitle($content); … … 448 864 449 865 if (!$result) { 450 return new IXR_Error(500, 'For some strange yet very annoying reason, this post could not be edited.');866 return new IXR_Error(500, __('For some strange yet very annoying reason, this post could not be edited.')); 451 867 } 452 868 $this->attach_uploads( $ID, $post_content ); … … 475 891 476 892 if (!$actual_post) { 477 return new IXR_Error(404, 'Sorry, no such post.');893 return new IXR_Error(404, __('Sorry, no such post.')); 478 894 } 479 895 480 896 set_current_user(0, $user_login); 481 897 if ( !current_user_can('edit_post', $post_ID) ) 482 return new IXR_Error(401, 'Sorry, you do not have the right to delete this post.');898 return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.')); 483 899 484 900 $result = wp_delete_post($post_ID); 485 901 486 902 if (!$result) { 487 return new IXR_Error(500, 'For some strange yet very annoying reason, this post could not be deleted.');903 return new IXR_Error(500, __('For some strange yet very annoying reason, this post could not be deleted.')); 488 904 } 489 905 … … 516 932 $user = set_current_user(0, $user_login); 517 933 if ( !current_user_can('publish_posts') ) 518 return new IXR_Error(401, 'Sorry, you can not post on this weblog or category.'); 934 return new IXR_Error(401, __('Sorry, you can not post on this weblog or category.')); 935 936 // The post_type defaults to post, but could also be page. 937 $post_type = "post"; 938 if( 939 !empty($content_struct["post_type"]) 940 && ($content_struct["post_type"] == "page") 941 ) { 942 $post_type = "page"; 943 } 944 945 // Let WordPress generate the post_name (slug) unless 946 // one has been provided. 947 $post_name = ""; 948 if(isset($content_struct["wp_slug"])) { 949 $post_name = $content_struct["wp_slug"]; 950 } 951 952 // Only use a password if one was given. 953 if(isset($content_struct["wp_password"])) { 954 $post_password = $content_struct["wp_password"]; 955 } 956 957 // Only set a post parent if one was provided. 958 if(isset($content_struct["wp_page_parent_id"])) { 959 $post_parent = $content_struct["wp_page_parent_id"]; 960 } 961 962 // Only set the menu_order if it was provided. 963 if(isset($content_struct["wp_page_order"])) { 964 $menu_order = $content_struct["wp_page_order"]; 965 } 519 966 520 967 $post_author = $user->ID; 968 969 // If an author id was provided then use it instead. 970 if( 971 isset($content_struct["wp_author_id"]) 972 && ($user->ID != $content_struct["wp_author_id"]) 973 ) { 974 switch($post_type) { 975 case "post": 976 if(!current_user_can("edit_others_posts")) { 977 return(new IXR_Error(401, "You are not allowed to " . 978 "post as this user")); 979 } 980 break; 981 case "page": 982 if(!current_user_can("edit_others_pages")) { 983 return(new IXR_Error(401, "You are not allowed to " . 984 "create pages as this user")); 985 } 986 break; 987 default: 988 return(new IXR_Error(401, __("Invalid post type."))); 989 break; 990 } 991 $post_author = $content_struct["wp_author_id"]; 992 } 521 993 522 994 $post_title = $content_struct['title']; … … 527 999 $post_more = $content_struct['mt_text_more']; 528 1000 529 $comment_status = (empty($content_struct['mt_allow_comments'])) ? 530 get_option('default_comment_status') 531 : $content_struct['mt_allow_comments']; 532 533 $ping_status = (empty($content_struct['mt_allow_pings'])) ? 534 get_option('default_ping_status') 535 : $content_struct['mt_allow_pings']; 1001 if(isset($content_struct["mt_allow_comments"])) { 1002 switch((int) $content_struct["mt_allow_comments"]) { 1003 case 0: 1004 $comment_status = "closed"; 1005 break; 1006 case 1: 1007 $comment_status = "open"; 1008 break; 1009 default: 1010 $comment_status = get_option("default_comment_status"); 1011 break; 1012 } 1013 } 1014 1015 if(isset($content_struct["mt_allow_pings"])) { 1016 switch((int) $content_struct["mt_allow_pings"]) { 1017 case 0: 1018 $ping_status = "closed"; 1019 break; 1020 case 1: 1021 $ping_status = "open"; 1022 break; 1023 default: 1024 $ping_status = get_option("default_ping_status"); 1025 break; 1026 } 1027 } 536 1028 537 1029 if ($post_more) { … … 548 1040 $dateCreated = $dateCreatedd->getIso(); 549 1041 $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); 550 $post_date_gmt = iso8601_to_datetime($dateCreated , GMT);1042 $post_date_gmt = iso8601_to_datetime($dateCreated. "Z", GMT); 551 1043 } else { 552 1044 $post_date = current_time('mysql'); … … 565 1057 566 1058 // We've got all the data -- post it: 567 $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping' );1059 $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping', 'post_type', 'post_name', 'post_password', 'post_parent', 'menu_order'); 568 1060 569 1061 $post_ID = wp_insert_post($postdata); 570 1062 571 1063 if (!$post_ID) { 572 return new IXR_Error(500, 'Sorry, your entry could not be posted. Something wrong happened.');1064 return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.')); 573 1065 } 574 1066 … … 611 1103 } 612 1104 613 set_current_user(0, $user_login); 614 if ( !current_user_can('edit_post', $post_ID) ) 615 return new IXR_Error(401, 'Sorry, you can not edit this post.'); 1105 $user = set_current_user(0, $user_login); 1106 1107 // The post_type defaults to post, but could also be page. 1108 $post_type = "post"; 1109 if( 1110 !empty($content_struct["post_type"]) 1111 && ($content_struct["post_type"] == "page") 1112 ) { 1113 $post_type = "page"; 1114 } 1115 1116 // Edit page caps are checked in editPage. Just check post here. 1117 if ( ( 'post' == $post_type ) && !current_user_can('edit_post', $post_ID) ) 1118 return new IXR_Error(401, __('Sorry, you can not edit this post.')); 616 1119 617 1120 $postdata = wp_get_single_post($post_ID, ARRAY_A); 1121 1122 // If there is no post data for the give post id, stop 1123 // now and return an error. Other wise a new post will be 1124 // created (which was the old behavior). 1125 if(empty($postdata["ID"])) { 1126 return(new IXR_Error(404, __("Invalid post id."))); 1127 } 1128 618 1129 extract($postdata); 619 1130 $this->escape($postdata); 1131 1132 // Let WordPress manage slug if none was provided. 1133 $post_name = ""; 1134 if(isset($content_struct["wp_slug"])) { 1135 $post_name = $content_struct["wp_slug"]; 1136 } 1137 1138 // Only use a password if one was given. 1139 if(isset($content_struct["wp_password"])) { 1140 $post_password = $content_struct["wp_password"]; 1141 } 1142 1143 // Only set a post parent if one was given. 1144 if(isset($content_struct["wp_page_parent_id"])) { 1145 $post_parent = $content_struct["wp_page_parent_id"]; 1146 } 1147 1148 // Only set the menu_order if it was given. 1149 if(isset($content_struct["wp_page_order"])) { 1150 $menu_order = $content_struct["wp_page_order"]; 1151 } 1152 1153 $post_author = $user->ID; 1154 1155 // Only set the post_author if one is set. 1156 if( 1157 isset($content_struct["wp_author_id"]) 1158 && ($user->ID != $content_struct["wp_author_id"]) 1159 ) { 1160 switch($post_type) { 1161 case "post": 1162 if(!current_user_can("edit_others_posts")) { 1163 return(new IXR_Error(401, "You are not allowed to " . 1164 "change the post author as this user.")); 1165 } 1166 break; 1167 case "page": 1168 if(!current_user_can("edit_others_pages")) { 1169 return(new IXR_Error(401, "You are not allowed to " . 1170 "change the page author as this user.")); 1171 } 1172 break; 1173 default: 1174 return(new IXR_Error(401, __("Invalid post type."))); 1175 break; 1176 } 1177 $post_author = $content_struct["wp_author_id"]; 1178 } 1179 1180 // Only set ping_status if it was provided. 1181 if(isset($content_struct["mt_allow_pings"])) { 1182 switch((int) $content_struct["mt_allow_pings"]) { 1183 case 0: 1184 $ping_status = "closed"; 1185 break; 1186 case 1: 1187 $ping_status = "open"; 1188 break; 1189 } 1190 } 620 1191 621 1192 $post_title = $content_struct['title']; … … 635 1206 $post_status = $publish ? 'publish' : 'draft'; 636 1207 637 638 if ( ('publish' == $post_status) && !current_user_can('publish_posts') ) 639 return new IXR_Error(401, 'Sorry, you do not have the right to publish this post.'); 1208 if ( ('publish' == $post_status) ) { 1209 if ( ( 'page' == $post_type ) && !current_user_can('publish_pages') ) 1210 return new IXR_Error(401, __('Sorry, you do not have the right to publish this page.')); 1211 else if ( !current_user_can('publish_posts') ) 1212 return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.')); 1213 } 640 1214 641 1215 if ($post_more) { … … 646 1220 if ( is_array($to_ping) ) 647 1221 $to_ping = implode(' ', $to_ping); 1222 1223 if(isset($content_struct["mt_allow_comments"])) { 1224 $comment_status = (int) $content_struct["mt_allow_comments"]; 1225 } 648 1226 649 $comment_status = (empty($content_struct['mt_allow_comments'])) ?650 get_option('default_comment_status')651 : $content_struct['mt_allow_comments'];652 653 $ping_status = (empty($content_struct['mt_allow_pings'])) ?654 get_option('default_ping_status')655 : $content_struct['mt_allow_pings'];656 657 1227 // Do some timestamp voodoo 658 1228 $dateCreatedd = $content_struct['dateCreated']; … … 660 1230 $dateCreated = $dateCreatedd->getIso(); 661 1231 $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); 662 $post_date_gmt = iso8601_to_datetime($dateCreated , GMT);1232 $post_date_gmt = iso8601_to_datetime($dateCreated . "Z", GMT); 663 1233 } else { 664 1234 $post_date = $postdata['post_date']; … … 667 1237 668 1238 // We've got all the data -- post it: 669 $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt', 'to_ping' );1239 $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt', 'to_ping', 'post_name', 'post_password', 'post_parent', 'menu_order', 'post_author'); 670 1240 671 1241 $result = wp_update_post($newpost); 672 1242 if (!$result) { 673 return new IXR_Error(500, 'Sorry, your entry could not be edited. Something wrong happened.');1243 return new IXR_Error(500, __('Sorry, your entry could not be edited. Something wrong happened.')); 674 1244 } 675 1245 $this->attach_uploads( $ID, $post_content ); … … 700 1270 if ($postdata['post_date'] != '') { 701 1271 702 $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date ']);1272 $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt']); 703 1273 704 1274 $categories = array(); … … 710 1280 $post = get_extended($postdata['post_content']); 711 1281 $link = post_permalink($postdata['ID']); 1282 1283 // Get the author info. 1284 $author = get_userdata($postdata['post_author']); 712 1285 713 1286 $allow_comments = ('open' == $postdata['comment_status']) ? 1 : 0; … … 728 1301 'mt_text_more' => $post['extended'], 729 1302 'mt_allow_comments' => $allow_comments, 730 'mt_allow_pings' => $allow_pings 1303 'mt_allow_pings' => $allow_pings, 1304 'wp_slug' => $postdata['post_name'], 1305 'wp_password' => $postdata['post_password'], 1306 'wp_author_id' => $author->ID, 1307 'wp_author_display_name' => $author->display_name 731 1308 ); 732 1309 733 1310 return $resp; 734 1311 } else { 735 return new IXR_Error(404, 'Sorry, no such post.');1312 return new IXR_Error(404, __('Sorry, no such post.')); 736 1313 } 737 1314 } … … 755 1332 756 1333 if (!$posts_list) { 757 $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');1334 $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); 758 1335 return $this->error; 759 1336 } … … 761 1338 foreach ($posts_list as $entry) { 762 1339 763 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date ']);1340 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt']); 764 1341 $categories = array(); 765 1342 $catids = wp_get_post_categories($entry['ID']); … … 770 1347 $post = get_extended($entry['post_content']); 771 1348 $link = post_permalink($entry['ID']); 1349 1350 // Get the post author info. 1351 $author = get_userdata($entry['post_author']); 772 1352 773 1353 $allow_comments = ('open' == $entry['comment_status']) ? 1 : 0; … … 788 1368 'mt_text_more' => $post['extended'], 789 1369 'mt_allow_comments' => $allow_comments, 790 'mt_allow_pings' => $allow_pings 1370 'mt_allow_pings' => $allow_pings, 1371 'wp_slug' => $entry['post_name'], 1372 'wp_password' => $entry['post_password'], 1373 'wp_author_id' => $author->ID, 1374 'wp_author_display_name' => $author->display_name 791 1375 ); 792 1376 … … 820 1404 821 1405 // FIXME: can we avoid using direct SQL there? 822 if ($cats = $wpdb->get_results("SELECT cat_ID,cat_name FROM $wpdb->categories", ARRAY_A)) {1406 if ($cats = $wpdb->get_results("SELECT cat_ID,cat_name,category_parent FROM $wpdb->categories", ARRAY_A)) { 823 1407 foreach ($cats as $cat) { 824 1408 $struct['categoryId'] = $cat['cat_ID']; 1409 $struct['parentId'] = $cat['category_parent']; 825 1410 $struct['description'] = $cat['cat_name']; 826 1411 $struct['categoryName'] = $cat['cat_name']; … … 852 1437 $bits = $data['bits']; 853 1438 1439 if(!empty($data["overwrite"]) && ($data["overwrite"] == true)) { 1440 // Get postmeta info on the object. 1441 $old_file = $wpdb->get_row(" 1442 SELECT ID 1443 FROM {$wpdb->posts} 1444 WHERE post_title = '{$name}' 1445 AND post_type = 'attachment' 1446 "); 1447 1448 // Delete previous file. 1449 wp_delete_attachment($old_file->ID); 1450 1451 // Make sure the new name is different by pre-pending the 1452 // previous post id. 1453 $filename = preg_replace("/^wpid\d+-/", "", $name); 1454 $name = "wpid{$old_file->ID}-{$filename}"; 1455 } 1456 854 1457 logIO('O', '(MW) Received '.strlen($bits).' bytes'); 855 1458 … … 860 1463 if ( !current_user_can('upload_files') ) { 861 1464 logIO('O', '(MW) User does not have upload_files capability'); 862 $this->error = new IXR_Error(401, 'You are not allowed to upload files to this site.');1465 $this->error = new IXR_Error(401, __('You are not allowed to upload files to this site.')); 863 1466 return $this->error; 864 1467 } … … 867 1470 return new IXR_Error(500, $upload_err); 868 1471 869 $upload = wp_upload_bits($name, $type, $bits );1472 $upload = wp_upload_bits($name, $type, $bits, $overwrite); 870 1473 if ( ! empty($upload['error']) ) { 871 1474 $errorString = 'Could not write file ' . $name . ' (' . $upload['error'] . ')'; … … 884 1487 'guid' => $upload[ 'url' ] 885 1488 ); 1489 886 1490 // Save the data 887 1491 $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id ); 888 1492 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); 889 1493 890 return apply_filters( 'wp_handle_upload', array( 'file' => $ upload[ 'file' ], 'url' => $upload[ 'url' ], 'type' => $type ) );1494 return apply_filters( 'wp_handle_upload', array( 'file' => $name, 'url' => $upload[ 'url' ], 'type' => $type ) ); 891 1495 } 892 1496 … … 913 1517 914 1518 if (!$posts_list) { 915 $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');1519 $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.')); 916 1520 return $this->error; 917 1521 } … … 919 1523 foreach ($posts_list as $entry) { 920 1524 921 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date ']);1525 $post_date = mysql2date('Ymd\TH:i:s', $entry['post_date_gmt']); 922 1526 923 1527 $struct[] = array( … … 1016 1620 set_current_user(0, $user_login); 1017 1621 if ( !current_user_can('edit_post', $post_ID) ) 1018 return new IXR_Error(401, 'Sorry, you can not edit this post.');1622 return new IXR_Error(401, __('Sorry, you can not edit this post.')); 1019 1623 1020 1624 foreach($categories as $cat) { … … 1043 1647 support per-post text filters yet */ 1044 1648 function mt_supportedTextFilters($args) { 1045 return a rray();1649 return apply_filters('xmlrpc_text_filters', array()); 1046 1650 } 1047 1651 … … 1057 1661 1058 1662 if (!$actual_post) { 1059 return new IXR_Error(404, 'Sorry, no such post.');1663 return new IXR_Error(404, __('Sorry, no such post.')); 1060 1664 } 1061 1665 … … 1098 1702 set_current_user(0, $user_login); 1099 1703 if ( !current_user_can('edit_post', $post_ID) ) 1100 return new IXR_Error(401, 'Sorry, you can not edit this post.');1704 return new IXR_Error(401, __('Sorry, you can not edit this post.')); 1101 1705 1102 1706 $postdata = wp_get_single_post($post_ID,ARRAY_A); … … 1139 1743 $pos1 = strpos($pagelinkedto, str_replace(array('http://www.','http://','https://www.','https://'), '', get_option('home'))); 1140 1744 if( !$pos1 ) 1141 return new IXR_Error(0, 'Is there no link to us?');1745 return new IXR_Error(0, __('Is there no link to us?')); 1142 1746 1143 1747 // let's find which post is linked to … … 1192 1796 1193 1797 if ( $post_ID == url_to_postid($pagelinkedfrom) ) 1194 return new IXR_Error(0, 'The source URL and the target URL cannot both point to the same resource.');1798 return new IXR_Error(0, __('The source URL and the target URL cannot both point to the same resource.')); 1195 1799 1196 1800 // Check if pings are on … … 1202 1806 1203 1807 if ( $wpdb->num_rows ) // We already have a Pingback from this URL 1204 return new IXR_Error(48, 'The pingback has already been registered.');1808 return new IXR_Error(48, __('The pingback has already been registered.')); 1205 1809 1206 1810 // very stupid, but gives time to the 'from' server to publish ! … … 1210 1814 $linea = wp_remote_fopen( $pagelinkedfrom ); 1211 1815 if ( !$linea ) 1212 return new IXR_Error(16, 'The source URL does not exist.');1816 return new IXR_Error(16, __('The source URL does not exist.')); 1213 1817 1214 1818 // Work around bug in strip_tags(): … … 1220 1824 $title = $matchtitle[1]; 1221 1825 if ( empty( $title ) ) 1222 return new IXR_Error(32, 'We cannot find a title on that page.');1826 return new IXR_Error(32, __('We cannot find a title on that page.')); 1223 1827 1224 1828 $linea = strip_tags( $linea, '<a>' ); // just keep the tag we need … … 1256 1860 1257 1861 if ( empty($context) ) // Link to target not found 1258 return new IXR_Error(17, 'The source URL does not contain a link to the target URL, and so cannot be used as a source.');1862 return new IXR_Error(17, __('The source URL does not contain a link to the target URL, and so cannot be used as a source.')); 1259 1863 1260 1864 $pagelinkedfrom = preg_replace('#&([^amp\;])#is', '&$1', $pagelinkedfrom); … … 1303 1907 if (!$actual_post) { 1304 1908 // No such post = resource not found 1305 return new IXR_Error(32, 'The specified target URL does not exist.');1909 return new IXR_Error(32, __('The specified target URL does not exist.')); 1306 1910 } 1307 1911
Note: See TracChangeset
for help on using the changeset viewer.