http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88592

Revision: 88592
Author:   yaron
Date:     2011-05-22 18:12:18 +0000 (Sun, 22 May 2011)
Log Message:
-----------
Added some code to improve FCKeditor display, from ontoprise; removed handling 
of CKeditor/WYSIWYG extensions, added in r87891 (will now be handled by hooks); 
removed default setting of user options via $wgDefaultUserOptions (caused 
problems and not necessary)

Modified Paths:
--------------
    trunk/extensions/SemanticForms/includes/SF_FormUtils.php

Modified: trunk/extensions/SemanticForms/includes/SF_FormUtils.php
===================================================================
--- trunk/extensions/SemanticForms/includes/SF_FormUtils.php    2011-05-22 
18:09:59 UTC (rev 88591)
+++ trunk/extensions/SemanticForms/includes/SF_FormUtils.php    2011-05-22 
18:12:18 UTC (rev 88592)
@@ -372,14 +372,20 @@
        static function getShowFCKEditor() {
                global $wgUser, $wgDefaultUserOptions;
 
+               // Differentiate between FCKeditor and the newer CKeditor,
+               // which isn't handled here
+               if ( !class_exists( 'FCKeditor' ) ) {
+                       return false;
+               }
+
                $showFCKEditor = 0;
-               if ( !array_key_exists( 'riched_start_disabled', 
$wgDefaultUserOptions) && !$wgUser->getOption( 'riched_start_disabled' ) ) {
+               if ( !$wgUser->getOption( 'riched_start_disabled' ) ) {
                        $showFCKEditor += RTE_VISIBLE;
                }
-               if ( array_key_exists( 'riched_use_popup', 
$wgDefaultUserOptions ) || $wgUser->getOption( 'riched_use_popup' ) ) {
+               if ( $wgUser->getOption( 'riched_use_popup' ) ) {
                        $showFCKEditor += RTE_POPUP;
                }
-               if ( array_key_exists( 'riched_use_toggle', 
$wgDefaultUserOptions ) || $wgUser->getOption( 'riched_use_toggle' ) ) {
+               if ( $wgUser->getOption( 'riched_use_toggle' ) ) {
                        $showFCKEditor += RTE_TOGGLE_LINK;
                }
 
@@ -404,10 +410,12 @@
                return $text;
        }
 
-       static function mainFCKJavascript( $showFCKEditor ) {
+       static function mainFCKJavascript( $showFCKEditor, $fieldArgs ) {
                global $wgUser, $wgScriptPath, $wgFCKEditorExtDir, 
$wgFCKEditorDir, $wgFCKEditorToolbarSet, $wgFCKEditorHeight;
                global $wgHooks, $wgExtensionFunctions;
 
+               $numRows = isset( $fieldArgs['rows'] ) && $fieldArgs['rows'] > 
0 ? $fieldArgs['rows'] : 5;
+
                $newWinMsg = wfMsg( 'rich_editor_new_window' );
                $javascript_text = '
 var showFCKEditor = ' . $showFCKEditor . ';
@@ -440,8 +448,7 @@
                        $wgFCKEditorDir .= '/';
                }
                
-               if ( class_exists('FCKeditor') ) {
-                       $javascript_text .= <<<END
+               $javascript_text .= <<<END
 var oFCKeditor = new FCKeditor( "free_text" );
 
 //Set config
@@ -463,6 +470,32 @@
        );
 }
 
+// If the rows attribute was defined in the form, use the font size to
+// calculate the editor window height
+function getFontSize(el) {
+       var x = document.getElementById(el);
+       if (x.currentStyle) {
+               // IE
+               var y = x.currentStyle['lineheight'];
+       } else if (window.getComputedStyle) {
+               // FF, Opera
+               var y = 
document.defaultView.getComputedStyle(x,null).getPropertyValue('line-height');
+       }
+       return y;
+}
+function getWindowHeight4editor() {
+       var fsize = getFontSize('free_text');
+       // if value was not determined, return default val from 
$wgFCKEditorHeight
+       if (!fsize) return $FCKEditorHeight;
+       if (fsize.indexOf('px') == -1)  // we didn't get pixels
+               // arbitary value, don't hassle with caluclating
+               return $FCKEditorHeight;
+       var px = parseFloat(fsize.replace(/\w{2}$/, ''));
+       // the text in the edit window is slightly larger than the determined 
value
+       px = px * 1.25;
+       return Math.round( px * $numRows );
+}
+
 function onLoadFCKeditor()
 {
        if (!(showFCKEditor & RTE_VISIBLE)) 
@@ -660,17 +693,12 @@
 addOnloadHook( initEditor );
 
 END;
-               } else {
-                       // CKeditor instead of FCKeditor
-                       $javascript_text = 
CKeditor_MediaWiki::InitializeScripts('free_text', $newWinMsg);
-               }
                return $javascript_text;
        }
 
        static function FCKToggleJavascript() {
                // add toggle link and handler
-               if ( class_exists('FCKeditor') ) {
-                       $javascript_text = <<<END
+               $javascript_text = <<<END
 
 function ToggleFCKEditor(mode, objId)
 {
@@ -775,10 +803,6 @@
 }
 
 END;
-               } else {
-                       // CKeditor instead of FCKeditor
-                       $javascript_text = CKeditor_MediaWiki::ToggleScript();
-               }
                return $javascript_text;
        }
 


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to