banner.lib.php 27 KB

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