BxBaseModTextPageEntry.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. return $this->_oModule->isEntryActive($this->_aContentInfo);
  44. }
  45. public function getCode ()
  46. {
  47. $mixedResult = parent::getCode();
  48. /*
  49. * Hide actions menu from View Page cover because
  50. * cover area should be decorative in Text Based modules.
  51. */
  52. $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
  53. if($oMenuSubmenu)
  54. $oMenuSubmenu->setObjectActionsMenu(false);
  55. return $mixedResult;
  56. }
  57. protected function _setSubmenu($aParams)
  58. {
  59. $CNF = &$this->_oModule->_oConfig->CNF;
  60. $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
  61. if(!$oMenuSubmenu)
  62. return false;
  63. $oMenuSubmenu->setObjectSubmenu($CNF['OBJECT_MENU_SUBMENU_VIEW_ENTRY'], array_merge(array(
  64. 'title' => '',
  65. 'link' => '',
  66. 'icon' => '',
  67. ), $aParams));
  68. return true;
  69. }
  70. protected function _getBlockService ($aBlock)
  71. {
  72. $a = parent::_getBlockService ($aBlock);
  73. $sTest = '_view_entry_comments';
  74. if (false !== strpos($aBlock['content'], 'entity_comments') && substr_compare($this->_sObject, $sTest, strlen($this->_sObject) - strlen($sTest), strlen($sTest)) === 0)
  75. unset($a['title']);
  76. return $a;
  77. }
  78. protected function _getImageForPageCover ()
  79. {
  80. return false;
  81. }
  82. }
  83. /** @} */