Completed
Pull Request — master (#2)
by Jacob
04:01
created
utility/Loader.class.inc.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -59,6 +59,9 @@  discard block
 block discarded – undo
59 59
 		$this->add_posts($youtube_result, 'youtube');
60 60
 	}
61 61
 
62
+	/**
63
+	 * @param string $type
64
+	 */
62 65
 	private function remove_existing($result, $type)
63 66
 	{
64 67
 		foreach($result as $key => $row)
@@ -70,6 +73,9 @@  discard block
 block discarded – undo
70 73
 		return $result;
71 74
 	}
72 75
 
76
+	/**
77
+	 * @param string $type
78
+	 */
73 79
 	private function add_posts($result, $type)
74 80
 	{
75 81
 		foreach($result as $row)
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,10 +104,10 @@  discard block
 block discarded – undo
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 113
 			// if(!file_exists($file_path))
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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();
Please login to merge, or discard this patch.
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,8 +17,9 @@  discard block
 block discarded – undo
17 17
 
18 18
 	public static function instance()
19 19
 	{
20
-		if(!isset(self::$instance))
21
-			self::$instance = new Loader();
20
+		if(!isset(self::$instance)) {
21
+					self::$instance = new Loader();
22
+		}
22 23
 		return self::$instance;
23 24
 	}
24 25
 
@@ -107,8 +108,9 @@  discard block
 block discarded – undo
107 108
 		foreach((array) $files as $file)
108 109
 		{
109 110
 			$file_path = self::instance()->get_path($type, $file);
110
-			if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view')
111
-				continue;
111
+			if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') {
112
+							continue;
113
+			}
112 114
 			
113 115
 			// if(!file_exists($file_path))
114 116
 			// 	Debugger::logMessage("Requested file does not exist: {$type}, {$file}");
@@ -160,10 +162,11 @@  discard block
 block discarded – undo
160 162
 		
161 163
 		$reflectionObject = self::create_reflection_class($file);
162 164
 		
163
-		if($reflectionObject->hasMethod('__construct'))
164
-			return $reflectionObject->newInstanceArgs($data);
165
-		else
166
-			return $reflectionObject->newInstance();
165
+		if($reflectionObject->hasMethod('__construct')) {
166
+					return $reflectionObject->newInstanceArgs($data);
167
+		} else {
168
+					return $reflectionObject->newInstance();
169
+		}
167 170
 	}
168 171
 
169 172
 	public static function getRoot()
Please login to merge, or discard this patch.
public/site/index.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 $streamHandler = new Monolog\Handler\StreamHandler(__DIR__ . '/../../logs/site.log', Monolog\Logger::INFO);
11 11
 $streamHandler->setFormatter(
12
-    new Monolog\Formatter\LineFormatter("[%datetime%] %channel%.%level_name%: %message%\n")
12
+	new Monolog\Formatter\LineFormatter("[%datetime%] %channel%.%level_name%: %message%\n")
13 13
 );
14 14
 $logger->pushHandler($streamHandler);
15 15
 
@@ -30,21 +30,21 @@  discard block
 block discarded – undo
30 30
 
31 31
 // shutdown - note, this should be in a shutdown function
