Exemple #1
0
 public function groupContentsContentType(array $items, array $viewingUser = null)
 {
     $this->standardizeViewingUserReference($viewingUser);
     if (empty($items)) {
         return $items;
     }
     $fetchQueue = array();
     foreach ($items as &$_item) {
         if (in_array($_item['content_type'], array('photo', 'video'))) {
             $_item['content_type'] = 'content';
         }
         $fetchQueue[$_item['content_type']][$_item['content_id']] = $_item['content_id'];
     }
     foreach ($fetchQueue as $handlerClass => $contentIds) {
         $fetchData[$handlerClass] = sonnb_XenGallery_ContentHandler_Abstract::create($handlerClass)->getContentsByIds($contentIds, $viewingUser);
     }
     foreach ($items as $id => $item) {
         if (!isset($fetchData[$item['content_type']][$item['content_id']])) {
             unset($items[$id]);
             continue;
         }
         if (!sonnb_XenGallery_ContentHandler_Abstract::create($item['content_type'])->canViewContent($fetchData[$item['content_type']][$item['content_id']], $viewingUser)) {
             unset($items[$id]);
             continue;
         }
         $items[$id]['content'] = $fetchData[$item['content_type']][$item['content_id']];
     }
     return $items;
 }
Exemple #2
0
 public static function renderContentByContentGrouped($itemsGrouped, XenForo_View $view)
 {
     $itemRendered = array();
     if ($itemsGrouped) {
         foreach ($itemsGrouped as $item) {
             $itemRendered[] = sonnb_XenGallery_ContentHandler_Abstract::create($item['content_type'])->renderHtml($item['content'], $view);
         }
     }
     return $itemRendered;
 }
Exemple #3
0
 public function actionTags()
 {
     $user = $this->_getAuthorOrError();
     $tagModel = $this->_getTagModel();
     $xenOptions = XenForo_Application::getOptions();
     $page = max(1, $this->_input->filterSingle('page', XenForo_Input::UINT));
     $photosPerPage = $xenOptions->sonnbXG_photoPerPage;
     $this->canonicalizeRequestUrl(XenForo_Link::buildPublicLink('gallery/authors/tags', $user + array('page' => $page)));
     list($defaultOrder, $defaultOrderDirection) = $this->_getDefaultTagSort();
     $order = $this->_input->filterSingle('order', XenForo_Input::STRING, array('default' => $defaultOrder));
     $orderDirection = $this->_input->filterSingle('direction', XenForo_Input::STRING, array('default' => $defaultOrderDirection));
     $conditions = $this->_getDefaultTagConditions($user);
     $fetchElements = $this->_getTagFetchElements($conditions);
     $tagFetchConditions = $fetchElements['conditions'];
     $tagFetchOptions = $fetchElements['options'] + array('perPage' => $photosPerPage, 'page' => $page, 'order' => $order, 'orderDirection' => $orderDirection);
     $totalTags = $tagModel->countTags($tagFetchConditions, $tagFetchOptions);
     $this->canonicalizePageNumber($page, $photosPerPage, $totalTags, 'gallery/authors/tags', $user);
     $tags = $tagModel->getTags($tagFetchConditions, $tagFetchOptions);
     $photos = $pageNavParams = array();
     if (!empty($tags)) {
         $photoIds = array();
         foreach ($tags as $_tag) {
             $photoIds[] = $_tag['content_id'];
         }
         $handler = sonnb_XenGallery_ContentHandler_Abstract::create(sonnb_XenGallery_Model_Photo::$contentType);
         $photos = $handler->getContentsByIds($photoIds);
         foreach ($photos as $_photoId => $_photo) {
             if (!$handler->canViewContent($_photo)) {
                 unset($photos[$_photoId]);
             }
         }
         $pageNavParams = array();
         $pageNavParams['order'] = $order != $defaultOrder ? $order : false;
         $pageNavParams['direction'] = $orderDirection != $defaultOrderDirection ? $orderDirection : false;
     }
     $viewParams = array('user' => $user, 'photos' => $photos, 'tags' => $tags, 'order' => $order, 'orderDirection' => $orderDirection, 'pageNavParams' => $pageNavParams, 'page' => $page, 'tagsPerPage' => $photosPerPage, 'totalTags' => $totalTags, 'canManageCover' => $this->_getGalleryModel()->canManageCover($user));
     return $this->responseView('sonnb_XenGallery_ViewPublic_Author_Tag', 'sonnb_xengallery_author_tags', $viewParams);
 }
Exemple #4
0
 public function canViewCommentAndContainer(array $comment, &$errorPhraseKey = '', array $viewingUser = null, &$content = null)
 {
     $this->standardizeViewingUserReference($viewingUser);
     if ($this->isDeleted($comment) && !$this->canViewDeletedComment($comment, $viewingUser)) {
         return false;
     }
     if ($this->isModerated($comment)) {
         if ($viewingUser['user_id'] !== $comment['user_id'] && !$this->canViewModeratedComment($viewingUser)) {
             return false;
         }
     }
     if (empty($comment['content'])) {
         $handler = sonnb_XenGallery_ContentHandler_Abstract::create($comment['content_type']);
         $content = $handler->getContentById($comment['content_id'], $viewingUser);
         return $handler->canViewContent($content, $viewingUser);
     }
     return true;
 }