PageRenderTime 67ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/main/inc/lib/template.lib.php

https://github.com/AngelFQC/chamilo-lms-icpna
PHP | 1502 lines | 1041 code | 196 blank | 265 comment | 284 complexity | 52ba27c22dc4ab59701659bef4058dde MD5 | raw file
Possible License(s): LGPL-2.1, MPL-2.0-no-copyleft-exception, GPL-2.0, MIT, LGPL-2.0, LGPL-3.0, BSD-3-Clause, GPL-3.0, Apache-2.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @author Julio Montoya <gugli100@gmail.com>
  5. * @todo better organization of the class, methods and variables
  6. *
  7. * */
  8. use \ChamiloSession as Session;
  9. use Silex\Application;
  10. use Symfony\Component\Security\Core\SecurityContext;
  11. use Symfony\Component\Translation\Translator;
  12. use Symfony\Component\Routing\Router;
  13. class Template
  14. {
  15. private $app;
  16. public $preview_theme = null;
  17. public $theme; // the chamilo theme public_admin, chamilo, chamilo_red, etc
  18. public $title = null;
  19. public $show_header;
  20. public $show_footer;
  21. public $help;
  22. public $menu_navigation = array();
  23. public $show_learnpath = false; // This is a learnpath section or not?
  24. public $plugin = null;
  25. public $course_id = null;
  26. public $user_is_logged_in = false;
  27. public $twig = null;
  28. public $jquery_ui_theme;
  29. public $force_plugin_load = true;
  30. public $navigation_array;
  31. public $loadBreadcrumb = true;
  32. /** @var SecurityContext */
  33. private $security;
  34. /** @var Translator */
  35. private $translator;
  36. /** @var Router */
  37. private $urlGenerator;
  38. /**
  39. * @param Application $app
  40. * @param Database $database
  41. * @param SecurityContext $security
  42. * @param Translator $translator
  43. * @param Router $urlGenerator
  44. */
  45. public function __construct(
  46. Application $app,
  47. Database $database,
  48. SecurityContext $security,
  49. Translator $translator,
  50. Router $urlGenerator
  51. ) {
  52. $this->app = &$app;
  53. $this->security = $security;
  54. $this->translator = $translator;
  55. $this->urlGenerator = $urlGenerator;
  56. $this->app['classic_layout'] = true;
  57. $this->navigation_array = $this->returnNavigationArray();
  58. // Just in case
  59. global $tool_name;
  60. // Page title
  61. $this->title = isset($app['title']) ? $app['title'] : $tool_name;
  62. $this->show_learnpath = $app['template.show_learnpath'];
  63. /* Current themes: cupertino, smoothness, ui-lightness.
  64. Find the themes folder in main/inc/lib/javascript/jquery-ui */
  65. $this->jquery_ui_theme = 'smoothness';
  66. // Setting system variables.
  67. $this->setSystemParameters();
  68. // Setting user variables.
  69. $this->setUserParameters();
  70. // Setting course variables.
  71. $this->setCourseParameters();
  72. // header and footer are showed by default
  73. $this->setFooter($app['template.show_footer']);
  74. $this->setHeader($app['template.show_header']);
  75. $this->setHeaderParameters();
  76. $this->setFooterParameters();
  77. $this->assign('style', $app['template_style']);
  78. //Chamilo plugins
  79. if ($this->show_header) {
  80. if ($app['template.load_plugins'] && !empty($app['plugins'])) {
  81. $this->plugin = new AppPlugin();
  82. //1. Showing installed plugins in regions
  83. $plugin_regions = $this->plugin->get_plugin_regions();
  84. foreach ($plugin_regions as $region) {
  85. $this->set_plugin_region($region);
  86. }
  87. //2. Loading the course plugin info
  88. global $course_plugin;
  89. if (isset($course_plugin) && !empty($course_plugin) && !empty($this->course_id)) {
  90. //Load plugin get_langs
  91. $this->plugin->load_plugin_lang_variables($course_plugin);
  92. }
  93. }
  94. }
  95. }
  96. /**
  97. * @param array $breadCrumb
  98. */
  99. public function setBreadcrumb($breadCrumb)
  100. {
  101. if (isset($this->app['breadcrumb']) && !empty($this->app['breadcrumb'])) {
  102. if (empty($breadCrumb)) {
  103. $breadCrumb = $this->app['breadcrumb'];
  104. } else {
  105. $breadCrumb = array_merge($breadCrumb, $this->app['breadcrumb']);
  106. }
  107. }
  108. if (!empty($breadCrumb)) {
  109. $this->app['breadcrumb'] = $breadCrumb;
  110. }
  111. }
  112. /**
  113. * Get icon path
  114. * @param string $image
  115. * @param int $size
  116. *
  117. * @return string
  118. */
  119. public static function get_icon_path($image, $size = ICON_SIZE_SMALL)
  120. {
  121. return Display::return_icon($image, '', array(), $size, false, true);
  122. }
  123. /**
  124. * Format date
  125. * @param string $timestamp
  126. * @param string $format
  127. *
  128. * @return string
  129. */
  130. public static function format_date($timestamp, $format = null)
  131. {
  132. return api_format_date($timestamp, $format);
  133. }
  134. /**
  135. * @param string $help_input
  136. */
  137. public function setHelp($help_input = null)
  138. {
  139. if (!empty($help_input)) {
  140. $help = $help_input;
  141. } else {
  142. $help = $this->help;
  143. }
  144. $this->assign('help_content', $help);
  145. }
  146. /**
  147. * Use template system to parse the actions menu
  148. * @todo finish it!
  149. * @param array $actions
  150. *
  151. **/
  152. public function setActions($actions)
  153. {
  154. $action_string = '';
  155. if (!empty($actions)) {
  156. foreach ($actions as $action) {
  157. $action_string .= $action;
  158. }
  159. }
  160. $this->assign('actions', $actions);
  161. }
  162. /**
  163. * Shortcut to display a 1 col layout (index.php)
  164. * */
  165. public function display_one_col_template()
  166. {
  167. $tpl = $this->get_template('layout/layout_1_col.tpl');
  168. $this->display($tpl);
  169. }
  170. /**
  171. * Shortcut to display a 2 col layout (userportal.php)
  172. * */
  173. public function display_two_col_template()
  174. {
  175. $tpl = $this->get_template('layout/layout_2_col.tpl');
  176. $this->display($tpl);
  177. }
  178. /**
  179. * Displays an empty template
  180. */
  181. public function display_blank_template()
  182. {
  183. $tpl = $this->get_template('layout/blank.tpl');
  184. $this->display($tpl);
  185. }
  186. /**
  187. * Displays an empty template
  188. */
  189. public function display_no_layout_template()
  190. {
  191. $tpl = $this->get_template('layout/no_layout.tpl');
  192. $this->display($tpl);
  193. }
  194. /**
  195. * Sets the footer visibility
  196. * @param bool true if we show the footer
  197. */
  198. public function setFooter($status)
  199. {
  200. $this->show_footer = $status;
  201. $this->assign('show_footer', $status);
  202. }
  203. /**
  204. * Sets the header visibility
  205. * @param bool true if we show the header
  206. */
  207. public function setHeader($status)
  208. {
  209. $this->show_header = $status;
  210. $this->assign('show_header', $status);
  211. //Toolbar
  212. $show_admin_toolbar = api_get_setting('show_admin_toolbar');
  213. $show_toolbar = 0;
  214. switch ($show_admin_toolbar) {
  215. case 'do_not_show':
  216. break;
  217. case 'show_to_admin':
  218. if (api_is_platform_admin()) {
  219. $show_toolbar = 1;
  220. }
  221. break;
  222. case 'show_to_admin_and_teachers':
  223. if (api_is_platform_admin() || api_is_allowed_to_edit()) {
  224. $show_toolbar = 1;
  225. }
  226. break;
  227. case 'show_to_all':
  228. $show_toolbar = 1;
  229. break;
  230. }
  231. $this->assign('show_toolbar', $show_toolbar);
  232. //Only if course is available
  233. $show_course_shortcut = null;
  234. $show_course_navigation_menu = null;
  235. if (!empty($this->course_id) && $this->user_is_logged_in) {
  236. if (api_get_setting('show_toolshortcuts') != 'false') {
  237. //Course toolbar
  238. $show_course_shortcut = CourseHome::show_navigation_tool_shortcuts();
  239. }
  240. if (api_get_setting('show_navigation_menu') != 'false') {
  241. //Course toolbar
  242. $show_course_navigation_menu = CourseHome::show_navigation_menu();
  243. }
  244. }
  245. $this->assign('show_course_shortcut', $show_course_shortcut);
  246. $this->assign('show_course_navigation_menu', $show_course_navigation_menu);
  247. }
  248. /**
  249. * @param string $name
  250. * @return string
  251. */
  252. public function getTemplate($name)
  253. {
  254. return $this->app['template_style'].'/'.$name;
  255. }
  256. /**
  257. * @deprecated use getTemplate
  258. */
  259. public function get_template($name)
  260. {
  261. return $this->getTemplate($name);
  262. }
  263. /**
  264. * Set course parameters
  265. */
  266. private function setCourseParameters()
  267. {
  268. //Setting course id
  269. $this->course_id = api_get_course_int_id();
  270. $this->app['course_code'] = api_get_course_id();
  271. $this->app['session_id'] = api_get_session_id();
  272. }
  273. /**
  274. * Set user parameters
  275. */
  276. private function setUserParameters()
  277. {
  278. $user_info = array();
  279. $user_info['logged'] = 0;
  280. $this->user_is_logged_in = false;
  281. $user_info = isset($this->app['current_user']) ? $this->app['current_user'] : null;
  282. if (api_user_is_login() && !empty($user_info)) {
  283. $user_info['logged'] = 1;
  284. $user_info['is_admin'] = 0;
  285. if (api_is_platform_admin()) {
  286. $user_info['is_admin'] = 1;
  287. }
  288. $new_messages = MessageManager::get_new_messages();
  289. $user_info['messages_count'] = $new_messages != 0 ? Display::label($new_messages, 'warning') : null;
  290. $this->user_is_logged_in = true;
  291. }
  292. //Setting the $_u array that could be use in any template
  293. $this->assign('_u', $user_info);
  294. }
  295. /**
  296. * Set system parameters
  297. */
  298. private function setSystemParameters()
  299. {
  300. $version = $this->app['configuration']['system_version'];
  301. // Setting app paths/URLs.
  302. $_p = array(
  303. 'web' => api_get_path(WEB_PATH),
  304. 'web_course' => api_get_path(WEB_COURSE_PATH),
  305. 'web_course_path' => api_get_path(WEB_COURSE_PATH),
  306. 'web_code_path' => api_get_path(WEB_CODE_PATH),
  307. 'web_main' => api_get_path(WEB_CODE_PATH),
  308. 'web_css' => api_get_path(WEB_CSS_PATH),
  309. 'web_css_path' => api_get_path(WEB_CSS_PATH),
  310. 'web_ajax' => api_get_path(WEB_AJAX_PATH),
  311. 'web_ajax_path' => api_get_path(WEB_AJAX_PATH),
  312. 'web_img' => api_get_path(WEB_IMG_PATH),
  313. 'web_img_path' => api_get_path(WEB_IMG_PATH),
  314. 'web_plugin' => api_get_path(WEB_PLUGIN_PATH),
  315. 'web_plugin_path' => api_get_path(WEB_PLUGIN_PATH),
  316. 'web_lib' => api_get_path(WEB_LIBRARY_PATH),
  317. 'web_library_path' => api_get_path(WEB_LIBRARY_PATH),
  318. 'public_web' => api_get_path(WEB_PUBLIC_PATH)
  319. );
  320. $this->assign('_p', $_p);
  321. //Here we can add system parameters that can be use in any template
  322. $_s = array(
  323. 'software_name' => api_get_software_name(),
  324. 'system_version' => $version,
  325. 'site_name' => api_get_setting('siteName'),
  326. 'institution' => api_get_setting('Institution')
  327. );
  328. $this->assign('_s', $_s);
  329. }
  330. /**
  331. * Set theme, include CSS files
  332. */
  333. private function setCssFiles()
  334. {
  335. global $disable_js_and_css_files;
  336. $css = array();
  337. $this->theme = api_get_visual_theme();
  338. if (isset($_POST['style']) && api_is_platform_admin()) {
  339. $this->preview_theme = $_POST['style'];
  340. }
  341. if (!empty($this->preview_theme)) {
  342. $this->theme = $this->preview_theme;
  343. }
  344. $this->app['theme'] = $this->theme;
  345. $cssPath = api_get_path(WEB_CSS_PATH);
  346. // Loads only 1 css file
  347. if ($this->app['assetic.enabled']) {
  348. $css[] = api_get_path(WEB_PUBLIC_PATH).'css/'.$this->theme.'/style.css';
  349. } else {
  350. // Bootstrap
  351. $css[] = api_get_cdn_path(api_get_path(WEB_LIBRARY_PATH).'javascript/bootstrap/css/bootstrap.css');
  352. //$css[] = api_get_cdn_path(api_get_path(WEB_LIBRARY_PATH).'javascript/bootstrap/css/bootstrap-theme.css');
  353. // Base CSS.
  354. $css[] = api_get_cdn_path($cssPath.'base.css');
  355. // Default theme CSS.
  356. $css[] = api_get_cdn_path($cssPath.$this->theme.'/default.css');
  357. // Extra CSS files.
  358. if ($this->show_learnpath) {
  359. //$css[] = $cssPath.$this->theme.'/learnpath.css';
  360. //$css[] = $cssPath.$this->theme.'/scorm.css';
  361. }
  362. if (api_is_global_chat_enabled()) {
  363. $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/chat/css/chat.css';
  364. }
  365. $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/jquery-ui/css/'.$this->jquery_ui_theme.'/jquery-ui-custom.css';
  366. //$css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/jquery-ui/default.css';
  367. }
  368. $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/font-awesome/css/font-awesome.css';
  369. $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.css';
  370. $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/chosen/chosen.css';
  371. $css_file_to_string = null;
  372. foreach ($css as $file) {
  373. $css_file_to_string .= api_get_css($file);
  374. }
  375. // @todo move this somewhere else. Special fix when using tablets in order to see the text near icons
  376. if (SHOW_TEXT_NEAR_ICONS == true) {
  377. //hack in order to fix the actions buttons
  378. $css_file_to_string .= '<style>
  379. .td_actions a {
  380. float:left;
  381. width:100%;
  382. }
  383. .forum_message_left a {
  384. float:left;
  385. width:100%;
  386. }
  387. </style>';
  388. }
  389. $navigator_info = api_get_navigator();
  390. if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
  391. $css_file_to_string .= 'img, div { behavior: url('.api_get_path(
  392. WEB_LIBRARY_PATH
  393. ).'javascript/iepngfix/iepngfix.htc) } '."\n";
  394. }
  395. if (!$disable_js_and_css_files) {
  396. $this->assign('css_file_to_string', $css_file_to_string);
  397. $style_print = api_get_css(api_get_cdn_path($cssPath.$this->theme.'/print.css'), 'print');
  398. $this->assign('css_style_print', $style_print);
  399. }
  400. }
  401. /**
  402. * @param array $htmlHeadXtra
  403. */
  404. public function addJsFiles($htmlHeadXtra = array())
  405. {
  406. $extra_headers = null;
  407. if (isset($htmlHeadXtra) && $htmlHeadXtra) {
  408. foreach ($htmlHeadXtra as $this_html_head) {
  409. $extra_headers .= $this_html_head."\n";
  410. }
  411. }
  412. if (isset($this->app['extraJS'])) {
  413. foreach ($this->app['extraJS'] as $this_html_head) {
  414. $extra_headers .= $this_html_head."\n";
  415. }
  416. }
  417. $this->assign('extra_headers', $extra_headers);
  418. }
  419. /**
  420. * Sets JS files
  421. */
  422. private function setJsFiles()
  423. {
  424. global $disable_js_and_css_files, $htmlHeadXtra;
  425. $jsFolder = api_get_path(WEB_LIBRARY_PATH).'javascript/';
  426. if ($this->app['assetic.enabled']) {
  427. $js_files = array(
  428. api_get_path(WEB_PATH).'web/js/script.js',
  429. $jsFolder.'chosen/chosen.jquery.min.js',
  430. $jsFolder.'thickbox.js',
  431. $jsFolder.'ckeditor/ckeditor.js',
  432. );
  433. } else {
  434. //JS files
  435. $js_files = array(
  436. $jsFolder.'modernizr.js',
  437. $jsFolder.'jquery.js',
  438. $jsFolder.'chosen/chosen.jquery.min.js',
  439. $jsFolder.'jquery-ui/js/jquery-ui.custom.js',
  440. $jsFolder.'thickbox.js',
  441. $jsFolder.'bootstrap/js/bootstrap.js',
  442. );
  443. }
  444. $this->app['html_editor']->getJavascriptToInclude($js_files);
  445. if (api_is_global_chat_enabled()) {
  446. //Do not include the global chat in LP
  447. if ($this->show_learnpath == false && $this->show_footer == true && $this->app['template.hide_global_chat'] == false) {
  448. $js_files[] = $jsFolder.'chat/js/chat.js';
  449. }
  450. }
  451. if (api_get_setting('accessibility_font_resize') == 'true') {
  452. $js_files[] = $jsFolder.'fontresize.js';
  453. }
  454. if (api_get_setting('include_asciimathml_script') == 'true') {
  455. $js_files[] = $jsFolder.'asciimath/ASCIIMathML.js';
  456. }
  457. if (api_get_setting('disable_copy_paste') == 'true') {
  458. $js_files[] = $jsFolder.'jquery.nocutcopypaste.js';
  459. }
  460. $js_file_to_string = null;
  461. foreach ($js_files as $js_file) {
  462. $js_file_to_string .= api_get_js_simple($js_file);
  463. }
  464. // Loading email_editor js.
  465. if (!api_is_anonymous() && api_get_setting('allow_email_editor') == 'true') {
  466. $js_file_to_string .= $this->fetch($this->app['template_style'].'/mail_editor/email_link.js.tpl');
  467. }
  468. if (!$disable_js_and_css_files) {
  469. $this->assign('js_file_to_string', $js_file_to_string);
  470. $extra_headers = null;
  471. if (isset($htmlHeadXtra) && $htmlHeadXtra) {
  472. foreach ($htmlHeadXtra as $this_html_head) {
  473. $extra_headers .= $this_html_head."\n";
  474. }
  475. }
  476. if (isset($this->app['extraJS'])) {
  477. foreach ($this->app['extraJS'] as $this_html_head) {
  478. $extra_headers .= $this_html_head."\n";
  479. }
  480. }
  481. $this->assign('extra_headers', $extra_headers);
  482. }
  483. }
  484. /**
  485. * Set header parameters
  486. */
  487. private function setHeaderParameters()
  488. {
  489. $_course = api_get_course_info();
  490. $_configuration = $this->app['configuration'];
  491. $this_section = $this->app['this_section'];
  492. $nameTools = $this->title;
  493. $navigation = $this->navigation_array;
  494. $this->menu_navigation = $navigation['menu_navigation'];
  495. $this->assign('system_charset', api_get_system_encoding());
  496. $this->assign('online_button', Display::return_icon('online.png'));
  497. $this->assign('offline_button', Display::return_icon('offline.png'));
  498. // Get language iso-code for this page - ignore errors
  499. $this->assign('document_language', $this->translator->getLocale());
  500. $course_title = isset($_course['name']) ? $_course['name'] : null;
  501. $title_list = array();
  502. $title_list[] = api_get_setting('Institution');
  503. $title_list[] = api_get_setting('siteName');
  504. if (!empty($course_title)) {
  505. $title_list[] = $course_title;
  506. }
  507. if ($nameTools != '') {
  508. $title_list[] = $nameTools;
  509. }
  510. $title_string = '';
  511. for ($i = 0; $i < count($title_list); $i++) {
  512. $title_string .= $title_list[$i];
  513. if (isset($title_list[$i + 1])) {
  514. $item = trim($title_list[$i + 1]);
  515. if (!empty($item)) {
  516. $title_string .= ' - ';
  517. }
  518. }
  519. }
  520. $this->assign('title_string', $title_string);
  521. //Setting the theme and CSS files
  522. $this->setCssFiles();
  523. $this->setJsFiles();
  524. // Implementation of prefetch.
  525. // See http://cdn.chamilo.org/main/img/online.png for details
  526. $prefetch = '';
  527. if (!empty($_configuration['cdn_enable'])) {
  528. $prefetch .= '<meta http-equiv="x-dns-prefetch-control" content="on">';
  529. foreach ($_configuration['cdn'] as $host => $exts) {
  530. $prefetch .= '<link rel="dns-prefetch" href="'.$host.'">';
  531. }
  532. }
  533. $this->assign('prefetch', $prefetch);
  534. $this->assign('text_direction', api_get_text_direction());
  535. $this->assign('section_name', 'section-'.$this_section);
  536. $favico = '<link rel="shortcut icon" href="'.api_get_path(WEB_PATH).'favicon.ico" type="image/x-icon" />';
  537. if (isset($_configuration['multiple_access_urls']) && $_configuration['multiple_access_urls']) {
  538. $access_url_id = api_get_current_access_url_id();
  539. if ($access_url_id != -1) {
  540. $url_info = api_get_current_access_url_info();
  541. $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
  542. $clean_url = api_replace_dangerous_char($url);
  543. $clean_url = str_replace('/', '-', $clean_url);
  544. $clean_url .= '/';
  545. $homep = api_get_path(REL_PATH).'home/'.$clean_url; //homep for Home Path
  546. $icon_real_homep = api_get_path(SYS_PATH).'home/'.$clean_url;
  547. //we create the new dir for the new sites
  548. if (is_file($icon_real_homep.'favicon.ico')) {
  549. $favico = '<link rel="shortcut icon" href="'.$homep.'favicon.ico" type="image/x-icon" />';
  550. }
  551. }
  552. }
  553. $this->assign('favico', $favico);
  554. $this->setHelp();
  555. $notification = $this->returnNotificationMenu();
  556. $this->assign('notification_menu', $notification);
  557. // Preparing values for the menu
  558. // Profile link.
  559. $this->assign('is_profile_editable', api_is_profile_readable());
  560. $profile_link = null;
  561. if (api_get_setting('allow_social_tool') == 'true') {
  562. $profile_link = '<a href="'.api_get_path(WEB_CODE_PATH).'social/home.php">'.get_lang('Profile').'</a>';
  563. } else {
  564. if (api_is_profile_readable()) {
  565. $profile_link = '<a href="'.api_get_path(WEB_CODE_PATH).'auth/profile.php">'.get_lang('Profile').'</a>';
  566. }
  567. }
  568. $this->assign('profile_link', $profile_link);
  569. // Message link.
  570. $message_link = null;
  571. if (api_get_setting('allow_message_tool') == 'true') {
  572. $message_link = '<a href="'.api_get_path(WEB_CODE_PATH).'messages/inbox.php">'.get_lang('Inbox').'</a>';
  573. }
  574. $this->assign('message_link', $message_link);
  575. $institution = api_get_setting('Institution');
  576. $portal_name = empty($institution) ? api_get_setting('siteName') : $institution;
  577. $this->assign('portal_name', $portal_name);
  578. // Menu.
  579. $menu = $this->returnMenu();
  580. $this->assign('menu', $menu);
  581. // Breadcrumb
  582. if ($this->loadBreadcrumb) {
  583. $this->loadBreadcrumbToTemplate();
  584. }
  585. // Extra content
  586. $extra_header = null;
  587. if (!api_is_platform_admin()) {
  588. $extra_header = trim(api_get_setting('header_extra_content'));
  589. }
  590. $this->assign('header_extra_content', $extra_header);
  591. }
  592. /**
  593. *
  594. */
  595. public function loadBreadcrumbToTemplate()
  596. {
  597. if (api_get_setting('breadcrumb_navigation_display') == 'false') {
  598. return;
  599. }
  600. $breadcrumb = $this->returnBreadcrumb();
  601. $this->assign('breadcrumb', $breadcrumb);
  602. }
  603. /**
  604. * Set footer parameters
  605. */
  606. private function setFooterParameters()
  607. {
  608. //Show admin data
  609. //$this->assign('show_administrator_data', api_get_setting('show_administrator_data'));
  610. if (api_get_setting('show_administrator_data') == 'true') {
  611. //Administrator name
  612. $administrator_data = get_lang('Manager').' : '.Display::encrypted_mailto_link(
  613. api_get_setting('emailAdministrator'),
  614. api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))
  615. );
  616. $this->assign('administrator_name', $administrator_data);
  617. }
  618. //Loading footer extra content
  619. if (!api_is_platform_admin()) {
  620. $extra_footer = trim(api_get_setting('footer_extra_content'));
  621. if (!empty($extra_footer)) {
  622. $this->assign('footer_extra_content', $extra_footer);
  623. }
  624. }
  625. $courseId = api_get_course_int_id();
  626. //Tutor name
  627. if (api_get_setting('show_tutor_data') == 'true') {
  628. // Course manager
  629. $id_session = api_get_session_id();
  630. if (isset($courseId) && $courseId != -1 && !empty($courseId)) {
  631. $tutor_data = '';
  632. if ($id_session != 0) {
  633. $coachs_email = CourseManager::get_email_of_tutor_to_session($id_session, $courseId);
  634. $email_link = array();
  635. foreach ($coachs_email as $coach) {
  636. $email_link[] = Display::encrypted_mailto_link($coach['email'], $coach['complete_name']);
  637. }
  638. if (count($coachs_email) > 1) {
  639. $tutor_data .= get_lang('Coachs').' : ';
  640. $tutor_data .= ArrayClass::array_to_string($email_link, CourseManager::USER_SEPARATOR);
  641. } elseif (count($coachs_email) == 1) {
  642. $tutor_data .= get_lang('Coach').' : ';
  643. $tutor_data .= ArrayClass::array_to_string($email_link, CourseManager::USER_SEPARATOR);
  644. } elseif (count($coachs_email) == 0) {
  645. $tutor_data .= '';
  646. }
  647. }
  648. $this->assign('session_teachers', $tutor_data);
  649. }
  650. }
  651. if (api_get_setting('show_teacher_data') == 'true') {
  652. // course manager
  653. if (isset($courseId) && $courseId != -1 && !empty($courseId)) {
  654. $courseInfo = api_get_course_info();
  655. $teacher_data = null;
  656. $label = get_lang('Teacher');
  657. if (count($courseInfo['teacher_list']) > 1) {
  658. $label = get_lang('Teachers');
  659. }
  660. $teacher_data .= $label.' : '.$courseInfo['teacher_list_formatted'];
  661. $this->assign('teachers', $teacher_data);
  662. }
  663. }
  664. }
  665. public function manageDisplay($content)
  666. {
  667. //$this->assign('content', $content);
  668. }
  669. /**
  670. * Sets the plugin content in a template variable
  671. * @param string
  672. */
  673. private function set_plugin_region($plugin_region)
  674. {
  675. if (!empty($plugin_region)) {
  676. $region_content = $this->plugin->load_region($this->app['plugins'], $plugin_region, $this, $this->force_plugin_load);
  677. if (!empty($region_content)) {
  678. $this->assign('plugin_'.$plugin_region, $region_content);
  679. } else {
  680. $this->assign('plugin_'.$plugin_region, null);
  681. }
  682. }
  683. }
  684. /**
  685. * @param string $template
  686. * @return mixed
  687. */
  688. public function fetch($template = null)
  689. {
  690. $template = $this->app['twig']->loadTemplate($template);
  691. return $template->render(array());
  692. }
  693. /**
  694. * @param string $key
  695. * @param mixed $value
  696. */
  697. public function assign($key, $value = null)
  698. {
  699. if ($this->app['allowed'] == true) {
  700. $this->app['twig']->addGlobal($key, $value);
  701. }
  702. }
  703. /**
  704. * @param string $template
  705. */
  706. public function display($template = null)
  707. {
  708. if (!empty($template)) {
  709. $this->app['default_layout'] = $template;
  710. }
  711. }
  712. /**
  713. * @return null|string
  714. */
  715. public function returnMenu()
  716. {
  717. $navigation = $this->navigation_array;
  718. $navigation = $navigation['navigation'];
  719. // Displaying the tabs
  720. $lang = api_get_user_language();
  721. // Preparing home folder for multiple urls
  722. if (api_get_multiple_access_url()) {
  723. $access_url_id = api_get_current_access_url_id();
  724. if ($access_url_id != -1) {
  725. $url_info = api_get_current_access_url_info();
  726. $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
  727. $clean_url = api_replace_dangerous_char($url);
  728. $clean_url = str_replace('/', '-', $clean_url);
  729. $clean_url .= '/';
  730. $homep = api_get_path(SYS_DATA_PATH).'home/'.$clean_url; //homep for Home Path
  731. //we create the new dir for the new sites
  732. if (!is_dir($homep)) {
  733. mkdir($homep, api_get_permissions_for_new_directories());
  734. }
  735. }
  736. } else {
  737. $homep = api_get_path(SYS_PATH).'home/';
  738. }
  739. $ext = '.html';
  740. $menutabs = 'home_tabs';
  741. $home_top = '';
  742. if (is_file($homep.$menutabs.'_'.$lang.$ext) && is_readable($homep.$menutabs.'_'.$lang.$ext)) {
  743. $home_top = @(string)file_get_contents($homep.$menutabs.'_'.$lang.$ext);
  744. } elseif (is_file($homep.$menutabs.$lang.$ext) && is_readable($homep.$menutabs.$lang.$ext)) {
  745. $home_top = @(string)file_get_contents($homep.$menutabs.$lang.$ext);
  746. } else {
  747. //$errorMsg = get_lang('HomePageFilesNotReadable');
  748. }
  749. $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
  750. $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top);
  751. $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
  752. $lis = '';
  753. if (!empty($open)) {
  754. if (strpos($open, 'show_menu') === false) {
  755. if (api_is_anonymous()) {
  756. $navigation[SECTION_CAMPUS] = null;
  757. }
  758. } else {
  759. //$lis .= Display::tag('li', $open);
  760. $lis .= $open;
  761. }
  762. }
  763. if (count($navigation) > 0 || !empty($lis)) {
  764. $pre_lis = '';
  765. foreach ($navigation as $section => $navigation_info) {
  766. if (isset($GLOBALS['this_section'])) {
  767. $current = $section == $GLOBALS['this_section'] ? ' id="current" class="active" ' : '';
  768. } else {
  769. $current = '';
  770. }
  771. if (!empty($navigation_info['title'])) {
  772. $pre_lis .= '<li'.$current.' ><a href="'.$navigation_info['url'].'" target="_top">'.$navigation_info['title'].'</a></li>';
  773. }
  774. }
  775. $lis = $pre_lis.$lis;
  776. }
  777. $menu = null;
  778. if (!empty($lis)) {
  779. $menu .= $lis;
  780. }
  781. return $menu;
  782. }
  783. /**
  784. * @return string
  785. */
  786. public function getNavigationLinks()
  787. {
  788. // Deleting the my profile link.
  789. if (api_get_setting('allow_social_tool') == 'true') {
  790. unset($this->menu_navigation['myprofile']);
  791. }
  792. return $this->menu_navigation;
  793. }
  794. /**
  795. * @param string $layout
  796. * @return mixed
  797. */
  798. public function renderLayout($layout = null)
  799. {
  800. if (empty($layout)) {
  801. $layout = $this->app['default_layout'];
  802. }
  803. $this->addJsFiles();
  804. return $this->app['twig']->render($this->app['template_style'].'/layout/'.$layout);
  805. }
  806. /**
  807. * @param string $layout
  808. * @deprecated use renderLayout
  809. * @return mixed
  810. */
  811. public function render_layout($layout = null)
  812. {
  813. return $this->renderLayout($layout);
  814. }
  815. /**
  816. * @param string $template
  817. * @param array $elements
  818. * @deprecated use renderTemplate
  819. * @return mixed
  820. */
  821. public function render_template($template, $elements = array())
  822. {
  823. return $this->renderTemplate($template, $elements);
  824. }
  825. /**
  826. * @param string $template
  827. * @param array $elements
  828. * @return mixed
  829. */
  830. public function renderTemplate($template, $elements = array())
  831. {
  832. $this->addJsFiles();
  833. return $this->app['twig']->render($this->app['template_style'].'/'.$template, $elements);
  834. }
  835. /**
  836. * Determines the possible tabs (=sections) that are available.
  837. * This function is used when creating the tabs in the third header line and
  838. * all the sections that do not appear there (as determined by the
  839. * platform admin on the Chamilo configuration settings page)
  840. * will appear in the right hand menu that appears on several other pages
  841. * @return array containing all the possible tabs
  842. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  843. */
  844. public function getTabs()
  845. {
  846. $_course = api_get_course_info();
  847. $navigation = array();
  848. // Campus Homepage
  849. $navigation[SECTION_CAMPUS]['url'] = api_get_path(WEB_PUBLIC_PATH).'index';
  850. $navigation[SECTION_CAMPUS]['title'] = get_lang('CampusHomepage');
  851. // My Courses
  852. $navigation['mycourses']['url'] = api_get_path(WEB_PUBLIC_PATH).'userportal';
  853. $navigation['mycourses']['title'] = get_lang('MyCourses');
  854. // My Profile
  855. if (api_is_profile_readable()) {
  856. $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '');
  857. $navigation['myprofile']['title'] = get_lang('ModifyProfile');
  858. }
  859. // Link to my agenda
  860. $navigation['myagenda']['url'] = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=personal';
  861. $navigation['myagenda']['title'] = get_lang('MyAgenda');
  862. // Gradebook
  863. if (api_get_setting('gradebook_enable') == 'true') {
  864. $navigation['mygradebook']['url'] = api_get_path(
  865. WEB_CODE_PATH
  866. ).'gradebook/gradebook.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '');
  867. $navigation['mygradebook']['title'] = get_lang('MyGradebook');
  868. }
  869. // Reporting
  870. if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
  871. // Link to my space
  872. $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/index.php';
  873. $navigation['session_my_space']['title'] = get_lang('MySpace');
  874. } else {
  875. // Link to my progress
  876. $navigation['session_my_progress']['url'] = api_get_path(WEB_CODE_PATH).'auth/my_progress.php';
  877. $navigation['session_my_progress']['title'] = get_lang('MyProgress');
  878. }
  879. // Social
  880. if (api_get_setting('allow_social_tool') == 'true') {
  881. $navigation['social']['url'] = api_get_path(WEB_CODE_PATH).'social/home.php';
  882. $navigation['social']['title'] = get_lang('SocialNetwork');
  883. }
  884. // Dashboard
  885. if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
  886. $navigation['dashboard']['url'] = api_get_path(WEB_CODE_PATH).'dashboard/index.php';
  887. $navigation['dashboard']['title'] = get_lang('Dashboard');
  888. }
  889. // Custom tabs
  890. for ($i = 1; $i <= 3; $i++) {
  891. if (api_get_setting('custom_tab_'.$i.'_name') && api_get_setting('custom_tab_'.$i.'_url')) {
  892. $navigation['custom_tab_'.$i]['url'] = api_get_setting('custom_tab_'.$i.'_url');
  893. $navigation['custom_tab_'.$i]['title'] = api_get_setting('custom_tab_'.$i.'_name');
  894. }
  895. }
  896. // Adding block settings for each role
  897. if (isset($this->app['allow_admin_toolbar'])) {
  898. $roleTemplate = array();
  899. foreach ($this->app['allow_admin_toolbar'] as $role) {
  900. if ($this->security->getToken() && $this->security->isGranted($role)) {
  901. // Fixes in order to match the templates
  902. if ($role == 'ROLE_ADMIN') {
  903. $role = 'administrator';
  904. }
  905. if ($role == 'ROLE_QUESTION_MANAGER') {
  906. $role = 'QUESTIONMANAGER';
  907. }
  908. $stripRole = strtolower(str_replace('ROLE_', '', $role));
  909. $roleTemplate[] = $stripRole;
  910. }
  911. }
  912. if (!empty($roleTemplate)) {
  913. if (api_get_setting('show_tabs', 'platform_administration') == 'true') {
  914. $navigation['admin']['url'] = api_get_path(WEB_PUBLIC_PATH).'admin';
  915. $navigation['admin']['title'] = get_lang('PlatformAdmin');
  916. }
  917. }
  918. $this->app['admin_toolbar_roles'] = $roleTemplate;
  919. }
  920. return $navigation;
  921. }
  922. /**
  923. * @param string $theme
  924. * @deprecated the logo is wrote in the main_header.tpl file
  925. * @return string
  926. */
  927. public function returnLogo($theme)
  928. {
  929. $_course = api_get_course_info();
  930. $html = '';
  931. $logo = api_get_path(SYS_CODE_PATH).'css/'.$theme.'/images/header-logo.png';
  932. $site_name = api_get_setting('siteName');
  933. if (file_exists($logo)) {
  934. $site_name = api_get_setting('Institution').' - '.$site_name;
  935. $html .= '<div id="logo">';
  936. $image_url = api_get_path(WEB_CSS_PATH).$theme.'/images/header-logo.png';
  937. $logo = Display::img($image_url, $site_name, array('title' => $site_name));
  938. $html .= Display::url($logo, api_get_path(WEB_PATH).'index.php');
  939. $html .= '</div>';
  940. } else {
  941. $html .= '<a href="'.api_get_path(WEB_PATH).'index.php" target="_top">'.$site_name.'</a>';
  942. $iurl = api_get_setting('InstitutionUrl');
  943. $iname = api_get_setting('Institution');
  944. if (!empty($iname)) {
  945. $html .= '-&nbsp;<a href="'.$iurl.'" target="_top">'.$iname.'</a>';
  946. }
  947. // External link section a.k.a Department - Department URL
  948. if (isset($_course['extLink']) && $_course['extLink']['name'] != '') {
  949. $html .= '<span class="extLinkSeparator"> - </span>';
  950. if ($_course['extLink']['url'] != '') {
  951. $html .= '<a class="extLink" href="'.$_course['extLink']['url'].'" target="_top">';
  952. $html .= $_course['extLink']['name'];
  953. $html .= '</a>';
  954. } else {
  955. $html .= $_course['extLink']['name'];
  956. }
  957. }
  958. }
  959. return $html;
  960. }
  961. /**
  962. * @return string
  963. */
  964. public function returnNotificationMenu()
  965. {
  966. $_course = api_get_course_info();
  967. $course_id = api_get_course_id();
  968. $user_id = api_get_user_id();
  969. $html = '';
  970. if ((api_get_setting('showonline', 'world') == 'true' AND !$user_id) OR
  971. (api_get_setting('showonline', 'users') == 'true' AND $user_id) OR
  972. (api_get_setting('showonline', 'course') == 'true' AND $user_id AND $course_id)
  973. ) {
  974. $number = Online::who_is_online_count(api_get_setting('time_limit_whosonline'));
  975. $number_online_in_course = 0;
  976. if (!empty($_course['id'])) {
  977. $number_online_in_course = Online::who_is_online_in_this_course_count(
  978. $user_id,
  979. api_get_setting('time_limit_whosonline'),
  980. $_course['id']
  981. );
  982. }
  983. // Display the who's online of the platform
  984. if ($number) {
  985. if ((api_get_setting('showonline', 'world') == 'true' AND !$user_id) OR
  986. (api_get_setting('showonline', 'users' ) == 'true' AND $user_id)
  987. ) {
  988. $html .= '<li><a href="'.SocialManager::getUserOnlineLink().'" target="_top" title="'.get_lang(
  989. 'UsersOnline'
  990. ).'" >'.
  991. Display::return_icon(
  992. 'user.png',
  993. get_lang('UsersOnline'),
  994. array(),
  995. ICON_SIZE_TINY
  996. ).' '.$number.'</a></li>';
  997. }
  998. }
  999. // Display the who's online for the course
  1000. if ($number_online_in_course) {
  1001. if (is_array($_course) AND
  1002. api_get_setting('showonline', 'course' ) == 'true' AND
  1003. isset($_course['sysCode'])
  1004. ) {
  1005. $html .= '<li><a href="'.SocialManager::getUserOnlineLink($_course['sysCode']).'" target="_top">'.
  1006. Display::return_icon(
  1007. 'course.png',
  1008. get_lang('UsersOnline').' '.get_lang('InThisCourse'),
  1009. array(),
  1010. ICON_SIZE_TINY
  1011. ).' '.$number_online_in_course.' </a></li>';
  1012. }
  1013. }
  1014. // Display the who's online for the session
  1015. if (api_get_setting('showonline', 'session') == 'true') {
  1016. if (isset($user_id) && api_get_session_id() != 0) {
  1017. if (api_is_allowed_to_edit()) {
  1018. $html .= '<li><a href="'.SocialManager::getUserOnlineLink(null, api_get_session_id()).'&id_coach='.$user_id.'" >'.
  1019. Display::return_icon(
  1020. 'session.png',
  1021. get_lang('UsersConnectedToMySessions'),
  1022. array(),
  1023. ICON_SIZE_TINY
  1024. ).' </a></li>';
  1025. }
  1026. }
  1027. }
  1028. }
  1029. if (api_get_setting('accessibility_font_resize') == 'true') {
  1030. $html .= '<li class="resize_font">';
  1031. $html .= '<span class="decrease_font" title="'.get_lang(
  1032. 'DecreaseFontSize'
  1033. ).'">A</span> <span class="reset_font" title="'.get_lang(
  1034. 'ResetFontSize'
  1035. ).'">A</span> <span class="increase_font" title="'.get_lang('IncreaseFontSize').'">A</span>';
  1036. $html .= '</li>';
  1037. }
  1038. return $html;
  1039. }
  1040. /**
  1041. * Gets the main menu
  1042. *
  1043. * @return array
  1044. */
  1045. public function returnNavigationArray()
  1046. {
  1047. $navigation = array();
  1048. $menu_navigation = array();
  1049. $possible_tabs = $this->getTabs();
  1050. // Campus Homepage
  1051. if (api_get_setting('show_tabs', 'campus_homepage') == 'true') {
  1052. $navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
  1053. } else {
  1054. $menu_navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
  1055. }
  1056. if (api_get_user_id() && !api_is_anonymous()) {
  1057. // My Courses
  1058. if (api_get_setting('show_tabs', 'my_courses') == 'true') {
  1059. $navigation['mycourses'] = $possible_tabs['mycourses'];
  1060. } else {
  1061. $menu_navigation['mycourses'] = $possible_tabs['mycourses'];
  1062. }
  1063. // My Profile
  1064. if (api_get_setting('show_tabs', 'my_profile') == 'true' && api_get_setting('allow_social_tool') != 'true') {
  1065. if (isset($possible_tabs['myprofile'])) {
  1066. $navigation['myprofile'] = $possible_tabs['myprofile'];
  1067. }
  1068. } else {
  1069. if (isset($possible_tabs['myprofile'])) {
  1070. $menu_navigation['myprofile'] = $possible_tabs['myprofile'];
  1071. }
  1072. }
  1073. // My Agenda
  1074. if (api_get_setting('show_tabs', 'my_agenda') == 'true') {
  1075. $navigation['myagenda'] = $possible_tabs['myagenda'];
  1076. } else {
  1077. $menu_navigation['myagenda'] = $possible_tabs['myagenda'];
  1078. }
  1079. // Gradebook
  1080. if (api_get_setting('gradebook_enable') == 'true') {
  1081. if (api_get_setting('show_tabs', 'my_gradebook') == 'true') {
  1082. $navigation['mygradebook'] = $possible_tabs['mygradebook'];
  1083. } else {
  1084. $menu_navigation['mygradebook'] = $possible_tabs['mygradebook'];
  1085. }
  1086. }
  1087. // Reporting
  1088. if (api_get_setting('show_tabs', 'reporting') == 'true') {
  1089. if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
  1090. $navigation['session_my_space'] = $possible_tabs['session_my_space'];
  1091. } else {
  1092. $navigation['session_my_space'] = $possible_tabs['session_my_progress'];
  1093. }
  1094. } else {
  1095. if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
  1096. $menu_navigation['session_my_space'] = $possible_tabs['session_my_space'];
  1097. } else {
  1098. $menu_navigation['session_my_space'] = $possible_tabs['session_my_progress'];
  1099. }
  1100. }
  1101. // Social Networking
  1102. if (api_get_setting('show_tabs', 'social') == 'true') {
  1103. if (api_get_setting('allow_social_tool') == 'true') {
  1104. $navigation['social'] = $possible_tabs['social'];
  1105. }
  1106. } else {
  1107. $menu_navigation['social'] = isset($possible_tabs['social']) ? $possible_tabs['social'] : null;
  1108. }
  1109. // Dashboard
  1110. if (api_get_setting('show_tabs', 'dashboard') == 'true') {
  1111. if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
  1112. $navigation['dashboard'] = $possible_tabs['dashboard'];
  1113. }
  1114. } else {
  1115. $menu_navigation['dashboard'] = isset($possible_tabs['dashboard']) ? $possible_tabs['dashboard'] : null;
  1116. }
  1117. if (isset($possible_tabs['admin'])) {
  1118. $navigation['platform_admin'] = $possible_tabs['admin'];
  1119. $navigation['platform_admin'] = $possible_tabs['admin'];
  1120. }
  1121. // Reports
  1122. if (!empty($possible_tabs['reports'])) {
  1123. if (api_get_setting('show_tabs', 'reports') == 'true') {
  1124. if ((api_is_platform_admin() || api_is_drh() || api_is_session_admin()) && Rights::hasRight(
  1125. 'show_tabs:reports'
  1126. )
  1127. ) {
  1128. $navigation['reports'] = $possible_tabs['reports'];
  1129. }
  1130. } else {
  1131. $menu_navigation['reports'] = $possible_tabs['reports'];
  1132. }
  1133. }
  1134. // Custom tabs
  1135. for ($i = 1; $i <= 3; $i++) {
  1136. if (api_get_setting('show_tabs', 'custom_tab_'.$i) == 'true') {
  1137. if (isset($possible_tabs['custom_tab_'.$i])) {
  1138. $navigation['custom_tab_'.$i] = $possible_tabs['custom_tab_'.$i];
  1139. }
  1140. } else {
  1141. if (isset($possible_tabs['custom_tab_'.$i])) {
  1142. $menu_navigation['custom_tab_'.$i] = $possible_tabs['custom_tab_'.$i];
  1143. }
  1144. }
  1145. }
  1146. }
  1147. $return = array(
  1148. 'menu_navigation' => $menu_navigation,
  1149. 'navigation' => $navigation,
  1150. 'possible_tabs' => $possible_tabs
  1151. );
  1152. return $return;
  1153. }
  1154. /**
  1155. * Return breadcrumb
  1156. * @return string
  1157. */
  1158. public function returnBreadcrumb()
  1159. {
  1160. $interbreadcrumb = $this->app['breadcrumb'];
  1161. $session_id = api_get_session_id();
  1162. $session_name = api_get_session_name($session_id);
  1163. $_course = api_get_course_info();
  1164. $user_id = api_get_user_id();
  1165. $course_id = api_get_course_id();
  1166. /* Plugins for banner section */
  1167. $web_course_path = api_get_path(WEB_COURSE_PATH);
  1168. /* If the user is a coach he can see the users who are logged in its session */
  1169. $navigation = array();
  1170. // part 1: Course Homepage. If we are in a course then the first breadcrumb is a link to the course homepage
  1171. // hide_course_breadcrumb the parameter has been added to hide the name of the course, that appeared in the default $interbreadcrumb
  1172. $session_name = Text::cut($session_name, MAX_LENGTH_BREADCRUMB);
  1173. $my_session_name = is_null($session_name) ? '' : '&nbsp;('.$session_name.')';
  1174. if (!empty($_course) && !isset($_GET['hide_course_breadcrumb'])) {
  1175. $navigation_item['url'] = $web_course_path.$_course['path'].'/index.php'.(!empty($session_id) ? '?id_session='.$session_id : '');
  1176. $course_title = Text::cut($_course['name'], MAX_LENGTH_BREADCRUMB);
  1177. switch (api_get_setting('breadcrumbs_course_homepage')) {
  1178. case 'get_lang':
  1179. $navigation_item['title'] = Display::img(
  1180. api_get_path(WEB_CSS_PATH).'home.png',
  1181. get_lang('CourseHomepageLink')
  1182. ).' '.get_lang('CourseHomepageLink');
  1183. break;
  1184. case 'course_code':
  1185. $navigation_item['title'] = Display::img(
  1186. api_get_path(WEB_CSS_PATH).'home.png',
  1187. $_course['official_code']
  1188. ).' '.$_course['official_code'];
  1189. break;
  1190. case 'session_name_and_course_title':
  1191. $navigation_item['title'] = Display::img(
  1192. api_get_path(WEB_CSS_PATH).'home.png',
  1193. $_course['name'].$my_session_name
  1194. ).' '.$course_title.$my_session_name;
  1195. break;
  1196. default:
  1197. if (api_get_session_id() != -1) {
  1198. $navigation_item['title'] = Display::img(
  1199. api_get_path(WEB_CSS_PATH).'home.png',
  1200. $_course['name'].$my_session_name
  1201. ).' '.$course_title.$my_session_name;
  1202. } else {

Large files files are truncated, but you can click here to view the full file