}; break;
case "rich": {
// not so safe..
- $ret.= "<blockquote>".$j->html."</blockquote>";
+ $ret.= $j->html;
}; break;
}
- $embedlink = (isset($j->title))?$j->title:$embedurl;
- $ret .= "<a href='$embedurl' rel='oembed'>$embedlink</a>";
- if (isset($j->author_name)) $ret.=" by ".$j->author_name;
- if (isset($j->provider_name)) $ret.=" on ".$j->provider_name;
+ // add link to source if not present in "rich" type
+ if ( $j->type!='rich' || !strpos($ret,$embedurl) ){
+ $embedlink = (isset($j->title))?$j->title:$embedurl;
+ $ret .= "<a href='$embedurl' rel='oembed'>$embedlink</a>";
+ if (isset($j->author_name)) $ret.=" by ".$j->author_name;
+ if (isset($j->provider_name)) $ret.=" on ".$j->provider_name;
+ } else {
+ // add <a> for html2bbcode conversion
+ $ret .= "<a href='$embedurl' rel='oembed'/>";
+ }
$ret.="<br style='clear:left'></span>";
- return $ret;
+ return mb_convert_encoding($ret, 'HTML-ENTITIES', mb_detect_encoding($ret));
}
function oembed_bbcode2html($text){
$xattr = oe_build_xpath("class","oembed");
$entries = $xpath->query("//span[$xattr]");
-
- $xattr = oe_build_xpath("rel","oembed");
+
+ $xattr = "@rel='oembed'";//oe_build_xpath("rel","oembed");
foreach($entries as $e) {
$href = $xpath->evaluate("a[$xattr]/@href", $e)->item(0)->nodeValue;
if(!is_null($href)) $e->parentNode->replaceChild(new DOMText("[embed]".$href."[/embed]"), $e);
}
}
-?>
\ No newline at end of file
+?>
/* oembed */
function _h2b_cb(match) {
- text = bin2hex(match);
function s_h2b(data) {
match = data;
- }
- $.ajax({
- url: 'oembed/h2b?text=' + text,
+ }\r
+ $.ajax({\r
+ type:"POST",
+ url: 'oembed/h2b',\r
+ data: {text: match},
async: false,
success: s_h2b,
dataType: 'html'
});
return match;
}
- s = s.replace(/<span class=\"oembed(.*?)<\/span>/gi, _h2b_cb);
+ if (s.indexOf('class="oembed')>=0){\r
+ //alert("request oembed html2bbcode");\r
+ s = _h2b_cb(s);\r
+ }\r
+
/* /oembed */
\r
\r
// Register plugin\r
tinymce.PluginManager.add('bbcode', tinymce.plugins.BBCodePlugin);\r
-})();
\ No newline at end of file
+})();\r