courses_categories.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * View (MVC patter) for courses categories
  5. * @author Christian Fasanando <christian1827@gmail.com> - Beeznest
  6. * @package chamilo.auth
  7. */
  8. $stok = Security::get_token();
  9. // Actions: The menu with the different options in cathe course management
  10. /*
  11. <?php if ($action != 'subscribe') { ?>
  12. &nbsp;<a href="<?php echo api_get_self(); ?>?action=subscribe"><?php echo Display::return_icon('user_subscribe_course.png', get_lang('SubscribeToCourse'),'','32'); ?></a>
  13. <?php } ?>
  14. <?php if ($action != 'sortmycourses' && isset($action)) { ?>
  15. &nbsp;<a href="<?php echo api_get_self(); ?>?action=sortmycourses"><?php echo Display::return_icon('course_move.png', get_lang('SortMyCourses'),'','32'); ?></a>
  16. <?php } ?>
  17. */
  18. ?>
  19. <script>
  20. $(document).ready( function() {
  21. $('.star-rating li a').click(function(){
  22. var id = $(this).parents('ul').attr('id');
  23. $('#vote_label2_' + id).html('<?php echo Display::return_icon('loading1.gif');?>');
  24. $.ajax({
  25. url: $(this).attr('rel'),
  26. success: function(data) {
  27. if(data == 'added') {
  28. //$('#vote_label_' + id).html('Saved');
  29. $('#vote_label2_' + id).html("<?php echo get_lang('Saved')?>");
  30. }
  31. if(data == 'updated') {
  32. $('#vote_label2_' + id).html("<?php echo get_lang('Saved')?>");
  33. }
  34. },
  35. })
  36. });
  37. });
  38. </script>
  39. <?php if (intval($_GET['hidden_links']) != 1) { ?>
  40. <div id="actions" class="actions">
  41. <span id="categories-search">
  42. <form class="course_list" method="post" action="<?php echo api_get_self(); ?>?action=subscribe&amp;hidden_links=0">
  43. <input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
  44. <input type="hidden" name="search_course" value="1" />
  45. <input type="text" name="search_term" value="<?php echo (empty($_POST['search_term']) ? '' : api_htmlentities(Security::remove_XSS($_POST['search_term']))); ?>" />
  46. &nbsp;<button class="search" type="submit"><?php echo get_lang('SearchCourse'); ?></button>
  47. </form>
  48. </span>
  49. </div>
  50. <?php
  51. $hidden_links = 0;
  52. } else {
  53. $hidden_links = 1;
  54. }
  55. ?>
  56. <div id="categories-content" >
  57. <div id="categories-content-first">
  58. <div id="categories-list">
  59. <?php
  60. if (!empty($browse_course_categories)) {
  61. if ($action == 'display_random_courses') {
  62. echo '<strong>'.get_lang('RandomPick').'</strong>';
  63. $code = '';
  64. } else {
  65. echo '<a href="'.api_get_self().'?action=display_random_courses">'.get_lang('RandomPick').'</a>';
  66. }
  67. // level 1
  68. foreach ($browse_course_categories[0] as $category) {
  69. $category_name = $category['name'];
  70. $category_code = $category['code'];
  71. $count_courses_lv1 = $category['count_courses'];
  72. if ($code == $category_code) {
  73. $category_link = '<strong>'.$category_name.' ('.$count_courses_lv1.')</strong>';
  74. } else {
  75. if (!empty($count_courses_lv1)) {
  76. $category_link = '<a href="'. api_get_self().'?action=display_courses&amp;category_code='.$category_code.'&amp;hidden_links='.$hidden_links.'">'.$category_name.'</a> ('.$count_courses_lv1.')';
  77. } else {
  78. $category_link = ''.$category_name.' ('.$count_courses_lv1.')';
  79. }
  80. }
  81. echo '<div>'.$category_link.'</div>';
  82. // level 2
  83. if (!empty($browse_course_categories[$category_code])) {
  84. foreach ($browse_course_categories[$category_code] as $subcategory1) {
  85. $subcategory1_name = $subcategory1['name'];
  86. $subcategory1_code = $subcategory1['code'];
  87. $count_courses_lv2 = $subcategory1['count_courses'];
  88. if ($code == $subcategory1_code) {
  89. $subcategory1_link = '<strong>'.$subcategory1_name.' ('.$count_courses_lv2.')</strong>';
  90. } else {
  91. $subcategory1_link = '<a href="'. api_get_self().'?action=display_courses&amp;category_code='.$subcategory1_code.'&amp;hidden_links='.$hidden_links.'">'.$subcategory1_name.'</a> ('.$count_courses_lv2.')';
  92. }
  93. echo '<div style="margin-left:20px;">'.$subcategory1_link.'</div>';
  94. }
  95. // level 3
  96. if (!empty($browse_course_categories[$subcategory1_code])) {
  97. foreach ($browse_course_categories[$subcategory1_code] as $subcategory2) {
  98. $subcategory2_name = $subcategory2['name'];
  99. $subcategory2_code = $subcategory2['code'];
  100. $count_courses_lv3 = $subcategory2['count_courses'];
  101. if ($code == $subcategory2_code) {
  102. $subcategory2_link = '<strong>'.$subcategory2_name.' ('.$count_courses_lv3.')</strong>';
  103. } else {
  104. $subcategory2_link = '<a href="'. api_get_self().'?action=display_courses&amp;category_code='.$subcategory2_code.'&amp;hidden_links='.$hidden_links.'">'.$subcategory2_name.'</a> ('.$count_courses_lv3.')';
  105. }
  106. echo '<div style="margin-left:40px;">'.$subcategory2_link.'</div>';
  107. }
  108. }
  109. }
  110. }
  111. }
  112. ?>
  113. </div>
  114. </div>
  115. <div id="categories-content-second">
  116. <?php
  117. if (!empty($message)) { Display::display_confirmation_message($message, false); }
  118. if (!empty($error)) { Display::display_error_message($error, false); }
  119. if (!empty($search_term)) {
  120. echo "<p><strong>".get_lang('SearchResultsFor')." ".Security::remove_XSS($_POST['search_term'])."</strong><br />";
  121. }
  122. $ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
  123. if (!empty($browse_courses_in_category)) {
  124. foreach ($browse_courses_in_category as $course) {
  125. $title = cut($course['title'], 70);
  126. $tutor_name = $course['tutor'];
  127. $creation_date = substr($course['creation_date'],0,10);
  128. $count_connections = $course['count_connections'];
  129. $course_path = api_get_path(SYS_COURSE_PATH).$course['directory']; // course path
  130. if (file_exists($course_path.'/course-pic85x85.png')) {
  131. $course_web_path = api_get_path(WEB_COURSE_PATH).$course['directory']; // course web path
  132. $course_medium_image = $course_web_path.'/course-pic85x85.png'; // redimensioned image 85x85
  133. } else {
  134. $course_medium_image = api_get_path(WEB_IMG_PATH).'without_picture.png'; // without picture
  135. }
  136. $rating = Display::return_rating_system($course['code'].'_rating', $course['point_average'], $ajax_url.'&course_id='.$course['real_id'], $course['users_who_voted']);
  137. //<div class="course-block-main-item"><div class="left">'.get_lang('Teacher').'</div><div class="course-block-teacher right">'.$tutor_name.'</div></div>
  138. //<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>
  139. echo '<div class="categories-block-course">
  140. <div class="categories-content-course">';
  141. echo '<div class="categories-course-picture"><center>';
  142. if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') {
  143. echo '<a class="ajax" href="'.api_get_path(WEB_CODE_PATH).'inc/ajax/course_home.ajax.php?a=show_course_information&amp;code='.$course['code'].'" title="'.$icon_title.'" rel="gb_page_center[778]">';
  144. echo '<img src="'.$course_medium_image.'" />';
  145. echo '</a>';
  146. } else {
  147. echo '<img src="'.$course_medium_image.'" />';
  148. }
  149. echo '</center></div>';
  150. echo '<div class="categories-course-description">
  151. <div class="course-block-title">'.cut($title, 60).'</div>
  152. '.$rating.'
  153. </div>';
  154. echo '<div class="course-block-popularity"><span>'.get_lang('ConnectionsLastMonth').'</span><div class="course-block-popularity-score">'.$count_connections.'</div></div>';
  155. echo '</div>';
  156. echo '<div class="categories-course-links">';
  157. // we display the icon to subscribe or the text already subscribed
  158. if (!in_array($course['code'], $user_coursecodes)) {
  159. if ($course['subscribe'] == SUBSCRIBE_ALLOWED) {
  160. echo '<div class="course-link-desc right">
  161. <a class="a_button gray small" href="'. api_get_self().'?action=subscribe_course&amp;sec_token='.$stok.'&amp;subscribe_course='.$course['code'].'&amp;search_term='.$search_term.'&amp;category_code='.$code.'">'.get_lang('Subscribe').'</a></div>';
  162. }
  163. }
  164. if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') {
  165. 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&amp;code='.$course['code'].'" title="'.$icon_title.'" class="thickbox">'.get_lang('Description').'</a></div>';
  166. }
  167. echo '</div>';
  168. echo '</div>';
  169. }
  170. } else {
  171. echo Display::display_warning_message(get_lang('ThereAreNoCoursesInThisCategory'));
  172. }
  173. ?>
  174. <div class="clear"></div>
  175. </div>
  176. </div>