Index: trunk/extensions/SemanticForms/includes/SF_FormUtils.php |
— | — | @@ -372,14 +372,20 @@ |
373 | 373 | static function getShowFCKEditor() { |
374 | 374 | global $wgUser, $wgDefaultUserOptions; |
375 | 375 | |
| 376 | + // Differentiate between FCKeditor and the newer CKeditor, |
| 377 | + // which isn't handled here |
| 378 | + if ( !class_exists( 'FCKeditor' ) ) { |
| 379 | + return false; |
| 380 | + } |
| 381 | + |
376 | 382 | $showFCKEditor = 0; |
377 | | - if ( !array_key_exists( 'riched_start_disabled', $wgDefaultUserOptions) && !$wgUser->getOption( 'riched_start_disabled' ) ) { |
| 383 | + if ( !$wgUser->getOption( 'riched_start_disabled' ) ) { |
378 | 384 | $showFCKEditor += RTE_VISIBLE; |
379 | 385 | } |
380 | | - if ( array_key_exists( 'riched_use_popup', $wgDefaultUserOptions ) || $wgUser->getOption( 'riched_use_popup' ) ) { |
| 386 | + if ( $wgUser->getOption( 'riched_use_popup' ) ) { |
381 | 387 | $showFCKEditor += RTE_POPUP; |
382 | 388 | } |
383 | | - if ( array_key_exists( 'riched_use_toggle', $wgDefaultUserOptions ) || $wgUser->getOption( 'riched_use_toggle' ) ) { |
| 389 | + if ( $wgUser->getOption( 'riched_use_toggle' ) ) { |
384 | 390 | $showFCKEditor += RTE_TOGGLE_LINK; |
385 | 391 | } |
386 | 392 | |
— | — | @@ -404,10 +410,12 @@ |
405 | 411 | return $text; |
406 | 412 | } |
407 | 413 | |
408 | | - static function mainFCKJavascript( $showFCKEditor ) { |
| 414 | + static function mainFCKJavascript( $showFCKEditor, $fieldArgs ) { |
409 | 415 | global $wgUser, $wgScriptPath, $wgFCKEditorExtDir, $wgFCKEditorDir, $wgFCKEditorToolbarSet, $wgFCKEditorHeight; |
410 | 416 | global $wgHooks, $wgExtensionFunctions; |
411 | 417 | |
| 418 | + $numRows = isset( $fieldArgs['rows'] ) && $fieldArgs['rows'] > 0 ? $fieldArgs['rows'] : 5; |
| 419 | + |
412 | 420 | $newWinMsg = wfMsg( 'rich_editor_new_window' ); |
413 | 421 | $javascript_text = ' |
414 | 422 | var showFCKEditor = ' . $showFCKEditor . '; |
— | — | @@ -440,8 +448,7 @@ |
441 | 449 | $wgFCKEditorDir .= '/'; |
442 | 450 | } |
443 | 451 | |
444 | | - if ( class_exists('FCKeditor') ) { |
445 | | - $javascript_text .= <<<END |
| 452 | + $javascript_text .= <<<END |
446 | 453 | var oFCKeditor = new FCKeditor( "free_text" ); |
447 | 454 | |
448 | 455 | //Set config |
— | — | @@ -463,6 +470,32 @@ |
464 | 471 | ); |
465 | 472 | } |
466 | 473 | |
| 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 | + |
467 | 500 | function onLoadFCKeditor() |
468 | 501 | { |
469 | 502 | if (!(showFCKEditor & RTE_VISIBLE)) |
— | — | @@ -660,17 +693,12 @@ |
661 | 694 | addOnloadHook( initEditor ); |
662 | 695 | |
663 | 696 | END; |
664 | | - } else { |
665 | | - // CKeditor instead of FCKeditor |
666 | | - $javascript_text = CKeditor_MediaWiki::InitializeScripts('free_text', $newWinMsg); |
667 | | - } |
668 | 697 | return $javascript_text; |
669 | 698 | } |
670 | 699 | |
671 | 700 | static function FCKToggleJavascript() { |
672 | 701 | // add toggle link and handler |
673 | | - if ( class_exists('FCKeditor') ) { |
674 | | - $javascript_text = <<<END |
| 702 | + $javascript_text = <<<END |
675 | 703 | |
676 | 704 | function ToggleFCKEditor(mode, objId) |
677 | 705 | { |
— | — | @@ -775,10 +803,6 @@ |
776 | 804 | } |
777 | 805 | |
778 | 806 | END; |
779 | | - } else { |
780 | | - // CKeditor instead of FCKeditor |
781 | | - $javascript_text = CKeditor_MediaWiki::ToggleScript(); |
782 | | - } |
783 | 807 | return $javascript_text; |
784 | 808 | } |
785 | 809 | |