1
0

BxBaseMenuFooter.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. * Site main menu representation.
  11. */
  12. class BxBaseMenuFooter extends BxTemplMenu
  13. {
  14. public function __construct ($aObject, $oTemplate)
  15. {
  16. parent::__construct ($aObject, $oTemplate);
  17. }
  18. public function getCode ()
  19. {
  20. return parent::getCode() . getVersionComment();
  21. }
  22. public function getMenuItems ()
  23. {
  24. $aItems = parent::getMenuItems();
  25. foreach($aItems as $iKey => $aItem) {
  26. switch($aItem['name']) {
  27. case 'switch_language':
  28. $sTitle = _t('_sys_menu_item_title_switch_language_mask', $aItems[$iKey]['title'], genFlag());
  29. $aItems[$iKey]['title'] = $sTitle;
  30. $aItems[$iKey]['bx_if:title']['condition'] = (bool)$sTitle;
  31. $aItems[$iKey]['bx_if:title']['content']['title'] = $sTitle;
  32. break;
  33. case 'switch_template':
  34. $aTemplates = get_templates_array(true, true);
  35. $sTemplateName = $this->_oTemplate->getCode();
  36. $sTemplateTitle = isset($aTemplates[$sTemplateName]) ? $aTemplates[$sTemplateName] : '';
  37. $sTitle = _t('_sys_menu_item_title_switch_template_mask', $aItems[$iKey]['title'], $sTemplateTitle);
  38. $aItems[$iKey]['title'] = $sTitle;
  39. $aItems[$iKey]['bx_if:title']['condition'] = (bool)$sTitle;
  40. $aItems[$iKey]['bx_if:title']['content']['title'] = $sTitle;
  41. break;
  42. case 'copyright':
  43. $aItems[$iKey]['title_attr'] = bx_html_attribute(_t('_copyright', date('Y')));
  44. break;
  45. case 'powered_by':
  46. $sTitleAttr = bx_html_attribute(_t('_sys_txt_powered_by'));
  47. $aItems[$iKey]['title_attr'] = $sTitleAttr;
  48. $aItems[$iKey]['bx_if:image']['content']['title_attr'] = $sTitleAttr;
  49. break;
  50. }
  51. $bTitleAttr = isset($aItems[$iKey]['title_attr']);
  52. $bTitleAttrImage = isset($aItems[$iKey]['bx_if:image']['content']['title_attr']);
  53. if(!$bTitleAttr || !$bTitleAttrImage) {
  54. $sTitleAttr = bx_html_attribute(strip_tags($aItems[$iKey]['title']));
  55. if(!$bTitleAttr)
  56. $aItems[$iKey]['title_attr'] = $sTitleAttr;
  57. if(!$bTitleAttrImage)
  58. $aItems[$iKey]['bx_if:image']['content']['title_attr'] = $sTitleAttr;
  59. }
  60. }
  61. return $aItems;
  62. }
  63. protected function _isVisible ($a)
  64. {
  65. if(!parent::_isVisible($a))
  66. return false;
  67. $bResult = true;
  68. switch ($a['name']) {
  69. case 'switch_language':
  70. $aLanguages = BxDolLanguagesQuery::getInstance()->getLanguages(false, true);
  71. if(count($aLanguages) <= 1)
  72. $bResult = false;
  73. break;
  74. case 'switch_template':
  75. $aTemplates = get_templates_array(true, true);
  76. if(count($aTemplates) <= 1)
  77. $bResult = false;
  78. break;
  79. }
  80. return $bResult;
  81. }
  82. }
  83. /** @} */