Completed
Push — master ( acb423...2a302c )
by Jacob
03:45
created
collector/comment/CommentCollector.class.inc.php 1 patch
Braces   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -2,11 +2,11 @@  discard block
 block discarded – undo
2 2
 
3 3
 Loader::load('collector', 'Collector');
4 4
 
5
-final class CommentCollector extends Collector
6
-{
5
+final class CommentCollector extends Collector
6
+{
7 7
 
8
-	public static function getCommenterByFields($name, $email, $website)
9
-	{
8
+	public static function getCommenterByFields($name, $email, $website)
9
+	{
10 10
 		$name = self::escape($name);
11 11
 		$email = self::escape($email);
12 12
 		$website = self::escape($website);
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 		return self::run_row_query($query);
26 26
 	}
27 27
 
28
-	public static function getCommentByBody($body)
29
-	{
28
+	public static function getCommentByBody($body)
29
+	{
30 30
 		$body = self::escape($body);
31 31
 		
32 32
 		$query = "
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 		return self::run_row_query($query);
42 42
 	}
43 43
 
44
-	public static function getCommentPageByURL($path, $site)
45
-	{
44
+	public static function getCommentPageByURL($path, $site)
45
+	{
46 46
 		$path = self::escape($path);
47 47
 		
48 48
 		$query = "
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 		return self::run_row_query($query);
60 60
 	}
61 61
 
62
-	public static function getNotificationForPage($comment_page)
63
-	{
62
+	public static function getNotificationForPage($comment_page)
63
+	{
64 64
 		$query = "
65 65
 			SELECT
66 66
 				`name`,
Please login to merge, or discard this patch.
controller/PageController.class.inc.php 1 patch
Braces   +77 added lines, -65 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 Loader::load('utility', 'Header');
4 4
 
5
-abstract class PageController
6
-{
5
+abstract class PageController
6
+{
7 7
 
8 8
 	private static $TRACKING_CODE = 'UA-11745070-1';
9 9
 	
@@ -20,12 +20,18 @@  discard block
 block discarded – undo
20 20
 	private $data_array = array();
21 21
 	private $body_view_array = array();
22 22
 
23
-	protected function set_head_data() {}
24
-	protected function set_body_data() {}
25
-	protected function set_data() {}
23
+	protected function set_head_data()
24
+	{
25
+}
26
+	protected function set_body_data()
27
+	{
28
+}
29
+	protected function set_data()
30
+	{
31
+}
26 32
 
27
-	public function __construct()
28
-	{
33
+	public function __construct()
34
+	{
29 35
 		$this->set_header_method('sendHTML');
30 36
 		
31 37
 		$this->set_head('google_verification', 'sgAISiuoWfK54KXnOfm2oU4vQdad8eyNCQX7LkZ1OxM');
@@ -38,8 +44,8 @@  discard block
 block discarded – undo
38 44
 			'date' => date('Y')));
39 45
 	}
40 46
 
41
-	protected function get_domain_container()
42
-	{
47
+	protected function get_domain_container()
48
+	{
43 49
 		$domain_container = new stdclass();
44 50
 		
45 51
 		$domain_container->blog = Loader::getRootUrl('blog');
@@ -52,8 +58,8 @@  discard block
 block discarded – undo
52 58
 		return $domain_container;
53 59
 	}
54 60
 
55
-    protected function get_recent_activity()
56
-    {
61
+    protected function get_recent_activity()
62
+    {
57 63
         global $container;
58 64
         $activityRepository = new Jacobemerick\Web\Domain\Stream\Activity\MysqlActivityRepository($container['db_connection_locator']);
59 65
         $post_result = $activityRepository->getActivities(5);
@@ -66,8 +72,8 @@  discard block
 block discarded – undo
66 72
         return $post_array;
67 73
     }
68 74
 
69
-    protected function expand_post($raw_post, $format = 'short')
70
-    {
75
+    protected function expand_post($raw_post, $format = 'short')
76
+    {
71 77
         $post = [
72 78
             'type' => $raw_post['type'],
73 79
             'title' => ($format == 'short') ? $raw_post['message'] : $raw_post['message_long'],
@@ -84,8 +90,8 @@  discard block
 block discarded – undo
84 90
         return (object) $post;
85 91
     }
86 92
 
87
-	public function activate()
88
-	{
93
+	public function activate()
94
+	{
89 95
 		$this->set_head_data();
90 96
 		$this->set_body_data();
91 97
 		$this->set_data();
@@ -97,10 +103,11 @@  discard block
 block discarded – undo
97 103
 		Loader::load('view', '/Head', $this->data_array['head']);
98 104
 		foreach($this->body_view_array as $view)
99 105
 		{
100
-			if(substr($view, 0, 1) == '/')
101
-				Loader::load('view', $view, $this->data_array['body']);
102
-			else
103
-				Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']);
106
+			if(substr($view, 0, 1) == '/') {
107
+							Loader::load('view', $view, $this->data_array['body']);
108
+			} else {
109
+							Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']);
110
+			}
104 111
 		}
105 112
         
106 113
         if (URLDecode::getSite() == 'waterfalls') {
@@ -109,62 +116,63 @@  discard block
 block discarded – undo
109 116
             Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE));
110 117
         }
111 118
 		
112
-		if($view == '/404' || $view == '/503')
113
-			exit;
119
+		if($view == '/404' || $view == '/503') {
120
+					exit;
121
+		}
114 122
 	}
115 123
 
116
-	protected function set_header_method($method)
117
-	{
124
+	protected function set_header_method($method)
125
+	{
118 126
 		$this->headers = $method;
119 127
 	}
120 128
 
121
-	protected function set_title($value)
122
-	{
129
+	protected function set_title($value)
130
+	{
123 131
 		$this->set_head('title', $value);
124 132
 	}
125 133
 
126
-	protected function set_author($value)
127
-	{
134
+	protected function set_author($value)
135
+	{
128 136
 		$this->set_head('author', $value);
129 137
 	}
130 138
 
131
-	protected function set_description($value)
132
-	{
139
+	protected function set_description($value)
140
+	{
133 141
 		$this->set_head('description', $value);
134 142
 	}
135 143
 
136
-	protected function set_keywords($array)
137
-	{
144
+	protected function set_keywords($array)
145
+	{
138 146
 		$this->set_head('keywords', implode(', ', $array));
139 147
 	}
140 148
 	
141
-	protected function set_canonical($url)
142
-	{
149
+	protected function set_canonical($url)
150
+	{
143 151
 		$this->set_head('canonical', $url);
144 152
 	}
145 153
 
146
-	protected function set_head($set, $value)
147
-	{
154
+	protected function set_head($set, $value)
155
+	{
148 156
 		$this->data_array['head'][$set] = $value;
149 157
 	}
150 158
 
151
-	protected function set_body($set, $value)
152
-	{
159
+	protected function set_body($set, $value)
160
+	{
153 161
 		$this->data_array['body'][$set] = $value;
154 162
 	}
155 163
 
156
-	protected function add_css($file, $version = 1)
157
-	{
164
+	protected function add_css($file, $version = 1)
165
+	{
158 166
 		$this->css_array[] = [$file, $version];
159 167
 	}
160 168
 
161
-	protected function add_js($file)
162
-	{
169
+	protected function add_js($file)
170
+	{
163 171
 		$this->js_array[] = $file;
164 172
 	}
165 173
 
166
-	private function load_assets()
167
-	{
174
+	private function load_assets()
175
+	{
168 176
     $css_array = array_map(function ($stylesheet) {
169 177
       $path = "/css/{$stylesheet[0]}.css";
170 178
       if ($stylesheet[1] > 1) {
@@ -183,40 +191,44 @@  discard block
 block discarded – undo
183 191
 		$this->set_head('js_link_array', $js_array);
184 192
 	}
185 193
 
186
-	protected function set_body_view($view)
187
-	{
194
+	protected function set_body_view($view)
195
+	{
188 196
 		$this->body_view_array[] = $view;
189 197
 	}
190 198
 
191
-	protected function eject()
192
-	{
193
-		if(get_class($this) !== 'Error404Controller')
194
-			Loader::loadNew('controller', '/Error404Controller')->activate();
199
+	protected function eject()
200
+	{
201
+		if(get_class($this) !== 'Error404Controller') {
202
+					Loader::loadNew('controller', '/Error404Controller')->activate();
203
+		}
195 204
 	}
196 205
 
197
-	protected function unavailable()
198
-	{
199
-		if(get_class($this) !== 'Error503Controller')
200
-			Loader::loadNew('controller', '/Error503Controller')->activate();
206
+	protected function unavailable()
207
+	{
208
+		if(get_class($this) !== 'Error503Controller') {
209
+					Loader::loadNew('controller', '/Error503Controller')->activate();
210
+		}
201 211
 	}
202 212
 
203
-	protected function redirect($uri, $method = 301)
204
-	{
213
+	protected function redirect($uri, $method = 301)
214
+	{
205 215
 		switch($method)
206 216
 		{
207 217
 			case 301 :
208
-				if(get_class($this) !== 'Error301Controller')
209
-					Loader::loadNew('controller', '/Error301Controller', array($uri))->activate();
218
+				if(get_class($this) !== 'Error301Controller') {
219
+									Loader::loadNew('controller', '/Error301Controller', array($uri))->activate();
220
+				}
210 221
 				break;
211 222
 			case 303 :
212
-				if(get_class($this) !== 'Error303Controller')
213
-					Loader::loadNew('controller', '/Error303Controller', array($uri))->activate();
223
+				if(get_class($this) !== 'Error303Controller') {
224
+									Loader::loadNew('controller', '/Error303Controller', array($uri))->activate();
225
+				}
214 226
 				break;
215 227
 		}
216 228
 	}
217 229
 
218
-	final protected function get_parsed_date($date)
219
-	{
230
+	final protected function get_parsed_date($date)
231
+	{
220 232
 		$parsed_date = new stdclass();
221 233
 		
222 234
 		$parsed_date->stamp = date('c', strtotime($date));
@@ -227,8 +239,8 @@  discard block
 block discarded – undo
227 239
 	}
228 240
 
229 241
 	private $comment_errors;
230
-	protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title)
231
-	{
242
+	protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title)
243
+	{
232 244
 		if(Request::hasPost() && Request::getPost('submit') == 'Submit Comment')
233 245
 		{
234 246
 			$parameters = array($site_id, $path, $redirect_url, $page_title);
@@ -238,8 +250,8 @@  discard block
 block discarded – undo
238 250
 		return;
239 251
 	}
240 252
 
241
-    protected function get_comment_array($site, $path)
242
-    {
253
+    protected function get_comment_array($site, $path)
254
+    {
243 255
         global $container;
244 256
         $repository = new Jacobemerick\Web\Domain\Comment\Comment\ServiceCommentRepository($container['comment_service_api']);
245 257
         $start = microtime(true);
Please login to merge, or discard this patch.
controller/blog/PostController.class.inc.php 1 patch
Braces   +30 added lines, -26 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 Loader::load('collector', 'waterfall/LogCollector');
4 4
 Loader::load('controller', 'blog/DefaultPageController');
5 5
 
6
-final class PostController extends DefaultPageController
7
-{
6
+final class PostController extends DefaultPageController
7
+{
8 8
 
9 9
 	private static $PAGE_DESCRIPTION_LIMIT = 250;
10 10
 
@@ -19,16 +19,17 @@  discard block
 block discarded – undo
19 19
 	private $tags;
20 20
 	private $comment_errors = array();
21 21
 
22
-	public function __construct()
23
-	{
22
+	public function __construct()
23
+	{
24 24
 		parent::__construct();
25 25
 		
26 26
         global $container;
27 27
         $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
28 28
         $this->post = $repository->findPostByPath(URLDecode::getPiece(2));
29 29
 
30
-		if($this->post == null)
31
-			$this->eject();
30
+		if($this->post == null) {
31
+					$this->eject();
32
+		}
32 33
 		
33 34
 		$this->handle_comment_submit(
34 35
 			self::$BLOG_SITE_ID,
@@ -41,8 +42,8 @@  discard block
 block discarded – undo
41 42
         $this->tags = $repository->getTagsForPost($this->post['id']);
42 43
 	}
43 44
 
44
-	protected function set_head_data()
45
-	{
45
+	protected function set_head_data()
46
+	{
46 47
 		parent::set_head_data();
47 48
 		
48 49
 		$this->set_title(sprintf(self::$TITLE, $this->post['title']));
@@ -64,10 +65,12 @@  discard block
 block discarded – undo
64 65
 		}
65 66
 	}
66 67
 
67
-	protected function get_introduction() {}
68
+	protected function get_introduction()
69
+	{
70
+}
68 71
 
69
-	protected function set_body_data()
70
-	{
72
+	protected function set_body_data()
73
+	{
71 74
 		parent::set_body_data();
72 75
 		
73 76
 		$this->set_body('title', $this->post['title']);
@@ -85,8 +88,8 @@  discard block
 block discarded – undo
85 88
     ));
86 89
 	}
87 90
 
88
-	protected function get_post_description()
89
-	{
91
+	protected function get_post_description()
92
+	{
90 93
 		$description = $this->post['body'];
91 94
 		$description = strip_tags($description);
92 95
 		$description = Content::instance('SmartTrim', $description)->activate(self::$PAGE_DESCRIPTION_LIMIT);
@@ -94,8 +97,8 @@  discard block
 block discarded – undo
94 97
 		return $description;
95 98
 	}
96 99
 
97
-	protected function get_post_keywords()
98
-	{
100
+	protected function get_post_keywords()
101
+	{
99 102
 		$keyword_array = array();
100 103
 		$keywords = $this->tags;
101 104
 		
@@ -110,11 +113,12 @@  discard block
 block discarded – undo
110 113
 		return $keyword_array;
111 114
 	}
112 115
 
113
-	private function get_series_posts()
114
-	{
116
+	private function get_series_posts()
117
+	{
115 118
 		$series_posts = $this->fetch_series_posts();
116
-		if(count($series_posts) < 1)
117
-			return array();
119
+		if(count($series_posts) < 1) {
120
+					return array();
121
+		}
118 122
 		
119 123
 		$previous_post = new stdclass();
120 124
 		$next_post = new stdclass();
@@ -153,9 +157,9 @@  discard block
 block discarded – undo
153 157
 
154 158
 			$post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/";
155 159
 			
156
-			if(!$found_current_post)
157
-				$previous_post = $post;
158
-			else
160
+			if(!$found_current_post) {
161
+							$previous_post = $post;
162
+			} else
159 163
 			{
160 164
 				$next_post = $post;
161 165
 				break;
@@ -170,8 +174,8 @@  discard block
 block discarded – undo
170 174
 	}
171 175
 
172 176
 	private $series_posts;
173
-	private function fetch_series_posts()
174
-	{
177
+	private function fetch_series_posts()
178
+	{
175 179
       if(!isset($this->series_posts)) {
176 180
           global $container;
177 181
           $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']);
@@ -180,8 +184,8 @@  discard block
 block discarded – undo
180 184
       return $this->series_posts;
181 185
 	}
182 186
 
183
-	private function get_related_posts()
184
-	{
187
+	private function get_related_posts()
188
+	{
185 189
 		$tag_array = array();
186 190
 		foreach($this->tags as $tag)
187 191
 		{
Please login to merge, or discard this patch.
controller/blog/DefaultPageController.class.inc.php 1 patch
Braces   +36 added lines, -32 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 Loader::load('controller', '/PageController');
4 4
 Loader::load('utility', 'Content');
5 5
 
6
-abstract class DefaultPageController extends PageController
7
-{
6
+abstract class DefaultPageController extends PageController
7
+{
8 8
 
9 9
 	private static $RECENT_COMMENT_COUNT = 10;
10 10
 	private static $MINIMUM_TAG_COUNT = 10;
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
 
15 15
 	private static $INTRODUCTION_IMAGE_PATTERN = '<img src="/photo/%s/%s-size-%s.jpg" height="%d" width="%d" alt="%s" />';
16 16
 
17
-	protected function set_head_data()
18
-	{
17
+	protected function set_head_data()
18
+	{
19 19
     $this->set_head('rss_link', [
20 20
       'title' => 'Jacob Emerick Blog Feed',
21 21
       'url' => '/rss.xml'
@@ -29,18 +29,19 @@  discard block
 block discarded – undo
29 29
 		$this->add_css('blog');
30 30
 	}
31 31
 
32
-	protected function get_introduction()
33
-	{
32
+	protected function get_introduction()
33
+	{
34 34
 		return;
35 35
 	}
36 36
 
37
-	protected function get_introduction_image($id)
38
-	{
37
+	protected function get_introduction_image($id)
38
+	{
39 39
 		Loader::load('collector', 'image/PhotoCollector');
40 40
 		$photo_result = PhotoCollector::getRow($id);
41 41
 		
42
-		if($photo_result == null)
43
-			return;
42
+		if($photo_result == null) {
43
+					return;
44
+		}
44 45
 		
45 46
 		$name = $photo_result->name;
46 47
 		$category = $photo_result->category;
@@ -52,8 +53,8 @@  discard block
 block discarded – undo
52 53
 		return sprintf(self::$INTRODUCTION_IMAGE_PATTERN, $category, $name, $size, $height, $width, $description);
53 54
 	}
54 55
 
55
-	protected function set_body_data()
56
-	{
56
+	protected function set_body_data()
57
+	{
57 58
 		$this->set_body('introduction', $this->get_introduction());
58 59
 		$this->set_body('right_side', $this->get_right_side());
59 60
 		$this->set_body('activity_array', $this->get_recent_activity());
@@ -61,8 +62,8 @@  discard block
 block discarded – undo
61 62
 		$this->set_body_view('Page');
62 63
 	}
63 64
 
64
-	final protected function format_post($post, $trim = false)
65
-	{
65
+	final protected function format_post($post, $trim = false)
66
+	{
66 67
 		$post_object = new stdclass();
67 68
 		
68 69
 		$post_object->title = $post['title'];
@@ -77,8 +78,8 @@  discard block
 block discarded – undo
77 78
 		return $post_object;
78 79
 	}
79 80
 
80
-	final private function get_tags_for_post($post)
81
-	{
81
+	final private function get_tags_for_post($post)
82
+	{
82 83
         global $container;
83 84
         $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']);
84 85
         $tag_result = $repository->getTagsForPost($post['id']);
@@ -94,12 +95,13 @@  discard block
 block discarded – undo
94 95
 		return $tag_array;
95 96
 	}
96 97
 
97
-	final private function get_body_for_post($post, $trim)
98
-	{
98
+	final private function get_body_for_post($post, $trim)
99
+	{
99 100
 		$body = $post['body'];
100 101
 		
101
-		if($trim)
102
-			$body = Content::instance('SmartTrim', $body)->activate(self::$LENGTH_OF_TRIMMED_POST);
102
+		if($trim) {
103
+					$body = Content::instance('SmartTrim', $body)->activate(self::$LENGTH_OF_TRIMMED_POST);
104
+		}
103 105
 		
104 106
 		$body = Content::instance('FixPhoto', $body)->activate(false, 'standard');
105 107
 		$body = Content::instance('MarkupCode', $body)->activate();
@@ -107,16 +109,16 @@  discard block
 block discarded – undo
107 109
 		return $body;
108 110
 	}
109 111
 
110
-	final protected function get_right_side()
111
-	{
112
+	final protected function get_right_side()
113
+	{
112 114
 		$side_array = array();
113 115
 		$side_array['tags'] = $this->get_tag_cloud();
114 116
 		$side_array['comments'] = $this->get_comments();
115 117
 		return $side_array;
116 118
 	}
117 119
 
118
-	final private function get_tag_cloud()
119
-	{
120
+	final private function get_tag_cloud()
121
+	{
120 122
         global $container;
121 123
         $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']);
122 124
         $tag_result = $repository->getTagCloud();
@@ -126,8 +128,9 @@  discard block
 block discarded – undo
126 128
 		$cloud_array = array();
127 129
 		foreach($tag_result as $tag)
128 130
 		{
129
-			if($tag['count'] < self::$MINIMUM_TAG_COUNT)
130
-				continue;
131
+			if($tag['count'] < self::$MINIMUM_TAG_COUNT) {
132
+							continue;
133
+			}
131 134
 			
132 135
 			$tag_object = new stdclass();
133 136
 			$tag_object->name = $tag['tag'];
@@ -139,20 +142,21 @@  discard block
 block discarded – undo
139 142
 		return $cloud_array;
140 143
 	}
141 144
 
142
-	final private function get_maximum_tag_count($tag_result)
143
-	{
145
+	final private function get_maximum_tag_count($tag_result)
146
+	{
144 147
 		$maximum = 1;
145 148
 		
146 149
 		foreach($tag_result as $tag)
147 150
 		{
148
-			if($tag['count'] > $maximum)
149
-				$maximum = $tag['count'];
151
+			if($tag['count'] > $maximum) {
152
+							$maximum = $tag['count'];
153
+			}
150 154
 		}
151 155
 		return $maximum;
152 156
 	}
153 157
 
154
-    final private function get_comments()
155
-    {
158
+    final private function get_comments()
159
+    {
156 160
         global $container;
157 161
         $repository = new Jacobemerick\Web\Domain\Comment\Comment\ServiceCommentRepository($container['comment_service_api']);
158 162
         $start = microtime(true);
Please login to merge, or discard this patch.
controller/waterfalls/HomeController.class.inc.php 1 patch
Braces   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@  discard block
 block discarded – undo
6 6
 ));
7 7
 Loader::load('controller', 'waterfalls/DefaultPageController');
8 8
 
9
-final class HomeController extends DefaultPageController
10
-{
9
+final class HomeController extends DefaultPageController
10
+{
11 11
 
12 12
     private static $TITLE = 'Waterfalls of the Keweenaw | Stories and Tips from Jacob Emerick';
13 13
     private static $DESCRIPTION = 'Stories, maps, and details about many of the waterfalls in the Upper Peninsula of Michigan, compiled by Jacob Emerick.';
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 
21 21
     private static $BANNER_IMAGE = 2661;
22 22
 
23
-    protected function set_head_data()
24
-    {
23
+    protected function set_head_data()
24
+    {
25 25
         parent::set_head_data();
26 26
         
27 27
         $this->set_title(self::$TITLE);
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
         $this->set_keywords(self::$KEYWORD_ARRAY);
30 30
     }
31 31
 
32
-    protected function set_body_data($page_type = 'wide')
33
-    {
32
+    protected function set_body_data($page_type = 'wide')
33
+    {
34 34
         parent::set_body_data($page_type);
35 35
         
36 36
         $photo = PhotoCollector::getRow(self::$BANNER_IMAGE);
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
         $this->set_body('view', 'Home');
60 60
     }
61 61
 
62
-    protected function get_comments()
63
-    {
62
+    protected function get_comments()
63
+    {
64 64
         global $container;
65 65
         $repository = new Jacobemerick\Web\Domain\Comment\Comment\ServiceCommentRepository($container['comment_service_api']);
66 66
         $start = microtime(true);
Please login to merge, or discard this patch.