function qtrans_modifyRichEditor($old_content)
{
    global $q_config;
    $init_editor = true;
    if ($GLOBALS['wp_version'] != QT_SUPPORTED_WP_VERSION) {
        if (!(isset($_REQUEST['qtranslateincompatiblemessage']) && $_REQUEST['qtranslateincompatiblemessage'] == "shown")) {
            echo '<p class="updated" id="qtrans_imsg">' . __('The qTranslate Editor has disabled itself because it hasn\'t been tested with your Wordpress version yet. This is done to prevent Wordpress from malfunctioning. You can reenable it by <a href="javascript:qtrans_editorInit();" title="Activate qTranslate" id="qtrans_imsg_link">clicking here</a> (may cause <b>data loss</b>! Use at own risk!). To remove this message permanently, please update qTranslate to the <a href="http://www.qianqin.de/qtranslate/download/">corresponding version</a>.', 'qtranslate') . '</p>';
        }
        $init_editor = false;
    }
    // save callback hook
    preg_match("/<textarea[^>]*id='([^']+)'/", $old_content, $matches);
    $id = $matches[1];
    preg_match("/cols='([^']+)'/", $old_content, $matches);
    $cols = $matches[1];
    preg_match("/rows='([^']+)'/", $old_content, $matches);
    $rows = $matches[1];
    // don't do anything if not editing the content
    if ($id != "content") {
        return $old_content;
    }
    // don't do anything to the editor if it's not rich
    if (!user_can_richedit()) {
        //echo '<p class="updated">'.__('The qTranslate Editor could not be loaded because WYSIWYG/TinyMCE is not activated in your profile.').'</p>';
        return $old_content;
    }
    $content = "";
    $content_append = "";
    // create editing field for selected languages
    $old_content = substr($old_content, 0, 26) . "<textarea id='qtrans_textarea_" . $id . "' name='qtrans_textarea_" . $id . "' tabindex='2' rows='" . $rows . "' cols='" . $cols . "' style='display:none' onblur='qtrans_save(this.value);'></textarea>" . substr($old_content, 26);
    // do some crazy js to alter the admin view
    $content .= "<script type=\"text/javascript\">\n// <![CDATA[\n";
    $content .= "function qtrans_editorInit1() {\n";
    // include needed js functions
    $content .= $q_config['js']['qtrans_is_array'];
    $content .= $q_config['js']['qtrans_xsplit'];
    $content .= $q_config['js']['qtrans_split'];
    $content .= $q_config['js']['qtrans_integrate'];
    $content .= $q_config['js']['qtrans_use'];
    $content .= $q_config['js']['qtrans_switch'];
    $content .= $q_config['js']['qtrans_assign'];
    $content .= $q_config['js']['qtrans_save'];
    $content .= $q_config['js']['qtrans_integrate_title'];
    $content .= $q_config['js']['qtrans_get_active_language'];
    // insert language, visual and html buttons
    $el = qtrans_getSortedLanguages();
    foreach ($el as $language) {
        $content .= qtrans_insertTitleInput($language);
    }
    $el = qtrans_getSortedLanguages(true);
    foreach ($el as $language) {
        $content .= qtrans_createEditorToolbarButton($language, $id);
    }
    $content = apply_filters('qtranslate_toolbar', $content);
    // hide old title bar
    $content .= "document.getElementById('titlediv').style.display='none';\n";
    $content .= "}\n";
    $content .= "// ]]>\n</script>\n";
    $content_append .= "<script type=\"text/javascript\">\n// <![CDATA[\n";
    // disable old editor here if editor is to be initialized
    if ($init_editor) {
        $content_append .= $q_config['js']['qtrans_disable_old_editor'];
    }
    $content_append .= "function qtrans_editorInit2() {\n";
    // disable old editor here if editor is not to be initialized
    if (!$init_editor) {
        $content_append .= $q_config['js']['qtrans_disable_old_editor'];
    }
    // hijack tinymce control
    $content_append .= $q_config['js']['qtrans_disable_old_editor'];
    // show default language tab
    $content_append .= "document.getElementById('qtrans_select_" . $q_config['default_language'] . "').className='edButton active';\n";
    // show default language
    $content_append .= "var ta = document.getElementById('" . $id . "');\n";
    $content_append .= "qtrans_assign('qtrans_textarea_" . $id . "',qtrans_use('" . $q_config['default_language'] . "',ta.value));\n";
    $content_append .= "}\n";
    $content_append .= "function qtrans_editorInit3() {\n";
    // make tinyMCE get the correct data
    $content_append .= $q_config['js']['qtrans_tinyMCEOverload'];
    $content_append .= "}\n";
    $content_append .= "function qtrans_editorInit() {\n";
    $content_append .= "qtrans_editorInit1();\n";
    $content_append .= "qtrans_editorInit2();\n";
    $content_append .= "jQuery('#qtrans_imsg').hide();\n";
    $content_append .= "qtrans_editorInit3();\n";
    $content_append .= "}\n";
    if ($init_editor) {
        $content_append .= $q_config['js']['qtrans_wpOnload'];
    } else {
        $content_append .= "var qtmsg = document.getElementById('qtrans_imsg');\n";
        $content_append .= "var et = document.getElementById('editor-toolbar');\n";
        $content_append .= "et.parentNode.insertBefore(qtmsg, et);\n";
    }
    $content_append = apply_filters('qtranslate_modify_editor_js', $content_append);
    $content_append .= "// ]]>\n</script>\n";
    return $content . $old_content . $content_append;
}
function qtrans_modifyRichEditor($old_content)
{
    if (preg_match('~/wp-admin/comment.php$~i', $_SERVER['PHP_SELF'])) {
        return $old_content;
    }
    global $q_config;
    $init_editor = true;
    if (version_compare($GLOBALS['wp_version'], QT_SUPPORTED_WP_VERSION, '>')) {
        if (!(isset($_REQUEST['qtranslateincompatiblemessage']) && $_REQUEST['qtranslateincompatiblemessage'] == "shown")) {
            echo '<div class="updated" id="qtrans_imsg">' . __('The qTranslate Editor has disabled itself because it hasn\'t been tested with your Wordpress version yet. This is done to prevent Wordpress from malfunctioning. You can reenable it by <a href="javascript:qtrans_editorInit();" title="Activate qTranslate" id="qtrans_imsg_link">clicking here</a> (may cause <b>data loss</b>! Use at own risk!). To remove this message permanently, please update qTranslate to the <a href="http://www.qianqin.de/qtranslate/download/">corresponding version</a>.', 'qtranslate') . '</div>';
        }
        $init_editor = false;
    }
    // save callback hook
    preg_match("/<textarea[^>]*id=\"([^']+)\"/", $old_content, $matches);
    $id = $matches[1];
    preg_match("/cols=\"([^\"]+)\"/", $old_content, $matches);
    $cols = $matches[1];
    // don't do anything if not editing the content
    if ($id != "content") {
        return $old_content;
    }
    // don't do anything to the editor if it's not rich
    if (!user_can_richedit()) {
        //echo '<p class="updated">'.__('The qTranslate Editor could not be loaded because WYSIWYG/TinyMCE is not activated in your profile.').'</p>';
        return $old_content;
    }
    // remove wpautop
    if ('html' != wp_default_editor()) {
        remove_filter('the_editor_content', 'wp_richedit_pre');
    }
    $content = "";
    $content_append = "";
    // create editing field for selected languages
    $qt_textarea = '<textarea id="qtrans_textarea_' . $id . '" name="qtrans_textarea_' . $id . '" tabindex="2" cols="' . $cols . '" style="display:none" onblur="qtrans_save(this.value);"></textarea>';
    $old_content = preg_replace('#(<textarea[^>]*>.*</textarea>)#', '$1' . $qt_textarea, $old_content);
    // do some crazy js to alter the admin view
    $content .= "<script type=\"text/javascript\">\n// <![CDATA[\n";
    // include needed js functions
    $content .= $q_config['js']['qtrans_is_array'];
    $content .= $q_config['js']['qtrans_xsplit'];
    $content .= $q_config['js']['qtrans_split'];
    $content .= $q_config['js']['qtrans_integrate'];
    $content .= $q_config['js']['qtrans_use'];
    $content .= $q_config['js']['qtrans_assign'];
    $content .= $q_config['js']['qtrans_save'];
    $content .= $q_config['js']['qtrans_integrate_title'];
    $content .= $q_config['js']['qtrans_get_active_language'];
    $content .= $q_config['js']['qtrans_hook_on_tinyMCE'];
    $content .= "function qtrans_editorInit1() {\n";
    $content .= $q_config['js']['qtrans_switch'];
    // insert language, visual and html buttons
    $el = qtrans_getSortedLanguages();
    foreach ($el as $language) {
        $content .= qtrans_insertTitleInput($language);
    }
    $el = qtrans_getSortedLanguages(true);
    foreach ($el as $language) {
        $content .= qtrans_createEditorToolbarButton($language, $id);
    }
    $content = apply_filters('qtranslate_toolbar', $content);
    // hide old title bar
    $content .= "document.getElementById('titlediv').style.display='none';\n";
    $content .= "}\n";
    $content .= "// ]]>\n</script>\n";
    $content_append .= "<script type=\"text/javascript\">\n// <![CDATA[\n";
    $content_append .= "function qtrans_editorInit2() {\n";
    // show default language tab
    $content_append .= "document.getElementById('qtrans_select_" . $q_config['default_language'] . "').className='wp-switch-editor switch-tmce switch-html';\n";
    // show default language
    $content_append .= "var text = document.getElementById('" . $id . "').value;\n";
    $content_append .= "qtrans_assign('qtrans_textarea_" . $id . "',qtrans_use('" . $q_config['default_language'] . "',text));\n";
    $content_append .= "}\n";
    $content_append .= "function qtrans_editorInit3() {\n";
    // make tinyMCE and mediauploader get the correct data
    $content_append .= $q_config['js']['qtrans_tinyMCEOverload'];
    $content_append .= $q_config['js']['qtrans_wpActiveEditorOverload'];
    $content_append .= "}\n";
    $content_append .= $q_config['js']['qtrans_editorInit'];
    if ($init_editor) {
        $content_append .= $q_config['js']['qtrans_wpOnload'];
    } else {
        $content_append .= "var qtmsg = document.getElementById('qtrans_imsg');\n";
        $content_append .= "var et = document.getElementById('wp-" . $id . "-editor-tools');\n";
        $content_append .= "et.parentNode.insertBefore(qtmsg, et);\n";
    }
    $content_append = apply_filters('qtranslate_modify_editor_js', $content_append);
    $content_append .= "// ]]>\n</script>\n";
    return $content . $old_content . $content_append;
}
function qs_toobar($content)
{
    // Create Translate Button
    $content .= qtrans_createEditorToolbarButton('translate', 'translate', 'init_qs', __('Translate'));
    return $content;
}
function qtrans_modifyRichEditor($old_content)
{
    global $q_config;
    $init_editor = true;
    if (!isWordPressMajorVersionSupported() && !(isset($_REQUEST['mqtranslateincompatiblemessage']) && $_REQUEST['mqtranslateincompatiblemessage'] == "shown")) {
        if (!defined('QT_DISPLAYED_INCOMPATIBLE_MESSAGE')) {
            echo '<div class="error" id="qtrans_imsg"><p>' . __('The mqTranslate Editor has disabled itself because it hasn\'t been tested with your Wordpress version yet. This is done to prevent Wordpress from malfunctioning. To remove this message permanently, please update mqTranslate to the <a href="http://wordpress.org/plugins/mqtranslate/" target="_blank">corresponding version</a>.', 'mqtranslate') . '</p></div>';
            define('QT_DISPLAYED_INCOMPATIBLE_MESSAGE', true);
        }
        $init_editor = false;
    }
    // save callback hook
    preg_match("/<textarea[^>]*id=\"([^\"]+)\"/", $old_content, $matches);
    $id = $matches[1];
    preg_match("/cols=\"([^\"]+)\"/", $old_content, $matches);
    $cols = $matches[1];
    // don't do anything if not editing the content
    if ($id != "content") {
        return $old_content;
    }
    // don't do anything to the editor if it's not rich
    if (!user_can_richedit()) {
        //echo '<p class="updated">'.__('The mqTranslate Editor could not be loaded because WYSIWYG/TinyMCE is not activated in your profile.').'</p>';
        return $old_content;
    }
    $content = "";
    $content_append = "";
    // create editing field for selected languages
    $cookie = (int) get_user_setting('ed_size');
    if ($cookie) {
        $str_height = "height: {$cookie}px; ";
    } else {
        $str_height = '';
    }
    $qt_textarea = '<textarea class="wp-editor-area" id="qtrans_textarea_' . $id . '" name="qtrans_textarea_' . $id . '" tabindex="2" cols="' . $cols . '" style="' . $str_height . 'display:none" onblur="qtrans_save(this.value);"></textarea>';
    $old_content = preg_replace('#(<textarea[^>]*>.*</textarea>)#', '$1' . $qt_textarea, $old_content);
    // do some crazy js to alter the admin view
    $content .= "<script type=\"text/javascript\">\n// <![CDATA[\n";
    // include needed js functions
    $content .= $q_config['js']['qtrans_is_array'];
    $content .= $q_config['js']['qtrans_xsplit'];
    $content .= $q_config['js']['qtrans_split'];
    $content .= $q_config['js']['qtrans_integrate'];
    $content .= $q_config['js']['qtrans_use'];
    $content .= $q_config['js']['qtrans_assign'];
    $content .= $q_config['js']['qtrans_save'];
    $content .= $q_config['js']['qtrans_integrate_title'];
    $content .= $q_config['js']['qtrans_get_active_language'];
    $content .= $q_config['js']['qtrans_hook_on_tinyMCE'];
    $content .= "function qtrans_editorInit1() {\n";
    $content .= $q_config['js']['qtrans_switch'];
    $cu = wp_get_current_user();
    // insert language, visual and html buttons
    $el = qtrans_getSortedLanguages();
    foreach ($el as $language) {
        if ($cu->has_cap('edit_users') || mqtrans_currentUserCanEdit($language) || mqtrans_currentUserCanView($language)) {
            $content .= qtrans_insertTitleInput($language);
        }
    }
    $el = qtrans_getSortedLanguages(true);
    foreach ($el as $language) {
        if ($cu->has_cap('edit_users') || mqtrans_currentUserCanEdit($language) || mqtrans_currentUserCanView($language)) {
            $content .= qtrans_createEditorToolbarButton($language, $id);
        }
    }
    $content = apply_filters('mqtranslate_toolbar', $content);
    // hide old title bar
    $content .= "document.getElementById('titlediv').style.display='none';\n";
    $content .= "}\n";
    $content .= "// ]]>\n</script>\n";
    $content_append .= "<script type=\"text/javascript\">\n// <![CDATA[\n";
    $content_append .= "function qtrans_editorInit2() {\n";
    // show default language tab
    $content_append .= "document.getElementById('qtrans_select_" . $q_config['default_language'] . "').className='wp-switch-editor switch-tmce switch-html';\n";
    // show default language
    $content_append .= "var text = document.getElementById('" . $id . "').value;\n";
    // when TinyMCE is displayed as the default editor, remove the automatically added paragraphs before initializing mqTranslate
    $content_append .= "if(getUserSetting( 'editor' ) == 'tinymce') { var text = switchEditors.pre_wpautop(text); }";
    $content_append .= "qtrans_assign('qtrans_textarea_" . $id . "',qtrans_use('" . $q_config['default_language'] . "',text));\n";
    $content_append .= "}\n";
    $content_append .= "function qtrans_editorInit3() {\n";
    // make tinyMCE and mediauploader get the correct data
    $content_append .= $q_config['js']['qtrans_tinyMCEOverload'];
    $content_append .= $q_config['js']['qtrans_wpActiveEditorOverload'];
    $content_append .= "}\n";
    $content_append .= $q_config['js']['qtrans_editorInit'];
    if ($init_editor) {
        $content_append .= $q_config['js']['qtrans_wpOnload'];
    } else {
        $content_append .= "var qtmsg = document.getElementById('qtrans_imsg');\n";
        $content_append .= "var et = document.getElementById('wp-" . $id . "-editor-tools');\n";
        $content_append .= "et.parentNode.insertBefore(qtmsg, et);\n";
    }
    $content_append = apply_filters('mqtranslate_modify_editor_js', $content_append);
    $content_append .= "// ]]>\n</script>\n";
    return $content . $old_content . $content_append;
}