|
@@ -16,8 +16,6 @@ use think\exception\HttpException;
|
|
|
|
|
|
use app\model\Category as CategoryModel;
|
|
|
use app\model\Article as ArticleModel;
|
|
|
-use app\model\ArticleBrowerHistory;
|
|
|
-use app\model\ArticleTags as ArticleTagsModel;
|
|
|
use app\model\ArticleDolikeLog;
|
|
|
use app\model\Tag;
|
|
|
use app\model\TagArticle;
|
|
@@ -36,31 +34,12 @@ class Article extends Base
|
|
|
|
|
|
$list = ArticleModel::queryPage($params);
|
|
|
|
|
|
- $category = CategoryModel::find($params['cid']);
|
|
|
-
|
|
|
- if ($category) {
|
|
|
- $baseUrl = $category->url;
|
|
|
- } else {
|
|
|
- $baseUrl = '/index/all';
|
|
|
- }
|
|
|
-
|
|
|
View::assign([
|
|
|
- 'baseUrl' => $baseUrl,
|
|
|
- 'list' => $list->all(),
|
|
|
- 'total' => $list->total(),
|
|
|
- 'limit' => $list->listRows(),
|
|
|
- 'page' => $list->currentPage(),
|
|
|
- 'lastPage' => $list->lastPage(),
|
|
|
- 'pagelist' => $list->render(),
|
|
|
- 'cid' => $params['cid'],
|
|
|
+ 'list' => $list,
|
|
|
+ 'cid' => $params['cid']
|
|
|
]);
|
|
|
|
|
|
- $html = View::fetch();
|
|
|
- // if ($this->html) {
|
|
|
- // $this->makeHtmlFile($html);
|
|
|
- // }
|
|
|
-
|
|
|
- return $html;
|
|
|
+ return View::fetch();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -74,30 +53,6 @@ class Article extends Base
|
|
|
throw new HttpException(404, '页面不存在');
|
|
|
}
|
|
|
|
|
|
- $ip = $this->request->ip();
|
|
|
- $time = time();
|
|
|
- $abh = ArticleBrowerHistory::getByIpAid($ip, $id);
|
|
|
-
|
|
|
- if (!$abh) {
|
|
|
- $data->hits += 1;
|
|
|
-
|
|
|
- $data->isAutoWriteTimestamp(false)->save();
|
|
|
-
|
|
|
- ArticleBrowerHistory::create([
|
|
|
- 'ip' => $ip,
|
|
|
- 'aid'=> $id,
|
|
|
- 'create_time' => $time
|
|
|
- ]);
|
|
|
- } else {
|
|
|
- $createTime = $abh->create_time;
|
|
|
-
|
|
|
- if ($createTime + 24*3600 < $time) {
|
|
|
- $data->hits += 1;
|
|
|
-
|
|
|
- $data->isAutoWriteTimestamp(false)->save();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
$prev_next = ArticleModel::getNextPrev($id, $data->cid);
|
|
|
|
|
|
if ($data->content_type == 1) {
|
|
@@ -117,9 +72,7 @@ class Article extends Base
|
|
|
$this->seo['des'] = $data->summary;
|
|
|
View::assign('seo', $this->seo);
|
|
|
|
|
|
- $html = View::fetch();
|
|
|
-
|
|
|
- return $html;
|
|
|
+ return View::fetch();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -167,7 +120,7 @@ class Article extends Base
|
|
|
throw new HttpException(404, '标签不存在');
|
|
|
}
|
|
|
|
|
|
- $list = TagArticle::queryList($tag->tid);
|
|
|
+ $list = TagArticle::queryList($tag->id);
|
|
|
|
|
|
View::assign([
|
|
|
'list' => $list,
|
|
@@ -182,30 +135,21 @@ class Article extends Base
|
|
|
*/
|
|
|
public function archive($year = 0, $month = 0)
|
|
|
{
|
|
|
- $yearMonth = $year . '-' . $month;
|
|
|
-
|
|
|
if ($year == 0 || $month == 0) {
|
|
|
throw new HttpException(404, '日期格式不正确');
|
|
|
}
|
|
|
+ $yearMonth = $year . '-' . $month;
|
|
|
+
|
|
|
+ $params = $this->app->request->param();
|
|
|
|
|
|
- $list = ArticleModel::queryPage(['yearMonth' => $yearMonth]);
|
|
|
+ $list = ArticleModel::queryPage($params);
|
|
|
|
|
|
View::assign([
|
|
|
- 'list' => $list->all(),
|
|
|
- 'total' => $list->total(),
|
|
|
- 'limit' => $list->listRows(),
|
|
|
- 'page' => $list->currentPage(),
|
|
|
- 'lastPage' => $list->lastPage(),
|
|
|
- 'pagelist' => $list->render(),
|
|
|
+ 'list' => $list,
|
|
|
'yearMonth' => $yearMonth
|
|
|
]);
|
|
|
|
|
|
- $html = View::fetch();
|
|
|
- // if ($this->html) {
|
|
|
- // $this->makeHtmlFile($html);
|
|
|
- // }
|
|
|
-
|
|
|
- return $html;
|
|
|
+ return View::fetch();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -213,20 +157,30 @@ class Article extends Base
|
|
|
*/
|
|
|
public function time()
|
|
|
{
|
|
|
- $params = ['order' => 'update_time desc'];
|
|
|
+ $params = $this->app->request->param();
|
|
|
+
|
|
|
$list = ArticleModel::queryPage($params);
|
|
|
|
|
|
- View::assign([
|
|
|
- 'list' => $list->all(),
|
|
|
- 'total' => $list->total(),
|
|
|
- 'limit' => $list->listRows(),
|
|
|
- 'page' => $list->currentPage(),
|
|
|
- 'lastPage' => $list->lastPage(),
|
|
|
- 'pagelist' => $list->render(),
|
|
|
- ]);
|
|
|
+ View::assign('list', $list);
|
|
|
|
|
|
- $html = View::fetch();
|
|
|
+ return View::fetch();
|
|
|
+ }
|
|
|
|
|
|
- return $html;
|
|
|
+ /**
|
|
|
+ * 文章搜索
|
|
|
+ */
|
|
|
+ public function search()
|
|
|
+ {
|
|
|
+ $key = $this->app->request->has('key') ? $this->app->request->param('key') : "";
|
|
|
+
|
|
|
+ if ($key != "") {
|
|
|
+ $params = $this->app->request->param();
|
|
|
+ $list = ArticleModel::queryPage($params);
|
|
|
+ View::assign('list', $list);
|
|
|
+ }
|
|
|
+
|
|
|
+ View::assign("key", $key);
|
|
|
+
|
|
|
+ return View::fetch();
|
|
|
}
|
|
|
}
|