1
0

BxDolInstallView.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php defined('BX_DOL_INSTALL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaInstall UNA Install
  7. * @{
  8. */
  9. class BxDolInstallView
  10. {
  11. protected $_sDirPlugins = BX_INSTALL_DIR_PLUGINS;
  12. protected $_sDirTemplates = BX_INSTALL_DIR_TEMPLATES;
  13. protected $_sUrlCss = '../template/css/';
  14. protected $_sPathCss = '../template/css/';
  15. protected $_sUrlJs = '../';
  16. protected $_aToolbarItem = array();
  17. protected $_aFilesCss = array (
  18. '../../plugins_public/tailwind/css/tailwind.min.css',
  19. 'common.css',
  20. 'default.less',
  21. 'general.css',
  22. 'icons.css',
  23. 'colors.css',
  24. 'forms.css',
  25. 'menu.css',
  26. 'media-desktop.css',
  27. 'media-tablet.css',
  28. 'media-phone.css',
  29. 'media-print.css',
  30. );
  31. protected $_aFilesJs = array (
  32. 'plugins_public/jquery/jquery.min.js',
  33. 'plugins_public/jquery-ui/jquery-ui.min.js',
  34. 'inc/js/jquery.dolPopup.js',
  35. 'inc/js/jquery.webForms.js',
  36. );
  37. function __construct()
  38. {
  39. }
  40. function out ($sTemplate, $aVars = array())
  41. {
  42. extract($aVars);
  43. include($this->_sDirTemplates . $sTemplate);
  44. }
  45. function pageStart ()
  46. {
  47. ob_start();
  48. }
  49. function pageEnd ($sTitle)
  50. {
  51. $oLang = BxDolInstallLang::getInstance();
  52. $aLangs = $oLang->getAvailableLanguages();
  53. $sLang = $oLang->getLang();
  54. $sLangTitle = (isset($aLangs[$sLang]) && !empty($aLangs[$sLang]['title'])) ? $aLangs[$sLang]['title'] : $sLang;
  55. $aToolbarItem = $this->_aToolbarItem;
  56. $sInlineCSS = $this->_getInlineCSS();
  57. $sFilesCSS = $this->_getFilesCSS();
  58. $sFilesJS = $this->_getFilesJS();
  59. $sCode = ob_get_clean();
  60. include($this->_sDirTemplates . '_page.php');
  61. }
  62. function setToolbarItem($sIcon, $sLink, $sTitle = '', $sTarget = '')
  63. {
  64. $this->_aToolbarItem = array(
  65. 'icon' => $sIcon,
  66. 'link' => $sLink,
  67. 'title' => $sTitle,
  68. 'target' => $sTarget,
  69. );
  70. }
  71. protected function _getFilesCSS()
  72. {
  73. $s = '';
  74. foreach ($this->_aFilesCss as $sFile)
  75. if (substr($sFile, -4) === '.css')
  76. $s .= '<link rel="stylesheet" href="' . $this->_sUrlCss . $sFile . '" />' . "\n";
  77. return $s;
  78. }
  79. protected function _getFilesJS()
  80. {
  81. $s = '';
  82. foreach ($this->_aFilesJs as $sFile)
  83. $s .= '<script src="' . $this->_sUrlJs . $sFile . '"></script>';
  84. return $s;
  85. }
  86. protected function _getInlineCSS()
  87. {
  88. $oLessParser = new Less_Parser();
  89. $oConfigBase = new BxBaseConfig();
  90. $oLessParser->ModifyVars($oConfigBase->aLessConfig);
  91. foreach ($this->_aFilesCss as $sFile) {
  92. if (substr($sFile, -5) !== '.less')
  93. continue;
  94. $oLessParser->parseFile($this->_sPathCss . $sFile, $this->_sUrlCss);
  95. }
  96. return $oLessParser->getCss();
  97. }
  98. }
  99. /** @} */