BxBaseModGeneralConfig.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 BaseGeneral Base classes for modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModGeneralConfig extends BxDolModuleConfig
  12. {
  13. public $CNF;
  14. protected $_aObjects;
  15. protected $_aPrefixes;
  16. protected $_aJsClasses;
  17. protected $_aJsObjects;
  18. protected $_aHtmlIds;
  19. protected $_aGridObjects;
  20. /**
  21. * Delayed Publishing Notification Time (in seconds)
  22. * If video transcoding takes more than specified amount of time
  23. * then author will be notified about publishing (failure).
  24. */
  25. protected $_iDpnTime;
  26. function __construct($aModule)
  27. {
  28. parent::__construct($aModule);
  29. $this->CNF = array();
  30. $this->_aObjects = array();
  31. $this->_aPrefixes = array();
  32. $this->_aJsClasses = array();
  33. $this->_aJsObjects = array();
  34. $this->_aGridObjects = array();
  35. $this->_iDpnTime = 3600;
  36. }
  37. public function getObject($sType = '')
  38. {
  39. if(empty($sType))
  40. return $this->_aObjects;
  41. return isset($this->_aObjects[$sType]) ? $this->_aObjects[$sType] : '';
  42. }
  43. public function getPrefix($sType = '')
  44. {
  45. if(empty($sType))
  46. return $this->_aPrefixes;
  47. return isset($this->_aPrefixes[$sType]) ? $this->_aPrefixes[$sType] : '';
  48. }
  49. public function getJsClass($sType)
  50. {
  51. return isset($this->_aJsClasses[$sType]) ? $this->_aJsClasses[$sType] : '';
  52. }
  53. public function getJsObject($sType)
  54. {
  55. return isset($this->_aJsObjects[$sType]) ? $this->_aJsObjects[$sType] : '';
  56. }
  57. public function getGridObject($sType)
  58. {
  59. return isset($this->_aGridObjects[$sType]) ? $this->_aGridObjects[$sType] : '';
  60. }
  61. /**
  62. * Is Auto Approve mode is available.
  63. */
  64. public function isAutoApprove()
  65. {
  66. return !empty($this->CNF['FIELD_STATUS_ADMIN']) && !empty($this->CNF['PARAM_AUTO_APPROVE']);
  67. }
  68. public function isAutoApproveEnabled()
  69. {
  70. return !$this->isAutoApprove() || getParam($this->CNF['PARAM_AUTO_APPROVE']) == 'on';
  71. }
  72. public function isEqualUrls($sUrl1, $sUrl2)
  73. {
  74. $sUrl1 = trim($sUrl1, "/");
  75. $sUrl2 = trim($sUrl2, "/");
  76. return strncmp($sUrl1, $sUrl2, strlen($sUrl1)) === 0;
  77. }
  78. /*
  79. * Note. The first Transcoder in the array $aTranscoders has the highest priority.
  80. */
  81. public function getImageUrl($iId, $aTranscoders)
  82. {
  83. $sResult = '';
  84. if(empty($iId) || empty($aTranscoders) || !is_array($aTranscoders))
  85. return $sResult;
  86. foreach($aTranscoders as $sTranscoder) {
  87. if(empty($this->CNF[$sTranscoder]))
  88. continue;
  89. $oTranscoder = BxDolTranscoderImage::getObjectInstance($this->CNF[$sTranscoder]);
  90. if(!$oTranscoder)
  91. continue;
  92. $sResult = $oTranscoder->getFileUrl($iId);
  93. if(!empty($sResult))
  94. break;
  95. }
  96. return $sResult;
  97. }
  98. public function getDpnTime()
  99. {
  100. return $this->_iDpnTime;
  101. }
  102. }
  103. /** @} */