Exemplo n.º 1
0
 function getWallPostOutline($aEvent, $sIcon = 'save', $aParams = array())
 {
     $sPrefix = $this->_oConfig->getMainPrefix();
     $sPrefixAlbum = $sPrefix . '_albums';
     $aOwner = getProfileInfo((int) $aEvent['owner_id']);
     $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();
     }
     $sClassName = $this->_oConfig->getClassPrefix() . 'Search';
     bx_import('Search', $this->_aModule);
     $oSearch = new $sClassName();
     $sItemThumbnailType = isset($aParams['thumbnail_type']) ? $aParams['thumbnail_type'] : 'browse';
     $iDeleted = 0;
     $aItems = $aTmplItems = array();
     foreach ($aObjectIds as $iId) {
         $aItem = $oSearch->serviceGetItemArray($iId, $sItemThumbnailType);
         if (empty($aItem)) {
             $iDeleted++;
         } else {
             if ($aItem['status'] == 'approved' && $this->oAlbumPrivacy->check('album_view', $aItem['album_id'], $this->oModule->_iProfileId)) {
                 if (!isset($aContent['idims'][$iId])) {
                     $sPath = isset($aItem['file_path']) && file_exists($aItem['file_path']) ? $aItem['file_path'] : $aItem['file'];
                     $aContent['idims'][$iId] = BxDolImageResize::instance()->getImageSize($sPath);
                     $bSave = true;
                 }
                 $aItem['dims'] = $aContent['idims'][$iId];
                 $aItems[] = $aItem;
                 $aItem2x = $oSearch->serviceGetItemArray($iId, $sItemThumbnailType . '2x');
                 $aTmplItems[] = array_merge($aItem, array('mod_prefix' => $sPrefix, 'item_width' => $aItem['dims']['w'], 'item_height' => $aItem['dims']['h'], 'item_icon' => $aItem['file'], 'item_icon_2x' => !empty($aItem2x['file']) ? $aItem2x['file'] : $aItem['file'], 'item_page' => $aItem['url'], 'item_title' => $aItem['title']));
             }
         }
     }
     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) {
         $aExtra = unserialize($aEvent['content']);
         $sAlbumUri = $aExtra['album'];
         $oAlbum = new BxDolAlbums($sPrefix);
         $aAlbumInfo = $oAlbum->getAlbumInfo(array('fileUri' => $sAlbumUri, 'owner' => $iOwner));
         $oAlbumCmts = new BxTemplCmtsView($sPrefixAlbum, $aAlbumInfo['ID']);
         $aAlbumInfo['comments_count'] = (int) $oAlbumCmts->getObjectCommentsCount();
         $aAlbumInfo['Url'] = $oSearch->getCurrentUrl('album', $aAlbumInfo['ID'], $aAlbumInfo['Uri']) . '/owner/' . getUsername($iOwner);
         $sTmplName = isset($aParams['templates']['grouped']) ? $aParams['templates']['grouped'] : 'modules/boonex/wall/|outline_item_image_grouped.html';
         $aResult['content'] = $sCss . $this->_oTemplate->parseHtmlByName($sTmplName, array('mod_prefix' => $sPrefix, 'mod_icon' => $sIcon, 'user_name' => $sOwner, 'user_link' => $sOwnerLink, 'bx_repeat:items' => $aTmplItems, 'album_url' => $aAlbumInfo['Url'], 'album_title' => $aAlbumInfo['Caption'], 'album_description' => strmaxtextlen($aAlbumInfo['Description'], 200), 'album_comments' => (int) $aAlbumInfo['comments_count'] > 0 ? _t('_wall_n_comments', $aAlbumInfo['comments_count']) : _t('_wall_no_comments'), 'album_comments_link' => $aAlbumInfo['Url'] . '#cmta-' . $sPrefixAlbum . '-' . $aAlbumInfo['ID'], '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.html';
     $aResult['content'] = $sCss . $this->_oTemplate->parseHtmlByName($sTmplName, array_merge($aTmplItem, array('mod_prefix' => $sPrefix, 'mod_icon' => $sIcon, 'user_name' => $sOwner, 'user_link' => $sOwnerLink, 'item_page' => $aItem['url'], 'item_title' => $aItem['title'], 'item_description' => strmaxtextlen($aItem['description'], 200), 'item_comments' => (int) $aItem['comments_count'] > 0 ? _t('_wall_n_comments', $aItem['comments_count']) : _t('_wall_no_comments'), 'item_comments_link' => $aItem['url'] . '#cmta-' . $sPrefix . '-' . $aItem['id'], 'post_id' => $aEvent['id'], 'post_ago' => $aEvent['ago'])));
     return $aResult;
 }