BxAdsGridCommon.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 Ads Ads
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxAdsGridCommon extends BxBaseModTextGridCommon
  12. {
  13. public function __construct ($aOptions, $oTemplate = false)
  14. {
  15. $this->MODULE = 'bx_ads';
  16. parent::__construct ($aOptions, $oTemplate);
  17. }
  18. protected function _getActionPromotion($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = [])
  19. {
  20. if(!$this->_oModule->_oConfig->isPromotion())
  21. return '';
  22. $CNF = &$this->_oModule->_oConfig->CNF;
  23. $sUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY_PROMOTION'] . '&id=' . $aRow[$CNF['FIELD_ID']]));
  24. if(bx_is_api()) {
  25. $a['type'] = 'link';
  26. $a['name'] = $sKey;
  27. $a['url'] = bx_api_get_relative_url($sUrl);
  28. return $a;
  29. }
  30. $a['attr'] = array_merge($a['attr'], [
  31. "onclick" => "window.open('" . $sUrl . "','_self');"
  32. ]);
  33. return $this->_getActionDefault ($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
  34. }
  35. protected function _getActionEditBudget($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = [])
  36. {
  37. if(!$this->_oModule->_oConfig->isPromotion())
  38. return '';
  39. $CNF = &$this->_oModule->_oConfig->CNF;
  40. $sUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_EDIT_ENTRY_BUDGET'] . '&id=' . $aRow[$CNF['FIELD_ID']]));
  41. if(bx_is_api()) {
  42. $a['type'] = 'link';
  43. $a['name'] = $sKey;
  44. $a['url'] = bx_api_get_relative_url($sUrl);
  45. return $a;
  46. }
  47. $a['attr'] = array_merge($a['attr'], [
  48. "onclick" => "window.open('" . $sUrl . "','_self');"
  49. ]);
  50. return $this->_getActionDefault ($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
  51. }
  52. }
  53. /** @} */