Completed
Push — master ( 6336a8...2eca18 )
by Jacob
07:36
created
controller/blog/PostController.class.inc.php 1 patch
Indentation   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -6,131 +6,131 @@  discard block
 block discarded – undo
6 6
 final class PostController extends DefaultPageController
7 7
 {
8 8
 
9
-	private static $PAGE_DESCRIPTION_LIMIT = 250;
9
+    private static $PAGE_DESCRIPTION_LIMIT = 250;
10 10
 
11
-	private static $TITLE = "%s | Jacob Emerick's Blog";
12
-	private static $AUTHOR = 'Jacob Emerick';
13
-	private static $AUTHOR_URL = 'https://home.jacobemerick.com/';
11
+    private static $TITLE = "%s | Jacob Emerick's Blog";
12
+    private static $AUTHOR = 'Jacob Emerick';
13
+    private static $AUTHOR_URL = 'https://home.jacobemerick.com/';
14 14
 
15
-	private static $POST_LENGTH_SHORT = 100;
16
-	private static $POST_LENGTH_LONG = 140;
15
+    private static $POST_LENGTH_SHORT = 100;
16
+    private static $POST_LENGTH_LONG = 140;
17 17
 
18
-	private $post;
19
-	private $tags;
20
-	private $comment_errors = array();
18
+    private $post;
19
+    private $tags;
20
+    private $comment_errors = array();
21 21
 
22
-	public function __construct()
23
-	{
24
-		parent::__construct();
22
+    public function __construct()
23
+    {
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
-		$this->handle_comment_submit(
34
-			self::$BLOG_SITE_ID,
35
-			$this->post['path'],
36
-			Loader::getRootUrl('blog') . $this->post['category'] . '/' . $this->post['path'] . '/',
37
-			$this->post['title']);
33
+        $this->handle_comment_submit(
34
+            self::$BLOG_SITE_ID,
35
+            $this->post['path'],
36
+            Loader::getRootUrl('blog') . $this->post['category'] . '/' . $this->post['path'] . '/',
37
+            $this->post['title']);
38 38
 
39 39
         global $container;
40 40
         $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']);
41 41
         $this->tags = $repository->getTagsForPost($this->post['id']);
42
-	}
42
+    }
43 43
 
44
-	protected function set_head_data()
45
-	{
46
-		parent::set_head_data();
44
+    protected function set_head_data()
45
+    {
46
+        parent::set_head_data();
47 47
 
48
-		$this->set_title(sprintf(self::$TITLE, $this->post['title']));
49
-		$this->set_description($this->get_post_description());
50
-		$this->set_keywords($this->get_post_keywords());
51
-		$this->set_author(self::$AUTHOR);
48
+        $this->set_title(sprintf(self::$TITLE, $this->post['title']));
49
+        $this->set_description($this->get_post_description());
50
+        $this->set_keywords($this->get_post_keywords());
51
+        $this->set_author(self::$AUTHOR);
52 52
 
53 53
     $photo = Content::instance('FetchFirstPhoto', $this->post['body'])->activate(true);
54 54
     $photo = preg_match('/^<img src="([a-z-:\.\/]+)" [^>]+>$/', $photo, $matches);
55 55
     $this->set_head('thumbnail', $matches[1]);
56 56
 
57
-		if (array_key_exists($this->post['id'], self::$DEPRECATED_BLOGS)) {
58
-			$log_id = self::$DEPRECATED_BLOGS[$this->post['id']];
59
-			$log = LogCollector::getById($log_id);
60
-			if (!empty($log)) {
61
-				$log_url = Loader::getRootUrl('waterfalls') . "journal/{$log->alias}/";
62
-				$this->set_canonical($log_url);
63
-			}
64
-		}
65
-	}
66
-
67
-	protected function get_introduction() {}
68
-
69
-	protected function set_body_data()
70
-	{
71
-		parent::set_body_data();
72
-
73
-		$this->set_body('title', $this->post['title']);
74
-		$this->set_body('view', 'Post');
75
-		$this->set_body('data', array(
76
-			'post' => $this->format_post($this->post, false),
77
-			'series_posts' => $this->get_series_posts(),
78
-			'related_posts' => $this->get_related_posts(),
79
-			'author' => self::$AUTHOR,
80
-			'author_url' => self::$AUTHOR_URL,
81
-      'comment_array' => $this->get_comment_array(
82
-          'blog.jacobemerick.com',
83
-          "{$this->post['category']}/{$this->post['path']}"
84
-      ),
57
+        if (array_key_exists($this->post['id'], self::$DEPRECATED_BLOGS)) {
58
+            $log_id = self::$DEPRECATED_BLOGS[$this->post['id']];
59
+            $log = LogCollector::getById($log_id);
60
+            if (!empty($log)) {
61
+                $log_url = Loader::getRootUrl('waterfalls') . "journal/{$log->alias}/";
62
+                $this->set_canonical($log_url);
63
+            }
64
+        }
65
+    }
66
+
67
+    protected function get_introduction() {}
68
+
69
+    protected function set_body_data()
70
+    {
71
+        parent::set_body_data();
72
+
73
+        $this->set_body('title', $this->post['title']);
74
+        $this->set_body('view', 'Post');
75
+        $this->set_body('data', array(
76
+            'post' => $this->format_post($this->post, false),
77
+            'series_posts' => $this->get_series_posts(),
78
+            'related_posts' => $this->get_related_posts(),
79
+            'author' => self::$AUTHOR,
80
+            'author_url' => self::$AUTHOR_URL,
81
+        'comment_array' => $this->get_comment_array(
82
+            'blog.jacobemerick.com',
83
+            "{$this->post['category']}/{$this->post['path']}"
84
+        ),
85 85
     ));
86
-	}
87
-
88
-	protected function get_post_description()
89
-	{
90
-		$description = $this->post['body'];
91
-		$description = strip_tags($description);
92
-		$description = Content::instance('SmartTrim', $description)->activate(self::$PAGE_DESCRIPTION_LIMIT);
93
-
94
-		return $description;
95
-	}
96
-
97
-	protected function get_post_keywords()
98
-	{
99
-		$keyword_array = array();
100
-		$keywords = $this->tags;
101
-
102
-		foreach($keywords as $keyword)
103
-		{
104
-			$keyword_array[] = $keyword['tag'];
105
-		}
106
-
107
-		$keyword_array[] = 'blog';
108
-		$keyword_array[] = 'Jacob Emerick';
109
-
110
-		return $keyword_array;
111
-	}
112
-
113
-	private function get_series_posts()
114
-	{
115
-		$series_posts = $this->fetch_series_posts();
116
-		if(count($series_posts) < 1)
117
-			return array();
118
-
119
-		$previous_post = new stdclass();
120
-		$next_post = new stdclass();
121
-
122
-		$found_current_post = false;
123
-		foreach($series_posts as $post_row)
124
-		{
125
-			if($post_row['post'] == $this->post['id'])
126
-			{
127
-				$found_current_post = true;
128
-				continue;
129
-			}
130
-
131
-			$post = new stdclass();
132
-
133
-      if (
86
+    }
87
+
88
+    protected function get_post_description()
89
+    {
90
+        $description = $this->post['body'];
91
+        $description = strip_tags($description);
92
+        $description = Content::instance('SmartTrim', $description)->activate(self::$PAGE_DESCRIPTION_LIMIT);
93
+
94
+        return $description;
95
+    }
96
+
97
+    protected function get_post_keywords()
98
+    {
99
+        $keyword_array = array();
100
+        $keywords = $this->tags;
101
+
102
+        foreach($keywords as $keyword)
103
+        {
104
+            $keyword_array[] = $keyword['tag'];
105
+        }
106
+
107
+        $keyword_array[] = 'blog';
108
+        $keyword_array[] = 'Jacob Emerick';
109
+
110
+        return $keyword_array;
111
+    }
112
+
113
+    private function get_series_posts()
114
+    {
115
+        $series_posts = $this->fetch_series_posts();
116
+        if(count($series_posts) < 1)
117
+            return array();
118
+
119
+        $previous_post = new stdclass();
120
+        $next_post = new stdclass();
121
+
122
+        $found_current_post = false;
123
+        foreach($series_posts as $post_row)
124
+        {
125
+            if($post_row['post'] == $this->post['id'])
126
+            {
127
+                $found_current_post = true;
128
+                continue;
129
+            }
130
+
131
+            $post = new stdclass();
132
+
133
+        if (
134 134
         strpos($post_row['title'], 'Rainy Supe Loop') === 0 ||
135 135
         strpos($post_row['title'], 'Malapais Loop') === 0 ||
136 136
         strpos($post_row['title'], 'Mazatzal Peak Loop') === 0 ||
@@ -141,65 +141,65 @@  discard block
 block discarded – undo
141 141
         strpos($post_row['title'], 'Upper Mazzie Loop') === 0 ||
142 142
         strpos($post_row['title'], 'Moody-Coon Loop') === 0 ||
143 143
         strpos($post_row['title'], 'Intro to Blue Range') === 0
144
-      ) {
144
+        ) {
145 145
         $title = $post_row['title'];
146 146
         $title = explode(':', $title);
147 147
         $title = array_pop($title);
148 148
         $title = trim($title);
149 149
         $post->title = $title;
150
-      } else if (strpos($post_row['title'], 'Isle Royale') === 0) {
151
-				$title = $post_row['title'];
152
-				$title = explode(',', $title);
153
-				$title = array_pop($title);
154
-				$title = trim($title);
155
-				$post->title = $title;
156
-			} else {
157
-				$post->title = $post_row['title'];
158
-			}
159
-
160
-			$post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/";
161
-
162
-			if(!$found_current_post)
163
-				$previous_post = $post;
164
-			else
165
-			{
166
-				$next_post = $post;
167
-				break;
168
-			}
169
-		}
170
-
171
-		return array(
172
-			'title' => $post_row['series_title'],
173
-			'description' => Content::instance('FixInternalLink', $post_row['series_description'])->activate(),
174
-			'previous' => $previous_post,
175
-			'next' => $next_post);
176
-	}
177
-
178
-	private $series_posts;
179
-	private function fetch_series_posts()
180
-	{
181
-      if(!isset($this->series_posts)) {
182
-          global $container;
183
-          $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']);
184
-          $this->series_posts = $repository->getSeriesForPost($this->post['id']);
185
-      }
186
-      return $this->series_posts;
187
-	}
188
-
189
-	private function get_related_posts()
190
-	{
191
-		$tag_array = array();
192
-		foreach($this->tags as $tag)
193
-		{
194
-			$tag_array[] = $tag['id'];
195
-		}
196
-
197
-		$series_posts = $this->fetch_series_posts();
198
-		$exclude_post_array = array();
199
-		foreach($series_posts as $series_post)
200
-		{
201
-			$exclude_post_array[] = $series_post['post'];
202
-		}
150
+        } else if (strpos($post_row['title'], 'Isle Royale') === 0) {
151
+                $title = $post_row['title'];
152
+                $title = explode(',', $title);
153
+                $title = array_pop($title);
154
+                $title = trim($title);
155
+                $post->title = $title;
156
+            } else {
157
+                $post->title = $post_row['title'];
158
+            }
159
+
160
+            $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/";
161
+
162
+            if(!$found_current_post)
163
+                $previous_post = $post;
164
+            else
165
+            {
166
+                $next_post = $post;
167
+                break;
168
+            }
169
+        }
170
+
171
+        return array(
172
+            'title' => $post_row['series_title'],
173
+            'description' => Content::instance('FixInternalLink', $post_row['series_description'])->activate(),
174
+            'previous' => $previous_post,
175
+            'next' => $next_post);
176
+    }
177
+
178
+    private $series_posts;
179
+    private function fetch_series_posts()
180
+    {
181
+        if(!isset($this->series_posts)) {
182
+            global $container;
183
+            $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']);
184
+            $this->series_posts = $repository->getSeriesForPost($this->post['id']);
185
+        }
186
+        return $this->series_posts;
187
+    }
188
+
189
+    private function get_related_posts()
190
+    {
191
+        $tag_array = array();
192
+        foreach($this->tags as $tag)
193
+        {
194
+            $tag_array[] = $tag['id'];
195
+        }
196
+
197
+        $series_posts = $this->fetch_series_posts();
198
+        $exclude_post_array = array();
199
+        foreach($series_posts as $series_post)
200
+        {
201
+            $exclude_post_array[] = $series_post['post'];
202
+        }
203 203
 
204 204
         global $container;
205 205
         $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
@@ -207,18 +207,18 @@  discard block
 block discarded – undo
207 207
 
208 208
         $post_array = array();
209 209
 
210
-		foreach($post_result as $post_row)
211
-		{
212
-			$post = new stdclass();
213
-			$post->title = $post_row['title'];
214
-			$post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/";
215
-			$post->category = ucwords(str_replace('-', ' ', $post_row['category']));
216
-			$post->thumb = Content::instance('FetchFirstPhoto', $post_row['body'])->activate();
217
-			$post->body = Content::instance('SmartTrim', $post_row['body'])->activate(($post->thumb !== '') ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG);
210
+        foreach($post_result as $post_row)
211
+        {
212
+            $post = new stdclass();
213
+            $post->title = $post_row['title'];
214
+            $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/";
215
+            $post->category = ucwords(str_replace('-', ' ', $post_row['category']));
216
+            $post->thumb = Content::instance('FetchFirstPhoto', $post_row['body'])->activate();
217
+            $post->body = Content::instance('SmartTrim', $post_row['body'])->activate(($post->thumb !== '') ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG);
218 218
 
219
-			$post_array[] = $post;
220
-		}
219
+            $post_array[] = $post;
220
+        }
221 221
 
222
-		return $post_array;
223
-	}
222
+        return $post_array;
223
+    }
224 224
 }
Please login to merge, or discard this patch.