Code Duplication    Length = 99-102 lines in 2 locations

include/functions.php 2 locations

@@ 442-543 (lines=102) @@
439
 *
440
 * @return bool|XoopsFormDhtmlTextArea|XoopsFormEditor|XoopsFormFckeditor|XoopsFormTextArea|XoopsFormTinymce
441
 */
442
function adslight_getEditor($caption, $name, $value = '', $width = '100%', $height = '300px', $supplemental = '')
443
{
444
    global $xoopsModuleConfig, $moduleDirName;
445
    $editor = false;
446
    $x22    = false;
447
    $xv     = str_replace('XOOPS ', '', XOOPS_VERSION);
448
    if (substr($xv, 2, 1) == '2') {
449
        $x22 = true;
450
    }
451
    $editor_configs           = array();
452
    $editor_configs['name']   = $name;
453
    $editor_configs['value']  = $value;
454
    $editor_configs['rows']   = 25;
455
    $editor_configs['cols']   = 80;
456
    $editor_configs['width']  = '100%';
457
    $editor_configs['height'] = '300px';
458
459
    switch (strtolower($xoopsModuleConfig['adslight_form_options'])) {
460
461
        case 'tinymce' :
462
            if (!$x22) {
463
                if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/tinymce/formtinymce.php')) {
464
                    include_once XOOPS_ROOT_PATH . '/class/xoopseditor/tinymce/formtinymce.php';
465
                    $editor = new XoopsFormTinymce(array(
466
                                                       'caption' => $caption,
467
                                                       'name'    => $name,
468
                                                       'value'   => $value,
469
                                                       'width'   => '100%',
470
                                                       'height'  => '300px'
471
                                                   ));
472
                } else {
473
                    if ($dhtml) {
474
                        $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
475
                    } else {
476
                        $editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
477
                    }
478
                }
479
            } else {
480
                $editor = new XoopsFormEditor($caption, 'tinyeditor', $editor_configs);
481
            }
482
            break;
483
484
        case 'fckeditor' :
485
            if (!$x22) {
486
                if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/fckeditor/formfckeditor.php')) {
487
                    include_once XOOPS_ROOT_PATH . '/class/xoopseditor/fckeditor/formfckeditor.php';
488
                    $editor = new XoopsFormFckeditor($editor_configs, true);
489
                } else {
490
                    if ($dhtml) {
491
                        $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
492
                    } else {
493
                        $editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
494
                    }
495
                }
496
            } else {
497
                $editor = new XoopsFormEditor($caption, 'fckeditor', $editor_configs);
498
            }
499
            break;
500
501
        case 'koivi' :
502
            if (!$x22) {
503
                if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/koivi/formkoivi.php')) {
504
                    include_once XOOPS_ROOT_PATH . '/class/xoopseditor/koivi/formkoivi.php';
505
                    include_once XOOPS_ROOT_PATH . '/class/xoopseditor/koivi/language/english.php';
506
                    $editor = new XoopsFormKoivi($editor_configs, true);
507
                } else {
508
                    if ($dhtml) {
509
                        $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
510
                    } else {
511
                        $editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
512
                    }
513
                }
514
            } else {
515
                $editor = new XoopsFormEditor($caption, 'koivi', $editor_configs);
516
            }
517
            break;
518
519
        case 'textarea':
520
            if (!$x22) {
521
                if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/textarea/textarea.php')) {
522
                    include_once XOOPS_ROOT_PATH . '/class/xoopseditor/textarea/textarea.php';
523
                    $editor = new FormTextArea($caption, $name, $value);
524
                } else {
525
                    if ($dhtml) {
526
                        $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
527
                    } else {
528
                        $editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
529
                    }
530
                }
531
            } else {
532
                $editor = new XoopsFormEditor($caption, 'htmlarea', $editor_configs);
533
            }
534
            break;
535
536
        default :
537
            //        if ($dhtml) {
538
            include_once XOOPS_ROOT_PATH . '/class/xoopseditor/dhtmltextarea/dhtmltextarea.php';
539
            $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 40, $supplemental);
540
            //       } else {
541
            //           $editor = new XoopsFormEditor($caption, 'dhtmltextarea', $editor_configs);
