/** * @brief showUser 显示某用户发布的文章 * * @param $params 传入参数 * * @return void */ public function showUser($params) { // 根据 uid 获取 用户信息 $user = new UserLibrary(); $user->setUID($params['uid']); if (!($u = $user->getUser())) { Response::error(404); return; } // 获取文章数据 Widget::initWidget('Post'); Widget::getWidget('Post')->setPerPage(8); Widget::getWidget('Post')->setCurrentPage(isset($params['page']) ? $params['page'] : 1); Widget::getWidget('Post')->setAuthor($u['uid']); Widget::getWidget('Post')->query(); // 设置标题、描述、关键词 Widget::getWidget('Global')->title = urldecode($u['username']); $this->display('index.php'); }
/** * @brief postAuthor 输出文章作者 * * @return void */ public function postAuthor() { // 检查是否有文章 if (!$this->postHave()) { return; } $author = $this->posts[$this->currentPost - 1]['uid']; $user = new UserLibrary(); $user->setUID($author); $u = $user->getUser(); echo '<a href="' . Router::patch('Author', array('uid' => $author)) . '">' . $u['username'] . '</a>'; }