/** * Finds video clips list of specified type * * @param string $type * @param int $page * @param int $limit * @return array of VIDEO_BOL_Clip */ public function findClipsList($type, $page, $limit) { if ($type == 'toprated') { $first = ($page - 1) * $limit; $topRatedList = BOL_RateService::getInstance()->findMostRatedEntityList('video_rates', $first, $limit); $clipArr = $this->clipDao->findByIdList(array_keys($topRatedList)); $clips = array(); foreach ($clipArr as $key => $clip) { $clipArrItem = (array) $clip; $clips[$key] = $clipArrItem; $clips[$key]['score'] = $topRatedList[$clipArrItem['id']]['avgScore']; $clips[$key]['rates'] = $topRatedList[$clipArrItem['id']]['ratesCount']; } usort($clips, array('VIDEO_BOL_ClipService', 'sortArrayItemByDesc')); } else { $clips = $this->clipDao->getClipsList($type, $page, $limit); } $list = array(); if (is_array($clips)) { foreach ($clips as $key => $clip) { $clip = (array) $clip; $list[$key] = $clip; $list[$key]['thumb'] = $this->getClipThumbUrl($clip['id'], $clip['code'], $clip['thumbUrl']); } } return $list; }