diff --git a/app/Http/Web/Views/course/list.volt b/app/Http/Web/Views/course/list.volt
index 25ad59e0..52aed001 100644
--- a/app/Http/Web/Views/course/list.volt
+++ b/app/Http/Web/Views/course/list.volt
@@ -4,6 +4,8 @@
{{ partial('course/list_filter') }}
+ {% set pager_url = url({'for':'web.course.pager'}, params) %}
+
{% endblock %}
diff --git a/app/Http/Web/Views/help/index.volt b/app/Http/Web/Views/help/index.volt
new file mode 100644
index 00000000..eec8c6c6
--- /dev/null
+++ b/app/Http/Web/Views/help/index.volt
@@ -0,0 +1,14 @@
+{% extends 'templates/full.volt' %}
+
+{% block content %}
+
+
+ {% for help in helps %}
+
+
{{ help.title }}
+
{{ help.content }}
+
+ {% endfor %}
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/app/Http/Web/Views/page/show.volt b/app/Http/Web/Views/page/show.volt
new file mode 100644
index 00000000..cbee24d8
--- /dev/null
+++ b/app/Http/Web/Views/page/show.volt
@@ -0,0 +1,9 @@
+{% extends 'templates/full.volt' %}
+
+{% block content %}
+
+
{{ page.title }}
+
+
{{ page.content }}
+
+{% endblock %}
\ No newline at end of file
diff --git a/app/Http/Web/Views/teacher/list.volt b/app/Http/Web/Views/teacher/list.volt
index 01a9334a..2f581f08 100644
--- a/app/Http/Web/Views/teacher/list.volt
+++ b/app/Http/Web/Views/teacher/list.volt
@@ -2,33 +2,19 @@
{% block content %}
+ {% set pager_url = url({'for':'web.teacher.pager'}) %}
+
- {% if pager.total_pages > 0 %}
-
-
- {% for item in pager.items %}
- {% set user_title = item.title ? item.title : '小小教书匠' %}
- {% set user_about = item.about ? item.about|e : '这个人很懒,什么都没留下' %}
- {% set user_url = url({'for':'web.teacher.show','id':item.id}) %}
-
-
-
-

-
-
-
{{ user_title }}
-
-
- {% endfor %}
-
-
- {{ partial('partials/pager') }}
- {% endif %}
+
+
+{% endblock %}
+
+{% block include_js %}
+
+ {{ js_include('web/js/teacher.list.js') }}
{% endblock %}
\ No newline at end of file
diff --git a/app/Http/Web/Views/teacher/list_pager.volt b/app/Http/Web/Views/teacher/list_pager.volt
new file mode 100644
index 00000000..6cb4e625
--- /dev/null
+++ b/app/Http/Web/Views/teacher/list_pager.volt
@@ -0,0 +1,23 @@
+{% if pager.total_pages > 0 %}
+
+
+ {% for item in pager.items %}
+ {% set user_title = item.title ? item.title : '小小教书匠' %}
+ {% set user_about = item.about ? item.about|e : '这个人很懒,什么都没留下' %}
+ {% set user_url = url({'for':'web.teacher.show','id':item.id}) %}
+
+
+
+

