public function index() { $config = Amango_Addons_Config('Sharephotos'); //$list = M('Addonssharepics')->where(array('status'=>1))->order('rand()')->limit(8)->select(); $model = M('Addonssharepics'); $total = $model->where(array('status' => 1))->count(); $listRows = $config['pagenums'] > 0 ? $config['pagenums'] : 5; $page = new \Think\Page($total, $listRows); $list = $model->where(array('status' => 1))->limit($page->firstRow . ',' . $page->listRows)->select(); //按照时间顺序奇偶分配左右 $paixu = array('left', 'right'); $newlist = array(); foreach ($list as $key => $value) { $newlist[$paixu[$key % 2]][] = $value; } //微信分享设置 //随机图片分享 $picinfo = M('Addonssharepics')->where(array('status' => 1))->order('rand()')->find(); $sharename = $picinfo['content'] . "【" . $config['title'] . "】"; $shareurl = addons_url('Sharephotos://Home/index', array(), 'home'); $Shareinfo = array('ImgUrl' => get_cover_pic($picinfo['picurl']), 'TimeLink' => $shareurl, 'FriendLink' => $shareurl, 'WeiboLink' => $shareurl, 'tTitle' => $sharename, 'tContent' => $sharename, 'fTitle' => $sharename, 'fContent' => $sharename, 'wContent' => $sharename); $this->assign('Share', $Shareinfo); $this->assign('urlhost', str_replace('.html', '', addons_url('Sharephotos://Home/sharepicsajax'))); $this->assign('info', $config); $this->assign('left', $newlist['left']); $this->assign('right', $newlist['right']); $this->display(); }
function set_jstpl($link_url, $info, $list, $common, $id) { //判断是否存在缓存 5小时 $cachetpl = S('Addonsexamcache' . $id); if (!empty($cachetpl)) { return $cachetpl; } //不存在 重新定义 //分享图片 $img_url = get_cover_pic($info['logo']); //分数段 $scoreparam = ''; $score_param = array(); $score_param = parse_config($info['score_param']); foreach ($score_param as $key => $value) { $scoreparam .= '{score: ' . $key . ',comment: "' . $value . '"},'; } //题目列表 $queData = set_queData($list); $tpl = <<<str (function() { window.amangoshare = { "img_url": "{$img_url}", "img_width": "120", "img_height": "120", "link": "{$link_url}", "desc": "我正在参加【{$info['title']}】!你也来试试!", "title": "{$info['title']}" }; window.buttonurl = [ '{$common[0]}', '{$common[1]}', '{$common[2]}', '{$common[3]}', ]; window.nowdatajson = { queData: [ {$queData} ], fullScore: {$info['score']}, scoreArray: [ {$scoreparam} ] }; }).call(this); str; S('Addonsexamcache' . $id, $tpl, 60 * 60); return $tpl; }
protected function setHeader($show = false, $shareurl, $imgurl, $title, $content) { $this->assign('HideFastmenu', '1'); $defaulturl = Amango_U('Index/index'); $defaultimg = get_cover_pic('/Addons/DanangTools/Public/vipshow/m_vip.png'); $d_title = '【岘港假期】该东南亚最佳避暑区旅游城市之一的避暑区'; $d_content = '岘港在韩江曰左岸,北临观港湾。位于越南中部,北连顺化、南接芽庄。背靠五行山,东北有山茶半岛作屏障,海湾呈马蹄形,港阔水深,形势险要,为天然良港。自古中固景口岸。东南35公里则为联合国世界文化遗产会安古镇,从会安古镇码头搭乘摆渡船出发则可以游览秋盆河明珠之迦南岛(Dao Cam Kim),迦南岛主要以水椰林及原生态自然风光而闻名。'; $shareurl = empty($shareurl) ? $defaulturl : $shareurl; $imgurl = empty($imgurl) ? $defaultimg : $imgurl; $title = empty($title) ? $d_title : $title; $content = empty($content) ? $d_content : $content; $Shareinfo = array('ImgUrl' => $imgurl, 'TimeLink' => $shareurl, 'FriendLink' => $shareurl, 'WeiboLink' => $shareurl, 'tTitle' => $title, 'tContent' => $content, 'fTitle' => $title, 'fContent' => $content, 'wContent' => $content); $this->assign('Share', $Shareinfo); $this->assign('HideFastmenu', '1'); if ($show) { $this->assign('HideAll', 1); } }
public function show_test() { if ($this->wxmainword == '中心') { global $_P; $article[0] = array('Title' => "微考试-考试中心\n已参加考试", 'Description' => "子曰:学而时习之,不亦说乎!\n已参加的考试列表:", 'PicUrl' => ADDON_PUBLIC . 'exam.jpg', 'Url' => ''); $userloglist = M('Addonsexamlog')->where(array('fromusername' => $_P['fromusername']))->limit(5)->order('addtime DESC')->select(); if (empty($userloglist)) { $article[0] = array('Title' => "您还未参加任何考试", 'Description' => "子曰:学而时习之,不亦说乎!", 'PicUrl' => '', 'Url' => ''); } else { $model = M('Addonsexam'); foreach ($userloglist as $key => $value) { $testinfo = $model->where(array('id' => $value['testid']))->field('title,logo')->find(); $userloglist[$key]['title'] = $testinfo['title']; $userloglist[$key]['logo'] = $testinfo['logo']; } $im = 1; foreach ($userloglist as $key => $value) { $article[$im++] = array('Title' => "《" . $value['title'] . "》\n分数:" . $value['score'] . "\n时间:" . date('Y-m-d h:i:sa', $value['addtime']), 'Description' => "子曰:学而时习之,不亦说乎!", 'PicUrl' => empty($value['logo']) ? ADDON_PUBLIC . 'exam.jpg' : get_cover_pic($value['logo']), 'Url' => ''); } } $this->assign('Duotw', $article); $this->display(); } $model = M('Addonsexam'); $fields = 'id,keyword,desc,title,score,author,views,logo'; $info = $model->where(array('keyword' => $this->wxmainword))->field($fields)->find(); //模糊查询 if (empty($info)) { $map['keyword'] = array('like', '%' . $this->wxmainword . '%'); $list = $model->where($map)->field($fields)->select(); $article = $this->default_tw($list); } else { $article[0] = array('Title' => "微考试-" . $info['title'], 'Description' => "出卷人:" . $info['author'] . "\n总 分:" . $info['score'] . "\n参考数:" . $info['views'] . "次\n简介:" . $info['desc'] . "\n\n点我立即参加考试>>>", 'PicUrl' => empty($info['logo']) ? ADDON_PUBLIC . 'exam.jpg' : get_cover_pic($info['logo']), 'Url' => $this->create_loginurl('index', array('id' => $info['id']))); } $this->assign('Duotw', $article); $this->display(); }
protected function setShare($imgurl, $url, $title, $content) { if (strpos($url, 'http://') === false) { $url = Amango_U('Article/lists', array('category' => 'wsqxxgl')); } if (empty($imgurl)) { $imgurl = 'http://' . $_SERVER['HTTP_HOST'] . '/Public/logo.jpg'; } else { $imgurl = get_cover_pic($imgurl); } if (empty($title)) { $title = C('WEB_SITE_TITLE'); } $content = $title . $content; $Shareinfo = array('ImgUrl' => $imgurl, 'TimeLink' => $url, 'FriendLink' => $url, 'WeiboLink' => $url, 'tTitle' => $title, 'tContent' => $content, 'fTitle' => $title, 'fContent' => $content, 'wContent' => $content); $this->assign('Share', $Shareinfo); }
public function detail($id = 0, $p = 1) { global $_K; /* 标识正确性检测 */ if (!($id && is_numeric($id))) { $this->error('文档ID错误!'); } /* 页码检测 */ $p = intval($p); $p = empty($p) ? 1 : $p; /* 获取详细信息 */ $info = api('Document/get_detail', array('id' => $id)); if (false === $info['status']) { $this->error($info['info']); } //芒果用户回复 $this->assign('model_id', $info['model_id']); $model = get_document_model($info['model_id']); $fields = get_model_attribute($model['id']); $newfields = array(); foreach ($fields[1] as $k => $v) { if ($v['reply_show'] == 1) { $newfields[] = $v; } } /* 分类信息 */ $category = $this->category($info['category_id']); /* 获取模板 */ if (!empty($info['template'])) { //已定制模板 $tmpl = $info['template']; } elseif (!empty($category['template_detail'])) { //分类已定制模板 $tmpl = $category['template_detail']; } else { //使用默认模板 $tmpl = 'Article/' . get_document_model($info['model_id'], 'name') . '/detail'; } /* 更新浏览数 */ $map = array('id' => $id); D('Document')->where($map)->setInc('view'); /* 芒果微信分享信息 */ $shareurl = Amango_U('Article/detail?id=' . $id); $biaoshi = $info['title'] . "来自:" . C('WEB_SITE_TITLE'); $Shareinfo = array('ImgUrl' => get_cover_pic($info['cover_id']), 'TimeLink' => $shareurl, 'FriendLink' => $shareurl, 'WeiboLink' => $shareurl, 'tTitle' => $biaoshi, 'tContent' => $biaoshi, 'fTitle' => $biaoshi, 'fContent' => $biaoshi, 'wContent' => $biaoshi); $this->assign('Share', $Shareinfo); //是否允许发表新 $this->assign('reply', $category['reply']); $this->assign('reply_show', $category['reply_show']); $this->assign('fields', $newfields); //一键关注链接 $this->assign('accountsub', $_K['DEFAULT']['account_sub']); /* 模板赋值并渲染模板 */ $this->assign('category', $category); $this->assign('info', $info); $this->assign('page', $p); //页码 //公共title $this->assign('Title', $info['title']); $this->display($tmpl); }
public function setInfo($type, $detail, $originalxml, $denytag, $otherparam) { $arraydetail = unserialize($detail); $readparam = explode(',', $arraydetail['neiron']); switch ($arraydetail['type']) { case 'fastarticles': $readfields = D('Flycloud')->where(array('data_type' => 'category', 'data_table' => $readparam[0]))->find(); //读取详情 判断是否为最新或随机 if (strtolower($readparam[1]) == 'rand') { $lists = api('Category/get_category_rand', array('cateid' => $readparam[0], 'field' => $readfields['data_fields'], 'limit' => $arraydetail['num'])); } if (strtolower($readparam[1]) == 'news') { $lists = api('Category/get_category_news', array('cateid' => $readparam[0], 'field' => $readfields['data_fields'], 'limit' => $arraydetail['num'])); } $newlist = array(); foreach ($lists as $key => $value) { $newlist[] = array_values($value); } $hassource = count($newlist); if ($hassource === 0) { wx_error('Sorry!暂无相关内容'); } $writetype = strtoupper($readparam[1]); $replacedate = array(); for ($i = 0; $i <= $arraydetail['num'] - 1; $i++) { $replacedate[$writetype . $i . '0'] = $newlist[$i][0]; $replacedate[$writetype . $i . '1'] = get_cover_pic($newlist[$i][1]); $replacedate[$writetype . $i . '2'] = $newlist[$i][2]; $replacedate[$writetype . $i . '3'] = Amango_U('Article/detail?id=' . $newlist[$i][3]); } $newcontent = strtr($originalxml, $replacedate); //wx_error(base64_encode($newcontent)); //wx_error(json_encode($replacedate)); return array('type' => 'Duotw', 'info' => $newcontent); break; case 'articles': $newcontent = self::creatArticles($type, $detail, $originalxml, $denytag, $otherparam); return array('type' => 'Duotw', 'info' => $newcontent); break; default: wx_error('多图文回复中未知类型~'); break; } }
public function setInfo($type, $detail, $originalxml, $denytag, $otherparam) { $arraydetail = unserialize($detail); $readparam = explode(',', $arraydetail['neiron']); //要读取的字段 $readfields = D('Flycloud')->where(array('data_type' => 'category', 'data_table' => $readparam[0]))->find(); //读取详情 判断是否为最新或随机 $artype = strtolower($readparam[1]); if (in_array($artype, array('rand', 'news'))) { $lists = api('Category/get_category_' . $artype, array('cateid' => $readparam[0], 'field' => $readfields['data_fields'], 'limit' => 1)); //完整XML格式信息 $serslists = array_values($lists[0]); $url = is_numeric($serslists[1]) ? D('Picture')->where(array('id' => $serslists[1]))->getField('path') : $serslists[1]; $prefix = strtoupper($readparam[1]); $replacedate = array($prefix . '0' => $serslists[0], $prefix . '1' => get_cover_pic($url), $prefix . '2' => $serslists[2], $prefix . '3' => Amango_U('Article/detail?id=' . $serslists[3])); $newcontent = strtr($originalxml, $replacedate); } else { $newcontent = $originalxml; } return array('type' => 'Dantw', 'info' => $newcontent); }