BxBaseModPaymentConfig.php 4.5 KB

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