public function __construct($request, $response, $params = NULL) { parent::__construct($request, $response, $params); if (!$this->user->hasLogin()) { $this->response->redirect($this->some->___loginUrl() . '?redir=' . $this->request->getRequestUrl()); } }
public function __construct($request, $response, $params = NULL) { parent::__construct($request, $response, $params); if (!$this->user->hasLogin()) { $this->response->redirect($this->some->___loginUrl() . '?redir=' . $this->request->getRequestUrl()); } /** 初始化皮肤路径 */ $this->_themeDir = rtrim($this->options->themeFile($this->options->theme), '/') . '/'; }
/** * 构造函数,初始化组件 * * @param mixed $request * @param mixed $response * @param mixed $params * @throws Typecho_Widget_Exception */ public function __construct($request, $response, $params = NULL) { parent::__construct($request, $response, $params); $this->parameter->setDefault(array('pageSize' => $this->options->pageSize, 'type' => NULL, 'checkPermalink' => true)); /** 用于判断是路由调用还是外部调用 */ if (NULL == $this->parameter->type) { $this->parameter->type = Typecho_Router::$current; } else { $this->_invokeFromOutside = true; } /** 用于判断是否为feed调用 */ if ($this->parameter->isFeed) { $this->_invokeByFeed = true; } /** 初始化皮肤路径 */ $this->_themeDir = rtrim($this->options->themeFile($this->options->theme), '/') . '/'; /** 处理feed模式 **/ if ('feed' == $this->parameter->type) { $this->_currentFeedUrl = ''; /** 判断聚合类型 */ switch (true) { case 0 === strpos($this->request->feed, '/rss/') || '/rss' == $this->request->feed: /** 如果是RSS1标准 */ $this->request->feed = substr($this->request->feed, 4); $this->_feedType = Typecho_Feed::RSS1; $this->_currentFeedUrl = $this->options->feedRssUrl; $this->_feedContentType = 'application/rdf+xml'; break; case 0 === strpos($this->request->feed, '/atom/') || '/atom' == $this->request->feed: /** 如果是ATOM标准 */ $this->request->feed = substr($this->request->feed, 5); $this->_feedType = Typecho_Feed::ATOM1; $this->_currentFeedUrl = $this->options->feedAtomUrl; $this->_feedContentType = 'application/atom+xml'; break; default: $this->_feedType = Typecho_Feed::RSS2; $this->_currentFeedUrl = $this->options->feedUrl; $this->_feedContentType = 'application/rss+xml'; break; } $feedQuery = $this->request->feed; //$this->parameter->type = Typecho_Router::$current; //$this->request->setParams($params); if ('/comments/' == $feedQuery || '/comments' == $feedQuery) { /** 专为feed使用的hack */ $this->parameter->type = 'comments'; } else { $matched = Typecho_Router::match($this->request->feed, 'pageSize=10&isFeed=1'); if ($matched && $matched instanceof Widget_Archive) { $this->import($matched); } else { throw new Typecho_Widget_Exception(_t('聚合页不存在'), 404); } } /** 初始化聚合器 */ $this->setFeed(new Typecho_Feed(Typecho_Common::VERSION, $this->_feedType, $this->options->charset, _t('zh-CN'))); /** 默认输出10则文章 **/ $this->parameter->pageSize = 10; } }