Project

General

Profile

« Previous | Next » 

Revision 478

Added by Matthias almost 17 years ago

speeded up highlighting on big WYSIWYG pages;
fixed: '>' wasn't shown in highlighting result;
Thanks to thorn

View differences:

trunk/wb/framework/frontend.functions.php
75 75
	$search_string = implode("|", $arr_string);
76 76
	$string = entities_to_umlauts($search_string, 'UTF-8');
77 77
	$string = strtr($string, $string_ul_umlauts);
78
	$foo = strtr($foo, array("<"=>"!,,!", ">"=>"!,,,!", "&"=>"!,,,,!", """=>"!,,,,,!", "'"=>"!,,,,,,!"));
79
	$string = strtr($string, array("<"=>"!,,!", ">"=>"!,,,!", "&"=>"!,,,,!", """=>"!,,,,,!", "'"=>"!,,,,,,!"));
78 80
	$foo = preg_replace('/('.$string.')(?=[^>]*<)/iUS', '<span class="highlight">$1</span>',$foo);
79 81
	$pos = strpos($foo, '<');
80 82
	if ($pos === false) { // "===" means identicaly
81 83
		$foo = preg_replace('/('.$string.')/i', '<span class="highlight">$1</span>',$foo);
82 84
	}
83
	$foo = umlauts_to_entities($foo, 'UTF-8', 0);
85
	$foo = strtr($foo, array("!,,!"=>"&lt;", "!,,,!"=>"&gt;", "!,,,,!"=>"&amp;", "!,,,,,!"=>"&quot;", "!,,,,,,!"=>"&#039;"));
86
	if(DEFAULT_CHARSET != 'utf-8') {
87
		$foo = mb_convert_encoding_wrapper($foo, DEFAULT_CHARSET, 'UTF-8');
88
		//$foo = umlauts_to_entities($foo, 'UTF-8');
89
	}
84 90
	return $foo;
85 91
}
86 92

  
trunk/wb/framework/functions.php
488 488
		'&Aacute;'=>'&#193;','&aacute;'=>'&#225;',
489 489
		'&Acirc;'=>'&#194;','&acirc;'=>'&#226;','&acute;'=>'&#180;','&AElig;'=>'&#198;','&aelig;'=>'&#230;',
490 490
		'&Agrave;'=>'&#192;','&agrave;'=>'&#224;','&alefsym;'=>'&#8501;','&Alpha;'=>'&#913;','&alpha;'=>'&#945;',
491
		'&amp;'=>'&#38;','&and;'=>'&#8743;','&ang;'=>'&#8736;','&apos;'=>'&#39;','&Aring;'=>'&#197;','&aring;'=>'&#229;',
491
		'&and;'=>'&#8743;','&ang;'=>'&#8736;','&apos;'=>'&#39;','&Aring;'=>'&#197;','&aring;'=>'&#229;',
492 492
		'&asymp;'=>'&#8776;','&Atilde;'=>'&#195;','&atilde;'=>'&#227;','&Auml;'=>'&#196;','&auml;'=>'&#228;',
493 493
		'&bdquo;'=>'&#8222;','&Beta;'=>'&#914;','&beta;'=>'&#946;','&brvbar;'=>'&#166;','&bull;'=>'&#8226;',
494 494
		'&cap;'=>'&#8745;','&Ccedil;'=>'&#199;','&ccedil;'=>'&#231;','&cedil;'=>'&#184;','&cent;'=>'&#162;',
......
501 501
		'&Eta;'=>'&#919;','&eta;'=>'&#951;','&ETH;'=>'&#208;','&eth;'=>'&#240;','&Euml;'=>'&#203;','&euml;'=>'&#235;',
502 502
		'&euro;'=>'&#8364;','&exist;'=>'&#8707;','&fnof;'=>'&#402;','&forall;'=>'&#8704;','&frac12;'=>'&#189;',
503 503
		'&frac14;'=>'&#188;','&frac34;'=>'&#190;','&frasl;'=>'&#8260;','&Gamma;'=>'&#915;','&gamma;'=>'&#947;',
504
		'&ge;'=>'&#8805;','&gt;'=>'&#62;','&hArr;'=>'&#8660;','&harr;'=>'&#8596;','&hearts;'=>'&#9829;',
