]> git.mxchange.org Git - friendica.git/blob - addon/oembed/oembed.php
Fix missing wrapping span on bbcode to html, split embed data fetch and rappresentati...
[friendica.git] / addon / oembed / oembed.php
1 <?php
2 /**
3  * oembed plugin
4  * 
5  * oEmbed is a format for allowing an embedded representation of a URL on third party sites
6  * http://www.oembed.com/
7  * 
8  */
9
10 require_once('include/oembed.php');
11
12 function oembed_install() {
13   register_hook('jot_tool', 'addon/oembed/oembed.php', 'oembed_hook_jot_tool');
14   register_hook('page_header', 'addon/oembed/oembed.php', 'oembed_hook_page_header');
15 }
16
17 function oembed_uninstall() {
18   unregister_hook('jot_tool', 'addon/oembed/oembed.php', 'oembed_hook_jot_tool');
19   unregister_hook('page_header', 'addon/oembed/oembed.php', 'oembed_hook_page_header');
20 }
21
22 function oembed_hook_page_header($a, &$b){
23   $a->page['htmlhead'] .= sprintf('<script src="%s/oembed/oembed.js"></script>', $a->get_baseurl());
24 }
25
26
27 function oembed_hook_jot_tool($a, &$b) {
28   $b .= '
29     <div class="tool-wrapper" style="display: $visitor;" >
30       <img class="tool-link" src="addon/oembed/oembed.png" alt="Embed" title="Embed" onclick="oembed();" />
31     </div> 
32   ';
33 }
34
35
36 function oembed_module() {
37         return;
38 }
39
40 function oembed_init(&$a) {
41         if ($a->argv[1]=='oembed.js'){
42                 $tpl = file_get_contents('addon/oembed/oembed.js');
43                 echo replace_macros($tpl, array(
44                         '$oembed_message' =>  t('URL to embed:'),
45                 ));
46         }
47         
48         if ($a->argv[1]=='b2h'){
49                 $url = array( "", trim(hex2bin($_GET['url'])));
50                 echo oembed_replacecb($url);
51         }
52         
53         if ($a->argv[1]=='h2b'){
54                 $text = trim(hex2bin($_GET['text']));
55                 echo oembed_html2bbcode($text);
56         }
57         
58         killme();
59         
60 }
61
62 ?>