new file/squeeze package) * * This is used for often used but "deprecated" assets that got * renamed or moved into a squeeze package. */ private static $compatibility_lookup = [ 'jquery/jquery.tablesorter.js' => 'tablesorter', // @since 3.4 ]; /** * Initialize default page layout. This should only be called once * from phplib_local.inc.php. Don't use this otherwise. */ public static function initialize() { // Get software version $v = StudipVersion::getStudipVersion(false); // set favicon self::addHeadElement('link', ['rel' => 'apple-touch-icon', 'sizes' => '180x180', 'href' => Assets::image_path('apple-touch-icon.png')]); self::addHeadElement('link', ['rel' => 'icon', 'type' => 'image/svg+xml', 'href' => Assets::image_path('favicon.svg')]); self::addHeadElement('link', ['rel' => 'icon', 'type' => 'image/png', 'sizes' => '64x64', 'href' => Assets::image_path('favicon-64x64.png')]); self::addHeadElement('link', ['rel' => 'icon', 'type' => 'image/png', 'sizes' => '32x32', 'href' => Assets::image_path('favicon-32x32.png')]); self::addHeadElement('link', ['rel' => 'icon', 'type' => 'image/png', 'sizes' => '16x16', 'href' => Assets::image_path('favicon-16x16.png')]); self::addHeadElement('link', ['rel' => 'manifest', 'href' => Assets::image_path('manifest.json')]); self::addHeadElement('link', ['rel' => 'mask-icon', 'href' => Assets::image_path('safari-pinned-tab.svg')]); self::addHeadElement('link', ['rel' => 'preload', 'href' => Assets::url('fonts/LatoLatin/LatoLatin-Regular.woff2'), 'as' => 'font', 'type' => 'font/woff2', 'crossorigin' => 'anonymous']); self::addHeadElement('link', ['rel' => 'preload', 'href' => Assets::url('fonts/LatoLatin/LatoLatin-Bold.woff2'), 'as' => 'font', 'type' => 'font/woff2', 'crossorigin' => 'anonymous']); self::addHeadElement('meta', ['name' => 'TileColor', 'content' => '#2b5797']); self::addHeadElement('meta', ['name' => 'TileImage', 'content' => Assets::image_path('mstile-144x144.png')]); self::addHeadElement('meta', ['name' => 'msapplication-config', 'content' => Assets::image_path('browserconfig.xml')]); self::addHeadElement('meta', ['name' => 'theme-color', 'content' => '#ffffff']); // set initial width for mobile devices self::addHeadElement('meta', ['name' => 'viewport', 'content' => 'width=device-width, initial-scale=1.0']); self::addHeadElement('link', [ 'rel' => 'help', 'href' => format_help_url('Basis.VerschiedenesFormat'), 'class' => 'text-format', 'title' => _('Hilfe zur Textformatierung') ]); self::addScript('vue.global.prod.js?v=' . $v); self::addScript('vuex.global.prod.js?v=' . $v); // This line fixes the vue-router v3, which is used in several Stud.IP plugins and incorrectly assumes to // interact with Vue2, although Stud.IP v6 uses Vue3. self::addHeadElement('script', [], 'window.Vue.use = () => {};'); self::addStylesheet('studip-base.css?v=' . $v, ['media' => 'screen']); try { $old_base = URLHelper::setBaseURL($GLOBALS['ABSOLUTE_URI_STUDIP']); self::addHeadElement('link', [ 'rel' => 'stylesheet', 'href' => Theme::getDownloadURL(), ]); URLHelper::setBaseURL($old_base); } catch (Exception) { } self::addScript('studip-base.js?v=' . $v); self::addScript('studip-wysiwyg.js?v=' . $v); self::addStylesheet('print.css?v=' . $v, ['media' => 'print']); if (Studip\Debug\DebugBar::isActivated()) { $old_base = URLHelper::setBaseURL($GLOBALS['ABSOLUTE_URI_STUDIP']); self::addHeadElement('link', [ 'href' => URLHelper::getURL('dispatch.php/debugbar/css'), 'rel' => 'stylesheet', 'type' => 'text/css', ]); self::addHeadElement('script', [ 'src' => URLHelper::getURL('dispatch.php/debugbar/js'), ], ''); URLHelper::setBaseURL($old_base); } } /** * Set the page title to the given text. * @param string $title Page title */ public static function setTitle($title) { self::$title = $title; } /** * Returns whether a title has been set * @return bool */ public static function hasTitle() { return isset(self::$title); } /** * Get the current page title (defaults to $UNI_NAME_CLEAN). * @return string */ public static function getTitle() { return isset(self::$title) ? self::$title : (isset($GLOBALS['_html_head_title']) ? $GLOBALS['_html_head_title'] : (isset($GLOBALS['CURRENT_PAGE']) ? $GLOBALS['CURRENT_PAGE'] : Config::get()->UNI_NAME_CLEAN)); } /** * Set the help keyword to the given string. */ public static function setHelpKeyword($help_keyword) { self::$help_keyword = $help_keyword; } /** * Get the current help keyword (defaults to 'Basis.Allgemeines'). */ public static function getHelpKeyword() { return self::$help_keyword ?? 'Basis.Allgemeines'; } /** * Set the help URL in the help bar. Pass null to fall back to the help keyword. */ public static function setHelpUrl(?string $url): void { self::$help_url = $url; } /** * Get the current help URL. If no URL is set explicitly, the URL for * the help keyword is used. */ public static function getHelpUrl(): ?string { return self::$help_url ?? format_help_url(self::getHelpKeyword()); } /** * Select which tabs (if any) should be displayed on the page. The * argument specifies a navigation item in the tree whose children * will form the first level of tabs. If $path is NULL, no tabs are * displayed. The default setting is to use the active element in * the top navigation. * * @param string $path path of navigation item for tabs or NULL */ public static function setTabNavigation($path) { self::$tab_navigation_path = $path; self::$tab_navigation = isset($path) ? Navigation::getItem($path) : NULL; } /** * Returns the base navigation object (not its path) for the tabs. * May return NULL if tab display is disabled. */ public static function getTabNavigation() { if (self::$tab_navigation === false) { self::$tab_navigation = Navigation::hasItem('/') ? Navigation::getItem('/')->activeSubNavigation() : null; } return self::$tab_navigation; } /** * Returns the base navigation path for the tabs. * May return NULL if tab display is disabled. */ public static function getTabNavigationPath() { if (self::$tab_navigation_path === false && self::getTabNavigation()) { foreach (self::getTabNavigation() as $subpath => $navigation) { if ($navigation->isActive()) { self::$tab_navigation_path = $subpath; } } } return self::$tab_navigation_path; } /** * Add CSS variables to the :root selector in the HTML HEAD section. * * @param array $variables Associative array of CSS variable names and values. */ public static function addRootStyle(array $variables) { if (empty($variables)) { return; } $style = ':root {' . PHP_EOL; foreach ($variables as $name => $value) { $style .= " --$name: $value;" . PHP_EOL; } $style .= '}' . PHP_EOL; // Add the