1
0

BxBaseModTextPageAuthor.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. if(bx_process_input(bx_get('owner'), BX_DATA_INT) == 1) {
  30. // select item in Profile Stats menu
  31. $oMenu = BxDolMenu::getObjectInstance('sys_profile_stats');
  32. if($oMenu && isset($this->_aObject['module']) && ($oModuleContent = BxDolModule::getInstance($this->_aObject['module']))) {
  33. $oMenu->setSelected($this->_aObject['module'], 'profile-stats-my-' . $oModuleContent->_oConfig->getUri());
  34. }
  35. }
  36. else {
  37. //set cover
  38. $sProfileModule = $this->_oProfile->getModule();
  39. if(BxDolRequest::serviceExists($sProfileModule, 'set_view_profile_cover')) {
  40. $aProfileInfoFull = BxDolService::call($sProfileModule, 'get_all', array(array('type' => 'id', 'id' => $this->_oProfile->getContentId())));
  41. BxDolService::call($sProfileModule, 'set_view_profile_cover', array($this, $aProfileInfoFull));
  42. }
  43. // select view profile submenu
  44. $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
  45. if ($oMenuSubmenu) {
  46. $sProfileObject = BxDolService::call($this->_oProfile->getModule(), 'get_submenu_object');
  47. if ($sProfileObject)
  48. $oMenuSubmenu->setObjectSubmenu($sProfileObject, array (
  49. 'title' => $this->_oProfile->getDisplayName(),
  50. 'link' => $this->_oProfile->getUrl(),
  51. 'icon' => $this->_oProfile->getIconModule(),
  52. ));
  53. }
  54. }
  55. // add replaceable markers
  56. $this->addMarkers($this->_aProfileInfo); // every profile field can be used as marker
  57. $this->addMarkers(array('profile_id' => $this->_oProfile->id())); // profile id
  58. $this->addMarkers(array('display_name' => $this->_oProfile->getDisplayName())); // profile display name
  59. $this->addMarkers(array('profile_link' => $this->_oProfile->getUrl())); // profile link
  60. }
  61. }
  62. /** @} */