@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | { |
24 | 24 | parent::__construct(); |
25 | 25 | |
26 | - global $container; |
|
27 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
28 | - $this->post = $repository->findPostByPath(URLDecode::getPiece(2)); |
|
26 | + global $container; |
|
27 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
28 | + $this->post = $repository->findPostByPath(URLDecode::getPiece(2)); |
|
29 | 29 | |
30 | 30 | if($this->post == null) |
31 | 31 | $this->eject(); |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | Loader::getRootUrl('blog') . $this->post['category'] . '/' . $this->post['path'] . '/', |
37 | 37 | $this->post['title']); |
38 | 38 | |
39 | - global $container; |
|
40 | - $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
|
41 | - $this->tags = $repository->getTagsForPost($this->post['id']); |
|
39 | + global $container; |
|
40 | + $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
|
41 | + $this->tags = $repository->getTagsForPost($this->post['id']); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | protected function set_head_data() |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | $this->set_keywords($this->get_post_keywords()); |
51 | 51 | $this->set_author(self::$AUTHOR); |
52 | 52 | |
53 | - $photo = Content::instance('FetchFirstPhoto', $this->post['body'])->activate(true); |
|
54 | - $photo = preg_match('/^<img src="([a-z-:\.\/]+)" [^>]+>$/', $photo, $matches); |
|
55 | - $this->set_head('thumbnail', $matches[1]); |
|
53 | + $photo = Content::instance('FetchFirstPhoto', $this->post['body'])->activate(true); |
|
54 | + $photo = preg_match('/^<img src="([a-z-:\.\/]+)" [^>]+>$/', $photo, $matches); |
|
55 | + $this->set_head('thumbnail', $matches[1]); |
|
56 | 56 | |
57 | 57 | if (array_key_exists($this->post['id'], self::$DEPRECATED_BLOGS)) { |
58 | 58 | $log_id = self::$DEPRECATED_BLOGS[$this->post['id']]; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | 'author' => self::$AUTHOR, |
80 | 80 | 'author_url' => self::$AUTHOR_URL, |
81 | 81 | 'comment_array' => $this->get_comment_array("{$this->post['category']}/{$this->post['path']}"), |
82 | - )); |
|
82 | + )); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | protected function get_post_description() |
@@ -127,18 +127,18 @@ discard block |
||
127 | 127 | |
128 | 128 | $post = new stdclass(); |
129 | 129 | |
130 | - if ( |
|
131 | - strpos($post_row['title'], 'Rainy Supe Loop') === 0 || |
|
132 | - strpos($post_row['title'], 'Malapais Loop') === 0 || |
|
133 | - strpos($post_row['title'], 'Mazatzal Peak Loop') === 0 || |
|
134 | - strpos($post_row['title'], 'Dripping Springs Loop') === 0 |
|
135 | - ) { |
|
136 | - $title = $post_row['title']; |
|
137 | - $title = explode(':', $title); |
|
138 | - $title = array_pop($title); |
|
139 | - $title = trim($title); |
|
140 | - $post->title = $title; |
|
141 | - } else if (strpos($post_row['title'], 'Isle Royale') === 0) { |
|
130 | + if ( |
|
131 | + strpos($post_row['title'], 'Rainy Supe Loop') === 0 || |
|
132 | + strpos($post_row['title'], 'Malapais Loop') === 0 || |
|
133 | + strpos($post_row['title'], 'Mazatzal Peak Loop') === 0 || |
|
134 | + strpos($post_row['title'], 'Dripping Springs Loop') === 0 |
|
135 | + ) { |
|
136 | + $title = $post_row['title']; |
|
137 | + $title = explode(':', $title); |
|
138 | + $title = array_pop($title); |
|
139 | + $title = trim($title); |
|
140 | + $post->title = $title; |
|
141 | + } else if (strpos($post_row['title'], 'Isle Royale') === 0) { |
|
142 | 142 | $title = $post_row['title']; |
143 | 143 | $title = explode(',', $title); |
144 | 144 | $title = array_pop($title); |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | private $series_posts; |
170 | 170 | private function fetch_series_posts() |
171 | 171 | { |
172 | - if(!isset($this->series_posts)) { |
|
173 | - global $container; |
|
174 | - $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']); |
|
175 | - $this->series_posts = $repository->getSeriesForPost($this->post['id']); |
|
176 | - } |
|
177 | - return $this->series_posts; |
|
172 | + if(!isset($this->series_posts)) { |
|
173 | + global $container; |
|
174 | + $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']); |
|
175 | + $this->series_posts = $repository->getSeriesForPost($this->post['id']); |
|
176 | + } |
|
177 | + return $this->series_posts; |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | private function get_related_posts() |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | $exclude_post_array[] = $series_post['post']; |
193 | 193 | } |
194 | 194 | |
195 | - global $container; |
|
196 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
197 | - $post_result = $repository->getActivePostsByRelatedTags($this->post['id']); |
|
195 | + global $container; |
|
196 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
197 | + $post_result = $repository->getActivePostsByRelatedTags($this->post['id']); |
|
198 | 198 | |
199 | - $post_array = array(); |
|
199 | + $post_array = array(); |
|
200 | 200 | |
201 | 201 | foreach($post_result as $post_row) |
202 | 202 | { |
@@ -213,68 +213,68 @@ discard block |
||
213 | 213 | return $post_array; |
214 | 214 | } |
215 | 215 | |
216 | - protected function get_comment_array($path) |
|
217 | - { |
|
218 | - $path = explode('/', $path); |
|
219 | - $path = array_pop($path); |
|
220 | - return parent::get_comment_array(self::$BLOG_SITE_ID, $path); |
|
216 | + protected function get_comment_array($path) |
|
217 | + { |
|
218 | + $path = explode('/', $path); |
|
219 | + $path = array_pop($path); |
|
220 | + return parent::get_comment_array(self::$BLOG_SITE_ID, $path); |
|
221 | 221 | |
222 | - global $config; |
|
223 | - $configuration = new Jacobemerick\CommentService\Configuration(); |
|
224 | - $configuration->setUsername($config->comments->user); |
|
225 | - $configuration->setPassword($config->comments->password); |
|
226 | - $configuration->addDefaultHeader('Content-Type', 'application/json'); |
|
227 | - $configuration->setHost($config->comments->host); |
|
228 | - $configuration->setCurlTimeout($config->comments->timeout); |
|
222 | + global $config; |
|
223 | + $configuration = new Jacobemerick\CommentService\Configuration(); |
|
224 | + $configuration->setUsername($config->comments->user); |
|
225 | + $configuration->setPassword($config->comments->password); |
|
226 | + $configuration->addDefaultHeader('Content-Type', 'application/json'); |
|
227 | + $configuration->setHost($config->comments->host); |
|
228 | + $configuration->setCurlTimeout($config->comments->timeout); |
|
229 | 229 | |
230 | - $client = new Jacobemerick\CommentService\ApiClient($configuration); |
|
231 | - $api = new Jacobemerick\CommentService\Api\DefaultApi($client); |
|
230 | + $client = new Jacobemerick\CommentService\ApiClient($configuration); |
|
231 | + $api = new Jacobemerick\CommentService\Api\DefaultApi($client); |
|
232 | 232 | |
233 | - $start = microtime(true); |
|
234 | - try { |
|
235 | - $comment_response = $api->getComments( |
|
236 | - 1, |
|
237 | - null, |
|
238 | - 'date', |
|
239 | - 'blog.jacobemerick.com', |
|
240 | - $path |
|
241 | - ); |
|
242 | - } catch (Exception $e) { |
|
243 | - global $container; |
|
244 | - $container['logger']->warning("CommentService | Path | {$e->getMessage()}"); |
|
245 | - return; |
|
246 | - } |
|
233 | + $start = microtime(true); |
|
234 | + try { |
|
235 | + $comment_response = $api->getComments( |
|
236 | + 1, |
|
237 | + null, |
|
238 | + 'date', |
|
239 | + 'blog.jacobemerick.com', |
|
240 | + $path |
|
241 | + ); |
|
242 | + } catch (Exception $e) { |
|
243 | + global $container; |
|
244 | + $container['logger']->warning("CommentService | Path | {$e->getMessage()}"); |
|
245 | + return; |
|
246 | + } |
|
247 | 247 | |
248 | - $elapsed = microtime(true) - $start; |
|
249 | - global $container; |
|
250 | - $container['logger']->info("CommentService | Path | {$elapsed}"); |
|
248 | + $elapsed = microtime(true) - $start; |
|
249 | + global $container; |
|
250 | + $container['logger']->info("CommentService | Path | {$elapsed}"); |
|
251 | 251 | |
252 | - $array = array(); |
|
253 | - foreach((array) $comment_response as $comment) |
|
254 | - { |
|
255 | - $body = $comment->getBody(); |
|
256 | - $body = Content::instance('CleanComment', $body)->activate(); |
|
257 | - $body = strip_tags($body); |
|
252 | + $array = array(); |
|
253 | + foreach((array) $comment_response as $comment) |
|
254 | + { |
|
255 | + $body = $comment->getBody(); |
|
256 | + $body = Content::instance('CleanComment', $body)->activate(); |
|
257 | + $body = strip_tags($body); |
|
258 | 258 | |
259 | - $comment_obj = new stdclass(); |
|
260 | - $comment_obj->id = $comment->getId(); |
|
261 | - $comment_obj->name = $comment->getCommenter()->getName(); |
|
262 | - $comment_obj->url = $comment->getCommenter()->getWebsite(); |
|
263 | - $comment_obj->trusted = true; |
|
264 | - $comment_obj->date = $comment->getDate()->format('M j, \'y'); |
|
265 | - $comment_obj->body = $body; |
|
259 | + $comment_obj = new stdclass(); |
|
260 | + $comment_obj->id = $comment->getId(); |
|
261 | + $comment_obj->name = $comment->getCommenter()->getName(); |
|
262 | + $comment_obj->url = $comment->getCommenter()->getWebsite(); |
|
263 | + $comment_obj->trusted = true; |
|
264 | + $comment_obj->date = $comment->getDate()->format('M j, \'y'); |
|
265 | + $comment_obj->body = $body; |
|
266 | 266 | |
267 | - // todo figure out if reply |
|
268 | - $array[] = $comment_obj; |
|
269 | - } |
|
267 | + // todo figure out if reply |
|
268 | + $array[] = $comment_obj; |
|
269 | + } |
|
270 | 270 | |
271 | - // todo figure out commenter obj |
|
272 | - // todo figure out how to handle errors or whatever |
|
273 | - return [ |
|
274 | - 'comments' => $array, |
|
275 | - 'commenter' => [], |
|
276 | - 'errors' => [], |
|
277 | - 'comment_count' => count($array), |
|
278 | - ]; |
|
279 | - } |
|
271 | + // todo figure out commenter obj |
|
272 | + // todo figure out how to handle errors or whatever |
|
273 | + return [ |
|
274 | + 'comments' => $array, |
|
275 | + 'commenter' => [], |
|
276 | + 'errors' => [], |
|
277 | + 'comment_count' => count($array), |
|
278 | + ]; |
|
279 | + } |
|
280 | 280 | } |