BxTemplFunctions.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 UnaTemplate UNA Template Classes
  7. * @{
  8. */
  9. class BxTemplFunctions extends BxBaseFunctions
  10. {
  11. protected $_sModule;
  12. function __construct($oTemplate = null)
  13. {
  14. $this->_sModule = 'bx_lucid';
  15. parent::__construct($oTemplate);
  16. }
  17. protected function getInjHeadStylesCustom()
  18. {
  19. $sCss = trim(getParam($this->_sModule . '_styles_custom'));
  20. return !empty($sCss) ? $this->_oTemplate->_wrapInTagCssCode($sCss) : '';
  21. }
  22. protected function getInjFooterIncludeCssJs()
  23. {
  24. return $this->_oTemplate->addJs([
  25. 'modules/base/template/js/|sidebar.js',
  26. ], true);
  27. }
  28. protected function getInjFooterPopupMenus()
  29. {
  30. $sContent = '';
  31. $oSearch = new BxTemplSearch();
  32. $oSearch->setLiveSearch(true);
  33. $sContent .= $this->_oTemplate->parsePageByName('search.html', array(
  34. 'search_form' => $oSearch->getForm(BX_DB_CONTENT_ONLY),
  35. 'results' => $oSearch->getResultsContainer(),
  36. ));
  37. if(isLogged()) {
  38. $sContent .= $this->_oTemplate->getMenu ('sys_add_content');
  39. $sContent .= $this->_oTemplate->getMenu ('sys_account_popup');
  40. }
  41. return $sContent;
  42. }
  43. protected function getInjFooterMenuDropdown()
  44. {
  45. $bLogged = isLogged();
  46. $sCode = '';
  47. $oSearch = new BxTemplSearch();
  48. $oSearch->setLiveSearch(true);
  49. $sSearch = $oSearch->getForm(BX_DB_CONTENT_ONLY);
  50. $bTmplVarsLogin = false;
  51. $aTmplVarsLogin = array();
  52. /*
  53. * Note. For now, login form was removed from Dropdown Menu.
  54. *
  55. $bTmplVarsLogin = !$bLogged;
  56. $aTmplVarsLogin = array();
  57. if($bTmplVarsLogin)
  58. $aTmplVarsLogin = array(
  59. 'login' => bx_srv('bx_canonic', 'get_block_login', array('menu'))
  60. );
  61. */
  62. $bTmplVarsProfile = false;
  63. $aTmplVarsProfile = array();
  64. /*
  65. * Note. For now, profile related items were removed from Dropdown Menu.
  66. *
  67. $bTmplVarsProfile = $bLogged;
  68. $aTmplVarsProfile = array();
  69. if($bTmplVarsProfile) {
  70. $oProfile = BxDolProfile::getInstance(bx_get_logged_profile_id());
  71. $aTmplVarsProfile = array(
  72. 'user_unit' => $oProfile->getUnit(0, array('template' => 'unit_wo_info_links')),
  73. 'user_name' => $oProfile->getDisplayName(),
  74. 'user_link' => $oProfile->getUrl(),
  75. 'bx_repeat:profile_submenu_items' => BxDolMenu::getObjectInstance('sys_account_notifications')->getMenuItems()
  76. );
  77. $sCode .= bx_srv('bx_notifications', 'get_include');
  78. }
  79. */
  80. $sLogoUrl = $this->getMainLogoUrl();
  81. $bLogoUrl = !empty($sLogoUrl);
  82. $sLogoText = BxDolDesigns::getInstance()->getSiteLogoAlt();
  83. if(empty($sLogoText))
  84. $sLogoText = getParam('site_title');
  85. $sCode .= $this->_oTemplate->parsePageByName('menu_dropdown.html', array(
  86. 'bx_if:show_logo_image' => array(
  87. 'condition' => $bLogoUrl,
  88. 'content' => array(
  89. 'logo_url' => $sLogoUrl,
  90. 'logo_text' => $sLogoText
  91. )
  92. ),
  93. 'bx_if:show_logo_text' => array(
  94. 'condition' => !$bLogoUrl,
  95. 'content' => array(
  96. 'logo_text' => $sLogoText
  97. )
  98. ),
  99. 'search_form' => $sSearch,
  100. 'bx_if:show_login' => array(
  101. 'condition' => $bTmplVarsLogin,
  102. 'content' => $aTmplVarsLogin
  103. ),
  104. 'bx_if:show_profile' => array(
  105. 'condition' => $bTmplVarsProfile,
  106. 'content' => $aTmplVarsProfile
  107. ),
  108. ));
  109. return $sCode;
  110. }
  111. }
  112. /** @} */