Code Duplication    Length = 62-68 lines in 2 locations

class/Utility.php 1 location

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

include/functions.php 1 location

@@ 612-673 (lines=62) @@
609
 * Retreive an editor according to the module's option "form_options"
610
 * following function is from News modified by trabis
611
 */
612
function &lx_getWysiwygForm($caption, $name, $value = '', $width = '100%', $height = '400px', $supplemental='')
613
{
614
    $editor_option = strtolower(lx_getmoduleoption('form_options'));
615
    $editor = false;
616
    $editor_configs = [];
617
    $editor_configs['name'] = $name;
618
    $editor_configs['value'] = $value;
619
    $editor_configs['rows'] = 35;
620
    $editor_configs['cols'] = 60;
621
    $editor_configs['width'] = '100%';
622
    $editor_configs['height'] = '350px';
623
    $editor_configs['editor'] = $editor_option;
624
625
    if(lx_isX23()) {
626
        $editor = new XoopsFormEditor($caption, $name, $editor_configs);
627
628
        return $editor;
629
            }
630
631
    // Only for Xoops 2.0.x
632
    switch($editor_option) {
633
        case 'fckeditor':
634
            if ( is_readable(XOOPS_ROOT_PATH . '/class/fckeditor/formfckeditor.php'))    {
635
                require_once(XOOPS_ROOT_PATH . '/class/fckeditor/formfckeditor.php');
636
                $editor = new XoopsFormFckeditor($caption, $name, $value);
637
            }
638
            break;
639
640
        case 'htmlarea':
641
                if ( is_readable(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php'))    {
642
                require_once(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php');
643
                    $editor = new XoopsFormHtmlarea($caption, $name, $value);
644
            }
645
            break;
646
647
        case 'dhtmltextarea':
648
        case 'dhtml':
649
                $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 50, $supplemental);
650
            break;
651
652
        case 'textarea':
653
            $editor = new XoopsFormTextArea($caption, $name, $value);
654
            break;
655
656
        case 'tinyeditor':
657
        case 'tinymce':
658
            if ( is_readable(XOOPS_ROOT_PATH.'/class/xoopseditor/tinyeditor/formtinyeditortextarea.php')) {
659
                require_once XOOPS_ROOT_PATH.'/class/xoopseditor/tinyeditor/formtinyeditortextarea.php';
660
                $editor = new XoopsFormTinyeditorTextArea(array('caption'=> $caption, 'name'=>$name, 'value'=>$value, 'width'=>'100%', 'height'=>'400px'));
661
            }
662
            break;
663
664
        case 'koivi':
665
                if ( is_readable(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php')) {
666
                require_once(XOOPS_ROOT_PATH . '/class/wysiwyg/formwysiwygtextarea.php');
667
                $editor = new XoopsFormWysiwygTextArea($caption, $name, $value, $width, $height, '');
668
            }
669
            break;
670
        }
671
672
        return $editor;
673
}
674
675
/**
676
 * linkterms: assign module header