BxBaseModGeneralPageEntry.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 BaseGeneral Base classes for modules
  7. * @ingroup DolphinModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxTemplPage');
  12. /**
  13. * Entry create/edit pages
  14. */
  15. class BxBaseModGeneralPageEntry extends BxTemplPage
  16. {
  17. protected $MODULE;
  18. protected $_oModule;
  19. protected $_aContentInfo = false;
  20. public function __construct($aObject, $oTemplate = false)
  21. {
  22. parent::__construct($aObject, $oTemplate);
  23. $this->_oModule = BxDolModule::getInstance($this->MODULE);
  24. }
  25. public function getCode ()
  26. {
  27. if (!$this->_aContentInfo) { // if entry is not found - display standard "404 page not found" page
  28. $this->_oTemplate->displayPageNotFound();
  29. exit;
  30. }
  31. if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedView($this->_aContentInfo))) {
  32. $this->_oTemplate->displayAccessDenied($sMsg);
  33. exit;
  34. }
  35. $this->_oModule->checkAllowedView($this->_aContentInfo, true);
  36. if (!empty($CNF['OBJECT_VIEWS'])) {
  37. bx_import('BxDolView');
  38. BxDolView::getObjectInstance($CNF['OBJECT_VIEWS'], $this->_aContentInfo[$CNF['FIELD_ID']])->doView();
  39. }
  40. return parent::getCode ();
  41. }
  42. protected function _getPageCacheParams ()
  43. {
  44. if (!$this->_aContentInfo)
  45. return '';
  46. return $this->_aContentInfo[$this->_oModule->_oConfig->CNF['FIELD_ID']]; // cache is different for every entry
  47. }
  48. }
  49. /** @} */