fix pagination in course catalog - refs #2681

pull/2818/head
Alex Aragón 6 years ago
parent 6788339e2f
commit 5007485b43
  1. 4
      .htaccess
  2. 63
      main/auth/courses_categories.php
  3. 7
      main/course_info/about.php
  4. 2
      main/inc/ajax/course.ajax.php
  5. 2
      main/inc/lib/CoursesAndSessionsCatalog.class.php
  6. 7
      main/inc/lib/course_category.lib.php
  7. 56
      main/template/default/auth/course_catalog.html.twig
  8. 5
      main/template/default/course_home/about.html.twig
  9. 15
      src/CoreBundle/Block/BreadcrumbBlockService.php
  10. 4
      src/ThemeBundle/Resources/views/Index/page.html.twig
  11. 2
      src/ThemeBundle/Resources/views/Macros/box.html.twig

@ -41,8 +41,8 @@ RewriteRule ^courses/([^/]+)/upload/([^/]+)/(.*)$ main/document/download_uploade
# Rewrite everything in the work folder
RewriteRule ^courses/([^/]+)/work/(.*)$ main/work/download.php?file=work/$2&cDir=$1 [QSA,L]
RewriteRule ^courses/([^/]+)/course-pic85x85.png$ main/inc/ajax/course.ajax.php?a=get_course_image&code=$1&image=course_image_source [QSA,L]
RewriteRule ^courses/([^/]+)/course-pic.png$ main/inc/ajax/course.ajax.php?a=get_course_image&code=$1&image=course_image_large_source [QSA,L]
RewriteRule ^courses/([^/]+)/course-pic85x85.png$ var/courses/$1/course-pic85x85.png [QSA,L]
RewriteRule ^courses/([^/]+)/course-pic.png$ var/courses/$1/course-pic.png [QSA,L]
# Redirect all courses/ to app/courses/
RewriteRule ^courses/([^/]+)/(.*)$ app/courses/$1/$2 [QSA,L]

