mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-07-06 08:51:10 +08:00
修正在php7.3下的类继承问题
This commit is contained in:
parent
401ec0793a
commit
680089e06f
78
app/Builders/CourseTopicList.php
Normal file
78
app/Builders/CourseTopicList.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Builders;
|
||||
|
||||
use App\Repos\Course as CourseRepo;
|
||||
use App\Repos\Topic as TopicRepo;
|
||||
|
||||
class CourseTopicList extends Builder
|
||||
{
|
||||
|
||||
public function handleCourses($relations)
|
||||
{
|
||||
$courses = $this->getCourses($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['course'] = $courses[$value['course_id']] ?? new \stdClass();
|
||||
}
|
||||
|
||||
return $relations;
|
||||
}
|
||||
|
||||
public function handleTopics($relations)
|
||||
{
|
||||
$topics = $this->getTopics($relations);
|
||||
|
||||
foreach ($relations as $key => $value) {
|
||||
$relations[$key]['topic'] = $topics[$value['topic_id']] ?? new \stdClass();
|
||||
}
|
||||
|
||||
return $relations;
|
||||
}
|
||||
|
||||
public function getCourses($relations)
|
||||
{
|
||||
$ids = kg_array_column($relations, 'course_id');
|
||||
|
||||
$courseRepo = new CourseRepo();
|
||||
|
||||
$columns = [
|
||||
'id', 'title', 'cover',
|
||||
'market_price', 'vip_price',
|
||||
'rating', 'model', 'level', 'attrs',
|
||||
'user_count', 'lesson_count',
|
||||
];
|
||||
|
||||
$courses = $courseRepo->findByIds($ids, $columns);
|
||||
|
||||
$baseUrl = kg_ci_base_url();
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($courses->toArray() as $course) {
|
||||
$course['cover'] = $baseUrl . $course['cover'];
|
||||
$course['attrs'] = json_decode($course['attrs'], true);
|
||||
$result[$course['id']] = $course;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getTopics($relations)
|
||||
{
|
||||
$ids = kg_array_column($relations, 'topic_id');
|
||||
|
||||
$topicRepo = new TopicRepo();
|
||||
|
||||
$topics = $topicRepo->findByIds($ids, ['id', 'title', 'summary']);
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($topics->toArray() as $topic) {
|
||||
$result[$topic['id']] = $topic;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
@ -30,23 +30,20 @@ class CourseController extends Controller
|
||||
{
|
||||
$service = new CourseQueryService();
|
||||
|
||||
$params = $service->getQueryParams();
|
||||
|
||||
$pagerUrl = $this->url->get(['for' => 'web.course.pager'], $params);
|
||||
|
||||
$topCategories = $service->handleTopCategories();
|
||||
$subCategories = $service->handleSubCategories();
|
||||
|
||||
$models = $service->handleModels();
|
||||
$levels = $service->handleLevels();
|
||||
$sorts = $service->handleSorts();
|
||||
$params = $service->getParams();
|
||||
|
||||
$this->view->setVar('pager_url', $pagerUrl);
|
||||
$this->view->setVar('top_categories', $topCategories);
|
||||
$this->view->setVar('sub_categories', $subCategories);
|
||||
$this->view->setVar('models', $models);
|
||||
$this->view->setVar('levels', $levels);
|
||||
$this->view->setVar('sorts', $sorts);
|
||||
$this->view->setVar('params', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,13 +111,11 @@ class CourseController extends Controller
|
||||
*/
|
||||
public function consultsAction($id)
|
||||
{
|
||||
$target = $this->request->get('target', 'trim', 'tab-consults');
|
||||
|
||||
$service = new CourseConsultListService();
|
||||
|
||||
$pager = $service->handle($id);
|
||||
$pager->items = kg_array_object($pager->items);
|
||||
$pager->target = $target;
|
||||
$pager->target = 'tab-consults';
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->setVar('pager', $pager);
|
||||
@ -131,13 +126,11 @@ class CourseController extends Controller
|
||||
*/
|
||||
public function reviewsAction($id)
|
||||
{
|
||||
$target = $this->request->get('target', 'trim', 'tab-reviews');
|
||||
|
||||
$service = new CourseReviewListService();
|
||||
|
||||
$pager = $service->handle($id);
|
||||
$pager->items = kg_array_object($pager->items);
|
||||
$pager->target = $target;
|
||||
$pager->target = 'tab-reviews';
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->setVar('pager', $pager);
|
||||
|
38
app/Http/Web/Controllers/HelpController.php
Normal file
38
app/Http/Web/Controllers/HelpController.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Web\Controllers;
|
||||
|
||||
use App\Services\Frontend\Help\HelpInfo as HelpInfoService;
|
||||
use App\Services\Frontend\Help\HelpList as HelpListService;
|
||||
|
||||
/**
|
||||
* @RoutePrefix("/help")
|
||||
*/
|
||||
class HelpController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* @Get("/", name="web.help.index")
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$service = new HelpListService();
|
||||
|
||||
$helps = $service->handle();
|
||||
|
||||
$this->view->setVar('helps', $helps);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get("/{id:[0-9]+}", name="web.help.show")
|
||||
*/
|
||||
public function showAction($id)
|
||||
{
|
||||
$service = new HelpInfoService();
|
||||
|
||||
$help = $service->handle($id);
|
||||
|
||||
$this->view->setVar('help', $help);
|
||||
}
|
||||
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Http\Web\Controllers;
|
||||
|
||||
use App\Services\Frontend\Page\PageInfo as PageInfoService;
|
||||
use App\Services\Frontend\Page\HelpInfo as PageInfoService;
|
||||
|
||||
/**
|
||||
* @RoutePrefix("/page")
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Web\Controllers;
|
||||
|
||||
use App\Services\Frontend\Teacher\TeacherList as TeacherListService;
|
||||
use Phalcon\Mvc\View;
|
||||
|
||||
/**
|
||||
* @RoutePrefix("/teacher")
|
||||
@ -11,18 +12,26 @@ class TeacherController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* @Get("/list", name="web.teacher")
|
||||
* @Get("/list", name="web.teacher.list")
|
||||
*/
|
||||
public function listAction()
|
||||
{
|
||||
$_REQUEST['limit'] = 12;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get("/pager", name="web.teacher.pager")
|
||||
*/
|
||||
public function pagerAction()
|
||||
{
|
||||
$service = new TeacherListService();
|
||||
|
||||
$pager = $service->handle();
|
||||
|
||||
$pager->items = kg_array_object($pager->items);
|
||||
$pager->target = 'teacher-list';
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->pick('teacher/list_pager');
|
||||
$this->view->setVar('pager', $pager);
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ namespace App\Http\Web\Controllers;
|
||||
|
||||
use App\Services\Frontend\Topic\CourseList as TopicCourseListService;
|
||||
use App\Services\Frontend\Topic\TopicInfo as TopicInfoService;
|
||||
use Phalcon\Mvc\View;
|
||||
|
||||
/**
|
||||
* @RoutePrefix("/topic")
|
||||
@ -20,12 +21,24 @@ class TopicController extends Controller
|
||||
|
||||
$topic = $service->handle($id);
|
||||
|
||||
$this->view->setVar('topic', $topic);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Get("/{id:[0-9]+}/courses", name="web.topic.courses")
|
||||
*/
|
||||
public function coursesAction($id)
|
||||
{
|
||||
$target = $this->request->get('target', 'trim', 'course-list');
|
||||
|
||||
$service = new TopicCourseListService();
|
||||
|
||||
$courses = $service->handle($id);
|
||||
$pager = $service->handle($id);
|
||||
$pager->items = kg_array_object($pager->items);
|
||||
$pager->target = $target;
|
||||
|
||||
$this->view->setVar('topic', $topic);
|
||||
$this->view->setVar('courses', $courses);
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->setVar('pager', $pager);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,13 +31,11 @@ class UserController extends Controller
|
||||
*/
|
||||
public function coursesAction($id)
|
||||
{
|
||||
$target = $this->request->get('target', 'trim', 'tab-courses');
|
||||
|
||||
$service = new UserCourseListService();
|
||||
|
||||
$pager = $service->handle($id);
|
||||
$pager->items = kg_array_object($pager->items);
|
||||
$pager->target = $target;
|
||||
$pager->target = 'tab-courses';
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->setVar('pager', $pager);
|
||||
@ -48,13 +46,11 @@ class UserController extends Controller
|
||||
*/
|
||||
public function favoritesAction($id)
|
||||
{
|
||||
$target = $this->request->get('target', 'trim', 'tab-favorites');
|
||||
|
||||
$service = new UserFavoriteListService();
|
||||
|
||||
$pager = $service->handle($id);
|
||||
$pager->items = kg_array_object($pager->items);
|
||||
$pager->target = $target;
|
||||
$pager->target = 'tab-favorites';
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->setVar('pager', $pager);
|
||||
@ -65,13 +61,11 @@ class UserController extends Controller
|
||||
*/
|
||||
public function friendsAction($id)
|
||||
{
|
||||
$target = $this->request->get('target', 'trim', 'tab-friends');
|
||||
|
||||
$service = new UserFriendListService();
|
||||
|
||||
$pager = $service->handle($id);
|
||||
$pager->items = kg_array_object($pager->items);
|
||||
$pager->target = $target;
|
||||
$pager->target = 'tab-friends';
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->setVar('pager', $pager);
|
||||
|
@ -30,13 +30,11 @@ class VipController extends Controller
|
||||
*/
|
||||
public function coursesAction()
|
||||
{
|
||||
$target = $this->request->get('target', 'trim', 'tab-courses');
|
||||
|
||||
$service = new VipCourseListService();
|
||||
|
||||
$pager = $service->handle();
|
||||
$pager->items = kg_array_object($pager->items);
|
||||
$pager->target = $target;
|
||||
$pager->target = 'tab-courses';
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->setVar('pager', $pager);
|
||||
@ -47,13 +45,11 @@ class VipController extends Controller
|
||||
*/
|
||||
public function usersAction()
|
||||
{
|
||||
$target = $this->request->get('target', 'trim', 'tab-users');
|
||||
|
||||
$service = new VipUserListService();
|
||||
|
||||
$pager = $service->handle();
|
||||
$pager->items = kg_array_object($pager->items);
|
||||
$pager->target = $target;
|
||||
$pager->target = 'tab-users';
|
||||
|
||||
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
|
||||
$this->view->setVar('pager', $pager);
|
||||
|
@ -18,7 +18,7 @@ class CourseQuery extends Service
|
||||
|
||||
public function handleTopCategories()
|
||||
{
|
||||
$params = $this->getQueryParams();
|
||||
$params = $this->getParams();
|
||||
|
||||
if (isset($params['tc'])) {
|
||||
unset($params['tc']);
|
||||
@ -33,7 +33,7 @@ class CourseQuery extends Service
|
||||
$defaultItem = [
|
||||
'id' => 'all',
|
||||
'name' => '全部',
|
||||
'url' => $baseUrl . $this->buildQueryParams($params),
|
||||
'url' => $baseUrl . $this->buildParams($params),
|
||||
];
|
||||
|
||||
$result = [];
|
||||
@ -49,7 +49,7 @@ class CourseQuery extends Service
|
||||
$result[] = [
|
||||
'id' => $category['id'],
|
||||
'name' => $category['name'],
|
||||
'url' => $baseUrl . $this->buildQueryParams($params),
|
||||
'url' => $baseUrl . $this->buildParams($params),
|
||||
];
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ class CourseQuery extends Service
|
||||
|
||||
public function handleSubCategories()
|
||||
{
|
||||
$params = $this->getQueryParams();
|
||||
$params = $this->getParams();
|
||||
|
||||
if (empty($params['tc'])) {
|
||||
return [];
|
||||
@ -81,7 +81,7 @@ class CourseQuery extends Service
|
||||
$defaultItem = [
|
||||
'id' => 'all',
|
||||
'name' => '全部',
|
||||
'url' => $baseUrl . $this->buildQueryParams($params),
|
||||
'url' => $baseUrl . $this->buildParams($params),
|
||||
];
|
||||
|
||||
$result = [];
|
||||
@ -93,7 +93,7 @@ class CourseQuery extends Service
|
||||
$result[] = [
|
||||
'id' => $category['id'],
|
||||
'name' => $category['name'],
|
||||
'url' => $baseUrl . $this->buildQueryParams($params),
|
||||
'url' => $baseUrl . $this->buildParams($params),
|
||||
];
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ class CourseQuery extends Service
|
||||
|
||||
public function handleModels()
|
||||
{
|
||||
$params = $this->getQueryParams();
|
||||
$params = $this->getParams();
|
||||
|
||||
if (isset($params['model'])) {
|
||||
unset($params['model']);
|
||||
@ -111,7 +111,7 @@ class CourseQuery extends Service
|
||||
$defaultItem = [
|
||||
'id' => 'all',
|
||||
'name' => '全部',
|
||||
'url' => $this->baseUrl . $this->buildQueryParams($params),
|
||||
'url' => $this->baseUrl . $this->buildParams($params),
|
||||
];
|
||||
|
||||
$result = [];
|
||||
@ -125,7 +125,7 @@ class CourseQuery extends Service
|
||||
$result[] = [
|
||||
'id' => $key,
|
||||
'name' => $value,
|
||||
'url' => $this->baseUrl . $this->buildQueryParams($params),
|
||||
'url' => $this->baseUrl . $this->buildParams($params),
|
||||
];
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ class CourseQuery extends Service
|
||||
|
||||
public function handleLevels()
|
||||
{
|
||||
$params = $this->getQueryParams();
|
||||
$params = $this->getParams();
|
||||
|
||||
if (isset($params['level'])) {
|
||||
unset($params['level']);
|
||||
@ -143,7 +143,7 @@ class CourseQuery extends Service
|
||||
$defaultItem = [
|
||||
'id' => 'all',
|
||||
'name' => '全部',
|
||||
'url' => $this->baseUrl . $this->buildQueryParams($params),
|
||||
'url' => $this->baseUrl . $this->buildParams($params),
|
||||
];
|
||||
|
||||
$result = [];
|
||||
@ -157,7 +157,7 @@ class CourseQuery extends Service
|
||||
$result[] = [
|
||||
'id' => $key,
|
||||
'name' => $value,
|
||||
'url' => $this->baseUrl . $this->buildQueryParams($params),
|
||||
'url' => $this->baseUrl . $this->buildParams($params),
|
||||
];
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ class CourseQuery extends Service
|
||||
|
||||
public function handleSorts()
|
||||
{
|
||||
$params = $this->getQueryParams();
|
||||
$params = $this->getParams();
|
||||
|
||||
$result = [];
|
||||
|
||||
@ -177,7 +177,7 @@ class CourseQuery extends Service
|
||||
$result[] = [
|
||||
'id' => $key,
|
||||
'name' => $value,
|
||||
'url' => $this->baseUrl . $this->buildQueryParams($params),
|
||||
'url' => $this->baseUrl . $this->buildParams($params),
|
||||
];
|
||||
}
|
||||
|
||||
@ -197,20 +197,20 @@ class CourseQuery extends Service
|
||||
|
||||
$result['top'] = [
|
||||
'name' => $topCategory->name,
|
||||
'url' => $this->baseUrl . $this->buildQueryParams($topParams),
|
||||
'url' => $this->baseUrl . $this->buildParams($topParams),
|
||||
];
|
||||
|
||||
$subParams = ['tc' => $topCategory->id, 'sc' => $subCategory->id];
|
||||
|
||||
$result['sub'] = [
|
||||
'name' => $subCategory->name,
|
||||
'url' => $this->baseUrl . $this->buildQueryParams($subParams),
|
||||
'url' => $this->baseUrl . $this->buildParams($subParams),
|
||||
];
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getQueryParams()
|
||||
public function getParams()
|
||||
{
|
||||
$query = $this->request->getQuery();
|
||||
|
||||
@ -246,7 +246,7 @@ class CourseQuery extends Service
|
||||
return $params;
|
||||
}
|
||||
|
||||
protected function buildQueryParams($params)
|
||||
protected function buildParams($params)
|
||||
{
|
||||
return $params ? '?' . http_build_query($params) : '';
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
<div class="layui-tab layui-tab-brief login-tab">
|
||||
<ul class="layui-tab-title login-tab-title">
|
||||
<li class="layui-this">密码登录</li>
|
||||
<li>验证码登录</li>
|
||||
<li>验证登录</li>
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
<div class="layui-tab-item layui-show">
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
{{ partial('course/list_filter') }}
|
||||
|
||||
{% set pager_url = url({'for':'web.course.pager'}, params) %}
|
||||
|
||||
<div id="course-list" data-url="{{ pager_url }}"></div>
|
||||
|
||||
{% endblock %}
|
||||
|
14
app/Http/Web/Views/help/index.volt
Normal file
14
app/Http/Web/Views/help/index.volt
Normal file
@ -0,0 +1,14 @@
|
||||
{% extends 'templates/full.volt' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="layui-collapse">
|
||||
{% for help in helps %}
|
||||
<div class="layui-colla-item">
|
||||
<h2 class="layui-colla-title">{{ help.title }}</h2>
|
||||
<div class="layui-colla-content layui-show">{{ help.content }}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
9
app/Http/Web/Views/page/show.volt
Normal file
9
app/Http/Web/Views/page/show.volt
Normal file
@ -0,0 +1,9 @@
|
||||
{% extends 'templates/full.volt' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h3 class="page-title">{{ page.title }}</h3>
|
||||
|
||||
<div class="page-content container">{{ page.content }}</div>
|
||||
|
||||
{% endblock %}
|
@ -2,33 +2,19 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% set pager_url = url({'for':'web.teacher.pager'}) %}
|
||||
|
||||
<div class="layui-breadcrumb breadcrumb">
|
||||
<a href="/">首页</a>
|
||||
<a><cite>名师</cite></a>
|
||||
</div>
|
||||
|
||||
{% if pager.total_pages > 0 %}
|
||||
<div class="teach-user-list clearfix">
|
||||
<div class="layui-row layui-col-space20">
|
||||
{% 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}) %}
|
||||
<div class="layui-col-md3">
|
||||
<div class="user-card">
|
||||
<div class="avatar">
|
||||
<a href="{{ user_url }}" title="{{ user_about }}"><img src="{{ item.avatar }}" alt="{{ item.name }}"></a>
|
||||
</div>
|
||||
<div class="name layui-elip">
|
||||
<a href="{{ user_url }}">{{ item.name }}</a>
|
||||
</div>
|
||||
<div class="title layui-elip">{{ user_title }}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{{ partial('partials/pager') }}
|
||||
{% endif %}
|
||||
<div id="teacher-list" data-url="{{ pager_url }}"></div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block include_js %}
|
||||
|
||||
{{ js_include('web/js/teacher.list.js') }}
|
||||
|
||||
{% endblock %}
|
23
app/Http/Web/Views/teacher/list_pager.volt
Normal file
23
app/Http/Web/Views/teacher/list_pager.volt
Normal file
@ -0,0 +1,23 @@
|
||||
{% if pager.total_pages > 0 %}
|
||||
<div class="teach-user-list clearfix">
|
||||
<div class="layui-row layui-col-space20">
|
||||
{% 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}) %}
|
||||
<div class="layui-col-md3">
|
||||
<div class="user-card">
|
||||
<div class="avatar">
|
||||
<a href="{{ user_url }}" title="{{ user_about }}"><img src="{{ item.avatar }}" alt="{{ item.name }}"></a>
|
||||
</div>
|
||||
<div class="name layui-elip">
|
||||
<a href="{{ user_url }}">{{ item.name }}</a>
|
||||
</div>
|
||||
<div class="title layui-elip">{{ user_title }}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{{ partial('partials/pager_ajax') }}
|
||||
{% endif %}
|
14
app/Http/Web/Views/topic/courses.volt
Normal file
14
app/Http/Web/Views/topic/courses.volt
Normal file
@ -0,0 +1,14 @@
|
||||
{{ partial('partials/macro_course') }}
|
||||
|
||||
{% if pager.total_pages > 0 %}
|
||||
<div class="course-list clearfix">
|
||||
<div class="layui-row layui-col-space20">
|
||||
{% for item in pager.items %}
|
||||
<div class="layui-col-md3">
|
||||
{{ course_card(item) }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{{ partial('partials/pager_ajax') }}
|
||||
{% endif %}
|
19
app/Http/Web/Views/topic/show.volt
Normal file
19
app/Http/Web/Views/topic/show.volt
Normal file
@ -0,0 +1,19 @@
|
||||
{% extends 'templates/full.volt' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% set courses_url = url({'for':'web.topic.courses','id':topic.id}) %}
|
||||
|
||||
<div class="topic-info container">
|
||||
<h3 class="title" title="{{ topic.summary|e }}">{{ topic.title }}</h3>
|
||||
</div>
|
||||
|
||||
<div id="course-list" data-url="{{ courses_url }}"></div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block include_js %}
|
||||
|
||||
{{ js_include('web/js/topic.show.js') }}
|
||||
|
||||
{% endblock %}
|
@ -57,7 +57,7 @@ class Redis extends \Phalcon\Cache\Backend\Redis
|
||||
*
|
||||
* @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;
|
||||
@ -130,7 +130,7 @@ class Redis extends \Phalcon\Cache\Backend\Redis
|
||||
* @param string $keyName
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($keyName)
|
||||
public function delete($keyName): bool
|
||||
{
|
||||
$redis = $this->getRedis();
|
||||
|
||||
@ -145,7 +145,7 @@ class Redis extends \Phalcon\Cache\Backend\Redis
|
||||
* @param string $prefix
|
||||
* @return array
|
||||
*/
|
||||
public function queryKeys($prefix = null)
|
||||
public function queryKeys($prefix = null): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
@ -171,7 +171,7 @@ class Redis extends \Phalcon\Cache\Backend\Redis
|
||||
* @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
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -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');
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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();
|
||||
|
||||
|
@ -47,7 +47,7 @@ class AccessToken extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_access_token';
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ class Account extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_account';
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class Audit extends Model
|
||||
*/
|
||||
public $create_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_audit';
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ class Category extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_category';
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ class Chapter extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_chapter';
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class ChapterLive extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_chapter_live';
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class ChapterRead extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_chapter_read';
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ class ChapterUser extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_chapter_user';
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class ChapterVod extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_chapter_vod';
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ class ChapterVote extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_chapter_vote';
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ class Comment extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_comment';
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ class CommentVote extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_comment_vote';
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ class Consult extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_consult';
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class ConsultVote extends Model
|
||||
*/
|
||||
public $create_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_consult_vote';
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class ContentImage extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_content_image';
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ class Course extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_course';
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class CourseCategory extends Model
|
||||
*/
|
||||
public $create_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_course_category';
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class CourseFavorite extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_course_favorite';
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class CoursePackage extends Model
|
||||
*/
|
||||
public $create_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_course_package';
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class CourseRelated extends Model
|
||||
*/
|
||||
public $create_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_course_related';
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class CourseTopic extends Model
|
||||
*/
|
||||
public $create_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_course_topic';
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ class CourseUser extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_course_user';
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class Help extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_help';
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class ImFriendGroup extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_im_friend_group';
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ class ImFriendMessage extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_im_friend_message';
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class ImFriendUser extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_im_friend_user';
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class ImGroup extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_im_group';
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class ImGroupMessage extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_im_group_message';
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ class ImGroupUser extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_im_group_user';
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ class ImSystemMessage extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_im_system_message';
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ class ImUser extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_im_user';
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ class Learning extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_learning';
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ class Nav extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_nav';
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ class Order extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_order';
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class OrderStatus extends Model
|
||||
*/
|
||||
public $create_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_order_status';
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class Package extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_package';
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class Page extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_page';
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class RefreshToken extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_refresh_token';
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ class Refund extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_refund';
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class RefundStatus extends Model
|
||||
*/
|
||||
public $create_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_refund_status';
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ class Review extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_review';
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class ReviewVote extends Model
|
||||
*/
|
||||
public $create_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_review_vote';
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class Reward extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_reward';
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class Role extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_role';
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class Setting extends Model
|
||||
*/
|
||||
public $item_value;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_setting';
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ class Slide extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_slide';
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class Task extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_task';
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class Topic extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_topic';
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ class Trade extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_trade';
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class TradeStatus extends Model
|
||||
*/
|
||||
public $create_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_trade_status';
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ class User extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_user';
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class Vip extends Model
|
||||
*/
|
||||
public $update_time;
|
||||
|
||||
public function getSource()
|
||||
public function getSource(): string
|
||||
{
|
||||
return 'kg_vip';
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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']]);
|
||||
}
|
||||
|
@ -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'])) {
|
||||
|
30
app/Services/Frontend/Help/HelpInfo.php
Normal file
30
app/Services/Frontend/Help/HelpInfo.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Frontend\Help;
|
||||
|
||||
use App\Models\Help as HelpModel;
|
||||
use App\Services\Frontend\HelpTrait;
|
||||
use App\Services\Frontend\Service as FrontendService;
|
||||
|
||||
class HelpInfo extends FrontendService
|
||||
{
|
||||
|
||||
use HelpTrait;
|
||||
|
||||
public function handle($id)
|
||||
{
|
||||
$help = $this->checkHelpCache($id);
|
||||
|
||||
return $this->handleHelp($help);
|
||||
}
|
||||
|
||||
protected function handleHelp(HelpModel $help)
|
||||
{
|
||||
return [
|
||||
'id' => $help->id,
|
||||
'title' => $help->title,
|
||||
'content' => $help->content,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
45
app/Services/Frontend/Help/HelpList.php
Normal file
45
app/Services/Frontend/Help/HelpList.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Frontend\Help;
|
||||
|
||||
use App\Models\Help as HelpModel;
|
||||
use App\Repos\Help as HelpRepo;
|
||||
use App\Services\Frontend\Service as FrontendService;
|
||||
|
||||
class HelpList extends FrontendService
|
||||
{
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$helpRepo = new HelpRepo();
|
||||
|
||||
$params = ['published' => 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;
|
||||
}
|
||||
|
||||
}
|
24
app/Services/Frontend/HelpTrait.php
Normal file
24
app/Services/Frontend/HelpTrait.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Frontend;
|
||||
|
||||
use App\Validators\Help as HelpValidator;
|
||||
|
||||
trait HelpTrait
|
||||
{
|
||||
|
||||
public function checkHelp($id)
|
||||
{
|
||||
$validator = new HelpValidator();
|
||||
|
||||
return $validator->checkHelp($id);
|
||||
}
|
||||
|
||||
public function checkHelpCache($id)
|
||||
{
|
||||
$validator = new HelpValidator();
|
||||
|
||||
return $validator->checkHelpCache($id);
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
10
public/static/web/js/teacher.list.js
Normal file
10
public/static/web/js/teacher.list.js
Normal file
@ -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'));
|
||||
|
||||
});
|
9
public/static/web/js/topic.show.js
Normal file
9
public/static/web/js/topic.show.js
Normal file
@ -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'));
|
||||
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user