@ -106,42 +106,71 @@ $code = isset($code) ? $code : null;
< / script >
< div class = "row" >
< div class = "col-md-6" >
< h2 > <?php echo get_lang ( 'Search' ); ?> </ h2 >
<?php if ( $showCourses ) { ?>
<?php if ( ! isset ( $_GET [ 'hidden_links' ]) || intval ( $_GET [ 'hidden_links' ]) != 1 ) { ?>
< form class = "form-search" method = "post" action = " <?php echo getCourseCategoryUrl ( 1 , $pageLength , 'ALL' , 0 , 'subscribe' ); ?> " >
< div class = "col-md-4" >
< h5 > <?php echo get_lang ( 'Search' ); ?> </ h5 >
<?php
if ($showCourses) {
if (!isset($_GET['hidden_links']) || intval($_GET['hidden_links']) != 1) { ?>
< form class = "form-horizontal" method = "post" action = " <?php echo getCourseCategoryUrl ( 1 , $pageLength , 'ALL' , 0 , 'subscribe' ); ?> " >
< input type = "hidden" name = "sec_token" value = " <?php echo $stok ; ?> " >
< input type = "hidden" name = "search_course" value = "1" / >
< div class = "control-group" >
< div class = "controls" >
< div class = "input-append" >
< input type = "text" name = "search_term" value = " <?php echo ( empty ( $_POST [ 'search_term' ]) ? '' : api_htmlentities ( Security :: remove_XSS ( $_POST [ 'search_term' ]))); ?> " />
< div class = "btn-group" >
< button class = "btn btn-default btn-sm" type = "submit" >
< 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' ]))); ?> " />
< div class = "input-group-btn" >
< button class = "btn btn-default" type = "submit" >
< i class = "fa fa-search" ></ i > <?php echo get_lang ( 'Search' ); ?>
< / button >
< / div >
< / div >
< / form >
<?php } ?>
< / div >
< div class = "col-md-4" >
< h5 > <?php echo get_lang ( 'CourseCategories' ); ?> </ h5 >
<?php
$hidden_links = 0;
} else {
$hidden_links = 1;
}
/* Categories will only show down to 4 levels, if you want more,
* you will have to patch the following code. We don't recommend
* it, as this can considerably slow down your system
*/
if (!empty($browse_course_categories)) {
echo '< a class = "btn btn-default btn-sm" href = "'.api_get_self().'?action=display_random_courses" > '.get_lang('RandomPick').'< / a > ';
$webAction = api_get_path(WEB_CODE_PATH).'auth/courses.php';
$action = 'display_courses';
$pageLength = 10;
$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 . '" > ';
$form .= '< input type = "hidden" name = "pageLength" value = "' . $pageLength . '" > ';
$form .= '< div class = "form-group" > ';
$form .= '< div class = "col-sm-12" > ';
$form .= '< select name = "category_code" onchange = "submit();" class = "chzn-select form-control" > ';
$codeType = $_GET[category_code];
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){
$subCategoryCode = $subCategory[code];
$form .= '< option ' . ( $ subCategoryCode = = $ codeType ? ' selected = "selected" ' : ' ' ) . ' value = "' . $subCategory[code] . '" > ---' . $subCategory[name] . ' ( '. $subCategory[count_courses] .' ) < / option > ';
}
}
}
$form .= '< / select > ';
$form .= '< / div > ';
$from .= '< / form > ';
echo $form;
?>
< / div >
< / div >
<?php
if ($showSessions) { ?>
< div class = "col-md-4" >
< h5 > <?php echo get_lang ( 'Sessions' ); ?> </ h5 >
< a class = "btn btn-default btn-block" href = " <?php echo getCourseCategoryUrl ( 1 , $pageLength , null , 0 , 'display_sessions' ); ?> " > <?php echo get_lang ( 'SessionList' ); ?> </ a >
< / div >
<?php } ?>
< / div >
< / form >
< / div >
< div class = "col-md-6" > < / div >
< / div >
<?php } ?>
< div class = "row" >
<?php if ( $showCourses && $action != 'display_sessions' ) {
@ -179,6 +208,7 @@ $code = isset($code) ? $code : null;
$course_open = ($course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM);
$course_private = ($course['visibility'] == COURSE_VISIBILITY_REGISTERED);
$course_closed = ($course['visibility'] == COURSE_VISIBILITY_CLOSED);
$course_subscribe_allowed = ($course['subscribe'] == 1);
$course_unsubscribe_allowed = ($course['unsubscribe'] == 1);
$count_connections = $course['count_connections'];
@ -200,32 +230,32 @@ $code = isset($code) ? $code : null;
// if user registered as student
if ($user_registerd_in_course_as_student) {
if (!$course_closed) {
//$html .= return_goto_button($course);
$html .= return_description_button($course, $icon_title);
if ($course_unsubscribe_allowed) {
$html .= return_unregister_button($course, $stok, $search_term, $code);
}
$html .= return_already_registered_label('student');
}
$html .= return_description_button($course, $icon_title);
} elseif ($user_registerd_in_course_as_teacher) {
// if user registered as teacher
//$html .= return_goto_button($course);
$html .= return_description_button($course, $icon_title);
if ($course_unsubscribe_allowed) {
$html .= return_unregister_button($course, $stok, $search_term, $code);
}
$html .= return_already_registered_label('teacher');
$html .= return_description_button($course, $icon_title);
} else {
// if user not registered in the course
if (!$course_closed) {
if (!$course_private) {
$html .= return_goto_button($course);
// $html .= return_goto_button($course);
if ($course_subscribe_allowed) {
$html .= return_register_button($course, $stok, $code, $search_term);
}
}
$html .= return_description_button($course, $icon_title);
}
$html .= return_description_button($course, $icon_title);
}
$html .= '< / div > ';
@ -244,146 +274,10 @@ $code = isset($code) ? $code : null;
}
}
echo $cataloguePagination;
?>
< / div >
< div class = "row" >
< div class = "col-md-3" >
< div class = "panel panel-default" >
< div class = "panel-heading" >
<?php
echo get_lang('CourseCategories').'< / div > ';
$action = 'display_courses';
// level 1
foreach ($browse_course_categories[0] as $category) {
$category_name = $category['name'];
$category_code = $category['code'];
$count_courses_lv1 = $category['count_courses'];
if ($code == $category_code) {
$category_link = '< strong > '.$category_name.' ('.$count_courses_lv1.')< / strong > ';
} else {
if (!empty($count_courses_lv1)) {
$category_link = '< a href = "' .
getCourseCategoryUrl(
1,
$pageLength,
$category_code,
$hidden_links,
$action
) .'">'.$category_name.' ('.$count_courses_lv1.') < / a > ';
} else {
$category_link = ''.$category_name.' ('.$count_courses_lv1.')';
}
}
echo '< div class = "panel-body" > ';
echo '< ul class = "nav nav-pills nav-stacked" > ';
echo '< li > '.$category_link.'< / li > ';
echo '< / ul > < / div > ';
// level 2
if (!empty($browse_course_categories[$category_code])) {
foreach ($browse_course_categories[$category_code] as $subcategory1) {
$subcategory1_name = $subcategory1['name'];
$subcategory1_code = $subcategory1['code'];
$count_courses_lv2 = $subcategory1['count_courses'];
if ($code == $subcategory1_code) {
$subcategory1_link = '< strong > '.$subcategory1_name.' ('.$count_courses_lv2.')< / strong > ';
} else {
$subcategory1_link = '< a href = "' .
getCourseCategoryUrl(
1,
$pageLength,
$subcategory1_code,
$hidden_links,
$action
) . '">'.$subcategory1_name.' ('.$count_courses_lv2.') < / a > ';
}
echo '< li style = "margin-left:20px;" > '.$subcategory1_link.'< / li > ';
// level 3
if (!empty($browse_course_categories[$subcategory1_code])) {
foreach ($browse_course_categories[$subcategory1_code] as $subcategory2) {
$subcategory2_name = $subcategory2['name'];
$subcategory2_code = $subcategory2['code'];
$count_courses_lv3 = $subcategory2['count_courses'];
if ($code == $subcategory2_code) {
$subcategory2_link = '< strong > '.$subcategory2_name.' ('.$count_courses_lv3.')< / strong > ';
} else {
$subcategory2_link = '< a href = "' .
getCourseCategoryUrl(
1,
$pageLength,
$subcategory2_code,
$hidden_links,
$action
) . '">'.$subcategory2_name.'< / a > ('.$count_courses_lv3.')';
}
echo '< li style = "margin-left:40px;" > '.$subcategory2_link.'< / li > ';
// level 4
if (!empty($browse_course_categories[$subcategory2_code])) {
foreach ($browse_course_categories[$subcategory2_code] as $subcategory3) {
$subcategory3_name = $subcategory3['name'];
$subcategory3_code = $subcategory3['code'];
$count_courses_lv4 = $subcategory3['count_courses'];
if ($code == $subcategory3_code) {
$subcategory3_link = '< strong > '.$subcategory3_name.' ('.$count_courses_lv4.')< / strong > ';
} else {
$subcategory3_link = '< a href = "' .
getCourseCategoryUrl(
1,
$pageLength,
$subcategory3_code,
$hidden_links,
$action
) . '">'.$subcategory3_name.' ('.$count_courses_lv4.') < / a > ';
}
echo '< li style = "margin-left:60px;" > '.$subcategory3_link.'< / li > ';
}
}
}
}
}
}
} ?>
< / ul >
< / div >
<?php
}
}
if ($showSessions) { ?>
< div class = "panel panel-default" >
< div class = "panel-heading" > <?php echo get_lang ( 'Sessions' ); ?> </ div >
< div class = "panel-body" >
<?php if ( $action == 'display_sessions' && $_SERVER [ 'REQUEST_METHOD' ] != 'POST' ) { ?>
< strong > <?php echo get_lang ( 'Sessions' ); ?> </ strong >
<?php } else { ?>
< a href = " <?php echo getCourseCategoryUrl ( 1 , $pageLength , null , 0 , 'display_sessions' ); ?> " > <?php echo get_lang ( 'SessionList' ); ?> </ a >
<?php } ?>
< p > <?php echo get_lang ( 'SearchActiveSessions' ) ?> </ p >
< form class = "form-search" method = "post" action = " <?php echo getCourseCategoryUrl ( 1 , $pageLength , null , 0 , 'display_sessions' ); ?> " >
< div class = "input-append" >
<?php echo Display :: input ( 'date' , 'date' , $date , array (
'class' => 'span2',
'id' => 'date',
'readonly' => ''
)); ?>
< button class = "btn btn-default" type = "submit" >
<?php echo get_lang ( 'Search' ); ?>
< / button >
< / div >
< / form >
< / div >
< / div >
<?php } ?>
?>
< / div >
< / div >
<?php
/**
@ -423,8 +317,7 @@ function return_thumbnail($course, $icon_title)
* @param $course
*/
function return_title($course)
{
$html = '';
{ $html = '';
$linkCourse = api_get_course_url($course['code']);
$title = cut($course['title'], 70);
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
@ -483,7 +376,7 @@ function return_already_registered_label($in_status)
*/
function return_register_button($course, $stok, $code, $search_term)
{
$html = ' < a class = "btn btn-primary " href = "'.api_get_self().'?action=subscribe_course&sec_token='.$stok.'&subscribe_course='.$course['code'].'&search_term='.$search_term.'&category_code='.$code.'" > '.get_lang('Subscribe').'< / a > ';
$html = ' < a class = "btn btn-success btn-block btn-sm " href = "'.api_get_self().'?action=subscribe_course&sec_token='.$stok.'&subscribe_course='.$course['code'].'&search_term='.$search_term.'&category_code='.$code.'" > '.get_lang('Subscribe').'< / a > ';
return $html;
}