BxArtificerModule.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 ('BxBaseModTemplateModule');
  12. class BxArtificerModule extends BxBaseModTemplateModule
  13. {
  14. function __construct(&$aModule)
  15. {
  16. parent::__construct($aModule);
  17. }
  18. public function processReplacements($s)
  19. {
  20. $a = $this->_oConfig->getReplacements();
  21. if(empty($a))
  22. return $s;
  23. return str_replace(array_keys($a), array_values($a), $s);
  24. }
  25. public function serviceGetSafeServices()
  26. {
  27. return array_merge(parent::serviceGetSafeServices(), [
  28. 'GetSplashMarker' => '',
  29. ]);
  30. }
  31. public function serviceIncludeCssJs($sType)
  32. {
  33. if(BxDolTemplate::getInstance()->getCode() != $this->_oConfig->getUri())
  34. return '';
  35. return $this->_oTemplate->getIncludeCssJs($sType);
  36. }
  37. public function serviceGetOptionsColorScheme()
  38. {
  39. $aOptions = ['auto', 'light_only', 'dark_only'];
  40. $aResult = [];
  41. foreach($aOptions as $sOption)
  42. $aResult[$sOption] = _t('_bx_artificer_stg_cpt_option_color_scheme_' . $sOption);
  43. return $aResult;
  44. }
  45. public function serviceGetSplashMarker($sName)
  46. {
  47. $sResult = '';
  48. switch($sName) {
  49. case 'header':
  50. $sResult = $this->_oTemplate->getHeader();
  51. break;
  52. case 'members':
  53. $sResult = '0';
  54. if($aMembers = BxDolAccountQuery::getInstance()->getAccounts(['type' => 'confirmed']))
  55. $sResult = count($aMembers);
  56. break;
  57. case 'posts':
  58. $iPosts = 0;
  59. $aModules = bx_srv('system', 'get_modules_by_type', ['content']);
  60. foreach($aModules as $aModule)
  61. if(BxDolRequest::serviceExists($aModule['name'], 'get_all'))
  62. $iPosts += bx_srv($aModule['name'], 'get_all', [['type' => 'all', 'count' => true]]);
  63. $sResult = $iPosts;
  64. break;
  65. case 'comments':
  66. $sResult = (int)BxDolCmtsQuery::getInfoBy(['type' => 'all', 'count' => true]);
  67. break;
  68. case 'login_agreement':
  69. $oPermalink = BxDolPermalinks::getInstance();
  70. $sLinkTerms = BX_DOL_URL_ROOT . $oPermalink->permalink('page.php?i=terms');
  71. $sLinkPrivacy = BX_DOL_URL_ROOT . $oPermalink->permalink('page.php?i=privacy');
  72. $sResult = _t('_bx_artificer_txt_splash_login_agreement', $sLinkTerms, $sLinkPrivacy);
  73. break;
  74. }
  75. return $sResult;
  76. }
  77. }
  78. /** @} */