|
@@ -163,8 +163,12 @@ class tpl_ugc
|
|
|
} else {
|
|
|
$this->mem_info = null;
|
|
|
}
|
|
|
- if(!empty($output['special_info'])) {
|
|
|
- $this->special = new ugc\special($output['special_info']);
|
|
|
+
|
|
|
+ $special_id = $output['special_info']['special_id'];
|
|
|
+ $mod_special = Model('mb_special');
|
|
|
+ $special_info = $mod_special->getMbSpecialByID($special_id,'*',true);
|
|
|
+ if(!empty($special_info)) {
|
|
|
+ $this->special = new ugc\special($special_info);
|
|
|
} else {
|
|
|
$this->special = null;
|
|
|
}
|
|
@@ -218,10 +222,15 @@ class tpl_ugc
|
|
|
$this->show_items($items);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
$this->show_submit();
|
|
|
}
|
|
|
private function show_submit()
|
|
|
{
|
|
|
+ $vote_single = $this->special->vote_single();
|
|
|
+ $submitor = new ugc\special_submitor($this->special_id(),$vote_single);
|
|
|
+ if($submitor->submited()) return false;
|
|
|
+
|
|
|
$special = $this->special;
|
|
|
if($special->has_vote() || $special->has_question())
|
|
|
{
|
|
@@ -264,8 +273,16 @@ class tpl_ugc
|
|
|
elseif($show_type == 'text') {
|
|
|
$this->show_text($item);
|
|
|
}
|
|
|
- elseif($show_type == 'vote') {
|
|
|
- $this->show_vote($item);
|
|
|
+ elseif($show_type == 'vote')
|
|
|
+ {
|
|
|
+ $vote_single = $this->special->vote_single();
|
|
|
+
|
|
|
+ $submitor = new ugc\special_submitor($this->special_id(),$vote_single);
|
|
|
+ if($submitor->submited()) {
|
|
|
+ $this->show_vote_result($item);
|
|
|
+ } else {
|
|
|
+ $this->show_vote($item);
|
|
|
+ }
|
|
|
}
|
|
|
elseif($show_type == 'question') {
|
|
|
$this->show_question($item);
|
|
@@ -434,6 +451,78 @@ class tpl_ugc
|
|
|
echo $str;
|
|
|
}
|
|
|
|
|
|
+ private function show_vote_result($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 = '最多选两项';
|
|
|
+ }
|
|
|
+
|
|
|
+ $str = "<div class=\"vote\">
|
|
|
+ <div class=\"vote_pro\">
|
|
|
+ <div class=\"vote_question\">{$title}</div>
|
|
|
+ <div class=\"vote_type\" data-type=\"{$vote_type}\">/{$svote_type}</div>
|
|
|
+ </div>";
|
|
|
+
|
|
|
+ $str .= '<div class="results">';
|
|
|
+ $result = $this->special->vote_result();
|
|
|
+ $total = 0;
|
|
|
+ foreach ($result as $key => $val) {
|
|
|
+ $total += $val;
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($options as $val)
|
|
|
+ {
|
|
|
+ $id = $val['id'];
|
|
|
+ $title = $val['text'];
|
|
|
+
|
|
|
+ $count = $result[$id];
|
|
|
+ if($total > 0) {
|
|
|
+ $per = intval($count * 100 / $total + 0.5);
|
|
|
+ } else {
|
|
|
+ $per = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ $option = "<div class=\"result\">
|
|
|
+ <div class=\"result_option\">{$title}</div>
|
|
|
+ <div class=\"status\">
|
|
|
+ <div class=\"status_line\">
|
|
|
+ <div class=\"stat\"></div>
|
|
|
+ <div class=\"status_bg\"></div>
|
|
|
+ </div>
|
|
|
+ <span class=\"num\">{$count}票</span>
|
|
|
+ <span class=\"percentage\">{$per}%</span>
|
|
|
+ </div>
|
|
|
+ </div>";
|
|
|
+ $str .= $option;
|
|
|
+ }
|
|
|
+ $str .= '</div></div>';
|
|
|
+
|
|
|
+ echo $str;
|
|
|
+ }
|
|
|
+
|
|
|
private function show_text($item)
|
|
|
{
|
|
|
$data = $item['data'];
|
|
@@ -486,6 +575,7 @@ class tpl_ugc
|
|
|
<div class="pro">
|
|
|
<div class="pro_title">评论/</div>
|
|
|
</div>
|
|
|
+ <div class="comment_list"></div>
|
|
|
</div>';
|
|
|
echo $pret;
|
|
|
|