1
0

BxBaseModTextPageEntry.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup BaseText Base classes for text modules
  7. * @ingroup DolphinModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxTemplPage');
  12. bx_import('BxDolModule');
  13. bx_import('BxDolMenu');
  14. /**
  15. * Entry create/edit pages
  16. */
  17. class BxBaseModTextPageEntry extends BxTemplPage
  18. {
  19. protected $MODULE;
  20. protected $_oModule;
  21. protected $_aContentInfo = false;
  22. public function __construct($aObject, $oTemplate = false)
  23. {
  24. parent::__construct($aObject, $oTemplate);
  25. $this->_oModule = BxDolModule::getInstance($this->MODULE);
  26. $CNF = &$this->_oModule->_oConfig->CNF;
  27. // select view entry submenu
  28. $oMenuSumbemu = BxDolMenu::getObjectInstance('sys_site_submenu');
  29. $oMenuSumbemu->setObjectSubmenu($CNF['OBJECT_MENU_SUBMENU_VIEW_ENTRY'], $CNF['OBJECT_MENU_SUBMENU_VIEW_ENTRY_MAIN_SELECTION']);
  30. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  31. if ($iContentId)
  32. $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
  33. if ($this->_aContentInfo) {
  34. $this->addMarkers($this->_aContentInfo); // every field can be used as marker
  35. $this->addMarkers(array(
  36. 'title' => strmaxtextlen($this->_aContentInfo[$CNF['FIELD_TEXT']], 20, '...'),
  37. ));
  38. }
  39. bx_import('BxDolView');
  40. BxDolView::getObjectInstance($CNF['OBJECT_VIEWS'], $iContentId)->doView();
  41. }
  42. public function getCode ()
  43. {
  44. if (!$this->_aContentInfo) { // if entry is not found - display standard "404 page not found" page
  45. $this->_oTemplate->displayPageNotFound();
  46. exit;
  47. }
  48. if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedView($this->_aContentInfo))) {
  49. $this->_oTemplate->displayAccessDenied($sMsg);
  50. exit;
  51. }
  52. $this->_oModule->checkAllowedView($this->_aContentInfo, true);
  53. return parent::getCode ();
  54. }
  55. protected function _getPageCacheParams ()
  56. {
  57. return $this->_aContentInfo[$this->_oModule->_oConfig->CNF['FIELD_ID']]; // cache is different for every entry
  58. }
  59. }
  60. /** @} */