mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-25 02:27:50 +01:00
rewrote convert_chars - hi again guys! :)
git-svn-id: http://svn.automattic.com/wordpress/trunk@306 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
805ab8be54
commit
3f3adc6824
@ -196,76 +196,36 @@ function get_weekstartend($mysqlstring, $start_of_week) {
|
|||||||
return $week;
|
return $week;
|
||||||
}
|
}
|
||||||
|
|
||||||
function convert_chars($content,$flag="html") { // html/unicode entities output, defaults to html
|
function convert_chars($content,$flag='obsolete attribute left there for backwards compatibility') { // html/unicode entities output
|
||||||
$newcontent = "";
|
|
||||||
|
|
||||||
global $convert_chars2unicode, $convert_entities2unicode, $leavecodealone, $use_htmltrans;
|
global $use_htmltrans, $b2_htmltrans, $b2_htmltranswinuni;
|
||||||
global $b2_htmltrans, $b2_htmltranswinuni;
|
|
||||||
|
|
||||||
### this is temporary - will be replaced by proper config stuff
|
// removes metadata tags
|
||||||
$convert_chars2unicode = 1;
|
$content = preg_replace('/<title>(.+?)<\/title>/','',$content);
|
||||||
if (($leavecodealone) || (!$use_htmltrans)) {
|
$content = preg_replace('/<category>(.+?)<\/category>/','',$content);
|
||||||
$convert_chars2unicode = 0;
|
|
||||||
}
|
|
||||||
###
|
|
||||||
|
|
||||||
|
if ($use_htmltrans) {
|
||||||
|
|
||||||
|
// converts lone & characters into & (a.k.a. &)
|
||||||
|
$content = preg_replace('/&[^#](?![a-z]*;)/ie', '"&".substr("\0",1)', $content);
|
||||||
|
|
||||||
// converts HTML-entities to their display values in order to convert them again later
|
// converts HTML-entities to their display values in order to convert them again later
|
||||||
|
$content = preg_replace('/['.chr(127).'-'.chr(255).']/e', '"&#".ord(\0).";"', $content );
|
||||||
$content = preg_replace("/<title>(.+?)<\/title>/","",$content);
|
|
||||||
$content = preg_replace("/<category>(.+?)<\/category>/","",$content);
|
|
||||||
|
|
||||||
# $content = str_replace("&","&",$content);
|
|
||||||
$content = strtr($content, $b2_htmltrans);
|
$content = strtr($content, $b2_htmltrans);
|
||||||
|
|
||||||
return $content;
|
|
||||||
|
|
||||||
// the following is the slowest. code. ever.
|
|
||||||
/*
|
|
||||||
for ($i=0; $i<strlen($content); $i=$i+1) {
|
|
||||||
$j = substr($content,$i,1);
|
|
||||||
$jnext = substr($content,$i+1,1);
|
|
||||||
$jord = ord($j);
|
|
||||||
if ($convert_chars2unicode) {
|
|
||||||
switch($flag) {
|
|
||||||
case "unicode":
|
|
||||||
// $j = str_replace("&","&",$j);
|
|
||||||
if (($jord>=128) || ($j == "&") || (($jord>=128) && ($jord<=159))) {
|
|
||||||
$j = "&#".$jord.";";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "html":
|
|
||||||
if (($jord>=128) || (($jord>=128) && ($jord<=159))) {
|
|
||||||
$j = "&#".$jord.";"; // $j = htmlentities($j);
|
|
||||||
} elseif (($j == "&") && ($jnext != "#")) {
|
|
||||||
$j = "&";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "xml":
|
|
||||||
if ($jord>=128) {
|
|
||||||
$j = "&#".$jord.";"; // $j = htmlentities($j);
|
|
||||||
// $j = htmlentities($j);
|
|
||||||
} elseif (($j == "&") && ($jnext != "#")) {
|
|
||||||
$j = "&";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$newcontent .= $j;
|
|
||||||
}
|
|
||||||
|
|
||||||
// now converting: Windows CP1252 => Unicode (valid HTML)
|
// now converting: Windows CP1252 => Unicode (valid HTML)
|
||||||
// (if you've ever pasted text from MSWord, you'll understand)
|
// (if you've ever pasted text from MSWord, you'll understand)
|
||||||
|
|
||||||
$newcontent = strtr($newcontent, $b2_htmltranswinuni);
|
$content = strtr($content, $b2_htmltranswinuni);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// you can delete these 2 lines if you don't like <br /> and <hr />
|
// you can delete these 2 lines if you don't like <br /> and <hr />
|
||||||
$newcontent = str_replace("<br>","<br />",$newcontent);
|
$content = str_replace("<br>","<br />",$content);
|
||||||
$newcontent = str_replace("<hr>","<hr />",$newcontent);
|
$content = str_replace("<hr>","<hr />",$content);
|
||||||
|
|
||||||
|
return $content;
|
||||||
|
|
||||||
return $newcontent;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function convert_bbcode($content) {
|
function convert_bbcode($content) {
|
||||||
|
Loading…
Reference in New Issue
Block a user