public function display($func, $params) { $params['background'] = $this->is_root ? 'url(images/17183518883b16614c2fe8.jpg)' : 'url(images/37fa8df7da45fd6c8a44a1664021a5df.jpg)'; if (TechlogTools::isMobile()) { $params['background'] = '#F2F0F1'; } $pattern = '/^(?<class>.+)Controller::(?<func>.+)Action/is'; if (preg_match($pattern, $func, $arr) == false) { header('Location: /index/notfound'); exit; } $class = strtolower($arr['class']); $func = strtolower($arr['func']); $file = $class . '/' . $func . '.php'; $params['is_root'] = $this->is_root; $params['is_mobile'] = TechlogTools::isMobile(); if (empty($class) || empty($func) || !file_exists(VIEW_PATH . '/' . $file)) { header("Location: /index/notfound"); } else { require VIEW_PATH . '/' . $file; } }
private function getArticle($article_id) { $params = array(); $params = array('eq' => array('article_id' => $article_id)); if (!$this->is_root) { $params['lt'] = array('category_id' => 5); } $article = Repository::findOneFromArticle($params); if ($article == false) { header("Location: /index/notfound"); return; } $params['tags'] = SqlRepository::getTags($article_id); $params['title'] = $article->get_title(); $params['indexs'] = json_decode($article->get_indexs()); $params['contents'] = TechlogTools::pre_treat_article($article->get_draft()); $params['title_desc'] = $article->get_title_desc(); $params['article_id'] = $article->get_article_id(); $params['comment_count'] = intval($article->get_comment_count()); $params['article_category_id'] = $article->get_category_id(); $comments_params = array('eq' => array('article_id' => $article_id), 'order' => array('inserttime' => 'asc')); if (!$this->is_root) { $comments_params['eq']['online'] = 1; } $params['comments'] = Repository::findFromComment($comments_params); if (StringOpt::spider_string($params['contents'], '"page-header"', '</div>') === null && !TechlogTools::isMobile()) { $params['contents'] = '<div class="page-header"><h1>' . $article->get_title() . '</h1></div>' . $params['contents']; } $article->set_access_count($article->get_access_count() + 1); Repository::persist($article); $params['inserttime'] = $article->get_inserttime() . ' 最后更新: ' . $article->get_updatetime() . ' 访问数量:' . ($article->get_access_count() + 1); return $params; }