BxSitesConfig.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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 Sites Sites
  7. * @ingroup DolphinModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxDolModuleConfig');
  12. class BxSitesConfig extends BxDolModuleConfig
  13. {
  14. public static $FIELD_AUTHOR = 'owner_id';
  15. public static $FIELD_ADDED = 'created';
  16. protected $_oDb;
  17. //General
  18. protected $sDomainMask;
  19. protected $aJsClasses;
  20. protected $aJsObjects;
  21. protected $sAnimationEffect;
  22. protected $iAnimationSpeed;
  23. //PayPal payments integration
  24. protected $iTrialMaxNumber;
  25. protected $fTrialPrice;
  26. protected $sTrialPeriod;
  27. protected $iTrialFrequency;
  28. protected $iTrialBillingCycles;
  29. protected $fRegularPrice;
  30. protected $sRegularPeriod;
  31. protected $iRegularFrequency;
  32. protected $iRegularBillingCycles;
  33. protected $sEmailBusiness;
  34. protected $sEmailSandbox;
  35. protected $bDemoMode;
  36. protected $sCurrencyCode;
  37. protected $sCurrencySign;
  38. protected $aPeriodConverter;
  39. /**
  40. * Constructor
  41. */
  42. function __construct($aModule)
  43. {
  44. parent::__construct($aModule);
  45. $this->sDomainMask = '%s.online.me';
  46. $this->aJsClasses = array('main' => 'BxSitesMain');
  47. $this->aJsObjects = array('main' => 'oSitesMain');
  48. $this->sAnimationEffect = 'fade';
  49. $this->iAnimationSpeed = 'slow';
  50. $this->aPeriodConverter = array(
  51. 'Day' => 86400,
  52. 'Week' => 604800,
  53. 'SemiMonth' => 1296000,
  54. 'Month' => 2592000,
  55. 'Year' => 31536000
  56. );
  57. }
  58. function init(&$oDb)
  59. {
  60. $this->_oDb = $oDb;
  61. $this->iTrialMaxNumber = (int)$this->_oDb->getParam('bx_sites_payment_trial_max_number');
  62. $this->fTrialPrice = (float)$this->_oDb->getParam('bx_sites_payment_trial_price');
  63. $this->sTrialPeriod = $this->_oDb->getParam('bx_sites_payment_trial_period');
  64. $this->iTrialFrequency = (float)$this->_oDb->getParam('bx_sites_payment_trial_frequency');
  65. $this->iTrialBillingCycles = 1;
  66. $this->fRegularPrice = (float)$this->_oDb->getParam('bx_sites_payment_regular_price');
  67. $this->sRegularPeriod = $this->_oDb->getParam('bx_sites_payment_regular_period');
  68. $this->iRegularFrequency = (float)$this->_oDb->getParam('bx_sites_payment_regular_frequency');
  69. $this->iRegularBillingCycles = 0;
  70. $this->sEmailBusiness = $this->_oDb->getParam('bx_sites_payment_email_business');
  71. $this->sEmailSandbox = $this->_oDb->getParam('bx_sites_payment_email_sandbox');
  72. $this->bDemoMode = $this->_oDb->getParam('bx_sites_payment_demo_mode') == 'on';
  73. $this->sCurrencyCode = $this->_oDb->getParam('bx_sites_payment_currency_code');
  74. $this->sCurrencySign = $this->_oDb->getParam('bx_sites_payment_currency_sign');
  75. }
  76. function getDomainMask()
  77. {
  78. return $this->sDomainMask;
  79. }
  80. function getPaymentPrice($sType)
  81. {
  82. $fResult = 0;
  83. switch($sType) {
  84. case BX_SITES_PP_PERIOD_TRIAL:
  85. $fResult = $this->fTrialPrice;
  86. break;
  87. case BX_SITES_PP_PERIOD_REGULAR:
  88. $fResult = $this->fRegularPrice;
  89. break;
  90. }
  91. return $fResult;
  92. }
  93. function getPaymentPeriod($sType, $bInSeconds = false)
  94. {
  95. $sResult = 0;
  96. switch($sType) {
  97. case BX_SITES_PP_PERIOD_TRIAL:
  98. $sResult = $this->sTrialPeriod;
  99. break;
  100. case BX_SITES_PP_PERIOD_REGULAR:
  101. $sResult = $this->sRegularPeriod;
  102. break;
  103. }
  104. return $bInSeconds ? $this->aPeriodConverter[$sResult] : $sResult;
  105. }
  106. function getPaymentFrequency($sType)
  107. {
  108. $iResult = 0;
  109. switch($sType) {
  110. case BX_SITES_PP_PERIOD_TRIAL:
  111. $iResult = $this->iTrialFrequency;
  112. break;
  113. case BX_SITES_PP_PERIOD_REGULAR:
  114. $iResult = $this->iRegularFrequency;
  115. break;
  116. }
  117. return $iResult;
  118. }
  119. function getPaymentBillingCycles($sType)
  120. {
  121. $iResult = 0;
  122. switch($sType) {
  123. case BX_SITES_PP_PERIOD_TRIAL:
  124. $iResult = $this->iTrialBillingCycles;
  125. break;
  126. case BX_SITES_PP_PERIOD_REGULAR:
  127. $iResult = $this->iRegularBillingCycles;
  128. break;
  129. }
  130. return $iResult;
  131. }
  132. function isPaymentDemo()
  133. {
  134. return $this->bDemoMode;
  135. }
  136. function getPaymentEmail()
  137. {
  138. return $this->isPaymentDemo() ? $this->sEmailSandbox : $this->sEmailBusiness;
  139. }
  140. function getCurrencyCode()
  141. {
  142. return $this->sCurrencyCode;
  143. }
  144. function getCurrencySign()
  145. {
  146. return $this->sCurrencySign;
  147. }
  148. function getTrialDuration()
  149. {
  150. return $this->getPaymentPeriod(BX_SITES_PP_PERIOD_TRIAL, true) * $this->iTrialFrequency * $this->iTrialBillingCycles;
  151. }
  152. function getTrialMaxNumber()
  153. {
  154. return $this->iTrialMaxNumber;
  155. }
  156. function getJsClass($sType = 'main')
  157. {
  158. if(empty($sType))
  159. return $this->aJsClasses;
  160. return $this->aJsClasses[$sType];
  161. }
  162. function getJsObject($sType = 'main')
  163. {
  164. if(empty($sType))
  165. return $this->aJsObjects;
  166. return $this->aJsObjects[$sType];
  167. }
  168. function getAnimationEffect()
  169. {
  170. return $this->sAnimationEffect;
  171. }
  172. function getAnimationSpeed()
  173. {
  174. return $this->iAnimationSpeed;
  175. }
  176. }
  177. /** @} */