diff --git a/addon/oembed/oembed.js b/addon/oembed/oembed.js
index 54547a86e..f8e957413 100644
--- a/addon/oembed/oembed.js
+++ b/addon/oembed/oembed.js
@@ -1,10 +1,6 @@
function oembed(){
- $("#oembed").toggleClass('hide');
-}
-
-function oembed_do(){
- embed = "[embed]"+$('#oembed_url').attr('value')+"[/embed]";
-
- tinyMCE.execCommand('mceInsertRawHTML',false,embed);
- oembed();
+ var reply = prompt("$oembed_message:");
+ if(reply && reply.length) {
+ tinyMCE.execCommand('mceInsertRawHTML',false, "[embed]"+reply+"[/embed]" );
+ }
}
diff --git a/addon/oembed/oembed.php b/addon/oembed/oembed.php
index d9b205a3a..f1fb27986 100644
--- a/addon/oembed/oembed.php
+++ b/addon/oembed/oembed.php
@@ -6,56 +6,89 @@
* http://www.oembed.com/
*
*/
-
+
+require_once('include/oembed.php');
+
function oembed_install() {
- register_hook('jot_tool', 'addon/oembed/oembed.php', 'oembed_hook_jot_tool');
- register_hook('page_header', 'addon/oembed/oembed.php', 'oembed_hook_page_header');
+ register_hook('jot_tool', 'addon/oembed/oembed.php', 'oembed_hook_jot_tool');
+ register_hook('page_header', 'addon/oembed/oembed.php', 'oembed_hook_page_header');
+ register_hook('plugin_settings', 'addon/oembed/oembed.php', 'oembed_settings');
+ register_hook('plugin_settings_post', 'addon/oembed/oembed.php', 'oembed_settings_post');
}
function oembed_uninstall() {
- unregister_hook('jot_tool', 'addon/oembed/oembed.php', 'oembed_hook_jot_tool');
- unregister_hook('page_header', 'addon/oembed/oembed.php', 'oembed_hook_page_header');
+ unregister_hook('jot_tool', 'addon/oembed/oembed.php', 'oembed_hook_jot_tool');
+ unregister_hook('page_header', 'addon/oembed/oembed.php', 'oembed_hook_page_header');
}
+function oembed_settings_post(){
+ if(! local_user())
+ return;
+ if (isset($_POST['oembed-submit'])){
+ set_pconfig(local_user(), 'oembed', 'use_for_youtube', (isset($_POST['oembed_use_for_youtube'])?1:0));
+ notice( t('OEmbed settings updated') . EOL);
+ }
+}
+
+function oembed_settings(&$a,&$o) {
+ if(! local_user())
+ return;
+ $uofy = get_pconfig(local_user(), 'oembed', 'use_for_youtube' );
+
+ $o .='
OEmbed ';
+ $o.='
+
+ '
+ .t('Use OEmbed for YouTube videos: ')
+ .'
+
+
+
+
+
';
+}
+
+
function oembed_hook_page_header($a, &$b){
-
- if(($a->module !== 'network') && ($a->module !== 'profile'))
- return;
-
- $b .= '
- ';
-
- $b .= '
-
-
-
-
Paste a link from 5min.com, Amazon Product Image, blip.tv, Clikthrough, CollegeHumor Video,
- Daily Show with Jon Stewart, Dailymotion, dotSUB.com, Flickr Photos, Funny or Die Video,
- Google Video, Hulu, Kinomap, LiveJournal UserPic, Metacafe, National Film Board of Canada,
- Phodroid Photos, Photobucket, Qik Video, Revision3, Scribd, SlideShare, TwitPic, Twitter Status,
- Viddler Video, Vimeo, Wikipedia, Wordpress.com, XKCD Comic, YFrog, YouTube
-
- ';
+ $a->page['htmlhead'] .= sprintf('', $a->get_baseurl());
}
function oembed_hook_jot_tool($a, &$b) {
- $b .= '
-
- ';
+ $b .= '
+
+ ';
}
+function oembed_module() {
+ return;
+}
+function oembed_init(&$a) {
+ if ($a->argv[1]=='oembed.js'){
+ $tpl = file_get_contents('addon/oembed/oembed.js');
+ echo replace_macros($tpl, array(
+ '$oembed_message' => t('URL to embed:'),
+ ));
+ }
+
+ if ($a->argv[1]=='b2h'){
+ $url = array( "", trim(hex2bin($_GET['url'])));
+ echo oembed_replacecb($url);
+ }
+
+ if ($a->argv[1]=='h2b'){
+ $text = trim(hex2bin($_GET['text']));
+ echo oembed_html2bbcode($text);
+ }
+
+ killme();
+
+}
-?>
\ No newline at end of file
+?>
diff --git a/addon/widgets/widgets.php b/addon/widgets/widgets.php
index 6bd7a73d1..af17d9e9a 100644
--- a/addon/widgets/widgets.php
+++ b/addon/widgets/widgets.php
@@ -7,12 +7,15 @@
function widgets_install() {
- // we need some hooks, for the configuration and for sending tweets
register_hook('plugin_settings', 'addon/widgets/widgets.php', 'widgets_settings');
register_hook('plugin_settings_post', 'addon/widgets/widgets.php', 'widgets_settings_post');
-
logger("installed widgets");
}
+function widgets_uninstall() {
+ unregister_hook('plugin_settings', 'addon/widgets/widgets.php', 'widgets_settings');
+ unregister_hook('plugin_settings_post', 'addon/widgets/widgets.php', 'widgets_settings_post');
+}
+
function widgets_settings_post(){
diff --git a/include/bbcode.php b/include/bbcode.php
index c2d932674..3caf2a6b1 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -92,17 +92,21 @@ function bbcode($Text,$preserve_nl = false) {
// [img=widthxheight]image source[/img]
$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", ' ', $Text);
- // Youtube extensions
+ if (get_pconfig(local_user(), 'oembed', 'use_for_youtube' )==1){
+ // use oembed for youtube links
+ $Text = preg_replace("/\[youtube\]/",'[embed]',$Text);
+ $Text = preg_replace("/\[\/youtube\]/",'[/embed]',$Text);
+ } else {
+ // Youtube extensions
$Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/watch\?v\=(.+?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text);
$Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.+?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text);
-
- $Text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", 'VIDEO ', $Text);
-
-// $Text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", ' ', $Text);
+ $Text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", 'VIDEO ', $Text);
+ }
+// $Text = preg_replace("/\[youtube\](.+?)\[\/youtube\]/", ' ', $Text);
// oembed tag
$Text = oembed_bbcode2html($Text);
-
+
call_hooks('bbcode',$Text);
return $Text;
diff --git a/include/oembed.php b/include/oembed.php
index 4d2b7185e..06a37d8e4 100644
--- a/include/oembed.php
+++ b/include/oembed.php
@@ -1,54 +1,92 @@
";
- switch ($j->type) {
- case "video": {
- if (isset($j->thumbnail_url)) {
- $tw = (isset($j->thumbnail_width)) ? $j->thumbnail_width:200;
- $th = (isset($j->thumbnail_height)) ? $j->thumbnail_height:180;
- $ret = "";
- $ret.= " ";
- $ret.= " ";
- } else {
- $ret=$j->html;
- }
- $ret.=" ";
- }; break;
- case "photo": {
- $ret = " ";
- $ret.=" ";
- }; break;
- case "link": {
- //$ret = "".$j->title." ";
- }; break;
- case "rich": {
- // not so safe..
- $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;
- $ret.="";
- return $ret;
+ $embedurl=$matches[1];
+ $j = oembed_fetch_url($embedurl);
+ return oembed_format_object($j);
+}
+
+
+function oembed_fetch_url($embedurl){
+ $r = q("SELECT v FROM `cache` WHERE k='%s'",
+ dbesc($embedurl));
+
+ if(count($r)){
+ $txt = $r[0]['v'];
+ } else {
+ $txt = "";
+
+ // try oembed autodiscovery
+ $html_text = fetch_url($embedurl);
+ $dom = @DOMDocument::loadHTML($html_text);
+ if ($dom){
+ $xpath = new DOMXPath($dom);
+ $attr = "oembed";
+
+ $xattr = oe_build_xpath("class","oembed");
+ $entries = $xpath->query("//link[@type='application/json+oembed']");
+ foreach($entries as $e){
+ $href = $e->getAttributeNode("href")->nodeValue;
+ $txt = fetch_url($href);
+ }
+ }
+
+ if ($txt==false || $txt==""){
+ // try oohembed service
+ $ourl = "http://oohembed.com/oohembed/?url=".urlencode($embedurl);
+ $txt = fetch_url($ourl);
+ }
+
+ $txt=trim($txt);
+ if ($txt[0]!="{") $txt='{"type":"error"}';
+
+ //save in cache
+ /*q("INSERT INTO `cache` VALUES ('%s','%s','%s')",
+ dbesc($embedurl),
+ dbesc($txt),
+ dbesc(datetime_convert()));*/
+ }
+
+ $j = json_decode($txt);
+ $j->embedurl = $embedurl;
+ return $j;
+}
+
+function oembed_format_object($j){
+ $embedurl = $j->embedurl;
+ $ret="";
+ switch ($j->type) {
+ case "video": {
+ if (isset($j->thumbnail_url)) {
+ /*$tw = (isset($j->thumbnail_width)) ? $j->thumbnail_width:200;
+ $th = (isset($j->thumbnail_height)) ? $j->thumbnail_height:180;*/
+ $tw=150; $th=120;
+ $ret.= "";
+ $ret.= " ";
+ $ret.= " ";
+ } else {
+ $ret=$j->html;
+ }
+ $ret.=" ";
+ }; break;
+ case "photo": {
+ $ret.= " ";
+ $ret.=" ";
+ }; break;
+ case "link": {
+ //$ret = "".$j->title." ";
+ }; break;
+ case "rich": {
+ // not so safe..
+ $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;
+ $ret.=" ";
+ return $ret;
}
function oembed_bbcode2html($text){
@@ -98,7 +136,7 @@ function oembed_html2bbcode($text) {
$xattr = 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);
+ if(!is_null($href)) $e->parentNode->replaceChild(new DOMText("[embed]".$href."[/embed]"), $e);
}
return oe_get_inner_html( $dom->getElementsByTagName("body")->item(0) );
} else {
diff --git a/mod/parse_url.php b/mod/parse_url.php
index 30371e9f6..15a6aced0 100644
--- a/mod/parse_url.php
+++ b/mod/parse_url.php
@@ -2,7 +2,6 @@
require_once('library/HTML5/Parser.php');
-
function parse_url_content(&$a) {
logger('parse_url: ' . $_GET['url']);
@@ -25,9 +24,9 @@ function parse_url_content(&$a) {
killme();
}
- if($url)
+ if($url) {
$s = fetch_url($url);
- else {
+ } else {
echo '';
killme();
}
@@ -97,4 +96,4 @@ function parse_url_content(&$a) {
echo sprintf($template,$url,$title,$text);
killme();
-}
\ No newline at end of file
+}
diff --git a/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js b/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js
index aad83280d..db676cd90 100644
--- a/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js
+++ b/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js
@@ -47,6 +47,27 @@
function rep(re, str) {
s = s.replace(re, str);
};
+
+
+
+
+ /* oembed */
+ function _h2b_cb(match) {
+ text = bin2hex(match);
+ function s_h2b(data) {
+ match = data;
+ }
+ $.ajax({
+ url: 'oembed/h2b?text=' + text,
+ async: false,
+ success: s_h2b,
+ dataType: 'html'
+ });
+ return match;
+ }
+ s = s.replace(//gi, _h2b_cb);
+ /* /oembed */
+
// example: to [b]
rep(/(.*?)<\/a>/gi,"[url=$1]$2[/url]");
@@ -55,8 +76,8 @@
rep(/(.*?)<\/font>/gi,"$1");
rep(/ /gi,"[img=$1x$2]$3[/img]");
rep(/ /gi,"[img=$2x$1]$3[/img]");
- rep(/ /gi,"[img=$3x$2]$1[/img]");
- rep(/ /gi,"[img=$2x$3]$1[/img]");
+ rep(/ /gi,"[img=$3x$2]$1[/img]");
+ rep(/ /gi,"[img=$2x$3]$1[/img]");
rep(/ /gi,"[img]$1[/img]");
rep(/(.*?)<\/code>/gi,"[code]$1[/code]");
rep(/<\/(strong|b)>/gi,"[/b]");
@@ -106,6 +127,24 @@
rep(/\[size=(.*?)\](.*?)\[\/size\]/gi,"$2 ");
rep(/\[code\](.*?)\[\/code\]/gi,"$1
");
rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"$1 ");
+
+ /* oembed */
+ function _b2h_cb(match, url) {
+ url = bin2hex(url);
+ function s_b2h(data) {
+ match = data;
+ }
+ $.ajax({
+ url: 'oembed/b2h?url=' + url,
+ async: false,
+ success: s_b2h,
+ dataType: 'html'
+ });
+ return match;
+ }
+ s = s.replace(/\[embed\](.*?)\[\/embed\]/gi, _b2h_cb);
+
+ /* /oembed */
return s;
}
diff --git a/view/it/strings.php b/view/it/strings.php
index de67aad4d..aa6184e21 100644
--- a/view/it/strings.php
+++ b/view/it/strings.php
@@ -119,7 +119,7 @@ $a->strings["Administrator"] = "Amministratore";
$a->strings["Friend/Connection Request"] = "Richieste di Amicizia/Connessione";
$a->strings["Examples: jojo@demo.friendika.com, http://demo.friendika.com/profile/jojo, testuser@identi.ca"] = "Esempi: jojo@demo.friendika.com, http://demo.friendika.com/profile/jojo, testuser@identi.ca";
$a->strings["Please answer the following:"] = "Rispondi al seguente:";
-$a->strings["Does \$name know you?"] = "$name ti conosce?";
+$a->strings["Does \$name know you?"] = "\$name ti conosce?";
$a->strings["Yes"] = "Si";
$a->strings["No"] = "No";
$a->strings["Add a personal note:"] = "Aggiungi una nota personale:";