PageRenderTime 135ms CodeModel.GetById 84ms app.highlight 40ms RepoModel.GetById 1ms app.codeStats 1ms

/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

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

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