BxBaseModPaymentConfig.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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 $_sCurrencySign;
  15. protected $_sCurrencyCode;
  16. protected $_aPerPage;
  17. protected $_aHtmlIds;
  18. protected $_sAnimationEffect;
  19. protected $_iAnimationSpeed;
  20. function __construct($aModule)
  21. {
  22. parent::__construct($aModule);
  23. $this->CNF = array_merge($this->CNF, array(
  24. 'OBJECT_FORM_PRELISTS_CURRENCIES' => '',
  25. 'KEY_SESSION_PENDING' => $this->_sName . '_pending_id',
  26. 'KEY_REQUEST_PENDING' => $this->_sName . '_pending_id',
  27. 'DIVIDER_DESCRIPTOR' => '_',
  28. 'DIVIDER_DESCRIPTORS' => ':',
  29. ));
  30. $this->_aPrefixes = array(
  31. 'general' => $this->_sName . '_',
  32. 'langs' => '_' . $this->_sName . '_',
  33. 'options' => $this->_sName . '_'
  34. );
  35. $this->_aObjects = array_merge($this->_aObjects, array(
  36. 'form_pendings' => $this->_sName . '_form_pendings',
  37. 'form_processed' => $this->_sName . '_form_processed',
  38. 'display_pendings_process' => $this->_sName . '_form_pendings_process',
  39. 'display_processed_add' => $this->_sName . '_form_processed_add',
  40. 'menu_dashboard' => 'sys_account_dashboard',
  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_providers' => $this->_sName . '_grid_providers',
  46. 'grid_history' => $this->_sName . '_grid_orders_history',
  47. 'grid_processed' => $this->_sName . '_grid_orders_processed',
  48. 'grid_pending' => $this->_sName . '_grid_orders_pending',
  49. 'grid_carts' => $this->_sName . '_grid_carts',
  50. 'grid_cart' => $this->_sName . '_grid_cart',
  51. 'grid_sbs_list_my' => $this->_sName . '_grid_sbs_list_my',
  52. 'grid_sbs_list_all' => $this->_sName . '_grid_sbs_list_all',
  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. }
  64. public function getDefaultCurrencySign()
  65. {
  66. return $this->_sCurrencySign;
  67. }
  68. public function getDefaultCurrencyCode()
  69. {
  70. return $this->_sCurrencyCode;
  71. }
  72. public function getKey($sType)
  73. {
  74. $sResult = '';
  75. if(empty($sType) || !isset($this->CNF[$sType]))
  76. return $sResult;
  77. return $this->CNF[$sType];
  78. }
  79. public function getUrl($sType, $aParams = array(), $bSsl = false)
  80. {
  81. $sResult = '';
  82. if(empty($sType) || !isset($this->CNF[$sType]))
  83. return $sResult;
  84. if(strncmp($this->CNF[$sType], BX_DOL_URL_ROOT, strlen(BX_DOL_URL_ROOT)) === 0)
  85. $sResult = bx_append_url_params($this->CNF[$sType], $aParams);
  86. else
  87. $sResult = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($this->CNF[$sType], $aParams);
  88. return $bSsl ? $this->http2https($sResult) : $sResult;
  89. }
  90. public function getDivider($sType)
  91. {
  92. $sResult = '';
  93. if(empty($sType) || !isset($this->CNF[$sType]))
  94. return $sResult;
  95. return $this->CNF[$sType];
  96. }
  97. public function getPerPage($sType = 'default')
  98. {
  99. if(empty($sType))
  100. return $this->_aPerPage;
  101. return isset($this->_aPerPage[$sType]) ? $this->_aPerPage[$sType] : '';
  102. }
  103. public function getHtmlIds($sType, $sKey = '')
  104. {
  105. if(empty($sKey))
  106. return isset($this->_aHtmlIds[$sType]) ? $this->_aHtmlIds[$sType] : array();
  107. return isset($this->_aHtmlIds[$sType][$sKey]) ? $this->_aHtmlIds[$sType][$sKey] : '';
  108. }
  109. public function getAnimationEffect()
  110. {
  111. return $this->_sAnimationEffect;
  112. }
  113. public function getAnimationSpeed()
  114. {
  115. return $this->_iAnimationSpeed;
  116. }
  117. public function getLicense()
  118. {
  119. list($fMilliSec, $iSec) = explode(' ', microtime());
  120. $fSeed = (float)$iSec + ((float)$fMilliSec * 100000);
  121. srand($fSeed);
  122. $sResult = '';
  123. for($i=0; $i < 16; ++$i) {
  124. switch(rand(1,2)) {
  125. case 1:
  126. $c = chr(rand(ord('A'),ord('Z')));
  127. break;
  128. case 2:
  129. $c = chr(rand(ord('0'),ord('9')));
  130. break;
  131. }
  132. $sResult .= $c;
  133. }
  134. return $sResult;
  135. }
  136. }
  137. /** @} */