BxBaseEmbedEmbedly.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. /**
  10. * Iframely integration.
  11. * @see BxDolEmbed
  12. */
  13. class BxBaseEmbedEmbedly extends BxDolEmbed
  14. {
  15. public function __construct ($aObject, $oTemplate)
  16. {
  17. parent::__construct ($aObject, $oTemplate);
  18. }
  19. public function getLinkHTML ($sLink, $sTitle = '', $sMaxWidth = '', $sTheme = '')
  20. {
  21. $aAttrs = array(
  22. 'title' => bx_html_attribute($sTitle)
  23. );
  24. if ($sTheme != ''){
  25. $aAttrs['data-card-theme'] = $sTheme;
  26. }
  27. // check for external link
  28. if (strncmp(BX_DOL_URL_ROOT, $sLink, strlen(BX_DOL_URL_ROOT)) !== 0) {
  29. $aAttrs['target'] = '_blank';
  30. if (getParam('sys_add_nofollow') == 'on')
  31. $aAttrs['rel'] = 'nofollow';
  32. }
  33. return $this->_oTemplate->parseHtmlByName('embed_embedly_link.html', array(
  34. 'link' => $sLink,
  35. 'title' => $sTitle,
  36. 'attrs' => bx_convert_array2attrs($aAttrs),
  37. 'width' => $sMaxWidth,
  38. ));
  39. }
  40. public function addProcessLinkMethod ()
  41. {
  42. return "
  43. <script>
  44. function bx_embed_link(e)
  45. {
  46. embedly('card', e);
  47. }
  48. </script>";
  49. }
  50. public function addJsCss ()
  51. {
  52. if ($this->_bCssJsAdded)
  53. return '';
  54. $sKey = getParam('sys_embedly_api_key');
  55. $this->_bCssJsAdded = true;
  56. return $this->_oTemplate->parseHtmlByName('embed_embedly_integration.html', array(
  57. 'bx_if:key' => array (
  58. 'condition' => !empty($sKey),
  59. 'content' => array('key' => $sKey),
  60. )
  61. ));
  62. }
  63. }
  64. /** @} */