pushCurrent(); $this->init(); // If the basic database hasn't been created, then build it. if(!DB::isActive() || !ClassInfo::hasTable('SiteTree')) { $this->response = new HTTPResponse(); $this->redirect("dev/build?returnURL="); return $this->response; } $controller = new ModelAsController(); $request = new HTTPRequest("GET", self::get_homepage_urlsegment().'/', $request->getVars(), $request->postVars()); $request->match('$URLSegment//$Action', true); $result = $controller->handleRequest($request); $this->popCurrent(); return $result; } /** * Return the URL segment for the current HTTP_HOST value * * @return string */ static function get_homepage_urlsegment() { $urlSegment = ''; // @todo Temporarily restricted to MySQL database while testing db abstraction if(DB::getConn() instanceof MySQLDatabase) { $host = $_SERVER['HTTP_HOST']; $host = str_replace('www.','',$host); $SQL_host = str_replace('.','\\.',Convert::raw2sql($host)); $homePageOBJ = DataObject::get_one("SiteTree", "HomepageForDomain REGEXP '(,|^) *$SQL_host *(,|\$)'"); } else { $homePageOBJ = null; } if($homePageOBJ) { $urlSegment = $homePageOBJ->URLSegment; } elseif(Translatable::is_enabled()) { $urlSegment = Translatable::get_homepage_urlsegment_by_language(Translatable::current_lang()); } return ($urlSegment) ? $urlSegment : self::get_default_homepage_urlsegment(); } /** * Returns true if we're currently on the root page and should be redirecting to the root * Doesn't take into account actions, post vars, or get vars */ static function should_be_on_root(SiteTree $currentPage) { if(!self::$is_at_root) return self::get_homepage_urlsegment() == $currentPage->URLSegment; else return false; } /** * @return string */ static function get_default_homepage_urlsegment() { return self::$default_homepage_urlsegment; } } ?>