Completed
Pull Request — master (#1)
by Jacob
03:28
created
controller/PageController.class.inc.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
Braces   +43 added lines, -31 removed lines patch added patch discarded remove patch
@@ -38,8 +38,9 @@  discard block
 block discarded – undo
38 38
 			'date' => date('Y')));
39 39
 		
40 40
 		Loader::loadInstance('utility', 'Database');
41
-		if(Database::isConnected() === false)
42
-			$this->unavailable();
41
+		if(Database::isConnected() === false) {
42
+					$this->unavailable();
43
+		}
43 44
 	}
44 45
 
45 46
 	protected function get_domain_container()
@@ -101,10 +102,11 @@  discard block
 block discarded – undo
101 102
 		Loader::load('view', '/Head', $this->data_array['head']);
102 103
 		foreach($this->body_view_array as $view)
103 104
 		{
104
-			if(substr($view, 0, 1) == '/')
105
-				Loader::load('view', $view, $this->data_array['body']);
106
-			else
107
-				Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']);
105
+			if(substr($view, 0, 1) == '/') {
106
+							Loader::load('view', $view, $this->data_array['body']);
107
+			} else {
108
+							Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']);
109
+			}
108 110
 		}
109 111
         
110 112
         if (URLDecode::getSite() == 'waterfalls') {
@@ -113,8 +115,9 @@  discard block
 block discarded – undo
113 115
             Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE));
114 116
         }
115 117
 		
116
-		if($view == '/404' || $view == '/503')
117
-			exit;
118
+		if($view == '/404' || $view == '/503') {
119
+					exit;
120
+		}
118 121
 	}
119 122
 
120 123
 	protected function set_header_method($method)
@@ -190,14 +193,16 @@  discard block
 block discarded – undo
190 193
 
191 194
 	protected function eject()
192 195
 	{
193
-		if(get_class($this) !== 'Error404Controller')
194
-			Loader::loadNew('controller', '/Error404Controller')->activate();
196
+		if(get_class($this) !== 'Error404Controller') {
197
+					Loader::loadNew('controller', '/Error404Controller')->activate();
198
+		}
195 199
 	}
196 200
 
197 201
 	protected function unavailable()
198 202
 	{
199
-		if(get_class($this) !== 'Error503Controller')
200
-			Loader::loadNew('controller', '/Error503Controller')->activate();
203
+		if(get_class($this) !== 'Error503Controller') {
204
+					Loader::loadNew('controller', '/Error503Controller')->activate();
205
+		}
201 206
 	}
202 207
 
203 208
 	protected function redirect($uri, $method = 301)
@@ -205,12 +210,14 @@  discard block
 block discarded – undo
205 210
 		switch($method)
206 211
 		{
207 212
 			case 301 :
208
-				if(get_class($this) !== 'Error301Controller')
209
-					Loader::loadNew('controller', '/Error301Controller', array($uri))->activate();
213
+				if(get_class($this) !== 'Error301Controller') {
214
+									Loader::loadNew('controller', '/Error301Controller', array($uri))->activate();
215
+				}
210 216
 				break;
211 217
 			case 303 :
212
-				if(get_class($this) !== 'Error303Controller')
213
-					Loader::loadNew('controller', '/Error303Controller', array($uri))->activate();
218
+				if(get_class($this) !== 'Error303Controller') {
219
+									Loader::loadNew('controller', '/Error303Controller', array($uri))->activate();
220
+				}
214 221
 				break;
215 222
 		}
216 223
 	}
@@ -257,18 +264,19 @@  discard block
 block discarded – undo
257 264
 			$comment_object->url = $comment->url;
258 265
 			$comment_object->trusted = $comment->trusted;
259 266
 			
260
-			if($comment->reply == 0 && Request::getPost('type') == $comment->id)
261
-				$comment_object->errors = $this->comment_errors;
262
-			else
263
-				$comment_object->errors = array();
267
+			if($comment->reply == 0 && Request::getPost('type') == $comment->id) {
268
+							$comment_object->errors = $this->comment_errors;
269
+			} else {
270
+							$comment_object->errors = array();
271
+			}
264 272
 			
265 273
 			if($comment->reply == 0)
266 274
 			{
267 275
 				$comment_object->replies = array();
268 276
 				$comment_array[$comment->id] = $comment_object;
269
-			}
270
-			else
271
-				$comment_array[$comment->reply]->replies[$comment->id] = $comment_object;
277
+			} else {
278
+							$comment_array[$comment->reply]->replies[$comment->id] = $comment_object;
279
+			}
272 280
 		}
273 281
 		
274 282
 		$comment_count = CommentCollector::getCommentCountForURL($site, $path);
@@ -293,22 +301,26 @@  discard block
 block discarded – undo
293 301
 		$commenter->website = '';
294 302
 		
295 303
 		$commenter_cookie = Cookie::instance('Commenter');
296
-		if(!$commenter_cookie->exists())
297
-			return $commenter;
304
+		if(!$commenter_cookie->exists()) {
305
+					return $commenter;
306
+		}
298 307
 		
