BxBaseModGeneralPageEntry.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 TridentModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxDolAcl');
  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. BxDolView::getObjectInstance($CNF['OBJECT_VIEWS'], $this->_aContentInfo[$CNF['FIELD_ID']])->doView();
  42. }
  43. // add content metatags
  44. if (!empty($CNF['OBJECT_METATAGS'])) {
  45. $o = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
  46. if ($o)
  47. $o->metaAdd($this->_aContentInfo[$CNF['FIELD_ID']], $this->_getThumbForMetaObject());
  48. }
  49. $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
  50. // add actions menu to submenu
  51. if (isset($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY']))
  52. $oMenuSubmenu->setObjectActionsMenu($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY']);
  53. // add social sharing menu to submenu
  54. $oMenuSubmenu->setServiceSocialSharing(array(
  55. 'module' => $this->MODULE,
  56. 'method' => 'entity_social_sharing',
  57. ));
  58. return parent::getCode ();
  59. }
  60. protected function _getThumbForMetaObject ()
  61. {
  62. $CNF = &$this->_oModule->_oConfig->CNF;
  63. if (empty($CNF['FIELD_THUMB']) || empty($this->_aContentInfo[$CNF['FIELD_THUMB']]) || empty($CNF['OBJECT_STORAGE']))
  64. return false;
  65. return array('id' => $this->_aContentInfo[$CNF['FIELD_THUMB']], 'object' => $CNF['OBJECT_STORAGE']);
  66. }
  67. protected function _getPageCacheParams ()
  68. {
  69. if (!$this->_aContentInfo)
  70. return '';
  71. return $this->_aContentInfo[$this->_oModule->_oConfig->CNF['FIELD_ID']]; // cache is different for every entry
  72. }
  73. }
  74. /** @} */