542
            //       }
543
544
            break;
545
    }
546
@@ 560-658 (lines=99) @@
557
 *
558
 * @return bool|XoopsFormDhtmlTextArea|XoopsFormEditor|XoopsFormFckeditor|XoopsFormTextArea|XoopsFormTinymce
559
 */
560
function adslight_adminEditor($caption, $name, $value = '', $width = '100%', $height = '300px', $supplemental = '')
561
{
562
    global $xoopsModuleConfig, $moduleDirName;
563
    $editor = false;
564
    $x22    = false;
565
    $xv     = str_replace('XOOPS ', '', XOOPS_VERSION);
566
    if (substr($xv, 2, 1) == '2') {
567
        $x22 = true;
568
    }
569
    $editor_configs           = array();
570
    $editor_configs['name']   = $name;
571
    $editor_configs['value']  = $value;
572
    $editor_configs['rows']   = 35;
573
    $editor_configs['cols']   = 60;
574
    $editor_configs['width']  = '100%';
575
    $editor_configs['height'] = '300px';
576
577
    switch (strtolower($xoopsModuleConfig['adslight_admin_editor'])) {
578
579
        case 'tinymce' :
580
            if (!$x22) {
581
                if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/tinymce/formtinymce.php')) {
582
                    include_once XOOPS_ROOT_PATH . '/class/xoopseditor/tinymce/formtinymce.php';
583
                    $editor = new XoopsFormTinymce(array(
584
                                                       'caption' => $caption,
585
                                                       'name'    => $name,
586
                                                       'value'   => $value,
587
                                                       'width'   => '100%',
588
                                                       'height'  => '300px'
589
                                                   ));
590
                } else {
591
                    if ($dhtml) {
592
                        $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
593
                    } else {
594
                        $editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
595
                    }
596
                }
597
            } else {
598
                $editor = new XoopsFormEditor($caption, 'tinyeditor', $editor_configs);
599
            }
600
            break;
601
602
        case 'fckeditor' :
603
            if (!$x22) {
604
                if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/fckeditor/formfckeditor.php')) {
605
                    include_once XOOPS_ROOT_PATH . '/class/xoopseditor/fckeditor/formfckeditor.php';
606
                    $editor = new XoopsFormFckeditor($editor_configs, true);
607
                } else {
608
                    if ($dhtml) {
609
                        $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
610
                    } else {
611
                        $editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
612
                    }
613
                }
614
            } else {
615
                $editor = new XoopsFormEditor($caption, 'fckeditor', $editor_configs);
616
            }
617
            break;
618
619
        case 'koivi' :
620
            if (!$x22) {
621
                if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/koivi/formkoivi.php')) {
622
                    include_once XOOPS_ROOT_PATH . '/class/xoopseditor/koivi/formkoivi.php';
623
                    include_once XOOPS_ROOT_PATH . '/class/xoopseditor/koivi/language/english.php';
624
                    $editor = new XoopsFormKoivi($editor_configs, true);
625
                } else {
626
                    if ($dhtml) {
627
                        $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
628
                    } else {
629
                        $editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
630
                    }
631
                }
632
            } else {
633
                $editor = new XoopsFormEditor($caption, 'koivi', $editor_configs);
634
            }
635
            break;
636
637
        case 'textarea':
638
            if (!$x22) {
639
                if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/textarea/textarea.php')) {
640
                    include_once XOOPS_ROOT_PATH . '/class/xoopseditor/textarea/textarea.php';
641
                    $editor = new FormTextArea($caption, $name, $value);
642
                } else {
643
                    if ($dhtml) {
644
                        $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60);
645
                    } else {
646
                        $editor = new XoopsFormTextArea($caption, $name, $value, 7, 60);
647
                    }
648
                }
649
            } else {
650
                $editor = new XoopsFormEditor($caption, 'textarea', $editor_configs);
651
            }
652
            break;
653
654
        default :
655
656
            include_once XOOPS_ROOT_PATH . '/class/xoopseditor/dhtmltextarea/dhtmltextarea.php';
657
            $editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 40, $supplemental);
658
659
            break;
660
    }
661