|
|
@@ -13,15 +13,23 @@ require_once('BxAclGridLevels.php');
|
|
|
|
|
|
class BxAclGridView extends BxAclGridLevels
|
|
|
{
|
|
|
- protected $_iOwner;
|
|
|
- protected $_oPayment;
|
|
|
- protected $_bTypeSingle;
|
|
|
- protected $_bTypeRecurring;
|
|
|
+ /**
|
|
|
+ * Array with check_sum => JS_code pairs of all JS codes
|
|
|
+ * which should be added to the page.
|
|
|
+ */
|
|
|
+ protected $_aJsCodes;
|
|
|
+
|
|
|
+ protected $_iOwner;
|
|
|
+ protected $_oPayment;
|
|
|
+ protected $_bTypeSingle;
|
|
|
+ protected $_bTypeRecurring;
|
|
|
|
|
|
public function __construct ($aOptions, $oTemplate = false)
|
|
|
{
|
|
|
parent::__construct ($aOptions, $oTemplate);
|
|
|
|
|
|
+ $this->_aJsCodes = array();
|
|
|
+
|
|
|
$this->_iOwner = $this->_oModule->_oConfig->getOwner();
|
|
|
$this->_oPayment = BxDolPayments::getInstance();
|
|
|
$this->_bTypeSingle = $this->_oPayment->isAcceptingPayments($this->_iOwner, BX_PAYMENT_TYPE_SINGLE);
|
|
|
@@ -52,7 +60,15 @@ class BxAclGridView extends BxAclGridLevels
|
|
|
|
|
|
public function getCode($isDisplayHeader = true)
|
|
|
{
|
|
|
- return $this->_oPayment->getCartJs() . parent::getCode($isDisplayHeader);
|
|
|
+ return parent::getCode($isDisplayHeader) . $this->getJsCode();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getJsCode()
|
|
|
+ {
|
|
|
+ if(empty($this->_aJsCodes) || !is_array($this->_aJsCodes))
|
|
|
+ return '';
|
|
|
+
|
|
|
+ return implode('', $this->_aJsCodes);
|
|
|
}
|
|
|
|
|
|
protected function _getCellLevelIcon($mixedValue, $sKey, $aField, $aRow)
|
|
|
@@ -69,19 +85,23 @@ class BxAclGridView extends BxAclGridLevels
|
|
|
return parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
|
|
|
}
|
|
|
|
|
|
- protected function _getActionBuy ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
|
|
|
+ protected function _getActionBuy ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
|
|
|
{
|
|
|
if((float)$aRow['price'] == 0 || !$this->_bTypeSingle || $this->_bTypeRecurring)
|
|
|
return '';
|
|
|
|
|
|
$aJs = $this->_oPayment->getAddToCartJs($this->_iOwner, $this->MODULE, $aRow['id'], 1, true);
|
|
|
if(!empty($aJs) && is_array($aJs)) {
|
|
|
- list($sJsCode, $sJsMethod) = $aJs;
|
|
|
+ list($sJsCode, $sJsMethod) = $aJs;
|
|
|
|
|
|
- $a['attr'] = array(
|
|
|
- 'title' => bx_html_attribute(_t('_bx_acl_grid_action_buy_title')),
|
|
|
- 'onclick' => $sJsMethod
|
|
|
- );
|
|
|
+ $sJsCodeCheckSum = md5($sJsCode);
|
|
|
+ if(!isset($this->_aJsCodes[$sJsCodeCheckSum]))
|
|
|
+ $this->_aJsCodes[$sJsCodeCheckSum] = $sJsCode;
|
|
|
+
|
|
|
+ $a['attr'] = array(
|
|
|
+ 'title' => bx_html_attribute(_t('_bx_acl_grid_action_buy_title')),
|
|
|
+ 'onclick' => $sJsMethod
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
return parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
|
|
|
@@ -93,16 +113,20 @@ class BxAclGridView extends BxAclGridLevels
|
|
|
return '';
|
|
|
|
|
|
$aJs = $this->_oPayment->getSubscribeJs($this->_iOwner, '', $this->MODULE, $aRow['id'], 1);
|
|
|
- if(!empty($aJs) && is_array($aJs)) {
|
|
|
- list($sJsCode, $sJsMethod) = $aJs;
|
|
|
+ if(!empty($aJs) && is_array($aJs)) {
|
|
|
+ list($sJsCode, $sJsMethod) = $aJs;
|
|
|
+
|
|
|
+ $sJsCodeCheckSum = md5($sJsCode);
|
|
|
+ if(!isset($this->_aJsCodes[$sJsCodeCheckSum]))
|
|
|
+ $this->_aJsCodes[$sJsCodeCheckSum] = $sJsCode;
|
|
|
|
|
|
- $a['attr'] = array(
|
|
|
- 'title' => bx_html_attribute(_t('_bx_acl_grid_action_subscribe_title')),
|
|
|
- 'onclick' => $sJsMethod
|
|
|
- );
|
|
|
- }
|
|
|
+ $a['attr'] = array(
|
|
|
+ 'title' => bx_html_attribute(_t('_bx_acl_grid_action_subscribe_title')),
|
|
|
+ 'onclick' => $sJsMethod
|
|
|
+ );
|
|
|
+ }
|
|
|
|
|
|
- return parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
|
|
|
+ return parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
|
|
|
}
|
|
|
}
|
|
|
|