@@ -24,7 +24,7 @@ |
||
| 24 | 24 | |
| 25 | 25 | return array ( |
| 26 | 26 | 'Multidimensional/Subdomains' => |
| 27 | - array('subdomains' => |
|
| 27 | + array('subdomains' => |
|
| 28 | 28 | array('{SUBDOMAIN_1}', '{SUBDOMAIN_2}', ... '{SUBDOMAIN_N}') |
| 29 | 29 | ) |
| 30 | 30 | ); |
| 31 | 31 | \ No newline at end of file |
@@ -40,45 +40,45 @@ |
||
| 40 | 40 | |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - private function _getPrefixAndHost(array $context = []) { |
|
| 44 | - if (empty($context['_host'])) { |
|
| 45 | - $request = Router::getRequest(true) ?: Request::createFromGlobals(); |
|
| 46 | - $host = $request->host(); |
|
| 47 | - } else { |
|
| 48 | - $host = $context['_host']; |
|
| 49 | - } |
|
| 50 | - $parts = explode('.', $host, 2); |
|
| 51 | - if (in_array($parts[0], $this->_getSubdomains())) { |
|
| 52 | - return $parts; |
|
| 53 | - } else { |
|
| 54 | - return [false, $host]; |
|
| 55 | - } |
|
| 56 | - } |
|
| 43 | + private function _getPrefixAndHost(array $context = []) { |
|
| 44 | + if (empty($context['_host'])) { |
|
| 45 | + $request = Router::getRequest(true) ?: Request::createFromGlobals(); |
|
| 46 | + $host = $request->host(); |
|
| 47 | + } else { |
|
| 48 | + $host = $context['_host']; |
|
| 49 | + } |
|
| 50 | + $parts = explode('.', $host, 2); |
|
| 51 | + if (in_array($parts[0], $this->_getSubdomains())) { |
|
| 52 | + return $parts; |
|
| 53 | + } else { |
|
| 54 | + return [false, $host]; |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - private function _checkPrefix($prefix) { |
|
| 59 | - $routePrefix = isset($this->defaults['prefix']) ? $this->defaults['prefix'] : false; |
|
| 60 | - return $prefix === $routePrefix; |
|
| 61 | - } |
|
| 58 | + private function _checkPrefix($prefix) { |
|
| 59 | + $routePrefix = isset($this->defaults['prefix']) ? $this->defaults['prefix'] : false; |
|
| 60 | + return $prefix === $routePrefix; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - public function parse($url, $method = '') { |
|
| 64 | - list($prefix) = $this->_getPrefixAndHost(); |
|
| 65 | - if (!$this->_checkPrefix($prefix)) { |
|
| 66 | - return false; |
|
| 67 | - } |
|
| 68 | - return parent::parse($url, $method); |
|
| 69 | - } |
|
| 63 | + public function parse($url, $method = '') { |
|
| 64 | + list($prefix) = $this->_getPrefixAndHost(); |
|
| 65 | + if (!$this->_checkPrefix($prefix)) { |
|
| 66 | + return false; |
|
| 67 | + } |
|
| 68 | + return parent::parse($url, $method); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - public function match(array $url, array $context = []) { |
|
| 72 | - if (!isset($url['prefix'])) { |
|
| 73 | - $url['prefix'] = false; |
|
| 74 | - } |
|
| 75 | - if (!$this->_checkPrefix($url['prefix'])) { |
|
| 76 | - return false; |
|
| 77 | - } |
|
| 78 | - list($prefix, $host) = $this->_getPrefixAndHost($context); |
|
| 79 | - if ($prefix !== $url['prefix']) { |
|
| 80 | - $url['_host'] = $url['prefix'] === false ? $host : $url['prefix'] . '.' . $host; |
|
| 81 | - } |
|
| 82 | - return parent::match($url, $context); |
|
| 83 | - } |
|
| 71 | + public function match(array $url, array $context = []) { |
|
| 72 | + if (!isset($url['prefix'])) { |
|
| 73 | + $url['prefix'] = false; |
|
| 74 | + } |
|
| 75 | + if (!$this->_checkPrefix($url['prefix'])) { |
|
| 76 | + return false; |
|
| 77 | + } |
|
| 78 | + list($prefix, $host) = $this->_getPrefixAndHost($context); |
|
| 79 | + if ($prefix !== $url['prefix']) { |
|
| 80 | + $url['_host'] = $url['prefix'] === false ? $host : $url['prefix'] . '.' . $host; |
|
| 81 | + } |
|
| 82 | + return parent::match($url, $context); |
|
| 83 | + } |
|
| 84 | 84 | } |
@@ -20,5 +20,5 @@ |
||
| 20 | 20 | |
| 21 | 21 | class DashedRoute extends CakeDashedRoute |
| 22 | 22 | { |
| 23 | - use SubdomainRouteTrait; |
|
| 23 | + use SubdomainRouteTrait; |
|
| 24 | 24 | } |
| 25 | 25 | \ No newline at end of file |
@@ -20,5 +20,5 @@ |
||
| 20 | 20 | |
| 21 | 21 | class Route extends CakeRoute |
| 22 | 22 | { |
| 23 | - use SubdomainRouteTrait; |
|
| 23 | + use SubdomainRouteTrait; |
|
| 24 | 24 | } |
| 25 | 25 | \ No newline at end of file |
@@ -20,5 +20,5 @@ |
||
| 20 | 20 | |
| 21 | 21 | class InflectedRoute extends CakeInflectedRoute |
| 22 | 22 | { |
| 23 | - use SubdomainRouteTrait; |
|
| 23 | + use SubdomainRouteTrait; |
|
| 24 | 24 | } |
| 25 | 25 | \ No newline at end of file |
@@ -19,19 +19,19 @@ |
||
| 19 | 19 | |
| 20 | 20 | class HeaderHelper extends Helper |
| 21 | 21 | { |
| 22 | - public function output($args = null) |
|
| 23 | - { |
|
| 24 | - $this->_io->out("\n\n"); |
|
| 25 | - $this->_io->styles('header', ['text' => 'green']); |
|
| 22 | + public function output($args = null) |
|
| 23 | + { |
|
| 24 | + $this->_io->out("\n\n"); |
|
| 25 | + $this->_io->styles('header', ['text' => 'green']); |
|
| 26 | 26 | |
| 27 | - $this->_io->out('<header> ______ _____ ___ ____ __ ______ _____ ______</header>'); |
|
| 27 | + $this->_io->out('<header> ______ _____ ___ ____ __ ______ _____ ______</header>'); |
|
| 28 | 28 | $this->_io->out('<header> / __/ / / / _ )/ _ \/ __ \/ |/ / _ | / _/ |/ / __/</header>'); |
| 29 | 29 | $this->_io->out('<header> _\ \/ /_/ / _ / // / /_/ / /|_/ / __ |_/ // /\ \ </header>'); |
| 30 | 30 | $this->_io->out('<header>/___/\____/____/____/\____/_/ /_/_/ |_/___/_/|_/___/ </header>'); |
| 31 | - $this->_io->out("\n"); |
|
| 32 | - $this->_io->out('<header> CakePHP : Subdomains Router </header>'); |
|
| 33 | - $this->_io->out('<header> by https://multidimension.al </header>'); |
|
| 34 | - $this->_io->out("\n\n"); |
|
| 35 | - } |
|
| 31 | + $this->_io->out("\n"); |
|
| 32 | + $this->_io->out('<header> CakePHP : Subdomains Router </header>'); |
|
| 33 | + $this->_io->out('<header> by https://multidimension.al </header>'); |
|
| 34 | + $this->_io->out("\n\n"); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | } |
@@ -25,12 +25,12 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | $subdomains = array(); |
| 27 | 27 | |
| 28 | - $this->clear(); |
|
| 28 | + $this->clear(); |
|
| 29 | 29 | |
| 30 | 30 | $this->_io->styles('error', ['text' => 'red']); |
| 31 | - $this->helper('Multidimensional/Subdomains.Header')->output(); |
|
| 31 | + $this->helper('Multidimensional/Subdomains.Header')->output(); |
|
| 32 | 32 | |
| 33 | - $first_run = Configure::check('Multidimensional/Subdomains.subdomains') ? false : true; |
|
| 33 | + $first_run = Configure::check('Multidimensional/Subdomains.subdomains') ? false : true; |
|
| 34 | 34 | |
| 35 | 35 | if ($first_run == false) { |
| 36 | 36 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if ((($first_run) ? (strtolower($this->in('Install Subdomains Plugin?', ['y','n'])) == 'y') : (strtolower($this->in('Update Configuration?', ['y','n'])) == 'y'))) { |
|
| 45 | + if ((($first_run) ? (strtolower($this->in('Install Subdomains Plugin?', ['y','n'])) == 'y') : (strtolower($this->in('Update Configuration?', ['y','n'])) == 'y'))) { |
|
| 46 | 46 | |
| 47 | 47 | do { |
| 48 | 48 | |
@@ -81,7 +81,7 @@ |
||
| 81 | 81 | $subdomains[] = $subdomain; |
| 82 | 82 | $valid = true; |
| 83 | 83 | $this->out(); |
| 84 | - }else{ |
|
| 84 | + } else{ |
|
| 85 | 85 | $valid = false; |
| 86 | 86 | $this->out(); |
| 87 | 87 | $this->_io->out('<error>Invalid Subdomain.</error>'); |