public static function listTVNetItems($top_id, $limit, $offset)
 {
     $device = IjoyPlusServiceUtils::getDevice();
     $where = '';
     if ($device === false) {
         $key = SearchManager::CACHE_LIST_ITEMS_BY_TYPE_LIMIT_OFFSET . '_TOPTVNet_' . $top_id . '_LIMIT_' . $limit . '_OFFSET_' . $offset;
     } else {
         $where = ' AND (can_search_device like \'%' . $device . '%\' or can_search_device is null or can_search_device =\'\' ) ';
         $key = SearchManager::CACHE_LIST_ITEMS_BY_TYPE_LIMIT_OFFSET . '_TOPTVNet_' . $top_id . '_LIMIT_' . $limit . '_OFFSET_' . $offset . '_DEVICE_' . $device;
     }
     if (IjoyPlusServiceUtils::isExcludeCopyMovie()) {
         $where = $where . " and vod.d_area not like '%美国%' ";
     }
     $items = CacheManager::getValueFromCache($key);
     if ($items) {
         return $items;
     }
     $items = Yii::app()->db->createCommand()->select('items.id as id, vod.d_id as prod_id,vod.d_name as prod_name,vod.d_sid as sid, vod.d_cid as cid, vod.d_playurl as vid,vod.d_playfrom as sources, vod.d_downurl as play_urls,vod.d_level as definition,vod.d_content as prod_summary, vod.d_type as prod_type,  substring_index( vod.d_pic_ipad, \'{Array}\', 1 )  as prod_pic_url,vod.d_starring as stars,vod.d_directed as directors ,vod.favority_user_count as favority_num ,vod.good_number as support_num ,vod.d_year as publish_date,vod.d_score as score,vod.d_area as area, vod.d_remarks as max_episode, vod.d_state as cur_episode , vod.duraning as duration ')->from('mac_vod_topic_items as items')->join("mac_vod as vod", "items.vod_id=vod.d_id")->where('items.flag=:t_flag and items.topic_id=:topic_id and vod.d_hide=0 ' . $where, array(':t_flag' => 1, ':topic_id' => $top_id))->order('items.disp_order desc, vod.d_level desc ,vod.d_good desc,vod.d_time DESC ')->limit($limit)->offset($offset)->queryAll();
     $tempList = array();
     if (isset($items) && !is_null($items) && is_array($items)) {
         foreach ($items as $item) {
             //	    	  $item['definition']='4';
             if ($item['prod_type'] === '1') {
                 $item['play_urls'] = ProgramUtil::parseMovidePlayurl($item['play_urls']);
                 if ($item['sources'] === 'so_hu_cp') {
                     $vid_arry = explode("{Array}", $item['vid']);
                     $vids = $vid_arry[0];
                     $vid = explode("\$", $vids);
                     if (count($vid) == 2) {
                         $item['vid'] = $vid[1];
                     } else {
                         if (count($vid) == 1) {
                             $item['vid'] = $vid[0];
                         }
                     }
                 }
             } else {
                 $item['vid'] = '';
                 $item['play_urls'] = array();
             }
             $tempList[] = $item;
         }
         $prodExpired = CacheManager::getExpireByCache(CacheManager::CACHE_PARAM_EXPIRED_POPULAR_PROGRAM);
         CacheManager::setValueToCache($key, $tempList, $prodExpired);
     }
     return $tempList;
 }
 public function actionViewRecommend()
 {
     header('Content-type: application/json');
     if (!IjoyPlusServiceUtils::validateAPPKey()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID);
         return;
     }
     if (IjoyPlusServiceUtils::validateUserID()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::USER_ID_INVALID);
         return;
     }
     $prod_id = Yii::app()->request->getParam("prod_id");
     if (!isset($prod_id) || is_null($prod_id)) {
         IjoyPlusServiceUtils::exportServiceError(Constants::PARAM_IS_INVALID);
         return;
     }
     $program = Program::model()->findByPk($prod_id);
     if ($program === null) {
         IjoyPlusServiceUtils::exportServiceError(Constants::OBJECT_NOT_FOUND);
         return;
     }
     $userid = Yii::app()->request->getParam("user_id");
     if (!isset($userid) || is_null($userid)) {
         $userid = Yii::app()->user->id;
     }
     $prod = ProgramUtil::exportProgramEntity($program);
     $reCom = Dynamic::model()->getDynamicByProd($userid, $prod_id, Constants::DYNAMIC_TYPE_RECOMMEND);
     if (isset($reCom) && !is_null($reCom)) {
         $prod['reason'] = $reCom->content_desc;
     }
     $comments = Comment::model()->getCommentsByProgram($prod_id, 10, 0);
     if (isset($comments) && is_array($comments)) {
         $commentTemps = array();
         foreach ($comments as $comment) {
             $commentTemps[] = IjoyPlusServiceUtils::transferComments($comment);
         }
         $prod['comments'] = $commentTemps;
     } else {
         $prod['comments'] = array();
     }
     $dynamic = Dynamic::model()->friendDynamicForProgram(Yii::app()->user->id, $prod_id, 10, 0);
     if (isset($dynamic) && is_array($dynamic)) {
         $prod['dynamics'] = $this->transferDynamics($dynamic);
     } else {
         $prod['dynamics'] = array();
     }
     $topics = Topic::model()->getRelatedTops($prod_id);
     if (isset($topics) && is_array($topics)) {
         $prod['topics'] = $topics;
     } else {
         $prod['topics'] = array();
     }
     IjoyPlusServiceUtils::exportEntity($prod);
 }
Example #3
0
 public static function parseMovidePlayurl($tmpdownurl)
 {
     $playfroms = "";
     $video_urls = array();
     if (!(is_null($tmpdownurl) || $tmpdownurl == '')) {
         $webArrays = explode("\$\$\$", $tmpdownurl);
         for ($k = 0; $k < count($webArrays); $k++) {
             //			var_dump($webArrays[$k]);
             $weburlarr2 = explode("\$\$", $webArrays[$k]);
             //			var_dump($weburlarr2);
             $tmpplayfrom = $weburlarr2[0];
             if (isset($tmpplayfrom) && !is_null($tmpplayfrom) && strlen(trim($tmpplayfrom)) > 0 && strpos($playfroms, $tmpplayfrom) === false) {
                 if (count($weburlarr2) < 2) {
                     continue;
                 }
                 $playfroms = $playfroms . ',' . $tmpplayfrom;
                 $platformWebUrl = $weburlarr2[1];
                 if (is_null($platformWebUrl) || $platformWebUrl == '') {
                     $platformWebUrl = "";
                 }
                 $tempUrl = explode("\$", $platformWebUrl);
                 if (count($tempUrl) == 2) {
                     $platformWebUrl = $tempUrl[1];
                 }
                 $video_urls[] = array('source' => $tmpplayfrom, 'urls' => ProgramUtil::parseDownVideoUrls($platformWebUrl, $tmpplayfrom));
             }
         }
     }
     return $video_urls;
 }