コード例 #1
0
ファイル: vwvc_online_list.php プロジェクト: vazahat/dudex
 /**
  * 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 = VWVC_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);
     if ($clips) {
         $this->assign('no_content', null);
         $this->assign('clips', $clips);
         $userIds = array();
         foreach ($clips as $clip) {
             if (!in_array($clip['userId'], $userIds)) {
                 array_push($userIds, $clip['userId']);
             }
         }
         $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('vwvc', 'no_vwvc_found'));
     }
 }