...
|
...
|
@@ -4,7 +4,7 @@ |
|
|
* 所有Controller控制器的基类
|
|
|
*
|
|
|
* @name AbstractAction
|
|
|
* @package
|
|
|
* @package library
|
|
|
* @copyright yoho.inc
|
|
|
* @version 1.0 (2015-9-15 11:55:25)
|
|
|
* @author fei.hong <fei.hong@yoho.cn>
|
...
|
...
|
@@ -25,6 +25,12 @@ class AbstractAction extends Controller_Abstract |
|
|
* @var object
|
|
|
*/
|
|
|
protected $_request;
|
|
|
|
|
|
/**
|
|
|
* 用户相关信息
|
|
|
*/
|
|
|
protected $_uid;
|
|
|
protected $_uname;
|
|
|
|
|
|
/**
|
|
|
* 初始化
|
...
|
...
|
@@ -35,13 +41,13 @@ class AbstractAction extends Controller_Abstract |
|
|
|
|
|
// 设置环境变量
|
|
|
switch (APPLICATION_ENV) {
|
|
|
case 'production':
|
|
|
case 'production': // 生产
|
|
|
$this->_view->assign('rlsEnv', true);
|
|
|
break;
|
|
|
case 'testing':
|
|
|
case 'testing': // 测试
|
|
|
$this->_view->assign('testEnv', true);
|
|
|
break;
|
|
|
case 'develop':
|
|
|
case 'develop': // 开发
|
|
|
default:
|
|
|
$this->_view->assign('devEnv', true);
|
|
|
break;
|
...
|
...
|
@@ -144,7 +150,7 @@ class AbstractAction extends Controller_Abstract |
|
|
* @param integer $path cookie可用的路径
|
|
|
* @param string $domain cookie可用域名
|
|
|
*/
|
|
|
protected function setCookie($name, $value, $expire = 0, $path = '/',$domain = 'yohobuy.com')
|
|
|
protected function setCookie($name, $value, $expire = 0, $path = '/', $domain = '.yohobuy.com')
|
|
|
{
|
|
|
setcookie($name, $value, $expire, $path, $domain);
|
|
|
}
|
...
|
...
|
@@ -158,7 +164,7 @@ class AbstractAction extends Controller_Abstract |
|
|
*/
|
|
|
protected function getCookie($name, $default = '')
|
|
|
{
|
|
|
return $this->request->getCookie($name, $default);
|
|
|
return $this->_request->getCookie($name, $default);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -198,7 +204,17 @@ class AbstractAction extends Controller_Abstract |
|
|
*/
|
|
|
protected function getUid()
|
|
|
{
|
|
|
return 0;
|
|
|
if (!$this->_uid) {
|
|
|
$cookie = $this->getCookie('_UID');
|
|
|
if (!empty($cookie)) {
|
|
|
$cookieList = explode('::', $cookie);
|
|
|
if (isset($cookieList[1]) && is_numeric($cookieList)) {
|
|
|
$this->_uid = $cookieList[1];
|
|
|
$this->_uname = $cookieList[0];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return $this->_uid;
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -215,6 +231,26 @@ class AbstractAction extends Controller_Abstract |
|
|
}
|
|
|
return $udid;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取当前登录的用户名字
|
|
|
*
|
|
|
* @return int
|
|
|
* @todo
|
|
|
*/
|
|
|
protected function getUname()
|
|
|
{
|
|
|
if (!$this->_uname) {
|
|
|
$cookie = $this->getCookie('_UID');
|
|
|
if (!empty($cookie)) {
|
|
|
$cookieList = explode('::', $cookie);
|
|
|
if (isset($cookieList[0])) {
|
|
|
$this->_uname = $cookieList[0];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return $this->_uname;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 设置网站SEO的标题
|
...
|
...
|
@@ -284,17 +320,18 @@ class AbstractAction extends Controller_Abstract |
|
|
$footer = array();
|
|
|
|
|
|
// 已登录 @todo
|
|
|
if (false) {
|
|
|
$name = $this->getUname();
|
|
|
if (!empty($name)) {
|
|
|
$footer['user'] = array();
|
|
|
$footer['user']['name'] = 'goodboy'; // 昵称
|
|
|
$footer['user']['name'] = $name; // 昵称
|
|
|
$footer['user']['url'] = ''; // 个人中心链接
|
|
|
$footer['user']['signoutUrl'] = ''; // 登出链接
|
|
|
$footer['user']['signoutUrl'] = '/passport/login/out'; // 登出链接
|
|
|
}
|
|
|
// 未登录
|
|
|
else {
|
|
|
$footer = array();
|
|
|
$footer['loginUrl'] = '/signin.html'; // 登录链接
|
|
|
$footer['signupUrl'] = '/login.html'; // 注册链接
|
|
|
$footer['signupUrl'] = '/reg.html'; // 注册链接
|
|
|
}
|
|
|
|
|
|
$this->_view->assign('pageFooter', $footer);
|
...
|
...
|
@@ -313,25 +350,25 @@ class AbstractAction extends Controller_Abstract |
|
|
'textCn' => '男生',
|
|
|
'textEn' => 'BOYS',
|
|
|
'styleClass' => 'boys',
|
|
|
'url' => '/boys.html',
|
|
|
'url' => '/boys',
|
|
|
),
|
|
|
1 => array(
|
|
|
'textCn' => '女生',
|
|
|
'textEn' => 'GIRLS',
|
|
|
'styleClass' => 'girls',
|
|
|
'url' => '/girls.html',
|
|
|
'url' => '/girls',
|
|
|
),
|
|
|
2 => array(
|
|
|
'textCn' => '潮童',
|
|
|
'textEn' => 'KIDS',
|
|
|
'styleClass' => 'kids',
|
|
|
'url' => '/kids.html',
|
|
|
'url' => '/kids',
|
|
|
),
|
|
|
3 => array(
|
|
|
'textCn' => '创意生活',
|
|
|
'textEn' => 'LIFE STYLE',
|
|
|
'styleClass' => 'life',
|
|
|
'url' => '/life.html',
|
|
|
'url' => '/life',
|
|
|
),
|
|
|
4 => array(
|
|
|
'textCn' => '逛',
|
...
|
...
|
|