@@ -39,20 +39,20 @@ discard block |
||
39 | 39 | public function perform() |
40 | 40 | { |
41 | 41 | $weighted_array = array(); |
42 | - foreach($this->result as $row) |
|
42 | + foreach ($this->result as $row) |
|
43 | 43 | { |
44 | 44 | $weight = $this->get_search_weight($row); |
45 | - if($weight > 0) |
|
45 | + if ($weight > 0) |
|
46 | 46 | $weighted_array[$row->id] = $weight; |
47 | 47 | } |
48 | 48 | arsort($weighted_array); |
49 | 49 | |
50 | 50 | $final_array = array(); |
51 | - foreach($weighted_array as $id => $weight) |
|
51 | + foreach ($weighted_array as $id => $weight) |
|
52 | 52 | { |
53 | - foreach($this->result as $row) |
|
53 | + foreach ($this->result as $row) |
|
54 | 54 | { |
55 | - if($row->id == $id) |
|
55 | + if ($row->id == $id) |
|
56 | 56 | $final_array[] = $row; |
57 | 57 | } |
58 | 58 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | private function get_search_weight($row) |
63 | 63 | { |
64 | 64 | $weight = 0; |
65 | - foreach($this->weight as $weight_array) |
|
65 | + foreach ($this->weight as $weight_array) |
|
66 | 66 | { |
67 | 67 | $text = $row->{$weight_array['field']}; |
68 | 68 | $weight += $weight_array['weight'] * substr_count(strtolower($text), strtolower($this->query)); |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | public function setToAddress($email, $person = null) |
22 | 22 | { |
23 | - if($person) |
|
23 | + if ($person) |
|
24 | 24 | $this->to[] = "{$person} <{$email}>"; |
25 | 25 | else |
26 | 26 | $this->to[] = "{$email}"; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | public function send() |
43 | 43 | { |
44 | - if(!Loader::isLive()) |
|
44 | + if (!Loader::isLive()) |
|
45 | 45 | { |
46 | 46 | Debugger::logMessage("Email Failed:\n\n{$this->message}"); |
47 | 47 | return; |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | $subject = $this->subject; |
52 | 52 | $message = $this->message; |
53 | 53 | |
54 | - if(empty($to) || empty($subject) || empty($message)) |
|
54 | + if (empty($to) || empty($subject) || empty($message)) |
|
55 | 55 | { |
56 | 56 | Debugger::logMessage("Attempted to send an email without all of the required fields."); |
57 | 57 | return; |
58 | 58 | } |
59 | 59 | |
60 | 60 | $header = ''; |
61 | - foreach($this->headers as $key => $value) |
|
61 | + foreach ($this->headers as $key => $value) |
|
62 | 62 | { |
63 | 63 | $header .= "{$key}: {$value}\r\n"; |
64 | 64 | } |
@@ -56,11 +56,11 @@ |
||
56 | 56 | final private function get_list_posts() |
57 | 57 | { |
58 | 58 | $post_array = array(); |
59 | - foreach($this->get_list_results() as $post) |
|
59 | + foreach ($this->get_list_results() as $post) |
|
60 | 60 | { |
61 | 61 | $post_array[] = $this->format_post($post, true); |
62 | 62 | } |
63 | - if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
63 | + if (count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
64 | 64 | $this->eject(); |
65 | 65 | return $post_array; |
66 | 66 | } |
@@ -33,16 +33,16 @@ discard block |
||
33 | 33 | |
34 | 34 | private function process_form() |
35 | 35 | { |
36 | - if(!Request::hasPost() || Request::getPost('submit') != 'Send Message!') |
|
36 | + if (!Request::hasPost() || Request::getPost('submit') != 'Send Message!') |
|
37 | 37 | return (object) array('display' => 'normal'); |
38 | 38 | |
39 | 39 | Loader::load('utility', 'Validate'); |
40 | 40 | $error_result = array(); |
41 | - if(!Validate::checkRequest('post', 'name', 'string')) |
|
41 | + if (!Validate::checkRequest('post', 'name', 'string')) |
|
42 | 42 | $error_result['name'] = 'please enter your name'; |
43 | - if(!Validate::checkRequest('post', 'email', 'string')) |
|
43 | + if (!Validate::checkRequest('post', 'email', 'string')) |
|
44 | 44 | $error_result['email'] = 'please enter a valid email'; |
45 | - if(!Validate::checkRequest('post', 'message', 'string')) |
|
45 | + if (!Validate::checkRequest('post', 'message', 'string')) |
|
46 | 46 | $error_result['message'] = 'please write a message'; |
47 | 47 | |
48 | 48 | $values = (object) array( |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | 'email' => Request::getPost('email'), |
51 | 51 | 'message' => Request::getPost('message')); |
52 | 52 | |
53 | - if(count($error_result) > 0) |
|
53 | + if (count($error_result) > 0) |
|
54 | 54 | { |
55 | 55 | return (object) array( |
56 | 56 | 'display' => 'error', |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | // configure the db connections holder |
22 | 22 | $db_connections = new Aura\Sql\ConnectionLocator(); |
23 | -$db_connections->setDefault(function () use ($config) { |
|
23 | +$db_connections->setDefault(function() use ($config) { |
|
24 | 24 | $connection = $config->database->slave; |
25 | 25 | return new Aura\Sql\ExtendedPdo( |
26 | 26 | "mysql:host={$connection->host}", |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $connection->password |
29 | 29 | ); |
30 | 30 | }); |
31 | -$db_connections->setWrite('master', function () use ($config) { |
|
31 | +$db_connections->setWrite('master', function() use ($config) { |
|
32 | 32 | $connection = $config->database->master; |
33 | 33 | return new Aura\Sql\ExtendedPdo( |
34 | 34 | "mysql:host={$connection->host}", |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $connection->password |
37 | 37 | ); |
38 | 38 | }); |
39 | -$db_connections->setRead('slave', function () use ($config) { |
|
39 | +$db_connections->setRead('slave', function() use ($config) { |
|
40 | 40 | $connection = $config->database->slave; |
41 | 41 | $pdo = new Aura\Sql\ExtendedPdo( |
42 | 42 | "mysql:host={$connection->host}", |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | parent::__construct(); |
21 | 21 | |
22 | 22 | $id = URLDecode::getPiece(2); |
23 | - if(!$id || !is_numeric($id)) |
|
23 | + if (!$id || !is_numeric($id)) |
|
24 | 24 | $this->eject(); |
25 | 25 | |
26 | 26 | $post = $this->postRepository->getPostById($id); |
27 | - if(!$post) |
|
27 | + if (!$post) |
|
28 | 28 | $this->eject(); |
29 | 29 | |
30 | - if(URLDecode::getPiece(1) != $post['type']) |
|
30 | + if (URLDecode::getPiece(1) != $post['type']) |
|
31 | 31 | $this->eject(); |
32 | 32 | |
33 | 33 | $this->post = $post; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | private function get_title() |
61 | 61 | { |
62 | - switch($this->post['type']) |
|
62 | + switch ($this->post['type']) |
|
63 | 63 | { |
64 | 64 | case 'blog' : |
65 | 65 | return 'Jacob blogged'; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | private function get_description() |
86 | 86 | { |
87 | - switch($this->post['type']) |
|
87 | + switch ($this->post['type']) |
|
88 | 88 | { |
89 | 89 | case 'blog' : |
90 | 90 | return 'Another awesome blog post from Jacob. Did I mention it was awesome?'; |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | |
21 | 21 | public function activate() |
22 | 22 | { |
23 | - foreach(self::$CRON_ARRAY as $cron => $frequency) |
|
23 | + foreach (self::$CRON_ARRAY as $cron => $frequency) |
|
24 | 24 | { |
25 | - if(!$this->time_to_run($frequency)) |
|
25 | + if (!$this->time_to_run($frequency)) |
|
26 | 26 | continue; |
27 | 27 | |
28 | 28 | Loader::load('utility', "cron/{$cron}"); |
@@ -46,19 +46,19 @@ discard block |
||
46 | 46 | $operator = explode(' ', $frequency); |
47 | 47 | list($time['minute'], $time['hour'], $time['day'], $time['month'], $time['weekday']) = $operator; |
48 | 48 | |
49 | - foreach($time as $key => $value) |
|
49 | + foreach ($time as $key => $value) |
|
50 | 50 | { |
51 | - if($value == '*') |
|
51 | + if ($value == '*') |
|
52 | 52 | continue; |
53 | - if(stristr($value, '/')) |
|
53 | + if (stristr($value, '/')) |
|
54 | 54 | { |
55 | 55 | $value = substr($value, 2); |
56 | - if($cur[$key] % $value == 0) |
|
56 | + if ($cur[$key] % $value == 0) |
|
57 | 57 | continue; |
58 | 58 | else |
59 | 59 | return; |
60 | 60 | } |
61 | - if($cur[$key] == $value) |
|
61 | + if ($cur[$key] == $value) |
|
62 | 62 | continue; |
63 | 63 | return; |
64 | 64 | } |
@@ -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,9 +63,9 @@ discard block |
||
63 | 63 | $post_result = $activityRepository->getPosts(5); |
64 | 64 | |
65 | 65 | $post_array = array(); |
66 | - foreach($post_result as $row) |
|
66 | + foreach ($post_result as $row) |
|
67 | 67 | { |
68 | - $post_array[] = $this->expand_post($row);; |
|
68 | + $post_array[] = $this->expand_post($row); ; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | return $post_array; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | $post = new stdclass(); |
87 | 87 | |
88 | - switch($raw_post['type']) |
|
88 | + switch ($raw_post['type']) |
|
89 | 89 | { |
90 | 90 | case 'blog' : |
91 | 91 | $row = $blogRepository->getBlogById($raw_post['type_id']); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $post->title = "Blogged about {$category}: <a href=\"{$row['url']}\">{$row['title']}</a>."; |
97 | 97 | $post->comments = $row['comments']; |
98 | 98 | |
99 | - if($format == 'full') |
|
99 | + if ($format == 'full') |
|
100 | 100 | $post->image = Content::instance('FetchFirstPhoto', $row['body'])->activate(false, 'standard'); |
101 | 101 | break; |
102 | 102 | case 'book' : |
@@ -105,23 +105,23 @@ discard block |
||
105 | 105 | $post->type = 'book'; |
106 | 106 | $post->title = "Just finished reading {$row['title']} by {$row['author']}."; |
107 | 107 | |
108 | - if($format == 'full') |
|
108 | + if ($format == 'full') |
|
109 | 109 | $post->image = "<img alt=\"{$row['title']} by {$row['author']}\" src=\"{$row['image']}\" />"; |
110 | 110 | break; |
111 | 111 | case 'distance' : |
112 | 112 | $row = $distanceRepository->getDistanceById($raw_post['type_id']); |
113 | 113 | |
114 | 114 | $post->type = 'distance'; |
115 | - if($row['type'] == 'running') |
|
115 | + if ($row['type'] == 'running') |
|
116 | 116 | { |
117 | 117 | $post->title = "Ran {$row['distance']} miles and felt {$row['felt']}."; |
118 | - if(strlen($row['message']) > 0) |
|
118 | + if (strlen($row['message']) > 0) |
|
119 | 119 | $post->title .= " Afterwards, I was all like '{$row['message']}'."; |
120 | 120 | } |
121 | - else if($row['type'] == 'hiking') |
|
121 | + else if ($row['type'] == 'hiking') |
|
122 | 122 | { |
123 | 123 | $post->title = "Hiked {$row['distance']} miles and felt {$row['felt']}."; |
124 | - if(strlen($row['title']) > 0) |
|
124 | + if (strlen($row['title']) > 0) |
|
125 | 125 | $post->title .= " I was hiking up around the {$row['title']} area."; |
126 | 126 | } |
127 | 127 | else if ($row['type'] == 'walking') { |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | $post->type = 'twitter'; |
141 | 141 | |
142 | - if($format == 'full') |
|
142 | + if ($format == 'full') |
|
143 | 143 | $post->title = $row['text_formatted_full']; |
144 | 144 | else |
145 | 145 | $post->title = $row['text_formatted']; |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | |
153 | 153 | $post->type = 'youtube'; |
154 | 154 | |
155 | - if($format == 'full') |
|
155 | + if ($format == 'full') |
|
156 | 156 | $post->title = "Favorited {$row['title']} by {$row['author']} on YouTube."; |
157 | 157 | else |
158 | 158 | $post->title = "Favorited <a href=\"http://www.youtube.com/watch?feature=player_embedded&v={$row['video_id']}\" rel=\"nofollow\" target=\"_blank\" title=\"{$row['content']}\">{$row['title']}</a> by {$row['author']} on YouTube."; |
159 | 159 | |
160 | - if($format == 'full') |
|
160 | + if ($format == 'full') |
|
161 | 161 | $post->embed_code = "<iframe src=\"http://www.youtube.com/embed/{$row['video_id']}?rel=0\" frameborder=\"0\" allowfullscreen></iframe>"; |
162 | 162 | break; |
163 | 163 | } |
@@ -185,9 +185,9 @@ discard block |
||
185 | 185 | $headers = $this->headers; |
186 | 186 | Header::$headers(); |
187 | 187 | Loader::load('view', '/Head', $this->data_array['head']); |
188 | - foreach($this->body_view_array as $view) |
|
188 | + foreach ($this->body_view_array as $view) |
|
189 | 189 | { |
190 | - if(substr($view, 0, 1) == '/') |
|
190 | + if (substr($view, 0, 1) == '/') |
|
191 | 191 | Loader::load('view', $view, $this->data_array['body']); |
192 | 192 | else |
193 | 193 | Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']); |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE)); |
200 | 200 | } |
201 | 201 | |
202 | - if($view == '/404' || $view == '/503') |
|
202 | + if ($view == '/404' || $view == '/503') |
|
203 | 203 | exit; |
204 | 204 | } |
205 | 205 | |
@@ -255,10 +255,10 @@ discard block |
||
255 | 255 | |
256 | 256 | private function load_assets() |
257 | 257 | { |
258 | - $css_array = array_map(function ($stylesheet) { |
|
258 | + $css_array = array_map(function($stylesheet) { |
|
259 | 259 | return "/css/{$stylesheet}.css"; |
260 | 260 | }, $this->css_array); |
261 | - $js_array = array_map(function ($script) { |
|
261 | + $js_array = array_map(function($script) { |
|
262 | 262 | return "/js/{$script}.js"; |
263 | 263 | }, $this->js_array); |
264 | 264 | |
@@ -273,26 +273,26 @@ discard block |
||
273 | 273 | |
274 | 274 | protected function eject() |
275 | 275 | { |
276 | - if(get_class($this) !== 'Error404Controller') |
|
276 | + if (get_class($this) !== 'Error404Controller') |
|
277 | 277 | Loader::loadNew('controller', '/Error404Controller')->activate(); |
278 | 278 | } |
279 | 279 | |
280 | 280 | protected function unavailable() |
281 | 281 | { |
282 | - if(get_class($this) !== 'Error503Controller') |
|
282 | + if (get_class($this) !== 'Error503Controller') |
|
283 | 283 | Loader::loadNew('controller', '/Error503Controller')->activate(); |
284 | 284 | } |
285 | 285 | |
286 | 286 | protected function redirect($uri, $method = 301) |
287 | 287 | { |
288 | - switch($method) |
|
288 | + switch ($method) |
|
289 | 289 | { |
290 | 290 | case 301 : |
291 | - if(get_class($this) !== 'Error301Controller') |
|
291 | + if (get_class($this) !== 'Error301Controller') |
|
292 | 292 | Loader::loadNew('controller', '/Error301Controller', array($uri))->activate(); |
293 | 293 | break; |
294 | 294 | case 303 : |
295 | - if(get_class($this) !== 'Error303Controller') |
|
295 | + if (get_class($this) !== 'Error303Controller') |
|
296 | 296 | Loader::loadNew('controller', '/Error303Controller', array($uri))->activate(); |
297 | 297 | break; |
298 | 298 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | private $comment_errors; |
313 | 313 | protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title) |
314 | 314 | { |
315 | - if(Request::hasPost() && Request::getPost('submit') == 'Submit Comment') |
|
315 | + if (Request::hasPost() && Request::getPost('submit') == 'Submit Comment') |
|
316 | 316 | { |
317 | 317 | $parameters = array($site_id, $path, $redirect_url, $page_title); |
318 | 318 | $this->comment_errors = Loader::loadNew('module', 'form/CommentSubmitModule', $parameters)->activate(); |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | $comment_array = array(); |
331 | 331 | $comment_result = CommentCollector::getCommentsForURL($site, $path, $commenter->id); |
332 | 332 | |
333 | - foreach($comment_result as $comment) |
|
333 | + foreach ($comment_result as $comment) |
|
334 | 334 | { |
335 | 335 | $comment_object = new stdclass(); |
336 | 336 | $comment_object->id = $comment->id; |
@@ -340,12 +340,12 @@ discard block |
||
340 | 340 | $comment_object->url = $comment->url; |
341 | 341 | $comment_object->trusted = $comment->trusted; |
342 | 342 | |
343 | - if($comment->reply == 0 && Request::getPost('type') == $comment->id) |
|
343 | + if ($comment->reply == 0 && Request::getPost('type') == $comment->id) |
|
344 | 344 | $comment_object->errors = $this->comment_errors; |
345 | 345 | else |
346 | 346 | $comment_object->errors = array(); |
347 | 347 | |
348 | - if($comment->reply == 0) |
|
348 | + if ($comment->reply == 0) |
|
349 | 349 | { |
350 | 350 | $comment_object->replies = array(); |
351 | 351 | $comment_array[$comment->id] = $comment_object; |
@@ -376,21 +376,21 @@ discard block |
||
376 | 376 | $commenter->website = ''; |
377 | 377 | |
378 | 378 | $commenter_cookie = Cookie::instance('Commenter'); |
379 | - if(!$commenter_cookie->exists()) |
|
379 | + if (!$commenter_cookie->exists()) |
|
380 | 380 | return $commenter; |
381 | 381 | |
382 | 382 | $commenter_cookie_value = $commenter_cookie->getValue(); |
383 | 383 | $commenter_cookie_value = json_decode($commenter_cookie_value); |
384 | 384 | |
385 | - if($commenter_cookie_value === NULL) |
|
385 | + if ($commenter_cookie_value === NULL) |
|
386 | 386 | return $commenter; |
387 | 387 | |
388 | - if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) |
|
388 | + if (!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) |
|
389 | 389 | return $commenter; |
390 | 390 | |
391 | 391 | $commenter_object = CommentCollector::getCommenterByFields($commenter_cookie_value->name, $commenter_cookie_value->email, (isset($commenter_cookie_value->website) ? $commenter_cookie_value->website : '')); |
392 | 392 | |
393 | - if($commenter_object === NULL) |
|
393 | + if ($commenter_object === NULL) |
|
394 | 394 | return $commenter; |
395 | 395 | |
396 | 396 | $commenter->id = $commenter_object->id; |
@@ -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(); |