diff --git a/core/function.php b/core/function.php index e231de3..6c46094 100644 --- a/core/function.php +++ b/core/function.php @@ -2,7 +2,7 @@ /* 获取主题当前版本号 */ function _getVersion() { - return "6.8.9"; + return "6.9.0"; }; /* 判断是否是手机 */ diff --git a/core/route.php b/core/route.php index 73052b3..a4e23e5 100644 --- a/core/route.php +++ b/core/route.php @@ -28,7 +28,7 @@ function _getRanking($self) /* 获取文章列表 已测试 √ */ function _getPost($self) { - header("HTTP/1.1 200 OK"); + header("HTTP/1.1 200 OK"); header('Access-Control-Allow-Origin:*'); header("Access-Control-Allow-Headers:Origin, X-Requested-With, Content-Type, Accept"); @@ -54,7 +54,7 @@ function _getPost($self) if ($sticky_text && $page == 1) { $sticky_arr = explode("||", $sticky_text); foreach ($sticky_arr as $cid) { - $self->widget('Widget_Archive@' . $cid, 'pageSize=1&type=post', 'cid=' . $cid)->to($item); + $self->widget('Widget_Contents_Post@' . $cid, 'cid=' . $cid)->to($item); if ($item->next()) { $result[] = array( "mode" => $item->fields->mode ? $item->fields->mode : 'default', @@ -101,7 +101,7 @@ function _handleViews($self) header("HTTP/1.1 200 OK"); header('Access-Control-Allow-Origin:*'); header("Access-Control-Allow-Headers:Origin, X-Requested-With, Content-Type, Accept"); - $cid = $self->request->cid; + $cid = $self->request->cid; /* sql注入校验 */ if (!preg_match('/^\d+$/', $cid)) { return $self->response->throwJson(array("code" => 0, "data" => "非法请求!已屏蔽!")); diff --git a/core/widget.php b/core/widget.php index c8235b5..c145e24 100644 --- a/core/widget.php +++ b/core/widget.php @@ -40,3 +40,20 @@ class Widget_Contents_Sort extends Widget_Abstract_Contents ); } } + +class Widget_Contents_Post extends Widget_Abstract_Contents +{ + public function execute() + { + $select = $this->select(); + $select->cleanAttribute('fields'); + $this->db->fetchAll( + $select + ->from('table.contents') + ->where('table.contents.type = ?', 'post') + ->where('table.contents.cid = ?', $this->parameter->cid) + ->limit(1), + array($this, 'push') + ); + } +} diff --git a/index.php b/index.php index f79fde7..dc31421 100644 --- a/index.php +++ b/index.php @@ -72,7 +72,7 @@
- widget('Widget_Archive@' . $cid, 'pageSize=1&type=post', 'cid=' . $cid)->to($item); ?> + widget('Widget_Contents_Post@' . $cid, 'cid=' . $cid)->to($item); ?>
<?php $item->title() ?> diff --git a/package.json b/package.json index 829ddab..cda0dd9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typecho-joe-next", - "version": "6.8.9", + "version": "6.9.0", "description": "A Theme Of Typecho", "main": "index.php", "keywords": [