From 7c5a7a94d4d224d23f7c922b86a60a6ffe53fc9f Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Mon, 23 May 2011 10:37:09 +0200 Subject: Add oembed user option for use oembed instead of standard yotube embedding. Remove global option and parse_url use of oembed. --- addon/oembed/oembed.php | 54 +++++++++++++++++++++++++++++++++++++++---------- include/bbcode.php | 3 +-- mod/parse_url.php | 12 +---------- 3 files changed, 45 insertions(+), 24 deletions(-) diff --git a/addon/oembed/oembed.php b/addon/oembed/oembed.php index caf4f5837..f1fb27986 100644 --- a/addon/oembed/oembed.php +++ b/addon/oembed/oembed.php @@ -10,26 +10,58 @@ 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.=' +
+ +
+
+
+ +
'; +} + + function oembed_hook_page_header($a, &$b){ - $a->page['htmlhead'] .= sprintf('', $a->get_baseurl()); + $a->page['htmlhead'] .= sprintf('', $a->get_baseurl()); } function oembed_hook_jot_tool($a, &$b) { - $b .= ' -
- Embed -
- '; + $b .= ' +
+ Embed +
+ '; } @@ -59,4 +91,4 @@ function oembed_init(&$a) { } -?> \ No newline at end of file +?> diff --git a/include/bbcode.php b/include/bbcode.php index b2e9cee6d..3caf2a6b1 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -92,8 +92,7 @@ function bbcode($Text,$preserve_nl = false) { // [img=widthxheight]image source[/img] $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", '', $Text); - $a = get_app(); - if ($a->config['system']['embed_all']){ + 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); diff --git a/mod/parse_url.php b/mod/parse_url.php index 8e1684732..15a6aced0 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -1,7 +1,6 @@ config['system']['embed_all']){ - $j = oembed_fetch_url($url); - if ($j->type!="error"){ - echo oembed_format_object($j); - killme(); - } - } - $s = fetch_url($url); } else { echo ''; @@ -106,4 +96,4 @@ function parse_url_content(&$a) { echo sprintf($template,$url,$title,$text); killme(); -} \ No newline at end of file +} -- cgit v1.2.3