123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- <?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();
- // Actions: The menu with the different options in cathe course management
- /*
- <?php if ($action != 'subscribe') { ?>
- <a href="<?php echo api_get_self(); ?>?action=subscribe"><?php echo Display::return_icon('user_subscribe_course.png', get_lang('SubscribeToCourse'),'','32'); ?></a>
- <?php } ?>
- <?php if ($action != 'sortmycourses' && isset($action)) { ?>
- <a href="<?php echo api_get_self(); ?>?action=sortmycourses"><?php echo Display::return_icon('course_move.png', get_lang('SortMyCourses'),'','32'); ?></a>
- <?php } ?>
- */
- ?>
- <script type="text/javascript">
- $(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('rel'),
- success: function(data) {
- $("#rating_wrapper_"+id).html(data);
- if(data == 'added') {
- //$('#vote_label_' + id).html('Saved');
- //$('#vote_label2_' + id).html("<?php echo get_lang('Saved')?>");
- }
- if(data == 'updated') {
- //$('#vote_label2_' + id).html("<?php echo get_lang('Saved')?>");
- }
- }
- })
- });
- });
- </script>
- <?php if (intval($_GET['hidden_links']) != 1) { ?>
- <div id="actions" class="actions">
- <span id="categories-search">
- <form class="course_list" method="post" action="<?php echo api_get_self(); ?>?action=subscribe&hidden_links=0">
- <input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
- <input type="hidden" name="search_course" value="1" />
- <input type="text" name="search_term" value="<?php echo (empty($_POST['search_term']) ? '' : api_htmlentities(Security::remove_XSS($_POST['search_term']))); ?>" />
- <button class="search" type="submit"><?php echo get_lang('SearchCourse'); ?></button>
- </form>
- </span>
- </div>
- <?php
- $hidden_links = 0;
- } else {
- $hidden_links = 1;
- }
- ?>
- <div id="categories-content" >
- <div id="categories-content-first">
- <div id="categories-list">
- <?php
- if (!empty($browse_course_categories)) {
- if ($action == 'display_random_courses') {
- echo '<strong>'.get_lang('RandomPick').'</strong>';
- $code = '';
- } else {
- echo '<a href="'.api_get_self().'?action=display_random_courses">'.get_lang('RandomPick').'</a>';
- }
-
- // 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="'. api_get_self().'?action=display_courses&category_code='.$category_code.'&hidden_links='.$hidden_links.'">'.$category_name.'</a> ('.$count_courses_lv1.')';
- } else {
- $category_link = ''.$category_name.' ('.$count_courses_lv1.')';
- }
- }
- echo '<div>'.$category_link.'</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="'. api_get_self().'?action=display_courses&category_code='.$subcategory1_code.'&hidden_links='.$hidden_links.'">'.$subcategory1_name.'</a> ('.$count_courses_lv2.')';
- }
- echo '<div style="margin-left:20px;">'.$subcategory1_link.'</div>';
- }
-
- // 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 '<div style="margin-left:40px;">'.$subcategory2_link.'</div>';
- }
- }
- }
- }
- }
- ?>
- </div>
- </div>
- <div id="categories-content-second">
- <?php
- if (!empty($message)) { Display::display_confirmation_message($message, false); }
- if (!empty($error)) { Display::display_error_message($error, false); }
- 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) {
- $title = 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
- }
-
- $rating = Display::return_rating_system('star_'.$course['real_id'], $ajax_url.'&course_id='.$course['real_id'], $course['point_info']);
- //<div class="course-block-main-item"><div class="left">'.get_lang('Teacher').'</div><div class="course-block-teacher right">'.$tutor_name.'</div></div>
- //<div class="course-block-main-item"><div class="left">'.get_lang('CreationDate').'</div><div class="course-block-date">'.api_format_date($creation_date,DATE_FORMAT_SHORT).'</div></div>
- echo '<div class="categories-block-course">
- <div class="categories-content-course">';
-
- echo '<div class="categories-course-picture"><center>';
- 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'].'" title="'.$icon_title.'" rel="gb_page_center[778]">';
- echo '<img src="'.$course_medium_image.'" />';
- echo '</a>';
- } else {
- echo '<img src="'.$course_medium_image.'" />';
- }
- echo '</center></div>';
-
-
- echo '<div class="categories-course-description">
- <div class="course-block-title">'.cut($title, 60).'</div>
- '.$rating.'
- </div>';
-
- 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 class="categories-course-links">';
- // we display the icon to subscribe or the text already subscribed
- if (!in_array($course['code'], $user_coursecodes)) {
- if ($course['subscribe'] == SUBSCRIBE_ALLOWED) {
- echo '<div class="course-link-desc right">
- <a class="a_button gray small" 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></div>';
- }
- }
- if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') {
- echo '<div class="course-link-desc right"><a class="ajax a_button white small" href="'.api_get_path(WEB_CODE_PATH).'inc/ajax/course_home.ajax.php?a=show_course_information&code='.$course['code'].'" title="'.$icon_title.'" class="thickbox">'.get_lang('Description').'</a></div>';
- }
- echo '</div>';
- echo '</div>';
- }
- } else {
- echo Display::display_warning_message(get_lang('ThereAreNoCoursesInThisCategory'));
- }
- ?>
- <div class="clear"></div>
- </div>
- </div>
|