| @@ 796-837 (lines=42) @@ | ||
| 793 | * @param $document |
|
| 794 | * @return mixed |
|
| 795 | */ |
|
| 796 | public static function convertHtml2text($document) |
|
| 797 | { |
|
| 798 | // PHP Manual:: function preg_replace $document should contain an HTML document. |
|
| 799 | // This will remove HTML tags, javascript sections and white space. It will also |
|
| 800 | // convert some common HTML entities to their text equivalent. |
|
| 801 | ||
| 802 | $search = array( |
|
| 803 | "'<script[^>]*?>.*?</script>'si", // Strip out javascript |
|
| 804 | "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags |
|
| 805 | "'([\r\n])[\s]+'", // Strip out white space |
|
| 806 | "'&(quot|#34);'i", // Replace HTML entities |
|
| 807 | "'&(amp|#38);'i", |
|
| 808 | "'&(lt|#60);'i", |
|
| 809 | "'&(gt|#62);'i", |
|
| 810 | "'&(nbsp|#160);'i", |
|
| 811 | "'&(iexcl|#161);'i", |
|
| 812 | "'&(cent|#162);'i", |
|
| 813 | "'&(pound|#163);'i", |
|
| 814 | "'&(copy|#169);'i" |
|
| 815 | ); |
|
| 816 | ||
| 817 | $replace = array( |
|
| 818 | '', |
|
| 819 | '', |
|
| 820 | "\\1", |
|
| 821 | "\"", |
|
| 822 | '&', |
|
| 823 | '<', |
|
| 824 | '>', |
|
| 825 | ' ', |
|
| 826 | chr(161), |
|
| 827 | chr(162), |
|
| 828 | chr(163), |
|
| 829 | chr(169) |
|
| 830 | ); |
|
| 831 | ||
| 832 | $text = preg_replace($search, $replace, $document); |
|
| 833 | ||
| 834 | $text = preg_replace_callback("&#(\d+)&", create_function('$matches', "return chr(\$matches[1]);"), $text); |
|
| 835 | ||
| 836 | return $text; |
|
| 837 | } |
|
| 838 | ||
| 839 | //Retrieve moduleoptions equivalent to $Xoopsmoduleconfig |
|
| 840 | /** |
|
| @@ 401-437 (lines=37) @@ | ||
| 398 | } |
|
| 399 | ||
| 400 | // clear descriptions |
|
| 401 | function lx_html2text($document) { |
|
| 402 | // PHP Manual:: function preg_replace $document should contain an HTML document. |
|
| 403 | // This will remove HTML tags, javascript sections and white space. It will also |
|
| 404 | // convert some common HTML entities to their text equivalent. |
|
| 405 | ||
| 406 | $search = array ("'<script[^>]*?>.*?</script>'si", // Strip out javascript |
|
| 407 | "'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags |
|
| 408 | "'([\r\n])[\s]+'", // Strip out white space |
|
| 409 | "'&(quot|#34);'i", // Replace HTML entities |
|
| 410 | "'&(amp|#38);'i", |
|
| 411 | "'&(lt|#60);'i", |
|
| 412 | "'&(gt|#62);'i", |
|
| 413 | "'&(nbsp|#160);'i", |
|
| 414 | "'&(iexcl|#161);'i", |
|
| 415 | "'&(cent|#162);'i", |
|
| 416 | "'&(pound|#163);'i", |
|
| 417 | "'&(copy|#169);'i"); |
|
| 418 | ||
| 419 | $replace = array ("", |
|
| 420 | "", |
|
| 421 | "\\1", |
|
| 422 | "\"", |
|
| 423 | "&", |
|
| 424 | "<", |
|
| 425 | ">", |
|
| 426 | " ", |
|
| 427 | chr(161), |
|
| 428 | chr(162), |
|
| 429 | chr(163), |
|
| 430 | chr(169)); |
|
| 431 | ||
| 432 | $text = preg_replace($search, $replace, $document); |
|
| 433 | ||
| 434 | $text = preg_replace_callback("&#(\d+)&", create_function('$matches',"return chr(\$matches[1]);"),$text); |
|
| 435 | ||
| 436 | return $text; |
|
| 437 | } |
|
| 438 | ||
| 439 | //Retrieve moduleoptions equivalent to $Xoopsmoduleconfig |
|
| 440 | function lx_getmoduleoption($option, $repmodule='lexikon') { |
|