| Total Complexity | 217 |
| Total Lines | 1646 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
Complex classes like Template often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Template, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 17 | class Template |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * The Template folder name see main/template. |
||
| 21 | * |
||
| 22 | * @var string |
||
| 23 | */ |
||
| 24 | public $templateFolder = 'default'; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * The theme that will be used: chamilo, public_admin, chamilo_red, etc |
||
| 28 | * This variable is set from the database. |
||
| 29 | * |
||
| 30 | * @var string |
||
| 31 | */ |
||
| 32 | public $theme = ''; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @var string |
||
| 36 | */ |
||
| 37 | public $preview_theme = ''; |
||
| 38 | public $title = null; |
||
| 39 | public $show_header; |
||
| 40 | public $show_footer; |
||
| 41 | public $help; |
||
| 42 | public $menu_navigation = []; //Used in the userportal.lib.php function: return_navigation_course_links() |
||
| 43 | public $show_learnpath = false; // This is a learnpath section or not? |
||
| 44 | public $plugin = null; |
||
| 45 | public $course_id = null; |
||
| 46 | public $user_is_logged_in = false; |
||
| 47 | public $twig = null; |
||
| 48 | |||
| 49 | /* Loads chamilo plugins */ |
||
| 50 | public $load_plugins = false; |
||
| 51 | public $params = []; |
||
| 52 | public $force_plugin_load = false; |
||
| 53 | public $responseCode = 0; |
||
| 54 | private $themeDir; |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @param string $title |
||
| 58 | * @param bool $show_header |
||
| 59 | * @param bool $show_footer |
||
| 60 | * @param bool $show_learnpath |
||
| 61 | * @param bool $hide_global_chat |
||
| 62 | * @param bool $load_plugins |
||
| 63 | * @param int $responseCode |
||
| 64 | * @param bool $sendHeaders send http headers or not |
||
| 65 | */ |
||
| 66 | public function __construct( |
||
| 126 | } |
||
| 127 | } |
||
| 128 | |||
| 129 | /** |
||
| 130 | * @param string $helpInput |
||
| 131 | */ |
||
| 132 | public function setHelp($helpInput = null) |
||
| 133 | { |
||
| 134 | if (!empty($helpInput)) { |
||
| 135 | $help = $helpInput; |
||
| 136 | } else { |
||
| 137 | $help = $this->help; |
||
| 138 | } |
||
| 139 | |||
| 140 | $content = ''; |
||
| 141 | if ('true' == api_get_setting('enable_help_link')) { |
||
| 142 | if (!empty($help)) { |
||
| 143 | $help = Security::remove_XSS($help); |
||
| 144 | $content = '<div class="help">'; |
||
| 145 | $content .= Display::url( |
||
| 146 | Display::return_icon('help.png', get_lang('Help'), null, ICON_SIZE_LARGE), |
||
| 147 | api_get_path(WEB_CODE_PATH).'help/help.php?open='.$help, |
||
| 148 | [ |
||
| 149 | 'class' => 'ajax', |
||
| 150 | 'data-title' => get_lang('Help'), |
||
| 151 | ] |
||
| 152 | ); |
||
| 153 | $content .= '</div>'; |
||
| 154 | } |
||
| 155 | } |
||
| 156 | $this->assign('help_content', $content); |
||
| 157 | } |
||
| 158 | |||
| 159 | /** |
||
| 160 | * Use template system to parse the actions menu. |
||
| 161 | * |
||
| 162 | * @todo finish it! |
||
| 163 | */ |
||
| 164 | public function set_actions($actions) |
||
| 165 | { |
||
| 166 | $action_string = ''; |
||
| 167 | if (!empty($actions)) { |
||
| 168 | foreach ($actions as $action) { |
||
| 169 | $action_string .= $action; |
||
| 170 | } |
||
| 171 | } |
||
| 172 | $this->assign('actions', $actions); |
||
| 173 | } |
||
| 174 | |||
| 175 | /** |
||
| 176 | * Render the template. |
||
| 177 | * |
||
| 178 | * @param string $template The template path |
||
| 179 | * @param bool $clearFlashMessages Clear the $_SESSION variables for flash messages |
||
| 180 | */ |
||
| 181 | public function display($template) |
||
| 195 | } |
||
| 196 | |||
| 197 | /** |
||
| 198 | * @param string $template |
||
| 199 | * |
||
| 200 | * @throws \Twig\Error\Error |
||
| 201 | */ |
||
| 202 | public function displayTemplate($template) |
||
| 206 | } |
||
| 207 | |||
| 208 | /** |
||
| 209 | * Shortcut to display a 1 col layout (index.php). |
||
| 210 | * */ |
||
| 211 | public function display_one_col_template() |
||
| 212 | { |
||
| 213 | $this->loadLegacyParams(); |
||
| 214 | $template = '@ChamiloCore/Layout/layout_one_col.html.twig'; |
||
| 215 | $origin = api_get_origin(); |
||
| 216 | if ('learnpath' === $origin) { |
||
| 217 | $template = '@ChamiloCore/Layout/no_layout.html.twig'; |
||
| 218 | } |
||
| 219 | $this->setVueParams($this->params); |
||
| 220 | $this->returnResponse($this->params, $template); |
||
| 221 | } |
||
| 222 | |||
| 223 | /** |
||
| 224 | * Displays an empty template. |
||
| 225 | */ |
||
| 226 | public function display_blank_template() |
||
| 227 | { |
||
| 228 | $this->loadLegacyParams(); |
||
| 229 | $template = '@ChamiloCore/Layout/blank.html.twig'; |
||
| 230 | $this->returnResponse($this->params, $template); |
||
| 231 | } |
||
| 232 | |||
| 233 | /** |
||
| 234 | * Displays an empty template. |
||
| 235 | */ |
||
| 236 | public function displayBlankTemplateNoHeader() |
||
| 237 | { |
||
| 238 | $this->loadLegacyParams(); |
||
| 239 | $template = '@ChamiloCore/Layout/blank_no_header.html.twig'; |
||
| 240 | $this->returnResponse($this->params, $template); |
||
| 241 | } |
||
| 242 | |||
| 243 | /** |
||
| 244 | * Displays an empty template. |
||
| 245 | */ |
||
| 246 | public function display_no_layout_template() |
||
| 247 | { |
||
| 248 | $this->loadLegacyParams(); |
||
| 249 | $template = '@ChamiloCore/Layout/no_layout.html.twig'; |
||
| 250 | $this->returnResponse($this->params, $template); |
||
| 251 | } |
||
| 252 | |||
| 253 | /** |
||
| 254 | * Displays an empty template. |
||
| 255 | */ |
||
| 256 | public function displaySkillLayout() |
||
| 257 | { |
||
| 258 | $this->loadLegacyParams(); |
||
| 259 | $template = '@ChamiloCore/Layout/skill_layout.html.twig'; |
||
| 260 | $this->returnResponse($this->params, $template); |
||
| 261 | } |
||
| 262 | |||
| 263 | /** |
||
| 264 | * return true if toolbar has to be displayed for user. |
||
| 265 | * |
||
| 266 | * @return bool |
||
| 267 | */ |
||
| 268 | public static function isToolBarDisplayedForUser() |
||
| 269 | { |
||
| 270 | //Toolbar |
||
| 271 | $show_admin_toolbar = api_get_setting('show_admin_toolbar'); |
||
| 272 | $show_toolbar = false; |
||
| 273 | |||
| 274 | switch ($show_admin_toolbar) { |
||
| 275 | case 'do_not_show': |
||
| 276 | break; |
||
| 277 | case 'show_to_admin': |
||
| 278 | if (api_is_platform_admin()) { |
||
| 279 | $show_toolbar = true; |
||
| 280 | } |
||
| 281 | break; |
||
| 282 | case 'show_to_admin_and_teachers': |
||
| 283 | if (api_is_platform_admin() || api_is_allowed_to_edit()) { |
||
| 284 | $show_toolbar = true; |
||
| 285 | } |
||
| 286 | break; |
||
| 287 | case 'show_to_all': |
||
| 288 | $show_toolbar = true; |
||
| 289 | break; |
||
| 290 | } |
||
| 291 | |||
| 292 | return $show_toolbar; |
||
| 293 | } |
||
| 294 | |||
| 295 | /** |
||
| 296 | * Sets the header visibility. |
||
| 297 | * |
||
| 298 | * @param bool true if we show the header |
||
| 299 | */ |
||
| 300 | public function set_header($status) |
||
| 301 | { |
||
| 302 | $this->show_header = $status; |
||
| 303 | $this->assign('show_header', $status); |
||
| 304 | |||
| 305 | $show_toolbar = 0; |
||
| 306 | |||
| 307 | if (self::isToolBarDisplayedForUser()) { |
||
| 308 | $show_toolbar = 1; |
||
| 309 | } |
||
| 310 | |||
| 311 | $this->assign('show_toolbar', $show_toolbar); |
||
| 312 | |||
| 313 | // Only if course is available |
||
| 314 | $courseToolBar = ''; |
||
| 315 | $show_course_navigation_menu = ''; |
||
| 316 | if (!empty($this->course_id) && $this->user_is_logged_in) { |
||
| 317 | if ('false' !== api_get_setting('show_toolshortcuts')) { |
||
| 318 | // Course toolbar |
||
| 319 | $courseToolBar = CourseHome::show_navigation_tool_shortcuts(); |
||
| 320 | } |
||
| 321 | if ('false' !== api_get_setting('show_navigation_menu')) { |
||
| 322 | //Course toolbar |
||
| 323 | $show_course_navigation_menu = CourseHome::show_navigation_menu(); |
||
| 324 | } |
||
| 325 | } |
||
| 326 | $this->assign('show_course_shortcut', $courseToolBar); |
||
| 327 | $this->assign('show_course_navigation_menu', $show_course_navigation_menu); |
||
| 328 | } |
||
| 329 | |||
| 330 | /** |
||
| 331 | * Returns the sub-folder and filename for the given tpl file. |
||
| 332 | * |
||
| 333 | * If template not found in overrides/ or custom template folder, the default template will be used. |
||
| 334 | * |
||
| 335 | * @param string $name |
||
| 336 | * |
||
| 337 | * @return string |
||
| 338 | */ |
||
| 339 | public static function findTemplateFilePath($name) |
||
| 340 | { |
||
| 341 | $sysTemplatePath = api_get_path(SYS_TEMPLATE_PATH); |
||
| 342 | |||
| 343 | // Check if the tpl file is present in the main/template/overrides/ dir |
||
| 344 | // Overrides is a special directory meant for temporary template |
||
| 345 | // customization. It must be taken into account before anything else |
||
| 346 | if (is_readable($sysTemplatePath."overrides/$name")) { |
||
| 347 | return "overrides/$name"; |
||
| 348 | } |
||
| 349 | |||
| 350 | $defaultFolder = api_get_configuration_value('default_template'); |
||
| 351 | |||
| 352 | // If a template folder has been manually defined, search for the right |
||
| 353 | // file, and if not found, go for the same file in the default template |
||
| 354 | if ($defaultFolder && 'default' != $defaultFolder) { |
||
| 355 | // Avoid missing template error, use the default file. |
||
| 356 | if (file_exists($sysTemplatePath."$defaultFolder/$name")) { |
||
| 357 | return "$defaultFolder/$name"; |
||
| 358 | } |
||
| 359 | } |
||
| 360 | |||
| 361 | $name = str_replace('tpl', 'html.twig', $name); |
||
| 362 | |||
| 363 | return "default/$name"; |
||
| 364 | } |
||
| 365 | |||
| 366 | /** |
||
| 367 | * Call non-static for Template::findTemplateFilePath. |
||
| 368 | * |
||
| 369 | * @see Template::findTemplateFilePath() |
||
| 370 | * |
||
| 371 | * @param string $name |
||
| 372 | * |
||
| 373 | * @return string |
||
| 374 | */ |
||
| 375 | public function get_template($name) |
||
| 376 | { |
||
| 377 | return api_find_template($name); |
||
| 378 | } |
||
| 379 | |||
| 380 | /** |
||
| 381 | * Get CSS themes sub-directory. |
||
| 382 | * |
||
| 383 | * @param string $theme |
||
| 384 | * |
||
| 385 | * @return string with a trailing slash, e.g. 'themes/chamilo_red/' |
||
| 386 | */ |
||
| 387 | public static function getThemeDir($theme) |
||
| 388 | { |
||
| 389 | $themeDir = 'themes/'.$theme.'/'; |
||
| 390 | $virtualTheme = api_get_configuration_value('virtual_css_theme_folder'); |
||
| 391 | if (!empty($virtualTheme)) { |
||
| 392 | $virtualThemeList = api_get_themes(true); |
||
| 393 | $isVirtualTheme = in_array($theme, array_keys($virtualThemeList)); |
||
| 394 | if ($isVirtualTheme) { |
||
| 395 | $themeDir = 'themes/'.$virtualTheme.'/'.$theme.'/'; |
||
| 396 | } |
||
| 397 | } |
||
| 398 | |||
| 399 | return $themeDir; |
||
| 400 | } |
||
| 401 | |||
| 402 | /** |
||
| 403 | * Set legacy twig globals in order to be hook in the LegacyListener.php. |
||
| 404 | * |
||
| 405 | * @return array |
||
| 406 | */ |
||
| 407 | public static function getGlobals() |
||
| 408 | { |
||
| 409 | return [ |
||
| 410 | '_s' => [ |
||
| 411 | 'software_name' => api_get_configuration_value('software_name'), |
||
| 412 | 'system_version' => api_get_configuration_value('system_version'), |
||
| 413 | 'site_name' => api_get_setting('siteName'), |
||
| 414 | 'institution' => api_get_setting('Institution'), |
||
| 415 | 'gamification_mode' => api_get_setting('gamification_mode'), |
||
| 416 | ], |
||
| 417 | 'template' => 'default', // @todo setup template folder in config.yml; |
||
| 418 | ]; |
||
| 419 | } |
||
| 420 | |||
| 421 | /** |
||
| 422 | * Set theme, include mainstream CSS files. |
||
| 423 | * |
||
| 424 | * @deprecated |
||
| 425 | * @see setCssCustomFiles() for additional CSS sheets |
||
| 426 | */ |
||
| 427 | public function setCssFiles() |
||
| 481 | } |
||
| 482 | |||
| 483 | /** |
||
| 484 | * Prepare custom CSS to be added at the very end of the <head> section. |
||
| 485 | * |
||
| 486 | * @see setCssFiles() for the mainstream CSS files |
||
| 487 | */ |
||
| 488 | public function setCssCustomFiles() |
||
| 489 | { |
||
| 490 | global $disable_js_and_css_files; |
||
| 542 | } |
||
| 543 | |||
| 544 | /** |
||
| 545 | * Declare and define the template variable that will be used to load |
||
| 546 | * javascript libraries in the header. |
||
| 547 | */ |
||
| 548 | public function set_js_files() |
||
| 675 | } |
||
| 676 | } |
||
| 677 | |||
| 678 | public static function setVueParams(&$params) |
||
| 679 | { |
||
| 680 | $params['is_authenticated'] = !api_is_anonymous(); |
||
| 681 | /*$user = api_get_user_entity(api_get_user_id()); |
||
| 682 | $encoded = ''; |
||
| 683 | if ($user) { |
||
| 684 | $encoded = json_encode($user); |
||
| 685 | } |
||
| 686 | $params['user'] = $encoded;*/ |
||
| 687 | $params['from_vue'] = isset($_REQUEST['from_vue']) ? 1 : 0; |
||
| 688 | } |
||
| 689 | |||
| 690 | /** |
||
| 691 | * @param array $params |
||
| 692 | * @param string $template |
||
| 693 | * |
||
| 694 | * @throws \Twig\Error\Error |
||
| 695 | */ |
||
| 696 | public function returnResponse($params, $template) |
||
| 697 | { |
||
| 698 | $flash = Display::getFlashToString(); |
||
| 699 | Display::cleanFlashMessages(); |
||
| 700 | $response = new Response(); |
||
| 701 | $params['flash_messages'] = $flash; |
||
| 702 | $content = Container::getTemplating()->render($template, $params); |
||
| 703 | $response->setContent($content); |
||
| 704 | $response->send(); |
||
| 705 | } |
||
| 706 | |||
| 707 | /** |
||
| 708 | * Special function to declare last-minute JS libraries which depend on |
||
| 709 | * other things to be declared first. In particular, it might be useful |
||
| 710 | * under IE9 with compatibility mode, which for some reason is getting |
||
| 711 | * upset when a variable is used in a function (even if not used yet) |
||
| 712 | * when this variable hasn't been defined yet. |
||
| 713 | */ |
||
| 714 | public function set_js_files_post() |
||
| 715 | { |
||
| 716 | global $disable_js_and_css_files; |
||
| 717 | $js_files = []; |
||
| 718 | if (api_is_global_chat_enabled()) { |
||
| 719 | //Do not include the global chat in LP |
||
| 720 | if (false == $this->show_learnpath && true == $this->show_footer && false == $this->hide_global_chat) { |
||
| 721 | $js_files[] = 'chat/js/chat.js'; |
||
| 722 | } |
||
| 723 | } |
||
| 724 | $js_file_to_string = ''; |
||
| 725 | foreach ($js_files as $js_file) { |
||
| 726 | $js_file_to_string .= api_get_js($js_file); |
||
| 727 | } |
||
| 728 | if (!$disable_js_and_css_files) { |
||
| 729 | $this->assign('js_file_to_string_post', $js_file_to_string); |
||
| 730 | } |
||
| 731 | } |
||
| 732 | |||
| 733 | /** |
||
| 734 | * @param string $theme |
||
| 735 | * |
||
| 736 | * @return string |
||
| 737 | */ |
||
| 738 | public static function getPortalIcon($theme) |
||
| 739 | { |
||
| 740 | // Default root chamilo favicon |
||
| 741 | $icon = 'favicon.ico'; |
||
| 742 | |||
| 743 | // Added to verify if in the current Chamilo Theme exist a favicon |
||
| 744 | $themeUrl = api_get_path(SYS_CSS_PATH).'themes/'.$theme.'/images/'; |
||
| 745 | |||
| 746 | // If exist pick the current chamilo theme favicon. |
||
| 747 | if (is_file($themeUrl.'favicon.ico')) { |
||
| 748 | $icon = 'build/css/themes/'.$theme.'/images/favicon.ico'; |
||
| 749 | } |
||
| 750 | |||
| 751 | return $icon; |
||
| 752 | } |
||
| 753 | |||
| 754 | /** |
||
| 755 | * Show footer js template. |
||
| 756 | */ |
||
| 757 | public function show_footer_js_template() |
||
| 758 | { |
||
| 759 | $tpl = $this->get_template('layout/footer.js.tpl'); |
||
| 760 | $this->display($tpl); |
||
| 761 | } |
||
| 762 | |||
| 763 | /** |
||
| 764 | * @param string $template |
||
| 765 | * |
||
| 766 | * @return string |
||
| 767 | */ |
||
| 768 | public function fetch($template = null) |
||
| 769 | { |
||
| 770 | return $this->twig->render($template, $this->params); |
||
| 771 | } |
||
| 772 | |||
| 773 | /** |
||
| 774 | * @param string $variable |
||
| 775 | * @param mixed $value |
||
| 776 | */ |
||
| 777 | public function assign($variable, $value = '') |
||
| 778 | { |
||
| 779 | $this->params[$variable] = $value; |
||
| 780 | } |
||
| 781 | |||
| 782 | /** |
||
| 783 | * Adds a body class for login pages. |
||
| 784 | */ |
||
| 785 | public function setLoginBodyClass() |
||
| 786 | { |
||
| 787 | $this->assign('login_class', 'section-login'); |
||
| 788 | } |
||
| 789 | |||
| 790 | /** |
||
| 791 | * The theme that will be used if the database is not working. |
||
| 792 | * |
||
| 793 | * @return string |
||
| 794 | */ |
||
| 795 | public static function getThemeFallback() |
||
| 796 | { |
||
| 797 | $theme = api_get_configuration_value('theme_fallback'); |
||
| 798 | if (empty($theme)) { |
||
| 799 | $theme = 'chamilo'; |
||
| 800 | } |
||
| 801 | |||
| 802 | return $theme; |
||
| 803 | } |
||
| 804 | |||
| 805 | /** |
||
| 806 | * @return string |
||
| 807 | */ |
||
| 808 | public function handleLoginFailed() |
||
| 809 | { |
||
| 810 | $message = get_lang('Login failed - incorrect login or password.'); |
||
| 811 | |||
| 812 | if (!isset($_GET['error'])) { |
||
| 813 | if (api_is_self_registration_allowed()) { |
||
| 814 | $message = get_lang('Login failed - if you are not registered, you can do so using the <a href=claroline/auth/inscription.php>registration form</a>'); |
||
| 815 | } |
||
| 816 | } else { |
||
| 817 | switch ($_GET['error']) { |
||
| 818 | case '': |
||
| 819 | if (api_is_self_registration_allowed()) { |
||
| 820 | $message = get_lang('Login failed - if you are not registered, you can do so using the <a href=claroline/auth/inscription.php>registration form</a>'); |
||
| 821 | } |
||
| 822 | break; |
||
| 823 | case 'account_expired': |
||
| 824 | $message = get_lang('Account expired'); |
||
| 825 | break; |
||
| 826 | case 'account_inactive': |
||
| 827 | $message = get_lang('Account inactive'); |
||
| 828 | |||
| 829 | if ('confirmation' === api_get_setting('allow_registration')) { |
||
| 830 | $message = get_lang('Your account is inactive because you have not confirmed it yet. Check your email and follow the instructions or click the following link to resend the email').PHP_EOL; |
||
| 831 | $message .= Display::url( |
||
| 832 | get_lang('Send confirmation mail again'), |
||
| 833 | api_get_path(WEB_PATH).'main/auth/resend_confirmation_mail.php', |
||
| 834 | ['class' => 'alert-link'] |
||
| 835 | ); |
||
| 836 | } |
||
| 837 | break; |
||
| 838 | case 'user_password_incorrect': |
||
| 839 | $message = get_lang('Login failed - incorrect login or password.'); |
||
| 840 | break; |
||
| 841 | case 'access_url_inactive': |
||
| 842 | $message = get_lang('Account inactive for this URL'); |
||
| 843 | break; |
||
| 844 | case 'wrong_captcha': |
||
| 845 | $message = get_lang('The text you entered doesn\'t match the picture.'); |
||
| 846 | break; |
||
| 847 | case 'blocked_by_captcha': |
||
| 848 | $message = get_lang('Account blocked by captcha.'); |
||
| 849 | break; |
||
| 850 | case 'multiple_connection_not_allowed': |
||
| 851 | $message = get_lang('This user is already logged in'); |
||
| 852 | break; |
||
| 853 | } |
||
| 854 | } |
||
| 855 | |||
| 856 | return Display::return_message($message, 'error', false); |
||
| 857 | } |
||
| 858 | |||
| 859 | /** |
||
| 860 | * @return string |
||
| 861 | */ |
||
| 862 | public function displayLoginForm() |
||
| 968 | } |
||
| 969 | |||
| 970 | /** |
||
| 971 | * Returns the tutors names for the current course in session |
||
| 972 | * Function to use in Twig templates. |
||
| 973 | * |
||
| 974 | * @return string |
||
| 975 | */ |
||
| 976 | public static function returnTutorsNames() |
||
| 977 | { |
||
| 978 | $em = Database::getManager(); |
||
| 979 | $tutors = $em |
||
| 980 | ->createQuery(' |
||
| 981 | SELECT u FROM ChamiloCoreBundle:User u |
||
| 982 | INNER JOIN ChamiloCoreBundle:SessionRelCourseRelUser scu WITH u.id = scu.user |
||
| 983 | WHERE scu.status = :teacher_status AND scu.session = :session AND scu.course = :course |
||
| 984 | ') |
||
| 985 | ->setParameters([ |
||
| 986 | 'teacher_status' => SessionRelCourseRelUser::STATUS_COURSE_COACH, |
||
| 987 | 'session' => api_get_session_id(), |
||
| 988 | 'course' => api_get_course_int_id(), |
||
| 989 | ]) |
||
| 990 | ->getResult(); |
||
| 991 | |||
| 992 | $names = []; |
||
| 993 | |||
| 994 | /** @var User $tutor */ |
||
| 995 | foreach ($tutors as $tutor) { |
||
| 996 | $names[] = UserManager::formatUserFullName($tutor); |
||
| 997 | } |
||
| 998 | |||
| 999 | return implode(CourseManager::USER_SEPARATOR, $names); |
||
| 1000 | } |
||
| 1001 | |||
| 1002 | /*s |
||
| 1003 | * Returns the teachers name for the current course |
||
| 1004 | * Function to use in Twig templates |
||
| 1005 | * @return string |
||
| 1006 | */ |
||
| 1007 | public static function returnTeachersNames() |
||
| 1008 | { |
||
| 1009 | $em = Database::getManager(); |
||
| 1010 | $teachers = $em |
||
| 1011 | ->createQuery(' |
||
| 1012 | SELECT u FROM ChamiloCoreBundle:User u |
||
| 1013 | INNER JOIN ChamiloCoreBundle:CourseRelUser cu WITH u.id = cu.user |
||
| 1014 | WHERE cu.status = :teacher_status AND cu.course = :course |
||
| 1015 | ') |
||
| 1016 | ->setParameters([ |
||
| 1017 | 'teacher_status' => User::COURSE_MANAGER, |
||
| 1018 | 'course' => api_get_course_int_id(), |
||
| 1019 | ]) |
||
| 1020 | ->getResult(); |
||
| 1021 | |||
| 1022 | $names = []; |
||
| 1023 | |||
| 1024 | /** @var User $teacher */ |
||
| 1025 | foreach ($teachers as $teacher) { |
||
| 1026 | $names[] = UserManager::formatUserFullName($teacher); |
||
| 1027 | } |
||
| 1028 | |||
| 1029 | return implode(CourseManager::USER_SEPARATOR, $names); |
||
| 1030 | } |
||
| 1031 | |||
| 1032 | /** |
||
| 1033 | * @param int $code |
||
| 1034 | */ |
||
| 1035 | public function setResponseCode($code) |
||
| 1036 | { |
||
| 1037 | $this->responseCode = $code; |
||
| 1038 | } |
||
| 1039 | |||
| 1040 | /** |
||
| 1041 | * @param string $code |
||
| 1042 | */ |
||
| 1043 | public function getResponseCode() |
||
| 1044 | { |
||
| 1045 | return $this->responseCode; |
||
| 1046 | } |
||
| 1047 | |||
| 1048 | /** |
||
| 1049 | * Assign HTML code to the 'bug_notification' template variable for the side tabs to report issues. |
||
| 1050 | * |
||
| 1051 | * @return bool Always return true because there is always a string, even if empty |
||
| 1052 | */ |
||
| 1053 | public function assignBugNotification() |
||
| 1054 | { |
||
| 1055 | //@todo move this in the template |
||
| 1056 | $rightFloatMenu = ''; |
||
| 1057 | $iconBug = Display::return_icon( |
||
| 1058 | 'bug.png', |
||
| 1059 | get_lang('Report a bug'), |
||
| 1060 | [], |
||
| 1061 | ICON_SIZE_LARGE |
||
| 1062 | ); |
||
| 1063 | if ('true' === api_get_setting('show_link_bug_notification') && $this->user_is_logged_in) { |
||
| 1064 | $rightFloatMenu = '<div class="report"> |
||
| 1065 | <a href="https://github.com/chamilo/chamilo-lms/wiki/How-to-report-issues" target="_blank"> |
||
| 1066 | '.$iconBug.' |
||
| 1067 | </a> |
||
| 1068 | </div>'; |
||
| 1069 | } |
||
| 1070 | |||
| 1071 | if ('true' === api_get_setting('show_link_ticket_notification') && |
||
| 1072 | $this->user_is_logged_in |
||
| 1073 | ) { |
||
| 1074 | // by default is project_id = 1 |
||
| 1075 | $defaultProjectId = 1; |
||
| 1076 | $iconTicket = Display::return_icon( |
||
| 1077 | 'help.png', |
||
| 1078 | get_lang('Ticket'), |
||
| 1079 | [], |
||
| 1080 | ICON_SIZE_LARGE |
||
| 1081 | ); |
||
| 1082 | $courseInfo = api_get_course_info(); |
||
| 1083 | $courseParams = ''; |
||
| 1084 | if (!empty($courseInfo)) { |
||
| 1085 | $courseParams = api_get_cidreq(); |
||
| 1086 | } |
||
| 1087 | $url = api_get_path(WEB_CODE_PATH).'ticket/tickets.php?project_id='.$defaultProjectId.'&'.$courseParams; |
||
| 1088 | |||
| 1089 | $allow = TicketManager::userIsAllowInProject(api_get_user_info(), $defaultProjectId); |
||
| 1090 | |||
| 1091 | if ($allow) { |
||
| 1092 | $rightFloatMenu .= '<div class="help"> |
||
| 1093 | <a href="'.$url.'" target="_blank"> |
||
| 1094 | '.$iconTicket.' |
||
| 1095 | </a> |
||
| 1096 | </div>'; |
||
| 1097 | } |
||
| 1098 | } |
||
| 1099 | |||
| 1100 | $this->assign('bug_notification', $rightFloatMenu); |
||
| 1101 | |||
| 1102 | return true; |
||
| 1103 | } |
||
| 1104 | |||
| 1105 | /** |
||
| 1106 | * Load legacy params. |
||
| 1107 | */ |
||
| 1108 | private function loadLegacyParams() |
||
| 1116 | } |
||
| 1117 | |||
| 1118 | /** |
||
| 1119 | * Prepare the _c array for template files. The _c array contains |
||
| 1120 | * information about the current course. |
||
| 1121 | */ |
||
| 1122 | private function set_course_parameters() |
||
| 1123 | { |
||
| 1124 | //Setting course id |
||
| 1125 | $course = api_get_course_info(); |
||
| 1126 | if (empty($course)) { |
||
| 1127 | $this->assign('course_is_set', false); |
||
| 1128 | |||
| 1129 | return; |
||
| 1130 | } |
||
| 1131 | $this->assign('course_is_set', true); |
||
| 1132 | $this->course_id = $course['id']; |
||
| 1133 | $_c = [ |
||
| 1134 | 'id' => $course['real_id'], |
||
| 1135 | 'code' => $course['code'], |
||
| 1136 | 'title' => $course['name'], |
||
| 1137 | 'visibility' => $course['visibility'], |
||
| 1138 | 'language' => $course['language'], |
||
| 1139 | 'directory' => $course['directory'], |
||
| 1140 | 'session_id' => api_get_session_id(), |
||
| 1141 | 'user_is_teacher' => api_is_course_admin(), |
||
| 1142 | 'student_view' => (!empty($_GET['isStudentView']) && 'true' == $_GET['isStudentView']), |
||
| 1143 | ]; |
||
| 1144 | $this->assign('course_code', $course['code']); |
||
| 1145 | $this->assign('_c', $_c); |
||
| 1146 | } |
||
| 1147 | |||
| 1148 | /** |
||
| 1149 | * Prepare the _u array for template files. The _u array contains |
||
| 1150 | * information about the current user, as returned by |
||
| 1151 | * api_get_user_info(). |
||
| 1152 | */ |
||
| 1153 | private function set_user_parameters() |
||
| 1154 | { |
||
| 1155 | $user_info = []; |
||
| 1156 | $user_info['logged'] = 0; |
||
| 1157 | $this->user_is_logged_in = false; |
||
| 1158 | if (api_user_is_login()) { |
||
| 1159 | $user_info = api_get_user_info(api_get_user_id(), true); |
||
| 1160 | $user_info['logged'] = 1; |
||
| 1161 | |||
| 1162 | $user_info['is_admin'] = 0; |
||
| 1163 | if (api_is_platform_admin()) { |
||
| 1164 | $user_info['is_admin'] = 1; |
||
| 1165 | } |
||
| 1166 | |||
| 1167 | $user_info['messages_count'] = MessageManager::getCountNewMessages(); |
||
| 1168 | $this->user_is_logged_in = true; |
||
| 1169 | } |
||
| 1170 | // Setting the $_u array that could be use in any template |
||
| 1171 | $this->assign('_u', $user_info); |
||
| 1172 | } |
||
| 1173 | |||
| 1174 | /** |
||
| 1175 | * Set header parameters. |
||
| 1176 | * |
||
| 1177 | * @deprecated |
||
| 1178 | * |
||
| 1179 | * @param bool $sendHeaders send headers |
||
| 1180 | */ |
||
| 1181 | private function set_header_parameters($sendHeaders) |
||
| 1182 | { |
||
| 1183 | global $httpHeadXtra, $interbreadcrumb, $language_file, $_configuration, $this_section; |
||
| 1184 | $_course = api_get_course_info(); |
||
| 1185 | $nameTools = $this->title; |
||
| 1186 | $navigation = return_navigation_array(); |
||
| 1187 | $this->menu_navigation = $navigation['menu_navigation']; |
||
| 1188 | |||
| 1189 | $this->assign('system_charset', api_get_system_encoding()); |
||
| 1190 | |||
| 1191 | if (isset($httpHeadXtra) && $httpHeadXtra) { |
||
| 1192 | foreach ($httpHeadXtra as &$thisHttpHead) { |
||
| 1193 | //header($thisHttpHead); |
||
| 1194 | } |
||
| 1195 | } |
||
| 1196 | |||
| 1197 | $this->assign( |
||
| 1198 | 'online_button', |
||
| 1199 | Display::return_icon('statusonline.png', null, [], ICON_SIZE_ATOM) |
||
| 1200 | ); |
||
| 1201 | $this->assign( |
||
| 1202 | 'offline_button', |
||
| 1203 | Display::return_icon('statusoffline.png', null, [], ICON_SIZE_ATOM) |
||
| 1204 | ); |
||
| 1205 | |||
| 1206 | // Get language iso-code for this page - ignore errors |
||
| 1207 | $this->assign('document_language', api_get_language_isocode()); |
||
| 1208 | |||
| 1209 | $course_title = isset($_course['name']) ? $_course['name'] : null; |
||
| 1210 | |||
| 1211 | $title_list = []; |
||
| 1212 | |||
| 1213 | $title_list[] = api_get_setting('Institution'); |
||
| 1214 | $title_list[] = api_get_setting('siteName'); |
||
| 1215 | |||
| 1216 | if (!empty($course_title)) { |
||
| 1217 | $title_list[] = $course_title; |
||
| 1218 | } |
||
| 1219 | if ('' != $nameTools) { |
||
| 1220 | $title_list[] = $nameTools; |
||
| 1221 | } |
||
| 1222 | |||
| 1223 | $title_string = ''; |
||
| 1224 | for ($i = 0; $i < count($title_list); $i++) { |
||
| 1225 | $title_string .= $title_list[$i]; |
||
| 1226 | if (isset($title_list[$i + 1])) { |
||
| 1227 | $item = trim($title_list[$i + 1]); |
||
| 1228 | if (!empty($item)) { |
||
| 1229 | $title_string .= ' - '; |
||
| 1230 | } |
||
| 1231 | } |
||
| 1232 | } |
||
| 1233 | |||
| 1234 | $this->assign('title_string', $title_string); |
||
| 1235 | |||
| 1236 | // Setting the theme and CSS files |
||
| 1237 | $this->setCssFiles(); |
||
| 1238 | $this->set_js_files(); |
||
| 1239 | $this->setCssCustomFiles(); |
||
| 1240 | |||
| 1241 | $browser = api_browser_support('check_browser'); |
||
| 1242 | if ('Internet Explorer' == $browser[0] && $browser[1] >= '11') { |
||
| 1243 | $browser_head = '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />'; |
||
| 1244 | $this->assign('browser_specific_head', $browser_head); |
||
| 1245 | } |
||
| 1246 | |||
| 1247 | // Implementation of prefetch. |
||
| 1248 | // See http://cdn.chamilo.org/main/img/online.png for details |
||
| 1249 | $prefetch = ''; |
||
| 1250 | if (!empty($_configuration['cdn_enable'])) { |
||
| 1251 | $prefetch .= '<meta http-equiv="x-dns-prefetch-control" content="on">'; |
||
| 1252 | foreach ($_configuration['cdn'] as $host => $exts) { |
||
| 1253 | $prefetch .= '<link rel="dns-prefetch" href="'.$host.'">'; |
||
| 1254 | } |
||
| 1255 | } |
||
| 1256 | |||
| 1257 | $this->assign('prefetch', $prefetch); |
||
| 1258 | $this->assign('text_direction', api_get_text_direction()); |
||
| 1259 | $this->assign('section_name', 'section-'.$this_section); |
||
| 1260 | $this->assignFavIcon(); |
||
| 1261 | $this->setHelp(); |
||
| 1262 | |||
| 1263 | $this->assignBugNotification(); //Prepare the 'bug_notification' var for the template |
||
| 1264 | |||
| 1265 | $this->assignAccessibilityBlock(); //Prepare the 'accessibility' var for the template |
||
| 1266 | |||
| 1267 | // Preparing values for the menu |
||
| 1268 | |||
| 1269 | // Logout link |
||
| 1270 | $hideLogout = api_get_setting('hide_logout_button'); |
||
| 1271 | if ('true' === $hideLogout) { |
||
| 1272 | $this->assign('logout_link', null); |
||
| 1273 | } else { |
||
| 1274 | $this->assign('logout_link', api_get_path(WEB_PATH).'index.php?logout=logout&uid='.api_get_user_id()); |
||
| 1275 | } |
||
| 1276 | |||
| 1277 | // Profile link |
||
| 1278 | if ('true' == api_get_setting('allow_social_tool')) { |
||
| 1279 | $profile_url = api_get_path(WEB_CODE_PATH).'social/home.php'; |
||
| 1280 | } else { |
||
| 1281 | $profile_url = api_get_path(WEB_CODE_PATH).'auth/profile.php'; |
||
| 1282 | } |
||
| 1283 | |||
| 1284 | $this->assign('profile_url', $profile_url); |
||
| 1285 | |||
| 1286 | //Message link |
||
| 1287 | $message_link = null; |
||
| 1288 | $message_url = null; |
||
| 1289 | if ('true' == api_get_setting('allow_message_tool')) { |
||
| 1290 | $message_url = api_get_path(WEB_CODE_PATH).'messages/inbox.php'; |
||
| 1291 | $message_link = '<a href="'.api_get_path(WEB_CODE_PATH).'messages/inbox.php">'.get_lang('Inbox').'</a>'; |
||
| 1292 | } |
||
| 1293 | $this->assign('message_link', $message_link); |
||
| 1294 | $this->assign('message_url', $message_url); |
||
| 1295 | |||
| 1296 | $pendingSurveyLink = ''; |
||
| 1297 | $show = api_get_configuration_value('show_pending_survey_in_menu'); |
||
| 1298 | if ($show) { |
||
| 1299 | $pendingSurveyLink = api_get_path(WEB_CODE_PATH).'survey/pending.php'; |
||
| 1300 | } |
||
| 1301 | $this->assign('pending_survey_url', $pendingSurveyLink); |
||
| 1302 | |||
| 1303 | // Certificate Link |
||
| 1304 | $allow = api_get_configuration_value('certificate.hide_my_certificate_link'); |
||
| 1305 | if (false === $allow) { |
||
| 1306 | $certificateUrl = api_get_path(WEB_CODE_PATH).'gradebook/my_certificates.php'; |
||
| 1307 | $certificateLink = Display::url( |
||
| 1308 | get_lang('My certificates'), |
||
| 1309 | $certificateUrl |
||
| 1310 | ); |
||
| 1311 | $this->assign('certificate_link', $certificateLink); |
||
| 1312 | $this->assign('certificate_url', $certificateUrl); |
||
| 1313 | } |
||
| 1314 | |||
| 1315 | $institution = api_get_setting('Institution'); |
||
| 1316 | $portal_name = empty($institution) ? api_get_setting('siteName') : $institution; |
||
| 1317 | |||
| 1318 | $this->assign('portal_name', $portal_name); |
||
| 1319 | |||
| 1320 | //Menu |
||
| 1321 | //$menu = menuArray(); |
||
| 1322 | //$this->assign('menu', $menu); |
||
| 1323 | |||
| 1324 | $breadcrumb = ''; |
||
| 1325 | // Hide breadcrumb in LP |
||
| 1326 | if (false == $this->show_learnpath) { |
||
| 1327 | $breadcrumb = return_breadcrumb( |
||
| 1328 | $interbreadcrumb, |
||
| 1329 | $language_file, |
||
| 1330 | $nameTools |
||
| 1331 | ); |
||
| 1332 | } |
||
| 1333 | $this->assign('breadcrumb', $breadcrumb); |
||
| 1334 | |||
| 1335 | //Extra content |
||
| 1336 | $extra_header = null; |
||
| 1337 | if (!api_is_platform_admin()) { |
||
| 1338 | $extra_header = trim(api_get_setting('header_extra_content')); |
||
| 1339 | } |
||
| 1340 | $this->assign('header_extra_content', $extra_header); |
||
| 1341 | |||
| 1342 | if ($sendHeaders) { |
||
| 1343 | /*header('Content-Type: text/html; charset='.api_get_system_encoding()); |
||
| 1344 | header( |
||
| 1345 | 'X-Powered-By: '.$_configuration['software_name'].' '.substr($_configuration['system_version'], 0, 1) |
||
| 1346 | ); |
||
| 1347 | self::addHTTPSecurityHeaders();*/ |
||
| 1348 | |||
| 1349 | $responseCode = $this->getResponseCode(); |
||
| 1350 | if (!empty($responseCode)) { |
||
| 1351 | switch ($responseCode) { |
||
| 1352 | case '404': |
||
| 1353 | header("HTTP/1.0 404 Not Found"); |
||
| 1354 | break; |
||
| 1355 | } |
||
| 1356 | } |
||
| 1357 | } |
||
| 1358 | |||
| 1359 | $socialMeta = ''; |
||
| 1360 | $metaTitle = api_get_setting('meta_title'); |
||
| 1361 | if (!empty($metaTitle)) { |
||
| 1362 | $socialMeta .= '<meta name="twitter:card" content="summary" />'."\n"; |
||
| 1363 | $metaSite = api_get_setting('meta_twitter_site'); |
||
| 1364 | if (!empty($metaSite)) { |
||
| 1365 | $socialMeta .= '<meta name="twitter:site" content="'.$metaSite.'" />'."\n"; |
||
| 1366 | $metaCreator = api_get_setting('meta_twitter_creator'); |
||
| 1367 | if (!empty($metaCreator)) { |
||
| 1368 | $socialMeta .= '<meta name="twitter:creator" content="'.$metaCreator.'" />'."\n"; |
||
| 1369 | } |
||
| 1370 | } |
||
| 1371 | |||
| 1372 | // The user badge page emits its own meta tags, so if this is |
||
| 1373 | // enabled, ignore the global ones |
||
| 1374 | $userId = isset($_GET['user']) ? intval($_GET['user']) : 0; |
||
| 1375 | $skillId = isset($_GET['skill']) ? intval($_GET['skill']) : 0; |
||
| 1376 | |||
| 1377 | if (!$userId && !$skillId) { |
||
| 1378 | // no combination of user and skill ID has been defined, |
||
| 1379 | // so print the normal OpenGraph meta tags |
||
| 1380 | $socialMeta .= '<meta property="og:title" content="'.$metaTitle.'" />'."\n"; |
||
| 1381 | $socialMeta .= '<meta property="og:url" content="'.api_get_path(WEB_PATH).'" />'."\n"; |
||
| 1382 | |||
| 1383 | $metaDescription = api_get_setting('meta_description'); |
||
| 1384 | if (!empty($metaDescription)) { |
||
| 1385 | $socialMeta .= '<meta property="og:description" content="'.$metaDescription.'" />'."\n"; |
||
| 1386 | } |
||
| 1387 | |||
| 1388 | $metaImage = api_get_setting('meta_image_path'); |
||
| 1389 | if (!empty($metaImage)) { |
||
| 1390 | if (is_file(api_get_path(SYS_PATH).$metaImage)) { |
||
| 1391 | $path = api_get_path(WEB_PATH).$metaImage; |
||
| 1392 | $socialMeta .= '<meta property="og:image" content="'.$path.'" />'."\n"; |
||
| 1393 | } |
||
| 1394 | } |
||
| 1395 | } |
||
| 1396 | } |
||
| 1397 | |||
| 1398 | $this->assign('social_meta', $socialMeta); |
||
| 1399 | } |
||
| 1400 | |||
| 1401 | /** |
||
| 1402 | * Set footer parameters. |
||
| 1403 | */ |
||
| 1404 | private function set_footer_parameters() |
||
| 1411 | } |
||
| 1412 | } |
||
| 1413 | } |
||
| 1414 | |||
| 1415 | /** |
||
| 1416 | * Manage specific HTTP headers security. |
||
| 1417 | */ |
||
| 1418 | private function addHTTPSecurityHeaders() |
||
| 1419 | { |
||
| 1420 | // Implementation of HTTP headers security, as suggested and checked |
||
| 1421 | // by https://securityheaders.io/ |
||
| 1422 | // Enable these settings in configuration.php to use them on your site |
||
| 1423 | // Strict-Transport-Security |
||
| 1424 | $setting = api_get_configuration_value('security_strict_transport'); |
||
| 1425 | if (!empty($setting)) { |
||
| 1426 | header('Strict-Transport-Security: '.$setting); |
||
| 1427 | } |
||
| 1428 | // Content-Security-Policy |
||
| 1429 | $setting = api_get_configuration_value('security_content_policy'); |
||
| 1430 | if (!empty($setting)) { |
||
| 1431 | header('Content-Security-Policy: '.$setting); |
||
| 1432 | } |
||
| 1433 | $setting = api_get_configuration_value('security_content_policy_report_only'); |
||
| 1434 | if (!empty($setting)) { |
||
| 1435 | header('Content-Security-Policy-Report-Only: '.$setting); |
||
| 1436 | } |
||
| 1437 | // Public-Key-Pins |
||
| 1438 | $setting = api_get_configuration_value('security_public_key_pins'); |
||
| 1439 | if (!empty($setting)) { |
||
| 1440 | header('Public-Key-Pins: '.$setting); |
||
| 1441 | } |
||
| 1442 | $setting = api_get_configuration_value('security_public_key_pins_report_only'); |
||
| 1443 | if (!empty($setting)) { |
||
| 1444 | header('Public-Key-Pins-Report-Only: '.$setting); |
||
| 1445 | } |
||
| 1446 | // X-Frame-Options |
||
| 1447 | $setting = api_get_configuration_value('security_x_frame_options'); |
||
| 1448 | if (!empty($setting)) { |
||
| 1449 | header('X-Frame-Options: '.$setting); |
||
| 1450 | } |
||
| 1451 | // X-XSS-Protection |
||
| 1452 | $setting = api_get_configuration_value('security_xss_protection'); |
||
| 1453 | if (!empty($setting)) { |
||
| 1454 | header('X-XSS-Protection: '.$setting); |
||
| 1455 | } |
||
| 1456 | // X-Content-Type-Options |
||
| 1457 | $setting = api_get_configuration_value('security_x_content_type_options'); |
||
| 1458 | if (!empty($setting)) { |
||
| 1459 | header('X-Content-Type-Options: '.$setting); |
||
| 1460 | } |
||
| 1461 | // Referrer-Policy |
||
| 1462 | $setting = api_get_configuration_value('security_referrer_policy'); |
||
| 1463 | if (!empty($setting)) { |
||
| 1464 | header('Referrer-Policy: '.$setting); |
||
| 1465 | } |
||
| 1466 | // end of HTTP headers security block |
||
| 1467 | } |
||
| 1468 | |||
| 1469 | /** |
||
| 1470 | * Assign favicon to the 'favico' template variable. |
||
| 1471 | * |
||
| 1472 | * @return bool Always return true because there is always at least one correct favicon.ico |
||
| 1473 | */ |
||
| 1474 | private function assignFavIcon() |
||
| 1475 | { |
||
| 1476 | // Default root chamilo favicon |
||
| 1477 | $favico = '<link rel="shortcut icon" href="'.api_get_path(WEB_PATH).'favicon.ico" type="image/x-icon" />'; |
||
| 1478 | |||
| 1479 | //Added to verify if in the current Chamilo Theme exist a favicon |
||
| 1480 | $favicoThemeUrl = api_get_path(SYS_CSS_PATH).$this->themeDir.'images/'; |
||
| 1481 | |||
| 1482 | //If exist pick the current chamilo theme favicon |
||
| 1483 | if (is_file($favicoThemeUrl.'favicon.ico')) { |
||
| 1484 | $favico = '<link rel="shortcut icon" href="'.api_get_path(WEB_CSS_PATH).$this->themeDir.'images/favicon.ico" type="image/x-icon" />'; |
||
| 1485 | } |
||
| 1486 | |||
| 1487 | if (api_is_multiple_url_enabled()) { |
||
| 1488 | /*$access_url_id = api_get_current_access_url_id(); |
||
| 1489 | if ($access_url_id != -1) { |
||
| 1490 | $url_info = api_get_access_url($access_url_id); |
||
| 1491 | $url = api_remove_trailing_slash( |
||
| 1492 | preg_replace('/https?:\/\//i', '', $url_info['url']) |
||
| 1493 | ); |
||
| 1494 | $clean_url = api_replace_dangerous_char($url); |
||
| 1495 | $clean_url = str_replace('/', '-', $clean_url); |
||
| 1496 | $clean_url .= '/'; |
||
| 1497 | $homep = api_get_path(REL_PATH).'home/'.$clean_url; //homep for Home Path |
||
| 1498 | $icon_real_homep = api_get_path(SYS_APP_PATH).'home/'.$clean_url; |
||
| 1499 | //we create the new dir for the new sites |
||
| 1500 | if (is_file($icon_real_homep.'favicon.ico')) { |
||
| 1501 | $favico = '<link rel="shortcut icon" href="'.$homep.'favicon.ico" type="image/x-icon" />'; |
||
| 1502 | } |
||
| 1503 | }*/ |
||
| 1504 | } |
||
| 1505 | |||
| 1506 | $this->assign('favico', $favico); |
||
| 1507 | |||
| 1508 | return true; |
||
| 1509 | } |
||
| 1510 | |||
| 1511 | /** |
||
| 1512 | * Assign HTML code to the 'accessibility' template variable (usually shown above top menu). |
||
| 1513 | * |
||
| 1514 | * @return bool Always return true (even if empty string) |
||
| 1515 | */ |
||
| 1516 | private function assignAccessibilityBlock() |
||
| 1531 | } |
||
| 1532 | |||
| 1533 | /** |
||
| 1534 | * Assign HTML code to the 'social_meta' template variable (usually shown above top menu). |
||
| 1535 | * |
||
| 1536 | * @return bool Always return true (even if empty string) |
||
| 1537 | */ |
||
| 1538 | private function assignSocialMeta() |
||
| 1631 | } |
||
| 1632 | |||
| 1633 | /** |
||
| 1634 | * Get platform meta image tag (check meta_image_path setting, then use the logo). |
||
| 1635 | * |
||
| 1636 | * @param string $imageAlt The alt attribute for the image |
||
| 1637 | * |
||
| 1638 | * @return string The meta image HTML tag, or empty |
||
| 1639 | */ |
||
| 1640 | private function getMetaPortalImagePath($imageAlt = '') |
||
| 1663 | } |
||
| 1664 | } |
||
| 1665 |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.