Code Duplication    Length = 37-42 lines in 2 locations

include/functions.php 1 location

@@ 525-561 (lines=37) @@
522
}
523
524
// clear descriptions
525
function lx_html2text($document) {
526
    // PHP Manual:: function preg_replace $document should contain an HTML document.
527
    // This will remove HTML tags, javascript sections and white space. It will also
528
    // convert some common HTML entities to their text equivalent.
529
530
    $search       = ["'<script[^>]*?>.*?</script>'si",  // Strip out javascript
531
                     "'<[\/\!]*?[^<>]*?>'si",          // Strip out HTML tags
532
                     "'([\r\n])[\s]+'",                // Strip out white space
533
                     "'&(quot|#34);'i",                // Replace HTML entities
534
                     "'&(amp|#38);'i",
535
                     "'&(lt|#60);'i",
536
                     "'&(gt|#62);'i",
537
                     "'&(nbsp|#160);'i",
538
                     "'&(iexcl|#161);'i",
539
                     "'&(cent|#162);'i",
540
                     "'&(pound|#163);'i",
541
                     "'&(copy|#169);'i"];
542
543
    $replace       = ["",
544
                      "",
545
                      "\\1",
546
                      "\"",
547
                      "&",
548
                      "<",
549
                      ">",
550
                      " ",
551
                      chr(161),
552
                      chr(162),
553
                      chr(163),
554
                      chr(169)];
555
556
    $text = preg_replace($search, $replace, $document);
557
558
    $text = preg_replace_callback("&#(\d+)&", create_function('$matches',"return chr(\$matches[1]);"),$text);
559
560
    return $text;
561
}
562
563
//Retrieve moduleoptions equivalent to $Xoopsmoduleconfig
564
function lx_getmoduleoption($option, $repmodule='lexikon') {

class/Utility.php 1 location

@@ 808-849 (lines=42) @@
805
     * @param $document
806
     * @return mixed
807
     */
808
public static function convertHtml2text($document)
809
{
810
    // PHP Manual:: function preg_replace $document should contain an HTML document.
811
        // This will remove HTML tags, javascript sections and white space. It will also
812
        // convert some common HTML entities to their text equivalent.
813
814
        $search = [
815
            "'<script[^>]*?>.*?</script>'si",  // Strip out javascript
816
            "'<[\/\!]*?[^<>]*?>'si",          // Strip out HTML tags
817
            "'([\r\n])[\s]+'",                // Strip out white space
818
            "'&(quot|#34);'i",                // Replace HTML entities
819
            "'&(amp|#38);'i",
820
            "'&(lt|#60);'i",
821
            "'&(gt|#62);'i",
822
            "'&(nbsp|#160);'i",
823
            "'&(iexcl|#161);'i",
824
            "'&(cent|#162);'i",
825
            "'&(pound|#163);'i",
826
            "'&(copy|#169);'i"
827
        ];
828
829
    $replace = [
830
            '',
831
            '',
832
            "\\1",
833
            "\"",
834
            '&',
835
            '<',
836
            '>',
837
            ' ',
838
            chr(161),
839
            chr(162),
840
            chr(163),
841
            chr(169)
842
        ];
843
844
    $text = preg_replace($search, $replace, $document);
845
846
    $text = preg_replace_callback("&#(\d+)&", create_function('$matches', "return chr(\$matches[1]);"), $text);
847
848
    return $text;
849
}
850
851
    //Retrieve moduleoptions equivalent to $Xoopsmoduleconfig
852
    /**