BxBaseModPaymentConfig.php 4.2 KB

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