BxDolInstallView.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup DolphinInstall Dolphin 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 $_aFilesCss = array (
  17. 'common.css',
  18. 'default.less',
  19. 'general.css',
  20. 'icons.css',
  21. 'colors.css',
  22. 'media-desktop.css',
  23. 'media-tablet.css',
  24. 'media-phone.css',
  25. 'media-print.css',
  26. );
  27. protected $_aFilesJs = array (
  28. 'plugins/jquery/jquery.js',
  29. );
  30. function __construct()
  31. {
  32. }
  33. function out ($sTemplate, $aVars = array())
  34. {
  35. extract($aVars);
  36. include($this->_sDirTemplates . $sTemplate);
  37. }
  38. function pageStart ()
  39. {
  40. ob_start();
  41. }
  42. function pageEnd ($sTitle)
  43. {
  44. $sInlineCSS = $this->_getInlineCSS();
  45. $sFilesCSS = $this->_getFilesCSS();
  46. $sFilesJS = $this->_getFilesJS();
  47. $sCode = ob_get_clean();
  48. include($this->_sDirTemplates . '_page.php');
  49. }
  50. protected function _getFilesCSS()
  51. {
  52. $s = '';
  53. foreach ($this->_aFilesCss as $sFile)
  54. if (substr($sFile, -4) === '.css')
  55. $s .= '<link rel="stylesheet" href="' . $this->_sUrlCss . $sFile . '" />';
  56. return $s;
  57. }
  58. protected function _getFilesJS()
  59. {
  60. $s = '';
  61. foreach ($this->_aFilesJs as $sFile)
  62. $s .= '<script src="' . $this->_sUrlJs . $sFile . '"></script>';
  63. return $s;
  64. }
  65. protected function _getInlineCSS()
  66. {
  67. $s = '';
  68. require_once($this->_sDirPlugins . 'lessphp/lessc.inc.php');
  69. $oLess = new lessc();
  70. $oConfigBase = new BxBaseConfig();
  71. $oLess->setVariables($oConfigBase->aLessConfig);
  72. foreach ($this->_aFilesCss as $sFile) {
  73. if (substr($sFile, -5) !== '.less')
  74. continue;
  75. $s .= $oLess->compileFile($this->_sPathCss . $sFile) . "\n";
  76. }
  77. return $s;
  78. }
  79. }
  80. /** @} */