courses_categories.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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 type="text/javascript">
  20. $(document).ready( function() {
  21. $('.star-rating li a').live('click', function(event) {
  22. var id = $(this).parents('ul').attr('id');
  23. $('#vote_label2_' + id).html('<?php echo get_lang('Loading');?>');
  24. $.ajax({
  25. url: $(this).attr('rel'),
  26. success: function(data) {
  27. $("#rating_wrapper_"+id).html(data);
  28. if(data == 'added') {
  29. //$('#vote_label_' + id).html('Saved');
  30. //$('#vote_label2_' + id).html("<?php echo get_lang('Saved')?>");
  31. }
  32. if(data == 'updated') {
  33. //$('#vote_label2_' + id).html("<?php echo get_lang('Saved')?>");
  34. }
  35. }
  36. })
  37. });
  38. });
  39. </script>
  40. <?php if (intval($_GET['hidden_links']) != 1) { ?>
  41. <div id="actions" class="actions">
  42. <span id="categories-search">
  43. <form class="course_list" method="post" action="<?php echo api_get_self(); ?>?action=subscribe&amp;hidden_links=0">
  44. <input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
  45. <input type="hidden" name="search_course" value="1" />
  46. <input type="text" name="search_term" value="<?php echo (empty($_POST['search_term']) ? '' : api_htmlentities(Security::remove_XSS($_POST['search_term']))); ?>" />
  47. &nbsp;<button class="search" type="submit"><?php echo get_lang('SearchCourse'); ?></button>
  48. </form>
  49. </span>
  50. </div>
  51. <?php
  52. $hidden_links = 0;
  53. } else {
  54. $hidden_links = 1;
  55. }
  56. ?>
  57. <div id="categories-content" >
  58. <div id="categories-content-first">
  59. <div id="categories-list">
  60. <?php
  61. if (!empty($browse_course_categories)) {
  62. if ($action == 'display_random_courses') {
  63. echo '<strong>'.get_lang('RandomPick').'</strong>';
  64. $code = '';
  65. } else {
  66. echo '<a href="'.api_get_self().'?action=display_random_courses">'.get_lang('RandomPick').'</a>';
  67. }
  68. // level 1
  69. foreach ($browse_course_categories[0] as $category) {
  70. $category_name = $category['name'];
  71. $category_code = $category['code'];
  72. $count_courses_lv1 = $category['count_courses'];
  73. if ($code == $category_code) {
  74. $category_link = '<strong>'.$category_name.' ('.$count_courses_lv1.')</strong>';
  75. } else {
  76. if (!empty($count_courses_lv1)) {
  77. $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.')';
  78. } else {
  79. $category_link = ''.$category_name.' ('.$count_courses_lv1.')';
  80. }
  81. }
  82. echo '<div>'.$category_link.'</div>';
  83. // level 2
  84. if (!empty($browse_course_categories[$category_code])) {
  85. foreach ($browse_course_categories[$category_code] as $subcategory1) {
  86. $subcategory1_name = $subcategory1['name'];
  87. $subcategory1_code = $subcategory1['code'];
  88. $count_courses_lv2 = $subcategory1['count_courses'];
  89. if ($code == $subcategory1_code) {
  90. $subcategory1_link = '<strong>'.$subcategory1_name.' ('.$count_courses_lv2.')</strong>';
  91. } else {
  92. $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.')';
  93. }
  94. echo '<div style="margin-left:20px;">'.$subcategory1_link.'</div>';
  95. }
  96. // level 3
  97. if (!empty($browse_course_categories[$subcategory1_code])) {
  98. foreach ($browse_course_categories[$subcategory1_code] as $subcategory2) {
  99. $subcategory2_name = $subcategory2['name'];
  100. $subcategory2_code = $subcategory2['code'];
  101. $count_courses_lv3 = $subcategory2['count_courses'];
  102. if ($code == $subcategory2_code) {
  103. $subcategory2_link = '<strong>'.$subcategory2_name.' ('.$count_courses_lv3.')</strong>';
  104. } else {
  105. $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.')';
  106. }
  107. echo '<div style="margin-left:40px;">'.$subcategory2_link.'</div>';
  108. }
  109. }
  110. }
  111. }
  112. }
  113. ?>
  114. </div>
  115. </div>
  116. <div id="categories-content-second">
  117. <?php
  118. if (!empty($message)) { Display::display_confirmation_message($message, false); }
  119. if (!empty($error)) { Display::display_error_message($error, false); }
  120. if (!empty($search_term)) {
  121. echo "<p><strong>".get_lang('SearchResultsFor')." ".Security::remove_XSS($_POST['search_term'])."</strong><br />";
  122. }
  123. $ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
  124. if (!empty($browse_courses_in_category)) {
  125. foreach ($browse_courses_in_category as $course) {
  126. $title = cut($course['title'], 70);
  127. $tutor_name = $course['tutor'];
  128. $creation_date = substr($course['creation_date'],0,10);
  129. $count_connections = $course['count_connections'];
  130. $course_path = api_get_path(SYS_COURSE_PATH).$course['directory']; // course path
  131. if (file_exists($course_path.'/course-pic85x85.png')) {
  132. $course_medium_image = api_get_path(WEB_COURSE_PATH).$course['directory'].'/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('star_'.$course['real_id'], $ajax_url.'&course_id='.$course['real_id'], $course['point_info']);
  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>