@ -83,7 +83,6 @@ $message = null;
$formSearch->addHidden('search_course', 1);
$formSearch->addText('search_term', get_lang('Search'), false,['value'=>$term]);
$formSearch->addButtonSearch(get_lang('Search'), 'submit');
//var_dump($formSearch->getLayout());
//$formSearch->defaultRenderer()->setElementTemplate($formSearch->getDefaultElementTemplate(),'search_term');
$search = $formSearch->returnForm();
@ -202,7 +201,7 @@ if ($showCourses && $action != 'display_sessions') {
}
if ($showTeacher) {
$teacher = return_teacher($course);
$teachers = CourseManager::getTeachersFromCourse($course['real_id']);
}
$separator = null;
@ -259,7 +258,7 @@ if ($showCourses && $action != 'display_sessions') {
'category' => $course['category_title'],
'image' => $courseMediumImage,
'url' => $linkCourse = api_get_path(WEB_PATH).'course/'.$course['real_id'].'/about',
'teacher' => $teacher,
'teachers' => $teachers,
'ranking' => $rating,
'description_ajax' => CourseManager::returnDescriptionButton($course),
'subscribe' => $subscribeButton
@ -293,64 +292,6 @@ echo $content;
/**
* @param array $courseInfo
*
* @return string
*/
function return_teacher($courseInfo)
{
$teachers = CourseManager::getTeachersFromCourse($courseInfo['real_id']);
$length = count($teachers);
if (!$length) {
return '';
}
$html = '<div class="block-author">';
if ($length > 6) {
$html .= '<a
id="plist"
data-trigger="focus"
tabindex="0" role="button"
class="btn btn-default panel_popover"
data-toggle="popover"
title="'.addslashes(get_lang('CourseTeachers')).'"
data-html="true"
>
<i class="fa fa-graduation-cap" aria-hidden="true"></i>
</a>';
$html .= '<div id="popover-content-plist" class="hide">';
foreach ($teachers as $value) {
$name = $value['firstname'].' '.$value['lastname'];
$html .= '<div class="popover-teacher">';
$html .= '<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'" title="'.$name.'">
<img src="'.$value['avatar'].'" alt="'.get_lang('UserPicture').'"/></a>';
$html .= '<div class="teachers-details"><h5>
<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'">'
.$name.'</a></h5></div>';
$html .= '</div>';
}
$html .= '</div>';
} else {
foreach ($teachers as $value) {
$name = $value['firstname'].' '.$value['lastname'];
if ($length > 2) {
$html .= '<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'" title="'.$name.'">
<img src="'.$value['avatar'].'" alt="'.get_lang('UserPicture').'"/></a>';
} else {
$html .= '<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'" title="'.$name.'">
<img src="'.$value['avatar'].'" alt="'.get_lang('UserPicture').'"/></a>';
$html .= '<div class="teachers-details"><h5>
<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'">'
.$name.'</a></h5><p>'.get_lang('Teacher').'</p></div>';
}
}
}
$html .= '</div>';
return $html;
}
/**

@ -139,6 +139,8 @@ if ($checker) {
);
}
$courseItem = [
'code' => $course->getCode(),
'title' => $course->getTitle(),
@ -164,7 +166,8 @@ $metaInfo .= '<meta property="og:image" content="'.$courseItem['image'].'" />';
$htmlHeadXtra[] = $metaInfo;
$htmlHeadXtra[] = api_get_asset('readmore-js/readmore.js');
$template = new Template($course->getTitle(), true, true, false, true, false);
$template = new Template(null);
//$template->assign('course', $course);
$template->assign('course', $courseItem);
$essence = new Essence\Essence();
$template->assign('essence', $essence);
@ -172,7 +175,7 @@ $template->assign('is_premium', $courseIsPremium);
$template->assign('allow_subscribe', $allowSubscribe);
$template->assign('token', $token);
$template->assign('url', $urlCourse);
$layout = $template->get_template('course_home/about.tpl');
$layout = $template->get_template('course_home/about.html.twig');
$content = $template->fetch($layout);
$template->assign('content', $content);
$template->display_one_col_template();

@ -32,6 +32,8 @@ switch ($action) {
case 'get_course_image':
$courseId = ChamiloApi::getCourseIdByDirectory($_REQUEST['code']);
$courseInfo = api_get_course_info_by_id($courseId);
var_dump($courseInfo);
die;
$image = isset($_REQUEST['image']) && in_array($_REQUEST['image'], ['course_image_large_source', 'course_image_source']) ? $_REQUEST['image'] : '';
if ($courseInfo && $image) {
DocumentManager::file_send_for_download($courseInfo[$image]);

@ -11,7 +11,7 @@ use Doctrine\ORM\Query\Expr\Join;
*/
class CoursesAndSessionsCatalog
{
const PAGE_LENGTH = 4;
const PAGE_LENGTH = 12;
/**
* Check the configuration for the courses and sessions catalog.

@ -789,9 +789,9 @@ class CourseCategory
// For each page add its page button to html
for ($i = $pageBottom; $i <= $pageTop; $i++) {
if ($i === $pageCurrent) {
$pageItemAttributes = ['class' => 'active'];
$pageItemAttributes = ['class' => 'page-item active'];
} else {
$pageItemAttributes = [];
$pageItemAttributes = ['class' => 'page-item'];
}
$pageDiv .= self::getPageNumberItem(
$i,
@ -910,7 +910,8 @@ class CourseCategory
'li',
Display::url(
$content,
$url
$url,
['class' => 'page-link']
),
$liAttributes
);

@ -1,8 +1,9 @@
{% import "@ChamiloTheme/Macros/box.html.twig" as macro %}
{% autoescape false %}
<div class="catalog" style="width: 100%;">
<h2>{{ 'Course Management'|get_lang }}</h2>
<h2>{{ 'Course Catalog'|get_lang }}</h2>
<div class="search">
<div class="row">
<div class="col-md-6">
@ -16,19 +17,52 @@
<div class="row">
{% for item in courses %}
<div class="col-md-3">
<div id="course_{{ item.real_id }}" class="card mb-4 shadow-sm">
<a href="{{ item.url }}">
<img class="card-img-top" alt="{{ item.title }}" src="{{ item.image }}" data-holder-rendered="true" style="width: 100%; display: block;">
{% set image %}
{% if item.category != '' %}
<div class="category">
{{ item.category }}
</div>
{% endif %}
<a href="{{ item.url }}" title="{{ item.title }}">
<img class="card-img-top" alt="{{ item.title }}" src="{{ item.image }}" data-holder-rendered="true" style="width: 100%; display: block;">
</a>
<div class="card-body">
<h4><a href="{{ item.url }}">{{ item.title }}</a></h4>
{% endset %}
{% set content %}
<div class="card-title">
<h5 class="title">
<a title="{{ item.title }}" href="{{ item.url }}">{{ item.title}}</a>
</h5>
</div>
<div class="card-author mb-2">
<i class="fa fa-graduation-cap" aria-hidden="true"></i>
{% if item.teachers | length >= 3 %}
<a id="plist-{{ loop.index }}" data-trigger="focus" tabindex="0" role="button" class="list-name" data-toggle="popover" title="{{ 'CourseTeachers' | trans }}" data-html="true">
{{ 'Course Teachers' | trans }}
</a>
<div id="popover-content-plist-{{ loop.index }}" style="display: none;">
{% for teacher in item.teachers %}
<div class="popover-teacher">
<a href="{{ teacher.url }}" class="ajax name" data-title="{{ teacher.firstname }} {{ teacher.lastname }}">
{{ teacher.firstname }} {{ teacher.lastname }}
</a>
</div>
{% endfor %}
</div>
{% else %}
{% for teacher in item.teachers %}
<a href="{{ teacher.url }}" class="ajax name" data-title="{{ teacher.firstname }} {{ teacher.lastname }}">
{{ teacher.firstname }} {{ teacher.lastname }}
</a>
{% endfor %}
{% endif %}
</div>
{% if item.ranking %}
<div class="ranking">
{{ item.ranking }}
{{ item.teacher }}
<div class="d-flex justify-content-between align-items-center">
{{ item.subscribe }}
</div>
</div>
</div>
{% endif %}
{% endset %}
{{ macro.panel_course(item.real_id, '', content, '', '', '', image) }}
</div>
{% endfor %}
</div>

@ -1,3 +1,4 @@
{% autoescape false %}
<div id="about-course">
<div id="course-info-top">
<h2 class="session-title">{{ course.title }}</h2>
@ -8,7 +9,6 @@
<li>{{ teacher.complete_name }} | </li>
{% endfor %}
</ul>
</div>
</div>
@ -185,4 +185,5 @@
heightMargin: 20
});
});
</script>
</script>
{% endautoescape %}

@ -61,12 +61,23 @@ class BreadcrumbBlockService extends BaseBreadcrumbMenuBlockService
// Add course
/** @var Course $course */
if ($course = $blockContext->getBlock()->getSetting('course')) {
if(is_array($course)){
$title = $course['title'];
$code = $course['code'];
} else {
$title = $course->getTitle();
$code = $course->getCode();
}
$menu->addChild(
$course->getTitle(),
$title,
[
'route' => 'course_home',
'routeParameters' => [
'course' => $course->getCode(),
'course' => $code,
],
]
);

@ -10,9 +10,9 @@
{% set content %}
{{ macro.box_header("IntroductionOfPlatform" | trans, buttons) }}
{{ macro.box_header("Introduction of platform" | trans, buttons) }}
{{ sonata_page_render_container('content', page) }}
{% endset %}
{{ macro.panel('', '', content, '', '', '', '') }}
{{ macro.panel('', content, '', '', '', '', '') }}

@ -187,7 +187,7 @@
{% macro panel_course(id, header, content, title, footer, subtitle, top_image) %}
{% autoescape false %}
<div class="card-course card-{{ id }} mt-3 mb-3">
<div class="card-course course-{{ id }} mt-3 mb-3">
{% if header %}
<div class="card-header"> {{ header }} </div>
{% endif %}

Loading…
Cancel
Save