Show.class.php
2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
class Controller_Show extends Controller_Abstract
{
public function indexAction()
{
$total = 0;
$limit = 24;
$offset = 0;
$page = new Lib_Helper_Pagination($total, $limit);
list($offset, $limit) = $page->getLimit();
$this->_view['fragments'] = $this->getShowTopicFragment($offset, $limit, $total);
$page->setRecordCount($total);
$this->_view['pagination'] = $page->getPagination();
}
/**
* 客户端html5
*
*/
public function clientAction()
{
$banner = '';
$total = 0;
$platforms = array('android' => array('scheme' =>'yohoshow://', 'download' => 'http://demo.yoho.cn/uploads/Android/show/1.4.0/release/YohoShow_1.4.0_70_9454_YOHO.apk'), 'ios'=> array('scheme' =>'yohoshow://', 'download' => 'https://itunes.apple.com/cn/app/yoho!-you-huo/id794364666?mt=8'));
$yohoshowState = $this->_request->query('yohoshowState', 0);
$platform = Lib_Utils::agentToPlatform($_SERVER['HTTP_USER_AGENT']);
$offset = $this->_request->query('offset', 0);
$limit = $this->_request->query('limit', 24);
$isAjax = $this->_request->query('isAjax', 0);
if($isAjax || $this->_request->isAjax())
{
$isAjax = 1;
}
else
{
$isAjax = 0;
}
if($platform != 'android')
{
$platform = 'ios';
}
if($yohoshowState)
{
$url = $platforms[$platform]['scheme'];
}
else
{
$url = $platforms[$platform]['download'];
}
$this->_view['url'] = $url;
$this->_view['fragments'] = $this->getShowTopicFragment($offset, $limit, $total, $banner);
$this->_view['banner'] = $banner;
$this->_view['yohoshowState'] = $yohoshowState;
$this->_view['offset'] = $offset;
$this->_view['limit'] = $limit;
$this->_view['isAjax'] = $isAjax;
$this->_viewname = 'clientmobile';
}
/**
* 获取show话题
*
* @param int $offset
* @param int $limit
* @param int $total
* @param string $banner
* @return array
*/
private function getShowTopicFragment($offset, $limit, &$total = 0, &$banner = '')
{
$params = array(
'offset'=> $offset,
'limit' => $limit,
);
$data = Util_Curl::get('http://www.yohoshow.com/api/yohood/topic?'.http_build_query($params));
$data = json_decode($data, true);
if(!empty($data['data']))
{
$list = $data['data']['list'];
$total = $data['data']['totalCount'];
$banner = $data['data']['bannerUrl'];
}
return $list;
}
}