BxDolFilesModule::serviceGetWallAddComment PHP Method

serviceGetWallAddComment() public method

public serviceGetWallAddComment ( $aEvent, $aParams = [] )
    function serviceGetWallAddComment($aEvent, $aParams = array())
    {
        $iId = (int) $aEvent['object_id'];
        $iOwner = (int) $aEvent['owner_id'];
        $sOwner = $iOwner != 0 ? getNickName($iOwner) : _t('_Anonymous');
        $aContent = unserialize($aEvent['content']);
        if (empty($aContent) || empty($aContent['object_id'])) {
            return '';
        }
        $sClassName = $this->_oConfig->getClassPrefix() . 'Search';
        bx_import('Search', $this->_aModule);
        $oSearch = new $sClassName();
        $iItem = (int) $aContent['object_id'];
        $aItem = $oSearch->serviceGetEntry($iItem, 'browse');
        if (empty($aItem) || !is_array($aItem)) {
            return array('perform_delete' => true);
        }
        if (!$this->oAlbumPrivacy->check('album_view', (int) $aItem['album_id'], $this->_iProfileId)) {
            return '';
        }
        bx_import('BxTemplCmtsView');
        $oCmts = new BxTemplCmtsView($this->_oConfig->getMainPrefix(), $iItem);
        if (!$oCmts->isEnabled()) {
            return '';
        }
        $aComment = $oCmts->getCommentRow($iId);
        if (empty($aComment) || !is_array($aComment)) {
            return array('perform_delete' => true);
        }
        $sCss = '';
        $sUri = $this->_oConfig->getUri();
        if ($aEvent['js_mode']) {
            $sCss = $this->_oTemplate->addCss('wall_post.css', true);
        } else {
            $this->_oTemplate->addCss('wall_post.css');
        }
        $sTextWallObject = _t('_bx_' . $sUri . '_wall_object');
        $sTmplName = isset($aParams['templates']['main']) ? $aParams['templates']['main'] : 'modules/boonex/wall/|timeline_comment.html';
        $sTmplNameSnippet = isset($aParams['templates']['snippet']) ? $aParams['templates']['snippet'] : 'modules/boonex/wall/|timeline_comment_files.html';
        return array('title' => _t('_bx_' . $sUri . '_wall_added_new_comment_title', $sOwner, $sTextWallObject), 'description' => $aComment['cmt_text'], 'content' => $sCss . $this->_oTemplate->parseHtmlByName($sTmplName, array('mod_prefix' => 'bx_' . $sUri, 'cpt_user_name' => $sOwner, 'cpt_added_new' => _t('_bx_' . $sUri . '_wall_added_new_comment'), 'cpt_object' => $sTextWallObject, 'cpt_item_url' => $aItem['url'], 'cnt_comment_text' => $aComment['cmt_text'], 'snippet' => $this->_oTemplate->parseHtmlByName($sTmplNameSnippet, array('mod_prefix' => 'bx_' . $sUri, 'cnt_item_page' => $aItem['url'], 'cnt_item_width' => $aItem['width'], 'cnt_item_height' => $aItem['height'], 'cnt_item_icon' => $aItem['file'], 'cnt_item_title' => $aItem['title'], 'cnt_item_title_attr' => bx_html_attribute($aItem['title']), 'cnt_item_description' => $aItem['description'], 'post_id' => $aEvent['id'])))));
    }

Usage Example

Beispiel #1
0
 function serviceGetWallAddComment($aEvent)
 {
     return parent::serviceGetWallAddComment($aEvent, array('templates' => array('snippet' => 'wall_post_comment.html')));
 }