]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #34 from fabrixxm/master
authorfabrixxm <fabrix.xm@gmail.com>
Fri, 21 Oct 2011 14:32:12 +0000 (07:32 -0700)
committerfabrixxm <fabrix.xm@gmail.com>
Fri, 21 Oct 2011 14:32:12 +0000 (07:32 -0700)
fixs to oembed

images/plugin.png [new file with mode: 0644]
include/oembed.php
library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js
view/custom_tinymce.css

diff --git a/images/plugin.png b/images/plugin.png
new file mode 100644 (file)
index 0000000..08b09e0
Binary files /dev/null and b/images/plugin.png differ
index 06f71a3b32f75e1d0868bf54fa7ebf9526765f7d..a8f6636ff7f480b567976e62bb87a0df4f37f996 100644 (file)
@@ -81,16 +81,22 @@ function oembed_format_object($j){
                }; 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){
@@ -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
+?>
index 789e75c399a5b921cd3ee94d1c25ea221552ff2f..9e680e104c5b4568c026abafca34d259dcdcc5ad 100644 (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
index 48621c42cd7b278e0dbecf327c6ec2a993bd3d6e..7932653b69fd2b216942fd4b3642e98cd646c5b2 100644 (file)
@@ -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;
+}