|
@@ -25,6 +25,12 @@ class AbstractAction extends Controller_Abstract |
|
@@ -25,6 +25,12 @@ class AbstractAction extends Controller_Abstract |
25
|
* @var object
|
25
|
* @var object
|
26
|
*/
|
26
|
*/
|
27
|
protected $_request;
|
27
|
protected $_request;
|
|
|
28
|
+
|
|
|
29
|
+ /**
|
|
|
30
|
+ * 用户相关信息
|
|
|
31
|
+ */
|
|
|
32
|
+ protected $_uid;
|
|
|
33
|
+ protected $_uname;
|
28
|
|
34
|
|
29
|
/**
|
35
|
/**
|
30
|
* 初始化
|
36
|
* 初始化
|
|
@@ -144,7 +150,7 @@ class AbstractAction extends Controller_Abstract |
|
@@ -144,7 +150,7 @@ class AbstractAction extends Controller_Abstract |
144
|
* @param integer $path cookie可用的路径
|
150
|
* @param integer $path cookie可用的路径
|
145
|
* @param string $domain cookie可用域名
|
151
|
* @param string $domain cookie可用域名
|
146
|
*/
|
152
|
*/
|
147
|
- protected function setCookie($name, $value, $expire = 0, $path = '/',$domain = 'yohobuy.com')
|
153
|
+ protected function setCookie($name, $value, $expire = 0, $path = '/', $domain = '.yohobuy.com')
|
148
|
{
|
154
|
{
|
149
|
setcookie($name, $value, $expire, $path, $domain);
|
155
|
setcookie($name, $value, $expire, $path, $domain);
|
150
|
}
|
156
|
}
|
|
@@ -158,7 +164,7 @@ class AbstractAction extends Controller_Abstract |
|
@@ -158,7 +164,7 @@ class AbstractAction extends Controller_Abstract |
158
|
*/
|
164
|
*/
|
159
|
protected function getCookie($name, $default = '')
|
165
|
protected function getCookie($name, $default = '')
|
160
|
{
|
166
|
{
|
161
|
- return $this->request->getCookie($name, $default);
|
167
|
+ return $this->_request->getCookie($name, $default);
|
162
|
}
|
168
|
}
|
163
|
|
169
|
|
164
|
/**
|
170
|
/**
|
|
@@ -198,7 +204,17 @@ class AbstractAction extends Controller_Abstract |
|
@@ -198,7 +204,17 @@ class AbstractAction extends Controller_Abstract |
198
|
*/
|
204
|
*/
|
199
|
protected function getUid()
|
205
|
protected function getUid()
|
200
|
{
|
206
|
{
|
201
|
- return 0;
|
207
|
+ if (!$this->_uid) {
|
|
|
208
|
+ $cookie = $this->getCookie('_UID');
|
|
|
209
|
+ if (!empty($cookie)) {
|
|
|
210
|
+ $cookieList = explode('::', $cookie);
|
|
|
211
|
+ if (isset($cookieList[1]) && is_numeric($cookieList)) {
|
|
|
212
|
+ $this->_uid = $cookieList[1];
|
|
|
213
|
+ $this->_uname = $cookieList[0];
|
|
|
214
|
+ }
|
|
|
215
|
+ }
|
|
|
216
|
+ }
|
|
|
217
|
+ return $this->_uid;
|
202
|
}
|
218
|
}
|
203
|
|
219
|
|
204
|
/**
|
220
|
/**
|
|
@@ -215,6 +231,26 @@ class AbstractAction extends Controller_Abstract |
|
@@ -215,6 +231,26 @@ class AbstractAction extends Controller_Abstract |
215
|
}
|
231
|
}
|
216
|
return $udid;
|
232
|
return $udid;
|
217
|
}
|
233
|
}
|
|
|
234
|
+
|
|
|
235
|
+ /**
|
|
|
236
|
+ * 获取当前登录的用户名字
|
|
|
237
|
+ *
|
|
|
238
|
+ * @return int
|
|
|
239
|
+ * @todo
|
|
|
240
|
+ */
|
|
|
241
|
+ protected function getUname()
|
|
|
242
|
+ {
|
|
|
243
|
+ if (!$this->_uname) {
|
|
|
244
|
+ $cookie = $this->getCookie('_UID');
|
|
|
245
|
+ if (!empty($cookie)) {
|
|
|
246
|
+ $cookieList = explode('::', $cookie);
|
|
|
247
|
+ if (isset($cookieList[0])) {
|
|
|
248
|
+ $this->_uname = $cookieList[0];
|
|
|
249
|
+ }
|
|
|
250
|
+ }
|
|
|
251
|
+ }
|
|
|
252
|
+ return $this->_uname;
|
|
|
253
|
+ }
|
218
|
|
254
|
|
219
|
/*
|
255
|
/*
|
220
|
* 设置网站SEO的标题
|
256
|
* 设置网站SEO的标题
|
|
@@ -284,17 +320,18 @@ class AbstractAction extends Controller_Abstract |
|
@@ -284,17 +320,18 @@ class AbstractAction extends Controller_Abstract |
284
|
$footer = array();
|
320
|
$footer = array();
|
285
|
|
321
|
|
286
|
// 已登录 @todo
|
322
|
// 已登录 @todo
|
287
|
- if (false) {
|
323
|
+ $name = $this->getUname();
|
|
|
324
|
+ if (!empty($name)) {
|
288
|
$footer['user'] = array();
|
325
|
$footer['user'] = array();
|
289
|
- $footer['user']['name'] = 'goodboy'; // 昵称
|
326
|
+ $footer['user']['name'] = $name; // 昵称
|
290
|
$footer['user']['url'] = ''; // 个人中心链接
|
327
|
$footer['user']['url'] = ''; // 个人中心链接
|
291
|
- $footer['user']['signoutUrl'] = ''; // 登出链接
|
328
|
+ $footer['user']['signoutUrl'] = '/passport/login/out'; // 登出链接
|
292
|
}
|
329
|
}
|
293
|
// 未登录
|
330
|
// 未登录
|
294
|
else {
|
331
|
else {
|
295
|
$footer = array();
|
332
|
$footer = array();
|
296
|
$footer['loginUrl'] = '/signin.html'; // 登录链接
|
333
|
$footer['loginUrl'] = '/signin.html'; // 登录链接
|
297
|
- $footer['signupUrl'] = '/login.html'; // 注册链接
|
334
|
+ $footer['signupUrl'] = '/reg.html'; // 注册链接
|
298
|
}
|
335
|
}
|
299
|
|
336
|
|
300
|
$this->_view->assign('pageFooter', $footer);
|
337
|
$this->_view->assign('pageFooter', $footer);
|