Showing
1 changed file
with
24 additions
and
21 deletions
@@ -9,11 +9,11 @@ | @@ -9,11 +9,11 @@ | ||
9 | * @version 1.0 (2015-9-15 11:55:25) | 9 | * @version 1.0 (2015-9-15 11:55:25) |
10 | * @author fei.hong <fei.hong@yoho.cn> | 10 | * @author fei.hong <fei.hong@yoho.cn> |
11 | */ | 11 | */ |
12 | + | ||
12 | namespace Action; | 13 | namespace Action; |
13 | 14 | ||
14 | use Yaf\Controller_Abstract; | 15 | use Yaf\Controller_Abstract; |
15 | use Yaf\Dispatcher; | 16 | use Yaf\Dispatcher; |
16 | - | ||
17 | use Hood\Cache; | 17 | use Hood\Cache; |
18 | 18 | ||
19 | class AbstractAction extends Controller_Abstract | 19 | class AbstractAction extends Controller_Abstract |
@@ -57,7 +57,7 @@ class AbstractAction extends Controller_Abstract | @@ -57,7 +57,7 @@ class AbstractAction extends Controller_Abstract | ||
57 | { | 57 | { |
58 | return $this->_request->getPost($key, $default); | 58 | return $this->_request->getPost($key, $default); |
59 | } | 59 | } |
60 | - | 60 | + |
61 | /** | 61 | /** |
62 | * 使用Memcache缓存 | 62 | * 使用Memcache缓存 |
63 | * | 63 | * |
@@ -67,13 +67,16 @@ class AbstractAction extends Controller_Abstract | @@ -67,13 +67,16 @@ class AbstractAction extends Controller_Abstract | ||
67 | */ | 67 | */ |
68 | protected function memcache($node = null, $childNode = 'hosts') | 68 | protected function memcache($node = null, $childNode = 'hosts') |
69 | { | 69 | { |
70 | + // WINDOWS | ||
70 | if (PATH_SEPARATOR === '\\') { | 71 | if (PATH_SEPARATOR === '\\') { |
71 | return Cache::memcache($node, $childNode); | 72 | return Cache::memcache($node, $childNode); |
72 | - } else { | 73 | + } |
74 | + // LINUX | ||
75 | + else { | ||
73 | return Cache::memcached($node, $childNode); | 76 | return Cache::memcached($node, $childNode); |
74 | } | 77 | } |
75 | } | 78 | } |
76 | - | 79 | + |
77 | /** | 80 | /** |
78 | * 关闭模板自动渲染 | 81 | * 关闭模板自动渲染 |
79 | * | 82 | * |
@@ -83,7 +86,7 @@ class AbstractAction extends Controller_Abstract | @@ -83,7 +86,7 @@ class AbstractAction extends Controller_Abstract | ||
83 | { | 86 | { |
84 | Dispatcher::getInstance()->autoRender(false); | 87 | Dispatcher::getInstance()->autoRender(false); |
85 | } | 88 | } |
86 | - | 89 | + |
87 | /** | 90 | /** |
88 | * 输出JSON数据到浏览器 | 91 | * 输出JSON数据到浏览器 |
89 | * | 92 | * |
@@ -92,14 +95,14 @@ class AbstractAction extends Controller_Abstract | @@ -92,14 +95,14 @@ class AbstractAction extends Controller_Abstract | ||
92 | protected function echoJson($json) | 95 | protected function echoJson($json) |
93 | { | 96 | { |
94 | headers_sent() || header('Content-Type: application/json; charset=utf-8;'); | 97 | headers_sent() || header('Content-Type: application/json; charset=utf-8;'); |
95 | - if(is_array($json)) | ||
96 | - { | 98 | + |
99 | + if (is_array($json)) { | ||
97 | $json = json_encode($json); | 100 | $json = json_encode($json); |
98 | } | 101 | } |
99 | - | 102 | + |
100 | echo $json; | 103 | echo $json; |
101 | } | 104 | } |
102 | - | 105 | + |
103 | /** | 106 | /** |
104 | * 返回JSON数据 | 107 | * 返回JSON数据 |
105 | * | 108 | * |
@@ -116,7 +119,7 @@ class AbstractAction extends Controller_Abstract | @@ -116,7 +119,7 @@ class AbstractAction extends Controller_Abstract | ||
116 | 'data' => $data, | 119 | 'data' => $data, |
117 | )); | 120 | )); |
118 | } | 121 | } |
119 | - | 122 | + |
120 | /** | 123 | /** |
121 | * 判断是不是AJAX请求 | 124 | * 判断是不是AJAX请求 |
122 | * | 125 | * |
@@ -126,17 +129,17 @@ class AbstractAction extends Controller_Abstract | @@ -126,17 +129,17 @@ class AbstractAction extends Controller_Abstract | ||
126 | { | 129 | { |
127 | return $this->_request->isXmlHttpRequest(); | 130 | return $this->_request->isXmlHttpRequest(); |
128 | } | 131 | } |
129 | - | 132 | + |
130 | /** | 133 | /** |
131 | * 跳转到错误页面 | 134 | * 跳转到错误页面 |
132 | */ | 135 | */ |
133 | protected function error() | 136 | protected function error() |
134 | { | 137 | { |
135 | headers_sent() || header('Location: /error.html'); | 138 | headers_sent() || header('Location: /error.html'); |
136 | - | 139 | + |
137 | exit; | 140 | exit; |
138 | } | 141 | } |
139 | - | 142 | + |
140 | /** | 143 | /** |
141 | * 设置网站SEO的标题 | 144 | * 设置网站SEO的标题 |
142 | * | 145 | * |
@@ -147,7 +150,7 @@ class AbstractAction extends Controller_Abstract | @@ -147,7 +150,7 @@ class AbstractAction extends Controller_Abstract | ||
147 | { | 150 | { |
148 | $this->_view->assign('title', $title); | 151 | $this->_view->assign('title', $title); |
149 | } | 152 | } |
150 | - | 153 | + |
151 | /** | 154 | /** |
152 | * 设置网站SEO的关键词 | 155 | * 设置网站SEO的关键词 |
153 | * | 156 | * |
@@ -158,7 +161,7 @@ class AbstractAction extends Controller_Abstract | @@ -158,7 +161,7 @@ class AbstractAction extends Controller_Abstract | ||
158 | { | 161 | { |
159 | $this->_view->assign('keywords', $keywords); | 162 | $this->_view->assign('keywords', $keywords); |
160 | } | 163 | } |
161 | - | 164 | + |
162 | /** | 165 | /** |
163 | * 设置网站SEO的描述内容 | 166 | * 设置网站SEO的描述内容 |
164 | * | 167 | * |
@@ -169,7 +172,7 @@ class AbstractAction extends Controller_Abstract | @@ -169,7 +172,7 @@ class AbstractAction extends Controller_Abstract | ||
169 | { | 172 | { |
170 | $this->_view->assign('description', $description); | 173 | $this->_view->assign('description', $description); |
171 | } | 174 | } |
172 | - | 175 | + |
173 | /** | 176 | /** |
174 | * 设置网站导航头部信息 | 177 | * 设置网站导航头部信息 |
175 | * | 178 | * |
@@ -191,10 +194,10 @@ class AbstractAction extends Controller_Abstract | @@ -191,10 +194,10 @@ class AbstractAction extends Controller_Abstract | ||
191 | if (!empty($homeUrl)) { | 194 | if (!empty($homeUrl)) { |
192 | $header['pageHeader']['navHome'] = $homeUrl; | 195 | $header['pageHeader']['navHome'] = $homeUrl; |
193 | } | 196 | } |
194 | - | 197 | + |
195 | $this->_view->assign('header', $header); | 198 | $this->_view->assign('header', $header); |
196 | } | 199 | } |
197 | - | 200 | + |
198 | /** | 201 | /** |
199 | * 设置网站导航底部信息 | 202 | * 设置网站导航底部信息 |
200 | * | 203 | * |
@@ -203,21 +206,21 @@ class AbstractAction extends Controller_Abstract | @@ -203,21 +206,21 @@ class AbstractAction extends Controller_Abstract | ||
203 | protected function setNavFooter() | 206 | protected function setNavFooter() |
204 | { | 207 | { |
205 | $footer = array(); | 208 | $footer = array(); |
206 | - | 209 | + |
207 | // 已登录 @todo | 210 | // 已登录 @todo |
208 | if (false) { | 211 | if (false) { |
209 | $footer['pageFooter']['user'] = array(); | 212 | $footer['pageFooter']['user'] = array(); |
210 | $footer['pageFooter']['user']['name'] = 'goodboy'; // 昵称 | 213 | $footer['pageFooter']['user']['name'] = 'goodboy'; // 昵称 |
211 | $footer['pageFooter']['user']['url'] = ''; // 个人中心链接 | 214 | $footer['pageFooter']['user']['url'] = ''; // 个人中心链接 |
212 | $footer['pageFooter']['user']['signoutUrl'] = ''; // 登出链接 | 215 | $footer['pageFooter']['user']['signoutUrl'] = ''; // 登出链接 |
213 | - } | 216 | + } |
214 | // 未登录 | 217 | // 未登录 |
215 | else { | 218 | else { |
216 | $footer['pageFooter'] = array(); | 219 | $footer['pageFooter'] = array(); |
217 | $footer['pageFooter']['loginUrl'] = ''; // 登录链接 | 220 | $footer['pageFooter']['loginUrl'] = ''; // 登录链接 |
218 | $footer['pageFooter']['signupUrl'] = ''; // 注册链接 | 221 | $footer['pageFooter']['signupUrl'] = ''; // 注册链接 |
219 | } | 222 | } |
220 | - | 223 | + |
221 | $this->_view->assign('footer', $footer); | 224 | $this->_view->assign('footer', $footer); |
222 | } | 225 | } |
223 | 226 |
-
Please register or login to post a comment