BxBaseModGeneralConfig.php 3.1 KB

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