| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- <?php defined('BX_DOL') or die('hack attempt');
- /**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup BaseGeneral Base classes for modules
- * @ingroup UnaModules
- *
- * @{
- */
- /**
- * View entry social actions menu
- */
- class BxBaseModGeneralMenuViewActions extends BxTemplMenuCustom
- {
- protected $_sModule;
- protected $_oModule;
- protected $_oMenuAction;
- protected $_oMenuSocialSharing;
- protected $_iContentId;
- protected $_aContentInfo;
- protected $_bDynamicMode;
- protected $_bShowAsButton;
- protected $_bShowTitle;
- public function __construct($aObject, $oTemplate = false)
- {
- parent::__construct($aObject, $oTemplate);
- $this->_oModule = BxDolModule::getInstance($this->_sModule);
- $this->setContentId(bx_process_input(bx_get('id'), BX_DATA_INT));
- $this->_oMenuActions = null;
- $this->_oMenuSocialSharing = null;
- $this->_bShowAsButton = true;
- $this->_bShowTitles = false;
- }
- public function setContentId($iContentId)
- {
- $this->_iContentId = (int)$iContentId;
- $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($this->_iContentId);
- if($this->_aContentInfo)
- $this->addMarkers(array('content_id' => (int)$this->_iContentId));
- }
- protected function _getMenuItemEditPost($aItem)
- {
- return $this->_getMenuItemByNameActions($aItem);
- }
- protected function _getMenuItemDeletePost($aItem)
- {
- return $this->_getMenuItemByNameActions($aItem);
- }
- protected function _getMenuItemView($aItem)
- {
- $CNF = &$this->_oModule->_oConfig->CNF;
- $oObject = !empty($CNF['OBJECT_VIEWS']) ? BxDolView::getObjectInstance($CNF['OBJECT_VIEWS'], $this->_iContentId) : false;
- if(!$oObject || !$oObject->isEnabled())
- return '';
- return $oObject->getElementBlock(array(
- 'dynamic_mode' => $this->_bDynamicMode,
- 'show_do_view_as_button' => $this->_bShowAsButton,
- 'show_do_view_label' => $this->_bShowTitle
- ));
- }
- protected function _getMenuItemComment($aItem)
- {
- $CNF = &$this->_oModule->_oConfig->CNF;
- $oObject = !empty($CNF['OBJECT_COMMENTS']) ? BxTemplCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $this->_iContentId) : false;
- if(!$oObject || !$oObject->isEnabled())
- return '';
- return $oObject->getElementBlock(array(
- 'dynamic_mode' => $this->_bDynamicMode,
- 'show_do_comment_as_button' => $this->_bShowAsButton,
- 'show_do_comment_label' => $this->_bShowTitle
- ));
- }
- protected function _getMenuItemVote($aItem)
- {
- $CNF = &$this->_oModule->_oConfig->CNF;
- $oObject = !empty($CNF['OBJECT_VOTES']) ? BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $this->_iContentId) : false;
- if(!$oObject || !$oObject->isEnabled())
- return '';
- return $oObject->getElementBlock(array(
- 'dynamic_mode' => $this->_bDynamicMode,
- 'show_do_vote_as_button' => $this->_bShowAsButton,
- 'show_do_vote_label' => $this->_bShowTitle
- ));
- }
-
- protected function _getMenuItemScore($aItem)
- {
- $CNF = &$this->_oModule->_oConfig->CNF;
- $oObject = !empty($CNF['OBJECT_SCORES']) ? BxDolScore::getObjectInstance($CNF['OBJECT_SCORES'], $this->_iContentId) : false;
- if(!$oObject || !$oObject->isEnabled())
- return '';
- return $oObject->getElementBlock(array(
- 'dynamic_mode' => $this->_bDynamicMode,
- 'show_do_vote_as_button' => $this->_bShowAsButton,
- 'show_do_vote_label' => $this->_bShowTitle
- ));
- }
- protected function _getMenuItemFavorite($aItem)
- {
- $CNF = &$this->_oModule->_oConfig->CNF;
- $oObject = !empty($CNF['OBJECT_FAVORITES']) ? BxDolFavorite::getObjectInstance($CNF['OBJECT_FAVORITES'], $this->_iContentId) : false;
- if(!$oObject || !$oObject->isEnabled())
- return '';
- return $oObject->getElementBlock(array(
- 'dynamic_mode' => $this->_bDynamicMode,
- 'show_do_favorite_as_button' => $this->_bShowAsButton,
- 'show_do_favorite_label' => $this->_bShowTitle
- ));
- }
- protected function _getMenuItemFeature($aItem)
- {
- $CNF = &$this->_oModule->_oConfig->CNF;
- $oObject = !empty($CNF['OBJECT_FEATURED']) ? BxDolFeature::getObjectInstance($CNF['OBJECT_FEATURED'], $this->_iContentId) : false;
- if(!$oObject || !$oObject->isEnabled())
- return '';
- return $oObject->getElementBlock(array(
- 'dynamic_mode' => $this->_bDynamicMode,
- 'show_do_feature_as_button' => $this->_bShowAsButton,
- 'show_do_feature_label' => $this->_bShowTitle
- ));
- }
- protected function _getMenuItemRepost($aItem)
- {
- $CNF = &$this->_oModule->_oConfig->CNF;
- if(!BxDolRequest::serviceExists('bx_timeline', 'get_repost_element_block'))
- return '';
- return BxDolService::call('bx_timeline', 'get_repost_element_block', array(bx_get_logged_profile_id(), $this->_oModule->_oConfig->getName(), 'added', $this->_iContentId, array(
- 'show_do_repost_as_button' => $this->_bShowAsButton,
- 'show_do_repost_text' => $this->_bShowTitle
- )));
- }
- protected function _getMenuItemReport($aItem)
- {
- $CNF = &$this->_oModule->_oConfig->CNF;
- $oObject = !empty($CNF['OBJECT_REPORTS']) ? BxDolReport::getObjectInstance($CNF['OBJECT_REPORTS'], $this->_iContentId) : false;
- if(!$oObject || !$oObject->isEnabled())
- return '';
- return $oObject->getElementBlock(array(
- 'dynamic_mode' => $this->_bDynamicMode,
- 'show_do_report_as_button' => $this->_bShowAsButton,
- 'show_do_report_label' => $this->_bShowTitle
- ));
- }
- protected function _getMenuItemMoreAuto($aItem)
- {
- $aItem['class_link'] = (!empty($aItem['class_link']) ? $aItem['class_link'] . ' ' : '') . 'bx-btn';
-
- return parent::_getMenuItemMoreAuto($aItem);
- }
- protected function _getMenuItemSocialSharingFacebook($aItem)
- {
- return $this->_getMenuItemByNameSocialSharing($aItem);
- }
- protected function _getMenuItemSocialSharingGoogleplus($aItem)
- {
- return $this->_getMenuItemByNameSocialSharing($aItem);
- }
- protected function _getMenuItemSocialSharingTwitter($aItem)
- {
- return $this->_getMenuItemByNameSocialSharing($aItem);
- }
- protected function _getMenuItemSocialSharingPinterest($aItem)
- {
- return $this->_getMenuItemByNameSocialSharing($aItem);
- }
- protected function _getMenuItemByNameActions($aItem)
- {
- $CNF = &$this->_oModule->_oConfig->CNF;
- if(empty($this->_oMenuActions)) {
- if(empty($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY']))
- return '';
- $this->_oMenuActions = BxDolMenu::getObjectInstance($CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY']);
- $this->_oMenuActions->setContentId($this->_iContentId);
- }
- return $this->_oMenuActions->getCodeItem($aItem['name']);
- }
- protected function _getMenuItemByNameSocialSharing($aItem)
- {
- if(empty($this->_oMenuSocialSharing)) {
- $this->_oMenuSocialSharing = BxDolMenu::getObjectInstance('sys_social_sharing');
- $this->_oMenuSocialSharing->addMarkers(array_merge($this->_aMarkers, array(
- 'id' => $this->_iContentId,
- 'module' => $this->_oModule->_oConfig->getName(),
- )));
- }
- return $this->_oMenuSocialSharing->getCodeItem($aItem['name']);
- }
- }
- /** @} */
|