Code Duplication    Length = 62-68 lines in 2 locations

class/Utility.php 1 location

@@ 905-972 (lines=68) @@
902
     * @param  string                                                                                                                         $supplemental
903
     * @return bool|XoopsFormDhtmlTextArea|XoopsFormEditor|XoopsFormFckeditor|XoopsFormHtmlarea|XoopsFormTextArea|XoopsFormTinyeditorTextArea
904
     */
905
public static function getWysiwygForm($caption, $name, $value = '', $width = '100%', $height = '400px', $supplemental = '')
906
{
907
    $editor_option            = strtolower(LexikonUtility::getModuleOption('form_options'));
908
    $editor                   = false;
909
    $editor_configs           = array();
910
    $editor_configs['name']   = $name;
911
    $editor_configs['value']  = $value;
912
    $editor_configs['rows']   = 35;
913
    $editor_configs['cols']   = 60;
914
    $editor_configs['width']  = '100%';
915
    $editor_configs['height'] = '350px';
916
    $editor_configs['editor'] = $editor_option;
917
918
    if (LexikonUtility::isX23()) {
919
        $editor = new XoopsFormEditor($caption, $name, $editor_configs);
920
921
        return $editor;
922
    }
923
924
        // Only for Xoops 2.0.x
925
        switch ($editor_option) {
926
            case 'fckeditor':
927
                if (is_readable(XOOPS_ROOT_PATH . '/class/fckeditor/formfckeditor.php')) {
928
                    require_once XOOPS_ROOT_PATH . '/class/fckeditor/formfckeditor.php';
929
                    $editor = new XoopsFormFckeditor($caption, $name, $value);
930
                }
931
                break;
932
933
            case 'htmlarea':
934
                if (is_readable(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php')) {
935
                    require_once XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php';
936
                    $editor = new XoopsFormHtmlarea($caption, $name, $value);
937
                }
938
                break;
939
940
            case 'dhtmltextarea':
941
            case 'dhtml':
942
                $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 50, $supplemental);
943
                break;
944
945
            case 'textarea':
946
                $editor = new XoopsFormTextArea($caption, $name, $value);
947
                break;
948
949
            case 'tinyeditor':
950
            case 'tinymce':
951
                if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php')) {
952
                    require_once XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php';
953
                    $editor = new XoopsFormTinyeditorTextArea(array(
954
                                                                  'caption' => $caption,
955
                                                                  'name'    => $name,
956
                                                                  'value'   => $value,
957
                                                                  'width'   => '100%',
958
                                                                  'height'  => '400px'
959
                                                              ));
960
                }
961
                break;
962
963
            case 'koivi':
964
                if (is_readable(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php')) {
965
                    require_once XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php';
966
                    $editor = new XoopsFormWysiwygTextArea($caption, $name, $value, $width, $height, '');
967
                }
968
                break;
969
        }
970
971
    return $editor;
972
}
973
974
    /**
975
     * linkterms: assign module header

include/functions.php 1 location

@@ 488-549 (lines=62) @@
485
 * Retreive an editor according to the module's option "form_options"
486
 * following function is from News modified by trabis
487
 */
488
function &lx_getWysiwygForm($caption, $name, $value = '', $width = '100%', $height = '400px', $supplemental='')
489
{
490
    $editor_option = strtolower(lx_getmoduleoption('form_options'));
491
    $editor = false;
492
    $editor_configs=array();
493
    $editor_configs['name'] =$name;
494
    $editor_configs['value'] = $value;
495
    $editor_configs['rows'] = 35;
496
    $editor_configs['cols'] = 60;
497
    $editor_configs['width'] = '100%';
498
    $editor_configs['height'] = '350px';
499
    $editor_configs['editor'] = $editor_option;
500
501
    if(lx_isX23()) {
502
        $editor = new XoopsFormEditor($caption, $name, $editor_configs);
503
504
        return $editor;
505
            }
506
507
    // Only for Xoops 2.0.x
508
    switch($editor_option) {
509
        case 'fckeditor':
510
            if ( is_readable(XOOPS_ROOT_PATH . '/class/fckeditor/formfckeditor.php'))    {
511
                require_once(XOOPS_ROOT_PATH . '/class/fckeditor/formfckeditor.php');
512
                $editor = new XoopsFormFckeditor($caption, $name, $value);
513
            }
514
            break;
515
516
        case 'htmlarea':
517
                if ( is_readable(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php'))    {
518
                require_once(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php');
519
                    $editor = new XoopsFormHtmlarea($caption, $name, $value);
520
            }
521
            break;
522
523
        case 'dhtmltextarea':
524
        case 'dhtml':
525
                $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 50, $supplemental);
526
            break;
527
528
        case 'textarea':
529
            $editor = new XoopsFormTextArea($caption, $name, $value);
530
            break;
531
532
        case 'tinyeditor':
533
        case 'tinymce':
534
            if ( is_readable(XOOPS_ROOT_PATH.'/class/xoopseditor/tinyeditor/formtinyeditortextarea.php')) {
535
                require_once XOOPS_ROOT_PATH.'/class/xoopseditor/tinyeditor/formtinyeditortextarea.php';
536
                $editor = new XoopsFormTinyeditorTextArea(array('caption'=> $caption, 'name'=>$name, 'value'=>$value, 'width'=>'100%', 'height'=>'400px'));
537
            }
538
            break;
539
540
        case 'koivi':
541
                if ( is_readable(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php')) {
542
                require_once(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php');
543
                $editor = new XoopsFormWysiwygTextArea($caption, $name, $value, $width, $height, '');
544
            }
545
            break;
546
        }
547
548
        return $editor;
549
}
550
551
/**
552
 * linkterms: assign module header