@@ -17,14 +17,14 @@ discard block |
||
17 | 17 | |
18 | 18 | public static function instance() |
19 | 19 | { |
20 | - if(!isset(self::$instance)) |
|
20 | + if (!isset(self::$instance)) |
|
21 | 21 | self::$instance = new Loader(); |
22 | 22 | return self::$instance; |
23 | 23 | } |
24 | 24 | |
25 | 25 | private function get_root() |
26 | 26 | { |
27 | - if(!isset($this->root)) |
|
27 | + if (!isset($this->root)) |
|
28 | 28 | { |
29 | 29 | $current_directory = dirname(__FILE__); |
30 | 30 | $current_directory = substr($current_directory, 0, -7); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | private static function get_extension($type) |
54 | 54 | { |
55 | - switch($type) |
|
55 | + switch ($type) |
|
56 | 56 | { |
57 | 57 | case 'collector' : |
58 | 58 | case 'controller' : |
@@ -104,18 +104,18 @@ discard block |
||
104 | 104 | |
105 | 105 | public static function load($type, $files, $data = array()) |
106 | 106 | { |
107 | - foreach((array) $files as $file) |
|
107 | + foreach ((array) $files as $file) |
|
108 | 108 | { |
109 | 109 | $file_path = self::instance()->get_path($type, $file); |
110 | - if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
110 | + if (in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') |
|
111 | 111 | continue; |
112 | 112 | |
113 | - if(!file_exists($file_path)) |
|
113 | + if (!file_exists($file_path)) |
|
114 | 114 | Debugger::logMessage("Requested file does not exist: {$type}, {$file}"); |
115 | 115 | |
116 | 116 | self::instance()->add_included_file($file_path); |
117 | 117 | |
118 | - switch($type) |
|
118 | + switch ($type) |
|
119 | 119 | { |
120 | 120 | case 'images' : |
121 | 121 | case 'scripts' : |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | $reflectionObject = self::create_reflection_class($file); |
147 | 147 | |
148 | - if( |
|
148 | + if ( |
|
149 | 149 | $reflectionObject->hasMethod('instance') && |
150 | 150 | $reflectionObject->getMethod('instance')->isStatic()) |
151 | 151 | { |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | $reflectionObject = self::create_reflection_class($file); |
162 | 162 | |
163 | - if($reflectionObject->hasMethod('__construct')) |
|
163 | + if ($reflectionObject->hasMethod('__construct')) |
|
164 | 164 | return $reflectionObject->newInstanceArgs($data); |
165 | 165 | else |
166 | 166 | return $reflectionObject->newInstance(); |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | |
19 | 19 | private static function get_router_name() |
20 | 20 | { |
21 | - if(Request::isAJAX()) |
|
21 | + if (Request::isAJAX()) |
|
22 | 22 | return 'AJAXRouter'; |
23 | 23 | |
24 | - switch(URLDecode::getSite()) |
|
24 | + switch (URLDecode::getSite()) |
|
25 | 25 | { |
26 | 26 | case 'ajax' : |
27 | 27 | return 'AjaxRouter'; |
@@ -66,36 +66,36 @@ discard block |
||
66 | 66 | |
67 | 67 | final protected function check_for_redirect($redirect_uri) |
68 | 68 | { |
69 | - foreach($this->get_redirect_array() as $check) |
|
69 | + foreach ($this->get_redirect_array() as $check) |
|
70 | 70 | { |
71 | 71 | $redirect_uri = preg_replace($check->pattern, $check->replace, $redirect_uri); |
72 | 72 | } |
73 | 73 | |
74 | 74 | $redirect_uri = $this->check_for_special_redirect($redirect_uri); |
75 | 75 | |
76 | - if($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') |
|
76 | + if ($this->requires_trailing_slash() && substr($redirect_uri, -1) != '/') |
|
77 | 77 | $redirect_uri .= '/'; |
78 | 78 | |
79 | 79 | if (URLDecode::getHost() == 'waterfalls.jacobemerick.com') { |
80 | 80 | $redirect_uri = 'http://' . (!Loader::isLive() ? 'dev' : 'www') . '.waterfallsofthekeweenaw.com' . $redirect_uri; |
81 | 81 | } |
82 | 82 | |
83 | - if($redirect_uri == URLDecode::getURI()) |
|
83 | + if ($redirect_uri == URLDecode::getURI()) |
|
84 | 84 | return; |
85 | 85 | |
86 | 86 | $controller_check = $redirect_uri; |
87 | - if(substr($redirect_uri, 0, 4) == 'http') |
|
87 | + if (substr($redirect_uri, 0, 4) == 'http') |
|
88 | 88 | $controller_check = preg_replace('@^http://([a-z\.]+)@', '', $redirect_uri); |
89 | 89 | |
90 | 90 | $controller = $this->get_controller($controller_check); |
91 | - if($controller == '/Error404Controller') |
|
91 | + if ($controller == '/Error404Controller') |
|
92 | 92 | { |
93 | 93 | Loader::loadNew('controller', '/Error404Controller') |
94 | 94 | ->activate(); |
95 | 95 | exit; |
96 | 96 | } |
97 | 97 | |
98 | - if(substr($redirect_uri, 0, 4) != 'http') |
|
98 | + if (substr($redirect_uri, 0, 4) != 'http') |
|
99 | 99 | { |
100 | 100 | $redirect_uri = substr($redirect_uri, 1); |
101 | 101 | $redirect_uri = URLDecode::getBase() . $redirect_uri; |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | |
113 | 113 | final private function get_controller($uri) |
114 | 114 | { |
115 | - foreach($this->get_direct_array() as $check) |
|
115 | + foreach ($this->get_direct_array() as $check) |
|
116 | 116 | { |
117 | - if($uri == $check->match) |
|
117 | + if ($uri == $check->match) |
|
118 | 118 | return "{$this->get_primary_folder()}/{$check->controller}"; |
119 | 119 | |
120 | - if(preg_match("@^{$check->match}$@", $uri)) |
|
120 | + if (preg_match("@^{$check->match}$@", $uri)) |
|
121 | 121 | return "{$this->get_primary_folder()}/{$check->controller}"; |
122 | 122 | } |
123 | 123 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | final private function get_primary_folder() |
128 | 128 | { |
129 | - if(Request::isAjax()) |
|
129 | + if (Request::isAjax()) |
|
130 | 130 | return 'ajax'; |
131 | 131 | |
132 | 132 | return URLDecode::getSite(); |
@@ -4,5 +4,5 @@ |
||
4 | 4 | |
5 | 5 | interface PieceRepositoryInterface |
6 | 6 | { |
7 | - public function getPieces($limit = null, $offset= 0); |
|
7 | + public function getPieces($limit = null, $offset = 0); |
|
8 | 8 | } |
@@ -4,5 +4,5 @@ |
||
4 | 4 | |
5 | 5 | interface LogRepositoryInterface |
6 | 6 | { |
7 | - public function getActiveLogs($limit = null, $offset= 0); |
|
7 | + public function getActiveLogs($limit = null, $offset = 0); |
|
8 | 8 | } |
@@ -4,5 +4,5 @@ |
||
4 | 4 | |
5 | 5 | interface WaterfallRepositoryInterface |
6 | 6 | { |
7 | - public function getWaterfalls($limit = null, $offset= 0); |
|
7 | + public function getWaterfalls($limit = null, $offset = 0); |
|
8 | 8 | } |
@@ -4,5 +4,5 @@ |
||
4 | 4 | |
5 | 5 | interface CommentRepositoryInterface |
6 | 6 | { |
7 | - public function getActiveCommentsBySite($site, $limit = null, $offset= 0); |
|
7 | + public function getActiveCommentsBySite($site, $limit = null, $offset = 0); |
|
8 | 8 | } |
@@ -16,7 +16,7 @@ |
||
16 | 16 | * @param string $folder |
17 | 17 | * @return boolean |
18 | 18 | */ |
19 | -$buildFeed = function (Feed $feed, $folder, $name = 'rss') { |
|
19 | +$buildFeed = function(Feed $feed, $folder, $name = 'rss') { |
|
20 | 20 | $tempFeed = __DIR__ . "/../../public/{$folder}/{$name}-new.xml"; |
21 | 21 | $finalFeed = __DIR__ . "/../../public/{$folder}/{$name}.xml"; |
22 | 22 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | 'date' => date('Y'))); |
39 | 39 | |
40 | 40 | Loader::loadInstance('utility', 'Database'); |
41 | - if(Database::isConnected() === false) |
|
41 | + if (Database::isConnected() === false) |
|
42 | 42 | $this->unavailable(); |
43 | 43 | } |
44 | 44 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $post_result = $activityRepository->getActivities(5); |
64 | 64 | |
65 | 65 | $post_array = array(); |
66 | - foreach($post_result as $row) { |
|
66 | + foreach ($post_result as $row) { |
|
67 | 67 | array_push($post_array, $this->expand_post($row)); |
68 | 68 | } |
69 | 69 | |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | $headers = $this->headers; |
100 | 100 | Header::$headers(); |
101 | 101 | Loader::load('view', '/Head', $this->data_array['head']); |
102 | - foreach($this->body_view_array as $view) |
|
102 | + foreach ($this->body_view_array as $view) |
|
103 | 103 | { |
104 | - if(substr($view, 0, 1) == '/') |
|
104 | + if (substr($view, 0, 1) == '/') |
|
105 | 105 | Loader::load('view', $view, $this->data_array['body']); |
106 | 106 | else |
107 | 107 | Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE)); |
114 | 114 | } |
115 | 115 | |
116 | - if($view == '/404' || $view == '/503') |
|
116 | + if ($view == '/404' || $view == '/503') |
|
117 | 117 | exit; |
118 | 118 | } |
119 | 119 | |
@@ -169,10 +169,10 @@ discard block |
||
169 | 169 | |
170 | 170 | private function load_assets() |
171 | 171 | { |
172 | - $css_array = array_map(function ($stylesheet) { |
|
172 | + $css_array = array_map(function($stylesheet) { |
|
173 | 173 | return "/css/{$stylesheet}.css"; |
174 | 174 | }, $this->css_array); |
175 | - $js_array = array_map(function ($script) { |
|
175 | + $js_array = array_map(function($script) { |
|
176 | 176 | if (substr($script, 0, 4) == 'http') { |
177 | 177 | return $script; |
178 | 178 | } |
@@ -190,26 +190,26 @@ discard block |
||
190 | 190 | |
191 | 191 | protected function eject() |
192 | 192 | { |
193 | - if(get_class($this) !== 'Error404Controller') |
|
193 | + if (get_class($this) !== 'Error404Controller') |
|
194 | 194 | Loader::loadNew('controller', '/Error404Controller')->activate(); |
195 | 195 | } |
196 | 196 | |
197 | 197 | protected function unavailable() |
198 | 198 | { |
199 | - if(get_class($this) !== 'Error503Controller') |
|
199 | + if (get_class($this) !== 'Error503Controller') |
|
200 | 200 | Loader::loadNew('controller', '/Error503Controller')->activate(); |
201 | 201 | } |
202 | 202 | |
203 | 203 | protected function redirect($uri, $method = 301) |
204 | 204 | { |
205 | - switch($method) |
|
205 | + switch ($method) |
|
206 | 206 | { |
207 | 207 | case 301 : |
208 | - if(get_class($this) !== 'Error301Controller') |
|
208 | + if (get_class($this) !== 'Error301Controller') |
|
209 | 209 | Loader::loadNew('controller', '/Error301Controller', array($uri))->activate(); |
210 | 210 | break; |
211 | 211 | case 303 : |
212 | - if(get_class($this) !== 'Error303Controller') |
|
212 | + if (get_class($this) !== 'Error303Controller') |
|
213 | 213 | Loader::loadNew('controller', '/Error303Controller', array($uri))->activate(); |
214 | 214 | break; |
215 | 215 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | private $comment_errors; |
230 | 230 | protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title) |
231 | 231 | { |
232 | - if(Request::hasPost() && Request::getPost('submit') == 'Submit Comment') |
|
232 | + if (Request::hasPost() && Request::getPost('submit') == 'Submit Comment') |
|
233 | 233 | { |
234 | 234 | $parameters = array($site_id, $path, $redirect_url, $page_title); |
235 | 235 | $this->comment_errors = Loader::loadNew('module', 'form/CommentSubmitModule', $parameters)->activate(); |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | $comment_array = array(); |
248 | 248 | $comment_result = CommentCollector::getCommentsForURL($site, $path, $commenter->id); |
249 | 249 | |
250 | - foreach($comment_result as $comment) |
|
250 | + foreach ($comment_result as $comment) |
|
251 | 251 | { |
252 | 252 | $comment_object = new stdclass(); |
253 | 253 | $comment_object->id = $comment->id; |
@@ -257,12 +257,12 @@ discard block |
||
257 | 257 | $comment_object->url = $comment->url; |
258 | 258 | $comment_object->trusted = $comment->trusted; |
259 | 259 | |
260 | - if($comment->reply == 0 && Request::getPost('type') == $comment->id) |
|
260 | + if ($comment->reply == 0 && Request::getPost('type') == $comment->id) |
|
261 | 261 | $comment_object->errors = $this->comment_errors; |
262 | 262 | else |
263 | 263 | $comment_object->errors = array(); |
264 | 264 | |
265 | - if($comment->reply == 0) |
|
265 | + if ($comment->reply == 0) |
|
266 | 266 | { |
267 | 267 | $comment_object->replies = array(); |
268 | 268 | $comment_array[$comment->id] = $comment_object; |
@@ -293,21 +293,21 @@ discard block |
||
293 | 293 | $commenter->website = ''; |
294 | 294 | |
295 | 295 | $commenter_cookie = Cookie::instance('Commenter'); |
296 | - if(!$commenter_cookie->exists()) |
|
296 | + if (!$commenter_cookie->exists()) |
|
297 | 297 | return $commenter; |
298 | 298 | |
299 | 299 | $commenter_cookie_value = $commenter_cookie->getValue(); |
300 | 300 | $commenter_cookie_value = json_decode($commenter_cookie_value); |
301 | 301 | |
302 | - if($commenter_cookie_value === NULL) |
|
302 | + if ($commenter_cookie_value === NULL) |
|
303 | 303 | return $commenter; |
304 | 304 | |
305 | - if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) |
|
305 | + if (!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) |
|
306 | 306 | return $commenter; |
307 | 307 | |
308 | 308 | $commenter_object = CommentCollector::getCommenterByFields($commenter_cookie_value->name, $commenter_cookie_value->email, (isset($commenter_cookie_value->website) ? $commenter_cookie_value->website : '')); |
309 | 309 | |
310 | - if($commenter_object === NULL) |
|
310 | + if ($commenter_object === NULL) |
|
311 | 311 | return $commenter; |
312 | 312 | |
313 | 313 | $commenter->id = $commenter_object->id; |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param string $domain |
27 | 27 | * @return boolean |
28 | 28 | */ |
29 | -$buildSitemap = function (array $entries, $domain, $folder) { |
|
29 | +$buildSitemap = function(array $entries, $domain, $folder) { |
|
30 | 30 | $urlSet = new Urlset(); |
31 | 31 | foreach ($entries as $path => $entry) { |
32 | 32 | $url = new Url("{$domain}{$path}"); // todo better detection of domain by env |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | /********************************************* |
54 | 54 | * blog.jacobemerick.com |
55 | 55 | *********************************************/ |
56 | -$reduceToMostRecentBlogPost = function ($recentPost, $post) { |
|
56 | +$reduceToMostRecentBlogPost = function($recentPost, $post) { |
|
57 | 57 | if (is_null($recentPost)) { |
58 | 58 | return $post; |
59 | 59 | } |
60 | 60 | $postDate = new DateTime($post['date']); |
61 | 61 | $recentPostDate = new DateTime($recentPost['date']); |
62 | - return ($postDate > $recentPostDate) ? $post: $recentPost; |
|
62 | + return ($postDate > $recentPostDate) ? $post : $recentPost; |
|
63 | 63 | }; |
64 | 64 | |
65 | 65 | $blogPostsPerPage = 10; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | ]; |
95 | 95 | |
96 | 96 | foreach ($blogCategoryArray as $blogCategory) { |
97 | - $blogCategoryPosts = array_filter($activeBlogPosts, function ($post) use ($blogCategory) { |
|
97 | + $blogCategoryPosts = array_filter($activeBlogPosts, function($post) use ($blogCategory) { |
|
98 | 98 | return $post['category'] == $blogCategory; |
99 | 99 | }); |
100 | 100 | $mostRecentBlogCategoryPost = array_reduce($blogCategoryPosts, $reduceToMostRecentBlogPost); |
@@ -207,13 +207,13 @@ discard block |
||
207 | 207 | /********************************************* |
208 | 208 | * lifestream.jacobemerick.com |
209 | 209 | *********************************************/ |
210 | -$reduceToMostRecentStreamActivity = function ($recentActivity, $activity) { |
|
210 | +$reduceToMostRecentStreamActivity = function($recentActivity, $activity) { |
|
211 | 211 | if (is_null($recentActivity)) { |
212 | 212 | return $activity; |
213 | 213 | } |
214 | 214 | $activityDate = new DateTime($activity['datetime']); |
215 | 215 | $recentActivityDate = new DateTime($recentActivity['datetime']); |
216 | - return ($activityDate > $recentActivityDate) ? $activity: $recentActivity; |
|
216 | + return ($activityDate > $recentActivityDate) ? $activity : $recentActivity; |
|
217 | 217 | }; |
218 | 218 | |
219 | 219 | $streamActivitiesPerPage = 15; |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | ]; |
252 | 252 | |
253 | 253 | foreach ($streamTypeArray as $streamType) { |
254 | - $streamTypeActivities = array_filter($streamActivities, function ($post) use ($streamType) { |
|
254 | + $streamTypeActivities = array_filter($streamActivities, function($post) use ($streamType) { |
|
255 | 255 | return $post['type'] == $streamType; |
256 | 256 | }); |
257 | 257 | $mostRecentStreamTypeActivity = array_reduce($streamTypeActivities, $reduceToMostRecentStreamActivity); |
@@ -385,13 +385,13 @@ discard block |
||
385 | 385 | /********************************************* |
386 | 386 | * www.waterfallofthekeweenaw.com |
387 | 387 | *********************************************/ |
388 | -$reduceToMostRecentJournalLog = function ($recentLog, $log) { |
|
388 | +$reduceToMostRecentJournalLog = function($recentLog, $log) { |
|
389 | 389 | if (is_null($recentLog)) { |
390 | 390 | return $log; |
391 | 391 | } |
392 | 392 | $logDate = new DateTime($log['publish_date']); |
393 | 393 | $recentLogDate = new DateTime($recentLog['publish_date']); |
394 | - return ($logDate > $recentLogDate) ? log: $recentLog; |
|
394 | + return ($logDate > $recentLogDate) ? log : $recentLog; |
|
395 | 395 | }; |
396 | 396 | |
397 | 397 | $waterfallRepository = new WaterfallRepository($container['db_connection_locator']); |