Esempio n. 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));
 }
Esempio n. 2
0
 private function getPic($id)
 {
     $conditions = " id = :id: ";
     $parameters = array("id" => "{$id}");
     $changeClassification = MeiuiPic::findFirst(array($conditions, "bind" => $parameters));
     return $changeClassification;
 }
Esempio n. 3
0
 public function insert_data($app, $file, $file_info)
 {
     //先判断APP 是否存在,不存在新建APP
     $conditions = " app_name = :app_name: ";
     $parameters = array("app_name" => $app);
     $db_app = MeiuiApp::findFirst(array($conditions, "bind" => $parameters));
     if (!$db_app) {
         $db_app = new MeiuiApp();
         $db_app->app_name = $app;
         $db_app->create_user = $_SESSION['auth']['id'];
         $db_app->create_time = time();
         $db_app->save();
     }
     //再判断PIC 是否存在,不存在新建PIC
     $tags = explode('.', $file);
     $pic_url = 'http://img.meiui.me' . $_POST['img_url'];
     $conditions = " pic_url = :pic_url: ";
     $parameters = array("pic_url" => $pic_url);
     $db_pic = MeiuiPic::findFirst(array($conditions, "bind" => $parameters));
     if (!$db_pic) {
         $db_pic = new MeiuiPic();
         $db_pic->app_id = $db_app->id;
         $db_pic->app_name = $db_app->app_name;
         $db_pic->pic_url = $pic_url;
         $db_pic->pic_w = $file_info[0];
         $db_pic->pic_h = $file_info[1];
         $db_pic->brief = 'brief default tag  ' . $app . ',' . $tags[0];
         $db_pic->create_user = $_SESSION['auth']['id'];
         $db_pic->create_time = time();
         $db_pic->save();
     }
     // 判断标签 不存在则插入
     $all_tag = explode(',', $tags[0]);
     $all_tag[] = $app;
     foreach ($all_tag as $one_tag) {
         $this->insert_tag_link_pic($one_tag, $db_pic->id);
     }
     $alert_message = "添加成功 <br/>APP:" . $app . '<br/>标签:' . $tags[0] . '<br/>url:' . $pic_url;
     $this->flash->notice($alert_message);
 }
Esempio n. 4
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));
 }
Esempio n. 5
0
 public function insert_data($app, $file, $file_info)
 {
     //先判断APP 是否存在,不存在新建APP
     $conditions = " app_name = :app_name: ";
     $parameters = array("app_name" => $app);
     $db_app = MeiuiApp::findFirst(array($conditions, "bind" => $parameters));
     if (!$db_app) {
         $db_app = new MeiuiApp();
         $db_app->app_name = $app;
         $db_app->create_user = $_SESSION['auth']['id'];
         $db_app->create_time = time();
         $db_app->save();
     }
     //再判断PIC 是否存在,不存在新建PIC
     $tags = explode('.', $file);
     $pic_url = '52.68.155.92/load/init_data/APP/' . $app . '/' . $file;
     $conditions = " pic_url = :pic_url: ";
     $parameters = array("pic_url" => $pic_url);
     $db_pic = MeiuiPic::findFirst(array($conditions, "bind" => $parameters));
     if (!$db_pic) {
         $db_pic = new MeiuiPic();
         $db_pic->app_id = $db_app->id;
         $db_pic->app_name = $db_app->app_name;
         $db_pic->pic_url = $pic_url;
         $db_pic->pic_w = $file_info[0];
         $db_pic->pic_h = $file_info[1];
         $db_pic->brief = 'brief default tag  ' . $app . ',' . $tags[0];
         $db_pic->create_user = $_SESSION['auth']['id'];
         $db_pic->create_time = time();
         $db_pic->save();
     }
     // 判断标签 不存在则插入
     $all_tag = explode(',', $tags[0]);
     $all_tag[] = $app;
     foreach ($all_tag as $one_tag) {
         $this->insert_tag_link_pic($one_tag, $db_pic->id);
     }
 }
Esempio n. 6
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;
 }
Esempio n. 7
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));
 }