Fix course catalog's search bar - refs BT#12937

pull/2487/head
Angel Fernando Quiroz Campos 8 years ago
parent 7b74817091
commit 95708b2057
  1. 131
      main/auth/courses_categories.php

@ -66,69 +66,88 @@ $code = isset($code) ? $code : null;
<h2 class="title-courses"><?php echo get_lang('CourseManagement'); ?></h2> <h2 class="title-courses"><?php echo get_lang('CourseManagement'); ?></h2>
<div class="search-courses"> <div class="search-courses">
<div class="row"> <div class="row">
<div class="col-md-<?php echo ($showSessions ? '4' : '6'); ?>"> <?php if ($showCourses) { ?>
<?php <div class="col-md-<?php echo($showSessions ? '4' : '6'); ?>">
if ($showCourses) { <?php if (!isset($_GET['hidden_links']) || intval($_GET['hidden_links']) != 1) { ?>
if (!isset($_GET['hidden_links']) || intval($_GET['hidden_links']) != 1) { ?> <form method="post"
<form method="post" action="<?php echo CourseCategory::getCourseCategoryUrl(1, $pageLength, 'ALL', 0, 'subscribe'); ?>"> action="<?php echo CourseCategory::getCourseCategoryUrl(1, $pageLength, 'ALL', 0, 'subscribe'); ?>">
<input type="hidden" name="sec_token" value="<?php echo $stok; ?>"> <input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
<input type="hidden" name="search_course" value="1" /> <input type="hidden" name="search_course" value="1"/>
<label><?php echo get_lang('Search'); ?></label> <label><?php echo get_lang('Search'); ?></label>
<div class="input-group"> <div class="input-group">
<input class="form-control" type="text" name="search_term" value="<?php echo (empty($_POST['search_term']) ? '' : api_htmlentities(Security::remove_XSS($_POST['search_term']))); ?>" /> <input class="form-control" type="text" name="search_term"
<div class="input-group-btn"> value="<?php echo(empty($_POST['search_term'])
<button class="btn btn-default" type="submit"> ? ''
<em class="fa fa-search"></em> <?php echo get_lang('Search'); ?> : api_htmlentities(Security::remove_XSS($_POST['search_term']))); ?>"/>
</button> <div class="input-group-btn">
<button class="btn btn-default" type="submit">
<em class="fa fa-search"></em> <?php echo get_lang('Search'); ?>
</button>
</div>
</div> </div>
</div> </form>
</form> <?php } ?>
<?php } ?> </div>
</div> <div class="col-md-<?php echo($showSessions ? '4' : '6'); ?>">
<div class="col-md-<?php echo ($showSessions ? '4' : '6'); ?>"> <?php
<?php $webAction = api_get_path(WEB_CODE_PATH).'auth/courses.php';
$webAction = api_get_path(WEB_CODE_PATH).'auth/courses.php'; $action = !empty($_REQUEST['action'])
$action = (!empty($_REQUEST['action']) ? Security::remove_XSS($_REQUEST['action']) : 'display_courses'); ? Security::remove_XSS($_REQUEST['action'])
$pageLength = !empty($_REQUEST['pageLength']) ? intval($_REQUEST['pageLength']) : CoursesAndSessionsCatalog::PAGE_LENGTH; : 'display_courses';
$pageCurrent = !empty($_REQUEST['pageCurrent']) ? intval($_REQUEST['pageCurrent']) : 1; $pageLength = !empty($_REQUEST['pageLength'])
$form = '<form action="'.$webAction.'" method="GET" >'; ? intval($_REQUEST['pageLength'])
$form .= '<input type="hidden" name="action" value="'.$action.'">'; : CoursesAndSessionsCatalog::PAGE_LENGTH;
$form .= '<input type="hidden" name="pageCurrent" value="'.$pageCurrent.'">'; $pageCurrent = !empty($_REQUEST['pageCurrent']) ? intval($_REQUEST['pageCurrent']) : 1;
$form .= '<input type="hidden" name="pageLength" value="'.$pageLength.'">'; $form = '<form action="'.$webAction.'" method="GET">';
$form .= '<div class="form-group">'; $form .= '<input type="hidden" name="action" value="'.$action.'">';
$form .= '<label>'.get_lang('CourseCategories').'</label>'; $form .= '<input type="hidden" name="pageCurrent" value="'.$pageCurrent.'">';
$form .= '<select name="category_code" onchange="submit();" class="selectpicker show-tick form-control">'; $form .= '<input type="hidden" name="pageLength" value="'.$pageLength.'">';
$codeType = isset($_REQUEST['category_code']) ? Security::remove_XSS($_REQUEST['category_code']) : ''; $form .= '<div class="form-group">';
foreach ($browse_course_categories[0] as $category) { $form .= '<label>'.get_lang('CourseCategories').'</label>';
$categoryCode = $category['code']; $form .= '<select name="category_code" onchange="submit();" class="selectpicker show-tick form-control">';
$countCourse = $category['count_courses']; $codeType = isset($_REQUEST['category_code'])
$form .= '<option '.($categoryCode == $codeType ? 'selected="selected" ' : '').' value="'.$category['code'].'">'.$category['name'].' ( '.$countCourse.' ) </option>'; ? Security::remove_XSS($_REQUEST['category_code'])
if (!empty($browse_course_categories[$categoryCode])) { : '';
foreach ($browse_course_categories[$categoryCode] as $subCategory) { foreach ($browse_course_categories[0] as $category) {
$subCategoryCode = $subCategory['code']; $categoryCode = $category['code'];
$form .= '<option '.($subCategoryCode == $codeType ? 'selected="selected" ' : '').' value="'.$subCategory['code'].'"> ---'.$subCategory['name'].' ( '.$subCategory['count_courses'].' ) </option>'; $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) {
$subCategoryCode = $subCategory['code'];
$form .= '<option '
.($subCategoryCode == $codeType
? 'selected="selected" '
: '')
.' value="'.$subCategory['code'].'">---'.$subCategory['name'].' ( '
.$subCategory['count_courses']
.' )</option>';
}
} }
} }
} $form .= '</select>';
$form .= '</select>'; $form .= '</div>';
$form .= '</form>'; $form .= '</form>';
echo $form; echo $form;
?> ?>
</div>
</div>
<?php if ($showSessions) { ?>
<div class="col-md-4">
<div class="return-catalog">
<a class="btn btn-default btn-lg btn-block" href="<?php echo CourseCategory::getCourseCategoryUrl(1, $pageLength, null, 0, 'display_sessions'); ?>">
<em class="fa fa-arrow-right"></em> <?php echo get_lang('SessionList'); ?>
</a>
</div> </div>
</div> <?php } ?>
<?php } ?> <?php if ($showSessions) { ?>
<div class="col-md-4">
<div class="return-catalog">
<a class="btn btn-default btn-lg btn-block"
href="<?php echo CourseCategory::getCourseCategoryUrl(1, $pageLength, null, 0, 'display_sessions'); ?>">
<em class="fa fa-arrow-right"></em> <?php echo get_lang('SessionList'); ?>
</a>
</div>
</div>
<?php } ?>
</div>
</div> </div>
</div> </div>
</div> </div>
<?php } ?>
<div class="grid-courses"> <div class="grid-courses">
<?php <?php
if ($showCourses && $action != 'display_sessions') { if ($showCourses && $action != 'display_sessions') {

Loading…
Cancel
Save