Merge branch 'master' of github.com:fabrixxm/friendika

This commit is contained in:
fabrixxm 2011-02-17 07:36:15 +01:00
commit 2493877a18

View file

@ -79,8 +79,14 @@ function oe_get_inner_html( $node ) {
* and replace it with [embed]url[/embed] * and replace it with [embed]url[/embed]
*/ */
function oembed_html2bbcode($text) { function oembed_html2bbcode($text) {
// start parser only if 'oembed' is in text
if (strpos($text, "oembed")){
// convert non ascii chars to html entities
$html_text = mb_convert_encoding($text, 'HTML-ENTITIES', mb_detect_encoding($text));
// If it doesn't parse at all, just return the text. // If it doesn't parse at all, just return the text.
$dom = @DOMDocument::loadHTML($text); $dom = @DOMDocument::loadHTML($html_text);
if(! $dom) if(! $dom)
return $text; return $text;
$xpath = new DOMXPath($dom); $xpath = new DOMXPath($dom);
@ -95,6 +101,9 @@ function oembed_html2bbcode($text) {
if(!is_null($href)) $e->parentNode->replaceChild(new DOMText("[embed]".$href."[embed]"), $e); if(!is_null($href)) $e->parentNode->replaceChild(new DOMText("[embed]".$href."[embed]"), $e);
} }
return oe_get_inner_html( $dom->getElementsByTagName("body")->item(0) ); return oe_get_inner_html( $dom->getElementsByTagName("body")->item(0) );
} else {
return $text;
}
} }
?> ?>