BxBasePageHome.php 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. /**
  10. * Homepage.
  11. */
  12. class BxBasePageHome extends BxTemplPage
  13. {
  14. protected $_sTourTheme = 'default';
  15. public function __construct($aObject, $oTemplate)
  16. {
  17. parent::__construct($aObject, $oTemplate);
  18. $this->addMarkers(array('site_title' => getParam('site_title')));
  19. $aCover = $this->getPageCoverImage();
  20. $bTmplVarsCover = !empty($aCover['id']);
  21. $aTmplVarsCover = $bTmplVarsCover ? array('image_url' => BxDolTranscoder::getObjectInstance($aCover['transcoder'])->getFileUrlById($aCover['id'])) : array();
  22. BxDolCover::getInstance()->set(array(
  23. 'class' => 'bx-cover-homepage',
  24. 'title' => _t('_sys_txt_homepage_cover', BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=create-account')),
  25. 'bx_if:bg' => array (
  26. 'condition' => $bTmplVarsCover,
  27. 'content' => $aTmplVarsCover,
  28. ),
  29. ), 'cover_home.html');
  30. $sSelName = 'home';
  31. if(bx_get('i') !== false)
  32. $sSelName = bx_process_input(bx_get('i'));
  33. BxDolMenu::setSelectedGlobal('system', $sSelName);
  34. }
  35. public function getCode ()
  36. {
  37. $s = parent::getCode ();
  38. if (isAdmin() && getParam('site_tour_home') == 'on')
  39. $s .= $this->_oTemplate->parseHtmlByName('homepage_tour.html', array('tour_theme' => $this->_sTourTheme));
  40. if (getParam('add_to_mobile_homepage') == 'on')
  41. $s .= BxDolService::call('system', 'add_to_mobile_homepage', array(), 'TemplServices');
  42. return $s;
  43. }
  44. protected function _getBlockRaw($aBlock)
  45. {
  46. if(strpos($aBlock['title'], 'splash') !== false) {
  47. $oPermalink = BxDolPermalinks::getInstance();
  48. $sJoinForm = $sLoginForm = '';
  49. if(!isLogged()) {
  50. $sJoinForm = BxDolService::call('system', 'create_account_form', array(), 'TemplServiceAccount');
  51. $sLoginForm = BxDolService::call('system', 'login_form', array(), 'TemplServiceLogin');
  52. }
  53. $oTemplate = BxDolTemplate::getInstance();
  54. $oTemplate->addJs(array('lottie.min.js'));
  55. $aBlock['content'] = $oTemplate->parseHtmlByContent($aBlock['content'], array(
  56. 'join_link' => BX_DOL_URL_ROOT . $oPermalink->permalink('page.php?i=create-account'),
  57. 'join_form' => $sJoinForm,
  58. 'join_form_in_box' => !empty($sJoinForm) ? DesignBoxContent(_t('_sys_txt_splash_join'), $sJoinForm, BX_DB_PADDING_DEF) : '',
  59. 'login_link' => BX_DOL_URL_ROOT . $oPermalink->permalink('page.php?i=login'),
  60. 'login_form' => $sLoginForm,
  61. 'login_form_in_box' => !empty($sLoginForm) ? DesignBoxContent(_t('_sys_txt_splash_login'), $sLoginForm, BX_DB_PADDING_DEF) : ''
  62. ));
  63. }
  64. return parent::_getBlockRaw($aBlock);
  65. }
  66. protected function _addJsCss()
  67. {
  68. parent::_addJsCss();
  69. if (isAdmin()) {
  70. $this->_oTemplate->addJs(array(
  71. 'shepherd/js/tether.min.js',
  72. 'shepherd/js/shepherd.min.js',
  73. ));
  74. $this->_oTemplate->addCss(array(
  75. 'homepage.css',
  76. BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'shepherd/css/|shepherd-theme-' . $this->_sTourTheme . '.css'
  77. ));
  78. }
  79. }
  80. }
  81. /** @} */