_oModule = BxDolModule::getInstance($this->MODULE); parent::__construct($aObject, $oTemplate ? $oTemplate : $this->_oModule->_oTemplate); $this->_sCoverClass = $this->_oModule->getName() . '_cover'; } public function isActive() { return true; } public function getContentInfo() { return $this->_aContentInfo; } public function getCode () { // check if content exists if (!$this->_aContentInfo || !$this->isActive()) { // if entry is not found - display standard "404 page not found" page $this->_oTemplate->displayPageNotFound(); exit; } $oCover = BxDolCover::getInstance($this->_oModule->_oTemplate); if ($oCover) $oCover->setCoverClass($this->_sCoverClass); // permissions check $this->_processPermissionsCheck (); // count views $CNF = &$this->_oModule->_oConfig->CNF; if(!empty($CNF['OBJECT_VIEWS'])) { $oView = BxDolView::getObjectInstance($CNF['OBJECT_VIEWS'], $this->_aContentInfo[$CNF['FIELD_ID']]); if($oView && $oView->isEnabled()) $oView->doView(); } // set cover image $mixedCover = method_exists($this, '_getImageForPageCover') ? $this->_getImageForPageCover() : $this->_getThumbForMetaObject(); if($mixedCover !== false) { $aCover = array( 'id' => $mixedCover['id'] ); if(!empty($mixedCover['transcoder'])) $aCover['transcoder'] = $mixedCover['transcoder']; else if(!empty($CNF['OBJECT_IMAGES_TRANSCODER_COVER'])) $aCover['transcoder'] = $CNF['OBJECT_IMAGES_TRANSCODER_COVER']; else if(!empty($mixedCover['object'])) $aCover['object'] = $mixedCover['object']; $oCover->setCoverImageUrl($aCover); } // add content metatags if(!empty($CNF['OBJECT_METATAGS']) && ($o = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS'])) !== false) $o->addPageMetaInfo($this->_aContentInfo[$CNF['FIELD_ID']], $this->_getThumbForMetaObject()); $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu'); if($oMenuSubmenu) { // add actions menu to submenu if(isset($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY'])) $oMenuSubmenu->setObjectActionsMenu($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY']); // add social sharing menu to submenu $oMenuSubmenu->setServiceSocialSharing(array( 'module' => $this->MODULE, 'method' => 'entity_social_sharing', )); } return parent::getCode (); } protected function _processPermissionsCheck () { if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedView($this->_aContentInfo))) { $this->_oTemplate->displayAccessDenied($sMsg); exit; } $this->_oModule->checkAllowedView($this->_aContentInfo, true); } protected function _getThumbForMetaObject () { return $this->_oModule->getEntryImageData($this->_aContentInfo); } protected function _getPageCacheParams () { if (!$this->_aContentInfo) return ''; return $this->_aContentInfo[$this->_oModule->_oConfig->CNF['FIELD_ID']]; // cache is different for every entry } } /** @} */