BxBaseModPaymentConfig.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 BasePayment Base classes for Payment like modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModPaymentConfig extends BxBaseModGeneralConfig
  12. {
  13. protected $_oDb;
  14. protected $_iSiteId;
  15. protected $_sCurrencySign;
  16. protected $_sCurrencyCode;
  17. protected $_aPerPage;
  18. protected $_aHtmlIds;
  19. protected $_sAnimationEffect;
  20. protected $_iAnimationSpeed;
  21. function __construct($aModule)
  22. {
  23. parent::__construct($aModule);
  24. $this->CNF = array_merge($this->CNF, array(
  25. 'OBJECT_FORM_PRELISTS_CURRENCIES' => '',
  26. 'KEY_SESSION_PENDING' => $this->_sName . '_pending_id',
  27. 'KEY_REQUEST_PENDING' => $this->_sName . '_pending_id',
  28. 'DIVIDER_DESCRIPTOR' => '_',
  29. 'DIVIDER_DESCRIPTORS' => ':',
  30. ));
  31. $this->_aPrefixes = array(
  32. 'general' => $this->_sName . '_',
  33. 'langs' => '_' . $this->_sName . '_',
  34. 'options' => $this->_sName . '_'
  35. );
  36. $this->_aObjects = array_merge($this->_aObjects, array(
  37. 'form_pendings' => $this->_sName . '_form_pendings',
  38. 'form_processed' => $this->_sName . '_form_processed',
  39. 'display_pendings_process' => $this->_sName . '_form_pendings_process',
  40. 'display_processed_add' => $this->_sName . '_form_processed_add',
  41. 'menu_cart_submenu' => $this->_sName . '_menu_cart_submenu',
  42. 'menu_orders_submenu' => $this->_sName . '_menu_orders_submenu',
  43. 'menu_sbs_submenu' => $this->_sName . '_menu_sbs_submenu',
  44. 'menu_sbs_actions' => $this->_sName . '_menu_sbs_actions',
  45. 'grid_history' => $this->_sName . '_grid_orders_history',
  46. 'grid_processed' => $this->_sName . '_grid_orders_processed',
  47. 'grid_pending' => $this->_sName . '_grid_orders_pending',
  48. 'grid_carts' => $this->_sName . '_grid_carts',
  49. 'grid_cart' => $this->_sName . '_grid_cart',
  50. 'grid_sbs_list' => $this->_sName . '_grid_sbs_list',
  51. 'grid_sbs_history' => $this->_sName . '_grid_sbs_history',
  52. ));
  53. $this->_aPerPage = array();
  54. $this->_aHtmlIds = array();
  55. $this->_sAnimationEffect = 'fade';
  56. $this->_iAnimationSpeed = 'slow';
  57. }
  58. public function init(&$oDb)
  59. {
  60. $this->_oDb = $oDb;
  61. $sPrefix = $this->getPrefix('options');
  62. $this->_iSiteId = (int)$this->_oDb->getParam($sPrefix . 'site_admin');
  63. }
  64. public function getSiteId()
  65. {
  66. if(empty($this->_iSiteId))
  67. return $this->_oDb->getFirstAdminId();
  68. return $this->_iSiteId;
  69. }
  70. public function getDefaultCurrencySign()
  71. {
  72. return $this->_sCurrencySign;
  73. }
  74. public function getDefaultCurrencyCode()
  75. {
  76. return $this->_sCurrencyCode;
  77. }
  78. public function getKey($sType)
  79. {
  80. $sResult = '';
  81. if(empty($sType) || !isset($this->CNF[$sType]))
  82. return $sResult;
  83. return $this->CNF[$sType];
  84. }
  85. public function getUrl($sType, $aParams = array(), $bSsl = false)
  86. {
  87. $sResult = '';
  88. if(empty($sType) || !isset($this->CNF[$sType]))
  89. return $sResult;
  90. if(strncmp($this->CNF[$sType], BX_DOL_URL_ROOT, strlen(BX_DOL_URL_ROOT)) === 0)
  91. $sResult = bx_append_url_params($this->CNF[$sType], $aParams);
  92. else
  93. $sResult = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($this->CNF[$sType], $aParams);
  94. return $bSsl ? $this->http2https($sResult) : $sResult;
  95. }
  96. public function getDivider($sType)
  97. {
  98. $sResult = '';
  99. if(empty($sType) || !isset($this->CNF[$sType]))
  100. return $sResult;
  101. return $this->CNF[$sType];
  102. }
  103. public function getPerPage($sType = 'default')
  104. {
  105. if(empty($sType))
  106. return $this->_aPerPage;
  107. return isset($this->_aPerPage[$sType]) ? $this->_aPerPage[$sType] : '';
  108. }
  109. public function getHtmlIds($sType, $sKey = '')
  110. {
  111. if(empty($sKey))
  112. return isset($this->_aHtmlIds[$sType]) ? $this->_aHtmlIds[$sType] : array();
  113. return isset($this->_aHtmlIds[$sType][$sKey]) ? $this->_aHtmlIds[$sType][$sKey] : '';
  114. }
  115. public function getAnimationEffect()
  116. {
  117. return $this->_sAnimationEffect;
  118. }
  119. public function getAnimationSpeed()
  120. {
  121. return $this->_iAnimationSpeed;
  122. }
  123. }
  124. /** @} */