Esempio n. 1
0
 public function actionIndex()
 {
     $p = intval($this->get("p", 1));
     if (!$p) {
         $p = 1;
     }
     $data = [];
     $pagesize = 20;
     $query = RichMedia::find()->where(['status' => [0, 1]]);
     $total_count = $query->count();
     $offset = ($p - 1) * $pagesize;
     $rich_list = $query->orderBy("id desc")->offset($offset)->limit($pagesize)->all();
     $page_info = DataHelper::ipagination(["total_count" => $total_count, "page_size" => $pagesize, "page" => $p, "display" => 10]);
     if ($rich_list) {
         $idx = 1;
         $domains = Yii::$app->params['domains'];
         foreach ($rich_list as $_rich_info) {
             $tmp_small_pic_url = GlobalUrlService::buildPic1Static($_rich_info['src_url'], ['h' => 100]);
             $tmp_big_pic_url = GlobalUrlService::buildPic1Static($_rich_info['src_url'], ['w' => 600]);
             $data[] = ['idx' => $idx, 'id' => $_rich_info['id'], 'small_src_url' => $tmp_small_pic_url, 'big_src_url' => $tmp_big_pic_url, 'src_url' => $tmp_small_pic_url, 'thumb_url' => $_rich_info['thumb_url'] ? $_rich_info['thumb_url'] : $domains['static'] . "/wx/video_cover.jpg", 'type' => $_rich_info['type'], 'address' => $_rich_info['address'], 'status' => $_rich_info['status'], 'status_info' => $this->status_desc[$_rich_info['status']], 'created' => $_rich_info['created_time']];
             $idx++;
         }
     }
     return $this->render("index", ["data" => $data, "page_info" => $page_info]);
 }
Esempio n. 2
0
 private function search($params = [])
 {
     $p = isset($params['p']) ? $params['p'] : 1;
     $offset = ($p - 1) * $this->page_size;
     $query = RichMedia::find()->where(['status' => 1, 'type' => 'image']);
     $rich_media_list = $query->orderBy("id desc")->offset($offset)->limit($this->page_size)->all();
     $data = [];
     if ($rich_media_list) {
         foreach ($rich_media_list as $_rich_info) {
             $data[] = ['id' => $_rich_info['id'], 'type' => $_rich_info['type'], 'src_url' => GlobalUrlService::buildPic1Static($_rich_info['src_url']), 'address' => $_rich_info['address'], 'switch' => \Yii::$app->params['switch']['cdn']['pic1']];
         }
     }
     return $data;
 }
Esempio n. 3
0
 public function actionMedia()
 {
     $p = intval($this->get("p", 1));
     $offset = ($p - 1) * $this->page_size;
     $query = RichMedia::find()->where(['status' => 1, 'type' => 'image']);
     $rich_media_list = $query->orderBy("id desc")->offset($offset)->limit($this->page_size)->all();
     $data = [];
     if ($rich_media_list) {
         foreach ($rich_media_list as $_rich_info) {
             $data[] = ['image_url' => GlobalUrlService::buildPic1Static($_rich_info['src_url']), 'title' => $_rich_info['address'] ? $_rich_info['address'] : ':('];
         }
     }
     return $this->renderJSON(['list' => $data]);
 }
Esempio n. 4
0
 public function actionAddress()
 {
     $rich_media_list = RichMedia::find()->orderBy("id asc")->all();
     if (!$rich_media_list) {
         return;
     }
     foreach ($rich_media_list as $_item) {
         if (!$_item['gps']) {
             continue;
         }
         $gps_info = @json_decode(strtolower($_item['gps']), true);
         if (!$gps_info) {
             continue;
         }
         $lat = $gps_info['latitude'];
         $lng = $gps_info['longitude'];
         $address = GeoService::baidugeocoding($lat, $lng);
         if (!$address) {
             continue;
         }
         $_item->address = $address;
         $_item->update(0);
     }
 }