banner.lib.php 25 KB

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