GalleryController.php
7.23 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?php
class GalleryController extends QLib_Controller_Default_Action
{
private $maxSize = 200;
public function indexAction()
{
$this->view->windowOpen = $windowOpen = $this->helpGquery('windowOpen', 0);
if ($windowOpen == 1) {
$this->_helper->layout()->setLayout('notheard');
}
$this->QLayoutScript()->offsetSetFile(2, $this->_js('jquery.wookmark'))
//->appendFile($this->_js('modernizr-transitions'))
->appendFile($this->_js('jquery.infinitescroll'))
->appendFile($this->_js('jquery.lazyload.mini'));
$this->QLayoutLink()->offsetSetStylesheet(20, $this->_css('style_css'))
->appendStylesheet($this->_css('style_css'))
->appendStylesheet($this->_css('photogallery'));
$title = 'YOHO!有货潮品型录 最新最全的人气潮品集合';
$keywords = '2012新品,2012超人气单品,2012热销TEE,2012热销短裤,2012最新潮鞋,2012经典,潮流小物集合';
$description = '2012最新最全潮流单品集合,品牌授权,100%正品保证';
$this->setMetaInfo($title, $keywords, $description);
$this->view->marking = $marking = $this->helpGquery('page', 1);
$total = QCGallery_Models_Client::getGalleryTotalView();
$this->view->paging = $paging = $this->helpPaging()->setTotal($total)->setSize($this->maxSize);
$galleryList = QCGallery_Models_Client::getGalleryListView($paging->getOffset(), 40, $marking);
$galleryListKey = array_keys($galleryList);
$this->view->pageData = implode(',', $galleryListKey);
$this->view->galleryList = $galleryList;
}
public function showAction()
{
$this->QLayoutLink()->offsetSetStylesheet(20, $this->_css('style_css'))
->appendStylesheet($this->_css('style_css'))
->appendStylesheet($this->_css('photogallery'));
$gallery_id = (int)$this->helpGparam('gallery_id');
$this->view->page_data = $page_data = $this->helpGquery('page_data');
$this->view->galleryInfo = $galleryInfo = QCGallery_Models_Client::getOne($gallery_id);
$product = array();
if (!empty($galleryInfo['product'])) {
foreach ($galleryInfo['product'] as $infokey => $infoval) {
if (!empty($infoval['storage'])) {
$product = $infoval;
break;
}
}
}
if (empty($product) && !empty($galleryInfo['product'])) {
$product = array_shift($galleryInfo['product']);
}
$title = $product['product_name'] . ' | YOHO!有货 100%正品保证';
$keywords = $product['style'];
$description = empty($product['phrase']) ? $product['product_name'] : $product['phrase'];
$this->setMetaInfo($title, $keywords, $description);
if (empty($galleryInfo)) {
$this->helpGo('/gallery');
}
$pageData = explode(',', $page_data);
$leftGalleryID = 0;
$rightGalleryID = 0;
$hitGalleryId = 0;
foreach ($pageData as $gallery_id_key) {
if ($hitGalleryId > 0) {
$rightGalleryID = $gallery_id_key;
break;
}
if ($gallery_id == $gallery_id_key) {
$hitGalleryId = $gallery_id_key;
continue;
}
$leftGalleryID = $gallery_id_key;
}
$this->view->isLike = 0;
$this->view->isFavorite = 0;
if ($this->uid > 0) {
$this->view->isLike = QCGallery_Models_Favorite_Client::checkUserFavorite($gallery_id, $this->uid, 2);
$this->view->isFavorite = QCGallery_Models_Favorite_Client::checkUserFavorite($gallery_id, $this->uid, 1);
}
$this->view->leftGalleryID = $leftGalleryID;
$this->view->rightGalleryID = $rightGalleryID;
}
public function nextAction()
{
$this->_helper->layout()->disableLayout();
$galleryList = array();
$galleryListKey = array();
$total = QCGallery_Models_Client::getGalleryTotalView();
$paging = $this->helpPaging()->setTotal($total)->setSize(20);
if ($paging->getOffset() < $this->maxSize) {
$page = $this->helpGquery('page', 1);
$marking = (int)Q_Utils_Function::base64_url_decode($this->helpGquery('marking'));
if ($page <= $paging->getPageNum()) {
$offset = $paging->getOffset();
if ($marking > 1) {
$markingPage = $this->helpPaging()->setTotal($total)->setSize($this->maxSize)->setCurrent($marking);
$offset = $markingPage->getOffset() + $paging->getOffset();
}
$galleryList = QCGallery_Models_Client::getGalleryListView($offset, $paging->getSize(), $marking);
}
$galleryListKey = array_keys($galleryList);
}
$this->view->pageData = implode(',', $galleryListKey);
$this->view->galleryList = $galleryList;
}
public function mouseoverAction()
{
$this->_helper->layout()->disableLayout();
$gallery_id = (int)$this->helpGquery('gallery_id');
$uid = (int)$this->helpIsLogin();
$data = array(
'like' => 0,
'favorite' => 0
);
if ($uid > 0) {
$data = array(
//1是收藏2是喜欢,pd里有写
'like' => QCGallery_Models_Favorite_Client::checkUserFavorite($gallery_id, $uid, 2),
'favorite' => QCGallery_Models_Favorite_Client::checkUserFavorite($gallery_id, $uid, 1),
'likeNum' => QCGallery_Models_Favorite_Client::getGalleryFavoriteCount($gallery_id, 2),
'favoriteNum' => QCGallery_Models_Favorite_Client::getGalleryFavoriteCount($gallery_id)
);
}
$this->helpJsonResult(200, 'mouseover action', $data);
}
public function clickAction()
{
$type = $this->helpGquery('type');
if ($type != 1 && $type != 2) {
$this->helpJsonResult('400', '点击错误.');
}
$gallery_id = $this->helpGquery('gallery_id');
$uid = (int)$this->helpIsLogin();
if ($uid < 1) {
$this->helpJsonResult('500', '请登陆后在点击.');
}
$checkTotal = QCGallery_Models_Favorite_Client::checkUserFavorite($gallery_id, $uid, $type);
if ($checkTotal > 0) {
$this->helpJsonResult('201', '', array('click' => 0));
}
QCGallery_Models_Favorite_Client::setGalleryFavorete($gallery_id, $uid, $type);
$this->helpJsonResult('200', 'click gallery', array('click' => 1));
}
public function updateattrAction()
{
set_time_limit(0);
$galleryList = QCGallery_Models_Client::getAttrIsNull(100);
foreach ($galleryList as $key => $val) {
$image = QLib_Images_Client::QFSFImages($val['image_url'], 'yohopin', '200x600');
$imagesAr = @getimagesize($image);
if ($imagesAr == false) {
echo $key . "<br />";
continue;
}
list($width, $height, $type, $attr) = $imagesAr;
if (!empty($attr)) {
QCGallery_Models_Client::updateAttr($attr, $val['id']);
}
}
die('ok');
}
}