1
0

BxBaseMenuProfileFollowings.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. * Menu representation.
  11. * @see BxDolMenu
  12. */
  13. class BxBaseMenuProfileFollowings extends BxTemplMenu
  14. {
  15. public function __construct ($aObject, $oTemplate)
  16. {
  17. parent::__construct ($aObject, $oTemplate);
  18. $this->_bMultilevel = true;
  19. $this->_bDisplayAddons = true;
  20. }
  21. protected function getMenuItemsRaw ()
  22. {
  23. $aMenuItems = parent::getMenuItemsRaw();
  24. if(empty($aMenuItems) || !is_array($aMenuItems))
  25. return $aMenuItems;
  26. $iProfile = bx_get_logged_profile_id();
  27. $oConnection = BxDolConnection::getObjectInstance('sys_profiles_subscriptions');
  28. foreach($aMenuItems as $iIndex => $aItem) {
  29. $aIds = $oConnection->getConnectedContentByType($iProfile, array($aItem['module']));
  30. if(empty($aItem['onclick']))
  31. $aMenuItems[$iIndex]['onclick'] = 'bx_toggle_pf(this)';
  32. $aSubmenu = array();
  33. foreach($aIds as $iId) {
  34. $oContext = BxDolProfile::getInstance($iId);
  35. if(!$oContext)
  36. continue;
  37. $aSubmenu[] = array(
  38. 'id' => 'context-' . $iId,
  39. 'name' => 'context-' . $iId,
  40. 'class' => '',
  41. 'link' => $oContext->getUrl(),
  42. 'onclick' => '',
  43. 'target' => '_self',
  44. 'title' => $oContext->getDisplayName(),
  45. 'icon' => $oContext->getIcon(),
  46. 'active' => 1
  47. );
  48. }
  49. if(!empty($aSubmenu))
  50. $aMenuItems[$iIndex]['subitems'] = $aSubmenu;
  51. else
  52. unset($aMenuItems[$iIndex]);
  53. }
  54. return $aMenuItems;
  55. }
  56. protected function _getTmplVarsAddon($mixedAddon, $aMenuItem)
  57. {
  58. $aAddon = parent::_getTmplVarsAddon($mixedAddon, $aMenuItem);
  59. $sAddonF = '';
  60. if(!empty($aAddon['addon']))
  61. $sAddonF = $this->_oTemplate->parseHtmlByTemplateName('menu_item_addon', array(
  62. 'content' => $aAddon['addon']
  63. ));
  64. return array(
  65. 'addon' => $aAddon['addon'],
  66. 'addonf' => $sAddonF
  67. );
  68. }
  69. }
  70. /** @} */