BxDolTwigModule::_serviceGetWallPostOutline PHP Method

_serviceGetWallPostOutline() public method

public _serviceGetWallPostOutline ( $aEvent, $sIcon, $aParams = [] )
    function _serviceGetWallPostOutline($aEvent, $sIcon, $aParams = array())
    {
        $iNoPhotoWidth = $iNoPhotoHeight = 140;
        $sNoPhoto = $this->_oTemplate->getImageUrl('no-image-thumb.png');
        $sBaseUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/';
        $aOwner = db_assoc_arr("SELECT `ID` AS `id`, `NickName` AS `username` FROM `Profiles` WHERE `ID`='" . (int) $aEvent['owner_id'] . "' LIMIT 1");
        $aObjectIds = strpos($aEvent['object_id'], ',') !== false ? explode(',', $aEvent['object_id']) : array($aEvent['object_id']);
        rsort($aObjectIds);
        $iItems = count($aObjectIds);
        $iItemsLimit = isset($aParams['grouped']['items_limit']) ? (int) $aParams['grouped']['items_limit'] : 3;
        if ($iItems > $iItemsLimit) {
            $aObjectIds = array_slice($aObjectIds, 0, $iItemsLimit);
        }
        $bSave = false;
        $aContent = array();
        if (!empty($aEvent['content'])) {
            $aContent = unserialize($aEvent['content']);
        }
        if (!isset($aContent['idims'])) {
            $aContent['idims'] = array();
        }
        $iDeleted = 0;
        $aItems = $aTmplItems = array();
        foreach ($aObjectIds as $iId) {
            $aItem = $this->_oDb->getEntryByIdAndOwner($iId, $aEvent['owner_id'], 1);
            if (empty($aItem)) {
                $iDeleted++;
            } else {
                if ($aItem[$this->_oDb->_sFieldStatus] == 'approved' && $aParams['obj_privacy']->check($aParams['txt_privacy_view_event'], $iId, $this->_iProfileId)) {
                    $aItem['thumb_file'] = '';
                    $aItem['thumb_dims'] = array();
                    if ($aItem[$this->_oDb->_sFieldThumb]) {
                        $aImage = BxDolService::call('photos', 'get_entry', array($aItem[$this->_oDb->_sFieldThumb], 'browse'), 'Search');
                        if (!empty($aImage)) {
                            if (!isset($aContent['idims'][$iId])) {
                                $sPath = isset($aImage['file_path']) && file_exists($aImage['file_path']) ? $aImage['file_path'] : $aImage['file'];
                                $aContent['idims'][$iId] = BxDolImageResize::instance()->getImageSize($sPath);
                                $bSave = true;
                            }
                            $aItem['thumb_file'] = $aImage['file'];
                            $aItem['thumb_dims'] = $aContent['idims'][$iId];
                        }
                        $aImage = BxDolService::call('photos', 'get_entry', array($aItem[$this->_oDb->_sFieldThumb], 'browse2x'), 'Search');
                        $aItem['thumb_file_2x'] = !empty($aImage) ? $aImage['file'] : $aItem['thumb_file'];
                    }
                    $aItem[$this->_oDb->_sFieldUri] = $sBaseUrl . $aItem[$this->_oDb->_sFieldUri];
                    $aItems[] = $aItem;
                    $aTmplItems[] = array('mod_prefix' => $this->_sPrefix, 'item_width' => isset($aItem['thumb_dims']['w']) ? $aItem['thumb_dims']['w'] : $iNoPhotoWidth, 'item_height' => isset($aItem['thumb_dims']['h']) ? $aItem['thumb_dims']['h'] : $iNoPhotoHeight, 'item_icon' => !empty($aItem['thumb_file']) ? $aItem['thumb_file'] : $sNoPhoto, 'item_icon_2x' => !empty($aItem['thumb_file_2x']) ? $aItem['thumb_file_2x'] : $sNoPhoto, 'item_page' => $aItem[$this->_oDb->_sFieldUri], 'item_title' => $aItem[$this->_oDb->_sFieldTitle]);
                }
            }
        }
        if ($iDeleted == count($aObjectIds)) {
            return array('perform_delete' => true);
        }
        if (empty($aOwner) || empty($aItems)) {
            return "";
        }
        $aResult = array();
        if ($bSave) {
            $aResult['save']['content'] = serialize($aContent);
        }
        $sCss = "";
        if ($aEvent['js_mode']) {
            $sCss = $this->_oTemplate->addCss('wall_outline.css', true);
        } else {
            $this->_oTemplate->addCss('wall_outline.css');
        }
        $iOwner = (int) $aEvent['owner_id'];
        $sOwner = getNickName($iOwner);
        $sOwnerLink = getProfileLink($iOwner);
        //--- Grouped events
        $iItems = count($aItems);
        if ($iItems > 1) {
            $sTmplName = isset($aParams['templates']['grouped']) ? $aParams['templates']['grouped'] : 'modules/boonex/wall/|outline_item_image_grouped';
            $aResult['content'] = $sCss . $this->_oTemplate->parseHtmlByName($sTmplName, array('mod_prefix' => $this->_sPrefix, 'mod_icon' => $sIcon, 'user_name' => $sOwner, 'user_link' => $sOwnerLink, 'bx_repeat:items' => $aTmplItems, 'album_url' => '', 'album_title' => '', 'album_description' => '', 'album_comments' => 0 ? _t('_wall_n_comments', 0) : _t('_wall_no_comments'), 'album_comments_link' => '', 'post_id' => $aEvent['id'], 'post_ago' => $aEvent['ago']));
            return $aResult;
        }
        //--- Single public event
        $aItem = $aItems[0];
        $aTmplItem = $aTmplItems[0];
        $sTmplName = isset($aParams['templates']['single']) ? $aParams['templates']['single'] : 'modules/boonex/wall/|outline_item_image';
        $aResult['content'] = $sCss . $this->_oTemplate->parseHtmlByName($sTmplName, array_merge($aTmplItem, array('mod_prefix' => $this->_sPrefix, 'mod_icon' => $sIcon, 'user_name' => $sOwner, 'user_link' => $sOwnerLink, 'item_page' => $aItem[$this->_oDb->_sFieldUri], 'item_title' => $aItem[$this->_oDb->_sFieldTitle], 'item_description' => $this->_formatSnippetTextForOutline($aItem), 'item_comments' => (int) $aItem[$this->_oDb->_sFieldCommentCount] > 0 ? _t('_wall_n_comments', $aItem[$this->_oDb->_sFieldCommentCount]) : _t('_wall_no_comments'), 'item_comments_link' => $aItem[$this->_oDb->_sFieldUri] . '#cmta-' . $this->_sPrefix . '-' . $aItem[$this->_oDb->_sFieldId], 'post_id' => $aEvent['id'], 'post_ago' => $aEvent['ago'])));
        return $aResult;
    }

Usage Example

Ejemplo n.º 1
0
 function serviceGetWallPostOutline($aEvent)
 {
     $aParams = array('txt_privacy_view_event' => 'view_product', 'obj_privacy' => $this->_oPrivacyProduct, 'templates' => array('grouped' => 'wall_outline_grouped'));
     return parent::_serviceGetWallPostOutline($aEvent, 'shopping-cart', $aParams);
 }
All Usage Examples Of BxDolTwigModule::_serviceGetWallPostOutline