299 308
 		$commenter_cookie_value = $commenter_cookie->getValue();
300 309
 		$commenter_cookie_value = json_decode($commenter_cookie_value);
301 310
 		
302
-		if($commenter_cookie_value === NULL)
303
-			return $commenter;
311
+		if($commenter_cookie_value === NULL) {
312
+					return $commenter;
313
+		}
304 314
 		
305
-		if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email))
306
-			return $commenter;
315
+		if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) {
316
+					return $commenter;
317
+		}
307 318
 		
308 319
 		$commenter_object = CommentCollector::getCommenterByFields($commenter_cookie_value->name, $commenter_cookie_value->email, (isset($commenter_cookie_value->website) ? $commenter_cookie_value->website : ''));
309 320
 		
310
-		if($commenter_object === NULL)
311
-			return $commenter;
321
+		if($commenter_object === NULL) {
322
+					return $commenter;
323
+		}
312 324
 		
313 325
 		$commenter->id = $commenter_object->id;
314 326
 		$commenter->name = $commenter_object->name;
Please login to merge, or discard this patch.
controller/lifestream/HomeController.class.inc.php 1 patch
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -38,8 +38,9 @@  discard block
 block discarded – undo
38 38
 	protected function get_page_number()
39 39
 	{
40 40
 		$page = URLDecode::getPiece(2);
41
-		if(isset($page) && is_numeric($page))
42
-			return $page;
41
+		if(isset($page) && is_numeric($page)) {
42
+					return $page;
43
+		}
43 44
 		return 1;
44 45
 	}
45 46
 
@@ -58,25 +59,29 @@  discard block
 block discarded – undo
58 59
 
59 60
 	protected function get_list_next_link()
60 61
 	{
61
-		if($this->page == 1)
62
-			return;
63
-		if($this->page == 2)
64
-			return Loader::getRootUrl('lifestream');
62
+		if($this->page == 1) {
63
+					return;
64
+		}
65
+		if($this->page == 2) {
66
+					return Loader::getRootUrl('lifestream');
67
+		}
65 68
 		return Loader::getRootUrl('lifestream') . 'page/' . ($this->page - 1) . '/';
66 69
 	}
67 70
 
68 71
 	protected function get_list_prev_link()
69 72
 	{
70
-		if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count())
71
-			return;
73
+		if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) {
74
+					return;
75
+		}
72 76
 		return Loader::getRootUrl('lifestream') . 'page/' . ($this->page + 1) . '/';
73 77
 	}
74 78
 
75 79
 	private $total_post_count;
76 80
 	protected function get_total_post_count()
77 81
 	{
78
-		if(!isset($this->total_post_count))
79
-			$this->total_post_count = $this->activityRepository->getActivitiesCount();
82
+		if(!isset($this->total_post_count)) {
83
+					$this->total_post_count = $this->activityRepository->getActivitiesCount();
84
+		}
80 85
 		return $this->total_post_count;
81 86
 	}
82 87
 
Please login to merge, or discard this patch.
controller/lifestream/TagController.class.inc.php 1 patch
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -97,8 +97,9 @@  discard block
 block discarded – undo
97 97
 	protected function get_page_number()
98 98
 	{
99 99
 		$page = URLDecode::getPiece(3);
100
-		if(isset($page) && is_numeric($page))
101
-			return $page;
100
+		if(isset($page) && is_numeric($page)) {
101
+					return $page;
102
+		}
102 103
 		return 1;
103 104
 	}
104 105
 
@@ -117,25 +118,29 @@  discard block
 block discarded – undo
117 118
 
118 119
 	protected function get_list_next_link()
119 120
 	{
120
-		if($this->page == 1)
121
-			return;
122
-		if($this->page == 2)
123
-			return Loader::getRootUrl('lifestream') . $this->tag . '/';
121
+		if($this->page == 1) {
122
+					return;
123
+		}
124
+		if($this->page == 2) {
125
+					return Loader::getRootUrl('lifestream') . $this->tag . '/';
126
+		}
124 127
 		return Loader::getRootUrl('lifestream') . $this->tag . '/page/' . ($this->page - 1) . '/';
125 128
 	}
126 129
 
127 130
 	protected function get_list_prev_link()
128 131
 	{
129
-		if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count())
130
-			return;
132
+		if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) {
133
+					return;
134
+		}
131 135
 		return Loader::getRootUrl('lifestream') . $this->tag . '/page/' . ($this->page + 1) . '/';
132 136
 	}
133 137
 
134 138
 	private $total_post_count;
135 139
 	protected function get_total_post_count()
136 140
 	{
137
-		if(!isset($this->total_post_count))
138
-			$this->total_post_count = $this->activityRepository->getActivitiesByTypeCount($this->tag);
141
+		if(!isset($this->total_post_count)) {
142
+					$this->total_post_count = $this->activityRepository->getActivitiesByTypeCount($this->tag);
143
+		}
139 144
 		return $this->total_post_count;
140 145
 	}
141 146
 
Please login to merge, or discard this patch.
script/cron/generate-sitemaps.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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']);
Please login to merge, or discard this patch.