@@ -8,24 +8,24 @@ discard block |
||
8 | 8 | class WaterfallRouter extends Router |
9 | 9 | { |
10 | 10 | |
11 | - protected function get_redirect_array() |
|
12 | - { |
|
13 | - return array( |
|
14 | - (object) array( |
|
15 | - 'pattern' => '@/index.(html|htm|php)$@', |
|
16 | - 'replace' => '/'), |
|
17 | - (object) array( |
|
18 | - 'pattern' => '@^/home(/?)$@', |
|
19 | - 'replace' => '/'), |
|
20 | - (object) array( |
|
21 | - 'pattern' => '@^/falls/by-rating(/?)$@', |
|
22 | - 'replace' => '/falls/'), |
|
23 | - (object) array( |
|
24 | - 'pattern' => '@^/falls/by-rating/([0-9]+)(/?)$@', |
|
25 | - 'replace' => '/falls/'), |
|
26 | - (object) array( |
|
27 | - 'pattern' => '@^/falls/results(/?)$@', |
|
28 | - 'replace' => '/falls/'), |
|
11 | + protected function get_redirect_array() |
|
12 | + { |
|
13 | + return array( |
|
14 | + (object) array( |
|
15 | + 'pattern' => '@/index.(html|htm|php)$@', |
|
16 | + 'replace' => '/'), |
|
17 | + (object) array( |
|
18 | + 'pattern' => '@^/home(/?)$@', |
|
19 | + 'replace' => '/'), |
|
20 | + (object) array( |
|
21 | + 'pattern' => '@^/falls/by-rating(/?)$@', |
|
22 | + 'replace' => '/falls/'), |
|
23 | + (object) array( |
|
24 | + 'pattern' => '@^/falls/by-rating/([0-9]+)(/?)$@', |
|
25 | + 'replace' => '/falls/'), |
|
26 | + (object) array( |
|
27 | + 'pattern' => '@^/falls/results(/?)$@', |
|
28 | + 'replace' => '/falls/'), |
|
29 | 29 | (object) array( |
30 | 30 | 'pattern' => '@^/log(/?)$@', |
31 | 31 | 'replace' => '/journal/'), |
@@ -35,44 +35,44 @@ discard block |
||
35 | 35 | (object) array( |
36 | 36 | 'pattern' => '@^/map/([^/]+)(/?)$@', |
37 | 37 | 'replace' => '/map/'), |
38 | - (object) array( |
|
39 | - 'pattern' => '@^/about/([a-z]*)(/?)$@', |
|
40 | - 'replace' => '/about/'), |
|
41 | - (object) array( |
|
42 | - 'pattern' => '@^/birch-creek/birch-creek-falls/?$@', |
|
43 | - 'replace' => '/birch-creek/gold-mine-falls/'), |
|
44 | - (object) array( |
|
45 | - 'pattern' => '@^/big-iron-river/bonanza-falls/?$@', |
|
46 | - 'replace' => '/big-iron-river/greenwood-falls/'), |
|
47 | - (object) array( |
|
48 | - 'pattern' => '@^/east-branch-huron-river/east-branch-huron-river-falls/?$@', |
|
49 | - 'replace' => '/east-branch-huron-river/east-branch-falls/'), |
|
50 | - (object) array( |
|
51 | - 'pattern' => '@^/montreal-river/lower-montreal-falls/?$@', |
|
52 | - 'replace' => '/montreal-river/montreal-falls/'), |
|
53 | - (object) array( |
|
54 | - 'pattern' => '@^/manganese-creek/manganese-gorge-falls/?$@', |
|
55 | - 'replace' => '/manganese-creek/manganese-falls/'), |
|
56 | - (object) array( |
|
57 | - 'pattern' => '@^/dead-river/tourist-park-dam-falls/?$@', |
|
58 | - 'replace' => '/dead-river/tourist-park-falls/'), |
|
59 | - (object) array( |
|
60 | - 'pattern' => '@^/sturgeon-river/upper-sturgeon-falls/?$@', |
|
61 | - 'replace' => '/sturgeon-river/little-spruce-falls/'), |
|
62 | - (object) array( |
|
63 | - 'pattern' => '@^/tahquamenon-river/upper-tahquamenon-falls/?$@', |
|
64 | - 'replace' => '/tahquamenon-river/tahquamenon-falls/'), |
|
65 | - (object) array( |
|
66 | - 'pattern' => '@^/west-branch-huron-river/west-branch-huron-river-falls/?@', |
|
67 | - 'replace' => '/west-branch-huron-river/west-branch-falls/'), |
|
68 | - (object) array( |
|
69 | - 'pattern' => '@^/west-branch-yellow-dog-river/west-branch-yellow-dog-falls/?@', |
|
70 | - 'replace' => '/west-branch-yellow-dog-river/west-branch-falls/'), |
|
71 | - ); |
|
72 | - } |
|
38 | + (object) array( |
|
39 | + 'pattern' => '@^/about/([a-z]*)(/?)$@', |
|
40 | + 'replace' => '/about/'), |
|
41 | + (object) array( |
|
42 | + 'pattern' => '@^/birch-creek/birch-creek-falls/?$@', |
|
43 | + 'replace' => '/birch-creek/gold-mine-falls/'), |
|
44 | + (object) array( |
|
45 | + 'pattern' => '@^/big-iron-river/bonanza-falls/?$@', |
|
46 | + 'replace' => '/big-iron-river/greenwood-falls/'), |
|
47 | + (object) array( |
|
48 | + 'pattern' => '@^/east-branch-huron-river/east-branch-huron-river-falls/?$@', |
|
49 | + 'replace' => '/east-branch-huron-river/east-branch-falls/'), |
|
50 | + (object) array( |
|
51 | + 'pattern' => '@^/montreal-river/lower-montreal-falls/?$@', |
|
52 | + 'replace' => '/montreal-river/montreal-falls/'), |
|
53 | + (object) array( |
|
54 | + 'pattern' => '@^/manganese-creek/manganese-gorge-falls/?$@', |
|
55 | + 'replace' => '/manganese-creek/manganese-falls/'), |
|
56 | + (object) array( |
|
57 | + 'pattern' => '@^/dead-river/tourist-park-dam-falls/?$@', |
|
58 | + 'replace' => '/dead-river/tourist-park-falls/'), |
|
59 | + (object) array( |
|
60 | + 'pattern' => '@^/sturgeon-river/upper-sturgeon-falls/?$@', |
|
61 | + 'replace' => '/sturgeon-river/little-spruce-falls/'), |
|
62 | + (object) array( |
|
63 | + 'pattern' => '@^/tahquamenon-river/upper-tahquamenon-falls/?$@', |
|
64 | + 'replace' => '/tahquamenon-river/tahquamenon-falls/'), |
|
65 | + (object) array( |
|
66 | + 'pattern' => '@^/west-branch-huron-river/west-branch-huron-river-falls/?@', |
|
67 | + 'replace' => '/west-branch-huron-river/west-branch-falls/'), |
|
68 | + (object) array( |
|
69 | + 'pattern' => '@^/west-branch-yellow-dog-river/west-branch-yellow-dog-falls/?@', |
|
70 | + 'replace' => '/west-branch-yellow-dog-river/west-branch-falls/'), |
|
71 | + ); |
|
72 | + } |
|
73 | 73 | |
74 | - protected function check_for_special_redirect($uri) |
|
75 | - { |
|
74 | + protected function check_for_special_redirect($uri) |
|
75 | + { |
|
76 | 76 | if (preg_match('@^/falls/([a-z\'-]+)(/?)$@', $uri, $matches)) { |
77 | 77 | $alias = $matches[1]; |
78 | 78 | $alias = str_replace("'", '', $alias); |
@@ -125,81 +125,81 @@ discard block |
||
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | - return $uri; |
|
129 | - } |
|
128 | + return $uri; |
|
129 | + } |
|
130 | 130 | |
131 | - protected function get_direct_array() |
|
132 | - { |
|
133 | - return array( |
|
134 | - (object) array( |
|
135 | - 'match' => '/', |
|
136 | - 'controller' => 'HomeController'), |
|
137 | - (object) array( |
|
138 | - 'match' => '/falls/', |
|
139 | - 'controller' => 'WaterfallListController'), |
|
140 | - (object) array( |
|
141 | - 'match' => '/falls/([0-9]+)/', |
|
142 | - 'controller' => 'WaterfallListController'), |
|
143 | - (object) array( |
|
144 | - 'match' => '/([a-z]+)-county/', |
|
145 | - 'controller' => 'CountyListController'), |
|
146 | - (object) array( |
|
147 | - 'match' => '/([a-z]+)-county/([0-9]+)/', |
|
148 | - 'controller' => 'CountyListController'), |
|
149 | - (object) array( |
|
150 | - 'match' => '/([a-z0-9-]+)-(creek|river)/', |
|
151 | - 'controller' => 'WatercourseListController'), |
|
152 | - (object) array( |
|
153 | - 'match' => '/([a-z0-9-]+)-(creek|river)/([0-9]+)/', |
|
154 | - 'controller' => 'WatercourseListController'), |
|
155 | - (object) array( |
|
156 | - 'match' => '/category/([a-z]+)/', |
|
157 | - 'controller' => 'CategoryListController'), |
|
158 | - (object) array( |
|
159 | - 'match' => '/category/([a-z]+)/([0-9]+)/', |
|
160 | - 'controller' => 'CategoryListController'), |
|
161 | - (object) array( |
|
162 | - 'match' => '/([a-z0-9-]+)-(creek|river)/([a-z-]+)/', |
|
163 | - 'controller' => 'WaterfallController'), |
|
164 | - (object) array( |
|
165 | - 'match' => '/map/', |
|
166 | - 'controller' => 'MapController'), |
|
131 | + protected function get_direct_array() |
|
132 | + { |
|
133 | + return array( |
|
134 | + (object) array( |
|
135 | + 'match' => '/', |
|
136 | + 'controller' => 'HomeController'), |
|
137 | + (object) array( |
|
138 | + 'match' => '/falls/', |
|
139 | + 'controller' => 'WaterfallListController'), |
|
140 | + (object) array( |
|
141 | + 'match' => '/falls/([0-9]+)/', |
|
142 | + 'controller' => 'WaterfallListController'), |
|
143 | + (object) array( |
|
144 | + 'match' => '/([a-z]+)-county/', |
|
145 | + 'controller' => 'CountyListController'), |
|
146 | + (object) array( |
|
147 | + 'match' => '/([a-z]+)-county/([0-9]+)/', |
|
148 | + 'controller' => 'CountyListController'), |
|
149 | + (object) array( |
|
150 | + 'match' => '/([a-z0-9-]+)-(creek|river)/', |
|
151 | + 'controller' => 'WatercourseListController'), |
|
152 | + (object) array( |
|
153 | + 'match' => '/([a-z0-9-]+)-(creek|river)/([0-9]+)/', |
|
154 | + 'controller' => 'WatercourseListController'), |
|
155 | + (object) array( |
|
156 | + 'match' => '/category/([a-z]+)/', |
|
157 | + 'controller' => 'CategoryListController'), |
|
158 | + (object) array( |
|
159 | + 'match' => '/category/([a-z]+)/([0-9]+)/', |
|
160 | + 'controller' => 'CategoryListController'), |
|
161 | + (object) array( |
|
162 | + 'match' => '/([a-z0-9-]+)-(creek|river)/([a-z-]+)/', |
|
163 | + 'controller' => 'WaterfallController'), |
|
164 | + (object) array( |
|
165 | + 'match' => '/map/', |
|
166 | + 'controller' => 'MapController'), |
|
167 | 167 | (object) array( |
168 | 168 | 'match' => '/map/#[a-z-/]+', |
169 | 169 | 'controller' => 'MapController'), |
170 | - (object) array( |
|
171 | - 'match' => '/journal/', |
|
172 | - 'controller' => 'LogListController'), |
|
173 | - (object) array( |
|
174 | - 'match' => '/journal/([0-9]+)/', |
|
175 | - 'controller' => 'LogListController'), |
|
176 | - (object) array( |
|
177 | - 'match' => '/journal/[a-z-]+/', |
|
178 | - 'controller' => 'LogController'), |
|
179 | - (object) array( |
|
180 | - 'match' => '/companion/([a-z-]+)/', |
|
181 | - 'controller' => 'CompanionListController'), |
|
182 | - (object) array( |
|
183 | - 'match' => '/companion/([a-z-]+)/([0-9]+)/', |
|
184 | - 'controller' => 'CompanionListController'), |
|
185 | - (object) array( |
|
186 | - 'match' => '/period/([a-z-]+)/', |
|
187 | - 'controller' => 'PeriodListController'), |
|
188 | - (object) array( |
|
189 | - 'match' => '/period/([a-z-]+)/([0-9]+)/', |
|
190 | - 'controller' => 'PeriodListController'), |
|
191 | - (object) array( |
|
192 | - 'match' => '/journal/tag/([a-z-]+)/', |
|
193 | - 'controller' => 'LogTagListController'), |
|
194 | - (object) array( |
|
195 | - 'match' => '/journal/tag/([a-z-]+)/([0-9]+)/', |
|
196 | - 'controller' => 'LogTagListController'), |
|
197 | - (object) array( |
|
198 | - 'match' => '/about/', |
|
199 | - 'controller' => 'AboutController'), |
|
200 | - (object) array( |
|
201 | - 'match' => '/contact/', |
|
202 | - 'controller' => 'ContactController')); |
|
203 | - } |
|
170 | + (object) array( |
|
171 | + 'match' => '/journal/', |
|
172 | + 'controller' => 'LogListController'), |
|
173 | + (object) array( |
|
174 | + 'match' => '/journal/([0-9]+)/', |
|
175 | + 'controller' => 'LogListController'), |
|
176 | + (object) array( |
|
177 | + 'match' => '/journal/[a-z-]+/', |
|
178 | + 'controller' => 'LogController'), |
|
179 | + (object) array( |
|
180 | + 'match' => '/companion/([a-z-]+)/', |
|
181 | + 'controller' => 'CompanionListController'), |
|
182 | + (object) array( |
|
183 | + 'match' => '/companion/([a-z-]+)/([0-9]+)/', |
|
184 | + 'controller' => 'CompanionListController'), |
|
185 | + (object) array( |
|
186 | + 'match' => '/period/([a-z-]+)/', |
|
187 | + 'controller' => 'PeriodListController'), |
|
188 | + (object) array( |
|
189 | + 'match' => '/period/([a-z-]+)/([0-9]+)/', |
|
190 | + 'controller' => 'PeriodListController'), |
|
191 | + (object) array( |
|
192 | + 'match' => '/journal/tag/([a-z-]+)/', |
|
193 | + 'controller' => 'LogTagListController'), |
|
194 | + (object) array( |
|
195 | + 'match' => '/journal/tag/([a-z-]+)/([0-9]+)/', |
|
196 | + 'controller' => 'LogTagListController'), |
|
197 | + (object) array( |
|
198 | + 'match' => '/about/', |
|
199 | + 'controller' => 'AboutController'), |
|
200 | + (object) array( |
|
201 | + 'match' => '/contact/', |
|
202 | + 'controller' => 'ContactController')); |
|
203 | + } |
|
204 | 204 | |
205 | 205 | } |
@@ -5,26 +5,26 @@ |
||
5 | 5 | final class HomeRouter extends Router |
6 | 6 | { |
7 | 7 | |
8 | - protected function get_redirect_array() |
|
9 | - { |
|
10 | - return array( |
|
11 | - (object) array( |
|
12 | - 'pattern' => '@/index.(html|htm|php)$@', |
|
13 | - 'replace' => '')); |
|
14 | - } |
|
8 | + protected function get_redirect_array() |
|
9 | + { |
|
10 | + return array( |
|
11 | + (object) array( |
|
12 | + 'pattern' => '@/index.(html|htm|php)$@', |
|
13 | + 'replace' => '')); |
|
14 | + } |
|
15 | 15 | |
16 | - protected function get_direct_array() |
|
17 | - { |
|
18 | - return array( |
|
19 | - (object) array( |
|
20 | - 'match' => '/', |
|
21 | - 'controller' => 'HomeController'), |
|
22 | - (object) array( |
|
23 | - 'match' => '/about/', |
|
24 | - 'controller' => 'AboutController'), |
|
25 | - (object) array( |
|
26 | - 'match' => '/contact/', |
|
27 | - 'controller' => 'ContactController')); |
|
28 | - } |
|
16 | + protected function get_direct_array() |
|
17 | + { |
|
18 | + return array( |
|
19 | + (object) array( |
|
20 | + 'match' => '/', |
|
21 | + 'controller' => 'HomeController'), |
|
22 | + (object) array( |
|
23 | + 'match' => '/about/', |
|
24 | + 'controller' => 'AboutController'), |
|
25 | + (object) array( |
|
26 | + 'match' => '/contact/', |
|
27 | + 'controller' => 'ContactController')); |
|
28 | + } |
|
29 | 29 | |
30 | 30 | } |
31 | 31 | \ No newline at end of file |
@@ -5,29 +5,29 @@ |
||
5 | 5 | class SiteRouter extends Router |
6 | 6 | { |
7 | 7 | |
8 | - protected function get_redirect_array() |
|
9 | - { |
|
10 | - return array( |
|
11 | - (object) array( |
|
12 | - 'pattern' => '@/index.(html|htm|php)$@', |
|
13 | - 'replace' => '/')); |
|
14 | - } |
|
8 | + protected function get_redirect_array() |
|
9 | + { |
|
10 | + return array( |
|
11 | + (object) array( |
|
12 | + 'pattern' => '@/index.(html|htm|php)$@', |
|
13 | + 'replace' => '/')); |
|
14 | + } |
|
15 | 15 | |
16 | - protected function get_direct_array() |
|
17 | - { |
|
18 | - return array( |
|
19 | - (object) array( |
|
20 | - 'match' => '/', |
|
21 | - 'controller' => 'HomeController'), |
|
22 | - (object) array( |
|
23 | - 'match' => '/terms/', |
|
24 | - 'controller' => 'TermsController'), |
|
25 | - (object) array( |
|
26 | - 'match' => '/change-log/', |
|
27 | - 'controller' => 'ChangelogController'), |
|
28 | - (object) array( |
|
29 | - 'match' => '/contact/', |
|
30 | - 'controller' => 'ContactController')); |
|
31 | - } |
|
16 | + protected function get_direct_array() |
|
17 | + { |
|
18 | + return array( |
|
19 | + (object) array( |
|
20 | + 'match' => '/', |
|
21 | + 'controller' => 'HomeController'), |
|
22 | + (object) array( |
|
23 | + 'match' => '/terms/', |
|
24 | + 'controller' => 'TermsController'), |
|
25 | + (object) array( |
|
26 | + 'match' => '/change-log/', |
|
27 | + 'controller' => 'ChangelogController'), |
|
28 | + (object) array( |
|
29 | + 'match' => '/contact/', |
|
30 | + 'controller' => 'ContactController')); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | } |
34 | 34 | \ No newline at end of file |
@@ -1,144 +1,144 @@ |
||
1 | 1 | <? |
2 | 2 | |
3 | 3 | Loader::load('utility', array( |
4 | - 'Request', |
|
5 | - 'URLDecode')); |
|
4 | + 'Request', |
|
5 | + 'URLDecode')); |
|
6 | 6 | |
7 | 7 | abstract class Router |
8 | 8 | { |
9 | 9 | |
10 | - public function __construct() {} |
|
10 | + public function __construct() {} |
|
11 | 11 | |
12 | - public static function instance() |
|
13 | - { |
|
14 | - $router_name = self::get_router_name(); |
|
15 | - $router = Loader::loadNew('router', $router_name); |
|
16 | - $router->route(); |
|
17 | - } |
|
12 | + public static function instance() |
|
13 | + { |
|
14 | + $router_name = self::get_router_name(); |
|
15 | + $router = Loader::loadNew('router', $router_name); |
|
16 | + $router->route(); |
|
17 | + } |
|
18 | 18 | |
19 | - private static function get_router_name() |
|
20 | - { |
|
21 | - if(Request::isAJAX()) |
|
22 | - return 'AJAXRouter'; |
|
19 | + private static function get_router_name() |
|
20 | + { |
|
21 | + if(Request::isAJAX()) |
|
22 | + return 'AJAXRouter'; |
|
23 | 23 | |
24 | - switch(URLDecode::getSite()) |
|
25 | - { |
|
26 | - case 'ajax' : |
|
27 | - return 'AjaxRouter'; |
|
28 | - break; |
|
29 | - case 'blog' : |
|
30 | - return 'BlogRouter'; |
|
31 | - break; |
|
32 | - case 'home' : |
|
33 | - return 'HomeRouter'; |
|
34 | - break; |
|
35 | - case 'lifestream' : |
|
36 | - return 'LifestreamRouter'; |
|
37 | - break; |
|
38 | - case 'portfolio' : |
|
39 | - return 'PortfolioRouter'; |
|
40 | - break; |
|
41 | - case 'site' : |
|
42 | - return 'SiteRouter'; |
|
43 | - break; |
|
44 | - case 'waterfalls' : |
|
45 | - return 'WaterfallRouter'; |
|
46 | - break; |
|
47 | - } |
|
24 | + switch(URLDecode::getSite()) |
|
25 | + { |
|
26 | + case 'ajax' : |
|
27 | + return 'AjaxRouter'; |
|
28 | + break; |
|
29 | + case 'blog' : |
|
30 | + return 'BlogRouter'; |
|
31 | + break; |
|
32 | + case 'home' : |
|
33 | + return 'HomeRouter'; |
|
34 | + break; |
|
35 | + case 'lifestream' : |
|
36 | + return 'LifestreamRouter'; |
|
37 | + break; |
|
38 | + case 'portfolio' : |
|
39 | + return 'PortfolioRouter'; |
|
40 | + break; |
|
41 | + case 'site' : |
|
42 | + return 'SiteRouter'; |
|
43 | + break; |
|
44 | + case 'waterfalls' : |
|
45 | + return 'WaterfallRouter'; |
|
46 | + break; |
|
47 | + } |
|
48 | 48 | |
49 | - Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
50 | - } |
|
49 | + Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
50 | + } |
|
51 | 51 | |
52 | - protected function route() |
|
53 | - { |
|
54 | - $uri = URLDecode::getURI(); |
|
52 | + protected function route() |
|
53 | + { |
|
54 | + $uri = URLDecode::getURI(); |
|
55 | 55 | |
56 | - $this->check_for_redirect($uri); |
|
56 | + $this->check_for_redirect($uri); |
|
57 | 57 | |
58 | - $controller = $this->get_controller($uri); |
|
59 | - Loader::loadNew('controller', $controller) |
|
60 | - ->activate(); |
|
61 | - } |
|
58 | + $controller = $this->get_controller($uri); |
|
59 | + Loader::loadNew('controller', $controller) |
|
60 | + ->activate(); |
|
61 | + } |
|
62 | 62 | |
63 | - abstract protected function get_redirect_array(); |
|
64 | - abstract protected function get_direct_array(); |
|
63 | + abstract protected function get_redirect_array(); |
|
64 | + abstract protected function get_direct_array(); |
|
65 | 65 | |
66 | - final protected function check_for_redirect($redirect_uri) |
|
67 | - { |
|
68 | - foreach($this->get_redirect_array() as $check) |
|
69 | - { |
|
70 | - $redirect_uri = preg_replace($check->pattern, $check->replace, $redirect_uri); |
|
71 | - } |
|
66 | + final protected function check_for_redirect($redirect_uri) |
|
67 | + { |
|
68 | + foreach($this->get_redirect_array() as $check) |
|
69 | + { |
|
70 | + $redirect_uri = preg_replace($check->pattern, $check->replace, $redirect_uri); |
|
71 | + } |
|
72 | 72 | |
73 | - $redirect_uri = $this->check_for_special_redirect($redirect_uri); |
|
73 | + $redirect_uri = $this->check_for_special_redirect($redirect_uri); |
|
74 | 74 | |
75 | - if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') |
|
76 | - $redirect_uri .= '/'; |
|
75 | + if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') |
|
76 | + $redirect_uri .= '/'; |
|
77 | 77 | |
78 | 78 | if (URLDecode::getHost() == 'waterfalls.jacobemerick.com') { |
79 | 79 | $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
80 | 80 | $redirect_uri = $protocol . '://' . (!Loader::isLive() ? 'dev' : 'www') . '.waterfallsofthekeweenaw.com' . $redirect_uri; |
81 | 81 | } |
82 | 82 | |
83 | - if($redirect_uri == URLDecode::getURI()) |
|
84 | - return; |
|
83 | + if($redirect_uri == URLDecode::getURI()) |
|
84 | + return; |
|
85 | 85 | |
86 | - $controller_check = $redirect_uri; |
|
87 | - if(substr($redirect_uri, 0, 4) == 'http') { |
|
88 | - $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
|
89 | - $controller_check = preg_replace('@^' . $protocol . '://([a-z\.]+)@', '', $redirect_uri); |
|
86 | + $controller_check = $redirect_uri; |
|
87 | + if(substr($redirect_uri, 0, 4) == 'http') { |
|
88 | + $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http'; |
|
89 | + $controller_check = preg_replace('@^' . $protocol . '://([a-z\.]+)@', '', $redirect_uri); |
|
90 | 90 | } |
91 | 91 | |
92 | - $controller = $this->get_controller($controller_check); |
|
93 | - if($controller == '/Error404Controller') |
|
94 | - { |
|
95 | - Loader::loadNew('controller', '/Error404Controller') |
|
96 | - ->activate(); |
|
97 | - exit; |
|
98 | - } |
|
92 | + $controller = $this->get_controller($controller_check); |
|
93 | + if($controller == '/Error404Controller') |
|
94 | + { |
|
95 | + Loader::loadNew('controller', '/Error404Controller') |
|
96 | + ->activate(); |
|
97 | + exit; |
|
98 | + } |
|
99 | 99 | |
100 | - if(substr($redirect_uri, 0, 4) != 'http') |
|
101 | - { |
|
102 | - $redirect_uri = substr($redirect_uri, 1); |
|
103 | - $redirect_uri = URLDecode::getBase() . $redirect_uri; |
|
104 | - } |
|
100 | + if(substr($redirect_uri, 0, 4) != 'http') |
|
101 | + { |
|
102 | + $redirect_uri = substr($redirect_uri, 1); |
|
103 | + $redirect_uri = URLDecode::getBase() . $redirect_uri; |
|
104 | + } |
|
105 | 105 | |
106 | - Loader::loadNew('controller', '/Error301Controller', (array) $redirect_uri) |
|
107 | - ->activate(); |
|
108 | - } |
|
106 | + Loader::loadNew('controller', '/Error301Controller', (array) $redirect_uri) |
|
107 | + ->activate(); |
|
108 | + } |
|
109 | 109 | |
110 | - protected function check_for_special_redirect($uri) |
|
111 | - { |
|
112 | - return $uri; |
|
113 | - } |
|
110 | + protected function check_for_special_redirect($uri) |
|
111 | + { |
|
112 | + return $uri; |
|
113 | + } |
|
114 | 114 | |
115 | - final private function get_controller($uri) |
|
116 | - { |
|
117 | - foreach($this->get_direct_array() as $check) |
|
118 | - { |
|
119 | - if($uri == $check->match) |
|
120 | - return "{$this->get_primary_folder()}/{$check->controller}"; |
|
115 | + final private function get_controller($uri) |
|
116 | + { |
|
117 | + foreach($this->get_direct_array() as $check) |
|
118 | + { |
|
119 | + if($uri == $check->match) |
|
120 | + return "{$this->get_primary_folder()}/{$check->controller}"; |
|
121 | 121 | |
122 | - if(preg_match("@^{$check->match}$@", $uri)) |
|
123 | - return "{$this->get_primary_folder()}/{$check->controller}"; |
|
124 | - } |
|
122 | + if(preg_match("@^{$check->match}$@", $uri)) |
|
123 | + return "{$this->get_primary_folder()}/{$check->controller}"; |
|
124 | + } |
|
125 | 125 | |
126 | - return '/Error404Controller'; |
|
127 | - } |
|
126 | + return '/Error404Controller'; |
|
127 | + } |
|
128 | 128 | |
129 | - final private function get_primary_folder() |
|
130 | - { |
|
131 | - if(Request::isAjax()) |
|
132 | - return 'ajax'; |
|
129 | + final private function get_primary_folder() |
|
130 | + { |
|
131 | + if(Request::isAjax()) |
|
132 | + return 'ajax'; |
|
133 | 133 | |
134 | - return URLDecode::getSite(); |
|
135 | - } |
|
134 | + return URLDecode::getSite(); |
|
135 | + } |
|
136 | 136 | |
137 | - private function requires_trailing_slash() |
|
138 | - { |
|
139 | - return ( |
|
140 | - URLDecode::getExtension() != 'json' && |
|
137 | + private function requires_trailing_slash() |
|
138 | + { |
|
139 | + return ( |
|
140 | + URLDecode::getExtension() != 'json' && |
|
141 | 141 | strstr(URLDecode::getURI(), '#') === false); |
142 | - } |
|
142 | + } |
|
143 | 143 | |
144 | 144 | } |
@@ -5,54 +5,54 @@ |
||
5 | 5 | class LifestreamRouter extends Router |
6 | 6 | { |
7 | 7 | |
8 | - protected function get_redirect_array() |
|
9 | - { |
|
10 | - return array( |
|
11 | - (object) array( |
|
12 | - 'pattern' => '@/index.(html|htm|php)$@', |
|
13 | - 'replace' => '/'), |
|
14 | - (object) array( |
|
15 | - 'pattern' => '@^/1/$@', |
|
16 | - 'replace' => '/'), |
|
17 | - (object) array( |
|
18 | - 'pattern' => '@/page_([0-9]+)(/?)$@', |
|
19 | - 'replace' => '/page/$1/'), |
|
20 | - (object) array( |
|
21 | - 'pattern' => '@/tag/([a-z]+)/$@', |
|
22 | - 'replace' => '/$1/'), |
|
23 | - (object) array( |
|
24 | - 'pattern' => '@/tag/([a-z]+)/page/([0-9]+)/$@', |
|
25 | - 'replace' => '/$1/page/$2/'), |
|
26 | - (object) array( |
|
27 | - 'pattern' => '@/tag/([a-z-]+)/$@', |
|
28 | - 'replace' => '/'), |
|
29 | - (object) array( |
|
30 | - 'pattern' => '@/tag/([a-z-]+)/page/([0-9]+)/$@', |
|
31 | - 'replace' => '/')); |
|
32 | - } |
|
8 | + protected function get_redirect_array() |
|
9 | + { |
|
10 | + return array( |
|
11 | + (object) array( |
|
12 | + 'pattern' => '@/index.(html|htm|php)$@', |
|
13 | + 'replace' => '/'), |
|
14 | + (object) array( |
|
15 | + 'pattern' => '@^/1/$@', |
|
16 | + 'replace' => '/'), |
|
17 | + (object) array( |
|
18 | + 'pattern' => '@/page_([0-9]+)(/?)$@', |
|
19 | + 'replace' => '/page/$1/'), |
|
20 | + (object) array( |
|
21 | + 'pattern' => '@/tag/([a-z]+)/$@', |
|
22 | + 'replace' => '/$1/'), |
|
23 | + (object) array( |
|
24 | + 'pattern' => '@/tag/([a-z]+)/page/([0-9]+)/$@', |
|
25 | + 'replace' => '/$1/page/$2/'), |
|
26 | + (object) array( |
|
27 | + 'pattern' => '@/tag/([a-z-]+)/$@', |
|
28 | + 'replace' => '/'), |
|
29 | + (object) array( |
|
30 | + 'pattern' => '@/tag/([a-z-]+)/page/([0-9]+)/$@', |
|
31 | + 'replace' => '/')); |
|
32 | + } |
|
33 | 33 | |
34 | - protected function get_direct_array() |
|
35 | - { |
|
36 | - return array( |
|
37 | - (object) array( |
|
38 | - 'match' => '/', |
|
39 | - 'controller' => 'HomeController'), |
|
40 | - (object) array( |
|
41 | - 'match' => '/about/', |
|
42 | - 'controller' => 'AboutController'), |
|
43 | - (object) array( |
|
44 | - 'match' => '/page/([0-9]+)/', |
|
45 | - 'controller' => 'HomeController'), |
|
46 | - (object) array( |
|
47 | - 'match' => '/([a-z]+)/', |
|
48 | - 'controller' => 'TagController'), |
|
49 | - (object) array( |
|
50 | - 'match' => '/([a-z]+)/page/([0-9]+)/', |
|
51 | - 'controller' => 'TagController'), |
|
52 | - (object) array( |
|
53 | - 'match' => '/([a-z]+)/([0-9]+)/', |
|
54 | - 'controller' => 'PostController')); |
|
55 | - } |
|
34 | + protected function get_direct_array() |
|
35 | + { |
|
36 | + return array( |
|
37 | + (object) array( |
|
38 | + 'match' => '/', |
|
39 | + 'controller' => 'HomeController'), |
|
40 | + (object) array( |
|
41 | + 'match' => '/about/', |
|
42 | + 'controller' => 'AboutController'), |
|
43 | + (object) array( |
|
44 | + 'match' => '/page/([0-9]+)/', |
|
45 | + 'controller' => 'HomeController'), |
|
46 | + (object) array( |
|
47 | + 'match' => '/([a-z]+)/', |
|
48 | + 'controller' => 'TagController'), |
|
49 | + (object) array( |
|
50 | + 'match' => '/([a-z]+)/page/([0-9]+)/', |
|
51 | + 'controller' => 'TagController'), |
|
52 | + (object) array( |
|
53 | + 'match' => '/([a-z]+)/([0-9]+)/', |
|
54 | + 'controller' => 'PostController')); |
|
55 | + } |
|
56 | 56 | |
57 | 57 | } |
58 | 58 |
@@ -5,22 +5,22 @@ |
||
5 | 5 | class AJAXRouter extends Router |
6 | 6 | { |
7 | 7 | |
8 | - protected function get_redirect_array() |
|
9 | - { |
|
10 | - return array( |
|
11 | - (object) array( |
|
12 | - 'pattern' => '@^/$@', |
|
13 | - 'replace' => 'https://home.jacobemerick.com/')); |
|
14 | - } |
|
8 | + protected function get_redirect_array() |
|
9 | + { |
|
10 | + return array( |
|
11 | + (object) array( |
|
12 | + 'pattern' => '@^/$@', |
|
13 | + 'replace' => 'https://home.jacobemerick.com/')); |
|
14 | + } |
|
15 | 15 | |
16 | - protected function get_direct_array() |
|
17 | - { |
|
18 | - return array( |
|
19 | - (object) array( |
|
20 | - 'match' => '/get/portfolioImage.json', |
|
21 | - 'controller' => 'GetPortfolioImageController'), |
|
16 | + protected function get_direct_array() |
|
17 | + { |
|
18 | + return array( |
|
19 | + (object) array( |
|
20 | + 'match' => '/get/portfolioImage.json', |
|
21 | + 'controller' => 'GetPortfolioImageController'), |
|
22 | 22 | ); |
23 | - } |
|
23 | + } |
|
24 | 24 | |
25 | 25 | } |
26 | 26 |
@@ -5,121 +5,121 @@ |
||
5 | 5 | class BlogRouter extends Router |
6 | 6 | { |
7 | 7 | |
8 | - protected function get_redirect_array() |
|
9 | - { |
|
10 | - return array( |
|
11 | - (object) array( |
|
12 | - 'pattern' => '@^/page_([0-9]+)/$@', |
|
13 | - 'replace' => '/$1/'), |
|
14 | - (object) array( |
|
15 | - 'pattern' => '@/index.(html|htm|php)$@', |
|
16 | - 'replace' => '/'), |
|
17 | - (object) array( |
|
18 | - 'pattern' => '@^/([0-9]{4})-([a-z]+)/$@', |
|
19 | - 'replace' => '/'), |
|
20 | - (object) array( |
|
21 | - 'pattern' => '@^/([0-9]{4})-([a-z]+)/([0-9]+)/$@', |
|
22 | - 'replace' => '/'), |
|
23 | - (object) array( |
|
24 | - 'pattern' => '@^/month_([a-z]{3,})_([0-9]{4})(/?)$@', |
|
25 | - 'replace' => '/'), |
|
26 | - (object) array( |
|
27 | - 'pattern' => '@^/month_([a-z]{3,})_([0-9]{4})/page_([0-9]+)(/?)$@', |
|
28 | - 'replace' => '/'), |
|
29 | - (object) array( |
|
30 | - 'pattern' => '@^/category_([a-z-]+)(/?)$@', |
|
31 | - 'replace' => '/$1/'), |
|
32 | - (object) array( |
|
33 | - 'pattern' => '@^/category_([a-z-]+)/page_([0-9]+)(/?)$@', |
|
34 | - 'replace' => '/$1/$2/'), |
|
35 | - (object) array( |
|
36 | - 'pattern' => '@^/tag_([a-z-]+)(/?)$@', |
|
37 | - 'replace' => '/tag/$1/'), |
|
38 | - (object) array( |
|
39 | - 'pattern' => '@^/tag_([a-z-]+)/page_([0-9]+)(/?)$@', |
|
40 | - 'replace' => '/tag/$1/$2/'), |
|
41 | - (object) array( |
|
42 | - 'pattern' => '@^/blog/(.*)$@', |
|
43 | - 'replace' => '/$1')); |
|
44 | - } |
|
8 | + protected function get_redirect_array() |
|
9 | + { |
|
10 | + return array( |
|
11 | + (object) array( |
|
12 | + 'pattern' => '@^/page_([0-9]+)/$@', |
|
13 | + 'replace' => '/$1/'), |
|
14 | + (object) array( |
|
15 | + 'pattern' => '@/index.(html|htm|php)$@', |
|
16 | + 'replace' => '/'), |
|
17 | + (object) array( |
|
18 | + 'pattern' => '@^/([0-9]{4})-([a-z]+)/$@', |
|
19 | + 'replace' => '/'), |
|
20 | + (object) array( |
|
21 | + 'pattern' => '@^/([0-9]{4})-([a-z]+)/([0-9]+)/$@', |
|
22 | + 'replace' => '/'), |
|
23 | + (object) array( |
|
24 | + 'pattern' => '@^/month_([a-z]{3,})_([0-9]{4})(/?)$@', |
|
25 | + 'replace' => '/'), |
|
26 | + (object) array( |
|
27 | + 'pattern' => '@^/month_([a-z]{3,})_([0-9]{4})/page_([0-9]+)(/?)$@', |
|
28 | + 'replace' => '/'), |
|
29 | + (object) array( |
|
30 | + 'pattern' => '@^/category_([a-z-]+)(/?)$@', |
|
31 | + 'replace' => '/$1/'), |
|
32 | + (object) array( |
|
33 | + 'pattern' => '@^/category_([a-z-]+)/page_([0-9]+)(/?)$@', |
|
34 | + 'replace' => '/$1/$2/'), |
|
35 | + (object) array( |
|
36 | + 'pattern' => '@^/tag_([a-z-]+)(/?)$@', |
|
37 | + 'replace' => '/tag/$1/'), |
|
38 | + (object) array( |
|
39 | + 'pattern' => '@^/tag_([a-z-]+)/page_([0-9]+)(/?)$@', |
|
40 | + 'replace' => '/tag/$1/$2/'), |
|
41 | + (object) array( |
|
42 | + 'pattern' => '@^/blog/(.*)$@', |
|
43 | + 'replace' => '/$1')); |
|
44 | + } |
|
45 | 45 | |
46 | - protected function check_for_special_redirect($uri) |
|
47 | - { |
|
48 | - if(preg_match('@^/post_([0-9]{4}-[0-9]{2}-[0-9]{2})_([a-z0-9-]+)(/?)$@', $uri, $matches)) |
|
49 | - { |
|
46 | + protected function check_for_special_redirect($uri) |
|
47 | + { |
|
48 | + if(preg_match('@^/post_([0-9]{4}-[0-9]{2}-[0-9]{2})_([a-z0-9-]+)(/?)$@', $uri, $matches)) |
|
49 | + { |
|
50 | 50 | global $container; |
51 | 51 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
52 | 52 | $post = $repository->findPostByPath($matches[2]); |
53 | 53 | |
54 | - if(!$post) |
|
55 | - { |
|
56 | - Loader::loadNew('controller', '/Error404Controller') |
|
57 | - ->activate(); |
|
58 | - } |
|
54 | + if(!$post) |
|
55 | + { |
|
56 | + Loader::loadNew('controller', '/Error404Controller') |
|
57 | + ->activate(); |
|
58 | + } |
|
59 | 59 | |
60 | - Loader::load('utility', 'Content'); |
|
61 | - $uri = Content::instance('URLSafe', "/{$post['category']}/{$post['path']}/")->activate(); |
|
62 | - } |
|
63 | - else |
|
64 | - { |
|
65 | - $post_uri = URLDecode::getPiece(1); |
|
66 | - if($post_uri !== null) |
|
67 | - { |
|
60 | + Loader::load('utility', 'Content'); |
|
61 | + $uri = Content::instance('URLSafe', "/{$post['category']}/{$post['path']}/")->activate(); |
|
62 | + } |
|
63 | + else |
|
64 | + { |
|
65 | + $post_uri = URLDecode::getPiece(1); |
|
66 | + if($post_uri !== null) |
|
67 | + { |
|
68 | 68 | global $container; |
69 | 69 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
70 | 70 | $post = $repository->findPostByPath($post_uri); |
71 | 71 | |
72 | - if($post != false) |
|
73 | - { |
|
74 | - Loader::load('utility', 'Content'); |
|
75 | - $uri = Content::instance('URLSafe', "/{$post['category']}/{$post['path']}/")->activate(); |
|
76 | - } |
|
77 | - } |
|
78 | - } |
|
79 | - if($uri == '/search/') |
|
80 | - { |
|
81 | - if(Request::getGet('submit') == 'Submit Search' && Request::getGet('search')) |
|
82 | - { |
|
83 | - $uri .= Request::getGet('search'); |
|
84 | - $uri .= '/'; |
|
85 | - } |
|
86 | - } |
|
87 | - return $uri; |
|
88 | - } |
|
72 | + if($post != false) |
|
73 | + { |
|
74 | + Loader::load('utility', 'Content'); |
|
75 | + $uri = Content::instance('URLSafe', "/{$post['category']}/{$post['path']}/")->activate(); |
|
76 | + } |
|
77 | + } |
|
78 | + } |
|
79 | + if($uri == '/search/') |
|
80 | + { |
|
81 | + if(Request::getGet('submit') == 'Submit Search' && Request::getGet('search')) |
|
82 | + { |
|
83 | + $uri .= Request::getGet('search'); |
|
84 | + $uri .= '/'; |
|
85 | + } |
|
86 | + } |
|
87 | + return $uri; |
|
88 | + } |
|
89 | 89 | |
90 | - protected function get_direct_array() |
|
91 | - { |
|
92 | - return array( |
|
93 | - (object) array( |
|
94 | - 'match' => '/', |
|
95 | - 'controller' => 'HomeController'), |
|
96 | - (object) array( |
|
97 | - 'match' => '/([0-9]+)/', |
|
98 | - 'controller' => 'HomeController'), |
|
99 | - (object) array( |
|
100 | - 'match' => '/about/', |
|
101 | - 'controller' => 'AboutController'), |
|
102 | - (object) array( |
|
103 | - 'match' => '/(hiking|personal|web-development)/', |
|
104 | - 'controller' => 'CategoryController'), |
|
105 | - (object) array( |
|
106 | - 'match' => '/(hiking|personal|web-development)/([0-9]+)/', |
|
107 | - 'controller' => 'CategoryController'), |
|
108 | - (object) array( |
|
109 | - 'match' => '/tag/([a-z0-9-]+)/', |
|
110 | - 'controller' => 'TagController'), |
|
111 | - (object) array( |
|
112 | - 'match' => '/tag/([a-z-]+)/([0-9]+)/', |
|
113 | - 'controller' => 'TagController'), |
|
114 | - (object) array( |
|
115 | - 'match' => '/search/([a-z0-9-]+)/', |
|
116 | - 'controller' => 'SearchController'), |
|
117 | - (object) array( |
|
118 | - 'match' => '/search/([a-z0-9-]+)/([0-9]+)/', |
|
119 | - 'controller' => 'SearchController'), |
|
120 | - (object) array( |
|
121 | - 'match' => '/([a-z-]+)/([a-z0-9-]+)/', |
|
122 | - 'controller' => 'PostController')); |
|
123 | - } |
|
90 | + protected function get_direct_array() |
|
91 | + { |
|
92 | + return array( |
|
93 | + (object) array( |
|
94 | + 'match' => '/', |
|
95 | + 'controller' => 'HomeController'), |
|
96 | + (object) array( |
|
97 | + 'match' => '/([0-9]+)/', |
|
98 | + 'controller' => 'HomeController'), |
|
99 | + (object) array( |
|
100 | + 'match' => '/about/', |
|
101 | + 'controller' => 'AboutController'), |
|
102 | + (object) array( |
|
103 | + 'match' => '/(hiking|personal|web-development)/', |
|
104 | + 'controller' => 'CategoryController'), |
|
105 | + (object) array( |
|
106 | + 'match' => '/(hiking|personal|web-development)/([0-9]+)/', |
|
107 | + 'controller' => 'CategoryController'), |
|
108 | + (object) array( |
|
109 | + 'match' => '/tag/([a-z0-9-]+)/', |
|
110 | + 'controller' => 'TagController'), |
|
111 | + (object) array( |
|
112 | + 'match' => '/tag/([a-z-]+)/([0-9]+)/', |
|
113 | + 'controller' => 'TagController'), |
|
114 | + (object) array( |
|
115 | + 'match' => '/search/([a-z0-9-]+)/', |
|
116 | + 'controller' => 'SearchController'), |
|
117 | + (object) array( |
|
118 | + 'match' => '/search/([a-z0-9-]+)/([0-9]+)/', |
|
119 | + 'controller' => 'SearchController'), |
|
120 | + (object) array( |
|
121 | + 'match' => '/([a-z-]+)/([a-z0-9-]+)/', |
|
122 | + 'controller' => 'PostController')); |
|
123 | + } |
|
124 | 124 | |
125 | 125 | } |
@@ -8,81 +8,81 @@ discard block |
||
8 | 8 | abstract class DefaultPageController extends PageController |
9 | 9 | { |
10 | 10 | |
11 | - private static $RECENT_COMMENT_COUNT = 10; |
|
12 | - private static $MINIMUM_TAG_COUNT = 10; |
|
13 | - protected static $LENGTH_OF_TRIMMED_POST = 300; |
|
11 | + private static $RECENT_COMMENT_COUNT = 10; |
|
12 | + private static $MINIMUM_TAG_COUNT = 10; |
|
13 | + protected static $LENGTH_OF_TRIMMED_POST = 300; |
|
14 | 14 | |
15 | - protected static $BLOG_SITE_ID = 2; |
|
15 | + protected static $BLOG_SITE_ID = 2; |
|
16 | 16 | |
17 | - private static $INTRODUCTION_IMAGE_PATTERN = '<img src="/photo/%s/%s-size-%s.jpg" height="%d" width="%d" alt="%s" />'; |
|
17 | + private static $INTRODUCTION_IMAGE_PATTERN = '<img src="/photo/%s/%s-size-%s.jpg" height="%d" width="%d" alt="%s" />'; |
|
18 | 18 | |
19 | - protected function set_head_data() |
|
20 | - { |
|
19 | + protected function set_head_data() |
|
20 | + { |
|
21 | 21 | $this->set_head('rss_link', [ |
22 | - 'title' => 'Jacob Emerick Blog Feed', |
|
23 | - 'url' => '/rss.xml' |
|
22 | + 'title' => 'Jacob Emerick Blog Feed', |
|
23 | + 'url' => '/rss.xml' |
|
24 | 24 | ]); |
25 | 25 | $this->set_head('rss_comment_link', [ |
26 | - 'title' => 'Jacob Emerick Blog Comment Feed', |
|
27 | - 'url' => '/rss-comments.xml' |
|
26 | + 'title' => 'Jacob Emerick Blog Comment Feed', |
|
27 | + 'url' => '/rss-comments.xml' |
|
28 | 28 | ]); |
29 | 29 | |
30 | - $this->add_css('normalize'); |
|
31 | - $this->add_css('blog'); |
|
32 | - } |
|
30 | + $this->add_css('normalize'); |
|
31 | + $this->add_css('blog'); |
|
32 | + } |
|
33 | 33 | |
34 | - protected function get_introduction() |
|
35 | - { |
|
36 | - return; |
|
37 | - } |
|
34 | + protected function get_introduction() |
|
35 | + { |
|
36 | + return; |
|
37 | + } |
|
38 | 38 | |
39 | - protected function get_introduction_image($id) |
|
40 | - { |
|
41 | - Loader::load('collector', 'image/PhotoCollector'); |
|
42 | - $photo_result = PhotoCollector::getRow($id); |
|
39 | + protected function get_introduction_image($id) |
|
40 | + { |
|
41 | + Loader::load('collector', 'image/PhotoCollector'); |
|
42 | + $photo_result = PhotoCollector::getRow($id); |
|
43 | 43 | |
44 | - if($photo_result == null) |
|
45 | - return; |
|
44 | + if($photo_result == null) |
|
45 | + return; |
|
46 | 46 | |
47 | - $name = $photo_result->name; |
|
48 | - $category = $photo_result->category; |
|
49 | - $size = 'medium'; |
|
50 | - $height = 375; |
|
51 | - $width = 500; |
|
52 | - $description = $photo_result->description; |
|
47 | + $name = $photo_result->name; |
|
48 | + $category = $photo_result->category; |
|
49 | + $size = 'medium'; |
|
50 | + $height = 375; |
|
51 | + $width = 500; |
|
52 | + $description = $photo_result->description; |
|
53 | 53 | |
54 | - return sprintf(self::$INTRODUCTION_IMAGE_PATTERN, $category, $name, $size, $height, $width, $description); |
|
55 | - } |
|
54 | + return sprintf(self::$INTRODUCTION_IMAGE_PATTERN, $category, $name, $size, $height, $width, $description); |
|
55 | + } |
|
56 | 56 | |
57 | - protected function set_body_data() |
|
58 | - { |
|
59 | - $this->set_body('introduction', $this->get_introduction()); |
|
60 | - $this->set_body('right_side', $this->get_right_side()); |
|
61 | - $this->set_body('activity_array', $this->get_recent_activity()); |
|
57 | + protected function set_body_data() |
|
58 | + { |
|
59 | + $this->set_body('introduction', $this->get_introduction()); |
|
60 | + $this->set_body('right_side', $this->get_right_side()); |
|
61 | + $this->set_body('activity_array', $this->get_recent_activity()); |
|
62 | 62 | |
63 | - $this->set_body_view('Page'); |
|
64 | - } |
|
63 | + $this->set_body_view('Page'); |
|
64 | + } |
|
65 | 65 | |
66 | - final protected function format_post($post, $trim = false) |
|
67 | - { |
|
68 | - $post_object = new stdclass(); |
|
66 | + final protected function format_post($post, $trim = false) |
|
67 | + { |
|
68 | + $post_object = new stdclass(); |
|
69 | 69 | |
70 | - $post_object->title = $post['title']; |
|
71 | - $post_object->path = "/{$post['category']}/{$post['path']}/"; |
|
72 | - $post_object->category = ucwords(str_replace('-', ' ', $post['category'])); |
|
73 | - $post_object->category_link = "/{$post['category']}/"; |
|
74 | - // $post_object->comment_count = $this->get_comments_for_post($post); |
|
75 | - $post_object->tags = $this->get_tags_for_post($post); |
|
76 | - $post_object->image = Content::instance('FetchFirstPhoto', $post['body'])->activate(false, 'small'); |
|
77 | - $post_object->body = $this->get_body_for_post($post, $trim); |
|
78 | - $post_object->date = $this->get_parsed_date($post['date']); |
|
70 | + $post_object->title = $post['title']; |
|
71 | + $post_object->path = "/{$post['category']}/{$post['path']}/"; |
|
72 | + $post_object->category = ucwords(str_replace('-', ' ', $post['category'])); |
|
73 | + $post_object->category_link = "/{$post['category']}/"; |
|
74 | + // $post_object->comment_count = $this->get_comments_for_post($post); |
|
75 | + $post_object->tags = $this->get_tags_for_post($post); |
|
76 | + $post_object->image = Content::instance('FetchFirstPhoto', $post['body'])->activate(false, 'small'); |
|
77 | + $post_object->body = $this->get_body_for_post($post, $trim); |
|
78 | + $post_object->date = $this->get_parsed_date($post['date']); |
|
79 | 79 | |
80 | - return $post_object; |
|
81 | - } |
|
80 | + return $post_object; |
|
81 | + } |
|
82 | 82 | |
83 | - final private function get_comments_for_post($post) |
|
84 | - { |
|
85 | - $count = CommentCollector::getCommentCountForURL(self::$BLOG_SITE_ID, $post['path']); |
|
83 | + final private function get_comments_for_post($post) |
|
84 | + { |
|
85 | + $count = CommentCollector::getCommentCountForURL(self::$BLOG_SITE_ID, $post['path']); |
|
86 | 86 | $count_from_service = $this->get_comments_for_post_from_service($post); |
87 | 87 | |
88 | 88 | if ($count_from_service !== null && $count_from_service != $count) { |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $container['console']->log("{$count}, {$count_from_service} in service"); |
92 | 92 | } |
93 | 93 | return $count; |
94 | - } |
|
94 | + } |
|
95 | 95 | |
96 | 96 | final private function get_comments_for_post_from_service($post) |
97 | 97 | { |
@@ -127,106 +127,106 @@ discard block |
||
127 | 127 | return count($comment_response); |
128 | 128 | } |
129 | 129 | |
130 | - final private function get_tags_for_post($post) |
|
131 | - { |
|
130 | + final private function get_tags_for_post($post) |
|
131 | + { |
|
132 | 132 | global $container; |
133 | 133 | $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
134 | 134 | $tag_result = $repository->getTagsForPost($post['id']); |
135 | 135 | |
136 | 136 | $tag_array = array(); |
137 | - foreach($tag_result as $tag) |
|
138 | - { |
|
139 | - $tag_object = new stdclass(); |
|
140 | - $tag_object->name = $tag['tag']; |
|
141 | - $tag_object->link = Content::instance('URLSafe', "/tag/{$tag['tag']}/")->activate(); |
|
142 | - $tag_array[] = $tag_object; |
|
143 | - } |
|
144 | - return $tag_array; |
|
145 | - } |
|
137 | + foreach($tag_result as $tag) |
|
138 | + { |
|
139 | + $tag_object = new stdclass(); |
|
140 | + $tag_object->name = $tag['tag']; |
|
141 | + $tag_object->link = Content::instance('URLSafe', "/tag/{$tag['tag']}/")->activate(); |
|
142 | + $tag_array[] = $tag_object; |
|
143 | + } |
|
144 | + return $tag_array; |
|
145 | + } |
|
146 | 146 | |
147 | - final private function get_body_for_post($post, $trim) |
|
148 | - { |
|
149 | - $body = $post['body']; |
|
147 | + final private function get_body_for_post($post, $trim) |
|
148 | + { |
|
149 | + $body = $post['body']; |
|
150 | 150 | |
151 | - if($trim) |
|
152 | - $body = Content::instance('SmartTrim', $body)->activate(self::$LENGTH_OF_TRIMMED_POST); |
|
151 | + if($trim) |
|
152 | + $body = Content::instance('SmartTrim', $body)->activate(self::$LENGTH_OF_TRIMMED_POST); |
|
153 | 153 | |
154 | - $body = Content::instance('FixPhoto', $body)->activate(false, 'standard'); |
|
155 | - $body = Content::instance('MarkupCode', $body)->activate(); |
|
154 | + $body = Content::instance('FixPhoto', $body)->activate(false, 'standard'); |
|
155 | + $body = Content::instance('MarkupCode', $body)->activate(); |
|
156 | 156 | |
157 | - return $body; |
|
158 | - } |
|
157 | + return $body; |
|
158 | + } |
|
159 | 159 | |
160 | - final protected function get_right_side() |
|
161 | - { |
|
162 | - $side_array = array(); |
|
163 | - $side_array['tags'] = $this->get_tag_cloud(); |
|
164 | - $side_array['comments'] = $this->get_comments(); |
|
165 | - return $side_array; |
|
166 | - } |
|
160 | + final protected function get_right_side() |
|
161 | + { |
|
162 | + $side_array = array(); |
|
163 | + $side_array['tags'] = $this->get_tag_cloud(); |
|
164 | + $side_array['comments'] = $this->get_comments(); |
|
165 | + return $side_array; |
|
166 | + } |
|
167 | 167 | |
168 | - final private function get_tag_cloud() |
|
169 | - { |
|
168 | + final private function get_tag_cloud() |
|
169 | + { |
|
170 | 170 | global $container; |
171 | 171 | $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
172 | 172 | $tag_result = $repository->getTagCloud(); |
173 | 173 | |
174 | - $maximum_tag_count = $this->get_maximum_tag_count($tag_result); |
|
174 | + $maximum_tag_count = $this->get_maximum_tag_count($tag_result); |
|
175 | 175 | |
176 | - $cloud_array = array(); |
|
177 | - foreach($tag_result as $tag) |
|
178 | - { |
|
179 | - if($tag['count'] < self::$MINIMUM_TAG_COUNT) |
|
180 | - continue; |
|
176 | + $cloud_array = array(); |
|
177 | + foreach($tag_result as $tag) |
|
178 | + { |
|
179 | + if($tag['count'] < self::$MINIMUM_TAG_COUNT) |
|
180 | + continue; |
|
181 | 181 | |
182 | - $tag_object = new stdclass(); |
|
183 | - $tag_object->name = $tag['tag']; |
|
184 | - $tag_object->link = Content::instance('URLSafe', "/tag/{$tag['tag']}/")->activate(); |
|
185 | - $tag_object->scalar = floor(($tag['count'] - 1) * (9 / ($maximum_tag_count - self::$MINIMUM_TAG_COUNT))); |
|
186 | - $cloud_array[] = $tag_object; |
|
187 | - } |
|
182 | + $tag_object = new stdclass(); |
|
183 | + $tag_object->name = $tag['tag']; |
|
184 | + $tag_object->link = Content::instance('URLSafe', "/tag/{$tag['tag']}/")->activate(); |
|
185 | + $tag_object->scalar = floor(($tag['count'] - 1) * (9 / ($maximum_tag_count - self::$MINIMUM_TAG_COUNT))); |
|
186 | + $cloud_array[] = $tag_object; |
|
187 | + } |
|
188 | 188 | |
189 | - return $cloud_array; |
|
190 | - } |
|
189 | + return $cloud_array; |
|
190 | + } |
|
191 | 191 | |
192 | - final private function get_maximum_tag_count($tag_result) |
|
193 | - { |
|
194 | - $maximum = 1; |
|
192 | + final private function get_maximum_tag_count($tag_result) |
|
193 | + { |
|
194 | + $maximum = 1; |
|
195 | 195 | |
196 | - foreach($tag_result as $tag) |
|
197 | - { |
|
198 | - if($tag['count'] > $maximum) |
|
199 | - $maximum = $tag['count']; |
|
200 | - } |
|
201 | - return $maximum; |
|
202 | - } |
|
196 | + foreach($tag_result as $tag) |
|
197 | + { |
|
198 | + if($tag['count'] > $maximum) |
|
199 | + $maximum = $tag['count']; |
|
200 | + } |
|
201 | + return $maximum; |
|
202 | + } |
|
203 | 203 | |
204 | - final private function get_comments() |
|
205 | - { |
|
206 | - $comment_array = CommentCollector::getRecentBlogComments(self::$RECENT_COMMENT_COUNT); |
|
204 | + final private function get_comments() |
|
205 | + { |
|
206 | + $comment_array = CommentCollector::getRecentBlogComments(self::$RECENT_COMMENT_COUNT); |
|
207 | 207 | |
208 | - $array = array(); |
|
209 | - foreach($comment_array as $comment) |
|
210 | - { |
|
211 | - $body = $comment->body; |
|
212 | - $body = strip_tags($body); |
|
208 | + $array = array(); |
|
209 | + foreach($comment_array as $comment) |
|
210 | + { |
|
211 | + $body = $comment->body; |
|
212 | + $body = strip_tags($body); |
|
213 | 213 | |
214 | - $comment_obj = new stdclass(); |
|
215 | - $comment_obj->description = Content::instance('SmartTrim', $body)->activate(30); |
|
216 | - $comment_obj->commenter = $comment->name; |
|
217 | - $comment_obj->link = Loader::getRootURL() . "{$comment->category}/{$comment->path}/#comment-{$comment->id}"; |
|
218 | - $array[] = $comment_obj; |
|
219 | - } |
|
214 | + $comment_obj = new stdclass(); |
|
215 | + $comment_obj->description = Content::instance('SmartTrim', $body)->activate(30); |
|
216 | + $comment_obj->commenter = $comment->name; |
|
217 | + $comment_obj->link = Loader::getRootURL() . "{$comment->category}/{$comment->path}/#comment-{$comment->id}"; |
|
218 | + $array[] = $comment_obj; |
|
219 | + } |
|
220 | 220 | |
221 | 221 | $comment_service_array = $this->get_comments_from_service(); |
222 | 222 | if ($comment_service_array !== null && $comment_service_array !== $array) { |
223 | - global $container; |
|
224 | - $container['console']->log('Mismatch between comment service and legacy db'); |
|
225 | - $container['console']->log($comment_service_array[0]); |
|
226 | - $container['console']->log($array[0]); |
|
223 | + global $container; |
|
224 | + $container['console']->log('Mismatch between comment service and legacy db'); |
|
225 | + $container['console']->log($comment_service_array[0]); |
|
226 | + $container['console']->log($array[0]); |
|
227 | + } |
|
228 | + return $array; |
|
227 | 229 | } |
228 | - return $array; |
|
229 | - } |
|
230 | 230 | |
231 | 231 | final private function get_comments_from_service() |
232 | 232 | { |