Merge pull request #34 from fabrixxm/master

fixs to oembed
This commit is contained in:
fabrixxm 2011-10-21 07:32:12 -07:00
commit a06c9768be
4 changed files with 32 additions and 15 deletions

BIN
images/plugin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

View file

@ -81,16 +81,22 @@ function oembed_format_object($j){
}; break; }; break;
case "rich": { case "rich": {
// not so safe.. // not so safe..
$ret.= "<blockquote>".$j->html."</blockquote>"; $ret.= $j->html;
}; break; }; break;
} }
$embedlink = (isset($j->title))?$j->title:$embedurl; // add link to source if not present in "rich" type
$ret .= "<a href='$embedurl' rel='oembed'>$embedlink</a>"; if ( $j->type!='rich' || !strpos($ret,$embedurl) ){
if (isset($j->author_name)) $ret.=" by ".$j->author_name; $embedlink = (isset($j->title))?$j->title:$embedurl;
if (isset($j->provider_name)) $ret.=" on ".$j->provider_name; $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>"; $ret.="<br style='clear:left'></span>";
return $ret; return mb_convert_encoding($ret, 'HTML-ENTITIES', mb_detect_encoding($ret));
} }
function oembed_bbcode2html($text){ function oembed_bbcode2html($text){
@ -136,8 +142,8 @@ function oembed_html2bbcode($text) {
$xattr = oe_build_xpath("class","oembed"); $xattr = oe_build_xpath("class","oembed");
$entries = $xpath->query("//span[$xattr]"); $entries = $xpath->query("//span[$xattr]");
$xattr = oe_build_xpath("rel","oembed"); $xattr = "@rel='oembed'";//oe_build_xpath("rel","oembed");
foreach($entries as $e) { foreach($entries as $e) {
$href = $xpath->evaluate("a[$xattr]/@href", $e)->item(0)->nodeValue; $href = $xpath->evaluate("a[$xattr]/@href", $e)->item(0)->nodeValue;
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);
@ -148,4 +154,4 @@ function oembed_html2bbcode($text) {
} }
} }
?> ?>

View file

@ -53,19 +53,24 @@
/* oembed */ /* oembed */
function _h2b_cb(match) { function _h2b_cb(match) {
text = bin2hex(match);
function s_h2b(data) { function s_h2b(data) {
match = data; match = data;
} }
$.ajax({ $.ajax({
url: 'oembed/h2b?text=' + text, type:"POST",
url: 'oembed/h2b',
data: {text: match},
async: false, async: false,
success: s_h2b, success: s_h2b,
dataType: 'html' dataType: 'html'
}); });
return match; return match;
} }
s = s.replace(/<span class=\"oembed(.*?)<\/span>/gi, _h2b_cb); if (s.indexOf('class="oembed')>=0){
//alert("request oembed html2bbcode");
s = _h2b_cb(s);
}
/* /oembed */ /* /oembed */
@ -154,4 +159,4 @@
// Register plugin // Register plugin
tinymce.PluginManager.add('bbcode', tinymce.plugins.BBCodePlugin); tinymce.PluginManager.add('bbcode', tinymce.plugins.BBCodePlugin);
})(); })();

View file

@ -33,3 +33,9 @@ scrollbar-track-color:#F5F5F5;
img:-moz-broken {-moz-force-broken-image-icon:1; width:24px; height:24px} img:-moz-broken {-moz-force-broken-image-icon:1; width:24px; height:24px}
font[face=mceinline] {font-family:inherit !important} font[face=mceinline] {font-family:inherit !important}
object {
display: block; width: 400px;
background: #cccccc url(../images/plugin.png) no-repeat center center;
}