@@ -64,10 +64,10 @@ discard block |
||
| 64 | 64 | $this->hostname = $config['hostname']; |
| 65 | 65 | $this->url = isset($config['resolves_to']) ? $config['resolves_to'] : null; |
| 66 | 66 | |
| 67 | - $globalAllowed = (array) Config::inst()->get('MultiDomain','allow'); |
|
| 68 | - $globalForced = (array) Config::inst()->get('MultiDomain','force'); |
|
| 69 | - $myAllowed = isset($config['allow']) ? $config['allow'] : array (); |
|
| 70 | - $myForced = isset($config['force']) ? $config['force'] : array (); |
|
| 67 | + $globalAllowed = (array) Config::inst()->get('MultiDomain', 'allow'); |
|
| 68 | + $globalForced = (array) Config::inst()->get('MultiDomain', 'force'); |
|
| 69 | + $myAllowed = isset($config['allow']) ? $config['allow'] : array(); |
|
| 70 | + $myForced = isset($config['force']) ? $config['force'] : array(); |
|
| 71 | 71 | $this->allowedPaths = array_merge($globalAllowed, $myAllowed); |
| 72 | 72 | $this->forcedPaths = array_merge($globalForced, $myForced); |
| 73 | 73 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @return boolean |
| 96 | 96 | */ |
| 97 | 97 | public function isActive() { |
| 98 | - if($this->isAllowedPath($this->getRequestUri())) { |
|
| 98 | + if ($this->isAllowedPath($this->getRequestUri())) { |
|
| 99 | 99 | return false; |
| 100 | 100 | } |
| 101 | 101 | |
@@ -108,8 +108,7 @@ discard block |
||
| 108 | 108 | $hostname = $this->getHostname(); |
| 109 | 109 | |
| 110 | 110 | return $allow_subdomains ? |
| 111 | - (bool) preg_match('/(\.|^)'.$hostname.'$/', $currentHost) : |
|
| 112 | - ($currentHost == $hostname); |
|
| 111 | + (bool) preg_match('/(\.|^)'.$hostname.'$/', $currentHost) : ($currentHost == $hostname); |
|
| 113 | 112 | } |
| 114 | 113 | |
| 115 | 114 | /** |
@@ -128,11 +127,11 @@ discard block |
||
| 128 | 127 | * @return string |
| 129 | 128 | */ |
| 130 | 129 | public function getNativeURL($url) { |
| 131 | - if($this->isPrimary()) { |
|
| 130 | + if ($this->isPrimary()) { |
|
| 132 | 131 | throw new Exception("Cannot convert a native URL on the primary domain"); |
| 133 | 132 | } |
| 134 | 133 | |
| 135 | - if($this->isAllowedPath($url) || $this->isForcedPath($url)) { |
|
| 134 | + if ($this->isAllowedPath($url) || $this->isForcedPath($url)) { |
|
| 136 | 135 | return $url; |
| 137 | 136 | } |
| 138 | 137 | |
@@ -147,12 +146,12 @@ discard block |
||
| 147 | 146 | * @return string |
| 148 | 147 | */ |
| 149 | 148 | public function getVanityURL($url) { |
| 150 | - if($this->isPrimary() || $this->isAllowedPath($url)) { |
|
| 149 | + if ($this->isPrimary() || $this->isAllowedPath($url)) { |
|
| 151 | 150 | return $url; |
| 152 | 151 | } |
| 153 | 152 | |
| 154 | 153 | $domainUrl = str_replace('/', '\/', $this->getURL()); |
| 155 | - return preg_replace('/^\/?' . $domainUrl . '\//', '', $url); |
|
| 154 | + return preg_replace('/^\/?'.$domainUrl.'\//', '', $url); |
|
| 156 | 155 | } |
| 157 | 156 | |
| 158 | 157 | /** |
@@ -161,9 +160,9 @@ discard block |
||
| 161 | 160 | * @return boolean |
| 162 | 161 | */ |
| 163 | 162 | public function hasURL($url) { |
| 164 | - if($this->isForcedPath($url)) return true; |
|
| 165 | - $domainBaseURL = trim($this->getURL(),'/'); |
|
| 166 | - if(preg_match('/^'.$domainBaseURL.'/', $url)) { |
|
| 163 | + if ($this->isForcedPath($url)) return true; |
|
| 164 | + $domainBaseURL = trim($this->getURL(), '/'); |
|
| 165 | + if (preg_match('/^'.$domainBaseURL.'/', $url)) { |
|
| 167 | 166 | return true; |
| 168 | 167 | } |
| 169 | 168 | |
@@ -249,13 +248,13 @@ discard block |
||
| 249 | 248 | * @return boolean |
| 250 | 249 | */ |
| 251 | 250 | protected static function match_url($url, $patterns) { |
| 252 | - if(!is_array($patterns)) return false; |
|
| 251 | + if (!is_array($patterns)) return false; |
|
| 253 | 252 | |
| 254 | 253 | $url = ltrim($url, '/'); |
| 255 | - if(substr($url, -1) !== '/') $url .= '/'; |
|
| 254 | + if (substr($url, -1) !== '/') $url .= '/'; |
|
| 256 | 255 | |
| 257 | - foreach($patterns as $pattern) { |
|
| 258 | - if(fnmatch($pattern, $url)) return true; |
|
| 256 | + foreach ($patterns as $pattern) { |
|
| 257 | + if (fnmatch($pattern, $url)) return true; |
|
| 259 | 258 | } |
| 260 | 259 | |
| 261 | 260 | return false; |
@@ -27,8 +27,8 @@ discard block |
||
| 27 | 27 | public static function domain_for_url($url) { |
| 28 | 28 | $url = trim($url, '/'); |
| 29 | 29 | |
| 30 | - foreach(self::get_all_domains() as $domain) { |
|
| 31 | - if($domain->hasURL($url)) { |
|
| 30 | + foreach (self::get_all_domains() as $domain) { |
|
| 31 | + if ($domain->hasURL($url)) { |
|
| 32 | 32 | return $domain; |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -43,10 +43,10 @@ discard block |
||
| 43 | 43 | * @return array |
| 44 | 44 | */ |
| 45 | 45 | public static function get_all_domains($includePrimary = false) { |
| 46 | - $domains = array (); |
|
| 46 | + $domains = array(); |
|
| 47 | 47 | |
| 48 | - foreach(self::config()->domains as $key => $config) { |
|
| 49 | - if(!$includePrimary && $key === self::KEY_PRIMARY) continue; |
|
| 48 | + foreach (self::config()->domains as $key => $config) { |
|
| 49 | + if (!$includePrimary && $key === self::KEY_PRIMARY) continue; |
|
| 50 | 50 | $domains[] = MultiDomainDomain::create($key, $config); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @return MultiDomainDomain |
| 68 | 68 | */ |
| 69 | 69 | public static function get_domain($domain) { |
| 70 | - if(isset(self::config()->domains[$domain])) { |
|
| 70 | + if (isset(self::config()->domains[$domain])) { |
|
| 71 | 71 | return MultiDomainDomain::create( |
| 72 | 72 | $domain, |
| 73 | 73 | self::config()->domains[$domain] |