Code Duplication    Length = 62-68 lines in 2 locations

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

class/Utility.php 1 location

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