From 6769436f3b43074d7d5895b36927eddf37b0ba8d Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Fri, 21 Oct 2011 16:26:29 +0200 Subject: oembed. fix html2bbcode when oembed html contains span and utf8 chars --- include/oembed.php | 24 ++++++++++++++-------- .../tiny_mce/plugins/bbcode/editor_plugin_src.js | 17 +++++++++------ 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/include/oembed.php b/include/oembed.php index 06f71a3b3..a8f6636ff 100644 --- a/include/oembed.php +++ b/include/oembed.php @@ -81,16 +81,22 @@ function oembed_format_object($j){ }; break; case "rich": { // not so safe.. - $ret.= "
".$j->html."
"; + $ret.= $j->html; }; break; } - $embedlink = (isset($j->title))?$j->title:$embedurl; - $ret .= "$embedlink"; - 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 .= "$embedlink"; + if (isset($j->author_name)) $ret.=" by ".$j->author_name; + if (isset($j->provider_name)) $ret.=" on ".$j->provider_name; + } else { + // add for html2bbcode conversion + $ret .= ""; + } $ret.="
"; - return $ret; + return mb_convert_encoding($ret, 'HTML-ENTITIES', mb_detect_encoding($ret)); } function oembed_bbcode2html($text){ @@ -136,8 +142,8 @@ function oembed_html2bbcode($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); @@ -148,4 +154,4 @@ function oembed_html2bbcode($text) { } } -?> \ No newline at end of file +?> diff --git a/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js b/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js index 789e75c39..9e680e104 100644 --- a/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js +++ b/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js @@ -53,19 +53,24 @@ /* oembed */ function _h2b_cb(match) { - text = bin2hex(match); function s_h2b(data) { match = data; - } - $.ajax({ - url: 'oembed/h2b?text=' + text, + } + $.ajax({ + type:"POST", + url: 'oembed/h2b', + data: {text: match}, async: false, success: s_h2b, dataType: 'html' }); return match; } - s = s.replace(//gi, _h2b_cb); + if (s.indexOf('class="oembed')>=0){ + //alert("request oembed html2bbcode"); + s = _h2b_cb(s); + } + /* /oembed */ @@ -154,4 +159,4 @@ // Register plugin tinymce.PluginManager.add('bbcode', tinymce.plugins.BBCodePlugin); -})(); \ No newline at end of file +})(); -- cgit v1.2.3 From d80c0da3c0bf2ab599f5d013d5c947823d917363 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Fri, 21 Oct 2011 16:26:57 +0200 Subject: add custom style to object tag in tinymce --- images/plugin.png | Bin 0 -> 2043 bytes view/custom_tinymce.css | 6 ++++++ 2 files changed, 6 insertions(+) create mode 100644 images/plugin.png diff --git a/images/plugin.png b/images/plugin.png new file mode 100644 index 000000000..08b09e060 Binary files /dev/null and b/images/plugin.png differ diff --git a/view/custom_tinymce.css b/view/custom_tinymce.css index 48621c42c..7932653b6 100644 --- a/view/custom_tinymce.css +++ b/view/custom_tinymce.css @@ -33,3 +33,9 @@ scrollbar-track-color:#F5F5F5; img:-moz-broken {-moz-force-broken-image-icon:1; width:24px; height:24px} font[face=mceinline] {font-family:inherit !important} + + +object { + display: block; width: 400px; + background: #cccccc url(../images/plugin.png) no-repeat center center; +} -- cgit v1.2.3