BxBaseMenuProfileFollowings.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. $aSubmenu = array();
  31. foreach($aIds as $iId) {
  32. $oContext = BxDolProfile::getInstance($iId);
  33. if(!$oContext)
  34. continue;
  35. $aSubmenu[] = array(
  36. 'id' => 'context-' . $iId,
  37. 'name' => 'context-' . $iId,
  38. 'class' => '',
  39. 'link' => $oContext->getUrl(),
  40. 'onclick' => '',
  41. 'target' => '_self',
  42. 'title' => $oContext->getDisplayName(),
  43. 'icon' => $oContext->getIcon(),
  44. 'active' => 1
  45. );
  46. }
  47. if(!empty($aSubmenu))
  48. $aMenuItems[$iIndex]['subitems'] = $aSubmenu;
  49. else
  50. unset($aMenuItems[$iIndex]);
  51. }
  52. return $aMenuItems;
  53. }
  54. protected function _getMenuIcon ($a)
  55. {
  56. list($sIcon, $sIconUrl, $sIconA) = parent::_getMenuIcon($a);
  57. if(!$sIcon && !$sIconUrl && !$sIconA && !empty($a['icon']) && strpos($a['icon'], '.') !== false)
  58. $sIconUrl = $a['icon'];
  59. return array($sIcon, $sIconUrl, $sIconA);
  60. }
  61. protected function _getTmplVarsAddon($mixedAddon, $aMenuItem)
  62. {
  63. $aAddon = parent::_getTmplVarsAddon($mixedAddon, $aMenuItem);
  64. $sAddonF = '';
  65. if(!empty($aAddon['addon']))
  66. $sAddonF = $this->_oTemplate->parseHtmlByTemplateName('menu_item_addon', array(
  67. 'content' => $aAddon['addon']
  68. ));
  69. return array(
  70. 'addon' => $aAddon['addon'],
  71. 'addonf' => $sAddonF
  72. );
  73. }
  74. }
  75. /** @} */