Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

96 lines
2.6 KiB

  1. <?php
  2. /**
  3. * Name: OEmbed
  4. * Description: OEmbed is a format for allowing an embedded representation of a URL on third party sites http://www.oembed.com/
  5. * Version: 1.2
  6. * Author: Fabio Comuni <http://kirgroup.com/profile/fabrix>
  7. */
  8. require_once('include/oembed.php');
  9. function oembed_install() {
  10. register_hook('jot_tool', 'addon/oembed/oembed.php', 'oembed_hook_jot_tool');
  11. register_hook('page_header', 'addon/oembed/oembed.php', 'oembed_hook_page_header');
  12. register_hook('plugin_settings', 'addon/oembed/oembed.php', 'oembed_settings');
  13. register_hook('plugin_settings_post', 'addon/oembed/oembed.php', 'oembed_settings_post');
  14. }
  15. function oembed_uninstall() {
  16. unregister_hook('jot_tool', 'addon/oembed/oembed.php', 'oembed_hook_jot_tool');
  17. unregister_hook('page_header', 'addon/oembed/oembed.php', 'oembed_hook_page_header');
  18. }
  19. function oembed_settings_post(){
  20. if(! local_user())
  21. return;
  22. if (isset($_POST['oembed-submit'])){
  23. set_pconfig(local_user(), 'oembed', 'use_for_youtube', (isset($_POST['oembed_use_for_youtube'])?1:0));
  24. notice( t('OEmbed settings updated') . EOL);
  25. }
  26. }
  27. function oembed_settings(&$a,&$o) {
  28. if(! local_user())
  29. return;
  30. $uofy = get_pconfig(local_user(), 'oembed', 'use_for_youtube' );
  31. $o.='
  32. <div class="settings-block">
  33. <h3 class="settings-heading">OEmbed</h3>
  34. <div id="settings-username-wrapper">
  35. <label for="oembed_use_for_youtube">'
  36. .t('Use OEmbed for YouTube videos: ')
  37. .'</label><input type="checkbox" id="oembed_use_for_youtube" name="oembed_use_for_youtube"'
  38. . ($uofy==1?'checked="true"':'')
  39. .'>
  40. </div>
  41. <div id="settings-username-end"></div>
  42. <div class="settings-submit-wrapper">
  43. <input type="submit" value="'.t('Submit').'" class="settings-submit" name="oembed-submit">
  44. </div>
  45. </div>';
  46. }
  47. function oembed_hook_page_header($a, &$b){
  48. $a->page['htmlhead'] .= sprintf('<script src="%s/oembed/oembed.js"></script>', $a->get_baseurl());
  49. }
  50. function oembed_hook_jot_tool($a, &$b) {
  51. $b .= '
  52. <div class="tool-wrapper" style="display: $visitor;" >
  53. <img class="tool-link" src="addon/oembed/oembed.png" alt="Embed" title="Embed" onclick="oembed();" />
  54. </div>
  55. ';
  56. }
  57. function oembed_module() {
  58. return;
  59. }
  60. function oembed_init(&$a) {
  61. if ($a->argv[1]=='oembed.js'){
  62. $tpl = file_get_contents('addon/oembed/oembed.js');
  63. echo replace_macros($tpl, array(
  64. '$oembed_message' => t('URL to embed:'),
  65. ));
  66. }
  67. if ($a->argv[1]=='b2h'){
  68. $url = array( "", trim(hex2bin($_GET['url'])));
  69. echo oembed_replacecb($url);
  70. }
  71. if ($a->argv[1]=='h2b'){
  72. $text = trim(hex2bin($_GET['text']));
  73. echo oembed_html2bbcode($text);
  74. }
  75. killme();
  76. }
  77. ?>