diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-09-26 15:45:20 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-09-26 15:45:20 +0000 |
commit | 28781ebb081ab8d99b30a33f5cd911b3b050bcc9 (patch) | |
tree | f21e6b7d3dd06002c58dd52ae2eae10d64d62d85 /wp-includes/general-template.php | |
parent | cbd939114d362bfece3839d7d5d5e07367fd6be8 (diff) | |
download | wordpress-mu-28781ebb081ab8d99b30a33f5cd911b3b050bcc9.tar.gz wordpress-mu-28781ebb081ab8d99b30a33f5cd911b3b050bcc9.tar.xz wordpress-mu-28781ebb081ab8d99b30a33f5cd911b3b050bcc9.zip |
WP Merge to rev 4254
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@770 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/general-template.php')
-rw-r--r-- | wp-includes/general-template.php | 101 |
1 files changed, 86 insertions, 15 deletions
diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index dd390aa..2cb5c02 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -127,6 +127,14 @@ function get_bloginfo($show='') { global $wp_version; $output = $wp_version; break; + case 'language': + $output = get_locale(); + $output = str_replace('_', '-', $output); + break; + case 'text_direction': + global $wp_locale; + $output = $wp_locale->text_direction; + break; case 'name': default: $output = get_option('blogname'); @@ -736,13 +744,15 @@ function noindex() { echo "<meta name='robots' content='noindex,nofollow' />\n"; } -/** - * Places a textarea according to the current user's preferences, filled with $content. - * Also places a script block that enables tabbing between Title and Content. - * - * @param string Editor contents - * @param string (optional) Previous form field's ID (for tabbing support) - */ +function user_can_richedit() { + $can = true; + + if ( 'true' != get_user_option('rich_editing') || preg_match('!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT']) ) + $can = false; + + return apply_filters('user_can_richedit', $can); +} + function the_editor($content, $id = 'content', $prev_id = 'title') { $rows = get_option('default_post_edit_rows'); if (($rows < 3) || ($rows > 100)) @@ -750,11 +760,61 @@ function the_editor($content, $id = 'content', $prev_id = 'title') { $rows = "rows='$rows'"; - the_quicktags(); - - if ( user_can_richedit() ) + if ( user_can_richedit() ) : add_filter('the_editor_content', 'wp_richedit_pre'); + // The following line moves the border so that the active button "attaches" to the toolbar. Only IE needs it. + ?> + <style type="text/css"> + #postdivrich table, #postdivrich #quicktags {border-top: none;} + #quicktags {border-bottom: none; padding-bottom: 2px; margin-bottom: -1px;} + #edButtons {border-bottom: 1px solid #ccc;} + </style> + <div id='edButtons' style='display:none;'> + <div class='zerosize'><input accesskey='e' type='button' onclick='switchEditors("<?php echo $id; ?>")' /></div> + <input id='edButtonPreview' class='edButtonFore' type='button' value='<?php _e('Compose'); ?>' /> + <input id='edButtonHTML' class='edButtonBack' type='button' value='<?php _e('HTML'); ?>' onclick='switchEditors("<?php echo $id; ?>")' /> + </div> + <script type="text/javascript"> + if ( typeof tinyMCE != "undefined" && tinyMCE.configs.length > 0 ) + document.getElementById('edButtons').style.display = 'block'; + </script> + + <?php endif; ?> + <div id="quicktags"> + <?php wp_print_scripts( 'quicktags' ); ?> + <script type="text/javascript">edToolbar()</script> + </div> + <script type="text/javascript"> + if ( typeof tinyMCE != "undefined" && tinyMCE.configs.length > 0 ) + document.getElementById("quicktags").style.display="none"; + + function edInsertContent(myField, myValue) { + //IE support + if (document.selection) { + myField.focus(); + sel = document.selection.createRange(); + sel.text = myValue; + myField.focus(); + } + //MOZILLA/NETSCAPE support + else if (myField.selectionStart || myField.selectionStart == "0") { + var startPos = myField.selectionStart; + var endPos = myField.selectionEnd; + myField.value = myField.value.substring(0, startPos) + + myValue + + myField.value.substring(endPos, myField.value.length); + myField.focus(); + myField.selectionStart = startPos + myValue.length; + myField.selectionEnd = startPos + myValue.length; + } else { + myField.value += myValue; + myField.focus(); + } + } + </script> + <?php + $the_editor = apply_filters('the_editor', "<div><textarea class='mceEditor' $rows cols='40' name='$id' tabindex='2' id='$id'>%s</textarea></div>\n"); $the_editor_content = apply_filters('the_editor_content', $content); @@ -764,17 +824,17 @@ function the_editor($content, $id = 'content', $prev_id = 'title') { <script type="text/javascript"> //<!-- edCanvas = document.getElementById('<?php echo $id; ?>'); - <?php if ( user_can_richedit() ) : ?> + <?php if ( $prev_id && user_can_richedit() ) : ?> // This code is meant to allow tabbing from Title to Post (TinyMCE). if ( tinyMCE.isMSIE ) document.getElementById('<?php echo $prev_id; ?>').onkeydown = function (e) { e = e ? e : window.event; if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) { - var i = tinyMCE.selectedInstance; + var i = tinyMCE.getInstanceById('<?php echo $id; ?>'); if(typeof i == 'undefined') return true; - tinyMCE.execCommand("mceStartTyping"); + tinyMCE.execCommand("mceStartTyping"); this.blur(); i.contentWindow.focus(); e.returnValue = false; @@ -786,10 +846,10 @@ function the_editor($content, $id = 'content', $prev_id = 'title') { { e = e ? e : window.event; if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) { - var i = tinyMCE.selectedInstance; + var i = tinyMCE.getInstanceById('<?php echo $id; ?>'); if(typeof i == 'undefined') return true; - tinyMCE.execCommand("mceStartTyping"); + tinyMCE.execCommand("mceStartTyping"); this.blur(); i.contentWindow.focus(); e.returnValue = false; @@ -807,4 +867,15 @@ function the_search_query() { echo wp_specialchars( stripslashes($s), 1 ); } +function language_attributes() { + $output = ''; + if ( $dir = get_bloginfo('text_direction') ) + $output = "dir=\"$dir\""; + if ( $lang = get_bloginfo('language') ) { + if ( $dir ) $output .= ' '; + $output .= "lang=\"$lang\" xml:lang=\"$lang\""; + } + + echo $output; +} ?> |