@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $comment_id = $this->save_comment(); |
43 | 43 | |
44 | 44 | $comment_meta_id = $this->save_comment_meta($commenter_id, $comment_id, $page_id); |
45 | - $comment_service_id = $this->save_to_comment_service(Request::getPost()); |
|
45 | + $comment_service_id = $this->save_to_comment_service(Request::getPost()); |
|
46 | 46 | |
47 | 47 | $this->send_notifications($page_id); |
48 | 48 | $this->redirect_to_comment($comment_meta_id); |
@@ -168,26 +168,26 @@ discard block |
||
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
171 | - $site = URLDecode::getSite(); |
|
171 | + $site = URLDecode::getSite(); |
|
172 | 172 | |
173 | - if ($site == 'blog') { |
|
174 | - $subject = "New Comment on Jacob Emerick's Blog"; |
|
175 | - $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!"; |
|
176 | - } else if ($site == 'waterfalls') { |
|
177 | - $subject = "New Comment on Waterfalls of the Keweenaw"; |
|
178 | - $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!"; |
|
179 | - } |
|
173 | + if ($site == 'blog') { |
|
174 | + $subject = "New Comment on Jacob Emerick's Blog"; |
|
175 | + $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!"; |
|
176 | + } else if ($site == 'waterfalls') { |
|
177 | + $subject = "New Comment on Waterfalls of the Keweenaw"; |
|
178 | + $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!"; |
|
179 | + } |
|
180 | 180 | |
181 | - global $container; |
|
181 | + global $container; |
|
182 | 182 | |
183 | 183 | foreach($email_recipient_array as $email_recipient) |
184 | 184 | { |
185 | - $sent = $container['mail'] |
|
186 | - ->addTo($email_recipient['email'], $email_recipient['name']) |
|
187 | - ->addBCC($container['config']->admin_email) |
|
188 | - ->setSubject($subject) |
|
189 | - ->setPlainMessage($message) |
|
190 | - ->send(); |
|
185 | + $sent = $container['mail'] |
|
186 | + ->addTo($email_recipient['email'], $email_recipient['name']) |
|
187 | + ->addBCC($container['config']->admin_email) |
|
188 | + ->setSubject($subject) |
|
189 | + ->setPlainMessage($message) |
|
190 | + ->send(); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
@@ -201,41 +201,41 @@ discard block |
||
201 | 201 | exit; |
202 | 202 | } |
203 | 203 | |
204 | - private function save_to_comment_service(array $data) |
|
205 | - { |
|
206 | - $path = $_SERVER['REQUEST_URI']; |
|
207 | - $path = explode('/', $path); |
|
208 | - $path = array_filter($path); |
|
209 | - $path = array_slice($path, 0, 2); |
|
210 | - $path = implode('/', $path); |
|
211 | - |
|
212 | - $body = [ |
|
213 | - 'commenter' => [ |
|
214 | - 'name' => $data['name'], |
|
215 | - 'email' => $data['email'], |
|
216 | - 'website' => $data['website'], |
|
217 | - ], |
|
218 | - 'body' => $data['comment'], |
|
219 | - 'should_notify' => (isset($data['notify']) && $data['notify'] == 'check'), |
|
220 | - 'domain' => (URLDecode::getSite() == 'blog' ? 'blog.jacobemerick.com' : 'waterfallsofthekeweenaw.com'), |
|
221 | - 'path' => $path, |
|
222 | - 'url' => $this->full_path, |
|
223 | - 'thread' => 'comments', |
|
224 | - 'ip_address' => $_SERVER['REMOTE_ADDR'], |
|
225 | - 'user_agent' => $_SERVER['HTTP_USER_AGENT'], |
|
226 | - 'referrer' => $_SERVER['HTTP_REFERER'], |
|
227 | - ]; |
|
228 | - |
|
229 | - global $config; |
|
230 | - $configuration = new Jacobemerick\CommentService\Configuration(); |
|
231 | - $configuration->setUsername($config->comments->user); |
|
232 | - $configuration->setPassword($config->comments->password); |
|
233 | - $configuration->addDefaultHeader('Content-Type', 'application/json'); |
|
234 | - $configuration->setHost($config->comments->host); |
|
235 | - $configuration->setCurlTimeout($config->comments->timeout); |
|
236 | - |
|
237 | - $client = new Jacobemerick\CommentService\ApiClient($configuration); |
|
238 | - $api = new Jacobemerick\CommentService\Api\DefaultApi($client); |
|
239 | - $response = $api->createComment($body); |
|
240 | - } |
|
204 | + private function save_to_comment_service(array $data) |
|
205 | + { |
|
206 | + $path = $_SERVER['REQUEST_URI']; |
|
207 | + $path = explode('/', $path); |
|
208 | + $path = array_filter($path); |
|
209 | + $path = array_slice($path, 0, 2); |
|
210 | + $path = implode('/', $path); |
|
211 | + |
|
212 | + $body = [ |
|
213 | + 'commenter' => [ |
|
214 | + 'name' => $data['name'], |
|
215 | + 'email' => $data['email'], |
|
216 | + 'website' => $data['website'], |
|
217 | + ], |
|
218 | + 'body' => $data['comment'], |
|
219 | + 'should_notify' => (isset($data['notify']) && $data['notify'] == 'check'), |
|
220 | + 'domain' => (URLDecode::getSite() == 'blog' ? 'blog.jacobemerick.com' : 'waterfallsofthekeweenaw.com'), |
|
221 | + 'path' => $path, |
|
222 | + 'url' => $this->full_path, |
|
223 | + 'thread' => 'comments', |
|
224 | + 'ip_address' => $_SERVER['REMOTE_ADDR'], |
|
225 | + 'user_agent' => $_SERVER['HTTP_USER_AGENT'], |
|
226 | + 'referrer' => $_SERVER['HTTP_REFERER'], |
|
227 | + ]; |
|
228 | + |
|
229 | + global $config; |
|
230 | + $configuration = new Jacobemerick\CommentService\Configuration(); |
|
231 | + $configuration->setUsername($config->comments->user); |
|
232 | + $configuration->setPassword($config->comments->password); |
|
233 | + $configuration->addDefaultHeader('Content-Type', 'application/json'); |
|
234 | + $configuration->setHost($config->comments->host); |
|
235 | + $configuration->setCurlTimeout($config->comments->timeout); |
|
236 | + |
|
237 | + $client = new Jacobemerick\CommentService\ApiClient($configuration); |
|
238 | + $api = new Jacobemerick\CommentService\Api\DefaultApi($client); |
|
239 | + $response = $api->createComment($body); |
|
240 | + } |
|
241 | 241 | } |
@@ -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'); |
@@ -87,11 +87,11 @@ discard block |
||
87 | 87 | |
88 | 88 | final private function get_tags_for_post($post) |
89 | 89 | { |
90 | - global $container; |
|
91 | - $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
|
92 | - $tag_result = $repository->getTagsForPost($post['id']); |
|
90 | + global $container; |
|
91 | + $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
|
92 | + $tag_result = $repository->getTagsForPost($post['id']); |
|
93 | 93 | |
94 | - $tag_array = array(); |
|
94 | + $tag_array = array(); |
|
95 | 95 | foreach($tag_result as $tag) |
96 | 96 | { |
97 | 97 | $tag_object = new stdclass(); |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | |
126 | 126 | final private function get_tag_cloud() |
127 | 127 | { |
128 | - global $container; |
|
129 | - $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
|
130 | - $tag_result = $repository->getTagCloud(); |
|
128 | + global $container; |
|
129 | + $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
|
130 | + $tag_result = $repository->getTagCloud(); |
|
131 | 131 | |
132 | 132 | $maximum_tag_count = $this->get_maximum_tag_count($tag_result); |
133 | 133 | |
@@ -176,44 +176,44 @@ discard block |
||
176 | 176 | $array[] = $comment_obj; |
177 | 177 | } |
178 | 178 | |
179 | - $comment_service_array = $this->get_comments_from_service(); |
|
180 | - if ($comment_service_array !== $array) { |
|
181 | - global $container; |
|
182 | - $container['console']->log('Mismatch between comment service and legacy db'); |
|
183 | - $container['console']->log($comment_service_array[0]); |
|
184 | - $container['console']->log($array[0]); |
|
185 | - } |
|
179 | + $comment_service_array = $this->get_comments_from_service(); |
|
180 | + if ($comment_service_array !== $array) { |
|
181 | + global $container; |
|
182 | + $container['console']->log('Mismatch between comment service and legacy db'); |
|
183 | + $container['console']->log($comment_service_array[0]); |
|
184 | + $container['console']->log($array[0]); |
|
185 | + } |
|
186 | 186 | return $array; |
187 | 187 | } |
188 | 188 | |
189 | - final private function get_comments_from_service() |
|
190 | - { |
|
191 | - global $config; |
|
192 | - $configuration = new Jacobemerick\CommentService\Configuration(); |
|
193 | - $configuration->setUsername($config->comments->user); |
|
194 | - $configuration->setPassword($config->comments->password); |
|
195 | - $configuration->addDefaultHeader('Content-Type', 'application/json'); |
|
196 | - $configuration->setHost($config->comments->host); |
|
197 | - $configuration->setCurlTimeout($config->comments->timeout); |
|
198 | - |
|
199 | - $client = new Jacobemerick\CommentService\ApiClient($configuration); |
|
200 | - $api = new Jacobemerick\CommentService\Api\DefaultApi($client); |
|
201 | - $comment_response = $api->getComments(1, self::$RECENT_COMMENT_COUNT, '-date', 'blog.jacobemerick.com'); |
|
202 | - |
|
203 | - $array = array(); |
|
204 | - foreach($comment_response as $comment) |
|
205 | - { |
|
206 | - $body = $comment->getBody(); |
|
207 | - $body = Content::instance('CleanComment', $body)->activate(); |
|
208 | - $body = strip_tags($body); |
|
209 | - |
|
210 | - $comment_obj = new stdclass(); |
|
211 | - $comment_obj->description = Content::instance('SmartTrim', $body)->activate(30); |
|
212 | - $comment_obj->commenter = $comment->getCommenter()->getName(); |
|
213 | - $comment_obj->link = "{$comment->getUrl()}/#comment-{$comment->getId()}"; |
|
214 | - $array[] = $comment_obj; |
|
215 | - } |
|
216 | - return $array; |
|
217 | - } |
|
189 | + final private function get_comments_from_service() |
|
190 | + { |
|
191 | + global $config; |
|
192 | + $configuration = new Jacobemerick\CommentService\Configuration(); |
|
193 | + $configuration->setUsername($config->comments->user); |
|
194 | + $configuration->setPassword($config->comments->password); |
|
195 | + $configuration->addDefaultHeader('Content-Type', 'application/json'); |
|
196 | + $configuration->setHost($config->comments->host); |
|
197 | + $configuration->setCurlTimeout($config->comments->timeout); |
|
198 | + |
|
199 | + $client = new Jacobemerick\CommentService\ApiClient($configuration); |
|
200 | + $api = new Jacobemerick\CommentService\Api\DefaultApi($client); |
|
201 | + $comment_response = $api->getComments(1, self::$RECENT_COMMENT_COUNT, '-date', 'blog.jacobemerick.com'); |
|
202 | + |
|
203 | + $array = array(); |
|
204 | + foreach($comment_response as $comment) |
|
205 | + { |
|
206 | + $body = $comment->getBody(); |
|
207 | + $body = Content::instance('CleanComment', $body)->activate(); |
|
208 | + $body = strip_tags($body); |
|
209 | + |
|
210 | + $comment_obj = new stdclass(); |
|
211 | + $comment_obj->description = Content::instance('SmartTrim', $body)->activate(30); |
|
212 | + $comment_obj->commenter = $comment->getCommenter()->getName(); |
|
213 | + $comment_obj->link = "{$comment->getUrl()}/#comment-{$comment->getId()}"; |
|
214 | + $array[] = $comment_obj; |
|
215 | + } |
|
216 | + return $array; |
|
217 | + } |
|
218 | 218 | |
219 | 219 | } |