| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php defined('BX_DOL') or die('hack attempt');
- /**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup Market Market
- * @ingroup UnaModules
- *
- * @{
- */
- /**
- * View entry menu
- */
- class BxMarketMenuView extends BxBaseModTextMenuView
- {
- public function __construct($aObject, $oTemplate = false)
- {
- $this->MODULE = 'bx_market';
- parent::__construct($aObject, $oTemplate);
- }
- public function getCode ()
- {
- return parent::getCode() . BxDolPayments::getInstance()->getCartJs();
- }
- protected function _isVisible ($a)
- {
- $CNF = &$this->_oModule->_oConfig->CNF;
- if(!parent::_isVisible($a))
- return false;
- $oPayment = BxDolPayments::getInstance();
- $bResult = false;
- switch ($a['name']) {
- case 'download':
- if((int)$this->_aContentInfo[$CNF['FIELD_PACKAGE']] == 0)
- break;
- $bResult = true;
- break;
- case 'add-to-cart':
- if((float)$this->_aContentInfo[$CNF['FIELD_PRICE_SINGLE']] == 0)
- break;
- $aJs = $oPayment->getAddToCartJs($this->_aContentInfo['author'], $this->MODULE, $this->_aContentInfo['id'], 1);
- if(empty($aJs) || !is_array($aJs))
- break;
- list($sJsCode, $sJsMethod) = $aJs;
- $aCurrency = $this->_oModule->_oConfig->getCurrency();
- $bResult = true;
- $this->addMarkers(array(
- 'add_to_cart_title' => _t('_bx_market_menu_item_title_add_to_cart', $aCurrency['sign'], $this->_aContentInfo[$CNF['FIELD_PRICE_SINGLE']]),
- 'add_to_cart_onclick' => $sJsMethod
- ));
- break;
- case 'subscribe':
- if((float)$this->_aContentInfo[$CNF['FIELD_PRICE_RECURRING']] == 0)
- break;
- $aJs = $oPayment->getSubscribeJs($this->_aContentInfo['author'], '', $this->MODULE, $this->_aContentInfo['id'], 1);
- if(empty($aJs) || !is_array($aJs))
- break;
- list($sJsCode, $sJsMethod) = $aJs;
- $aCurrency = $this->_oModule->_oConfig->getCurrency();
- $bResult = true;
- $this->addMarkers(array(
- 'subscribe_title' => _t('_bx_market_menu_item_title_subscribe', $aCurrency['sign'], $this->_aContentInfo[$CNF['FIELD_PRICE_RECURRING']], _t('_bx_market_txt_per_' . $this->_aContentInfo[$CNF['FIELD_DURATION_RECURRING']])),
- 'subscribe_onclick' => $sJsMethod
- ));
- break;
- default:
- $bResult = true;
- }
- return $bResult;
- }
- }
- /** @} */
|