BxArtificerConfig.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 Artificer Artificer template
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxBaseModTemplateConfig');
  12. class BxArtificerConfig extends BxBaseModTemplateConfig
  13. {
  14. protected $_iLogoDark;
  15. protected $_iLogoDarkWidth;
  16. protected $_iLogoDarkHeight;
  17. protected $_fLogoDarkAspectRatio;
  18. protected $_fLogoDarkAspectRatioDefault;
  19. protected $_sLogoInline;
  20. protected $_iMarkDark;
  21. protected $_iMarkDarkWidth;
  22. protected $_iMarkDarkHeight;
  23. protected $_fMarkDarkAspectRatio;
  24. protected $_fMarkDarkAspectRatioDefault;
  25. protected $_sMarkInline;
  26. protected $_sKeyLogoDarkAspectRatio;
  27. protected $_sKeyMarkDarkAspectRatio;
  28. protected $_aReplacements;
  29. protected $_sThumbSizeDefault;
  30. protected $_aThumbSizes;
  31. protected $_aThumbSizeByTemplate;
  32. function __construct($aModule)
  33. {
  34. parent::__construct($aModule);
  35. $this->CNF = array_merge($this->CNF, [
  36. // some params
  37. 'PARAM_IMAGES_CUSTOM' => 'bx_artificer_images_custom',
  38. ]);
  39. $this->_aJsClasses = array_merge($this->_aJsClasses, array(
  40. 'utils' => 'BxArtificerUtils'
  41. ));
  42. $this->_aJsObjects = array_merge($this->_aJsObjects, array(
  43. 'utils' => 'oBxArtificerUtils'
  44. ));
  45. $this->_iLogoHeight = 40;
  46. $this->_iLogoDarkWidth = 0;
  47. $this->_iLogoDarkHeight = $this->_iLogoHeight;
  48. $this->_fLogoDarkAspectRatioDefault = BxDolDesigns::$fLogoAspectRatioDefault;
  49. $this->_iMarkHeight = 40;
  50. $this->_iMarkDarkWidth = 0;
  51. $this->_iMarkDarkHeight = $this->_iMarkHeight;
  52. $this->_fMarkDarkAspectRatioDefault = BxDolDesigns::$fMarkAspectRatioDefault;
  53. $this->_aPrefixes = [
  54. 'option' => 'bx_artificer_'
  55. ];
  56. $this->_aReplacements = [
  57. 'bx-def-margin-sec-neg' => '-m-2',
  58. ];
  59. $this->_sThumbSizeDefault = 'thumb';
  60. $this->_aThumbSizes = [
  61. 'icon' => 'h-8 w-8',
  62. 'thumb' => 'h-10 w-10',
  63. 'ava' => 'h-24 w-24',
  64. 'ava-big' => 'w-48 h-48'
  65. ];
  66. $this->_aThumbSizeByTemplate = [
  67. 'unit_with_cover.html' => 'h-24 w-24' //--- 'ava' size
  68. ];
  69. }
  70. public function init(&$oDb)
  71. {
  72. parent::init($oDb);
  73. $sPrefix = $this->getPrefix('option');
  74. $this->_sKeyLogoDarkAspectRatio = $sPrefix . 'site_logo_dark_aspect_ratio';
  75. $this->_sKeyMarkDarkAspectRatio = $sPrefix . 'site_mark_dark_aspect_ratio';
  76. $this->_iLogoDark = (int)$this->_oDb->getParam($sPrefix . 'site_logo_dark');
  77. $this->_fLogoDarkAspectRatio = (float)$this->_oDb->getParam($this->_sKeyLogoDarkAspectRatio);
  78. $this->_sLogoInline = $this->_oDb->getParam($sPrefix . 'site_logo_inline');
  79. $this->_iMarkDark = (int)$this->_oDb->getParam($sPrefix . 'site_mark_dark');
  80. $this->_fMarkDarkAspectRatio = (float)$this->_oDb->getParam($this->_sKeyMarkDarkAspectRatio);
  81. $this->_sMarkInline = $this->_oDb->getParam($sPrefix . 'site_mark_inline');
  82. }
  83. public function getColorScheme()
  84. {
  85. return getParam('bx_artificer_color_scheme');
  86. }
  87. public function getLogoParams()
  88. {
  89. $sPrefix = $this->getPrefix('option');
  90. return [
  91. 'logo' => $sPrefix . 'site_logo',
  92. 'logo_dark' => $sPrefix . 'site_logo_dark',
  93. 'logo_inline' => $sPrefix . 'site_logo_inline',
  94. 'mark' => $sPrefix . 'site_mark',
  95. 'mark_dark' => $sPrefix . 'site_mark_dark',
  96. 'mark_inline' => $sPrefix . 'site_mark_inline',
  97. 'logo_alt' => $sPrefix . 'site_logo_alt'
  98. ];
  99. }
  100. public function getReplacements()
  101. {
  102. return $this->_aReplacements;
  103. }
  104. public function getThumbSize($sName = '', $sTemplate = '')
  105. {
  106. if (empty($sName))
  107. $sName = 'thumb';
  108. if(!empty($sName) && isset($this->_aThumbSizes[$sName]))
  109. return $this->_aThumbSizes[$sName];
  110. if(!empty($sTemplate) && isset($this->_aThumbSizeByTemplate[$sTemplate]))
  111. return $this->_aThumbSizeByTemplate[$sTemplate];
  112. return $this->_sThumbSizeDefault;
  113. }
  114. }
  115. /** @} */