banner.lib.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Code
  5. * @package chamilo.include
  6. */
  7. /**
  8. * Determines the possible tabs (=sections) that are available.
  9. * This function is used when creating the tabs in the third header line and
  10. * all the sections that do not appear there (as determined by the
  11. * platform admin on the Dokeos configuration settings page)
  12. * will appear in the right hand menu that appears on several other pages
  13. * @return array containing all the possible tabs
  14. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  15. */
  16. function get_tabs() {
  17. global $_course;
  18. // Campus Homepage
  19. $navigation[SECTION_CAMPUS]['url'] = api_get_path(WEB_PATH).'index.php';
  20. $navigation[SECTION_CAMPUS]['title'] = get_lang('CampusHomepage');
  21. // My Courses
  22. if(api_get_setting('use_session_mode')=='true') {
  23. if(api_is_allowed_to_create_course()) {
  24. // Link to my courses for teachers
  25. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php?nosession=true';
  26. $navigation['mycourses']['title'] = get_lang('MyCourses');
  27. } else {
  28. // Link to my courses for students
  29. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php';
  30. $navigation['mycourses']['title'] = get_lang('MyCourses');
  31. }
  32. } else {
  33. // Link to my courses
  34. $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php';
  35. $navigation['mycourses']['title'] = get_lang('MyCourses');
  36. }
  37. // My Profile
  38. $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
  39. $navigation['myprofile']['title'] = get_lang('ModifyProfile');
  40. // Link to my agenda
  41. $navigation['myagenda']['url'] = api_get_path(WEB_CODE_PATH).'calendar/myagenda.php?view=month&'.(!empty($_course['path']) ? 'coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
  42. $navigation['myagenda']['title'] = get_lang('MyAgenda');
  43. // Gradebook
  44. if (api_get_setting('gradebook_enable') == 'true') {
  45. $navigation['mygradebook']['url'] = api_get_path(WEB_CODE_PATH).'gradebook/gradebook.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
  46. $navigation['mygradebook']['title'] = get_lang('MyGradebook');
  47. }
  48. // Reporting
  49. if(api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
  50. // Link to my space
  51. $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/';
  52. $navigation['session_my_space']['title'] = get_lang('MySpace');
  53. } else {
  54. // Link to my progress
  55. $navigation['session_my_progress']['url'] = api_get_path(WEB_CODE_PATH).'auth/my_progress.php';
  56. $navigation['session_my_progress']['title'] = get_lang('MyProgress');
  57. }
  58. // Social
  59. if (api_get_setting('allow_social_tool')=='true') {
  60. $navigation['social']['url'] = api_get_path(WEB_CODE_PATH).'social/home.php';
  61. require_once api_get_path(LIBRARY_PATH).'message.lib.php';
  62. require_once api_get_path(LIBRARY_PATH).'social.lib.php';
  63. // get count unread message and total invitations
  64. $count_unread_message = MessageManager::get_number_of_messages(true);
  65. $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id());
  66. $group_pending_invitations = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION,false);
  67. $group_pending_invitations = 0;
  68. if (!empty($group_pending_invitations )) {
  69. $group_pending_invitations = count($group_pending_invitations);
  70. }
  71. $total_invitations = intval($number_of_new_messages_of_friend) + $group_pending_invitations + intval($count_unread_message);
  72. $total_invitations = (!empty($total_invitations)?' ('.$total_invitations.')':'');
  73. $navigation['social']['title'] = get_lang('SocialNetwork'). $total_invitations;
  74. }
  75. // Dashboard
  76. if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
  77. $navigation['dashboard']['url'] = api_get_path(WEB_CODE_PATH).'dashboard/index.php';
  78. $navigation['dashboard']['title'] = get_lang('Dashboard');
  79. }
  80. // Platform administration
  81. if (api_is_platform_admin(true)) {
  82. //$navigation['platform_admin']['url'] = $rootAdminWeb;
  83. $navigation['platform_admin']['url'] = api_get_path(WEB_CODE_PATH).'admin/';
  84. $navigation['platform_admin']['title'] = get_lang('PlatformAdmin');
  85. }
  86. return $navigation;
  87. }
  88. function show_header_1($language_file, $nameTools) {
  89. $_course = api_get_course_info();
  90. echo '<div id="header1">';
  91. echo '<div id="top_corner"></div>';
  92. $logo = api_get_path(SYS_CODE_PATH).'css/'.api_get_visual_theme().'/images/header-logo.png';
  93. $site_name = api_get_setting('siteName');
  94. if (file_exists($logo)) {
  95. $site_name = api_get_setting('Institution').' - '.$site_name;
  96. echo '<div id="logo">';
  97. $image_url = api_get_path(WEB_CSS_PATH).api_get_visual_theme().'/images/header-logo.png';
  98. $logo = Display::img($image_url, $site_name, array('title'=>$site_name));
  99. echo Display::url($logo, api_get_path(WEB_PATH).'index.php');
  100. echo '</div>';
  101. } else {
  102. echo '<a href="'.api_get_path(WEB_PATH).'index.php" target="_top">'.$site_name.'</a>';
  103. $iurl = api_get_setting('InstitutionUrl');
  104. $iname = api_get_setting('Institution');
  105. if (!empty($iname)) {
  106. echo '-&nbsp;<a href="'.$iurl.'" target="_top">'.$iname.'</a>';
  107. }
  108. // External link section a.k.a Department - Department URL
  109. if (isset($_course['extLink']) && $_course['extLink']['name'] != '') {
  110. echo '<span class="extLinkSeparator"> - </span>';
  111. if ($_course['extLink']['url'] != '') {
  112. echo '<a class="extLink" href="'.$_course['extLink']['url'].'" target="_top">';
  113. echo $_course['extLink']['name'];
  114. echo '</a>';
  115. } else {
  116. echo $_course['extLink']['name'];
  117. }
  118. }
  119. }
  120. /* Course title section */
  121. if (!empty($_cid) and $_cid != -1 and isset($_course)) {
  122. //Put the name of the course in the header
  123. echo '<div id="my_courses">';
  124. /* <div id="my_courses"><a href="<?php echo api_get_path(WEB_COURSE_PATH).$_course['path']; ?>/index.php" target="_top">&nbsp;
  125. echo $_course['name'].' ';
  126. if (api_get_setting('display_coursecode_in_courselist') == 'true') {
  127. echo $_course['official_code'];
  128. }
  129. if (api_get_setting('use_session_mode') == 'true' && isset($_SESSION['session_name'])) {
  130. echo '&nbsp;('.$_SESSION['session_name'].')&nbsp;';
  131. }
  132. if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') {
  133. echo ' - ';
  134. }
  135. if (api_get_setting('display_teacher_in_courselist') == 'true') {
  136. //This is still necessary? There is the course teacher in the footer
  137. echo stripslashes($_course['titular']);
  138. }
  139. echo '</a>';*/
  140. echo '</div>';
  141. } elseif (isset($nameTools) && $language_file != 'course_home') {
  142. //Put the name of the user-tools in the header
  143. if (!isset($_user['user_id'])) {
  144. //echo '<div id="my_courses"></div>';
  145. } elseif (!$noPHP_SELF) {
  146. echo '<div id="my_courses"><a href="'.api_get_self().'?'.api_get_cidreq(), '" target="_top">'.$nameTools.'</a></div>';
  147. } else {
  148. echo '<div id="my_courses">'.$nameTools.'</div>';
  149. }
  150. } else {
  151. //echo '<div id="my_courses"></div>';
  152. }
  153. echo '<div id="plugin-header">';
  154. api_plugin('header');
  155. echo '</div>';
  156. //Don't let the header disappear if there's nothing on the left
  157. //echo '<div class="clear">&nbsp;</div>';
  158. echo '</div>';
  159. }
  160. function show_header_2() {
  161. $_course = api_get_course_info();
  162. $course_id = api_get_course_id();
  163. $user_id = api_get_user_id();
  164. echo '<div id="header2">';
  165. echo '<div id="Header2Right">';
  166. echo '<ul>';
  167. if ((api_get_setting('showonline', 'world') == 'true' AND !$user_id) OR (api_get_setting('showonline', 'users') == 'true' AND $user_id) OR (api_get_setting('showonline', 'course') == 'true' AND $user_id AND $course_id)) {
  168. $number = who_is_online_count(api_get_setting('time_limit_whosonline'));
  169. $number_online_in_course = 0;
  170. if(!empty($_course['id'])) {
  171. $number_online_in_course = who_is_online_in_this_course_count($user_id, api_get_setting('time_limit_whosonline'), $_course['id']);
  172. }
  173. echo '<li>';
  174. // Display the who's online of the platform
  175. if ($number) {
  176. if ((api_get_setting('showonline', 'world') == 'true' AND !$user_id) OR (api_get_setting('showonline', 'users') == 'true' AND $user_id)) {
  177. echo '<li><a href="'.api_get_path(WEB_PATH).'whoisonline.php" target="_top" title="'.get_lang('UsersOnline').'" ><img width="13px" src="'.api_get_path(WEB_IMG_PATH).'members.gif" title="'.get_lang('UsersOnline').'"> '.$number.'</a></li>';
  178. }
  179. }
  180. // Display the who's online for the course
  181. if ($number_online_in_course) {
  182. if (is_array($_course) AND api_get_setting('showonline', 'course') == 'true' AND isset($_course['sysCode'])) {
  183. echo '<li>| <a href="'.api_get_path(WEB_PATH).'whoisonline.php?cidReq='.$_course['sysCode'].'" target="_top">'.Display::return_icon('course.gif', get_lang('UsersOnline').' '.get_lang('InThisCourse'), array('width'=>'13px')).' '.$number_online_in_course.' </a></li>';
  184. }
  185. }
  186. // Display the who's online for the session
  187. if (api_get_setting('use_session_mode') == 'true' && isset($user_id) && api_get_session_id() != 0) {
  188. //echo '<li><a href="'.api_get_path(WEB_PATH).'whoisonlinesession.php?id_coach='.$user_id.'&amp;referer='.urlencode($_SERVER['REQUEST_URI']).'" target="_top">'.get_lang('UsersConnectedToMySessions').'</a></li>';
  189. echo '<li>| <a href="'.api_get_path(WEB_PATH).'whoisonlinesession.php?id_coach='.$user_id.'&amp;referer='.urlencode($_SERVER['REQUEST_URI']).'" target="_top">'.Display::return_icon('session.png', get_lang('UsersConnectedToMySessions'), array('width'=>'13px')).' </a></li>';
  190. }
  191. echo '</li>';
  192. }
  193. if ($user_id && isset($course_id)) {
  194. if ((api_is_course_admin() || api_is_platform_admin()) && api_get_setting('student_view_enabled') == 'true') {
  195. echo '<li>&nbsp;|&nbsp;';
  196. api_display_tool_view_option();
  197. echo '</li>';
  198. }
  199. }
  200. if (api_get_setting('accessibility_font_resize') == 'true') {
  201. echo '<li class="resize_font">';
  202. echo '<span class="decrease_font" title="'.get_lang('DecreaseFontSize').'">A</span> <span class="reset_font" title="'.get_lang('ResetFontSize').'">A</span> <span class="increase_font" title="'.get_lang('IncreaseFontSize').'">A</span>';
  203. echo '</li>';
  204. }
  205. echo '</ul>';
  206. echo '</div>';
  207. echo '</div>';
  208. }
  209. function show_header_3() {
  210. $navigation = $menu_navigation = array();
  211. $possible_tabs = get_tabs();
  212. // Campus Homepage
  213. if (api_get_setting('show_tabs', 'campus_homepage') == 'true') {
  214. $navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
  215. } else {
  216. $menu_navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
  217. }
  218. if (api_get_user_id() && !api_is_anonymous()) {
  219. // My Courses
  220. if (api_get_setting('show_tabs', 'my_courses') == 'true') {
  221. $navigation['mycourses'] = $possible_tabs['mycourses'];
  222. } else {
  223. $menu_navigation['mycourses'] = $possible_tabs['mycourses'];
  224. }
  225. // My Profile
  226. if (api_get_setting('show_tabs', 'my_profile') == 'true' && api_get_setting('allow_social_tool') != 'true') {
  227. $navigation['myprofile'] = $possible_tabs['myprofile'];
  228. } else {
  229. $menu_navigation['myprofile'] = $possible_tabs['myprofile'];
  230. }
  231. // My Agenda
  232. if (api_get_setting('show_tabs', 'my_agenda') == 'true') {
  233. $navigation['myagenda'] = $possible_tabs['myagenda'];
  234. } else {
  235. $menu_navigation['myagenda'] = $possible_tabs['myagenda'];
  236. }
  237. // Gradebook
  238. if (api_get_setting('gradebook_enable') == 'true') {
  239. if (api_get_setting('show_tabs', 'my_gradebook') == 'true') {
  240. $navigation['mygradebook'] = $possible_tabs['mygradebook'];
  241. } else{
  242. $menu_navigation['mygradebook'] = $possible_tabs['mygradebook'];
  243. }
  244. }
  245. // Reporting
  246. if (api_get_setting('show_tabs', 'reporting') == 'true') {
  247. if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
  248. $navigation['session_my_space'] = $possible_tabs['session_my_space'];
  249. } else {
  250. $navigation['session_my_space'] = $possible_tabs['session_my_progress'];
  251. }
  252. } else {
  253. if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
  254. $menu_navigation['session_my_space'] = $possible_tabs['session_my_space'];
  255. } else {
  256. $menu_navigation['session_my_space'] = $possible_tabs['session_my_progress'];
  257. }
  258. }
  259. // Social Networking
  260. if (api_get_setting('show_tabs', 'social') == 'true') {
  261. if (api_get_setting('allow_social_tool') == 'true') {
  262. $navigation['social'] = $possible_tabs['social'];
  263. }
  264. } else{
  265. $menu_navigation['social'] = $possible_tabs['social'];
  266. }
  267. // Dashboard
  268. if (api_get_setting('show_tabs', 'dashboard') == 'true') {
  269. if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
  270. $navigation['dashboard'] = $possible_tabs['dashboard'];
  271. }
  272. } else{
  273. $menu_navigation['dashboard'] = $possible_tabs['dashboard'];
  274. }
  275. // Administration
  276. if (api_is_platform_admin(true)) {
  277. if (api_get_setting('show_tabs', 'platform_administration') == 'true') {
  278. $navigation['platform_admin'] = $possible_tabs['platform_admin'];
  279. } else {
  280. $menu_navigation['platform_admin'] = $possible_tabs['platform_admin'];
  281. }
  282. }
  283. }
  284. // Displaying the tabs
  285. $lang = ''; //el for "Edit Language"
  286. if (!empty($_SESSION['user_language_choice'])) {
  287. $lang = $_SESSION['user_language_choice'];
  288. } elseif (!empty($_SESSION['_user']['language'])) {
  289. $lang = $_SESSION['_user']['language'];
  290. } else {
  291. $lang = get_setting('platformLanguage');
  292. }
  293. //Preparing home folder for multiple urls
  294. if (api_get_multiple_access_url()) {
  295. $access_url_id = api_get_current_access_url_id();
  296. if ($access_url_id != -1) {
  297. $url_info = api_get_access_url($access_url_id);
  298. $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
  299. $clean_url = replace_dangerous_char($url);
  300. $clean_url = str_replace('/', '-', $clean_url);
  301. $clean_url .= '/';
  302. $homep = api_get_path(SYS_PATH).'home/'.$clean_url; //homep for Home Path
  303. //we create the new dir for the new sites
  304. if (!is_dir($homep)) {
  305. mkdir($homep, api_get_permissions_for_new_directories());
  306. }
  307. }
  308. } else {
  309. $homep = api_get_path(SYS_PATH).'home/';
  310. }
  311. $ext = '.html';
  312. $menutabs = 'home_tabs';
  313. $home_top = '';
  314. if (is_file($homep.$menutabs.'_'.$lang.$ext) && is_readable($homep.$menutabs.'_'.$lang.$ext)) {
  315. $home_top = @(string)file_get_contents($homep.$menutabs.'_'.$lang.$ext);
  316. } elseif (is_file($homep.$menutabs.$lang.$ext) && is_readable($homep.$menutabs.$lang.$ext)) {
  317. $home_top = @(string)file_get_contents($homep.$menutabs.$lang.$ext);
  318. } else {
  319. $errorMsg = get_lang('HomePageFilesNotReadable');
  320. }
  321. $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
  322. //if (api_get_self() != '/main/admin/configure_homepage.php') {
  323. $open = str_replace('{rel_path}',api_get_path(REL_PATH), $home_top);
  324. $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
  325. $lis = '';
  326. if (!empty($open)) {
  327. $lis .= Display::tag('li', $open);
  328. $show_bar = true;
  329. }
  330. //} else {
  331. //This code was moved in the admin/configure_homepage.php file
  332. /*
  333. $home_menu = '';
  334. if (file_exists($homep.$menutabs.'_'.$lang.$ext)) {
  335. $home_menu = @file($homep.$menutabs.'_'.$lang.$ext);
  336. } else {
  337. $home_menu = @file($homep.$menutabs.$ext);
  338. }
  339. if (empty($home_menu)) {
  340. $home_menu = array();
  341. }
  342. if (!empty($home_menu)) {
  343. $home_menu = implode("\n", $home_menu);
  344. $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
  345. $home_menu = explode("\n", $home_menu);
  346. }
  347. $tab_counter = 0;
  348. if (!empty($home_menu)) {
  349. $show_bar = true;
  350. }
  351. foreach ($home_menu as $enreg) {
  352. $enreg = trim($enreg);
  353. if (!empty($enreg)) {
  354. $edit_link = '<a href="'.api_get_self().'?action=edit_tabs&amp;link_index='.$tab_counter.'" ><span>'.Display::return_icon('edit.gif', get_lang('Edit')).'</span></a>';
  355. $delete_link = '<a href="'.api_get_self().'?action=delete_tabs&amp;link_index='.$tab_counter.'" onclick="javascript: if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)).'\')) return false;"><span>'.Display::return_icon('delete.gif', get_lang('Delete')).'</span></a>';
  356. $tab_string = str_replace(array('href="'.api_get_path(WEB_PATH).'index.php?include=', '</li>'), array('href="'.api_get_path(WEB_CODE_PATH).'admin/'.basename(api_get_self()).'?action=open_link&link=', $edit_link.$delete_link.'</li>'), $enreg);
  357. $lis .= $tab_string;
  358. $tab_counter++;
  359. }
  360. }
  361. $lis .= '<li id="insert-link"><a href="'.api_get_self().'?action=insert_tabs" style="padding-right:0px;"><span>'. Display::return_icon('addd.gif', get_lang('InsertLink'), array('style' => 'vertical-align:middle')).' '.get_lang('InsertLink').'</span></a></li>';
  362. */
  363. //}
  364. if (count($navigation) > 1 || !empty($lis)) {
  365. $pre_lis = '';
  366. foreach ($navigation as $section => $navigation_info) {
  367. if (isset($GLOBALS['this_section'])) {
  368. $current = $section == $GLOBALS['this_section'] ? ' id="current"' : '';
  369. } else {
  370. $current = '';
  371. }
  372. $pre_lis .= '<li'.$current.'><a href="'.$navigation_info['url'].'" target="_top"><span id="tab_active">'.$navigation_info['title'].'</span></a></li>';
  373. }
  374. $lis = $pre_lis.$lis;
  375. $show_bar = true;
  376. }
  377. // Logout
  378. if ($show_bar) {
  379. echo '<div id="header3">';
  380. if (api_get_user_id()) {
  381. $login = '';
  382. if (api_is_anonymous()) {
  383. $login = get_lang('Anonymous');
  384. } else {
  385. $uinfo = api_get_user_info(api_get_user_id());
  386. $login = $uinfo['username'];
  387. }
  388. //start user section line with name, my course, my profile, scorm info, etc
  389. echo '<ul id="logout">';
  390. //echo '<li><span>'.get_lang('LoggedInAsX').' '.$login.'</span></li>';
  391. //echo '<li><a href="'.api_get_path(WEB_PATH).'main/auth/profile.php" target="_top"><span>'.get_lang('Profile').'</span></a></li>';
  392. echo '<li><a href="'.api_get_path(WEB_PATH).'index.php?logout=logout&uid='.api_get_user_id().'" target="_top"><span>'.get_lang('Logout').' ('.$login.')</span></a></li>';
  393. echo '</ul>';
  394. }
  395. echo '<ul>';
  396. echo $lis;
  397. echo '</ul>';
  398. echo '</div>';
  399. }
  400. return $menu_navigation;
  401. }
  402. //Header 4
  403. function show_header_4($interbreadcrumb, $language_file, $nameTools) {
  404. $session_id = api_get_session_id();
  405. $session_name = api_get_session_name($session_id);
  406. $_course = api_get_course_info();
  407. /* Plugins for banner section */
  408. $web_course_path = api_get_path(WEB_COURSE_PATH);
  409. /*
  410. * if the user is a coach he can see the users who are logged in its session
  411. */
  412. $navigation = array();
  413. // part 1: Course Homepage. If we are in a course then the first breadcrumb is a link to the course homepage
  414. // hide_course_breadcrumb the parameter has been added to hide the name of the course, that appeared in the default $interbreadcrumb
  415. $my_session_name = is_null($session_name) ? '' : '&nbsp;('.$session_name.')';
  416. if (!empty($_course) && !isset($_GET['hide_course_breadcrumb'])) {
  417. $navigation_item['url'] = $web_course_path . $_course['path'].'/index.php'.(!empty($session_id) ? '?id_session='.$session_id : '');
  418. switch (api_get_setting('breadcrumbs_course_homepage')) {
  419. case 'get_lang':
  420. $navigation_item['title'] = get_lang('CourseHomepageLink');
  421. break;
  422. case 'course_code':
  423. $navigation_item['title'] = $_course['official_code'];
  424. break;
  425. case 'session_name_and_course_title':
  426. $navigation_item['title'] = $_course['name'].$my_session_name;
  427. break;
  428. default:
  429. if (api_get_setting('use_session_mode') == 'true' && api_get_session_id() != -1 ) {
  430. $navigation_item['title'] = $_course['name'].$my_session_name;
  431. } else {
  432. $navigation_item['title'] = $_course['name'];
  433. }
  434. break;
  435. }
  436. $navigation[] = $navigation_item;
  437. }
  438. // part 2: Interbreadcrumbs. If there is an array $interbreadcrumb defined then these have to appear before the last breadcrumb (which is the tool itself)
  439. if (isset($interbreadcrumb) && is_array($interbreadcrumb)) {
  440. foreach ($interbreadcrumb as $breadcrumb_step) {
  441. if ($breadcrumb_step['url'] != '#') {
  442. $sep = (strrchr($breadcrumb_step['url'], '?') ? '&amp;' : '?');
  443. $navigation_item['url'] = $breadcrumb_step['url'].$sep.api_get_cidreq();
  444. } else {
  445. $navigation_item['url'] = '#';
  446. }
  447. $navigation_item['title'] = $breadcrumb_step['name'];
  448. // titles for shared folders
  449. if ($breadcrumb_step['name'] == 'shared_folder') {
  450. $navigation_item['title'] = get_lang('UserFolders');
  451. } elseif(strstr($breadcrumb_step['name'], 'shared_folder_session_')) {
  452. $navigation_item['title'] = get_lang('UserFolders');
  453. } elseif(strstr($breadcrumb_step['name'], 'sf_user_')) {
  454. $userinfo = Database::get_user_info_from_id(substr($breadcrumb_step['name'], 8));
  455. $navigation_item['title'] = api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
  456. } elseif($breadcrumb_step['name'] == 'chat_files') {
  457. $navigation_item['title'] = get_lang('ChatFiles');
  458. } elseif($breadcrumb_step['name'] == 'images') {
  459. $navigation_item['title'] = get_lang('Images');
  460. } elseif($breadcrumb_step['name'] == 'video') {
  461. $navigation_item['title'] = get_lang('Video');
  462. } elseif($breadcrumb_step['name'] == 'audio') {
  463. $navigation_item['title'] = get_lang('Audio');
  464. } elseif($breadcrumb_step['name'] == 'flash') {
  465. $navigation_item['title'] = get_lang('Flash');
  466. } elseif($breadcrumb_step['name'] == 'gallery') {
  467. $navigation_item['title'] = get_lang('Gallery');
  468. }
  469. //Fixes breadcrumb title now we applied the Security::remove_XSS and we cut the string depending of the MAX_LENGTH_BREADCRUMB value
  470. if (api_strlen($navigation_item['title']) > MAX_LENGTH_BREADCRUMB) {
  471. $navigation_item['title'] = api_substr($navigation_item['title'], 0, MAX_LENGTH_BREADCRUMB).' ...';
  472. }
  473. $navigation_item['title'] = Security::remove_XSS($navigation_item['title']);
  474. $navigation[] = $navigation_item;
  475. }
  476. }
  477. // part 3: The tool itself. If we are on the course homepage we do not want to display the title of the course because this
  478. // is the same as the first part of the breadcrumbs (see part 1)
  479. if (isset($nameTools) && $language_file != 'course_home') { // TODO: This condition $language_file != 'course_home' might bring surprises.
  480. $navigation_item['url'] = '#';
  481. $navigation_item['title'] = $nameTools;
  482. $navigation[] = $navigation_item;
  483. }
  484. $final_navigation = array();
  485. $counter = 0;
  486. foreach ($navigation as $index => $navigation_info) {
  487. if (!empty($navigation_info['title'])) {
  488. if ($navigation_info['url'] == '#') {
  489. $final_navigation[$index] = '<span>'.$navigation_info['title'].'</span>';
  490. } else {
  491. $final_navigation[$index] = '<a href="'.$navigation_info['url'].'" class="breadcrumb breadcrumb'.$index.'" target="_top"><span>'.$navigation_info['title'].'</span></a>';
  492. }
  493. $counter++;
  494. }
  495. }
  496. if (!empty($final_navigation)) {
  497. echo '<div id="header4">';
  498. $lis = '';
  499. $i = 0;
  500. $lis.= Display::tag('li', Display::url(Display::img(api_get_path(WEB_CSS_PATH).'home.png', get_lang('Homepage'), array('align'=>'middle')), api_get_path(WEB_PATH), array('class'=>'home')));
  501. foreach ($final_navigation as $bread) {
  502. $lis.= Display::tag('li', $bread);
  503. $i++;
  504. }
  505. echo Display::tag('ul',$lis, array('class'=>'bread'));
  506. echo '</div>';
  507. } else {
  508. echo '<div id="header4">';
  509. echo '</div>';
  510. }
  511. echo '<div class="clear"></div>';
  512. }
  513. function load_navigation_menu() {
  514. }