예제 #1
0
 public function actionInfo()
 {
     header('Access-Control-Allow-Origin:*');
     $id = intval($this->get("id", 0));
     if (!$id) {
         return $this->renderJSON([], '参数错误~~', -1);
     }
     $info = EmoticonLibrary::find()->where(['id' => $id, 'status' => 1])->one();
     if (!$info) {
         return $this->renderJSON([], '参数错误~~', -1);
     }
     $w = intval($this->get("w", 0));
     $w = ceil($w / 50) * 50;
     $w = 200;
     $pre_list = EmoticonLibrary::find()->where(['status' => 1])->where(['<', 'id', $id])->orderBy(['id' => SORT_DESC])->limit(5)->all();
     $next_list = EmoticonLibrary::find()->where(['status' => 1])->where(['>', 'id', $id])->orderBy(['id' => SORT_ASC])->limit(5)->all();
     $thunb_images = [];
     $current_image = ['id' => $info['id'], 'url' => GlobalUrlService::buildPic2Static($info['url'], ['w' => $w]), 'file_name' => $info['url'], 'small_url' => GlobalUrlService::buildPic2Static($info['url'], ['w' => 100, 'h' => 100]), 'share_url' => GlobalUrlService::buildPic2Static($info['url'], ['w' => 200])];
     if ($pre_list) {
         foreach ($pre_list as $_item) {
             $thunb_images[$_item['id']] = ['id' => $_item['id'], 'url' => GlobalUrlService::buildPic2Static($_item['url'], ['w' => $w]), 'file_name' => $_item['url'], 'small_url' => GlobalUrlService::buildPic2Static($_item['url'], ['w' => 100, 'h' => 100]), 'share_url' => GlobalUrlService::buildPic2Static($_item['url'], ['w' => 200])];
         }
     }
     $thunb_images[$info['id']] = $current_image;
     if ($next_list) {
         foreach ($next_list as $_item) {
             $thunb_images[$_item['id']] = ['id' => $_item['id'], 'url' => GlobalUrlService::buildPic2Static($_item['url'], ['w' => $w]), 'file_name' => $_item['url'], 'small_url' => GlobalUrlService::buildPic2Static($_item['url'], ['w' => 100, 'h' => 100]), 'share_url' => GlobalUrlService::buildPic2Static($_item['url'], ['w' => 200])];
         }
     }
     return $this->renderJSON($thunb_images);
 }
예제 #2
0
 public static function save2Library($params)
 {
     if (!$params || !isset($params['url'])) {
         return self::_err('url must be ~~');
     }
     $model_library = new EmoticonLibrary();
     $model_library->title = isset($params['title']) ? $params['title'] : '';
     $model_library->url = $params['url'];
     $model_library->cdn_source = isset($params['cdn_source']) ? $params['cdn_source'] : 0;
     $model_library->self_cdn = isset($params['self_cdn']) ? $params['self_cdn'] : 0;
     $model_library->cdn_rule = isset($params['cdn_rule']) ? $params['cdn_rule'] : '';
     $model_library->group_name = isset($params['group_name']) ? $params['cdn_rule'] : '';
     $model_library->status = 0;
     $model_library->updated_time = date("Y-m-d H:i:s");
     $model_library->created_time = $model_library->updated_time;
     return $model_library->save(0);
 }