Пример #1
0
 public function get_pic_detail()
 {
     $pic_id = intval($_GET['pic_id']);
     $pic_item = MeiuiPic::find('id = ' . $pic_id);
     if (count($pic_item)) {
         foreach ($pic_item as $value) {
             $user = MeiuiUser::findFirst('id=' . $value->create_user);
             $tags = MeiuiPicLinkTag::find('pic_id=' . $value->id);
             $sys_tag = [];
             $user_tag = [];
             if (count($tags) > 0) {
                 foreach ($tags as $v) {
                     if (in_array($v->pic_id, $this->user_tag_array['del_flag'][$v->tag_id])) {
                         $user_tag[] = $v->tag_name;
                         if ($v->tag_type == 2) {
                             $sys_tag[] = $v->tag_name;
                         }
                     } else {
                         if ($v->tag_type == 2) {
                             $sys_tag[] = $v->tag_name;
                         }
                     }
                 }
             }
             $this->main['data']['items'][] = array('pic_id' => $value->id, 'pic' => $value->pic_url, 'pic_h' => $value->pic_h, 'pic_w' => $value->pic_w, 'app_id' => $value->app_id, 'user_id' => $value->create_user, 'user_name' => $user->username, 'user_pic' => $user->user_pic, 'app_name' => $value->app_name, 'brief' => $value->brief, 'sys_tag' => $sys_tag, 'user_tag' => $user_tag);
         }
         $this->main['alert']['msg'] = $this->lang['request_success'];
     } else {
         $this->main['alert']['msg'] = '不存在图片';
     }
     die(json_encode($this->main));
 }
Пример #2
0
 public function search()
 {
     $data = $this->main;
     $page = 1;
     if (isset($_GET['page'])) {
         $page = intval($_GET['page']);
     }
     $this->set_search_history();
     $keyword = $_GET['keyword'];
     $conditions = " tag_name LIKE :tag_name: group by pic_id";
     $parameters = array("tag_name" => '%' . $keyword . '%');
     $all_pic = MeiuiPicLinkTag::find(array($conditions, "bind" => $parameters));
     $paginator = new Paginator(array("data" => $all_pic, "limit" => 10, "page" => $page));
     $all_pic = $paginator->getPaginate();
     $data['status'] = '200200';
     $data['data']['page'] = $all_pic->current . '/' . $all_pic->total_pages;
     $login_user_id = intval($_GET['user_id']);
     $login_user_collect = MeiuiUserTag::find('user_id = ' . $login_user_id . '  and del_flag = 1 ');
     $login_collect_tag = [];
     if (count($login_user_collect) > 0) {
         foreach ($login_user_collect as $collect) {
             $login_collect_tag[] = $collect->tag_id;
         }
     }
     foreach ($all_pic->items as $pic_value) {
         $pic = MeiuiPic::findFirst('id=' . $pic_value->pic_id);
         if ($pic) {
             $user = MeiuiUser::findFirst('id=' . $pic->create_user);
             $tags = MeiuiPicLinkTag::find('pic_id=' . $pic->id);
             $sys_tag = [];
             $user_tag = [];
             if (count($tags) > 0) {
                 foreach ($tags as $v) {
                     if (in_array($v->pic_id, $this->user_tag_array['del_flag'][$v->tag_id])) {
                         $user_tag[] = $v->tag_name;
                         if ($v->tag_type == 2) {
                             $sys_tag[] = $v->tag_name;
                         }
                     } else {
                         if ($v->tag_type == 2) {
                             $sys_tag[] = $v->tag_name;
                         }
                     }
                 }
             }
             $data['data']['items'][] = array('pic_id' => $pic->id, 'pic' => $pic->pic_url, 'pic_h' => $pic->pic_h, 'pic_w' => $pic->pic_w, 'app_id' => $pic->app_id, 'user_id' => $pic->create_user, 'user_name' => $user->username, 'user_pic' => $user->user_pic, 'app_name' => $pic->app_name, 'brief' => $pic->brief, 'sys_tag' => $sys_tag, 'user_tag' => $user_tag);
         }
     }
     $data['alert']['msg'] = $this->lang['request_success'];
     die(json_encode($data));
 }