504
		'&ge;'=>'&#8805;','&hArr;'=>'&#8660;','&harr;'=>'&#8596;','&hearts;'=>'&#9829;',
505 505
		'&hellip;'=>'&#8230;','&Iacute;'=>'&#205;','&iacute;'=>'&#237;','&Icirc;'=>'&#206;','&icirc;'=>'&#238;',
506 506
		'&iexcl;'=>'&#161;','&Igrave;'=>'&#204;','&igrave;'=>'&#236;','&image;'=>'&#8465;','&infin;'=>'&#8734;',
507 507
		'&int;'=>'&#8747;','&Iota;'=>'&#921;','&iota;'=>'&#953;','&iquest;'=>'&#191;','&isin;'=>'&#8712;',
508 508
		'&Iuml;'=>'&#207;','&iuml;'=>'&#239;','&Kappa;'=>'&#922;','&kappa;'=>'&#954;','&Lambda;'=>'&#923;',
509 509
		'&lambda;'=>'&#955;','&lang;'=>'&#9001;','&laquo;'=>'&#171;','&lArr;'=>'&#8656;','&larr;'=>'&#8592;',
510 510
		'&lceil;'=>'&#8968;','&ldquo;'=>'&#8220;','&le;'=>'&#8804;','&lfloor;'=>'&#8970;','&lowast;'=>'&#8727;',
511
		'&loz;'=>'&#9674;','&lrm;'=>'&#8206;','&lsaquo;'=>'&#8249;','&lsquo;'=>'&#8216;','&lt;'=>'&#60;',
511
		'&loz;'=>'&#9674;','&lrm;'=>'&#8206;','&lsaquo;'=>'&#8249;','&lsquo;'=>'&#8216;',
512 512
		'&macr;'=>'&#175;','&mdash;'=>'&#8212;','&micro;'=>'&#181;','&middot;'=>'&#183;','&minus;'=>'&#8722;',
513 513
		'&Mu;'=>'&#924;','&mu;'=>'&#956;','&nabla;'=>'&#8711;','&nbsp;'=>'&#160;','&ndash;'=>'&#8211;',
514 514
		'&ne;'=>'&#8800;','&ni;'=>'&#8715;','&not;'=>'&#172;','&notin;'=>'&#8713;','&nsub;'=>'&#8836;',
