2011-01-26 16:20:12 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* oembed plugin
|
|
|
|
*
|
|
|
|
* oEmbed is a format for allowing an embedded representation of a URL on third party sites
|
|
|
|
* http://www.oembed.com/
|
|
|
|
*
|
|
|
|
*/
|
2011-05-22 21:56:47 +02:00
|
|
|
|
|
|
|
require_once('include/oembed.php');
|
|
|
|
|
2011-01-26 16:20:12 +01:00
|
|
|
function oembed_install() {
|
2011-05-23 10:37:09 +02:00
|
|
|
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');
|
2011-01-26 16:20:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function oembed_uninstall() {
|
2011-05-23 10:37:09 +02:00
|
|
|
unregister_hook('jot_tool', 'addon/oembed/oembed.php', 'oembed_hook_jot_tool');
|
|
|
|
unregister_hook('page_header', 'addon/oembed/oembed.php', 'oembed_hook_page_header');
|
2011-01-26 16:20:12 +01:00
|
|
|
}
|
|
|
|
|
2011-05-23 10:37:09 +02:00
|
|
|
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' );
|
2011-05-31 08:12:39 +02:00
|
|
|
|
2011-05-23 10:37:09 +02:00
|
|
|
$o.='
|
2011-05-31 08:12:39 +02:00
|
|
|
<div class="settings-block">
|
|
|
|
<h3 class="settings-heading">OEmbed</h3>
|
2011-05-23 10:37:09 +02:00
|
|
|
<div id="settings-username-wrapper">
|
|
|
|
<label for="oembed_use_for_youtube">'
|
|
|
|
.t('Use OEmbed for YouTube videos: ')
|
|
|
|
.'</label><input type="checkbox" id="oembed_use_for_youtube" name="oembed_use_for_youtube"'
|
|
|
|
. ($uofy==1?'checked="true"':'')
|
|
|
|
.'>
|
|
|
|
</div>
|
|
|
|
<div id="settings-username-end"></div>
|
|
|
|
<div class="settings-submit-wrapper">
|
|
|
|
<input type="submit" value="'.t('Submit').'" class="settings-submit" name="oembed-submit">
|
2011-05-31 08:12:39 +02:00
|
|
|
</div>
|
2011-05-23 10:37:09 +02:00
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-26 16:20:12 +01:00
|
|
|
function oembed_hook_page_header($a, &$b){
|
2011-05-23 10:37:09 +02:00
|
|
|
$a->page['htmlhead'] .= sprintf('<script src="%s/oembed/oembed.js"></script>', $a->get_baseurl());
|
2011-01-26 16:20:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function oembed_hook_jot_tool($a, &$b) {
|
2011-05-23 10:37:09 +02:00
|
|
|
$b .= '
|
|
|
|
<div class="tool-wrapper" style="display: $visitor;" >
|
|
|
|
<img class="tool-link" src="addon/oembed/oembed.png" alt="Embed" title="Embed" onclick="oembed();" />
|
|
|
|
</div>
|
|
|
|
';
|
2011-01-26 16:20:12 +01:00
|
|
|
}
|
|
|
|
|
2011-01-26 17:17:02 +01:00
|
|
|
|
2011-05-22 21:56:47 +02:00
|
|
|
function oembed_module() {
|
|
|
|
return;
|
|
|
|
}
|
2011-01-26 16:20:12 +01:00
|
|
|
|
2011-05-22 21:56:47 +02:00
|
|
|
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'])));
|
2011-05-22 23:03:34 +02:00
|
|
|
echo oembed_replacecb($url);
|
2011-05-22 21:56:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($a->argv[1]=='h2b'){
|
|
|
|
$text = trim(hex2bin($_GET['text']));
|
|
|
|
echo oembed_html2bbcode($text);
|
|
|
|
}
|
|
|
|
|
|
|
|
killme();
|
|
|
|
|
|
|
|
}
|
2011-01-26 16:20:12 +01:00
|
|
|
|
2011-05-23 10:37:09 +02:00
|
|
|
?>
|