BxBaseModPaymentConfig.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup BasePayment Base classes for Payment like modules
  7. * @ingroup TridentModules
  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. '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_cart_submenu' => $this->_sName . '_menu_cart_submenu',
  41. 'menu_orders_submenu' => $this->_sName . '_menu_orders_submenu',
  42. 'grid_history' => $this->_sName . '_grid_orders_history',
  43. 'grid_processed' => $this->_sName . '_grid_orders_processed',
  44. 'grid_pending' => $this->_sName . '_grid_orders_pending',
  45. 'grid_carts' => $this->_sName . '_grid_carts',
  46. 'grid_cart' => $this->_sName . '_grid_cart',
  47. ));
  48. $this->_aPerPage = array();
  49. $this->_aHtmlIds = array();
  50. $this->_sAnimationEffect = 'fade';
  51. $this->_iAnimationSpeed = 'slow';
  52. }
  53. public function init(&$oDb)
  54. {
  55. $this->_oDb = $oDb;
  56. $sPrefix = $this->getPrefix('options');
  57. $this->_iSiteId = (int)$this->_oDb->getParam($sPrefix . 'site_admin');
  58. $this->_sCurrencySign = $this->_oDb->getParam($sPrefix . 'default_currency_sign');
  59. $this->_sCurrencyCode = $this->_oDb->getParam($sPrefix . 'default_currency_code');
  60. }
  61. public function getSiteId()
  62. {
  63. if(empty($this->_iSiteId))
  64. return $this->_oDb->getFirstAdminId();
  65. return $this->_iSiteId;
  66. }
  67. public function getCurrencySign()
  68. {
  69. return $this->_sCurrencySign;
  70. }
  71. public function getCurrencyCode()
  72. {
  73. return $this->_sCurrencyCode;
  74. }
  75. public function getKey($sType)
  76. {
  77. $sResult = '';
  78. if(empty($sType) || !isset($this->CNF[$sType]))
  79. return $sResult;
  80. return $this->CNF[$sType];
  81. }
  82. public function getUrl($sType, $aParams = array(), $bSsl = false)
  83. {
  84. $sResult = '';
  85. if(empty($sType) || !isset($this->CNF[$sType]))
  86. return $sResult;
  87. if(strncmp($this->CNF[$sType], BX_DOL_URL_ROOT, strlen(BX_DOL_URL_ROOT)) == 0)
  88. $sResult = bx_append_url_params($this->CNF[$sType], $aParams);
  89. else
  90. $sResult = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($this->CNF[$sType], $aParams);
  91. return $bSsl ? $this->http2https($sResult) : $sResult;
  92. }
  93. public function getDivider($sType)
  94. {
  95. $sResult = '';
  96. if(empty($sType) || !isset($this->CNF[$sType]))
  97. return $sResult;
  98. return $this->CNF[$sType];
  99. }
  100. public function getPerPage($sType = 'default')
  101. {
  102. if(empty($sType))
  103. return $this->_aPerPage;
  104. return isset($this->_aPerPage[$sType]) ? $this->_aPerPage[$sType] : '';
  105. }
  106. public function getHtmlIds($sType, $sKey = '')
  107. {
  108. if(empty($sKey))
  109. return isset($this->_aHtmlIds[$sType]) ? $this->_aHtmlIds[$sType] : array();
  110. return isset($this->_aHtmlIds[$sType][$sKey]) ? $this->_aHtmlIds[$sType][$sKey] : '';
  111. }
  112. public function getAnimationEffect()
  113. {
  114. return $this->_sAnimationEffect;
  115. }
  116. public function getAnimationSpeed()
  117. {
  118. return $this->_iAnimationSpeed;
  119. }
  120. }
  121. /** @} */