@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | |
19 | 19 | protected function set_head_data() |
20 | 20 | { |
21 | - $this->set_head('rss_link', [ |
|
22 | - 'title' => 'Jacob Emerick Blog Feed', |
|
23 | - 'url' => '/rss.xml' |
|
24 | - ]); |
|
25 | - $this->set_head('rss_comment_link', [ |
|
26 | - 'title' => 'Jacob Emerick Blog Comment Feed', |
|
27 | - 'url' => '/rss-comments.xml' |
|
28 | - ]); |
|
21 | + $this->set_head('rss_link', [ |
|
22 | + 'title' => 'Jacob Emerick Blog Feed', |
|
23 | + 'url' => '/rss.xml' |
|
24 | + ]); |
|
25 | + $this->set_head('rss_comment_link', [ |
|
26 | + 'title' => 'Jacob Emerick Blog Comment Feed', |
|
27 | + 'url' => '/rss-comments.xml' |
|
28 | + ]); |
|
29 | 29 | |
30 | 30 | $this->add_css('normalize'); |
31 | 31 | $this->add_css('blog'); |
@@ -83,57 +83,57 @@ discard block |
||
83 | 83 | final private function get_comments_for_post($post) |
84 | 84 | { |
85 | 85 | $count = CommentCollector::getCommentCountForURL(self::$BLOG_SITE_ID, $post['path']); |
86 | - $count_from_service = $this->get_comments_for_post_from_service($post); |
|
87 | - |
|
88 | - if ($count_from_service !== null && $count_from_service != $count) { |
|
89 | - global $container; |
|
90 | - $container['console']->log('Mismatch between comment service and legacy db'); |
|
91 | - $container['console']->log("{$count}, {$count_from_service} in service"); |
|
92 | - } |
|
93 | - return $count; |
|
86 | + $count_from_service = $this->get_comments_for_post_from_service($post); |
|
87 | + |
|
88 | + if ($count_from_service !== null && $count_from_service != $count) { |
|
89 | + global $container; |
|
90 | + $container['console']->log('Mismatch between comment service and legacy db'); |
|
91 | + $container['console']->log("{$count}, {$count_from_service} in service"); |
|
92 | + } |
|
93 | + return $count; |
|
94 | 94 | } |
95 | 95 | |
96 | - final private function get_comments_for_post_from_service($post) |
|
97 | - { |
|
98 | - global $config; |
|
99 | - $configuration = new Jacobemerick\CommentService\Configuration(); |
|
100 | - $configuration->setUsername($config->comments->user); |
|
101 | - $configuration->setPassword($config->comments->password); |
|
102 | - $configuration->addDefaultHeader('Content-Type', 'application/json'); |
|
103 | - $configuration->setHost($config->comments->host); |
|
104 | - $configuration->setCurlTimeout($config->comments->timeout); |
|
105 | - |
|
106 | - $client = new Jacobemerick\CommentService\ApiClient($configuration); |
|
107 | - $api = new Jacobemerick\CommentService\Api\DefaultApi($client); |
|
108 | - |
|
109 | - $start = microtime(true); |
|
110 | - try { |
|
111 | - $comment_response = $api->getComments( |
|
112 | - null, |
|
113 | - null, |
|
114 | - null, |
|
115 | - 'blog.jacobemerick.com', |
|
116 | - "{$post['category']}/{$post['path']}" |
|
117 | - ); |
|
118 | - } catch (Exception $e) { |
|
119 | - global $container; |
|
120 | - $container['logger']->warning("CommentService | Comment Count | {$e->getMessage()}"); |
|
121 | - return; |
|
122 | - } |
|
123 | - $elapsed = microtime(true) - $start; |
|
124 | - global $container; |
|
125 | - $container['logger']->info("CommentService | Comment Count | {$elapsed}"); |
|
126 | - |
|
127 | - return count($comment_response); |
|
128 | - } |
|
96 | + final private function get_comments_for_post_from_service($post) |
|
97 | + { |
|
98 | + global $config; |
|
99 | + $configuration = new Jacobemerick\CommentService\Configuration(); |
|
100 | + $configuration->setUsername($config->comments->user); |
|
101 | + $configuration->setPassword($config->comments->password); |
|
102 | + $configuration->addDefaultHeader('Content-Type', 'application/json'); |
|
103 | + $configuration->setHost($config->comments->host); |
|
104 | + $configuration->setCurlTimeout($config->comments->timeout); |
|
105 | + |
|
106 | + $client = new Jacobemerick\CommentService\ApiClient($configuration); |
|
107 | + $api = new Jacobemerick\CommentService\Api\DefaultApi($client); |
|
108 | + |
|
109 | + $start = microtime(true); |
|
110 | + try { |
|
111 | + $comment_response = $api->getComments( |
|
112 | + null, |
|
113 | + null, |
|
114 | + null, |
|
115 | + 'blog.jacobemerick.com', |
|
116 | + "{$post['category']}/{$post['path']}" |
|
117 | + ); |
|
118 | + } catch (Exception $e) { |
|
119 | + global $container; |
|
120 | + $container['logger']->warning("CommentService | Comment Count | {$e->getMessage()}"); |
|
121 | + return; |
|
122 | + } |
|
123 | + $elapsed = microtime(true) - $start; |
|
124 | + global $container; |
|
125 | + $container['logger']->info("CommentService | Comment Count | {$elapsed}"); |
|
126 | + |
|
127 | + return count($comment_response); |
|
128 | + } |
|
129 | 129 | |
130 | 130 | final private function get_tags_for_post($post) |
131 | 131 | { |
132 | - global $container; |
|
133 | - $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
|
134 | - $tag_result = $repository->getTagsForPost($post['id']); |
|
132 | + global $container; |
|
133 | + $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
|
134 | + $tag_result = $repository->getTagsForPost($post['id']); |
|
135 | 135 | |
136 | - $tag_array = array(); |
|
136 | + $tag_array = array(); |
|
137 | 137 | foreach($tag_result as $tag) |
138 | 138 | { |
139 | 139 | $tag_object = new stdclass(); |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | |
168 | 168 | final private function get_tag_cloud() |
169 | 169 | { |
170 | - global $container; |
|
171 | - $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
|
172 | - $tag_result = $repository->getTagCloud(); |
|
170 | + global $container; |
|
171 | + $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
|
172 | + $tag_result = $repository->getTagCloud(); |
|
173 | 173 | |
174 | 174 | $maximum_tag_count = $this->get_maximum_tag_count($tag_result); |
175 | 175 | |
@@ -218,61 +218,61 @@ discard block |
||
218 | 218 | $array[] = $comment_obj; |
219 | 219 | } |
220 | 220 | |
221 | - $comment_service_array = $this->get_comments_from_service(); |
|
222 | - if ($comment_service_array !== null && $comment_service_array !== $array) { |
|
223 | - global $container; |
|
224 | - $container['console']->log('Mismatch between comment service and legacy db'); |
|
225 | - $container['console']->log($comment_service_array[0]); |
|
226 | - $container['console']->log($array[0]); |
|
227 | - } |
|
221 | + $comment_service_array = $this->get_comments_from_service(); |
|
222 | + if ($comment_service_array !== null && $comment_service_array !== $array) { |
|
223 | + global $container; |
|
224 | + $container['console']->log('Mismatch between comment service and legacy db'); |
|
225 | + $container['console']->log($comment_service_array[0]); |
|
226 | + $container['console']->log($array[0]); |
|
227 | + } |
|
228 | 228 | return $array; |
229 | 229 | } |
230 | 230 | |
231 | - final private function get_comments_from_service() |
|
232 | - { |
|
233 | - global $config; |
|
234 | - $configuration = new Jacobemerick\CommentService\Configuration(); |
|
235 | - $configuration->setUsername($config->comments->user); |
|
236 | - $configuration->setPassword($config->comments->password); |
|
237 | - $configuration->addDefaultHeader('Content-Type', 'application/json'); |
|
238 | - $configuration->setHost($config->comments->host); |
|
239 | - $configuration->setCurlTimeout($config->comments->timeout); |
|
240 | - |
|
241 | - $client = new Jacobemerick\CommentService\ApiClient($configuration); |
|
242 | - $api = new Jacobemerick\CommentService\Api\DefaultApi($client); |
|
243 | - |
|
244 | - $start = microtime(true); |
|
245 | - try { |
|
246 | - $comment_response = $api->getComments( |
|
247 | - 1, |
|
248 | - self::$RECENT_COMMENT_COUNT, |
|
249 | - '-date', |
|
250 | - 'blog.jacobemerick.com' |
|
251 | - ); |
|
252 | - } catch (Exception $e) { |
|
253 | - global $container; |
|
254 | - $container['logger']->warning("CommentService | Sidebar | {$e->getMessage()}"); |
|
255 | - return; |
|
256 | - } |
|
231 | + final private function get_comments_from_service() |
|
232 | + { |
|
233 | + global $config; |
|
234 | + $configuration = new Jacobemerick\CommentService\Configuration(); |
|
235 | + $configuration->setUsername($config->comments->user); |
|
236 | + $configuration->setPassword($config->comments->password); |
|
237 | + $configuration->addDefaultHeader('Content-Type', 'application/json'); |
|
238 | + $configuration->setHost($config->comments->host); |
|
239 | + $configuration->setCurlTimeout($config->comments->timeout); |
|
240 | + |
|
241 | + $client = new Jacobemerick\CommentService\ApiClient($configuration); |
|
242 | + $api = new Jacobemerick\CommentService\Api\DefaultApi($client); |
|
243 | + |
|
244 | + $start = microtime(true); |
|
245 | + try { |
|
246 | + $comment_response = $api->getComments( |
|
247 | + 1, |
|
248 | + self::$RECENT_COMMENT_COUNT, |
|
249 | + '-date', |
|
250 | + 'blog.jacobemerick.com' |
|
251 | + ); |
|
252 | + } catch (Exception $e) { |
|
253 | + global $container; |
|
254 | + $container['logger']->warning("CommentService | Sidebar | {$e->getMessage()}"); |
|
255 | + return; |
|
256 | + } |
|
257 | 257 | |
258 | - $elapsed = microtime(true) - $start; |
|
259 | - global $container; |
|
260 | - $container['logger']->info("CommentService | Sidebar | {$elapsed}"); |
|
261 | - |
|
262 | - $array = array(); |
|
263 | - foreach($comment_response as $comment) |
|
264 | - { |
|
265 | - $body = $comment->getBody(); |
|
266 | - $body = Content::instance('CleanComment', $body)->activate(); |
|
267 | - $body = strip_tags($body); |
|
268 | - |
|
269 | - $comment_obj = new stdclass(); |
|
270 | - $comment_obj->description = Content::instance('SmartTrim', $body)->activate(30); |
|
271 | - $comment_obj->commenter = $comment->getCommenter()->getName(); |
|
272 | - $comment_obj->link = "{$comment->getUrl()}/#comment-{$comment->getId()}"; |
|
273 | - $array[] = $comment_obj; |
|
274 | - } |
|
275 | - return $array; |
|
276 | - } |
|
258 | + $elapsed = microtime(true) - $start; |
|
259 | + global $container; |
|
260 | + $container['logger']->info("CommentService | Sidebar | {$elapsed}"); |
|
261 | + |
|
262 | + $array = array(); |
|
263 | + foreach($comment_response as $comment) |
|
264 | + { |
|
265 | + $body = $comment->getBody(); |
|
266 | + $body = Content::instance('CleanComment', $body)->activate(); |
|
267 | + $body = strip_tags($body); |
|
268 | + |
|
269 | + $comment_obj = new stdclass(); |
|
270 | + $comment_obj->description = Content::instance('SmartTrim', $body)->activate(30); |
|
271 | + $comment_obj->commenter = $comment->getCommenter()->getName(); |
|
272 | + $comment_obj->link = "{$comment->getUrl()}/#comment-{$comment->getId()}"; |
|
273 | + $array[] = $comment_obj; |
|
274 | + } |
|
275 | + return $array; |
|
276 | + } |
|
277 | 277 | |
278 | 278 | } |
@@ -57,37 +57,37 @@ discard block |
||
57 | 57 | return $domain_container; |
58 | 58 | } |
59 | 59 | |
60 | - protected function get_recent_activity() |
|
61 | - { |
|
62 | - global $container; |
|
63 | - $activityRepository = new Jacobemerick\Web\Domain\Stream\Activity\MysqlActivityRepository($container['db_connection_locator']); |
|
64 | - $post_result = $activityRepository->getActivities(5); |
|
65 | - |
|
66 | - $post_array = array(); |
|
67 | - foreach($post_result as $row) { |
|
68 | - array_push($post_array, $this->expand_post($row)); |
|
69 | - } |
|
70 | - |
|
71 | - return $post_array; |
|
72 | - } |
|
73 | - |
|
74 | - protected function expand_post($raw_post, $format = 'short') |
|
75 | - { |
|
76 | - $post = [ |
|
77 | - 'type' => $raw_post['type'], |
|
78 | - 'title' => ($format == 'short') ? $raw_post['message'] : $raw_post['message_long'], |
|
79 | - 'date' => $this->get_parsed_date($raw_post['datetime']), |
|
80 | - ]; |
|
81 | - |
|
82 | - if ($format != 'short') { |
|
83 | - $post['url'] = Loader::getRootUrl('lifestream') . "{$raw_post['type']}/{$raw_post['id']}/"; |
|
84 | - |
|
85 | - $metadata = json_decode($raw_post['metadata'], true); |
|
86 | - $post = array_merge($post, $metadata); |
|
87 | - } |
|
88 | - |
|
89 | - return (object) $post; |
|
90 | - } |
|
60 | + protected function get_recent_activity() |
|
61 | + { |
|
62 | + global $container; |
|
63 | + $activityRepository = new Jacobemerick\Web\Domain\Stream\Activity\MysqlActivityRepository($container['db_connection_locator']); |
|
64 | + $post_result = $activityRepository->getActivities(5); |
|
65 | + |
|
66 | + $post_array = array(); |
|
67 | + foreach($post_result as $row) { |
|
68 | + array_push($post_array, $this->expand_post($row)); |
|
69 | + } |
|
70 | + |
|
71 | + return $post_array; |
|
72 | + } |
|
73 | + |
|
74 | + protected function expand_post($raw_post, $format = 'short') |
|
75 | + { |
|
76 | + $post = [ |
|
77 | + 'type' => $raw_post['type'], |
|
78 | + 'title' => ($format == 'short') ? $raw_post['message'] : $raw_post['message_long'], |
|
79 | + 'date' => $this->get_parsed_date($raw_post['datetime']), |
|
80 | + ]; |
|
81 | + |
|
82 | + if ($format != 'short') { |
|
83 | + $post['url'] = Loader::getRootUrl('lifestream') . "{$raw_post['type']}/{$raw_post['id']}/"; |
|
84 | + |
|
85 | + $metadata = json_decode($raw_post['metadata'], true); |
|
86 | + $post = array_merge($post, $metadata); |
|
87 | + } |
|
88 | + |
|
89 | + return (object) $post; |
|
90 | + } |
|
91 | 91 | |
92 | 92 | public function activate() |
93 | 93 | { |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']); |
109 | 109 | } |
110 | 110 | |
111 | - if (URLDecode::getSite() == 'waterfalls') { |
|
112 | - Loader::load('view', '/WaterfallFoot'); |
|
113 | - } else { |
|
114 | - Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE)); |
|
115 | - } |
|
111 | + if (URLDecode::getSite() == 'waterfalls') { |
|
112 | + Loader::load('view', '/WaterfallFoot'); |
|
113 | + } else { |
|
114 | + Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE)); |
|
115 | + } |
|
116 | 116 | |
117 | 117 | if($view == '/404' || $view == '/503') |
118 | 118 | exit; |
@@ -170,19 +170,19 @@ discard block |
||
170 | 170 | |
171 | 171 | private function load_assets() |
172 | 172 | { |
173 | - $css_array = array_map(function ($stylesheet) { |
|
174 | - $path = "/css/{$stylesheet[0]}.css"; |
|
175 | - if ($stylesheet[1] > 1) { |
|
176 | - $path .= "?v={$stylesheet[1]}"; |
|
177 | - } |
|
178 | - return $path; |
|
179 | - }, $this->css_array); |
|
180 | - $js_array = array_map(function ($script) { |
|
181 | - if (substr($script, 0, 4) == 'http') { |
|
182 | - return $script; |
|
183 | - } |
|
184 | - return "/js/{$script}.min.js"; |
|
185 | - }, $this->js_array); |
|
173 | + $css_array = array_map(function ($stylesheet) { |
|
174 | + $path = "/css/{$stylesheet[0]}.css"; |
|
175 | + if ($stylesheet[1] > 1) { |
|
176 | + $path .= "?v={$stylesheet[1]}"; |
|
177 | + } |
|
178 | + return $path; |
|
179 | + }, $this->css_array); |
|
180 | + $js_array = array_map(function ($script) { |
|
181 | + if (substr($script, 0, 4) == 'http') { |
|
182 | + return $script; |
|
183 | + } |
|
184 | + return "/js/{$script}.min.js"; |
|
185 | + }, $this->js_array); |
|
186 | 186 | |
187 | 187 | $this->set_head('css_link_array', $css_array); |
188 | 188 | $this->set_head('js_link_array', $js_array); |
@@ -296,9 +296,9 @@ discard block |
||
296 | 296 | $commenter->email = ''; |
297 | 297 | $commenter->website = ''; |
298 | 298 | |
299 | - if (!isset($_COOKIE['commenter'])) { |
|
300 | - return $commenter; |
|
301 | - } |
|
299 | + if (!isset($_COOKIE['commenter'])) { |
|
300 | + return $commenter; |
|
301 | + } |
|
302 | 302 | |
303 | 303 | $commenter_cookie_value = json_decode($_COOKIE['commenter']); |
304 | 304 |
@@ -64,7 +64,7 @@ discard block |
||
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 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | ]; |
81 | 81 | |
82 | 82 | if ($format != 'short') { |
83 | - $post['url'] = Loader::getRootUrl('lifestream') . "{$raw_post['type']}/{$raw_post['id']}/"; |
|
83 | + $post['url'] = Loader::getRootUrl('lifestream')."{$raw_post['type']}/{$raw_post['id']}/"; |
|
84 | 84 | |
85 | 85 | $metadata = json_decode($raw_post['metadata'], true); |
86 | 86 | $post = array_merge($post, $metadata); |
@@ -100,12 +100,12 @@ discard block |
||
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 | - Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']); |
|
108 | + Loader::load('view', URLDecode::getSite().'/'.$view, $this->data_array['body']); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | if (URLDecode::getSite() == 'waterfalls') { |
@@ -114,7 +114,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -302,15 +302,15 @@ discard block |
||
302 | 302 | |
303 | 303 | $commenter_cookie_value = json_decode($_COOKIE['commenter']); |
304 | 304 | |
305 | - if($commenter_cookie_value === NULL) |
|
305 | + if ($commenter_cookie_value === NULL) |
|
306 | 306 | return $commenter; |
307 | 307 | |
308 | - if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) |
|
308 | + if (!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) |
|
309 | 309 | return $commenter; |
310 | 310 | |
311 | 311 | $commenter_object = CommentCollector::getCommenterByFields($commenter_cookie_value->name, $commenter_cookie_value->email, (isset($commenter_cookie_value->website) ? $commenter_cookie_value->website : '')); |
312 | 312 | |
313 | - if($commenter_object === NULL) |
|
313 | + if ($commenter_object === NULL) |
|
314 | 314 | return $commenter; |
315 | 315 | |
316 | 316 | $commenter->id = $commenter_object->id; |
@@ -102,10 +102,11 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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); |
@@ -302,16 +309,19 @@ discard block |
||
302 | 309 | |
303 | 310 | $commenter_cookie_value = json_decode($_COOKIE['commenter']); |
304 | 311 | |
305 | - if($commenter_cookie_value === NULL) |
|
306 | - return $commenter; |
|
312 | + if($commenter_cookie_value === NULL) { |
|
313 | + return $commenter; |
|
314 | + } |
|
307 | 315 | |
308 | - if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) |
|
309 | - return $commenter; |
|
316 | + if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) { |
|
317 | + return $commenter; |
|
318 | + } |
|
310 | 319 | |
311 | 320 | $commenter_object = CommentCollector::getCommenterByFields($commenter_cookie_value->name, $commenter_cookie_value->email, (isset($commenter_cookie_value->website) ? $commenter_cookie_value->website : '')); |
312 | 321 | |
313 | - if($commenter_object === NULL) |
|
314 | - return $commenter; |
|
322 | + if($commenter_object === NULL) { |
|
323 | + return $commenter; |
|
324 | + } |
|
315 | 325 | |
316 | 326 | $commenter->id = $commenter_object->id; |
317 | 327 | $commenter->name = $commenter_object->name; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $comment_id = $this->save_comment(); |
42 | 42 | |
43 | 43 | $comment_meta_id = $this->save_comment_meta($commenter_id, $comment_id, $page_id); |
44 | - $comment_service_id = $this->save_to_comment_service(Request::getPost()); |
|
44 | + $comment_service_id = $this->save_to_comment_service(Request::getPost()); |
|
45 | 45 | |
46 | 46 | $this->send_notifications($page_id); |
47 | 47 | $this->redirect_to_comment($comment_meta_id); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | if(Request::getPost('website') != '') |
89 | 89 | $cookie_value['website'] = Request::getPost('website'); |
90 | 90 | |
91 | - setcookie('commenter', json_encode($cookie_value), time() + 31536000, '/', 'jacobemerick.com'); |
|
91 | + setcookie('commenter', json_encode($cookie_value), time() + 31536000, '/', 'jacobemerick.com'); |
|
92 | 92 | |
93 | 93 | $commenter_result = CommentCollector::getCommenterByFields(Request::getPost('name'), Request::getPost('email'), Request::getPost('website')); |
94 | 94 | if($commenter_result !== null) |
@@ -163,26 +163,26 @@ discard block |
||
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
166 | - $site = URLDecode::getSite(); |
|
166 | + $site = URLDecode::getSite(); |
|
167 | 167 | |
168 | - if ($site == 'blog') { |
|
169 | - $subject = "New Comment on Jacob Emerick's Blog"; |
|
170 | - $message = "Hello!\nThere has been a new comment on the post '{$this->page_title}' at Jacob Emerick's Blog. You have chosen to be notified of it - please reply to [email protected] if you would like to be removed from these notifications.\n\nOn " . date('F j, Y g:i a') . ", " . Request::getPost('name') . " commented...\n" . Request::getPost('comment') . "\n\nVisit {$this->full_path}#comments to see and reply to all the comments on this post.\nThank you!"; |
|
171 | - } else if ($site == 'waterfalls') { |
|
172 | - $subject = "New Comment on Waterfalls of the Keweenaw"; |
|
173 | - $message = "Hello!\nThere has been a new comment on the page '{$this->page_title}' at Waterfalls of the Keweenaw. You have chosen to be notified of it - please reply to [email protected] if you would like to be removed from these notifications.\n\nOn " . date('F j, Y g:i a') . ", " . Request::getPost('name') . " commented...\n" . Request::getPost('comment') . "\n\nVisit {$this->full_path}#comments to see and reply to all the comments on this post.\nThank you!"; |
|
174 | - } |
|
168 | + if ($site == 'blog') { |
|
169 | + $subject = "New Comment on Jacob Emerick's Blog"; |
|
170 | + $message = "Hello!\nThere has been a new comment on the post '{$this->page_title}' at Jacob Emerick's Blog. You have chosen to be notified of it - please reply to [email protected] if you would like to be removed from these notifications.\n\nOn " . date('F j, Y g:i a') . ", " . Request::getPost('name') . " commented...\n" . Request::getPost('comment') . "\n\nVisit {$this->full_path}#comments to see and reply to all the comments on this post.\nThank you!"; |
|
171 | + } else if ($site == 'waterfalls') { |
|
172 | + $subject = "New Comment on Waterfalls of the Keweenaw"; |
|
173 | + $message = "Hello!\nThere has been a new comment on the page '{$this->page_title}' at Waterfalls of the Keweenaw. You have chosen to be notified of it - please reply to [email protected] if you would like to be removed from these notifications.\n\nOn " . date('F j, Y g:i a') . ", " . Request::getPost('name') . " commented...\n" . Request::getPost('comment') . "\n\nVisit {$this->full_path}#comments to see and reply to all the comments on this post.\nThank you!"; |
|
174 | + } |
|
175 | 175 | |
176 | - global $container; |
|
176 | + global $container; |
|
177 | 177 | |
178 | 178 | foreach($email_recipient_array as $email_recipient) |
179 | 179 | { |
180 | - $sent = $container['mail'] |
|
181 | - ->addTo($email_recipient['email'], $email_recipient['name']) |
|
182 | - ->addBCC($container['config']->admin_email) |
|
183 | - ->setSubject($subject) |
|
184 | - ->setPlainMessage($message) |
|
185 | - ->send(); |
|
180 | + $sent = $container['mail'] |
|
181 | + ->addTo($email_recipient['email'], $email_recipient['name']) |
|
182 | + ->addBCC($container['config']->admin_email) |
|
183 | + ->setSubject($subject) |
|
184 | + ->setPlainMessage($message) |
|
185 | + ->send(); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
@@ -196,41 +196,41 @@ discard block |
||
196 | 196 | exit; |
197 | 197 | } |
198 | 198 | |
199 | - private function save_to_comment_service(array $data) |
|
200 | - { |
|
201 | - $path = $_SERVER['REQUEST_URI']; |
|
202 | - $path = explode('/', $path); |
|
203 | - $path = array_filter($path); |
|
204 | - $path = array_slice($path, 0, 2); |
|
205 | - $path = implode('/', $path); |
|
206 | - |
|
207 | - $body = [ |
|
208 | - 'commenter' => [ |
|
209 | - 'name' => $data['name'], |
|
210 | - 'email' => $data['email'], |
|
211 | - 'website' => $data['website'], |
|
212 | - ], |
|
213 | - 'body' => $data['comment'], |
|
214 | - 'should_notify' => (isset($data['notify']) && $data['notify'] == 'check'), |
|
215 | - 'domain' => (URLDecode::getSite() == 'blog' ? 'blog.jacobemerick.com' : 'waterfallsofthekeweenaw.com'), |
|
216 | - 'path' => $path, |
|
217 | - 'url' => $this->full_path, |
|
218 | - 'thread' => 'comments', |
|
219 | - 'ip_address' => $_SERVER['REMOTE_ADDR'], |
|
220 | - 'user_agent' => $_SERVER['HTTP_USER_AGENT'], |
|
221 | - 'referrer' => $_SERVER['HTTP_REFERER'], |
|
222 | - ]; |
|
223 | - |
|
224 | - global $config; |
|
225 | - $configuration = new Jacobemerick\CommentService\Configuration(); |
|
226 | - $configuration->setUsername($config->comments->user); |
|
227 | - $configuration->setPassword($config->comments->password); |
|
228 | - $configuration->addDefaultHeader('Content-Type', 'application/json'); |
|
229 | - $configuration->setHost($config->comments->host); |
|
230 | - $configuration->setCurlTimeout($config->comments->timeout); |
|
231 | - |
|
232 | - $client = new Jacobemerick\CommentService\ApiClient($configuration); |
|
233 | - $api = new Jacobemerick\CommentService\Api\DefaultApi($client); |
|
234 | - $response = $api->createComment($body); |
|
235 | - } |
|
199 | + private function save_to_comment_service(array $data) |
|
200 | + { |
|
201 | + $path = $_SERVER['REQUEST_URI']; |
|
202 | + $path = explode('/', $path); |
|
203 | + $path = array_filter($path); |
|
204 | + $path = array_slice($path, 0, 2); |
|
205 | + $path = implode('/', $path); |
|
206 | + |
|
207 | + $body = [ |
|
208 | + 'commenter' => [ |
|
209 | + 'name' => $data['name'], |
|
210 | + 'email' => $data['email'], |
|
211 | + 'website' => $data['website'], |
|
212 | + ], |
|
213 | + 'body' => $data['comment'], |
|
214 | + 'should_notify' => (isset($data['notify']) && $data['notify'] == 'check'), |
|
215 | + 'domain' => (URLDecode::getSite() == 'blog' ? 'blog.jacobemerick.com' : 'waterfallsofthekeweenaw.com'), |
|
216 | + 'path' => $path, |
|
217 | + 'url' => $this->full_path, |
|
218 | + 'thread' => 'comments', |
|
219 | + 'ip_address' => $_SERVER['REMOTE_ADDR'], |
|
220 | + 'user_agent' => $_SERVER['HTTP_USER_AGENT'], |
|
221 | + 'referrer' => $_SERVER['HTTP_REFERER'], |
|
222 | + ]; |
|
223 | + |
|
224 | + global $config; |
|
225 | + $configuration = new Jacobemerick\CommentService\Configuration(); |
|
226 | + $configuration->setUsername($config->comments->user); |
|
227 | + $configuration->setPassword($config->comments->password); |
|
228 | + $configuration->addDefaultHeader('Content-Type', 'application/json'); |
|
229 | + $configuration->setHost($config->comments->host); |
|
230 | + $configuration->setCurlTimeout($config->comments->timeout); |
|
231 | + |
|
232 | + $client = new Jacobemerick\CommentService\ApiClient($configuration); |
|
233 | + $api = new Jacobemerick\CommentService\Api\DefaultApi($client); |
|
234 | + $response = $api->createComment($body); |
|
235 | + } |
|
236 | 236 | } |