+
+
+
{{ user_title }}
+
+
+ {% endfor %}
+
+
+ {{ partial('partials/pager_ajax') }}
+{% endif %}
diff --git a/app/Http/Web/Views/topic/courses.volt b/app/Http/Web/Views/topic/courses.volt
new file mode 100644
index 00000000..5bd3e409
--- /dev/null
+++ b/app/Http/Web/Views/topic/courses.volt
@@ -0,0 +1,14 @@
+{{ partial('partials/macro_course') }}
+
+{% if pager.total_pages > 0 %}
+
+
+ {% for item in pager.items %}
+
+ {{ course_card(item) }}
+
+ {% endfor %}
+
+
+ {{ partial('partials/pager_ajax') }}
+{% endif %}
\ No newline at end of file
diff --git a/app/Http/Web/Views/topic/show.volt b/app/Http/Web/Views/topic/show.volt
new file mode 100644
index 00000000..11c2f8e6
--- /dev/null
+++ b/app/Http/Web/Views/topic/show.volt
@@ -0,0 +1,19 @@
+{% extends 'templates/full.volt' %}
+
+{% block content %}
+
+ {% set courses_url = url({'for':'web.topic.courses','id':topic.id}) %}
+
+
+
{{ topic.title }}
+
+
+
+
+{% endblock %}
+
+{% block include_js %}
+
+ {{ js_include('web/js/topic.show.js') }}
+
+{% endblock %}
\ No newline at end of file
diff --git a/app/Library/Cache/Backend/Redis.php b/app/Library/Cache/Backend/Redis.php
index aec875cf..c78ad6f2 100644
--- a/app/Library/Cache/Backend/Redis.php
+++ b/app/Library/Cache/Backend/Redis.php
@@ -16,8 +16,8 @@ class Redis extends \Phalcon\Cache\Backend\Redis
/**
* {@inheritdoc}
*
- * @param string $keyName
- * @param int $lifetime
+ * @param string $keyName
+ * @param int $lifetime
* @return mixed|null
*/
public function get($keyName, $lifetime = null)
@@ -49,15 +49,15 @@ class Redis extends \Phalcon\Cache\Backend\Redis
/**
* {@inheritdoc}
*
- * @param string $keyName
- * @param string $content
- * @param int $lifetime
- * @param bool $stopBuffer
+ * @param string $keyName
+ * @param string $content
+ * @param int $lifetime
+ * @param bool $stopBuffer
* @return bool
*
* @throws Exception
*/
- public function save($keyName = null, $content = null, $lifetime = null, $stopBuffer = true)
+ public function save($keyName = null, $content = null, $lifetime = null, bool $stopBuffer = true): bool
{
if ($keyName === null) {
$lastKey = $this->_lastKey;
@@ -127,10 +127,10 @@ class Redis extends \Phalcon\Cache\Backend\Redis
/**
* {@inheritdoc}
*
- * @param string $keyName
+ * @param string $keyName
* @return bool
*/
- public function delete($keyName)
+ public function delete($keyName): bool
{
$redis = $this->getRedis();
@@ -142,10 +142,10 @@ class Redis extends \Phalcon\Cache\Backend\Redis
/**
* {@inheritdoc}
*
- * @param string $prefix
+ * @param string $prefix
* @return array
*/
- public function queryKeys($prefix = null)
+ public function queryKeys($prefix = null): array
{
$result = [];
@@ -167,11 +167,11 @@ class Redis extends \Phalcon\Cache\Backend\Redis
/**
* {@inheritdoc}
*
- * @param string $keyName
- * @param string $lifetime
+ * @param string $keyName
+ * @param string $lifetime
* @return bool
*/
- public function exists($keyName = null, $lifetime = null)
+ public function exists($keyName = null, $lifetime = null): bool
{
$redis = $this->getRedis();
@@ -191,7 +191,7 @@ class Redis extends \Phalcon\Cache\Backend\Redis
* @param int $value
* @return int
*/
- public function increment($keyName = null, $value = 1)
+ public function increment($keyName = null, $value = 1): int
{
$redis = $this->getRedis();
@@ -211,7 +211,7 @@ class Redis extends \Phalcon\Cache\Backend\Redis
* @param int $value
* @return int
*/
- public function decrement($keyName = null, $value = 1)
+ public function decrement($keyName = null, $value = 1): int
{
$redis = $this->getRedis();
@@ -229,7 +229,7 @@ class Redis extends \Phalcon\Cache\Backend\Redis
*
* @return bool
*/
- public function flush()
+ public function flush(): bool
{
}
diff --git a/app/Library/Http/Request.php b/app/Library/Http/Request.php
index 6bc88c92..d88e43ef 100644
--- a/app/Library/Http/Request.php
+++ b/app/Library/Http/Request.php
@@ -8,7 +8,7 @@ class Request extends \Phalcon\Http\Request
/**
* @return bool
*/
- public function isAjax()
+ public function isAjax(): bool
{
if (parent::isAjax()) {
return true;
@@ -26,7 +26,7 @@ class Request extends \Phalcon\Http\Request
/**
* @return bool
*/
- public function isApi()
+ public function isApi(): bool
{
$url = $this->get('_url');
diff --git a/app/Library/Http/Response.php b/app/Library/Http/Response.php
index 3281b841..b7fdc7c5 100644
--- a/app/Library/Http/Response.php
+++ b/app/Library/Http/Response.php
@@ -2,14 +2,16 @@
namespace App\Library\Http;
+use Phalcon\Http\ResponseInterface;
+
class Response extends \Phalcon\Http\Response
{
- public function setJsonContent($content, $jsonOptions = 0, $depth = 512)
+ public function setJsonContent($content, $jsonOptions = 0, $depth = 512): ResponseInterface
{
$jsonOptions = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION;
- parent::setJsonContent($content, $jsonOptions, $depth);
+ return parent::setJsonContent($content, $jsonOptions, $depth);
}
}
\ No newline at end of file
diff --git a/app/Library/Mvc/View.php b/app/Library/Mvc/View.php
index e32fbcb4..77ef13c6 100644
--- a/app/Library/Mvc/View.php
+++ b/app/Library/Mvc/View.php
@@ -2,10 +2,12 @@
namespace App\Library\Mvc;
-class View extends \Phalcon\Mvc\View
+use Phalcon\Mvc\View as PhView;
+
+class View extends PhView
{
- public function setVars(array $params, $merge = true)
+ public function setVars(array $params, bool $merge = true): PhView
{
foreach ($params as $key => $param) {
if (is_array($param)) {
@@ -13,16 +15,16 @@ class View extends \Phalcon\Mvc\View
}
}
- parent::setVars($params, $merge);
+ return parent::setVars($params, $merge);
}
- public function setVar($key, $value)
+ public function setVar(string $key, $value): PhView
{
if (is_array($value)) {
$value = kg_array_object($value);
}
- parent::setVar($key, $value);
+ return parent::setVar($key, $value);
}
}
\ No newline at end of file
diff --git a/app/Library/Paginator/Adapter/QueryBuilder.php b/app/Library/Paginator/Adapter/QueryBuilder.php
index f23fc4ce..c826866b 100644
--- a/app/Library/Paginator/Adapter/QueryBuilder.php
+++ b/app/Library/Paginator/Adapter/QueryBuilder.php
@@ -4,6 +4,7 @@ namespace App\Library\Paginator\Adapter;
use App\Library\Paginator\Query;
use Phalcon\Paginator\Adapter\QueryBuilder as BaseQueryBuilder;
+use stdClass;
class QueryBuilder extends BaseQueryBuilder
{
@@ -12,7 +13,7 @@ class QueryBuilder extends BaseQueryBuilder
protected $params = [];
- public function paginate()
+ public function paginate(): stdClass
{
$pager = parent::paginate();
diff --git a/app/Models/AccessToken.php b/app/Models/AccessToken.php
index eadd87f6..f3ff5b05 100644
--- a/app/Models/AccessToken.php
+++ b/app/Models/AccessToken.php
@@ -47,7 +47,7 @@ class AccessToken extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_access_token';
}
diff --git a/app/Models/Account.php b/app/Models/Account.php
index 1aff0846..1461a6dc 100644
--- a/app/Models/Account.php
+++ b/app/Models/Account.php
@@ -63,7 +63,7 @@ class Account extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_account';
}
diff --git a/app/Models/Audit.php b/app/Models/Audit.php
index 91a48c87..afe748b0 100644
--- a/app/Models/Audit.php
+++ b/app/Models/Audit.php
@@ -61,7 +61,7 @@ class Audit extends Model
*/
public $create_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_audit';
}
diff --git a/app/Models/Category.php b/app/Models/Category.php
index 4402e719..1e48b380 100644
--- a/app/Models/Category.php
+++ b/app/Models/Category.php
@@ -92,7 +92,7 @@ class Category extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_category';
}
diff --git a/app/Models/Chapter.php b/app/Models/Chapter.php
index c147d91f..82a4af1b 100644
--- a/app/Models/Chapter.php
+++ b/app/Models/Chapter.php
@@ -174,7 +174,7 @@ class Chapter extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_chapter';
}
diff --git a/app/Models/ChapterLive.php b/app/Models/ChapterLive.php
index be9c8faa..75def952 100644
--- a/app/Models/ChapterLive.php
+++ b/app/Models/ChapterLive.php
@@ -61,7 +61,7 @@ class ChapterLive extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_chapter_live';
}
diff --git a/app/Models/ChapterRead.php b/app/Models/ChapterRead.php
index 446e8791..ec3a6d7c 100644
--- a/app/Models/ChapterRead.php
+++ b/app/Models/ChapterRead.php
@@ -60,7 +60,7 @@ class ChapterRead extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_chapter_read';
}
diff --git a/app/Models/ChapterUser.php b/app/Models/ChapterUser.php
index 5ade5b66..cde7c085 100644
--- a/app/Models/ChapterUser.php
+++ b/app/Models/ChapterUser.php
@@ -91,7 +91,7 @@ class ChapterUser extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_chapter_user';
}
diff --git a/app/Models/ChapterVod.php b/app/Models/ChapterVod.php
index 6c40e18b..52cbe08d 100644
--- a/app/Models/ChapterVod.php
+++ b/app/Models/ChapterVod.php
@@ -56,7 +56,7 @@ class ChapterVod extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_chapter_vod';
}
diff --git a/app/Models/ChapterVote.php b/app/Models/ChapterVote.php
index 6365932a..6f284619 100644
--- a/app/Models/ChapterVote.php
+++ b/app/Models/ChapterVote.php
@@ -63,7 +63,7 @@ class ChapterVote extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_chapter_vote';
}
diff --git a/app/Models/Comment.php b/app/Models/Comment.php
index 693bba9c..65ee4da5 100644
--- a/app/Models/Comment.php
+++ b/app/Models/Comment.php
@@ -107,7 +107,7 @@ class Comment extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_comment';
}
diff --git a/app/Models/CommentVote.php b/app/Models/CommentVote.php
index 635c57e9..b8df55c5 100644
--- a/app/Models/CommentVote.php
+++ b/app/Models/CommentVote.php
@@ -63,7 +63,7 @@ class CommentVote extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_comment_vote';
}
diff --git a/app/Models/Consult.php b/app/Models/Consult.php
index ab980a5f..943e4f8f 100644
--- a/app/Models/Consult.php
+++ b/app/Models/Consult.php
@@ -91,7 +91,7 @@ class Consult extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_consult';
}
diff --git a/app/Models/ConsultVote.php b/app/Models/ConsultVote.php
index 2d32cc6a..3bf0ca77 100644
--- a/app/Models/ConsultVote.php
+++ b/app/Models/ConsultVote.php
@@ -56,7 +56,7 @@ class ConsultVote extends Model
*/
public $create_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_consult_vote';
}
diff --git a/app/Models/ContentImage.php b/app/Models/ContentImage.php
index 50598c60..f15c73a2 100644
--- a/app/Models/ContentImage.php
+++ b/app/Models/ContentImage.php
@@ -42,7 +42,7 @@ class ContentImage extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_content_image';
}
diff --git a/app/Models/Course.php b/app/Models/Course.php
index ec082c64..71b2df3f 100644
--- a/app/Models/Course.php
+++ b/app/Models/Course.php
@@ -241,7 +241,7 @@ class Course extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_course';
}
diff --git a/app/Models/CourseCategory.php b/app/Models/CourseCategory.php
index 4d821002..32eec7c6 100644
--- a/app/Models/CourseCategory.php
+++ b/app/Models/CourseCategory.php
@@ -33,7 +33,7 @@ class CourseCategory extends Model
*/
public $create_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_course_category';
}
diff --git a/app/Models/CourseFavorite.php b/app/Models/CourseFavorite.php
index e1a87301..eda06128 100644
--- a/app/Models/CourseFavorite.php
+++ b/app/Models/CourseFavorite.php
@@ -49,7 +49,7 @@ class CourseFavorite extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_course_favorite';
}
diff --git a/app/Models/CoursePackage.php b/app/Models/CoursePackage.php
index 4bdb81ef..1ea23a98 100644
--- a/app/Models/CoursePackage.php
+++ b/app/Models/CoursePackage.php
@@ -33,7 +33,7 @@ class CoursePackage extends Model
*/
public $create_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_course_package';
}
diff --git a/app/Models/CourseRelated.php b/app/Models/CourseRelated.php
index 8a06806c..4c593320 100644
--- a/app/Models/CourseRelated.php
+++ b/app/Models/CourseRelated.php
@@ -33,7 +33,7 @@ class CourseRelated extends Model
*/
public $create_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_course_related';
}
diff --git a/app/Models/CourseTopic.php b/app/Models/CourseTopic.php
index 4bd72f62..083c1aef 100644
--- a/app/Models/CourseTopic.php
+++ b/app/Models/CourseTopic.php
@@ -33,7 +33,7 @@ class CourseTopic extends Model
*/
public $create_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_course_topic';
}
diff --git a/app/Models/CourseUser.php b/app/Models/CourseUser.php
index 4405b957..a925bc9c 100644
--- a/app/Models/CourseUser.php
+++ b/app/Models/CourseUser.php
@@ -111,7 +111,7 @@ class CourseUser extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_course_user';
}
diff --git a/app/Models/Help.php b/app/Models/Help.php
index b535b8cd..6ee09917 100644
--- a/app/Models/Help.php
+++ b/app/Models/Help.php
@@ -64,7 +64,7 @@ class Help extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_help';
}
diff --git a/app/Models/ImFriendGroup.php b/app/Models/ImFriendGroup.php
index 9878dbce..7c29d685 100644
--- a/app/Models/ImFriendGroup.php
+++ b/app/Models/ImFriendGroup.php
@@ -56,7 +56,7 @@ class ImFriendGroup extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_im_friend_group';
}
diff --git a/app/Models/ImFriendMessage.php b/app/Models/ImFriendMessage.php
index 6aa00e6d..e5292659 100644
--- a/app/Models/ImFriendMessage.php
+++ b/app/Models/ImFriendMessage.php
@@ -70,7 +70,7 @@ class ImFriendMessage extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_im_friend_message';
}
diff --git a/app/Models/ImFriendUser.php b/app/Models/ImFriendUser.php
index 1d3e28fb..5f8609b3 100644
--- a/app/Models/ImFriendUser.php
+++ b/app/Models/ImFriendUser.php
@@ -61,7 +61,7 @@ class ImFriendUser extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_im_friend_user';
}
diff --git a/app/Models/ImGroup.php b/app/Models/ImGroup.php
index 91863d4b..0d5b4005 100644
--- a/app/Models/ImGroup.php
+++ b/app/Models/ImGroup.php
@@ -78,7 +78,7 @@ class ImGroup extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_im_group';
}
diff --git a/app/Models/ImGroupMessage.php b/app/Models/ImGroupMessage.php
index 080105a8..b4ac4a7c 100644
--- a/app/Models/ImGroupMessage.php
+++ b/app/Models/ImGroupMessage.php
@@ -56,7 +56,7 @@ class ImGroupMessage extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_im_group_message';
}
diff --git a/app/Models/ImGroupUser.php b/app/Models/ImGroupUser.php
index e3652d73..6f086020 100644
--- a/app/Models/ImGroupUser.php
+++ b/app/Models/ImGroupUser.php
@@ -54,7 +54,7 @@ class ImGroupUser extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_im_group_user';
}
diff --git a/app/Models/ImSystemMessage.php b/app/Models/ImSystemMessage.php
index 0e0c9b55..eb6931f2 100644
--- a/app/Models/ImSystemMessage.php
+++ b/app/Models/ImSystemMessage.php
@@ -94,7 +94,7 @@ class ImSystemMessage extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_im_system_message';
}
diff --git a/app/Models/ImUser.php b/app/Models/ImUser.php
index e1b25a39..53cfe426 100644
--- a/app/Models/ImUser.php
+++ b/app/Models/ImUser.php
@@ -79,7 +79,7 @@ class ImUser extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_im_user';
}
diff --git a/app/Models/Learning.php b/app/Models/Learning.php
index 4d7c2b55..6197defe 100644
--- a/app/Models/Learning.php
+++ b/app/Models/Learning.php
@@ -111,7 +111,7 @@ class Learning extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_learning';
}
diff --git a/app/Models/Nav.php b/app/Models/Nav.php
index dbe9bd6c..293d9607 100644
--- a/app/Models/Nav.php
+++ b/app/Models/Nav.php
@@ -117,7 +117,7 @@ class Nav extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_nav';
}
diff --git a/app/Models/Order.php b/app/Models/Order.php
index 1a18daae..01eb8e46 100644
--- a/app/Models/Order.php
+++ b/app/Models/Order.php
@@ -137,7 +137,7 @@ class Order extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_order';
}
diff --git a/app/Models/OrderStatus.php b/app/Models/OrderStatus.php
index 7e5b9660..7b33ee6d 100644
--- a/app/Models/OrderStatus.php
+++ b/app/Models/OrderStatus.php
@@ -33,7 +33,7 @@ class OrderStatus extends Model
*/
public $create_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_order_status';
}
diff --git a/app/Models/Package.php b/app/Models/Package.php
index 62a7824e..eaf5919b 100644
--- a/app/Models/Package.php
+++ b/app/Models/Package.php
@@ -78,7 +78,7 @@ class Package extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_package';
}
diff --git a/app/Models/Page.php b/app/Models/Page.php
index 9bf00e1b..a5390a87 100644
--- a/app/Models/Page.php
+++ b/app/Models/Page.php
@@ -50,7 +50,7 @@ class Page extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_page';
}
diff --git a/app/Models/RefreshToken.php b/app/Models/RefreshToken.php
index 56340449..a7929abc 100644
--- a/app/Models/RefreshToken.php
+++ b/app/Models/RefreshToken.php
@@ -47,7 +47,7 @@ class RefreshToken extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_refresh_token';
}
diff --git a/app/Models/Refund.php b/app/Models/Refund.php
index 757928bb..595b254e 100644
--- a/app/Models/Refund.php
+++ b/app/Models/Refund.php
@@ -108,7 +108,7 @@ class Refund extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_refund';
}
diff --git a/app/Models/RefundStatus.php b/app/Models/RefundStatus.php
index 15524878..c8b1b55f 100644
--- a/app/Models/RefundStatus.php
+++ b/app/Models/RefundStatus.php
@@ -33,7 +33,7 @@ class RefundStatus extends Model
*/
public $create_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_refund_status';
}
diff --git a/app/Models/Review.php b/app/Models/Review.php
index e17bddf4..11a18e1e 100644
--- a/app/Models/Review.php
+++ b/app/Models/Review.php
@@ -91,7 +91,7 @@ class Review extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_review';
}
diff --git a/app/Models/ReviewVote.php b/app/Models/ReviewVote.php
index 0ece47f5..e709d55e 100644
--- a/app/Models/ReviewVote.php
+++ b/app/Models/ReviewVote.php
@@ -56,7 +56,7 @@ class ReviewVote extends Model
*/
public $create_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_review_vote';
}
diff --git a/app/Models/Reward.php b/app/Models/Reward.php
index 099168e8..017a0258 100644
--- a/app/Models/Reward.php
+++ b/app/Models/Reward.php
@@ -49,7 +49,7 @@ class Reward extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_reward';
}
diff --git a/app/Models/Role.php b/app/Models/Role.php
index 780c579e..5ab46137 100644
--- a/app/Models/Role.php
+++ b/app/Models/Role.php
@@ -84,7 +84,7 @@ class Role extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_role';
}
diff --git a/app/Models/Setting.php b/app/Models/Setting.php
index 327ce3e9..a4bd5f01 100644
--- a/app/Models/Setting.php
+++ b/app/Models/Setting.php
@@ -33,7 +33,7 @@ class Setting extends Model
*/
public $item_value;
- public function getSource()
+ public function getSource(): string
{
return 'kg_setting';
}
diff --git a/app/Models/Slide.php b/app/Models/Slide.php
index 095f4d52..88dd82eb 100644
--- a/app/Models/Slide.php
+++ b/app/Models/Slide.php
@@ -99,7 +99,7 @@ class Slide extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_slide';
}
diff --git a/app/Models/Task.php b/app/Models/Task.php
index f38c7306..80d68642 100644
--- a/app/Models/Task.php
+++ b/app/Models/Task.php
@@ -89,7 +89,7 @@ class Task extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_task';
}
diff --git a/app/Models/Topic.php b/app/Models/Topic.php
index b5ea5077..9294fef0 100644
--- a/app/Models/Topic.php
+++ b/app/Models/Topic.php
@@ -64,7 +64,7 @@ class Topic extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_topic';
}
diff --git a/app/Models/Trade.php b/app/Models/Trade.php
index 05a767e7..cd5e345b 100644
--- a/app/Models/Trade.php
+++ b/app/Models/Trade.php
@@ -105,7 +105,7 @@ class Trade extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_trade';
}
diff --git a/app/Models/TradeStatus.php b/app/Models/TradeStatus.php
index 723d02ab..002d9742 100644
--- a/app/Models/TradeStatus.php
+++ b/app/Models/TradeStatus.php
@@ -33,7 +33,7 @@ class TradeStatus extends Model
*/
public $create_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_trade_status';
}
diff --git a/app/Models/User.php b/app/Models/User.php
index dbc3b996..f1cb233f 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -141,7 +141,7 @@ class User extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_user';
}
diff --git a/app/Models/Vip.php b/app/Models/Vip.php
index 63555cae..26453113 100644
--- a/app/Models/Vip.php
+++ b/app/Models/Vip.php
@@ -56,7 +56,7 @@ class Vip extends Model
*/
public $update_time;
- public function getSource()
+ public function getSource(): string
{
return 'kg_vip';
}
diff --git a/app/Repos/CourseTopic.php b/app/Repos/CourseTopic.php
index 5ae55624..d1d66e76 100644
--- a/app/Repos/CourseTopic.php
+++ b/app/Repos/CourseTopic.php
@@ -2,6 +2,7 @@
namespace App\Repos;
+use App\Library\Paginator\Adapter\QueryBuilder as PagerQueryBuilder;
use App\Models\CourseTopic as CourseTopicModel;
use Phalcon\Mvc\Model;
use Phalcon\Mvc\Model\Resultset;
@@ -10,6 +11,40 @@ use Phalcon\Mvc\Model\ResultsetInterface;
class CourseTopic extends Repository
{
+ public function paginate($where = [], $sort = 'latest', $page = 1, $limit = 15)
+ {
+ $builder = $this->modelsManager->createBuilder();
+
+
+ $builder->from(CourseTopicModel::class);
+
+ $builder->where('1 = 1');
+
+ if (!empty($where['course_id'])) {
+ $builder->andWhere('course_id = :course_id:', ['course_id' => $where['course_id']]);
+ }
+
+ if (!empty($where['topic_id'])) {
+ $builder->andWhere('topic_id = :topic_id:', ['topic_id' => $where['topic_id']]);
+ }
+
+ switch ($sort) {
+ default:
+ $orderBy = 'id DESC';
+ break;
+ }
+
+ $builder->orderBy($orderBy);
+
+ $pager = new PagerQueryBuilder([
+ 'builder' => $builder,
+ 'page' => $page,
+ 'limit' => $limit,
+ ]);
+
+ return $pager->paginate();
+ }
+
/**
* @param int $courseId
* @param int $topicId
diff --git a/app/Repos/Help.php b/app/Repos/Help.php
index 4b406669..30f95968 100644
--- a/app/Repos/Help.php
+++ b/app/Repos/Help.php
@@ -2,6 +2,7 @@
namespace App\Repos;
+use App\Library\Paginator\Adapter\QueryBuilder as PagerQueryBuilder;
use App\Models\Help as HelpModel;
use Phalcon\Mvc\Model;
use Phalcon\Mvc\Model\Resultset;
@@ -10,6 +11,43 @@ use Phalcon\Mvc\Model\ResultsetInterface;
class Help extends Repository
{
+ public function paginate($where = [], $sort = 'latest', $page = 1, $limit = 15)
+ {
+ $builder = $this->modelsManager->createBuilder();
+
+ $builder->from(HelpModel::class);
+
+ $builder->where('1 = 1');
+
+ if (!empty($where['title'])) {
+ $builder->andWhere('title LIKE :title:', ['title' => "%{$where['title']}%"]);
+ }
+
+ if (isset($where['published'])) {
+ $builder->andWhere('published = :published:', ['published' => $where['published']]);
+ }
+
+ if (isset($where['deleted'])) {
+ $builder->andWhere('deleted = :deleted:', ['deleted' => $where['deleted']]);
+ }
+
+ switch ($sort) {
+ default:
+ $orderBy = 'id DESC';
+ break;
+ }
+
+ $builder->orderBy($orderBy);
+
+ $pager = new PagerQueryBuilder([
+ 'builder' => $builder,
+ 'page' => $page,
+ 'limit' => $limit,
+ ]);
+
+ return $pager->paginate();
+ }
+
/**
* @param int $id
* @return HelpModel|Model|bool
diff --git a/app/Repos/Page.php b/app/Repos/Page.php
index a2f81017..e7acb1fe 100644
--- a/app/Repos/Page.php
+++ b/app/Repos/Page.php
@@ -19,6 +19,10 @@ class Page extends Repository
$builder->where('1 = 1');
+ if (!empty($where['title'])) {
+ $builder->andWhere('title LIKE :title:', ['title' => "%{$where['title']}%"]);
+ }
+
if (isset($where['published'])) {
$builder->andWhere('published = :published:', ['published' => $where['published']]);
}
diff --git a/app/Repos/Topic.php b/app/Repos/Topic.php
index 6081b976..b76f0394 100644
--- a/app/Repos/Topic.php
+++ b/app/Repos/Topic.php
@@ -21,8 +21,8 @@ class Topic extends Repository
$builder->where('1 = 1');
- if (!empty($where['user_id'])) {
- $builder->andWhere('user_id = :user_id:', ['user_id' => $where['user_id']]);
+ if (!empty($where['title'])) {
+ $builder->andWhere('title LIKE :title:', ['title' => "%{$where['title']}%"]);
}
if (isset($where['published'])) {
diff --git a/app/Services/Frontend/Help/HelpInfo.php b/app/Services/Frontend/Help/HelpInfo.php
new file mode 100644
index 00000000..2b6619b9
--- /dev/null
+++ b/app/Services/Frontend/Help/HelpInfo.php
@@ -0,0 +1,30 @@
+checkHelpCache($id);
+
+ return $this->handleHelp($help);
+ }
+
+ protected function handleHelp(HelpModel $help)
+ {
+ return [
+ 'id' => $help->id,
+ 'title' => $help->title,
+ 'content' => $help->content,
+ ];
+ }
+
+}
diff --git a/app/Services/Frontend/Help/HelpList.php b/app/Services/Frontend/Help/HelpList.php
new file mode 100644
index 00000000..8531189a
--- /dev/null
+++ b/app/Services/Frontend/Help/HelpList.php
@@ -0,0 +1,45 @@
+ 1];
+
+ $helps = $helpRepo->findAll($params);
+
+ if ($helps->count() > 0) {
+ return $this->handleHelps($helps);
+ }
+ }
+
+ /**
+ * @param HelpModel[] $helps
+ * @return array
+ */
+ protected function handleHelps($helps)
+ {
+ $items = [];
+
+ foreach ($helps as $help) {
+
+ $items[] = [
+ 'id' => $help->id,
+ 'title' => $help->title,
+ 'content' => $help->content,
+ ];
+ }
+
+ return $items;
+ }
+
+}
diff --git a/app/Services/Frontend/HelpTrait.php b/app/Services/Frontend/HelpTrait.php
new file mode 100644
index 00000000..1be74743
--- /dev/null
+++ b/app/Services/Frontend/HelpTrait.php
@@ -0,0 +1,24 @@
+checkHelp($id);
+ }
+
+ public function checkHelpCache($id)
+ {
+ $validator = new HelpValidator();
+
+ return $validator->checkHelpCache($id);
+ }
+
+}
diff --git a/app/Services/Frontend/Topic/CourseList.php b/app/Services/Frontend/Topic/CourseList.php
index 8ade19cd..ad6aa2c2 100644
--- a/app/Services/Frontend/Topic/CourseList.php
+++ b/app/Services/Frontend/Topic/CourseList.php
@@ -2,7 +2,9 @@
namespace App\Services\Frontend\Topic;
-use App\Caches\TopicCourseList as TopicCourseListCache;
+use App\Builders\CourseTopicList as CourseTopicListBuilder;
+use App\Library\Paginator\Query as PagerQuery;
+use App\Repos\CourseTopic as CourseTopicRepo;
use App\Services\Frontend\Service as FrontendService;
use App\Services\Frontend\TopicTrait;
@@ -15,11 +17,34 @@ class CourseList extends FrontendService
{
$topic = $this->checkTopicCache($id);
- $cache = new TopicCourseListCache();
+ $pagerQuery = new PagerQuery();
- $result = $cache->get($topic->id);
+ $sort = $pagerQuery->getSort();
+ $page = $pagerQuery->getPage();
+ $limit = $pagerQuery->getLimit();
- return $result ?: [];
+ $params = ['topic_id' => $topic->id];
+
+ $courseTopicRepo = new CourseTopicRepo();
+
+ $pager = $courseTopicRepo->paginate($params, $sort, $page, $limit);
+
+ return $this->handleCourses($pager);
+ }
+
+ protected function handleCourses($pager)
+ {
+ if ($pager->total_items == 0) {
+ return $pager;
+ }
+
+ $builder = new CourseTopicListBuilder();
+
+ $relations = $pager->items->toArray();
+
+ $pager->items = $builder->getCourses($relations);
+
+ return $pager;
}
}
diff --git a/app/Services/Frontend/Topic/TopicInfo.php b/app/Services/Frontend/Topic/TopicInfo.php
index a6595d76..70250ec7 100644
--- a/app/Services/Frontend/Topic/TopicInfo.php
+++ b/app/Services/Frontend/Topic/TopicInfo.php
@@ -23,8 +23,7 @@ class TopicInfo extends FrontendService
return [
'id' => $topic->id,
'title' => $topic->title,
- 'summary' => $topic->about,
- 'course_count' => $topic->course_count,
+ 'summary' => $topic->summary,
];
}
diff --git a/public/static/web/css/common.css b/public/static/web/css/common.css
index b058d74a..847c7c16 100644
--- a/public/static/web/css/common.css
+++ b/public/static/web/css/common.css
@@ -54,7 +54,7 @@
.container {
padding: 20px;
- margin-bottom: 15px;
+ margin-bottom: 20px;
background-color: #fff;
border-radius: 2px;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
@@ -284,6 +284,36 @@
margin-bottom: 5px;
}
+.page-title {
+ padding-bottom: 10px;
+ margin-bottom: 20px;
+ border-bottom: 1px solid #d3d3d3;
+ text-align: center;
+ color: #666;
+}
+
+.page-content {
+ min-height: 450px;
+ color: #666;
+}
+
+.topic-info {
+ margin-bottom: 20px;
+}
+
+.topic-info .title {
+ text-align: center;
+}
+
+.topic-info .summary {
+ padding: 15px 0;
+ color: #666;
+}
+
+.course-list {
+ margin-bottom: 20px;
+}
+
.course-card {
float: left;
width: 100%;
@@ -376,10 +406,6 @@
margin-right: 20px;
}
-.course-list {
- margin-bottom: 20px;
-}
-
.course-meta .cover {
float: left;
margin-right: 10px;
diff --git a/public/static/web/js/teacher.list.js b/public/static/web/js/teacher.list.js
new file mode 100644
index 00000000..28cbe43c
--- /dev/null
+++ b/public/static/web/js/teacher.list.js
@@ -0,0 +1,10 @@
+layui.use(['jquery', 'helper'], function () {
+
+ var $ = layui.jquery;
+ var helper = layui.helper;
+
+ var $teacherList = $('#teacher-list');
+
+ helper.ajaxLoadHtml($teacherList.data('url'), $teacherList.attr('id'));
+
+});
\ No newline at end of file
diff --git a/public/static/web/js/topic.show.js b/public/static/web/js/topic.show.js
new file mode 100644
index 00000000..c66e7726
--- /dev/null
+++ b/public/static/web/js/topic.show.js
@@ -0,0 +1,9 @@
+layui.use(['jquery', 'helper'], function () {
+
+ var $ = layui.jquery;
+ var helper = layui.helper;
+ var $courseList = $('#course-list');
+
+ helper.ajaxLoadHtml($courseList.data('url'), $courseList.attr('id'));
+
+});
\ No newline at end of file