From 6769436f3b43074d7d5895b36927eddf37b0ba8d Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Fri, 21 Oct 2011 16:26:29 +0200 Subject: [PATCH 1/2] oembed. fix html2bbcode when oembed html contains span and utf8 chars --- include/oembed.php | 24 ++++++++++++------- .../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 06f71a3b32..a8f6636ff7 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 789e75c399..9e680e104c 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 +})(); From d80c0da3c0bf2ab599f5d013d5c947823d917363 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Fri, 21 Oct 2011 16:26:57 +0200 Subject: [PATCH 2/2] 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 0000000000000000000000000000000000000000..08b09e0601fd5527c202739ea6031b0a0e692169 GIT binary patch literal 2043 zcmVPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipo2 z4ihI=At18=00(@;cGrb*SNaVRZK zLW)%(fz*Op36&RKc&G{wAn|~Z0P#{NY9x?A2u0$BHUWwX&9zR_G_BeswLNx7>bQ0? z7tf4m=G^9-vw299CN$Ub2sGvi#vDj9IA=Pi_1praU-mga4V>S{X&Rm_w3no z?pDRy+S^gQo}t}ecl@4rVc3_nDZ z2Mz9PFmB;y&`Nt0_lYNhDiPmh-xBsyou@^jJEb zK9I>|N&u-;DruVLk2OX9F5MT7ZW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