mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX: Made 'homepage for domain' feature work on all databases.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@79318 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
ab9c826ba2
commit
5d67fe14ad
@ -56,14 +56,18 @@ class RootURLController extends Controller {
|
|||||||
static function get_homepage_urlsegment() {
|
static function get_homepage_urlsegment() {
|
||||||
$urlSegment = '';
|
$urlSegment = '';
|
||||||
|
|
||||||
// @todo Temporarily restricted to MySQL database while testing db abstraction
|
$homePageOBJ = null;
|
||||||
if(DB::getConn() instanceof MySQLDatabase) {
|
|
||||||
$host = $_SERVER['HTTP_HOST'];
|
$host = $_SERVER['HTTP_HOST'];
|
||||||
$host = str_replace('www.','',$host);
|
$host = str_replace('www.','',$host);
|
||||||
$SQL_host = str_replace('.','\\.',Convert::raw2sql($host));
|
$SQL_host = Convert::raw2sql($host);
|
||||||
$homePageOBJ = DataObject::get_one("SiteTree", "HomepageForDomain REGEXP '(,|^) *$SQL_host *(,|\$)'");
|
|
||||||
} else {
|
$homePageOBJs = DataObject::get("SiteTree", "HomepageForDomain LIKE '%$SQL_host%'");
|
||||||
$homePageOBJ = null;
|
if($homePageOBJs) foreach($homePageOBJs as $candidateObj) {
|
||||||
|
if(preg_match('/(,|^) *' . preg_quote($host) . ' *(,|$)/', $candidateObj->HomepageForDomain)) {
|
||||||
|
$homePageOBJ = $candidateObj;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(singleton('SiteTree')->hasExtension('Translatable') && !$homePageOBJ) {
|
if(singleton('SiteTree')->hasExtension('Translatable') && !$homePageOBJ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user