oembed.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaCore UNA Core
  7. * @{
  8. */
  9. require_once('./inc/header.inc.php');
  10. require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
  11. $aLinks = bx_get('l');
  12. bx_import('BxDolEmbed');
  13. $oEmbed = BxDolEmbed::getObjectInstance('sys_iframely');
  14. if (bx_get('html')){
  15. echo '<style>body, html {margin:0px}</style><div style="max-width:900; margin:0px auto; justify-content: center;" id="ifr">' . $oEmbed->getDataHtml($aLinks, bx_get('theme')) . '<script language="javascript" src="'.BX_DOL_URL_ROOT.'/plugins_public/jquery/jquery.min.js"></script><script>
  16. $(document).ready(function () {
  17. a = ["' . bx_get('hash') . '", $("#ifr").height(),$("#ifr").width()];
  18. try{
  19. window.parent.postMessage(JSON.stringify(a), "*");
  20. window.ReactNativeWebView.postMessage(JSON.stringify(a));
  21. }
  22. catch (e) {}
  23. })
  24. window.addEventListener("message", function(event) {
  25. if (event.data && event.data!=""){
  26. try {
  27. a = JSON.parse(event.data);
  28. } catch (e) {}
  29. if (a && a.method=="resize"){
  30. a = ["' . bx_get('hash') . '", a.height,$(".iframely-embed").width()];
  31. try{
  32. window.parent.postMessage(JSON.stringify(a), "*");
  33. window.ReactNativeWebView.postMessage(JSON.stringify(a));
  34. }
  35. catch (e) {}
  36. }
  37. }
  38. }, false);
  39. </script></div>';
  40. exit();
  41. }
  42. echoJson($oEmbed->parseLinks($aLinks));