1
0

BxBaseModTextPageAuthor.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 BaseText Base classes for text modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Profile's entries page.
  13. */
  14. class BxBaseModTextPageAuthor extends BxTemplPage
  15. {
  16. protected $_aProfileInfo;
  17. protected $_oProfile;
  18. public function __construct($aObject, $oTemplate = false)
  19. {
  20. parent::__construct($aObject, $oTemplate);
  21. // get profile info
  22. $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
  23. if ($iProfileId) {
  24. $this->_oProfile = BxDolProfile::getInstance($iProfileId);
  25. $this->_aProfileInfo = $this->_oProfile ? $this->_oProfile->getInfo() : false;
  26. }
  27. if (!$this->_aProfileInfo || !$this->_oProfile)
  28. return;
  29. //set cover
  30. $sProfileModule = $this->_oProfile->getModule();
  31. if(BxDolRequest::serviceExists($sProfileModule, 'set_view_profile_cover')) {
  32. $aProfileInfoFull = BxDolService::call($sProfileModule, 'get_all', array(array('type' => 'id', 'id' => $this->_oProfile->getContentId())));
  33. BxDolService::call($sProfileModule, 'set_view_profile_cover', array($this, $aProfileInfoFull));
  34. }
  35. // select view profile submenu
  36. $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
  37. if ($oMenuSubmenu) {
  38. $sProfileObject = BxDolService::call($this->_oProfile->getModule(), 'get_submenu_object');
  39. if ($sProfileObject)
  40. $oMenuSubmenu->setObjectSubmenu($sProfileObject, array (
  41. 'title' => $this->_oProfile->getDisplayName(),
  42. 'link' => $this->_oProfile->getUrl(),
  43. 'icon' => $this->_oProfile->getIconModule(),
  44. ));
  45. }
  46. // add replaceable markers
  47. $this->addMarkers($this->_aProfileInfo); // every profile field can be used as marker
  48. $this->addMarkers(array('profile_id' => $this->_oProfile->id())); // profile id
  49. $this->addMarkers(array('display_name' => $this->_oProfile->getDisplayName())); // profile display name
  50. $this->addMarkers(array('profile_link' => $this->_oProfile->getUrl())); // profile link
  51. }
  52. }
  53. /** @} */