123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- <?php
- /* For licensing terms, see /license.txt */
- /**
- * View (MVC patter) for courses categories
- * @author Christian Fasanando <christian1827@gmail.com> - Beeznest
- * @package chamilo.auth
- */
- $stok = Security::get_token();
- ?>
- <script>
- $(document).ready( function() {
- $('.star-rating li a').live('click', function(event) {
- var id = $(this).parents('ul').attr('id');
- $('#vote_label2_' + id).html("<?php echo get_lang('Loading'); ?>");
- $.ajax({
- url: $(this).attr('data-link'),
- success: function(data) {
- $("#rating_wrapper_"+id).html(data);
- if(data == 'added') {
- //$('#vote_label2_' + id).html("{'Saved'|get_lang}");
- }
- if(data == 'updated') {
- //$('#vote_label2_' + id).html("{'Saved'|get_lang}");
- }
- }
- });
- });
- });
- </script>
- <div class="row">
- <div class="span3">
- <div id="course_category_well" class="well">
- <ul class="nav nav-list">
- <?php if (!isset($_GET['hidden_links']) || isset($_GET['hidden_links']) && intval($_GET['hidden_links']) != 1) { ?>
- <form class="form-search" method="post" action="<?php echo api_get_self(); ?>?action=subscribe&hidden_links=0">
- <fieldset>
- <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 class="span2" type="text" name="search_term" value="<?php echo (empty($_POST['search_term']) ? '' : api_htmlentities(Security::remove_XSS($_POST['search_term']))); ?>" />
- <button class="btn" type="submit"><?php echo get_lang('Search'); ?></button>
- </div>
- </div>
- </div>
- </fieldset>
- </form>
- <?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" href="'.api_get_self().'?action=display_random_courses">'.get_lang('RandomPick').'</a><br /><br />';
- echo '<li class="nav-header">'.get_lang('CourseCategories').'</li>';
- // level 1
- foreach ($browse_course_categories[0] as $category) {
- $category_name = $category['name'];
- $category_code = isset($category['code']) ? $category['code'] : null;
- $count_courses_lv1 = $category['count_courses'];
- if (isset($code) && $code == $category_code) {
- $category_link = '<strong>'.$category_name.' ('.$count_courses_lv1.')</strong>';
- } else {
- if (!empty($count_courses_lv1)) {
- $category_link = '<a href="'. api_get_self().'?action=display_courses&category_code='.$category_code.'&hidden_links='.$hidden_links.'">'.$category_name.' ('.$count_courses_lv1.') </a>';
- } else {
- $category_link = ''.$category_name.' ('.$count_courses_lv1.')';
- }
- }
- echo '<li>'.$category_link.'</li>';
- // 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="'. api_get_self().'?action=display_courses&category_code='.$subcategory1_code.'&hidden_links='.$hidden_links.'">'.$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="'. api_get_self().'?action=display_courses&category_code='.$subcategory2_code.'&hidden_links='.$hidden_links.'">'.$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="'. api_get_self().'?action=display_courses&category_code='.$subcategory3_code.'&hidden_links='.$hidden_links.'">'.$subcategory3_name.' ('.$count_courses_lv4.') </a>';
- }
- echo '<li style="margin-left:60px;">'.$subcategory3_link.'</li>';
- }
- }
- }
- }
- }
- }
- }
- }
- ?>
- </div>
- </div>
- <div class="span9">
- <?php
- if (!empty($message)) { Display::display_confirmation_message($message, false); }
- if (!empty($error)) { Display::display_error_message($error, false); }
- if (!empty($content)) { echo $content; }
- if (!empty($search_term)) {
- echo "<p><strong>".get_lang('SearchResultsFor')." ".Security::remove_XSS($_POST['search_term'])."</strong><br />";
- }
- $ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
- if (!empty($browse_courses_in_category)) {
- foreach ($browse_courses_in_category as $course) {
- // if course is closed, don't show it.
- if ($course['visibility'] == COURSE_VISIBILITY_CLOSED) {
- continue;
- }
- // course isn't closed
- $title = Text::cut($course['title'], 70);
- $tutor_name = $course['tutor'];
- $creation_date = substr($course['creation_date'],0,10);
- $count_connections = $course['count_connections'];
- $course_path = api_get_path(SYS_COURSE_PATH).$course['directory']; // course path
- if (file_exists($course_path.'/course-pic85x85.png')) {
- $course_medium_image = api_get_path(WEB_COURSE_PATH).$course['directory'].'/course-pic85x85.png'; // redimensioned image 85x85
- } else {
- $course_medium_image = api_get_path(WEB_IMG_PATH).'without_picture.png'; // without picture
- }
- $pointInfo = isset($course['point_info']) ? $course['point_info'] : null;
- $rating = Display::return_rating_system('star_'.$course['real_id'], $ajax_url.'&course_id='.$course['real_id'], $pointInfo);
- echo '<div class="well_border"><div class="row">';
- echo '<div class="span2">';
- echo '<div class="thumbnail">';
- if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') {
- echo '<a class="ajax" href="'.api_get_path(WEB_CODE_PATH).'inc/ajax/course_home.ajax.php?a=show_course_information&code='.$course['code'].'" rel="gb_page_center[778]">';
- echo '<img src="'.$course_medium_image.'" alt="" />';
- echo '</a>';
- } else {
- echo '<img src="'.$course_medium_image.'" alt="'.$title.'"/>';
- }
- echo '</div>';//thumb
- echo '</div>';
- echo '<div class="span4">';
- $teachers = CourseManager::get_teacher_list_from_course_code_to_string($course['real_id']);
- $teachers = '<h5>'.$teachers.'</h5>';
- echo '<div class="categories-course-description"><h3>'.Text::cut($title, 60).'</h3>'.$teachers.$rating.'</div>';
- echo '<p>';
- // we display the icon to subscribe or the text already subscribed
- echo '<div class="btn-toolbar">';
- if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') {
- echo '<a class="ajax btn" href="'.api_get_path(WEB_CODE_PATH).'inc/ajax/course_home.ajax.php?a=show_course_information&code='.$course['code'].'" class="thickbox">'.get_lang('Description').'</a>';
- }
- // Get access type for course button ("enter" or/and "register")
- $access_type = CourseManager::get_access_link_by_user(api_get_user_id(), $course);
- // Go To Course button (only if admin, if course public or if student already subscribed)
- if ($access_type && in_array('enter', $access_type)) {
- echo ' <a class="btn btn-primary" href="'. api_get_course_url($course['code']).'">'.get_lang('GoToCourse').'</a>';
- }
- // Register button
- if ($access_type && in_array('register', $access_type)) {
- echo ' <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>';
- }
- // If user is already subscribed to the course
- if (!api_is_anonymous() && in_array($course['code'], $user_coursecodes)) {
- if ($course['unsubscribe'] == UNSUBSCRIBE_ALLOWED) {
- echo ' <a class="btn btn-primary" href="'. api_get_self().'?action=unsubscribe&sec_token='.$stok.'&unsubscribe='.$course['code'].'&search_term='.$search_term.'&category_code='.$code.'">'.get_lang('Unsubscribe').'</a>';
- }
- echo '<br />';
- echo '<br />';
- echo Display::label(get_lang("AlreadyRegisteredToCourse"), "info");
- }
- echo '</div>';
- echo '</p>';
- echo '</div>';
- echo '<div class="span2">';
- echo '<div class="course-block-popularity"><span>'.get_lang('ConnectionsLastMonth').'</span><div class="course-block-popularity-score">'.$count_connections.'</div></div>';
- echo '</div>';
- echo '</div></div>';
- }
- } else {
- if (!isset($_REQUEST['subscribe_user_with_password']) && !isset($_REQUEST['subscribe_course'])) {
- echo Display::display_warning_message(get_lang('ThereAreNoCoursesInThisCategory'));
- }
- }
- ?>
- </div>
- </div>
|