@@ -27,13 +27,13 @@ discard block |
||
| 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) |
|
| 30 | + if ($this->post == null) |
|
| 31 | 31 | $this->eject(); |
| 32 | 32 | |
| 33 | 33 | $this->handle_comment_submit( |
| 34 | 34 | self::$BLOG_SITE_ID, |
| 35 | 35 | $this->post['path'], |
| 36 | - Loader::getRootUrl('blog') . $this->post['category'] . '/' . $this->post['path'] . '/', |
|
| 36 | + Loader::getRootUrl('blog').$this->post['category'].'/'.$this->post['path'].'/', |
|
| 37 | 37 | $this->post['title']); |
| 38 | 38 | |
| 39 | 39 | global $container; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $log_id = self::$DEPRECATED_BLOGS[$this->post['id']]; |
| 59 | 59 | $log = LogCollector::getById($log_id); |
| 60 | 60 | if (!empty($log)) { |
| 61 | - $log_url = Loader::getRootUrl('waterfalls') . "journal/{$log->alias}/"; |
|
| 61 | + $log_url = Loader::getRootUrl('waterfalls')."journal/{$log->alias}/"; |
|
| 62 | 62 | $this->set_canonical($log_url); |
| 63 | 63 | } |
| 64 | 64 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $keyword_array = array(); |
| 96 | 96 | $keywords = $this->tags; |
| 97 | 97 | |
| 98 | - foreach($keywords as $keyword) |
|
| 98 | + foreach ($keywords as $keyword) |
|
| 99 | 99 | { |
| 100 | 100 | $keyword_array[] = $keyword['tag']; |
| 101 | 101 | } |
@@ -109,16 +109,16 @@ discard block |
||
| 109 | 109 | private function get_series_posts() |
| 110 | 110 | { |
| 111 | 111 | $series_posts = $this->fetch_series_posts(); |
| 112 | - if(count($series_posts) < 1) |
|
| 112 | + if (count($series_posts) < 1) |
|
| 113 | 113 | return array(); |
| 114 | 114 | |
| 115 | 115 | $previous_post = new stdclass(); |
| 116 | 116 | $next_post = new stdclass(); |
| 117 | 117 | |
| 118 | 118 | $found_current_post = false; |
| 119 | - foreach($series_posts as $post_row) |
|
| 119 | + foreach ($series_posts as $post_row) |
|
| 120 | 120 | { |
| 121 | - if($post_row['post'] == $this->post['id']) |
|
| 121 | + if ($post_row['post'] == $this->post['id']) |
|
| 122 | 122 | { |
| 123 | 123 | $found_current_post = true; |
| 124 | 124 | continue; |
@@ -146,9 +146,9 @@ discard block |
||
| 146 | 146 | $post->title = $post_row['title']; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
|
| 149 | + $post->url = Loader::getRootUrl('blog')."{$post_row['category']}/{$post_row['path']}/"; |
|
| 150 | 150 | |
| 151 | - if(!$found_current_post) |
|
| 151 | + if (!$found_current_post) |
|
| 152 | 152 | $previous_post = $post; |
| 153 | 153 | else |
| 154 | 154 | { |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | private $series_posts; |
| 168 | 168 | private function fetch_series_posts() |
| 169 | 169 | { |
| 170 | - if(!isset($this->series_posts)) { |
|
| 170 | + if (!isset($this->series_posts)) { |
|
| 171 | 171 | global $container; |
| 172 | 172 | $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']); |
| 173 | 173 | $this->series_posts = $repository->getSeriesForPost($this->post['id']); |
@@ -178,14 +178,14 @@ discard block |
||
| 178 | 178 | private function get_related_posts() |
| 179 | 179 | { |
| 180 | 180 | $tag_array = array(); |
| 181 | - foreach($this->tags as $tag) |
|
| 181 | + foreach ($this->tags as $tag) |
|
| 182 | 182 | { |
| 183 | 183 | $tag_array[] = $tag['id']; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | $series_posts = $this->fetch_series_posts(); |
| 187 | 187 | $exclude_post_array = array(); |
| 188 | - foreach($series_posts as $series_post) |
|
| 188 | + foreach ($series_posts as $series_post) |
|
| 189 | 189 | { |
| 190 | 190 | $exclude_post_array[] = $series_post['post']; |
| 191 | 191 | } |
@@ -196,11 +196,11 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | $post_array = array(); |
| 198 | 198 | |
| 199 | - foreach($post_result as $post_row) |
|
| 199 | + foreach ($post_result as $post_row) |
|
| 200 | 200 | { |
| 201 | 201 | $post = new stdclass(); |
| 202 | 202 | $post->title = $post_row['title']; |
| 203 | - $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
|
| 203 | + $post->url = Loader::getRootUrl('blog')."{$post_row['category']}/{$post_row['path']}/"; |
|
| 204 | 204 | $post->category = ucwords(str_replace('-', ' ', $post_row['category'])); |
| 205 | 205 | $post->thumb = Content::instance('FetchFirstPhoto', $post_row['body'])->activate(); |
| 206 | 206 | $post->body = Content::instance('SmartTrim', $post_row['body'])->activate(($post->thumb !== '') ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG); |
@@ -113,6 +113,9 @@ discard block |
||
| 113 | 113 | exit; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | + /** |
|
| 117 | + * @param string $method |
|
| 118 | + */ |
|
| 116 | 119 | protected function set_header_method($method) |
| 117 | 120 | { |
| 118 | 121 | $this->headers = $method; |
@@ -123,6 +126,9 @@ discard block |
||
| 123 | 126 | $this->set_head('title', $value); |
| 124 | 127 | } |
| 125 | 128 | |
| 129 | + /** |
|
| 130 | + * @param string $value |
|
| 131 | + */ |
|
| 126 | 132 | protected function set_author($value) |
| 127 | 133 | { |
| 128 | 134 | $this->set_head('author', $value); |
@@ -138,26 +144,41 @@ discard block |
||
| 138 | 144 | $this->set_head('keywords', implode(', ', $array)); |
| 139 | 145 | } |
| 140 | 146 | |
| 147 | + /** |
|
| 148 | + * @param string $url |
|
| 149 | + */ |
|
| 141 | 150 | protected function set_canonical($url) |
| 142 | 151 | { |
| 143 | 152 | $this->set_head('canonical', $url); |
| 144 | 153 | } |
| 145 | 154 | |
| 155 | + /** |
|
| 156 | + * @param string $set |
|
| 157 | + */ |
|
| 146 | 158 | protected function set_head($set, $value) |
| 147 | 159 | { |
| 148 | 160 | $this->data_array['head'][$set] = $value; |
| 149 | 161 | } |
| 150 | 162 | |
| 163 | + /** |
|
| 164 | + * @param string $set |
|
| 165 | + */ |
|
| 151 | 166 | protected function set_body($set, $value) |
| 152 | 167 | { |
| 153 | 168 | $this->data_array['body'][$set] = $value; |
| 154 | 169 | } |
| 155 | 170 | |
| 171 | + /** |
|
| 172 | + * @param string $file |
|
| 173 | + */ |
|
| 156 | 174 | protected function add_css($file, $version = 1) |
| 157 | 175 | { |
| 158 | 176 | $this->css_array[] = [$file, $version]; |
| 159 | 177 | } |
| 160 | 178 | |
| 179 | + /** |
|
| 180 | + * @param string $file |
|
| 181 | + */ |
|
| 161 | 182 | protected function add_js($file) |
| 162 | 183 | { |
| 163 | 184 | $this->js_array[] = $file; |
@@ -183,6 +204,9 @@ discard block |
||
| 183 | 204 | $this->set_head('js_link_array', $js_array); |
| 184 | 205 | } |
| 185 | 206 | |
| 207 | + /** |
|
| 208 | + * @param string $view |
|
| 209 | + */ |
|
| 186 | 210 | protected function set_body_view($view) |
| 187 | 211 | { |
| 188 | 212 | $this->body_view_array[] = $view; |
@@ -227,6 +251,10 @@ discard block |
||
| 227 | 251 | } |
| 228 | 252 | |
| 229 | 253 | private $comment_errors; |
| 254 | + |
|
| 255 | + /** |
|
| 256 | + * @param string $redirect_url |
|
| 257 | + */ |
|
| 230 | 258 | protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title) |
| 231 | 259 | { |
| 232 | 260 | if(Request::hasPost() && Request::getPost('submit') == 'Submit Comment') |
@@ -238,6 +266,9 @@ discard block |
||
| 238 | 266 | return; |
| 239 | 267 | } |
| 240 | 268 | |
| 269 | + /** |
|
| 270 | + * @param string $site |
|
| 271 | + */ |
|
| 241 | 272 | protected function get_comment_array($site, $path) |
| 242 | 273 | { |
| 243 | 274 | global $container; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $post_result = $activityRepository->getActivities(5); |
| 60 | 60 | |
| 61 | 61 | $post_array = array(); |
| 62 | - foreach($post_result as $row) { |
|
| 62 | + foreach ($post_result as $row) { |
|
| 63 | 63 | array_push($post_array, $this->expand_post($row)); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | ]; |
| 76 | 76 | |
| 77 | 77 | if ($format != 'short') { |
| 78 | - $post['url'] = Loader::getRootUrl('lifestream') . "{$raw_post['type']}/{$raw_post['id']}/"; |
|
| 78 | + $post['url'] = Loader::getRootUrl('lifestream')."{$raw_post['type']}/{$raw_post['id']}/"; |
|
| 79 | 79 | |
| 80 | 80 | $metadata = json_decode($raw_post['metadata'], true); |
| 81 | 81 | $post = array_merge($post, $metadata); |
@@ -95,12 +95,12 @@ discard block |
||
| 95 | 95 | $headers = $this->headers; |
| 96 | 96 | Header::$headers(); |
| 97 | 97 | Loader::load('view', '/Head', $this->data_array['head']); |
| 98 | - foreach($this->body_view_array as $view) |
|
| 98 | + foreach ($this->body_view_array as $view) |
|
| 99 | 99 | { |
| 100 | - if(substr($view, 0, 1) == '/') |
|
| 100 | + if (substr($view, 0, 1) == '/') |
|
| 101 | 101 | Loader::load('view', $view, $this->data_array['body']); |
| 102 | 102 | else |
| 103 | - Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']); |
|
| 103 | + Loader::load('view', URLDecode::getSite().'/'.$view, $this->data_array['body']); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | if (URLDecode::getSite() == 'waterfalls') { |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE)); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if($view == '/404' || $view == '/503') |
|
| 112 | + if ($view == '/404' || $view == '/503') |
|
| 113 | 113 | exit; |
| 114 | 114 | } |
| 115 | 115 | |
@@ -165,14 +165,14 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | private function load_assets() |
| 167 | 167 | { |
| 168 | - $css_array = array_map(function ($stylesheet) { |
|
| 168 | + $css_array = array_map(function($stylesheet) { |
|
| 169 | 169 | $path = "/css/{$stylesheet[0]}.css"; |
| 170 | 170 | if ($stylesheet[1] > 1) { |
| 171 | 171 | $path .= "?v={$stylesheet[1]}"; |
| 172 | 172 | } |
| 173 | 173 | return $path; |
| 174 | 174 | }, $this->css_array); |
| 175 | - $js_array = array_map(function ($script) { |
|
| 175 | + $js_array = array_map(function($script) { |
|
| 176 | 176 | if (substr($script, 0, 4) == 'http') { |
| 177 | 177 | return $script; |
| 178 | 178 | } |
@@ -190,26 +190,26 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | protected function eject() |
| 192 | 192 | { |
| 193 | - if(get_class($this) !== 'Error404Controller') |
|
| 193 | + if (get_class($this) !== 'Error404Controller') |
|
| 194 | 194 | Loader::loadNew('controller', '/Error404Controller')->activate(); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | protected function unavailable() |
| 198 | 198 | { |
| 199 | - if(get_class($this) !== 'Error503Controller') |
|
| 199 | + if (get_class($this) !== 'Error503Controller') |
|
| 200 | 200 | Loader::loadNew('controller', '/Error503Controller')->activate(); |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | protected function redirect($uri, $method = 301) |
| 204 | 204 | { |
| 205 | - switch($method) |
|
| 205 | + switch ($method) |
|
| 206 | 206 | { |
| 207 | 207 | case 301 : |
| 208 | - if(get_class($this) !== 'Error301Controller') |
|
| 208 | + if (get_class($this) !== 'Error301Controller') |
|
| 209 | 209 | Loader::loadNew('controller', '/Error301Controller', array($uri))->activate(); |
| 210 | 210 | break; |
| 211 | 211 | case 303 : |
| 212 | - if(get_class($this) !== 'Error303Controller') |
|
| 212 | + if (get_class($this) !== 'Error303Controller') |
|
| 213 | 213 | Loader::loadNew('controller', '/Error303Controller', array($uri))->activate(); |
| 214 | 214 | break; |
| 215 | 215 | } |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | private $comment_errors; |
| 230 | 230 | protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title) |
| 231 | 231 | { |
| 232 | - if(Request::hasPost() && Request::getPost('submit') == 'Submit Comment') |
|
| 232 | + if (Request::hasPost() && Request::getPost('submit') == 'Submit Comment') |
|
| 233 | 233 | { |
| 234 | 234 | $parameters = array($site_id, $path, $redirect_url, $page_title); |
| 235 | 235 | $this->comment_errors = Loader::loadNew('module', 'form/CommentSubmitModule', $parameters)->activate(); |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | $container['logger']->info("CommentService | Path | {$elapsed}"); |
| 262 | 262 | |
| 263 | 263 | $array = array(); |
| 264 | - foreach((array) $comment_response as $comment) |
|
| 264 | + foreach ((array) $comment_response as $comment) |
|
| 265 | 265 | { |
| 266 | 266 | $body = Content::instance('CleanComment', $comment['body'])->activate(); |
| 267 | 267 | $body = strip_tags($body); |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | Loader::load('collector', 'image/PhotoCollector'); |
| 40 | 40 | $photo_result = PhotoCollector::getRow($id); |
| 41 | 41 | |
| 42 | - if($photo_result == null) |
|
| 42 | + if ($photo_result == null) |
|
| 43 | 43 | return; |
| 44 | 44 | |
| 45 | 45 | $name = $photo_result->name; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $tag_result = $repository->getTagsForPost($post['id']); |
| 85 | 85 | |
| 86 | 86 | $tag_array = array(); |
| 87 | - foreach($tag_result as $tag) |
|
| 87 | + foreach ($tag_result as $tag) |
|
| 88 | 88 | { |
| 89 | 89 | $tag_object = new stdclass(); |
| 90 | 90 | $tag_object->name = $tag['tag']; |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | { |
| 99 | 99 | $body = $post['body']; |
| 100 | 100 | |
| 101 | - if($trim) |
|
| 101 | + if ($trim) |
|
| 102 | 102 | $body = Content::instance('SmartTrim', $body)->activate(self::$LENGTH_OF_TRIMMED_POST); |
| 103 | 103 | |
| 104 | 104 | $body = Content::instance('FixPhoto', $body)->activate(false, 'standard'); |
@@ -124,9 +124,9 @@ discard block |
||
| 124 | 124 | $maximum_tag_count = $this->get_maximum_tag_count($tag_result); |
| 125 | 125 | |
| 126 | 126 | $cloud_array = array(); |
| 127 | - foreach($tag_result as $tag) |
|
| 127 | + foreach ($tag_result as $tag) |
|
| 128 | 128 | { |
| 129 | - if($tag['count'] < self::$MINIMUM_TAG_COUNT) |
|
| 129 | + if ($tag['count'] < self::$MINIMUM_TAG_COUNT) |
|
| 130 | 130 | continue; |
| 131 | 131 | |
| 132 | 132 | $tag_object = new stdclass(); |
@@ -143,9 +143,9 @@ discard block |
||
| 143 | 143 | { |
| 144 | 144 | $maximum = 1; |
| 145 | 145 | |
| 146 | - foreach($tag_result as $tag) |
|
| 146 | + foreach ($tag_result as $tag) |
|
| 147 | 147 | { |
| 148 | - if($tag['count'] > $maximum) |
|
| 148 | + if ($tag['count'] > $maximum) |
|
| 149 | 149 | $maximum = $tag['count']; |
| 150 | 150 | } |
| 151 | 151 | return $maximum; |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | $container['logger']->info("CommentService | Sidebar | {$elapsed}"); |
| 175 | 175 | |
| 176 | 176 | $array = array(); |
| 177 | - foreach($comment_response as $comment) |
|
| 177 | + foreach ($comment_response as $comment) |
|
| 178 | 178 | { |
| 179 | 179 | $body = Content::instance('CleanComment', $comment['body'])->activate(); |
| 180 | 180 | $body = strip_tags($body); |
@@ -82,7 +82,7 @@ |
||
| 82 | 82 | $container['logger']->info("CommentService | Sidebar | {$elapsed}"); |
| 83 | 83 | |
| 84 | 84 | $array = array(); |
| 85 | - foreach($comment_response as $comment) |
|
| 85 | + foreach ($comment_response as $comment) |
|
| 86 | 86 | { |
| 87 | 87 | $body = Content::instance('CleanComment', $comment['body'])->activate(); |
| 88 | 88 | $body = strip_tags($body); |