public function indexAction() { $id = Comm\Arg::get('id', FILTER_VALIDATE_INT); $result = Model\Theme\Resource::show($id); if (empty($result)) { throw new Exception\Msg('指定模板资源不存在'); } //判断是否为只读 $main = Model\Theme\Main::show($result['tpl_id']); try { Model\User::validateAuth($main['user_id']); $readonly = false; } catch (Exception $e) { $readonly = true; } Comm\Response::json(100000, 'succ', array('content' => $result['content'], 'readonly' => $readonly), false); }
public function indexAction() { $theme = Comm\Arg::get('theme', FILTER_VALIDATE_INT, ['min_range' => 0], true); $resource = Comm\Arg::get('resource', FILTER_DEFAULT, null, true); Yaf_Registry::set('tpl_id', $theme); switch ($resource) { //预览首页 case 'home': $pager = new Comm\Pager(1000, 20, 1); $articles = Model\Article::showUserList($pager); Model\Publish::home($articles, $pager, null, false); break; //预览分类下的文章列表 //预览分类下的文章列表 case 'article-list': $pager = new Comm\Pager(1000, 20, 1); $articles = Model\Article::showUserList(new Comm\Pager(1, 1, 1)); if (!$articles) { throw new Exception\Msg(_('至少发表一篇文章才可预览')); } $article = reset($articles['result']); $category = Model\Category::show($article['category_id']); $articles = Model\Article::showUserList($pager, false, $category['id']); $articles = isset($articles['result']) ? $articles['result'] : array(); Model\Publish::categoryArticleList($category, $articles, $pager, null, false); break; //预览文章 //预览文章 case 'article': $articles = Model\Article::showUserList(new Comm\Pager(1, 1, 1)); $article = reset($articles['result']); Model\Publish::article($article, false); break; //预览导航 //预览导航 case 'sidebar': Model\Publish::sidebar(false, false); break; default: throw new \Exception\Msg('本资源不支持预览'); } }
public function indexAction() { $last_page = Comm\Arg::get('last_page', FILTER_VALIDATE_INT, ['min_range' => 1]) ?: 0; $page = Comm\Arg::get('p', FILTER_VALIDATE_INT, ['min_range' => 1]) ?: 1; $uid = Yaf_Registry::get('current_uid'); //获取总数 $total = Model\Counter\Article::get(0, $uid); //获取用户的博客配置中的分页设置 $blog = Model\Blog::show(); empty($blog['data']['page_count']) || ($this->_limit = $blog['data']['page_count']); //获取分页参数 $pager = new \Comm\Pager($total, $this->_limit); //获取数据 $articles = Model\Article::showUserList($pager); //获取分类内容 $categorys = Model\Category::showUserAll(); $categorys = Comm\Arr::hashmap($categorys, 'id'); //获取用户博客基本地址 $blog_url = 'http://' . \Model\Github::showDefaultBlogRepoName(); $this->viewDisplay(array('articles' => $articles, 'categorys' => $categorys, 'pager' => $pager, 'blog_url' => $blog_url)); }