BxBaseModGeneralPageEntry.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. // check if content exists
  28. if (!$this->_aContentInfo) { // if entry is not found - display standard "404 page not found" page
  29. $this->_oTemplate->displayPageNotFound();
  30. exit;
  31. }
  32. // permissions check
  33. if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedView($this->_aContentInfo))) {
  34. $this->_oTemplate->displayAccessDenied($sMsg);
  35. exit;
  36. }
  37. $this->_oModule->checkAllowedView($this->_aContentInfo, true);
  38. // count views
  39. $CNF = &$this->_oModule->_oConfig->CNF;
  40. if (!empty($CNF['OBJECT_VIEWS'])) {
  41. bx_import('BxDolView');
  42. BxDolView::getObjectInstance($CNF['OBJECT_VIEWS'], $this->_aContentInfo[$CNF['FIELD_ID']])->doView();
  43. }
  44. // add content metatags
  45. if (!empty($CNF['OBJECT_METATAGS'])) {
  46. bx_import('BxDolMetatags');
  47. $o = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
  48. if ($o) {
  49. $aThumb = false;
  50. if (!empty($CNF['FIELD_THUMB']) && !empty($this->_aContentInfo[$CNF['FIELD_THUMB']]) && !empty($CNF['OBJECT_STORAGE']))
  51. $aThumb = array('id' => $this->_aContentInfo[$CNF['FIELD_THUMB']], 'object' => $CNF['OBJECT_STORAGE']);
  52. $o->metaAdd($this->_aContentInfo[$CNF['FIELD_ID']], $aThumb);
  53. }
  54. }
  55. return parent::getCode ();
  56. }
  57. protected function _getPageCacheParams ()
  58. {
  59. if (!$this->_aContentInfo)
  60. return '';
  61. return $this->_aContentInfo[$this->_oModule->_oConfig->CNF['FIELD_ID']]; // cache is different for every entry
  62. }
  63. }
  64. /** @} */