Fix pagination

ofaj
jmontoyaa 9 years ago
parent 577f684e3e
commit 965c658031
  1. 10
      main/inc/lib/course_category.lib.php
  2. 25
      main/template/default/auth/courses_categories.php

@ -924,17 +924,13 @@ class CourseCategory
*/
public static function getLimitArray()
{
$pageCurrent = isset($_REQUEST['pageCurrent']) ?
intval($_GET['pageCurrent']) :
1;
$pageLength = isset($_REQUEST['pageLength']) ?
intval($_GET['pageLength']) :
10;
$pageCurrent = isset($_REQUEST['pageCurrent']) ? intval($_GET['pageCurrent']) : 1;
$pageLength = isset($_REQUEST['pageLength']) ? intval($_GET['pageLength']) : 12;
return array(
'start' => ($pageCurrent - 1) * $pageLength,
'current' => $pageCurrent,
'length' => $pageLength,
'length' => $pageLength
);
}

@ -15,17 +15,11 @@ if (isset($_REQUEST['action']) && Security::remove_XSS($_REQUEST['action']) !==
$showCourses = CoursesAndSessionsCatalog::showCourses();
$showSessions = CoursesAndSessionsCatalog::showSessions();
$pageCurrent = isset($pageCurrent) ? $pageCurrent :
isset($_GET['pageCurrent']) ? intval($_GET['pageCurrent']) :
1;
$pageLength = isset($pageLength) ? $pageLength :
isset($_GET['pageLength']) ? intval($_GET['pageLength']) :
10;
$pageCurrent = isset($pageCurrent) ? $pageCurrent : isset($_GET['pageCurrent']) ? intval($_GET['pageCurrent']) : 1;
$pageLength = isset($pageLength) ? $pageLength : isset($_GET['pageLength']) ? intval($_GET['pageLength']) : 12;
$pageTotal = intval(ceil(intval($countCoursesInCategory) / $pageLength));
$cataloguePagination = $pageTotal > 1 ?
CourseCategory::getCatalogPagination($pageCurrent, $pageLength, $pageTotal) :
'';
$search_term = isset($search_term) ? $search_term :null;
$cataloguePagination = $pageTotal > 1 ? CourseCategory::getCatalogPagination($pageCurrent, $pageLength, $pageTotal) : '';
$search_term = isset($search_term) ? $search_term : null;
if ($showSessions && isset($_POST['date'])) {
$date = $_POST['date'];
@ -130,9 +124,9 @@ $code = isset($code) ? $code : null;
<?php
$webAction = api_get_path(WEB_CODE_PATH).'auth/courses.php';
$action = (!empty($_REQUEST['action']) ? Security::remove_XSS($_REQUEST['action']):'display_courses');
$pageLength = (!empty($_REQUEST['pageLength'])?intval($_REQUEST['pageLength']):10);
$pageCurrent = (!empty($_REQUEST['pageCurrent'])?intval($_REQUEST['pageCurrent']):1);
$action = (!empty($_REQUEST['action']) ? Security::remove_XSS($_REQUEST['action']) : 'display_courses');
$pageLength = (!empty($_REQUEST['pageLength']) ? intval($_REQUEST['pageLength']) : 10);
$pageCurrent = (!empty($_REQUEST['pageCurrent']) ? intval($_REQUEST['pageCurrent']) : 1);
$form = '<form action="'.$webAction.'" method="GET" class="form-horizontal">';
$form .= '<input type="hidden" name="action" value="' . $action . '">';
$form .= '<input type="hidden" name="pageCurrent" value="' . $pageCurrent . '">';
@ -144,7 +138,6 @@ $code = isset($code) ? $code : null;
foreach ($browse_course_categories[0] as $category) {
$categoryCode = $category['code'];
$countCourse = $category['count_courses'];
$form .= '<option '. ($categoryCode == $codeType? 'selected="selected" ':'') .' value="' . $category['code'] . '">' . $category['name'] . ' ( '. $countCourse .' ) </option>';
if (!empty($browse_course_categories[$categoryCode])) {
foreach ($browse_course_categories[$categoryCode] as $subCategory){
@ -196,7 +189,7 @@ if ($showCourses && $action != 'display_sessions') {
if (!empty($browse_courses_in_category)) {
foreach ($browse_courses_in_category as $course) {
$course_hidden = ($course['visibility'] == COURSE_VISIBILITY_HIDDEN);
$course_hidden = $course['visibility'] == COURSE_VISIBILITY_HIDDEN;
if ($course_hidden) {
continue;
@ -213,7 +206,7 @@ if ($showCourses && $action != 'display_sessions') {
$course_subscribe_allowed = ($course['subscribe'] == 1);
$course_unsubscribe_allowed = ($course['unsubscribe'] == 1);
$count_connections = $course['count_connections'];
$creation_date = substr($course['creation_date'],0,10);
$creation_date = substr($course['creation_date'], 0, 10);
$html = null;
// display the course bloc

Loading…
Cancel
Save