/** * 获取频道分类数据 * @return array 所有频道分类数据 */ public function getChannels($uid, $count = 6, $page = 1, $order = 'sort asc', $sql = '') { $start = ($page - 1) * $count; $end = $count; $data = D('channel_category')->where($sql)->order($order)->limit("{$start}, {$end}")->findAll(); foreach ($data as $k => $v) { if (!empty($v['ext'])) { $ext = unserialize($v['ext']); $v = array_merge($v, $ext); } $data[$k] = $v; } // 组装附件信息 $attachIds = getSubByKey($data, 'attach'); $attachIds = array_filter($attachIds); $attachIds = array_unique($attachIds); $attachInfos = model('Attach')->getAttachByIds($attachIds); $attachData = array(); foreach ($attachInfos as $attach) { $attachData[$attach['attach_id']] = $attach; } foreach ($data as &$value) { if (!empty($value['attach']) && !empty($attachData[$value['attach']])) { $value['icon_url'] = getImageUrl($attachData[$value['attach']]['save_path'] . $attachData[$value['attach']]['save_name']); } else { $value['icon_url'] = null; } unset($value['ext'], $value['attach'], $value['user_bind'], $value['topic_bind']); if ($uid) { $value['followStatus'] = intval(D('ChannelFollow', 'channel')->getFollowStatus($uid, $value['channel_category_id'])); } } return $data; }
/** * 根据群组Logo的保存路径获取Logo的URL * * @param string $save_path 群组Logo的保存路径 * @return string 群组Logo的URL. 给定路径不存在时, 返回默认的群组Logo的URL地址. */ function logo_path_to_url($save_path, $width = 100, $height = 100) { $path = getImageUrl($save_path, $width, $height, true); if ($save_path != 'default.gif') { return $path; } else { return SITE_URL . '/apps/group/Tpl/default/Public/images/group_pic.gif'; } }
function getCover($coverId, $width = 100, $height = 100) { if ($coverId > 0) { $cover = model('Attach')->where("attach_id={$coverId}")->find(); } if ($cover) { $cover = getImageUrl($cover['save_path'] . $cover['save_name'], $width, $height, true); } else { $cover = SITE_URL . '/apps/event/_static/images/hdpic1.gif'; } return $cover; }
/** * 微吧管理首页-修改微吧信息 * @return void */ public function index() { $weiba_id = intval($_GET['weiba_id']); $this->assign('weiba_id', $weiba_id); $weiba_detail = D('weiba')->where('weiba_id=' . $weiba_id)->find(); if ($weiba_detail['logo']) { $logo = D('attach')->where('attach_id=' . $weiba_detail['logo'])->find(); $weiba_detail['logo_url'] = getImageUrl($logo['save_path'] . $logo['save_name']); } $this->assign('weiba_detail', $weiba_detail); $this->display(); }
function createMapping($field) { $arr['title'] = $field['vendor'] . ' ' . $field['name']; $arr['body_html'] = $field['description']; $arr['vendor'] = $field['vendor']; $arr['product_type'] = $field['type']; $arr['tags'] = getTags($field['tags']); $arr['images'] = array(getImageUrl(IMAGE_BASE_URL, $field['image'])); $arr['metafields_global_title_tag'] = 'Paramount BP ' . $arr['title']; $arr['metafields_global_description_tag'] = $field['meta_description']; $arr['variants'] = array(getbasicVariants($field)); return $arr; }
/** * 返回用户勋章 * @param unknown_type $uid */ public function getMedalByUid($uid) { $list = D()->query('select b.* from ' . C('DB_PREFIX') . 'medal_user a inner join ' . C('DB_PREFIX') . 'medal b on a.medal_id=b.id where a.uid=' . $uid . ' order by a.ctime desc'); if (is_array($list)) { foreach ($list as &$v) { $src = explode('|', $v['src']); $v['src'] = getImageUrl($src[1]); $smallsrc = explode('|', $v['small_src']); $v['small_src'] = getImageUrl($smallsrc[1]); } } return $list; }
public function index() { //echo $_GET['domain'];exit; if ($_GET['domain']) { $map['domain'] = t($_GET['domain']); //echo $domain;exit; $data['search_key'] = model('FeedTopic')->where($map)->getField('topic_name'); } else { $data['search_key'] = $this->__getSearchKey(); } // 专题信息 if (false == ($data['topics'] = model('FeedTopic')->getTopic($data['search_key'], false))) { if (!$data['topics']) { $this->error('此话题不存在'); } $data['topics']['name'] = t($data['search_key']); } if ($data['topics']['lock'] == 1) { $this->error('该话题已被屏蔽'); } if ($data['topics']['pic']) { $pic = D('attach')->where('attach_id=' . $data['topics']['pic'])->find(); //$data['topics']['pic'] = UPLOAD_URL.'/'.$pic['save_path'].$pic['save_name']; $pic_url = $pic['save_path'] . $pic['save_name']; $data['topics']['pic'] = getImageUrl($pic_url); } $data['topic'] = $data['search_key'] ? $data['search_key'] : html_entity_decode($data['topics']['name'], ENT_QUOTES, 'UTF-8'); $data['topic_id'] = $data['topics']['topic_id'] ? $data['topics']['topic_id'] : model('FeedTopic')->getTopicId($data['search_key']); $initHtml = '#' . $data['search_key'] . '#'; $this->assign('initHtml', $initHtml); $this->assign($data); //seo $seo = model('Xdata')->get("admin_Config:seo_feed_topic"); $replace['topicName'] = $data['topic']; $replace['topicNote'] = $data['topics']['note']; $replace['topicDes'] = $data['topics']['des']; if ($lastTopic = D('feed_data')->where('feed_id=' . D('feed_topic_link')->where('topic_id=' . $data['topic_id'])->order('feed_topic_id desc')->limit(1)->getField('feed_id'))->getField('feed_content')) { $replace['lastTopic'] = $lastTopic; } $replaces = array_keys($replace); foreach ($replaces as &$v) { $v = "{" . $v . "}"; } $seo['title'] = str_replace($replaces, $replace, $seo['title']); $seo['keywords'] = str_replace($replaces, $replace, $seo['keywords']); $seo['des'] = str_replace($replaces, $replace, $seo['des']); !empty($seo['title']) && $this->setTitle($seo['title']); !empty($seo['keywords']) && $this->setKeywords($seo['keywords']); !empty($seo['des']) && $this->setDescription($seo['des']); $this->display(); }
/** * 格式化出需要的数据 * * @param array $medals 数据库原始勋章数据 * @param array [$data] 额外携带的数据 * @return array * @author Seven Du <*****@*****.**> **/ private function formatMedal(array $medals, array $data = array()) { foreach ($medals as $value) { $medal = array(); $medal['id'] = $value['id']; $medal['name'] = $value['name']; $medal['desc'] = $value['desc']; $medal['icon'] = getImageUrl(explode('|', $value['src'])[1]); $medal['show'] = getImageUrl(explode('|', $value['share_card'])[1]); array_push($data, $medal); } unset($medals, $value, $medal); return $data; }
/** * 页面列表 */ public function newslist() { $_REQUEST['tabHash'] = 'newslist'; //按钮 //$this->pageButton[] = array('uid','title'=>'搜索', 'onclick'=>"admin.fold('search_form')"); $this->pageButton[] = array('uid', 'title' => '删除', 'onclick' => "admin.deleteInfo();"); $this->pageButton[] = array('uid', 'title' => '添加资讯', 'onclick' => "location.href='" . U('news/admin/setinfo', array('tabHash' => 'newslist')) . "';"); //处理分类HASH $cs = model('CategoryTree')->setTable('news_category')->getCategoryList(); $categorys = array(); foreach ($cs as $ct) { $categorys[$ct['news_category_id']] = $ct; } //构造搜索条件 //列表key值 DOACTION表示操作 $this->pageKeyList = array('image', 'news_title', 'news_content', 'state', 'is_top', 'hits', 'date', 'DOACTION'); $listData = M('News')->order('news_id desc')->findPage(15); foreach ($listData['data'] as $key => $val) { $listData['data'][$key]['id'] = $val['news_id']; $thumb = APPS_URL . '/' . APP_NAME . '/_static/nopic.jpg'; if ($val['image']) { $attach = model('Attach')->getAttachById($val['image']); if ($attach) { $thumb = getImageUrl($attach['save_path'] . $attach['save_name'], 100, 100, true); } } //获取分类 $type_str = ''; if ($val['type_id']) { if (isset($categorys[$val['type_id']])) { $type_str .= $categorys[$val['type_id']]['title']; if (isset($categorys[$categorys[$val['type_id']]['pid']])) { $type_str = $categorys[$categorys[$val['type_id']]['pid']]['title'] . '--' . $type_str; } } } $listData['data'][$key]['image'] = '<img src="' . $thumb . '">'; $listData['data'][$key]['news_title'] = msubstr($val['news_title'], 0, 20) . "<BR><BR><font style='color:#7d7d7d;'>分类: " . $type_str . "</font>"; $listData['data'][$key]['news_content'] = msubstr(strip_tags($val['news_content']), 0, 20); $listData['data'][$key]['state'] = D('News')->getState($val['state']); $listData['data'][$key]['date'] = '创建:' . date('m/d G:i', $val['created']); if ($val['updated']) { $listData['data'][$key]['date'] .= '<br>更新:' . date('m/d G:i', $val['updated']); } $listData['data'][$key]['is_top'] = $val['is_top'] ? '<font color="red">置顶</font>' : '否'; $listData['data'][$key]['DOACTION'] = '<a href="' . U('news/admin/setinfo', array('news_id' => $val['news_id'], 'tabHash' => 'setinfo')) . '">编辑</a>'; } $this->displayList($listData); }
private function convertImgUrl($list) { foreach ($list as &$vo) { $vo['img_url'] = getImageUrl($vo['img']); unset($vo['img']); unset($vo['id']); unset($vo['notes']); unset($vo['uid']); unset($vo['storeid']); unset($vo['createtime']); unset($vo['starttime']); unset($vo['endtime']); unset($vo['noticetime']); } return $list; }
/** * 获取回复列表 * @param array $map 查询条件 * @param string $order 排序条件,默认为comment_id ASC * @param int $limit 结果集数目,默认为10 * @return array 评论列表信息 */ public function getReplyList($map = null, $order = 'reply_id desc', $limit = 10) { !isset($map['is_del']) && ($map['is_del'] = 0); $data = $this->where($map)->order($order)->findPage($limit); // // TODO:后续优化 foreach ($data['data'] as &$v) { $v['user_info'] = model('User')->getUserInfo($v['uid']); $v['user_info']['groupData'] = model('UserGroupLink')->getUserGroupData($v['uid']); //获取用户组信息 $v['content'] = parse_html(h(htmlspecialchars($v['content']))); //$v['sourceInfo'] = model('Source')->getSourceInfo($v['table'], $v['row_id'], false, $v['app']); $v['attach_info'] = model('Attach')->getAttachById($v['attach_id']); if ($v['attach_info']['attach_type'] == 'weiba_comment_image' || $v['attach_info']['attach_type'] == 'feed_image') { $v['attach_info']['attach_url'] = getImageUrl($v['attach_info']['save_path'] . $v['attach_info']['save_name'], 590); } } return $data; }
public function index() { $u['savepath'] = ''; $u['savename'] = ''; list($width, $height) = getimagesize(getImageUrl($u['savepath'] . $u['savename'])); exit; $demo = json_decode(file_get_contents('http://tsimg.tsurl.cn/2013/0819/16/5211de3274738.jpg!exif')); settype($demo, 'array'); dump($demo); exit; // $str = 'http://tsimg.tsurl.cn/2013/0819/16/5211de3274738.jpg!exif'; $str = 'http://tsimg.tsurl.cn/2013/0819/16/5211de327473832123.jpg!exif'; $demo = file_get_contents($str); $demo = json_decode($demo); dump($demo->width); dump($demo->height); dump($demo); }
public function login() { // 登录验证 $passport = model('Passport'); if ($passport->isLogged()) { $this->redirect(U('w3g/Index/index')); } //载入站点配置全局变量 if ($GLOBALS['ts']['site']['site_logo_w3g'] == '') { $w3gLogoUrl = 'img/logo.png'; } else { $attach = model('Attach')->getAttachById($GLOBALS['ts']['site']['site_logo_w3g']); $w3gLogoUrl = getImageUrl($attach['save_path'] . $attach['save_name']); } $this->assign('w3gLogoUrl', $w3gLogoUrl); // dump($w3gLogoUrl);exit(); $this->assign('is_register_open', $this->isRegisterOpen() ? '1' : '0'); $this->display(); }
/** * 渲染关注按钮模板 * @example * $data['follower_uid'] integer 用户ID * @param array $data 渲染的相关配置参数 * @return string 渲染后的模板数据 */ public function render($data) { $var = array(); $var['type'] = 'FollowWeibaList'; $follow = D('weiba_follow')->where('follower_uid=' . $data['follower_uid'])->findAll(); $map['weiba_id'] = array('in', getSubByKey($follow, 'weiba_id')); $map['is_del'] = 0; $var['weibaList'] = D('weiba')->where($map)->findAll(); $var['weibaListCount'] = D('weiba')->where($map)->count(); foreach ($var['weibaList'] as $k => $v) { $logo = D('attach')->where('attach_id=' . $v['logo'])->find(); $var['weibaList'][$k]['logo'] = getImageUrl($logo['save_path'] . $logo['save_name']); } is_array($data) && ($var = array_merge($var, $data)); // 渲染模版 $content = $this->renderFile(dirname(__FILE__) . "/followWeibaList.html", $var); unset($var, $data); // 输出数据 return $content; }
/** * 获取全部话题 * @param int limit 每页显示条数 * @return array 话题列表 */ public function getTopic($limit = 20, $isrecommend) { if ($isrecommend) { $map['recommend'] = 1; } if ($_POST) { $_POST['topic_id'] && ($map['topic_id'] = intval($_POST['topic_id'])); $_POST['topic_name'] && ($map['topic_name'] = array('like', '%' . t($_POST['topic_name']) . '%')); $_POST['recommend'] && ($map['recommend'] = $_POST['recommend'] == 1 ? 1 : 0); $_POST['essence'] && ($map['essence'] = $_POST['essence'] == 1 ? 1 : 0); $_POST['lock'] && ($map['lock'] = $_POST['lock'] == 1 ? 1 : 0); } $topic_list = D('feed_topic')->where($map)->order('recommend desc,recommend_time desc,ctime desc')->findpage($limit); //数据格式化 foreach ($topic_list['data'] as $k => $v) { if ($v['recommend'] == 1) { $topic_list['data'][$k]['topic_name'] = '<a target="_blank" href="' . U('public/Topic/index', array('k' => urlencode($topic_list['data'][$k]['topic_name']))) . '">' . $topic_list['data'][$k]['topic_name'] . '</a>'; } else { $topic_list['data'][$k]['topic_name'] = '<a target="_blank" href="' . U('public/Topic/index', array('k' => urlencode($topic_list['data'][$k]['topic_name']))) . '">' . $topic_list['data'][$k]['topic_name'] . '</a>'; } $pic = D('attach')->where('attach_id=' . $v['pic'])->find(); $topic_list['data'][$k]['pic'] && ($topic_list['data'][$k]['pic'] = '<img src="' . getImageUrl($pic['save_path'] . $pic['save_name']) . '" width="50">'); $topic_user = explode(',', $v['topic_user']); $topic_user_info = model('User')->getUserInfoByUids($topic_user); $topic_list['data'][$k]['topic_user'] = ''; foreach ($topic_user as $key => $val) { $topic_list['data'][$k]['topic_user'] .= $topic_user_info[$val]['space_link'] . '<br />'; } //dump($topic_list['data'][$k]['topic_user']);exit; // $isrecommend = $v['recommend']?'是':'否'; // $topic_list['data'][$k]['recommend'] = '<a href="javascript:void(0);" onclick="admin.setTopic(1,'.$v['topic_id'].','.intval($v['recommend']).')">'.$isrecommend.'</a>'; // $isessence = $v['essence']?'是':'否'; // $topic_list['data'][$k]['essence'] = '<a href="javascript:void(0);" onclick="admin.setTopic(2,'.$v['topic_id'].','.intval($v['essence']).')">'.$isessence.'</a>'; $islock = $v['lock'] ? '取消屏蔽' : '屏蔽'; // 操作数据 $topic_list['data'][$k]['DOACTION'] = '<a href="javascript:void(0);" onclick="admin.setTopic(3,' . $v['topic_id'] . ',' . intval($v['lock']) . ')">' . $islock . '</a> - '; $topic_list['data'][$k]['DOACTION'] .= '<a href="' . U('admin/Content/editTopic', array('topic_id' => $v['topic_id'], 'tabHash' => 'editTopic')) . '">编辑</a>'; //$listData['data'][$k]['DOACTION'] .= '<a href="javascript:void(0)" onclick="admin.deleteUser(\''.$v['uid'].'\')">'.L('PUBLIC_STREAM_DELETE').'</a>'; } return $topic_list; }
/** * 这里返回的是模板中需要渲染的变量 */ public function replace() { $time = str_replace(array(' ', '.'), '', microtime()); $var['image'] = $this->attr['image_list']; $var['effect'] = $this->attr['effect']; //动画可选 'none','scrollx', 'scrolly', 'fade' $var['autoPlay'] = $this->attr['autoPlay']; //是否自动播放 $var['autoPlayInterval'] = $this->attr['autoPlayInterval']; //自动播放间隔时间 $var['width'] = $this->attr['width']; $var['height'] = $this->attr['height']; foreach ($var['image'] as &$value) { $value->path = getImageUrl($value->path); $value->url = str_replace('[@]', '&', $value->url); } $var['imgId'] = "i" . substr($this->sign, 0, 5) . $time; $var['imgPanel'] = "i" . substr($this->sign, 0, 6) . $time; $var['imgNav'] = "i" . substr($this->sign, 0, 7) . $time; return $var; }
/** * 勋章详细 */ public function showdetail() { $id = intval($_GET['id']); $type = intval($_GET['type']); if ($id) { if ($type == 1) { $umedal = D('medal_user')->where('uid=' . $GLOBALS['ts']['mid'] . ' and medal_id=' . $id)->field('`desc`,ctime')->find(); $desc = $umedal['desc']; $ctime = $umedal['ctime']; } $medal = model('Medal')->where('id=' . $id)->find(); if ($medal) { $src = explode('|', $medal['src']); $medal['src'] = getImageUrl($src[1]); $desc && ($medal['desc'] = $desc); $ctime && ($medal['ctime'] = date('Y-m-d H:i:s', $ctime)); $this->assign('medal', $medal); $this->display(); } } }
/** * 获取所有频道分类数据 * @return array 所有频道分类数据 */ public function getAllChannel() { $data = model('CategoryTree')->setTable('channel_category')->getCategoryAllHash(); // 组装附件信息 $attachIds = getSubByKey($data, 'attach'); $attachIds = array_filter($attachIds); $attachIds = array_unique($attachIds); $attachInfos = model('Attach')->getAttachByIds($attachIds); $attachData = array(); foreach ($attachInfos as $attach) { $attachData[$attach['attach_id']] = $attach; } foreach ($data as &$value) { if (!empty($value['attach']) && !empty($attachData[$value['attach']])) { $value['icon_url'] = getImageUrl($attachData[$value['attach']]['save_path'] . $attachData[$value['attach']]['save_name']); } else { $value['icon_url'] = null; } unset($value['ext'], $value['attach'], $value['user_bind'], $value['topic_bind']); } return $data; }
/** * 频道首页 * @param integer user_id 用户ID * @param integer page 第几页 * @param integer count 视频条数 * @return json 频道分类+热门视频 */ public function channel() { $page = $this->data['page'] ? intval($this->data['page']) : 1; $count = $this->data['count'] ? intval($this->data['count']) : 6; if ($page == 1) { $this->user_id = empty($this->user_id) ? $this->mid : $this->user_id; // $data['channels'] = D('ChannelApi', 'channel')->getChannels($this->user_id,6); $data['channels'] = D('ChannelFollow', 'channel')->getFollowList($this->user_id); foreach ($data['channels'] as $k => &$v) { $ext = unserialize($v['ext']); $v['attach'] = $ext['attach']; } // 组装附件信息 $attachIds = getSubByKey($data['channels'], 'attach'); $attachIds = array_filter($attachIds); $attachIds = array_unique($attachIds); $attachInfos = model('Attach')->getAttachByIds($attachIds); $attachData = array(); foreach ($attachInfos as $attach) { $attachData[$attach['attach_id']] = $attach; } foreach ($data['channels'] as &$value) { if (!empty($value['attach']) && !empty($attachData[$value['attach']])) { $value['icon_url'] = getImageUrl($attachData[$value['attach']]['save_path'] . $attachData[$value['attach']]['save_name']); } else { $value['icon_url'] = null; } unset($value['ext'], $value['attach'], $value['user_bind'], $value['topic_bind']); if ($this->user_id) { $value['followStatus'] = intval(D('ChannelFollow', 'channel')->getFollowStatus($this->user_id, $value['channel_category_id'])); } } } $data['videos'] = D('ChannelApi', 'channel')->getChannelFeed('', 'postvideo', $count, $page); return $data; }
/** * 编辑器文件上传 * @return array 上传文件的信息 */ public function saveEditorFile() { $data['attach_type'] = 'editor_file'; $data['upload_type'] = 'file'; //使用又拍云时,必须指定类型为file $info = model('Attach')->upload($data); if ($info['status']) { $data = $info['info'][0]; $data['src'] = getImageUrl($data['save_path'] . $data['save_name'], 100, 100, true); $data['extension'] = strtolower($data['extension']); $return = array('status' => 1, 'data' => $data); } else { $return = array('status' => 0, 'data' => $info['info']); } echo json_encode($return); exit; }
function topicDetail() { $tid = intval($_GET['tid']) > 0 ? $_GET['tid'] : 0; if ($tid == 0) { $this->error('参数错误'); } $limit = 20; $this->topic->setInc('viewcount', 'id=' . $tid); $thread = $this->topic->getThread($tid); // 获取主题 // 判读帖子存不存在 if (!$thread) { $jumpUrl = U('w3g/Group/detail', array('gid' => $this->gid)); $this->error('帖子不存在'); } // 帖子的分类 $thread['ctitle'] = M('group_topic_category')->getField('title', "id={$thread['cid']} AND gid={$this->gid}"); $thread['ctitle'] = $thread['ctitle'] ? "[{$thread['ctitle']}]" : ''; // 附件信息 if ($thread['attach']) { $_attach_map['id'] = array('IN', unserialize($thread['attach'])); $thread['attach'] = D('Dir', 'group')->field('id,name,note,is_del')->where($_attach_map)->findAll(); } if (!empty($thread['image_ids'])) { $thread['attachIds'] = explode(',', $thread['image_ids']); $attachInfo = model('Attach')->getAttachByIds($thread['attachIds']); foreach ($attachInfo as $var) { $src = getImageUrl($var['save_path'] . $var['save_name'], 250, 250, true); if ($src) { $thread['content'] .= '<br/><p><img src="' . $src . '" /></p>'; } } } $postlist = $this->post->where('is_del = 0 AND istopic=0 AND tid=' . $tid)->findPage($limit); foreach ($postlist['data'] as &$vo) { if (!empty($vo['image_ids'])) { $vo['attachIds'] = explode(',', $vo['image_ids']); $attachInfo = model('Attach')->getAttachByIds($vo['attachIds']); foreach ($attachInfo as $var) { $src = getImageUrl($var['save_path'] . $var['save_name'], 250, 250, true); if ($src) { $vo['content'] .= '<br/><p><img src="' . $src . '" /></p>'; } } } } // 起始楼层计算 $p = $_GET[C('VAR_PAGE')] ? intval($_GET[C('VAR_PAGE')]) : 1; $this->assign('start_floor', intval(1 == $p ? ($p - 1) * $limit + 1 : ($p - 1) * $limit)); $this->assign('topic', $thread); // dump($thread); $this->assign('tid', $tid); $this->assign('postlist', $postlist); $this->assign('isCollect', D('Collect', 'group')->isCollect($tid, $this->mid)); // 判断是否收藏 $this->setTitle("{$thread['title']} - 帖子 - {$this->groupinfo['name']}"); $this->display(); }
function jsonDetailsOut($response, $nameresponse, $wikipediaresponse, $langs = "en", $offset = 0, $id, $type, $callback) { if ($response) { $name = getNameDetail($langs, $nameresponse); $phone = getPhoneFaxDetail(array($response['phone1'], $response['phone2'], $response['phone3'])); $fax = getPhoneFaxDetail(array($response['fax1'], $response['fax2'], $response['fax3'])); $mobilephone = getPhoneFaxDetail(array($element['mobilephone1'], $element['mobilephone2'])); $website = getWebsiteDetail(array($response['website1'], $response['website2'], $response['website3'], $response['website4'])); $email = getMailDetail(array($response['email1'], $response['email2'], $response['email3'])); // get wikipedia link and make translation if ($wikipediaresponse) { $wikipedia = getWikipediaDetail($langs, $wikipediaresponse); } $openinghours = getOpeninghoursDetail($response['openinghours']); $servicetimes = getOpeninghoursDetail($response['servicetimes']); $data = array('id' => (int) $id, 'type' => $type); // name if ($name) { if ($name[0]) { $data['name'] = array('lang' => $name[1], 'name' => $name[0]); } else { $data['name'] = $name[0]; } } // address information if ($response['street']) { $data['street'] = $response['street']; } if ($response['housenumber']) { $data['housenumber'] = $response['housenumber']; } if ($response['country']) { $data['country'] = strtoupper($response['country']); } if ($response['postcode']) { $data['postcode'] = $response['postcode']; } if ($response['city']) { $data['city'] = $response['city']; } if ($response['suburb']) { $data['suburb'] = $response['suburb']; } // contact information if ($phone) { $tmp = array(); foreach ($phone as $phonenumber) { array_push($tmp, $phonenumber[1]); } $data['phone'] = $tmp; } if ($fax) { $tmp = array(); foreach ($fax as $faxnumber) { array_push($tmp, $faxnumber[1]); } $data['fax'] = $tmp; } if ($mobilephone) { $tmp = array(); foreach ($mobilephone as $mobilephonenumber) { array_push($tmp, $mobilephonenumber[1]); } $data['mobilephone'] = $tmp; } if ($email) { $data['email'] = $email; } // website and wikipedia links if ($website) { $tmp = array(); foreach ($website as $webaddress) { array_push($tmp, $webaddress[0]); } $data['website'] = $tmp; } if ($wikipedia[1]) { $data['wikipedia'] = $wikipedia[1]; } // operator if ($response['operator']) { $data['operator'] = $response['operator']; } // opening hours if ($openinghours) { if (isPoiOpen($response['openinghours'], $offset)) { $state .= "open"; } else { if (isInHoliday($response['openinghours'], $offset)) { $state .= "maybeopen"; } else { $state .= "closed"; } } $data['openinghours'] = array('state' => $state, 'openinghours' => $response['openinghours']); } // service times if ($servicetimes) { if (isPoiOpen($response['servicetimes'], $offset)) { $state .= "open"; } else { if (isInHoliday($response['servicetimes'], $offset)) { $state .= "maybeopen"; } else { $state .= "closed"; } } $data['servicetimes'] = array('state' => $state, 'servicetimes' => $response['servicetimes']); } // image, only images from domains listed on a whitelist are supported if (imageDomainAllowed($response['image'])) { $data['image'] = getImageUrl($response['image']); } else { if (getWikipediaImage($wikipedia[1])) { $data['image'] = getWikipediaImage($wikipedia[1]); } } $jsonData = json_encode($data); // JSONP request? if (isset($callback)) { return $callback . '(' . $jsonData . ')'; } else { return $jsonData; } } else { return false; } }
/** * 用户勋章列表 */ public function userMedal() { if ($_POST['user']) { $map['uid'] = array('in', explode(',', t($_POST['user']))); } if ($_POST['medal']) { $mearray = is_array($_POST['medal']) ? $_POST['medal'] : array(intval($_POST['medal'])); $map['medal_id'] = array('in', $mearray); } $list = model('Medal')->getUserMedalList($map); $this->pageKeyList = array('id', 'uname', 'medalname', 'medalsrc', 'desc', 'DOACTION'); foreach ($list['data'] as &$v) { $v['medalsrc'] = '<img src="' . getImageUrl($v['medalsrc']) . '" width="100px" height="100px" />'; $v['DOACTION'] = '<a href="' . U('admin/Medal/editUserMedal', array('id' => $v['id'])) . '" >编辑</a>'; // $v['DOACTION'] .= " <a href='javascript:void(0)' onclick='admin.deleteusermedal(".$v['id'].")'>删除</a>"; } $this->pageButton[] = array('title' => '搜索', 'onclick' => "admin.fold('search_form')"); $this->pageButton[] = array('title' => '颁发勋章', 'onclick' => "javascript:location.href='" . U('admin/Medal/addUserMedal') . "';"); // $this->pageButton[] = array( 'title' => '删除' , 'onclick' => "admin.deleteusermedal()" ); $this->searchKey = array('user', 'medal'); $medals = model('Medal')->getAllMedal(); $medals[0] = '不限'; ksort($medals); $this->opt['medal'] = $medals; $this->displayList($list); }
/** * 编辑话题 * @return void */ public function editTopic() { $this->assign('pageTitle', '编辑话题'); $this->pageTab[] = array('title' => '话题管理', 'tabHash' => 'list', 'url' => U('admin/Content/topic')); $this->pageTab[] = array('title' => '推荐话题', 'tabHash' => 'recommendTopic', 'url' => U('admin/Content/topic', array('recommend' => 1))); $this->pageTab[] = array('title' => '添加话题', 'tabHash' => 'addTopic', 'url' => U('admin/Content/addTopic')); $this->pageTab[] = array('title' => '编辑话题', 'tabHash' => 'editTopic', 'url' => U('admin/Content/editTopic', array('topic_id' => intval($_GET['topic_id']), 'tabHash' => 'editTopic'))); $this->pageKeyList = array('topic_id', 'topic_name', 'note', 'domain', 'des', 'pic', 'topic_user', 'outlink', 'recommend'); $this->opt['recommend'] = array('1' => '是', '0' => '否'); //$this->opt['essence'] = array('1'=>'是','0'=>'否'); $topic = model('FeedTopic')->where('topic_id=' . intval($_GET['topic_id']))->find(); if ($topic['pic']) { $pic = D('attach')->where('attach_id=' . $topic['pic'])->find(); $pic_url = $pic['save_path'] . $pic['save_name']; $topic['pic_url'] = getImageUrl($pic_url); } $topic['domain'] = SITE_URL . '/topics/' . '<input type="text" value="' . $topic['domain'] . '" name="domain" id="form_domain">'; $this->notEmpty = array('note'); $this->savePostUrl = U('admin/Content/doEditTopic'); $this->onsubmit = 'admin.topicCheck(this)'; $this->displayConfig($topic); }
/** * 注册流程 - 第四步骤 */ public function getGroup() { $map['status'] = 1; $map['is_del'] = 0; $list = D('Group')->where($map)->order('rand()')->limit('4')->select(); $cids = getSubByKey($list, 'cid0'); $cmap['id'] = array('in', $cids); $cateinfos = D('Category')->where($cmap)->field('id,title')->findAll(); $cnames = array(); foreach ($cateinfos as $cate) { $cnames[$cate['id']] = $cate['title']; } foreach ($list as $k => $v) { $list[$k]['logo'] = getImageUrl($v['logo'], 100, 100, true); $list[$k]['catename'] = $cnames[$v['cid0']]; } foreach ($list as $vo) { $html .= '<li>'; $html .= '<div class="circle-pic"><img src="' . $vo['logo'] . '"/></div>'; $html .= '<div class="circle-info">'; $html .= '<h>' . $vo['name'] . '</h>'; $html .= '<p>' . $vo['intro'] . '</p>'; $html .= '<a href="javascript:joingroup(' . $vo['id'] . ')" class="act-but joingroup_' . $vo['id'] . ' tojoin">加入</a> </div>'; $html .= '</li>'; } echo $html; }
function getImageSCById($id, $width = 180, $heigth = 180) { $attach = model('Attach')->getAttachById($id); return getImageUrl($attach['save_path'] . $attach['save_name'], $width, $heigth, true); }
/** * 任务奖励列表 */ public function reward() { $this->pageKeyList = array('task_name', 'reward', 'medal', 'DOACTION'); $list = model('Task')->group('task_name')->where('task_type=2')->field('task_name,task_level,task_type')->findPage(); foreach ($list['data'] as &$v) { $taskreward = D('task_reward')->where('task_type=' . $v['task_type'] . ' and task_level=' . $v['task_level'])->getField('reward'); $reward = json_decode($taskreward); $src = $reward->medal->src; $v['reward'] = '经验+' . intval($reward->exp) . ' 财富+' . intval($reward->score); if ($src) { $v['medal'] = '<img width="100px" height="100px" src="' . getImageUrl($src) . '" />'; } $v['DOACTION'] = '<a href="' . U('admin/Task/editReward', array('task_level' => $v['task_level'], 'task_type' => $v['task_type'])) . '">编辑</a>'; } $this->allSelected = false; $this->displayList($list); }
/** * 搜索微吧 * @param varchar keyword 搜索关键字 * @param integer limit 每页显示条数 * @param integer page 第几页 * @param integer uid 用户UID * @return array 微吧列表 */ public function searchWeibaForApi($keyword, $limit, $page, $uid) { $limit = intval($limit); $page = intval($page); $start = ($page - 1) * $limit; $end = $limit; $map['is_del'] = 0; $where['weiba_name'] = array('like', '%' . $keyword . '%'); $where['intro'] = array('like', '%' . $keyword . '%'); $where['_logic'] = 'or'; $map['_complex'] = $where; $weibaList = D('weiba')->where($map)->limit("{$start},{$end}")->order('follower_count desc,thread_count desc')->findAll(); if ($weibaList) { foreach ($weibaList as $k => $v) { if ($v['logo']) { $pic = D('attach')->where('attach_id=' . $v['logo'])->find(); $weibaList[$k]['logo_url'] = getImageUrl($pic['save_path'] . $pic['save_name']); } if (D('weiba_follow')->where('follower_uid=' . $uid . ' AND weiba_id=' . $v['weiba_id'])->find()) { $weibaList[$k]['followstate'] = 1; } else { $weibaList[$k]['followstate'] = 0; } } return $weibaList; } else { return array(); } }
public function upImageAttachCloud($page = 1, $count = 100) { set_time_limit(0); $where = "`extension` IN ('jpg', 'gif', 'png', 'jpeg', 'bmp') AND attach_type != 'feed_file'"; $limit = ($page - 1) * $count . ', ' . $count; $list = $this->field('attach_id, save_path, save_name')->where($where)->limit($limit)->order('attach_id DESC')->findAll(); if (empty($list)) { return false; } foreach ($list as $value) { $imageInfo = json_decode(file_get_contents(getImageUrl($value['save_path'] . $value['save_name']) . '!exif')); settype($imageInfo, 'array'); if (empty($imageInfo)) { continue; } $data['width'] = $imageInfo['width']; $data['height'] = $imageInfo['height']; $map['attach_id'] = $value['attach_id']; $this->where($map)->save($data); } return true; }
/** * 获取指定私信列表中的私信内容 * @param integer $list_id 私信列表ID * @param integer $uid 用户ID * @param integer $since_id 最早会话ID * @param integer $max_id 最新会话ID * @param integer $count 旧会话加载条数,默认为20 * @return array 指定私信列表中的私信内容 */ public function getMessageByListId($list_id, $uid, $since_id = null, $max_id = null, $count = 20) { $list_id = intval($list_id); $uid = intval($uid); $since_id = intval($since_id); $max_id = intval($max_id); $count = intval($count); // 验证该用户是否为该私信成员 if (!$list_id || !$uid || !($messageInfo = $this->isMember($list_id, $uid, false))) { return false; } $where = "`list_id`={$list_id} AND `is_del`=0"; if ($since_id > 0) { $where .= " AND `message_id` > {$since_id}"; $max_id > 0 && ($where .= " AND `message_id` < {$max_id}"); $limit = intval($count) + 1; } else { $max_id > 0 && ($where .= " AND `message_id` < {$max_id}"); // 多查询一条验证,是否还有后续信息 $limit = intval($count) + 1; } $res['data'] = D('message_content')->where($where)->order('message_id DESC')->limit($limit)->findAll(); foreach ($res['data'] as $r_d_k => $r_d_v) { $res['data'][$r_d_k]['user_info'] = model('User')->getUserInfo($r_d_v['from_uid']); // 处理附件信息 $attachType = ''; $attachArr = array(); $attachIds = unserialize($r_d_v['attach_ids']); foreach ($attachIds as &$attachId) { // 获取附件信息 $attachInfo = model('Attach')->getAttachById($attachId); $attachType = $attachInfo['attach_type']; switch ($attachType) { case 'message_image': $tmp['attach_id'] = $attachInfo['attach_id']; $tmp['width'] = $attachInfo['width']; $tmp['file'] = $attachInfo['save_path'] . $attachInfo['save_name']; $tmp['url'] = getImageUrl($attachInfo['save_path'] . $attachInfo['save_name']); break; case 'message_file': $tmp['attach_id'] = $attachInfo['attach_id']; $tmp['extension'] = strtolower($attachInfo['extension']); $tmp['attach_name'] = $attachInfo['name']; $tmp['size'] = $attachInfo['size']; break; } $attachArr[] = $tmp; unset($tmp); } $res['data'][$r_d_k]['attach_infos'] = $attachArr; $res['data'][$r_d_k]['attach_type'] = $attachType; unset($attachInfos); } $res['count'] = count($res['data']); if ($since_id > 0) { $res['since_id'] = $res['data'][0]['message_id']; $res['max_id'] = $res['data'][$res['count'] - 1]['message_id']; if ($res['count'] < $limit) { $res['max_id'] = 0; } } else { $res['since_id'] = $res['data'][0]['message_id']; // 结果数等于查询数,则说明还有后续message if ($res['count'] == $limit) { // 去除结果的最后一条 array_pop($res['data']); // 计数减一 $res['count']--; // 取最后一条结果message_id $res['max_id'] = $res['data'][$res['count'] - 1]['message_id']; } else { if ($res['count'] < $limit) { // 取最后一条结果message_id设置为0,表示结束 $res['max_id'] = 0; } } } return $res; }