public function onBeforeInit()
 {
     $host = GlobalNavSiteTreeExtension::get_toolbar_hostname();
     if ((isset($_REQUEST['regenerate_nav']) || isset($_REQUEST['flush'])) && $host == Director::protocolAndHost() && (Permission::check('ADMIN') || Director::isDev())) {
         GlobalNavSiteTreeExtension::create_static_navs();
     }
 }
 public function onBeforeInit()
 {
     $host = GlobalNavSiteTreeExtension::get_toolbar_hostname();
     if (isset($_REQUEST['flush']) && $host == Director::absoluteBaseURL()) {
         GlobalNavSiteTreeExtension::create_nav();
     }
 }
 /**
  * @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;
 }
 public function GlobalNav()
 {
     Requirements::css(Controller::join_links(GlobalNavSiteTreeExtension::get_toolbar_hostname(), Config::inst()->get('GlobalNav', 'css_path')));
     $html = DBField::create_field('HTMLText', $this->globalNav);
     $html->setOptions(array('shortcodes' => false));
     return $html;
 }