BxVideosEmbedProviderOEmbed.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup Videos Videos
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Class for parsing links which support oembed API.
  13. */
  14. class BxVideosEmbedProviderOEmbed
  15. {
  16. var $_oModule;
  17. public function __construct(&$oModule) {
  18. $this->_oModule = $oModule;
  19. }
  20. public function parseLink($sLink) {
  21. bx_import('BxDolEmbed');
  22. $oEmbed = BxDolEmbed::getObjectInstance('sys_oembed');
  23. $aResponse = $oEmbed->getUrlData($sLink);
  24. if ($aResponse) {
  25. $aResponse = $aResponse[$sLink];
  26. if (isset($aResponse['type']) && $aResponse['type'] == 'video' && isset($aResponse['html']) && !empty($aResponse['html']))
  27. return [
  28. 'thumb' => isset($aResponse['thumbnail_url']) ? $aResponse['thumbnail_url'] : '',
  29. 'embed' => $aResponse['html'],
  30. ];
  31. }
  32. return false;
  33. }
  34. }
  35. /** @} */