......
540 540
	$numbered_to_named_entities=array(
541 541
		'&#193;'=>'&Aacute;','&#225;'=>'&aacute;','&#194;'=>'&Acirc;','&#226;'=>'&acirc;','&#180;'=>'&acute;',
542 542
		'&#198;'=>'&AElig;','&#230;'=>'&aelig;','&#192;'=>'&Agrave;','&#224;'=>'&agrave;','&#8501;'=>'&alefsym;',
543
		'&#913;'=>'&Alpha;','&#945;'=>'&alpha;','&#38;'=>'&amp;','&#8743;'=>'&and;','&#8736;'=>'&ang;',
543
		'&#913;'=>'&Alpha;','&#945;'=>'&alpha;','&#8743;'=>'&and;','&#8736;'=>'&ang;',
544 544
		'&#39;'=>'&apos;','&#197;'=>'&Aring;','&#229;'=>'&aring;','&#8776;'=>'&asymp;','&#195;'=>'&Atilde;',
545 545
		'&#227;'=>'&atilde;','&#196;'=>'&Auml;','&#228;'=>'&auml;','&#8222;'=>'&bdquo;','&#914;'=>'&Beta;',
546 546
		'&#946;'=>'&beta;','&#166;'=>'&brvbar;','&#8226;'=>'&bull;','&#8745;'=>'&cap;','&#199;'=>'&Ccedil;',
......
554 554
		'&#208;'=>'&ETH;','&#240;'=>'&eth;','&#203;'=>'&Euml;','&#235;'=>'&euml;','&#8364;'=>'&euro;',
555 555
		'&#8707;'=>'&exist;','&#402;'=>'&fnof;','&#8704;'=>'&forall;','&#189;'=>'&frac12;','&#188;'=>'&frac14;',
556 556
		'&#190;'=>'&frac34;','&#8260;'=>'&frasl;','&#915;'=>'&Gamma;','&#947;'=>'&gamma;','&#8805;'=>'&ge;',
557
		'&#62;'=>'&gt;','&#8660;'=>'&hArr;','&#8596;'=>'&harr;','&#9829;'=>'&hearts;','&#8230;'=>'&hellip;',
557
		'&#8660;'=>'&hArr;','&#8596;'=>'&harr;','&#9829;'=>'&hearts;','&#8230;'=>'&hellip;',
558 558
		'&#205;'=>'&Iacute;','&#237;'=>'&iacute;','&#206;'=>'&Icirc;','&#238;'=>'&icirc;','&#161;'=>'&iexcl;',
559 559
		'&#204;'=>'&Igrave;','&#236;'=>'&igrave;','&#8465;'=>'&image;','&#8734;'=>'&infin;','&#8747;'=>'&int;',
560 560
		'&#921;'=>'&Iota;','&#953;'=>'&iota;','&#191;'=>'&iquest;','&#8712;'=>'&isin;','&#207;'=>'&Iuml;',
561 561
		'&#239;'=>'&iuml;','&#922;'=>'&Kappa;','&#954;'=>'&kappa;','&#923;'=>'&Lambda;','&#955;'=>'&lambda;',
562 562
		'&#9001;'=>'&lang;','&#171;'=>'&laquo;','&#8656;'=>'&lArr;','&#8592;'=>'&larr;','&#8968;'=>'&lceil;',
563 563
		'&#8220;'=>'&ldquo;','&#8804;'=>'&le;','&#8970;'=>'&lfloor;','&#8727;'=>'&lowast;','&#9674;'=>'&loz;',
564
		'&#8206;'=>'&lrm;','&#8249;'=>'&lsaquo;','&#8216;'=>'&lsquo;','&#60;'=>'&lt;','&#175;'=>'&macr;',
564
		'&#8206;'=>'&lrm;','&#8249;'=>'&lsaquo;','&#8216;'=>'&lsquo;','&#175;'=>'&macr;',
565 565
		'&#8212;'=>'&mdash;','&#181;'=>'&micro;','&#183;'=>'&middot;','&#8722;'=>'&minus;','&#924;'=>'&Mu;',
566 566
		'&#956;'=>'&mu;','&#8711;'=>'&nabla;','&#160;'=>'&nbsp;','&#8211;'=>'&ndash;','&#8800;'=>'&ne;',
567 567
		'&#8715;'=>'&ni;','&#172;'=>'&not;','&#8713;'=>'&notin;','&#8836;'=>'&nsub;','&#209;'=>'&Ntilde;',
......
695 695
		// decode html-entities
696 696
		if(preg_match("/&[#a-zA-Z0-9]+;/", $string)) {
697 697
			$string=string_decode_encode_entities($string, 'UTF-8', 'HTML-ENTITIES');
698
			//$string=mb_convert_encoding_wrapper($string, 'HTML-ENTITIES', 'UTF-8');
699
			//$string=mb_convert_encoding_wrapper($string, 'UTF-8', 'HTML-ENTITIES');
698 700
		}
699 701
	}
700 702
	else {
......
721 723
			$string=utf8_encode($string);
722 724
		}
723 725
		// encode html-entities
724
		$string=string_decode_encode_entities($string, 'HTML-ENTITIES', 'UTF-8');
725
		//$string=mb_convert_encoding_wrapper($string, 'HTML-ENTITIES', 'UTF-8');
726
		//$string=string_decode_encode_entities($string, 'HTML-ENTITIES', 'UTF-8');
727
		$string=mb_convert_encoding_wrapper($string, 'HTML-ENTITIES', 'UTF-8');
726 728
	}
727 729
	else {
728 730
		$string = string_to_utf8($string, $charset_in);
729 731
		// encode html-entities
730 732
		if (is_UTF8($string)) {
731
			$string=string_decode_encode_entities($string, 'HTML-ENTITIES', 'UTF-8');
732
			//$string=mb_convert_encoding_wrapper($string, 'HTML-ENTITIES', 'UTF-8');
733
			//$string=string_decode_encode_entities($string, 'HTML-ENTITIES', 'UTF-8');
734
			$string=mb_convert_encoding_wrapper($string, 'HTML-ENTITIES', 'UTF-8');
733 735
		}
734 736
	}
735 737
	return $string;

Also available in: Unified diff