r88592 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88591‎ | r88592 | r88593 >
Date:18:12, 22 May 2011
Author:yaron
Status:deferred
Tags:
Comment:
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) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormUtils.php
@@ -372,14 +372,20 @@
373373 static function getShowFCKEditor() {
374374 global $wgUser, $wgDefaultUserOptions;
375375
 376+ // Differentiate between FCKeditor and the newer CKeditor,
 377+ // which isn't handled here
 378+ if ( !class_exists( 'FCKeditor' ) ) {
 379+ return false;
 380+ }
 381+
376382 $showFCKEditor = 0;
377 - if ( !array_key_exists( 'riched_start_disabled', $wgDefaultUserOptions) && !$wgUser->getOption( 'riched_start_disabled' ) ) {
 383+ if ( !$wgUser->getOption( 'riched_start_disabled' ) ) {
378384 $showFCKEditor += RTE_VISIBLE;
379385 }
380 - if ( array_key_exists( 'riched_use_popup', $wgDefaultUserOptions ) || $wgUser->getOption( 'riched_use_popup' ) ) {
 386+ if ( $wgUser->getOption( 'riched_use_popup' ) ) {
381387 $showFCKEditor += RTE_POPUP;
382388 }
383 - if ( array_key_exists( 'riched_use_toggle', $wgDefaultUserOptions ) || $wgUser->getOption( 'riched_use_toggle' ) ) {
 389+ if ( $wgUser->getOption( 'riched_use_toggle' ) ) {
384390 $showFCKEditor += RTE_TOGGLE_LINK;
385391 }
386392
@@ -404,10 +410,12 @@
405411 return $text;
406412 }
407413
408 - static function mainFCKJavascript( $showFCKEditor ) {
 414+ static function mainFCKJavascript( $showFCKEditor, $fieldArgs ) {
409415 global $wgUser, $wgScriptPath, $wgFCKEditorExtDir, $wgFCKEditorDir, $wgFCKEditorToolbarSet, $wgFCKEditorHeight;
410416 global $wgHooks, $wgExtensionFunctions;
411417
 418+ $numRows = isset( $fieldArgs['rows'] ) && $fieldArgs['rows'] > 0 ? $fieldArgs['rows'] : 5;
 419+
412420 $newWinMsg = wfMsg( 'rich_editor_new_window' );
413421 $javascript_text = '
414422 var showFCKEditor = ' . $showFCKEditor . ';
@@ -440,8 +448,7 @@
441449 $wgFCKEditorDir .= '/';
442450 }
443451
444 - if ( class_exists('FCKeditor') ) {
445 - $javascript_text .= <<<END
 452+ $javascript_text .= <<<END
446453 var oFCKeditor = new FCKeditor( "free_text" );
447454
448455 //Set config
@@ -463,6 +470,32 @@
464471 );
465472 }
466473
 474+// If the rows attribute was defined in the form, use the font size to
 475+// calculate the editor window height
 476+function getFontSize(el) {
 477+ var x = document.getElementById(el);
 478+ if (x.currentStyle) {
 479+ // IE
 480+ var y = x.currentStyle['lineheight'];
 481+ } else if (window.getComputedStyle) {
 482+ // FF, Opera
 483+ var y = document.defaultView.getComputedStyle(x,null).getPropertyValue('line-height');
 484+ }
 485+ return y;
 486+}
 487+function getWindowHeight4editor() {
 488+ var fsize = getFontSize('free_text');
 489+ // if value was not determined, return default val from $wgFCKEditorHeight
 490+ if (!fsize) return $FCKEditorHeight;
 491+ if (fsize.indexOf('px') == -1) // we didn't get pixels
 492+ // arbitary value, don't hassle with caluclating
 493+ return $FCKEditorHeight;
 494+ var px = parseFloat(fsize.replace(/\w{2}$/, ''));
 495+ // the text in the edit window is slightly larger than the determined value
 496+ px = px * 1.25;
 497+ return Math.round( px * $numRows );
 498+}
 499+
467500 function onLoadFCKeditor()
468501 {
469502 if (!(showFCKEditor & RTE_VISIBLE))
@@ -660,17 +693,12 @@
661694 addOnloadHook( initEditor );
662695
663696 END;
664 - } else {
665 - // CKeditor instead of FCKeditor
666 - $javascript_text = CKeditor_MediaWiki::InitializeScripts('free_text', $newWinMsg);
667 - }
668697 return $javascript_text;
669698 }
670699
671700 static function FCKToggleJavascript() {
672701 // add toggle link and handler
673 - if ( class_exists('FCKeditor') ) {
674 - $javascript_text = <<<END
 702+ $javascript_text = <<<END
675703
676704 function ToggleFCKEditor(mode, objId)
677705 {
@@ -775,10 +803,6 @@
776804 }
777805
778806 END;
779 - } else {
780 - // CKeditor instead of FCKeditor
781 - $javascript_text = CKeditor_MediaWiki::ToggleScript();
782 - }
783807 return $javascript_text;
784808 }
785809

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r87891Added changes suggested by ontoprise/SMW+, to improved support for FCKeditoryaron20:29, 11 May 2011