pub_special($special_id); self::outsuccess($ret); } else { $spitem = spid_helper::instance()->special($special_id); if($spitem == false) { return self::outerr(errcode::ErrParamter,"该专题不存在"); } if($spitem->from_user()) { $ret = $this->pri_special($special_id); $ret['spitem'] = $spitem; $tpl_obj = new tpl_ugc($ret); self::outsuccess(['tpl_obj' => $tpl_obj],'ugc/content'); } else { $ret = $this->pub_special($special_id); self::outsuccess($ret); } } } public function voteOp() { $special_id = intval($_GET['special_id']); if(!empty($_GET['options'])) { $options = explode(',',$_GET['options']); } if($special_id < 0 || empty($options)) { return self::outerr(errcode::ErrParamter,"该文章不存在或者没有选中选项"); } $spitem = spid_helper::instance()->special($special_id); if($spitem->has_vote()) { $result = ugc_helper::vote($special_id,$options,$err); if($result == false) { return self::outerr($err['code'],$err['msg']); } else { $vote_result = $result['vote_result']; $type_sn = $result['type_sn']; if(!empty($type_sn)) { $url = BASE_SITE_URL . "/mobile/index.php?act=bonusex&op=open&type_sn={$type_sn}"; } else { $url = ""; } return self::outsuccess(['special_id' => $special_id,'vote_result' => $vote_result,'bonus_url' => $url]); } } else { return self::outerr(errcode::ErrSpecial,"本文不支持投票"); } } protected function pub_special($special_id) { $specials = special_manager::instance()->special($special_id,$goods_ids,true); if (!empty($goods_ids)) { $helper = new goods_helper(); $goodsex = $helper->online_summary($goods_ids, $related_goods); return array('special_list' => $specials, 'summary' => $goodsex['summary'], 'groupbuy' => $goodsex['groupbuy'], 'limitime' => $goodsex['limitime'], 'bundling' => $goodsex['bundling'], 'mobile_page' => mobile_page(1)); } else { return array('special_list' => $specials, 'summary' => array(), 'groupbuy' => array(), 'limitime' => array(), 'bundling' => array(), 'mobile_page' => mobile_page(1)); } } protected function pri_special($special_id) { $result = special_manager::instance()->special($special_id,$goods_ids,false); if (!empty($goods_ids)) { $helper = new goods_helper(); $goodsex = $helper->online_summary($goods_ids, $related_goods); return array('special_list' => $result['specials'], 'sender_info' => $result['sender_info'], 'special_info' => $result['special_info'], 'summary' => $goodsex['summary'], 'groupbuy' => $goodsex['groupbuy'], 'limitime' => $goodsex['limitime'], 'bundling' => $goodsex['bundling'], 'mobile_page' => mobile_page(1)); } else { return array('special_list' => $result['specials'], 'sender_info' => $result['sender_info'], 'special_info' => $result['special_info'], 'summary' => array(), 'groupbuy' => array(), 'limitime' => array(), 'bundling' => array(), 'mobile_page' => mobile_page(1)); } } } class tpl_ugc { private $spitem; private $special_list; private $summary; private $mem_info; private $special_info; public function __construct($output) { $this->spitem = $output['spitem']; $this->special_list = $output['special_list']; $this->summary = $output['summary']; if(!empty($output['sender_info'])) { $this->mem_info = new member_info($output['sender_info']); } else { $this->mem_info = null; } if(!empty($output['special_info'])) { $this->special_info = new special_info($output['special_info']); } else { $this->special_info = null; } } public function title() { return $this->spitem->share_title(); } public function show_title() { $title = $this->spitem->share_title(); if(!empty($title)) { $str = "

{$title}

"; echo $str; } } public function show_sender() { if($this->mem_info != null) { $nick_name = $this->mem_info->nickname(); $avatar = $this->mem_info->avatar(); $str = "\"熊猫美妆\"文/{$nick_name}"; } else { $str = ''; } echo $str; } public function show_blocks() { foreach ($this->special_list as $block) { $item_type = $block['item_type']; $items = $block['items']; if($item_type == 'home_ugc' && !empty($items)) { $this->show_items($items); } } } private function show_items($items) { $qindex = 0; foreach ($items as $item) { $show_type = $item['show_type']; if($show_type == 'image') { $this->show_image($item); } elseif($show_type == 'text') { $this->show_text($item); } elseif($show_type == 'vote') { $this->show_vote($item); } elseif($show_type == 'question') { $this->show_question($item,$qindex); $qindex++; } else { } } } private function show_question($item,$qindex) { } private function show_vote($item) { if(empty($item['data'])) return false; $options = json_decode($item['data'],true); if(empty($options)) return false; $title = $item['title']; $reserved = $item['reserved']; $kv = preg_split('/=/',$reserved); if(!empty($kv)) { $k = trim($kv[0]); $v = trim($kv[1]); if(!empty($k) && $k == 'vote_type') { $vote_type = $v; } } $vote_type = intval($vote_type); if($vote_type == 0) { $svote_type = '单选'; } elseif ($vote_type == 1) { $svote_type = '最多选两项'; } else { $svote_type = '多选'; } if($this->special_info != null) { $special_id = $this->special_info->special_id(); } else { $special_id = -1; } $str = "
{$title}
/{$svote_type}
"; foreach ($options as $val) { $key = $val['id']; $option = $val['text']; $soption = "
"; $str .= $soption; } $str .= '
'; echo $str; } private function show_text($item) { $data = $item['data']; echo "
{$data}
"; } private function show_image($item) { $image = $item['show_data']; $type = $item['type']; $title = $item['title']; if($type == 'url') { $url = $item['data']; $str = "
\"熊猫美妆\"
{$title}
"; } elseif($type == 'video') { $video = $item['data']; $str = "
《化妆小教程》
"; } else { $str = "
\"熊猫美妆\"
{$title}
"; } echo $str; } }