...
|
...
|
@@ -9,11 +9,11 @@ |
|
|
* @version 1.0 (2015-9-15 11:55:25)
|
|
|
* @author fei.hong <fei.hong@yoho.cn>
|
|
|
*/
|
|
|
|
|
|
namespace Action;
|
|
|
|
|
|
use Yaf\Controller_Abstract;
|
|
|
use Yaf\Dispatcher;
|
|
|
|
|
|
use Hood\Cache;
|
|
|
|
|
|
class AbstractAction extends Controller_Abstract
|
...
|
...
|
@@ -57,7 +57,7 @@ class AbstractAction extends Controller_Abstract |
|
|
{
|
|
|
return $this->_request->getPost($key, $default);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 使用Memcache缓存
|
|
|
*
|
...
|
...
|
@@ -67,13 +67,16 @@ class AbstractAction extends Controller_Abstract |
|
|
*/
|
|
|
protected function memcache($node = null, $childNode = 'hosts')
|
|
|
{
|
|
|
// WINDOWS
|
|
|
if (PATH_SEPARATOR === '\\') {
|
|
|
return Cache::memcache($node, $childNode);
|
|
|
} else {
|
|
|
}
|
|
|
// LINUX
|
|
|
else {
|
|
|
return Cache::memcached($node, $childNode);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 关闭模板自动渲染
|
|
|
*
|
...
|
...
|
@@ -83,7 +86,7 @@ class AbstractAction extends Controller_Abstract |
|
|
{
|
|
|
Dispatcher::getInstance()->autoRender(false);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 输出JSON数据到浏览器
|
|
|
*
|
...
|
...
|
@@ -92,14 +95,14 @@ class AbstractAction extends Controller_Abstract |
|
|
protected function echoJson($json)
|
|
|
{
|
|
|
headers_sent() || header('Content-Type: application/json; charset=utf-8;');
|
|
|
if(is_array($json))
|
|
|
{
|
|
|
|
|
|
if (is_array($json)) {
|
|
|
$json = json_encode($json);
|
|
|
}
|
|
|
|
|
|
|
|
|
echo $json;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 返回JSON数据
|
|
|
*
|
...
|
...
|
@@ -116,7 +119,7 @@ class AbstractAction extends Controller_Abstract |
|
|
'data' => $data,
|
|
|
));
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 判断是不是AJAX请求
|
|
|
*
|
...
|
...
|
@@ -126,17 +129,17 @@ class AbstractAction extends Controller_Abstract |
|
|
{
|
|
|
return $this->_request->isXmlHttpRequest();
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 跳转到错误页面
|
|
|
*/
|
|
|
protected function error()
|
|
|
{
|
|
|
headers_sent() || header('Location: /error.html');
|
|
|
|
|
|
|
|
|
exit;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 设置网站SEO的标题
|
|
|
*
|
...
|
...
|
@@ -147,7 +150,7 @@ class AbstractAction extends Controller_Abstract |
|
|
{
|
|
|
$this->_view->assign('title', $title);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 设置网站SEO的关键词
|
|
|
*
|
...
|
...
|
@@ -158,7 +161,7 @@ class AbstractAction extends Controller_Abstract |
|
|
{
|
|
|
$this->_view->assign('keywords', $keywords);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 设置网站SEO的描述内容
|
|
|
*
|
...
|
...
|
@@ -169,7 +172,7 @@ class AbstractAction extends Controller_Abstract |
|
|
{
|
|
|
$this->_view->assign('description', $description);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 设置网站导航头部信息
|
|
|
*
|
...
|
...
|
@@ -191,10 +194,10 @@ class AbstractAction extends Controller_Abstract |
|
|
if (!empty($homeUrl)) {
|
|
|
$header['pageHeader']['navHome'] = $homeUrl;
|
|
|
}
|
|
|
|
|
|
|
|
|
$this->_view->assign('header', $header);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 设置网站导航底部信息
|
|
|
*
|
...
|
...
|
@@ -203,21 +206,21 @@ class AbstractAction extends Controller_Abstract |
|
|
protected function setNavFooter()
|
|
|
{
|
|
|
$footer = array();
|
|
|
|
|
|
|
|
|
// 已登录 @todo
|
|
|
if (false) {
|
|
|
$footer['pageFooter']['user'] = array();
|
|
|
$footer['pageFooter']['user']['name'] = 'goodboy'; // 昵称
|
|
|
$footer['pageFooter']['user']['url'] = ''; // 个人中心链接
|
|
|
$footer['pageFooter']['user']['signoutUrl'] = ''; // 登出链接
|
|
|
}
|
|
|
}
|
|
|
// 未登录
|
|
|
else {
|
|
|
$footer['pageFooter'] = array();
|
|
|
$footer['pageFooter']['loginUrl'] = ''; // 登录链接
|
|
|
$footer['pageFooter']['signupUrl'] = ''; // 注册链接
|
|
|
}
|
|
|
|
|
|
|
|
|
$this->_view->assign('footer', $footer);
|
|
|
}
|
|
|
|
...
|
...
|
|