/** * Class constructor * * @param string $listType * @param int $count * @param string $tag * @param int $userId */ public function __construct(array $params) { parent::__construct(); $listType = isset($params['type']) ? $params['type'] : ''; $count = isset($params['count']) ? $params['count'] : 5; // $count = 5; $tag = isset($params['tag']) ? $params['tag'] : ''; $userId = isset($params['userId']) ? $params['userId'] : null; $this->clipService = VWLS_BOL_ClipService::getInstance(); $page = isset($_GET['page']) && (int) $_GET['page'] ? (int) $_GET['page'] : 1; // $clipsPerPage = $this->clipService->getClipPerPageConfig(); $clipsPerPage = 10; if ($userId) { $clips = $this->clipService->findUserClipsList($userId, $page, $clipsPerPage); $records = $this->clipService->findUserClipsCount($userId); } else { if (strlen($tag)) { $clips = $this->clipService->findTaggedClipsList($tag, $page, $clipsPerPage); $records = $this->clipService->findTaggedClipsCount($tag); } else { $clips = $this->clipService->findClipsList($listType, $page, $clipsPerPage); $records = $this->clipService->findClipsCount($listType); } } $this->assign('listType', $listType); $userIdx = OW::getUser()->getId(); if ($clips) { $this->assign('no_content', null); $this->assign('clips', $clips); // user is owner ? $userIsOwner = array(); $userIds = array(); foreach ($clips as $clip) { if ($clip['userId'] == $userIdx) { $isOwner = 1; } else { $isOwner = 0; } array_push($userIsOwner, $isOwner); if (!in_array($clip['userId'], $userIds)) { array_push($userIds, $clip['userId']); } } $this->assign('userIsOwner', $userIsOwner); $names = BOL_UserService::getInstance()->getDisplayNamesForList($userIds); $this->assign('displayNames', $names); $usernames = BOL_UserService::getInstance()->getUserNamesForList($userIds); $this->assign('usernames', $usernames); // Paging $pages = (int) ceil($records / $clipsPerPage); $paging = new BASE_CMP_Paging($page, $pages, 10); $this->assign('paging', $paging->render()); $this->assign('count', $count); } else { $this->assign('no_content', OW::getLanguage()->text('vwls', 'no_vwls_found')); } }