32 32
 if ($_COOKIE['debugger'] == 'display') {
33
-    $dbProfiles = $container['db_connection_locator']
34
-        ->getRead()
35
-        ->getProfiler()
36
-        ->getProfiles();
37
-    $dbProfiles = array_filter($dbProfiles, function ($profile) {
38
-        return $profile['function'] == 'perform';
39
-    });
40
-    $dbProfiles = array_map(function ($profile) {
41
-        return [
42
-            'sql' => trim(preg_replace('/\s+/', ' ', $profile['statement'])),
43
-            'parameters' => $profile['bind_values'],
44
-            'time' => $profile['duration'],
45
-        ];
46
-    }, $dbProfiles);
47
-    $container['profiler']->setProfiledQueries($dbProfiles);
48
-    $container['profiler']->setDisplay(new Particletree\Pqp\Display());
49
-    $container['profiler']->display($container['db_connection_locator']->getRead());
33
+	$dbProfiles = $container['db_connection_locator']
34
+		->getRead()
35
+		->getProfiler()
36
+		->getProfiles();
37
+	$dbProfiles = array_filter($dbProfiles, function ($profile) {
38
+		return $profile['function'] == 'perform';
39
+	});
40
+	$dbProfiles = array_map(function ($profile) {
41
+		return [
42
+			'sql' => trim(preg_replace('/\s+/', ' ', $profile['statement'])),
43
+			'parameters' => $profile['bind_values'],
44
+			'time' => $profile['duration'],
45
+		];
46
+	}, $dbProfiles);
47
+	$container['profiler']->setProfiledQueries($dbProfiles);
48
+	$container['profiler']->setDisplay(new Particletree\Pqp\Display());
49
+	$container['profiler']->display($container['db_connection_locator']->getRead());
50 50
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@
 block discarded – undo
34 34
         ->getRead()
35 35
         ->getProfiler()
36 36
         ->getProfiles();
37
-    $dbProfiles = array_filter($dbProfiles, function ($profile) {
37
+    $dbProfiles = array_filter($dbProfiles, function($profile) {
38 38
         return $profile['function'] == 'perform';
39 39
     });
40
-    $dbProfiles = array_map(function ($profile) {
40
+    $dbProfiles = array_map(function($profile) {
41 41
         return [
42 42
             'sql' => trim(preg_replace('/\s+/', ' ', $profile['statement'])),
43 43
             'parameters' => $profile['bind_values'],
Please login to merge, or discard this patch.
bootstrap.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 
8 8
 $handle = @fopen($config_path, 'r');
9 9
 if ($handle === false) {
10
-    throw new RuntimeException("Could not load config");
10
+	throw new RuntimeException("Could not load config");
11 11
 }
12 12
 $config = fread($handle, filesize($config_path));
13 13
 fclose($handle);
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 $config = json_decode($config);
16 16
 $last_json_error = json_last_error();
17 17
 if ($last_json_error !== JSON_ERROR_NONE) {
18
-    throw new RuntimeException("Could not parse config - JSON error detected");
18
+	throw new RuntimeException("Could not parse config - JSON error detected");
19 19
 }
20 20
 
21 21
 // timezones are fun
@@ -24,34 +24,34 @@  discard block
 block discarded – undo
24 24
 // configure the db connections holder
25 25
 $db_connections = new Aura\Sql\ConnectionLocator();
26 26
 $db_connections->setDefault(function () use ($config) {
27
-    $connection = $config->database->slave;
28
-    return new Aura\Sql\ExtendedPdo(
29
-        "mysql:host={$connection->host}",
30
-        $connection->user,
31
-        $connection->password
32
-    );
27
+	$connection = $config->database->slave;
28
+	return new Aura\Sql\ExtendedPdo(
29
+		"mysql:host={$connection->host}",
30
+		$connection->user,
31
+		$connection->password
32
+	);
33 33
 });
34 34
 $db_connections->setWrite('master', function () use ($config) {
35
-    $connection = $config->database->master;
36
-    return new Aura\Sql\ExtendedPdo(
37
-        "mysql:host={$connection->host}",
38
-        $connection->user,
39
-        $connection->password
40
-    );
35
+	$connection = $config->database->master;
36
+	return new Aura\Sql\ExtendedPdo(
37
+		"mysql:host={$connection->host}",
38
+		$connection->user,
39
+		$connection->password
40
+	);
41 41
 });
42 42
 $db_connections->setRead('slave', function () use ($config) {
43
-    $connection = $config->database->slave;
44
-    $pdo = new Aura\Sql\ExtendedPdo(
45
-        "mysql:host={$connection->host}",
46
-        $connection->user,
47
-        $connection->password
48
-    );
43
+	$connection = $config->database->slave;
44
+	$pdo = new Aura\Sql\ExtendedPdo(
45
+		"mysql:host={$connection->host}",
46
+		$connection->user,
47
+		$connection->password
48
+	);
49 49
 
50
-    $profiler = new Aura\Sql\Profiler();
51
-    $profiler->setActive(true);
52
-    $pdo->setProfiler($profiler);
50
+	$profiler = new Aura\Sql\Profiler();
51
+	$profiler->setActive(true);
52
+	$pdo->setProfiler($profiler);
53 53
 
54
-    return $pdo;
54
+	return $pdo;
55 55
 });
56 56
 
57 57
 // setup the profiler
Please login to merge, or discard this patch.
controller/PageController.class.inc.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         $post_result = $activityRepository->getActivities(5);
65 65
 
66 66
         $post_array = array();
67
-        foreach($post_result as $row) {
67
+        foreach ($post_result as $row) {
68 68
             array_push($post_array, $this->expand_post($row));
69 69
         }
70 70
 
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
 		$headers = $this->headers;
101 101
 		Header::$headers();
102 102
 		Loader::load('view', '/Head', $this->data_array['head']);
103
-		foreach($this->body_view_array as $view)
103
+		foreach ($this->body_view_array as $view)
104 104
 		{
105
-			if(substr($view, 0, 1) == '/')
105
+			if (substr($view, 0, 1) == '/')
106 106
 				Loader::load('view', $view, $this->data_array['body']);
107 107
 			else
108 108
 				Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']);
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
             Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE));
115 115
         }
116 116
 		
117
-		if($view == '/404' || $view == '/503')
117
+		if ($view == '/404' || $view == '/503')
118 118
 			exit;
119 119
 	}
120 120
 
@@ -170,14 +170,14 @@  discard block
 block discarded – undo
170 170
 
171 171
 	private function load_assets()
172 172
 	{
173
-    $css_array = array_map(function ($stylesheet) {
173
+    $css_array = array_map(function($stylesheet) {
174 174
       $path = "/css/{$stylesheet[0]}.css";
175 175
       if ($stylesheet[1] > 1) {
176 176
         $path .= "?v={$stylesheet[1]}";
177 177
       }
178 178
       return $path;
179 179
     }, $this->css_array);
180
-    $js_array = array_map(function ($script) {
180
+    $js_array = array_map(function($script) {
181 181
       if (substr($script, 0, 4) == 'http') {
182 182
         return $script;
183 183
       }
@@ -195,26 +195,26 @@  discard block
 block discarded – undo
195 195
 
196 196
 	protected function eject()
197 197
 	{
198
-		if(get_class($this) !== 'Error404Controller')
198
+		if (get_class($this) !== 'Error404Controller')
199 199
 			Loader::loadNew('controller', '/Error404Controller')->activate();
200 200
 	}
201 201
 
202 202
 	protected function unavailable()
203 203
 	{
204
-		if(get_class($this) !== 'Error503Controller')
204
+		if (get_class($this) !== 'Error503Controller')
205 205
 			Loader::loadNew('controller', '/Error503Controller')->activate();
206 206
 	}
207 207
 
208 208
 	protected function redirect($uri, $method = 301)
209 209
 	{
210
-		switch($method)
210
+		switch ($method)
211 211
 		{
212 212
 			case 301 :
213
-				if(get_class($this) !== 'Error301Controller')
213
+				if (get_class($this) !== 'Error301Controller')
214 214
 					Loader::loadNew('controller', '/Error301Controller', array($uri))->activate();
215 215
 				break;
216 216
 			case 303 :
217
-				if(get_class($this) !== 'Error303Controller')
217
+				if (get_class($this) !== 'Error303Controller')
218 218
 					Loader::loadNew('controller', '/Error303Controller', array($uri))->activate();
219 219
 				break;
220 220
 		}
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	private $comment_errors;
235 235
 	protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title)
236 236
 	{
237
-		if(Request::hasPost() && Request::getPost('submit') == 'Submit Comment')
237
+		if (Request::hasPost() && Request::getPost('submit') == 'Submit Comment')
238 238
 		{
239 239
 			$parameters = array($site_id, $path, $redirect_url, $page_title);
240 240
 			$this->comment_errors = Loader::loadNew('module', 'form/CommentSubmitModule', $parameters)->activate();
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 		$comment_array = array();
253 253
 		$comment_result = CommentCollector::getCommentsForURL($site, $path, $commenter->id);
254 254
 		
255
-		foreach($comment_result as $comment)
255
+		foreach ($comment_result as $comment)
256 256
 		{
257 257
 			$comment_object = new stdclass();
258 258
 			$comment_object->id = $comment->id;
@@ -262,12 +262,12 @@  discard block
 block discarded – undo
262 262
 			$comment_object->url = $comment->url;
263 263
 			$comment_object->trusted = $comment->trusted;
264 264
 			
265
-			if($comment->reply == 0 && Request::getPost('type') == $comment->id)
265
+			if ($comment->reply == 0 && Request::getPost('type') == $comment->id)
266 266
 				$comment_object->errors = $this->comment_errors;
267 267
 			else
268 268
 				$comment_object->errors = array();
269 269
 			
270
-			if($comment->reply == 0)
270
+			if ($comment->reply == 0)
271 271
 			{
272 272
 				$comment_object->replies = array();
273 273
 				$comment_array[$comment->id] = $comment_object;
@@ -298,21 +298,21 @@  discard block
 block discarded – undo
298 298
 		$commenter->website = '';
299 299
 		
300 300
 		$commenter_cookie = Cookie::instance('Commenter');
301
-		if(!$commenter_cookie->exists())
301
+		if (!$commenter_cookie->exists())
302 302
 			return $commenter;
303 303
 		
304 304
 		$commenter_cookie_value = $commenter_cookie->getValue();
305 305
 		$commenter_cookie_value = json_decode($commenter_cookie_value);
306 306
 		
307
-		if($commenter_cookie_value === NULL)
307
+		if ($commenter_cookie_value === NULL)
308 308
 			return $commenter;
309 309
 		
310
-		if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email))
310
+		if (!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email))
311 311
 			return $commenter;
312 312
 		
313 313
 		$commenter_object = CommentCollector::getCommenterByFields($commenter_cookie_value->name, $commenter_cookie_value->email, (isset($commenter_cookie_value->website) ? $commenter_cookie_value->website : ''));
314 314
 		
315
-		if($commenter_object === NULL)
315
+		if ($commenter_object === NULL)
316 316
 			return $commenter;
317 317
 		
318 318
 		$commenter->id = $commenter_object->id;
Please login to merge, or discard this patch.
Braces   +40 added lines, -29 removed lines patch added patch discarded remove patch
@@ -102,10 +102,11 @@  discard block
 block discarded – undo
102 102
 		Loader::load('view', '/Head', $this->data_array['head']);
103 103
 		foreach($this->body_view_array as $view)
104 104
 		{
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']);
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
+			}
109 110
 		}
110 111
         
111 112
         if (URLDecode::getSite() == 'waterfalls') {
@@ -114,8 +115,9 @@  discard block
 block discarded – undo
114 115
             Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE));
115 116
         }
116 117
 		
117
-		if($view == '/404' || $view == '/503')
118
-			exit;
118
+		if($view == '/404' || $view == '/503') {
119
+					exit;
120
+		}
119 121
 	}
120 122
 
121 123
 	protected function set_header_method($method)
@@ -195,14 +197,16 @@  discard block
 block discarded – undo
195 197
 
196 198
 	protected function eject()
197 199
 	{
198
-		if(get_class($this) !== 'Error404Controller')
199
-			Loader::loadNew('controller', '/Error404Controller')->activate();
200
+		if(get_class($this) !== 'Error404Controller') {
201
+					Loader::loadNew('controller', '/Error404Controller')->activate();
202
+		}
200 203
 	}
201 204
 
202 205
 	protected function unavailable()
203 206
 	{
204
-		if(get_class($this) !== 'Error503Controller')
205
-			Loader::loadNew('controller', '/Error503Controller')->activate();
207
+		if(get_class($this) !== 'Error503Controller') {
208
+					Loader::loadNew('controller', '/Error503Controller')->activate();
209
+		}
206 210
 	}
207 211
 
208 212
 	protected function redirect($uri, $method = 301)
@@ -210,12 +214,14 @@  discard block
 block discarded – undo
210 214
 		switch($method)
211 215
 		{
212 216
 			case 301 :
213
-				if(get_class($this) !== 'Error301Controller')
214
-					Loader::loadNew('controller', '/Error301Controller', array($uri))->activate();
217
+				if(get_class($this) !== 'Error301Controller') {
218
+									Loader::loadNew('controller', '/Error301Controller', array($uri))->activate();
219
+				}
215 220
 				break;
216 221
 			case 303 :
217
-				if(get_class($this) !== 'Error303Controller')
218
-					Loader::loadNew('controller', '/Error303Controller', array($uri))->activate();
222
+				if(get_class($this) !== 'Error303Controller') {
223
+									Loader::loadNew('controller', '/Error303Controller', array($uri))->activate();
224
+				}
219 225
 				break;
220 226
 		}
221 227
 	}
@@ -262,18 +268,19 @@  discard block
 block discarded – undo
262 268
 			$comment_object->url = $comment->url;
263 269
 			$comment_object->trusted = $comment->trusted;
264 270
 			
265
-			if($comment->reply == 0 && Request::getPost('type') == $comment->id)
266
-				$comment_object->errors = $this->comment_errors;
267
-			else
268
-				$comment_object->errors = array();
271
+			if($comment->reply == 0 && Request::getPost('type') == $comment->id) {
272
+							$comment_object->errors = $this->comment_errors;
273
+			} else {
274
+							$comment_object->errors = array();
275
+			}
269 276
 			
270 277
 			if($comment->reply == 0)
271 278
 			{
272 279
 				$comment_object->replies = array();
273 280
 				$comment_array[$comment->id] = $comment_object;
274
-			}
275
-			else
276
-				$comment_array[$comment->reply]->replies[$comment->id] = $comment_object;
281
+			} else {
282
+							$comment_array[$comment->reply]->replies[$comment->id] = $comment_object;
283
+			}
277 284
 		}
278 285
 		
279 286
 		$comment_count = CommentCollector::getCommentCountForURL($site, $path);
@@ -298,22 +305,26 @@  discard block
 block discarded – undo
298 305
 		$commenter->website = '';
299 306
 		
300 307
 		$commenter_cookie = Cookie::instance('Commenter');
301
-		if(!$commenter_cookie->exists())
302
-			return $commenter;
308
+		if(!$commenter_cookie->exists()) {
309
+					return $commenter;
310
+		}
303 311
 		
304 312
 		$commenter_cookie_value = $commenter_cookie->getValue();
305 313
 		$commenter_cookie_value = json_decode($commenter_cookie_value);
306 314
 		
307
-		if($commenter_cookie_value === NULL)
308
-			return $commenter;
315
+		if($commenter_cookie_value === NULL) {
316
+					return $commenter;
317
+		}
309 318
 		
310
-		if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email))
311
-			return $commenter;
319
+		if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) {
320
+					return $commenter;
321
+		}
312 322
 		
313 323
 		$commenter_object = CommentCollector::getCommenterByFields($commenter_cookie_value->name, $commenter_cookie_value->email, (isset($commenter_cookie_value->website) ? $commenter_cookie_value->website : ''));
314 324
 		
315
-		if($commenter_object === NULL)
316
-			return $commenter;
325
+		if($commenter_object === NULL) {
326
+					return $commenter;
327
+		}
317 328
 		
318 329
 		$commenter->id = $commenter_object->id;
319 330
 		$commenter->name = $commenter_object->name;
Please login to merge, or discard this patch.