/** * @param $key The nav key, e.g. "doc", "userhelp" * @return HTMLText */ public static function GlobalNav($key) { $baseURL = GlobalNavSiteTreeExtension::get_toolbar_baseurl(); Requirements::css(Controller::join_links($baseURL, Config::inst()->get('GlobalNav', 'css_path'))); // If this method haven't been called before, get the toolbar and cache it if (self::$global_nav_html === null) { // Set the default to empty self::$global_nav_html = ''; // Prevent recursion from happening if (empty($_GET['globaltoolbar'])) { $host = GlobalNavSiteTreeExtension::get_toolbar_hostname(); $path = Director::makeRelative(GlobalNavSiteTreeExtension::get_navbar_filename($key)); if (Config::inst()->get('GlobalNav', 'use_localhost')) { self::$global_nav_html = file_get_contents(BASE_PATH . $path); } else { $url = Controller::join_links($baseURL, $path, '?globaltoolbar=true'); $connectionTimeout = Config::inst()->get('GlobalNavTemplateProvider', 'connection_timeout'); $transferTimeout = Config::inst()->get('GlobalNavTemplateProvider', 'transfer_timeout'); // Get the HTML and cache it self::$global_nav_html = self::curl_call($url, $connectionTimeout, $transferTimeout); } } } $html = DBField::create_field('HTMLText', self::$global_nav_html); $html->setOptions(array('shortcodes' => false)); return $html; }