BxAdsMenuSnippetMeta.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 BxAdsMenuSnippetMeta extends BxBaseModTextMenuSnippetMeta
  12. {
  13. protected $_sCategoryUrl;
  14. public function __construct($aObject, $oTemplate = false)
  15. {
  16. $this->_sModule = 'bx_ads';
  17. parent::__construct($aObject, $oTemplate);
  18. $CNF = &$this->_oModule->_oConfig->CNF;
  19. $this->_sCategoryUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink($CNF['URL_CATEGORIES'], array($CNF['GET_PARAM_CATEGORY'] => '')));
  20. }
  21. protected function _getMenuItemCategory($aItem)
  22. {
  23. $CNF = &$this->_oModule->_oConfig->CNF;
  24. if(empty($CNF['FIELD_CATEGORY']) || empty($this->_aContentInfo[$CNF['FIELD_CATEGORY']]))
  25. return false;
  26. $iCategory = (int)$this->_aContentInfo[$CNF['FIELD_CATEGORY']];
  27. $aCategory = $this->_oModule->_oDb->getCategories(array('type' => 'id', 'id' => $iCategory));
  28. if(empty($aCategory) || !is_array($aCategory))
  29. return false;
  30. return $this->getUnitMetaItemLink(_t($aCategory['title']), array(
  31. 'href' => $this->_sCategoryUrl . $iCategory
  32. ));
  33. }
  34. protected function _getMenuItemPrice($aItem)
  35. {
  36. $CNF = &$this->_oModule->_oConfig->CNF;
  37. if(empty($CNF['FIELD_PRICE']))
  38. return false;
  39. if(!empty($this->_aContentInfo[$CNF['FIELD_PRICE']]))
  40. $sPrice = _t_format_currency_ext((float)$this->_aContentInfo[$CNF['FIELD_PRICE']], [
  41. 'sign' => BxDolPayments::getInstance()->getCurrencySign((int)$this->_aContentInfo[$CNF['FIELD_AUTHOR']])
  42. ]);
  43. else
  44. $sPrice = _t('_bx_ads_txt_free');
  45. return $this->getUnitMetaItemText($sPrice, array(
  46. 'class' => 'price'
  47. ));
  48. }
  49. }
  50. /** @} */