@@ -4,22 +4,21 @@ discard block |
||
4 | 4 | 'Request', |
5 | 5 | 'URLDecode')); |
6 | 6 | |
7 | -abstract class Router |
|
8 | -{ |
|
7 | +abstract class Router |
|
8 | +{ |
|
9 | 9 | |
10 | 10 | public function __construct() {} |
11 | 11 | |
12 | - public static function instance() |
|
13 | - { |
|
12 | + public static function instance() { |
|
14 | 13 | $router_name = self::get_router_name(); |
15 | 14 | $router = Loader::loadNew('router', $router_name); |
16 | 15 | $router->route(); |
17 | 16 | } |
18 | 17 | |
19 | - private static function get_router_name() |
|
20 | - { |
|
21 | - if(Request::isAJAX()) |
|
22 | - return 'AJAXRouter'; |
|
18 | + private static function get_router_name() { |
|
19 | + if(Request::isAJAX()) { |
|
20 | + return 'AJAXRouter'; |
|
21 | + } |
|
23 | 22 | |
24 | 23 | switch(URLDecode::getSite()) |
25 | 24 | { |
@@ -49,8 +48,7 @@ discard block |
||
49 | 48 | Loader::loadNew('controller', '/Error404Controller')->activate(); |
50 | 49 | } |
51 | 50 | |
52 | - protected function route() |
|
53 | - { |
|
51 | + protected function route() { |
|
54 | 52 | $uri = URLDecode::getURI(); |
55 | 53 | |
56 | 54 | $this->check_for_redirect($uri); |
@@ -63,8 +61,7 @@ discard block |
||
63 | 61 | abstract protected function get_redirect_array(); |
64 | 62 | abstract protected function get_direct_array(); |
65 | 63 | |
66 | - final protected function check_for_redirect($redirect_uri) |
|
67 | - { |
|
64 | + final protected function check_for_redirect($redirect_uri) { |
|
68 | 65 | foreach($this->get_redirect_array() as $check) |
69 | 66 | { |
70 | 67 | $redirect_uri = preg_replace($check->pattern, $check->replace, $redirect_uri); |
@@ -72,16 +69,18 @@ discard block |
||
72 | 69 | |
73 | 70 | $redirect_uri = $this->check_for_special_redirect($redirect_uri); |
74 | 71 | |
75 | - if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') |
|
76 | - $redirect_uri .= '/'; |
|
72 | + if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') { |
|
73 | + $redirect_uri .= '/'; |
|
74 | + } |
|
77 | 75 | |
78 | 76 | if (URLDecode::getHost() == 'waterfalls.jacobemerick.com') { |
79 | 77 | $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
80 | 78 | $redirect_uri = $protocol . '://' . (!Loader::isLive() ? 'dev' : 'www') . '.waterfallsofthekeweenaw.com' . $redirect_uri; |
81 | 79 | } |
82 | 80 | |
83 | - if($redirect_uri == URLDecode::getURI()) |
|
84 | - return; |
|
81 | + if($redirect_uri == URLDecode::getURI()) { |
|
82 | + return; |
|
83 | + } |
|
85 | 84 | |
86 | 85 | $controller_check = $redirect_uri; |
87 | 86 | if(substr($redirect_uri, 0, 4) == 'http') { |
@@ -107,35 +106,34 @@ discard block |
||
107 | 106 | ->activate(); |
108 | 107 | } |
109 | 108 | |
110 | - protected function check_for_special_redirect($uri) |
|
111 | - { |
|
109 | + protected function check_for_special_redirect($uri) { |
|
112 | 110 | return $uri; |
113 | 111 | } |
114 | 112 | |
115 | - final private function get_controller($uri) |
|
116 | - { |
|
113 | + final private function get_controller($uri) { |
|
117 | 114 | foreach($this->get_direct_array() as $check) |
118 | 115 | { |
119 | - if($uri == $check->match) |
|
120 | - return "{$this->get_primary_folder()}/{$check->controller}"; |
|
116 | + if($uri == $check->match) { |
|
117 | + return "{$this->get_primary_folder()}/{$check->controller}"; |
|
118 | + } |
|
121 | 119 | |
122 | - if(preg_match("@^{$check->match}$@", $uri)) |
|
123 | - return "{$this->get_primary_folder()}/{$check->controller}"; |
|
120 | + if(preg_match("@^{$check->match}$@", $uri)) { |
|
121 | + return "{$this->get_primary_folder()}/{$check->controller}"; |
|
122 | + } |
|
124 | 123 | } |
125 | 124 | |
126 | 125 | return '/Error404Controller'; |
127 | 126 | } |
128 | 127 | |
129 | - final private function get_primary_folder() |
|
130 | - { |
|
131 | - if(Request::isAjax()) |
|
132 | - return 'ajax'; |
|
128 | + final private function get_primary_folder() { |
|
129 | + if(Request::isAjax()) { |
|
130 | + return 'ajax'; |
|
131 | + } |
|
133 | 132 | |
134 | 133 | return URLDecode::getSite(); |
135 | 134 | } |
136 | 135 | |
137 | - private function requires_trailing_slash() |
|
138 | - { |
|
136 | + private function requires_trailing_slash() { |
|
139 | 137 | return ( |
140 | 138 | URLDecode::getExtension() != 'json' && |
141 | 139 | strstr(URLDecode::getURI(), '#') === false); |
@@ -2,11 +2,10 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('router', 'Router'); |
4 | 4 | |
5 | -class LifestreamRouter extends Router |
|
6 | -{ |
|
5 | +class LifestreamRouter extends Router |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function get_redirect_array() |
|
9 | - { |
|
8 | + protected function get_redirect_array() { |
|
10 | 9 | return array( |
11 | 10 | (object) array( |
12 | 11 | 'pattern' => '@/index.(html|htm|php)$@', |
@@ -31,8 +30,7 @@ discard block |
||
31 | 30 | 'replace' => '/')); |
32 | 31 | } |
33 | 32 | |
34 | - protected function get_direct_array() |
|
35 | - { |
|
33 | + protected function get_direct_array() { |
|
36 | 34 | return array( |
37 | 35 | (object) array( |
38 | 36 | 'match' => '/', |
@@ -2,19 +2,17 @@ |
||
2 | 2 | |
3 | 3 | Loader::load('router', 'Router'); |
4 | 4 | |
5 | -class AJAXRouter extends Router |
|
6 | -{ |
|
5 | +class AJAXRouter extends Router |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function get_redirect_array() |
|
9 | - { |
|
8 | + protected function get_redirect_array() { |
|
10 | 9 | return array( |
11 | 10 | (object) array( |
12 | 11 | 'pattern' => '@^/$@', |
13 | 12 | 'replace' => 'https://home.jacobemerick.com/')); |
14 | 13 | } |
15 | 14 | |
16 | - protected function get_direct_array() |
|
17 | - { |
|
15 | + protected function get_direct_array() { |
|
18 | 16 | return array( |
19 | 17 | (object) array( |
20 | 18 | 'match' => '/get/portfolioImage.json', |
@@ -2,11 +2,10 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('router', 'Router'); |
4 | 4 | |
5 | -class PortfolioRouter extends Router |
|
6 | -{ |
|
5 | +class PortfolioRouter extends Router |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function get_redirect_array() |
|
9 | - { |
|
8 | + protected function get_redirect_array() { |
|
10 | 9 | $paths = [ |
11 | 10 | [ |
12 | 11 | 'pattern' => '@/index.(html|htm|php)$@', |
@@ -31,8 +30,7 @@ discard block |
||
31 | 30 | }, $paths); |
32 | 31 | } |
33 | 32 | |
34 | - protected function get_direct_array() |
|
35 | - { |
|
33 | + protected function get_direct_array() { |
|
36 | 34 | $paths = [ |
37 | 35 | [ |
38 | 36 | 'match' => '/', |
@@ -2,11 +2,10 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('router', 'Router'); |
4 | 4 | |
5 | -class BlogRouter extends Router |
|
6 | -{ |
|
5 | +class BlogRouter extends Router |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function get_redirect_array() |
|
9 | - { |
|
8 | + protected function get_redirect_array() { |
|
10 | 9 | return array( |
11 | 10 | (object) array( |
12 | 11 | 'pattern' => '@^/page_([0-9]+)/$@', |
@@ -43,8 +42,7 @@ discard block |
||
43 | 42 | 'replace' => '/$1')); |
44 | 43 | } |
45 | 44 | |
46 | - protected function check_for_special_redirect($uri) |
|
47 | - { |
|
45 | + protected function check_for_special_redirect($uri) { |
|
48 | 46 | if(preg_match('@^/post_([0-9]{4}-[0-9]{2}-[0-9]{2})_([a-z0-9-]+)(/?)$@', $uri, $matches)) |
49 | 47 | { |
50 | 48 | global $container; |
@@ -59,8 +57,7 @@ discard block |
||
59 | 57 | |
60 | 58 | Loader::load('utility', 'Content'); |
61 | 59 | $uri = Content::instance('URLSafe', "/{$post['category']}/{$post['path']}/")->activate(); |
62 | - } |
|
63 | - else |
|
60 | + } else |
|
64 | 61 | { |
65 | 62 | $post_uri = URLDecode::getPiece(1); |
66 | 63 | if($post_uri !== null) |
@@ -87,8 +84,7 @@ discard block |
||
87 | 84 | return $uri; |
88 | 85 | } |
89 | 86 | |
90 | - protected function get_direct_array() |
|
91 | - { |
|
87 | + protected function get_direct_array() { |
|
92 | 88 | return array( |
93 | 89 | (object) array( |
94 | 90 | 'match' => '/', |