1
0

BxBaseModTextPageEntry.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. * Entry create/edit pages
  13. */
  14. class BxBaseModTextPageEntry extends BxBaseModGeneralPageEntry
  15. {
  16. public function __construct($aObject, $oTemplate = false)
  17. {
  18. parent::__construct($aObject, $oTemplate);
  19. $CNF = &$this->_oModule->_oConfig->CNF;
  20. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  21. if ($iContentId)
  22. $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
  23. $sTitle = $sUrl = $sIcon = "";
  24. if ($this->_aContentInfo && CHECK_ACTION_RESULT_ALLOWED === $this->_oModule->checkAllowedView($this->_aContentInfo)) {
  25. $sTitle = isset($this->_aContentInfo[$CNF['FIELD_TITLE']]) ? $this->_aContentInfo[$CNF['FIELD_TITLE']] : strmaxtextlen($this->_aContentInfo[$CNF['FIELD_TEXT']], 20, '...');
  26. $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $this->_aContentInfo[$CNF['FIELD_ID']]);
  27. $sIcon = $CNF['ICON'];
  28. $this->addMarkers($this->_aContentInfo); // every field can be used as marker
  29. }
  30. $this->addMarkers(array(
  31. 'title' => $sTitle,
  32. 'entry_link' => $sUrl,
  33. ));
  34. // select view entry submenu
  35. $this->_setSubmenu(array(
  36. 'title' => $sTitle,
  37. 'link' => $sUrl,
  38. 'icon' => $sIcon
  39. ));
  40. }
  41. public function isActive()
  42. {
  43. $CNF = &$this->_oModule->_oConfig->CNF;
  44. if($this->_aContentInfo[$CNF['FIELD_AUTHOR']] == bx_get_logged_profile_id() || $this->_oModule->_isModerator())
  45. return true;
  46. if(isset($CNF['FIELD_STATUS']) && $this->_aContentInfo[$CNF['FIELD_STATUS']] != 'active')
  47. return false;
  48. if(isset($CNF['FIELD_STATUS_ADMIN']) && $this->_aContentInfo[$CNF['FIELD_STATUS_ADMIN']] != 'active')
  49. return false;
  50. return true;
  51. }
  52. protected function _setSubmenu($aParams)
  53. {
  54. $CNF = &$this->_oModule->_oConfig->CNF;
  55. $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
  56. $oMenuSubmenu->setObjectSubmenu($CNF['OBJECT_MENU_SUBMENU_VIEW_ENTRY'], array_merge(array(
  57. 'title' => '',
  58. 'link' => '',
  59. 'icon' => '',
  60. ), $aParams));
  61. }
  62. protected function _getBlockService ($aBlock)
  63. {
  64. $a = parent::_getBlockService ($aBlock);
  65. $sTest = '_view_entry_comments';
  66. if (false !== strpos($aBlock['content'], 'entity_comments') && substr_compare($this->_sObject, $sTest, strlen($this->_sObject) - strlen($sTest), strlen($sTest)) === 0)
  67. unset($a['title']);
  68. return $a;
  69. }
  70. protected function _getImageForPageCover ()
  71. {
  72. return false;
  73. }
  74. }
  75. /** @} */