Пример #3
0
 public function pic_item($pic_id)
 {
     $pic = MeiuiPic::findFirst('id=' . $pic_id);
     $user = MeiuiUsers::findFirst('id=' . $pic->create_user);
     $tags = MeiuiPicLinkTag::find('pic_id=' . $pic_id);
     $tag = '';
     if (count($tags) > 0) {
         foreach ($tags as $v) {
             $tag .= $v->tag_name . ',';
         }
     }
     $pic_item = array('user_id' => $pic->create_user, 'user_name' => $user->username, 'user_pic' => $user->user_pic, 'pic' => $pic->pic_url, 'pic_h' => $pic->pic_h, 'pic_w' => $pic->pic_w, 'app_id' => $pic->app_id, 'app_name' => $pic->app_name, 'brief' => $pic->brief, 'tag' => $tag);
     return $pic_item;
 }
Пример #4
0
 public function center()
 {
     $data = $this->main;
     $data['status'] = '400200';
     $conditions = " id = :id: ";
     $parameters = array("id" => intval($_GET['user_id']));
     $user = MeiuiUser::findFirst(array($conditions, "bind" => $parameters));
     if ($user) {
         $data['data']['user_pic'] = $user->user_pic;
         $data['data']['user_name'] = $user->nickname;
         $data['data']['user_id'] = $user->id;
     } else {
         $data['alert']['msg'] = $this->lang['lack_user_info'];
         die(json_encode($data));
     }
     $conditions = " user_id = :user_id: and del_flag = 1";
     $parameters = array("user_id" => intval($_GET['user_id']));
     $user_tag = MeiuiUserTag::find(array($conditions, "bind" => $parameters));
     $tag_tree = [];
     $login_collect_tag = [];
     foreach ($user_tag as $tag) {
         $tag_tree[$tag->tag_id][] = $tag;
         $login_collect_tag[] = $tag->tag_id;
     }
     krsort($tag_tree);
     // 遍历用户标签
     foreach ($tag_tree as $tag_key => $tag_value) {
         $tag_arr = array();
         foreach ($tag_value as $one_pic) {
             $pic = MeiuiPic::findFirst('id=' . $one_pic->pic_id);
             $user = MeiuiUser::findFirst('id=' . $pic->create_user);
             $tags = MeiuiPicLinkTag::find('pic_id=' . $pic->id);
             $sys_tag = [];
             $user_tag = [];
             $tag_name = '';
             if (count($tags) > 0) {
                 foreach ($tags as $v) {
                     if ($v->tag_id == $tag_key) {
                         $tag_name = $v->tag_name;
                     }
                     if (in_array($v->pic_id, $this->user_tag_array['del_flag'][$v->tag_id])) {
                         $user_tag[] = $v->tag_name;
                         if ($v->tag_type == 2) {
                             $sys_tag[] = $v->tag_name;
                         }
                     } else {
                         if ($v->tag_type == 2) {
                             $sys_tag[] = $v->tag_name;
                         }
                     }
                 }
             }
             $tag_arr['tag_name'] = $tag_name;
             $tag_arr['items'][] = array('pic_id' => $pic->id, 'pic' => $pic->pic_url, 'pic_h' => $pic->pic_h, 'pic_w' => $pic->pic_w, 'app_id' => $pic->app_id, 'user_id' => $pic->create_user, 'user_name' => $user->username, 'user_pic' => $user->user_pic, 'app_name' => $pic->app_name, 'brief' => $pic->brief, 'sys_tag' => $sys_tag, 'user_tag' => $user_tag);
         }
         $data['data']['tags'][] = $tag_arr;
     }
     $data['alert']['msg'] = $this->lang['request_success'];
     die(json_encode($data));
 }