Exemplo n.º 1
0
 function actionShowTopItems()
 {
     header('Content-type: application/json');
     if (!IjoyPlusServiceUtils::validateAPPKey()) {
         IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID);
         return;
     }
     $page_size = Yii::app()->request->getParam("page_size");
     $page_num = Yii::app()->request->getParam("page_num");
     if (!(isset($page_size) && is_numeric($page_size))) {
         $page_size = 10;
         $page_num = 1;
     } else {
         if (!(isset($page_num) && is_numeric($page_num))) {
             $page_num = 1;
         }
     }
     $top_id = Yii::app()->request->getParam("top_id");
     if (!isset($top_id) || is_null($top_id)) {
         IjoyPlusServiceUtils::exportServiceError(Constants::PARAM_IS_INVALID);
         return;
     }
     try {
         $lists = SearchManager::listShowItems($top_id, $page_size, $page_size * ($page_num - 1));
         if (isset($lists) && is_array($lists)) {
             IjoyPlusServiceUtils::exportEntity(array('items' => $lists));
         } else {
             IjoyPlusServiceUtils::exportEntity(array('items' => array()));
         }
     } catch (Exception $e) {
         Yii::log(CJSON::encode($e), "error");
         IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR);
     }
 }
Exemplo n.º 2
0
 public static function show_tops($limit, $offset)
 {
     $device = IjoyPlusServiceUtils::getDevice();
     $where = '';
     if ($device === false) {
         $key = SearchManager::CACHE_SHOW_TOPS_LIMIT_OFFSET . '_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_SHOW_TOPS_LIMIT_OFFSET . '_LIMIT_' . $limit . '_OFFSET_' . $offset . '_DEVICE_' . $device;
     }
     $lists = CacheManager::getValueFromCache($key);
     if ($lists) {
         return $lists;
     }
     $lists = Yii::app()->db->createCommand()->select('t_id as id, t_name as name, t_type as prod_type, 	t_pic as pic_url,t_des as content')->from('mac_vod_topic ')->where('t_flag=:t_flag and t_id>4 and t_bdtype=2 and t_type=' . Constants::PROGRAM_TYPE_SHOW . $where, array(':t_flag' => 1))->order('t_sort desc,create_date desc ')->limit($limit)->offset($offset)->queryAll();
     $temp = array();
     if (isset($lists) && is_array($lists)) {
         foreach ($lists as $list) {
             $items = SearchManager::listShowItems($list['id'], SearchManager::BD_TOPS_LIST_ITEM_NUM, 0);
             if (isset($items) && is_array($items) && count($items) > 0) {
                 $list['items'] = $items;
                 if (!(isset($list['pic_url']) && is_null($list['pic_url']))) {
                     $list['pic_url'] = $items[0]['prod_pic_url'];
                 }
                 $list['big_pic_url'] = $items[0]['big_prod_pic_url'];
             }
             $temp[] = $list;
         }
         if (count($temp) > 0) {
             $prodExpired = CacheManager::getExpireByCache(CacheManager::CACHE_PARAM_EXPIRED_POPULAR_PROGRAM);
             CacheManager::setValueToCache($key, $temp, $prodExpired);
         }
     }
     return $temp;
 }