banner.lib.php 26 KB

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