@@ -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); |
@@ -6,194 +6,194 @@ discard block |
||
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(); |
|
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 | 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 | - ), |
|
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 | - } |
|
86 | + } |
|
87 | 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); |
|
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 | 93 | |
94 | - return $description; |
|
95 | - } |
|
94 | + return $description; |
|
95 | + } |
|
96 | 96 | |
97 | - protected function get_post_keywords() |
|
98 | - { |
|
99 | - $keyword_array = array(); |
|
100 | - $keywords = $this->tags; |
|
97 | + protected function get_post_keywords() |
|
98 | + { |
|
99 | + $keyword_array = array(); |
|
100 | + $keywords = $this->tags; |
|
101 | 101 | |
102 | - foreach($keywords as $keyword) |
|
103 | - { |
|
104 | - $keyword_array[] = $keyword['tag']; |
|
105 | - } |
|
102 | + foreach($keywords as $keyword) |
|
103 | + { |
|
104 | + $keyword_array[] = $keyword['tag']; |
|
105 | + } |
|
106 | 106 | |
107 | - $keyword_array[] = 'blog'; |
|
108 | - $keyword_array[] = 'Jacob Emerick'; |
|
107 | + $keyword_array[] = 'blog'; |
|
108 | + $keyword_array[] = 'Jacob Emerick'; |
|
109 | 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(); |
|
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 | 118 | |
119 | - $previous_post = new stdclass(); |
|
120 | - $next_post = new stdclass(); |
|
119 | + $previous_post = new stdclass(); |
|
120 | + $next_post = new stdclass(); |
|
121 | 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 | - } |
|
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 | 130 | |
131 | - $post = new stdclass(); |
|
131 | + $post = new stdclass(); |
|
132 | 132 | |
133 | - if ( |
|
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 || |
137 | 137 | strpos($post_row['title'], 'Dripping Springs Loop') === 0 |
138 | - ) { |
|
138 | + ) { |
|
139 | 139 | $title = $post_row['title']; |
140 | 140 | $title = explode(':', $title); |
141 | 141 | $title = array_pop($title); |
142 | 142 | $title = trim($title); |
143 | 143 | $post->title = $title; |
144 | - } else if (strpos($post_row['title'], 'Isle Royale') === 0) { |
|
145 | - $title = $post_row['title']; |
|
146 | - $title = explode(',', $title); |
|
147 | - $title = array_pop($title); |
|
148 | - $title = trim($title); |
|
149 | - $post->title = $title; |
|
150 | - } else { |
|
151 | - $post->title = $post_row['title']; |
|
152 | - } |
|
153 | - |
|
154 | - $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
|
144 | + } else if (strpos($post_row['title'], 'Isle Royale') === 0) { |
|
145 | + $title = $post_row['title']; |
|
146 | + $title = explode(',', $title); |
|
147 | + $title = array_pop($title); |
|
148 | + $title = trim($title); |
|
149 | + $post->title = $title; |
|
150 | + } else { |
|
151 | + $post->title = $post_row['title']; |
|
152 | + } |
|
153 | + |
|
154 | + $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
|
155 | 155 | |
156 | - if(!$found_current_post) |
|
157 | - $previous_post = $post; |
|
158 | - else |
|
159 | - { |
|
160 | - $next_post = $post; |
|
161 | - break; |
|
162 | - } |
|
163 | - } |
|
156 | + if(!$found_current_post) |
|
157 | + $previous_post = $post; |
|
158 | + else |
|
159 | + { |
|
160 | + $next_post = $post; |
|
161 | + break; |
|
162 | + } |
|
163 | + } |
|
164 | 164 | |
165 | - return array( |
|
166 | - 'title' => $post_row['series_title'], |
|
167 | - 'description' => Content::instance('FixInternalLink', $post_row['series_description'])->activate(), |
|
168 | - 'previous' => $previous_post, |
|
169 | - 'next' => $next_post); |
|
170 | - } |
|
171 | - |
|
172 | - private $series_posts; |
|
173 | - private function fetch_series_posts() |
|
174 | - { |
|
175 | - if(!isset($this->series_posts)) { |
|
176 | - global $container; |
|
177 | - $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']); |
|
178 | - $this->series_posts = $repository->getSeriesForPost($this->post['id']); |
|
179 | - } |
|
180 | - return $this->series_posts; |
|
181 | - } |
|
182 | - |
|
183 | - private function get_related_posts() |
|
184 | - { |
|
185 | - $tag_array = array(); |
|
186 | - foreach($this->tags as $tag) |
|
187 | - { |
|
188 | - $tag_array[] = $tag['id']; |
|
189 | - } |
|
165 | + return array( |
|
166 | + 'title' => $post_row['series_title'], |
|
167 | + 'description' => Content::instance('FixInternalLink', $post_row['series_description'])->activate(), |
|
168 | + 'previous' => $previous_post, |
|
169 | + 'next' => $next_post); |
|
170 | + } |
|
171 | + |
|
172 | + private $series_posts; |
|
173 | + private function fetch_series_posts() |
|
174 | + { |
|
175 | + if(!isset($this->series_posts)) { |
|
176 | + global $container; |
|
177 | + $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']); |
|
178 | + $this->series_posts = $repository->getSeriesForPost($this->post['id']); |
|
179 | + } |
|
180 | + return $this->series_posts; |
|
181 | + } |
|
182 | + |
|
183 | + private function get_related_posts() |
|
184 | + { |
|
185 | + $tag_array = array(); |
|
186 | + foreach($this->tags as $tag) |
|
187 | + { |
|
188 | + $tag_array[] = $tag['id']; |
|
189 | + } |
|
190 | 190 | |
191 | - $series_posts = $this->fetch_series_posts(); |
|
192 | - $exclude_post_array = array(); |
|
193 | - foreach($series_posts as $series_post) |
|
194 | - { |
|
195 | - $exclude_post_array[] = $series_post['post']; |
|
196 | - } |
|
191 | + $series_posts = $this->fetch_series_posts(); |
|
192 | + $exclude_post_array = array(); |
|
193 | + foreach($series_posts as $series_post) |
|
194 | + { |
|
195 | + $exclude_post_array[] = $series_post['post']; |
|
196 | + } |
|
197 | 197 | |
198 | 198 | global $container; |
199 | 199 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
@@ -201,18 +201,18 @@ discard block |
||
201 | 201 | |
202 | 202 | $post_array = array(); |
203 | 203 | |
204 | - foreach($post_result as $post_row) |
|
205 | - { |
|
206 | - $post = new stdclass(); |
|
207 | - $post->title = $post_row['title']; |
|
208 | - $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
|
209 | - $post->category = ucwords(str_replace('-', ' ', $post_row['category'])); |
|
210 | - $post->thumb = Content::instance('FetchFirstPhoto', $post_row['body'])->activate(); |
|
211 | - $post->body = Content::instance('SmartTrim', $post_row['body'])->activate(($post->thumb !== '') ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG); |
|
204 | + foreach($post_result as $post_row) |
|
205 | + { |
|
206 | + $post = new stdclass(); |
|
207 | + $post->title = $post_row['title']; |
|
208 | + $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
|
209 | + $post->category = ucwords(str_replace('-', ' ', $post_row['category'])); |
|
210 | + $post->thumb = Content::instance('FetchFirstPhoto', $post_row['body'])->activate(); |
|
211 | + $post->body = Content::instance('SmartTrim', $post_row['body'])->activate(($post->thumb !== '') ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG); |
|
212 | 212 | |
213 | - $post_array[] = $post; |
|
214 | - } |
|
213 | + $post_array[] = $post; |
|
214 | + } |
|
215 | 215 | |
216 | - return $post_array; |
|
217 | - } |
|
216 | + return $post_array; |
|
217 | + } |
|
218 | 218 | } |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | Loader::load('collector', 'waterfall/LogCollector'); |
4 | 4 | Loader::load('controller', 'blog/DefaultPageController'); |
5 | 5 | |
6 | -final class PostController extends DefaultPageController |
|
7 | -{ |
|
6 | +final class PostController extends DefaultPageController |
|
7 | +{ |
|
8 | 8 | |
9 | 9 | private static $PAGE_DESCRIPTION_LIMIT = 250; |
10 | 10 | |
@@ -19,16 +19,17 @@ discard block |
||
19 | 19 | private $tags; |
20 | 20 | private $comment_errors = array(); |
21 | 21 | |
22 | - public function __construct() |
|
23 | - { |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | 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 | |
33 | 34 | $this->handle_comment_submit( |
34 | 35 | self::$BLOG_SITE_ID, |
@@ -41,8 +42,8 @@ discard block |
||
41 | 42 | $this->tags = $repository->getTagsForPost($this->post['id']); |
42 | 43 | } |
43 | 44 | |
44 | - protected function set_head_data() |
|
45 | - { |
|
45 | + protected function set_head_data() |
|
46 | + { |
|
46 | 47 | parent::set_head_data(); |
47 | 48 | |
48 | 49 | $this->set_title(sprintf(self::$TITLE, $this->post['title'])); |
@@ -64,10 +65,12 @@ discard block |
||
64 | 65 | } |
65 | 66 | } |
66 | 67 | |
67 | - protected function get_introduction() {} |
|
68 | + protected function get_introduction() |
|
69 | + { |
|
70 | +} |
|
68 | 71 | |
69 | - protected function set_body_data() |
|
70 | - { |
|
72 | + protected function set_body_data() |
|
73 | + { |
|
71 | 74 | parent::set_body_data(); |
72 | 75 | |
73 | 76 | $this->set_body('title', $this->post['title']); |
@@ -85,8 +88,8 @@ discard block |
||
85 | 88 | )); |
86 | 89 | } |
87 | 90 | |
88 | - protected function get_post_description() |
|
89 | - { |
|
91 | + protected function get_post_description() |
|
92 | + { |
|
90 | 93 | $description = $this->post['body']; |
91 | 94 | $description = strip_tags($description); |
92 | 95 | $description = Content::instance('SmartTrim', $description)->activate(self::$PAGE_DESCRIPTION_LIMIT); |
@@ -94,8 +97,8 @@ discard block |
||
94 | 97 | return $description; |
95 | 98 | } |
96 | 99 | |
97 | - protected function get_post_keywords() |
|
98 | - { |
|
100 | + protected function get_post_keywords() |
|
101 | + { |
|
99 | 102 | $keyword_array = array(); |
100 | 103 | $keywords = $this->tags; |
101 | 104 | |
@@ -110,11 +113,12 @@ discard block |
||
110 | 113 | return $keyword_array; |
111 | 114 | } |
112 | 115 | |
113 | - private function get_series_posts() |
|
114 | - { |
|
116 | + private function get_series_posts() |
|
117 | + { |
|
115 | 118 | $series_posts = $this->fetch_series_posts(); |
116 | - if(count($series_posts) < 1) |
|
117 | - return array(); |
|
119 | + if(count($series_posts) < 1) { |
|
120 | + return array(); |
|
121 | + } |
|
118 | 122 | |
119 | 123 | $previous_post = new stdclass(); |
120 | 124 | $next_post = new stdclass(); |
@@ -153,9 +157,9 @@ discard block |
||
153 | 157 | |
154 | 158 | $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
155 | 159 | |
156 | - if(!$found_current_post) |
|
157 | - $previous_post = $post; |
|
158 | - else |
|
160 | + if(!$found_current_post) { |
|
161 | + $previous_post = $post; |
|
162 | + } else |
|
159 | 163 | { |
160 | 164 | $next_post = $post; |
161 | 165 | break; |
@@ -170,8 +174,8 @@ discard block |
||
170 | 174 | } |
171 | 175 | |
172 | 176 | private $series_posts; |
173 | - private function fetch_series_posts() |
|
174 | - { |
|
177 | + private function fetch_series_posts() |
|
178 | + { |
|
175 | 179 | if(!isset($this->series_posts)) { |
176 | 180 | global $container; |
177 | 181 | $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']); |
@@ -180,8 +184,8 @@ discard block |
||
180 | 184 | return $this->series_posts; |
181 | 185 | } |
182 | 186 | |
183 | - private function get_related_posts() |
|
184 | - { |
|
187 | + private function get_related_posts() |
|
188 | + { |
|
185 | 189 | $tag_array = array(); |
186 | 190 | foreach($this->tags as $tag) |
187 | 191 | { |
@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | { |
33 | 33 | parent::set_head_data(); |
34 | 34 | |
35 | - if($this->page == 1) |
|
35 | + if ($this->page == 1) |
|
36 | 36 | $this->set_title(self::$TITLE_MAIN); |
37 | 37 | else |
38 | 38 | $this->set_title(sprintf(self::$TITLE_PAGINATED, $this->page, $this->total_pages)); |
39 | 39 | |
40 | - if($this->page == 1) |
|
40 | + if ($this->page == 1) |
|
41 | 41 | $this->set_description(self::$DESCRIPTION_MAIN); |
42 | 42 | else |
43 | 43 | $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages)); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | protected function get_introduction() |
49 | 49 | { |
50 | - if($this->page == 1) |
|
50 | + if ($this->page == 1) |
|
51 | 51 | { |
52 | 52 | global $container; |
53 | 53 | $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | protected function get_page_number() |
69 | 69 | { |
70 | 70 | $page = URLDecode::getPiece(1); |
71 | - if(isset($page) && is_numeric($page)) |
|
71 | + if (isset($page) && is_numeric($page)) |
|
72 | 72 | return $page; |
73 | 73 | return 1; |
74 | 74 | } |
@@ -90,24 +90,24 @@ discard block |
||
90 | 90 | |
91 | 91 | protected function get_list_next_link() |
92 | 92 | { |
93 | - if($this->page == 1) |
|
93 | + if ($this->page == 1) |
|
94 | 94 | return; |
95 | - if($this->page == 2) |
|
95 | + if ($this->page == 2) |
|
96 | 96 | return '/'; |
97 | - return '/' . ($this->page - 1) . '/'; |
|
97 | + return '/'.($this->page - 1).'/'; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | protected function get_list_prev_link() |
101 | 101 | { |
102 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
102 | + if (($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
103 | 103 | return; |
104 | - return '/' . ($this->page + 1) . '/'; |
|
104 | + return '/'.($this->page + 1).'/'; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | private $total_post_count; |
108 | 108 | protected function get_total_post_count() |
109 | 109 | { |
110 | - if(!isset($this->total_post_count)) { |
|
110 | + if (!isset($this->total_post_count)) { |
|
111 | 111 | global $container; |
112 | 112 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
113 | 113 | $this->total_post_count = $repository->getActivePostsCount(); |
@@ -5,115 +5,115 @@ |
||
5 | 5 | final class HomeController extends DefaultListController |
6 | 6 | { |
7 | 7 | |
8 | - private static $TITLE_MAIN = "Jacob Emerick's Blog | Posts on Hiking, Web Development, and more"; |
|
9 | - private static $TITLE_PAGINATED = "Page %d of %d in Jacob Emerick's Blog"; |
|
10 | - |
|
11 | - private static $DESCRIPTION_MAIN = "Jacob Emerick's Blog - a collection of posts about hiking the Upper Peninsula, learning to be a web developer, and other experiences of a young man."; |
|
12 | - private static $DESCRIPTION_PAGINATED = "Page %d of %d of posts about hiking in the Upper Peninsula, learning to be a web developer, and more on Jacob Emerick's Blog."; |
|
13 | - |
|
14 | - private static $KEYWORD_ARRAY = array( |
|
15 | - 'blog', |
|
16 | - 'Jacob Emerick', |
|
17 | - 'hiking', |
|
18 | - 'Huron Mountains', |
|
19 | - 'Peshekee Highlands', |
|
20 | - 'Keweenaw', |
|
21 | - 'Michigan', |
|
22 | - 'Upper Peninsula', |
|
23 | - 'leadership', |
|
24 | - 'web development', |
|
25 | - 'php programming', |
|
26 | - 'data handling', |
|
27 | - 'optimization'); |
|
28 | - |
|
29 | - private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d total posts.'; |
|
30 | - |
|
31 | - protected function set_head_data() |
|
32 | - { |
|
33 | - parent::set_head_data(); |
|
8 | + private static $TITLE_MAIN = "Jacob Emerick's Blog | Posts on Hiking, Web Development, and more"; |
|
9 | + private static $TITLE_PAGINATED = "Page %d of %d in Jacob Emerick's Blog"; |
|
10 | + |
|
11 | + private static $DESCRIPTION_MAIN = "Jacob Emerick's Blog - a collection of posts about hiking the Upper Peninsula, learning to be a web developer, and other experiences of a young man."; |
|
12 | + private static $DESCRIPTION_PAGINATED = "Page %d of %d of posts about hiking in the Upper Peninsula, learning to be a web developer, and more on Jacob Emerick's Blog."; |
|
13 | + |
|
14 | + private static $KEYWORD_ARRAY = array( |
|
15 | + 'blog', |
|
16 | + 'Jacob Emerick', |
|
17 | + 'hiking', |
|
18 | + 'Huron Mountains', |
|
19 | + 'Peshekee Highlands', |
|
20 | + 'Keweenaw', |
|
21 | + 'Michigan', |
|
22 | + 'Upper Peninsula', |
|
23 | + 'leadership', |
|
24 | + 'web development', |
|
25 | + 'php programming', |
|
26 | + 'data handling', |
|
27 | + 'optimization'); |
|
28 | + |
|
29 | + private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d total posts.'; |
|
30 | + |
|
31 | + protected function set_head_data() |
|
32 | + { |
|
33 | + parent::set_head_data(); |
|
34 | 34 | |
35 | - if($this->page == 1) |
|
36 | - $this->set_title(self::$TITLE_MAIN); |
|
37 | - else |
|
38 | - $this->set_title(sprintf(self::$TITLE_PAGINATED, $this->page, $this->total_pages)); |
|
35 | + if($this->page == 1) |
|
36 | + $this->set_title(self::$TITLE_MAIN); |
|
37 | + else |
|
38 | + $this->set_title(sprintf(self::$TITLE_PAGINATED, $this->page, $this->total_pages)); |
|
39 | 39 | |
40 | - if($this->page == 1) |
|
41 | - $this->set_description(self::$DESCRIPTION_MAIN); |
|
42 | - else |
|
43 | - $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages)); |
|
40 | + if($this->page == 1) |
|
41 | + $this->set_description(self::$DESCRIPTION_MAIN); |
|
42 | + else |
|
43 | + $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages)); |
|
44 | 44 | |
45 | - $this->set_keywords(self::$KEYWORD_ARRAY); |
|
46 | - } |
|
45 | + $this->set_keywords(self::$KEYWORD_ARRAY); |
|
46 | + } |
|
47 | 47 | |
48 | - protected function get_introduction() |
|
49 | - { |
|
50 | - if($this->page == 1) |
|
51 | - { |
|
48 | + protected function get_introduction() |
|
49 | + { |
|
50 | + if($this->page == 1) |
|
51 | + { |
|
52 | 52 | global $container; |
53 | 53 | $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
54 | 54 | $introduction_result = $repository->findByType('home'); |
55 | 55 | |
56 | - $introduction = array(); |
|
57 | - $introduction['title'] = $introduction_result['title']; |
|
58 | - $introduction['content'] = $introduction_result['content']; |
|
59 | - $introduction['image'] = $this->get_introduction_image($introduction_result['image']); |
|
56 | + $introduction = array(); |
|
57 | + $introduction['title'] = $introduction_result['title']; |
|
58 | + $introduction['content'] = $introduction_result['content']; |
|
59 | + $introduction['image'] = $this->get_introduction_image($introduction_result['image']); |
|
60 | 60 | |
61 | - return $introduction; |
|
62 | - } |
|
61 | + return $introduction; |
|
62 | + } |
|
63 | 63 | |
64 | - return array( |
|
65 | - 'title' => "All of Jacob Emerick's posts, page {$this->page} of {$this->total_pages}."); |
|
66 | - } |
|
67 | - |
|
68 | - protected function get_page_number() |
|
69 | - { |
|
70 | - $page = URLDecode::getPiece(1); |
|
71 | - if(isset($page) && is_numeric($page)) |
|
72 | - return $page; |
|
73 | - return 1; |
|
74 | - } |
|
75 | - |
|
76 | - protected function get_list_results() |
|
77 | - { |
|
64 | + return array( |
|
65 | + 'title' => "All of Jacob Emerick's posts, page {$this->page} of {$this->total_pages}."); |
|
66 | + } |
|
67 | + |
|
68 | + protected function get_page_number() |
|
69 | + { |
|
70 | + $page = URLDecode::getPiece(1); |
|
71 | + if(isset($page) && is_numeric($page)) |
|
72 | + return $page; |
|
73 | + return 1; |
|
74 | + } |
|
75 | + |
|
76 | + protected function get_list_results() |
|
77 | + { |
|
78 | 78 | global $container; |
79 | 79 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
80 | 80 | return $repository->getActivePosts(self::$POSTS_PER_PAGE, $this->offset); |
81 | - } |
|
81 | + } |
|
82 | 82 | |
83 | - protected function get_list_description() |
|
84 | - { |
|
85 | - $start = $this->offset + 1; |
|
86 | - $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
83 | + protected function get_list_description() |
|
84 | + { |
|
85 | + $start = $this->offset + 1; |
|
86 | + $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
87 | 87 | |
88 | - return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count()); |
|
89 | - } |
|
90 | - |
|
91 | - protected function get_list_next_link() |
|
92 | - { |
|
93 | - if($this->page == 1) |
|
94 | - return; |
|
95 | - if($this->page == 2) |
|
96 | - return '/'; |
|
97 | - return '/' . ($this->page - 1) . '/'; |
|
98 | - } |
|
99 | - |
|
100 | - protected function get_list_prev_link() |
|
101 | - { |
|
102 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
103 | - return; |
|
104 | - return '/' . ($this->page + 1) . '/'; |
|
105 | - } |
|
106 | - |
|
107 | - private $total_post_count; |
|
108 | - protected function get_total_post_count() |
|
109 | - { |
|
110 | - if(!isset($this->total_post_count)) { |
|
111 | - global $container; |
|
112 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
113 | - $this->total_post_count = $repository->getActivePostsCount(); |
|
114 | - } |
|
115 | - |
|
116 | - return $this->total_post_count; |
|
117 | - } |
|
88 | + return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count()); |
|
89 | + } |
|
90 | + |
|
91 | + protected function get_list_next_link() |
|
92 | + { |
|
93 | + if($this->page == 1) |
|
94 | + return; |
|
95 | + if($this->page == 2) |
|
96 | + return '/'; |
|
97 | + return '/' . ($this->page - 1) . '/'; |
|
98 | + } |
|
99 | + |
|
100 | + protected function get_list_prev_link() |
|
101 | + { |
|
102 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
103 | + return; |
|
104 | + return '/' . ($this->page + 1) . '/'; |
|
105 | + } |
|
106 | + |
|
107 | + private $total_post_count; |
|
108 | + protected function get_total_post_count() |
|
109 | + { |
|
110 | + if(!isset($this->total_post_count)) { |
|
111 | + global $container; |
|
112 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
113 | + $this->total_post_count = $repository->getActivePostsCount(); |
|
114 | + } |
|
115 | + |
|
116 | + return $this->total_post_count; |
|
117 | + } |
|
118 | 118 | |
119 | 119 | } |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'blog/DefaultListController'); |
4 | 4 | |
5 | -final class HomeController extends DefaultListController |
|
6 | -{ |
|
5 | +final class HomeController extends DefaultListController |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | private static $TITLE_MAIN = "Jacob Emerick's Blog | Posts on Hiking, Web Development, and more"; |
9 | 9 | private static $TITLE_PAGINATED = "Page %d of %d in Jacob Emerick's Blog"; |
@@ -28,25 +28,27 @@ discard block |
||
28 | 28 | |
29 | 29 | private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d total posts.'; |
30 | 30 | |
31 | - protected function set_head_data() |
|
32 | - { |
|
31 | + protected function set_head_data() |
|
32 | + { |
|
33 | 33 | parent::set_head_data(); |
34 | 34 | |
35 | - if($this->page == 1) |
|
36 | - $this->set_title(self::$TITLE_MAIN); |
|
37 | - else |
|
38 | - $this->set_title(sprintf(self::$TITLE_PAGINATED, $this->page, $this->total_pages)); |
|
35 | + if($this->page == 1) { |
|
36 | + $this->set_title(self::$TITLE_MAIN); |
|
37 | + } else { |
|
38 | + $this->set_title(sprintf(self::$TITLE_PAGINATED, $this->page, $this->total_pages)); |
|
39 | + } |
|
39 | 40 | |
40 | - if($this->page == 1) |
|
41 | - $this->set_description(self::$DESCRIPTION_MAIN); |
|
42 | - else |
|
43 | - $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages)); |
|
41 | + if($this->page == 1) { |
|
42 | + $this->set_description(self::$DESCRIPTION_MAIN); |
|
43 | + } else { |
|
44 | + $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages)); |
|
45 | + } |
|
44 | 46 | |
45 | 47 | $this->set_keywords(self::$KEYWORD_ARRAY); |
46 | 48 | } |
47 | 49 | |
48 | - protected function get_introduction() |
|
49 | - { |
|
50 | + protected function get_introduction() |
|
51 | + { |
|
50 | 52 | if($this->page == 1) |
51 | 53 | { |
52 | 54 | global $container; |
@@ -65,48 +67,52 @@ discard block |
||
65 | 67 | 'title' => "All of Jacob Emerick's posts, page {$this->page} of {$this->total_pages}."); |
66 | 68 | } |
67 | 69 | |
68 | - protected function get_page_number() |
|
69 | - { |
|
70 | + protected function get_page_number() |
|
71 | + { |
|
70 | 72 | $page = URLDecode::getPiece(1); |
71 | - if(isset($page) && is_numeric($page)) |
|
72 | - return $page; |
|
73 | + if(isset($page) && is_numeric($page)) { |
|
74 | + return $page; |
|
75 | + } |
|
73 | 76 | return 1; |
74 | 77 | } |
75 | 78 | |
76 | - protected function get_list_results() |
|
77 | - { |
|
79 | + protected function get_list_results() |
|
80 | + { |
|
78 | 81 | global $container; |
79 | 82 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
80 | 83 | return $repository->getActivePosts(self::$POSTS_PER_PAGE, $this->offset); |
81 | 84 | } |
82 | 85 | |
83 | - protected function get_list_description() |
|
84 | - { |
|
86 | + protected function get_list_description() |
|
87 | + { |
|
85 | 88 | $start = $this->offset + 1; |
86 | 89 | $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
87 | 90 | |
88 | 91 | return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count()); |
89 | 92 | } |
90 | 93 | |
91 | - protected function get_list_next_link() |
|
92 | - { |
|
93 | - if($this->page == 1) |
|
94 | - return; |
|
95 | - if($this->page == 2) |
|
96 | - return '/'; |
|
94 | + protected function get_list_next_link() |
|
95 | + { |
|
96 | + if($this->page == 1) { |
|
97 | + return; |
|
98 | + } |
|
99 | + if($this->page == 2) { |
|
100 | + return '/'; |
|
101 | + } |
|
97 | 102 | return '/' . ($this->page - 1) . '/'; |
98 | 103 | } |
99 | 104 | |
100 | - protected function get_list_prev_link() |
|
101 | - { |
|
102 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
103 | - return; |
|
105 | + protected function get_list_prev_link() |
|
106 | + { |
|
107 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) { |
|
108 | + return; |
|
109 | + } |
|
104 | 110 | return '/' . ($this->page + 1) . '/'; |
105 | 111 | } |
106 | 112 | |
107 | 113 | private $total_post_count; |
108 | - protected function get_total_post_count() |
|
109 | - { |
|
114 | + protected function get_total_post_count() |
|
115 | + { |
|
110 | 116 | if(!isset($this->total_post_count)) { |
111 | 117 | global $container; |
112 | 118 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | { |
45 | 45 | parent::set_head_data(); |
46 | 46 | |
47 | - if($this->page == 1) |
|
47 | + if ($this->page == 1) |
|
48 | 48 | { |
49 | 49 | $this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->query))); |
50 | 50 | $this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->query))); |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | |
63 | 63 | protected function get_introduction() |
64 | 64 | { |
65 | - if($this->total_pages > 1) |
|
65 | + if ($this->total_pages > 1) |
|
66 | 66 | return array( |
67 | 67 | 'title' => "Posts from search '{$this->query}', page {$this->page} of {$this->total_pages}."); |
68 | - else if($this->total_pages == 1) |
|
68 | + else if ($this->total_pages == 1) |
|
69 | 69 | return array( |
70 | 70 | 'title' => "Posts from search '{$this->query}'."); |
71 | 71 | else |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | protected function get_page_number() |
77 | 77 | { |
78 | 78 | $page = URLDecode::getPiece(3); |
79 | - if(isset($page) && is_numeric($page)) |
|
79 | + if (isset($page) && is_numeric($page)) |
|
80 | 80 | return $page; |
81 | 81 | return 1; |
82 | 82 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | private $search_result; |
85 | 85 | private function get_search_result() |
86 | 86 | { |
87 | - if(!isset($this->search_result)) |
|
87 | + if (!isset($this->search_result)) |
|
88 | 88 | { |
89 | 89 | global $container; |
90 | 90 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
@@ -114,24 +114,24 @@ discard block |
||
114 | 114 | |
115 | 115 | protected function get_list_next_link() |
116 | 116 | { |
117 | - if($this->page == 1) |
|
117 | + if ($this->page == 1) |
|
118 | 118 | return; |
119 | - if($this->page == 2) |
|
119 | + if ($this->page == 2) |
|
120 | 120 | return Content::instance('URLSafe', "/search/{$this->query}/")->activate(); |
121 | - return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page - 1) . '/')->activate(); |
|
121 | + return Content::instance('URLSafe', "/search/{$this->query}/".($this->page - 1).'/')->activate(); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | protected function get_list_prev_link() |
125 | 125 | { |
126 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
126 | + if (($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
127 | 127 | return; |
128 | - return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page + 1) . '/')->activate(); |
|
128 | + return Content::instance('URLSafe', "/search/{$this->query}/".($this->page + 1).'/')->activate(); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | private $total_post_count; |
132 | 132 | protected function get_total_post_count() |
133 | 133 | { |
134 | - if(!isset($this->total_post_count)) |
|
134 | + if (!isset($this->total_post_count)) |
|
135 | 135 | $this->total_post_count = count($this->get_search_result()); |
136 | 136 | return $this->total_post_count; |
137 | 137 | } |
@@ -6,134 +6,134 @@ |
||
6 | 6 | final class SearchController extends DefaultListController |
7 | 7 | { |
8 | 8 | |
9 | - private static $TITLE_MAIN = "%s Search | Jacob Emerick's Blog"; |
|
10 | - private static $DESCRIPTION_MAIN = "Posts containing the phrase %s on Jacob Emerick's Blog."; |
|
11 | - |
|
12 | - private static $TITLE_PAGINATED = "%s Search - Page %d of %d | Jacob Emerick's Blog"; |
|
13 | - private static $DESCRIPTION_PAGINATED = "Page %d of %d with posts containing the phrase %s on Jacob Emerick's Blog."; |
|
14 | - |
|
15 | - private static $KEYWORD_ARRAY = array( |
|
16 | - 'hiking', |
|
17 | - 'web development', |
|
18 | - 'blog', |
|
19 | - 'Jacob Emerick'); |
|
20 | - |
|
21 | - private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d posts containing the phrase %s.'; |
|
22 | - private static $SEARCH_WEIGHTS = array( |
|
23 | - array( |
|
24 | - 'field' => 'title', |
|
25 | - 'weight' => 8), |
|
26 | - array( |
|
27 | - 'field' => 'body', |
|
28 | - 'weight' => 4)); |
|
29 | - |
|
30 | - private $query; |
|
31 | - |
|
32 | - public function __construct() |
|
33 | - { |
|
34 | - $query = URLDecode::getPiece(2); |
|
35 | - $query = urldecode($query); |
|
9 | + private static $TITLE_MAIN = "%s Search | Jacob Emerick's Blog"; |
|
10 | + private static $DESCRIPTION_MAIN = "Posts containing the phrase %s on Jacob Emerick's Blog."; |
|
11 | + |
|
12 | + private static $TITLE_PAGINATED = "%s Search - Page %d of %d | Jacob Emerick's Blog"; |
|
13 | + private static $DESCRIPTION_PAGINATED = "Page %d of %d with posts containing the phrase %s on Jacob Emerick's Blog."; |
|
14 | + |
|
15 | + private static $KEYWORD_ARRAY = array( |
|
16 | + 'hiking', |
|
17 | + 'web development', |
|
18 | + 'blog', |
|
19 | + 'Jacob Emerick'); |
|
20 | + |
|
21 | + private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d posts containing the phrase %s.'; |
|
22 | + private static $SEARCH_WEIGHTS = array( |
|
23 | + array( |
|
24 | + 'field' => 'title', |
|
25 | + 'weight' => 8), |
|
26 | + array( |
|
27 | + 'field' => 'body', |
|
28 | + 'weight' => 4)); |
|
29 | + |
|
30 | + private $query; |
|
31 | + |
|
32 | + public function __construct() |
|
33 | + { |
|
34 | + $query = URLDecode::getPiece(2); |
|
35 | + $query = urldecode($query); |
|
36 | 36 | $query = str_replace('-', ' ', $query); |
37 | 37 | |
38 | - $this->query = $query; |
|
38 | + $this->query = $query; |
|
39 | 39 | |
40 | - parent::__construct(); |
|
41 | - } |
|
40 | + parent::__construct(); |
|
41 | + } |
|
42 | 42 | |
43 | - protected function set_head_data() |
|
44 | - { |
|
45 | - parent::set_head_data(); |
|
43 | + protected function set_head_data() |
|
44 | + { |
|
45 | + parent::set_head_data(); |
|
46 | 46 | |
47 | - if($this->page == 1) |
|
48 | - { |
|
49 | - $this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->query))); |
|
50 | - $this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->query))); |
|
51 | - } |
|
52 | - else |
|
53 | - { |
|
54 | - $this->set_title(sprintf(self::$TITLE_PAGINATED, ucwords($this->query), $this->page, $this->total_pages)); |
|
55 | - $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages, ucwords($this->query))); |
|
56 | - } |
|
47 | + if($this->page == 1) |
|
48 | + { |
|
49 | + $this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->query))); |
|
50 | + $this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->query))); |
|
51 | + } |
|
52 | + else |
|
53 | + { |
|
54 | + $this->set_title(sprintf(self::$TITLE_PAGINATED, ucwords($this->query), $this->page, $this->total_pages)); |
|
55 | + $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages, ucwords($this->query))); |
|
56 | + } |
|
57 | 57 | |
58 | - $keyword_array = self::$KEYWORD_ARRAY; |
|
59 | - array_unshift($keyword_array, $this->query); |
|
60 | - $this->set_keywords($keyword_array); |
|
61 | - } |
|
62 | - |
|
63 | - protected function get_introduction() |
|
64 | - { |
|
65 | - if($this->total_pages > 1) |
|
66 | - return array( |
|
67 | - 'title' => "Posts from search '{$this->query}', page {$this->page} of {$this->total_pages}."); |
|
68 | - else if($this->total_pages == 1) |
|
69 | - return array( |
|
70 | - 'title' => "Posts from search '{$this->query}'."); |
|
71 | - else |
|
72 | - return array( |
|
73 | - 'title' => "Sorry, '{$this->query}' didn't return any posts."); |
|
74 | - } |
|
75 | - |
|
76 | - protected function get_page_number() |
|
77 | - { |
|
78 | - $page = URLDecode::getPiece(3); |
|
79 | - if(isset($page) && is_numeric($page)) |
|
80 | - return $page; |
|
81 | - return 1; |
|
82 | - } |
|
83 | - |
|
84 | - private $search_result; |
|
85 | - private function get_search_result() |
|
86 | - { |
|
87 | - if(!isset($this->search_result)) |
|
88 | - { |
|
58 | + $keyword_array = self::$KEYWORD_ARRAY; |
|
59 | + array_unshift($keyword_array, $this->query); |
|
60 | + $this->set_keywords($keyword_array); |
|
61 | + } |
|
62 | + |
|
63 | + protected function get_introduction() |
|
64 | + { |
|
65 | + if($this->total_pages > 1) |
|
66 | + return array( |
|
67 | + 'title' => "Posts from search '{$this->query}', page {$this->page} of {$this->total_pages}."); |
|
68 | + else if($this->total_pages == 1) |
|
69 | + return array( |
|
70 | + 'title' => "Posts from search '{$this->query}'."); |
|
71 | + else |
|
72 | + return array( |
|
73 | + 'title' => "Sorry, '{$this->query}' didn't return any posts."); |
|
74 | + } |
|
75 | + |
|
76 | + protected function get_page_number() |
|
77 | + { |
|
78 | + $page = URLDecode::getPiece(3); |
|
79 | + if(isset($page) && is_numeric($page)) |
|
80 | + return $page; |
|
81 | + return 1; |
|
82 | + } |
|
83 | + |
|
84 | + private $search_result; |
|
85 | + private function get_search_result() |
|
86 | + { |
|
87 | + if(!isset($this->search_result)) |
|
88 | + { |
|
89 | 89 | global $container; |
90 | 90 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
91 | 91 | $posts = $repository->getActivePosts(); |
92 | 92 | |
93 | - $this->search_result = Search::instance() |
|
94 | - ->setQuery($this->query) |
|
95 | - ->setResult($posts) |
|
96 | - ->setWeight(self::$SEARCH_WEIGHTS) |
|
97 | - ->perform(); |
|
98 | - } |
|
99 | - return $this->search_result; |
|
100 | - } |
|
101 | - |
|
102 | - protected function get_list_results() |
|
103 | - { |
|
104 | - return array_slice($this->get_search_result(), $this->offset, self::$POSTS_PER_PAGE); |
|
105 | - } |
|
106 | - |
|
107 | - protected function get_list_description() |
|
108 | - { |
|
109 | - $start = $this->offset + 1; |
|
110 | - $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
93 | + $this->search_result = Search::instance() |
|
94 | + ->setQuery($this->query) |
|
95 | + ->setResult($posts) |
|
96 | + ->setWeight(self::$SEARCH_WEIGHTS) |
|
97 | + ->perform(); |
|
98 | + } |
|
99 | + return $this->search_result; |
|
100 | + } |
|
101 | + |
|
102 | + protected function get_list_results() |
|
103 | + { |
|
104 | + return array_slice($this->get_search_result(), $this->offset, self::$POSTS_PER_PAGE); |
|
105 | + } |
|
106 | + |
|
107 | + protected function get_list_description() |
|
108 | + { |
|
109 | + $start = $this->offset + 1; |
|
110 | + $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
111 | 111 | |
112 | - return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count(), $this->query); |
|
113 | - } |
|
114 | - |
|
115 | - protected function get_list_next_link() |
|
116 | - { |
|
117 | - if($this->page == 1) |
|
118 | - return; |
|
119 | - if($this->page == 2) |
|
120 | - return Content::instance('URLSafe', "/search/{$this->query}/")->activate(); |
|
121 | - return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page - 1) . '/')->activate(); |
|
122 | - } |
|
123 | - |
|
124 | - protected function get_list_prev_link() |
|
125 | - { |
|
126 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
127 | - return; |
|
128 | - return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page + 1) . '/')->activate(); |
|
129 | - } |
|
130 | - |
|
131 | - private $total_post_count; |
|
132 | - protected function get_total_post_count() |
|
133 | - { |
|
134 | - if(!isset($this->total_post_count)) |
|
135 | - $this->total_post_count = count($this->get_search_result()); |
|
136 | - return $this->total_post_count; |
|
137 | - } |
|
112 | + return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count(), $this->query); |
|
113 | + } |
|
114 | + |
|
115 | + protected function get_list_next_link() |
|
116 | + { |
|
117 | + if($this->page == 1) |
|
118 | + return; |
|
119 | + if($this->page == 2) |
|
120 | + return Content::instance('URLSafe', "/search/{$this->query}/")->activate(); |
|
121 | + return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page - 1) . '/')->activate(); |
|
122 | + } |
|
123 | + |
|
124 | + protected function get_list_prev_link() |
|
125 | + { |
|
126 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
127 | + return; |
|
128 | + return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page + 1) . '/')->activate(); |
|
129 | + } |
|
130 | + |
|
131 | + private $total_post_count; |
|
132 | + protected function get_total_post_count() |
|
133 | + { |
|
134 | + if(!isset($this->total_post_count)) |
|
135 | + $this->total_post_count = count($this->get_search_result()); |
|
136 | + return $this->total_post_count; |
|
137 | + } |
|
138 | 138 | |
139 | 139 | } |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | Loader::load('controller', 'blog/DefaultListController'); |
4 | 4 | Loader::load('utility', 'Search'); |
5 | 5 | |
6 | -final class SearchController extends DefaultListController |
|
7 | -{ |
|
6 | +final class SearchController extends DefaultListController |
|
7 | +{ |
|
8 | 8 | |
9 | 9 | private static $TITLE_MAIN = "%s Search | Jacob Emerick's Blog"; |
10 | 10 | private static $DESCRIPTION_MAIN = "Posts containing the phrase %s on Jacob Emerick's Blog."; |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | |
30 | 30 | private $query; |
31 | 31 | |
32 | - public function __construct() |
|
33 | - { |
|
32 | + public function __construct() |
|
33 | + { |
|
34 | 34 | $query = URLDecode::getPiece(2); |
35 | 35 | $query = urldecode($query); |
36 | 36 | $query = str_replace('-', ' ', $query); |
@@ -40,16 +40,15 @@ discard block |
||
40 | 40 | parent::__construct(); |
41 | 41 | } |
42 | 42 | |
43 | - protected function set_head_data() |
|
44 | - { |
|
43 | + protected function set_head_data() |
|
44 | + { |
|
45 | 45 | parent::set_head_data(); |
46 | 46 | |
47 | 47 | if($this->page == 1) |
48 | 48 | { |
49 | 49 | $this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->query))); |
50 | 50 | $this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->query))); |
51 | - } |
|
52 | - else |
|
51 | + } else |
|
53 | 52 | { |
54 | 53 | $this->set_title(sprintf(self::$TITLE_PAGINATED, ucwords($this->query), $this->page, $this->total_pages)); |
55 | 54 | $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages, ucwords($this->query))); |
@@ -60,30 +59,32 @@ discard block |
||
60 | 59 | $this->set_keywords($keyword_array); |
61 | 60 | } |
62 | 61 | |
63 | - protected function get_introduction() |
|
64 | - { |
|
65 | - if($this->total_pages > 1) |
|
66 | - return array( |
|
67 | - 'title' => "Posts from search '{$this->query}', page {$this->page} of {$this->total_pages}."); |
|
68 | - else if($this->total_pages == 1) |
|
69 | - return array( |
|
70 | - 'title' => "Posts from search '{$this->query}'."); |
|
71 | - else |
|
72 | - return array( |
|
73 | - 'title' => "Sorry, '{$this->query}' didn't return any posts."); |
|
62 | + protected function get_introduction() |
|
63 | + { |
|
64 | + if($this->total_pages > 1) { |
|
65 | + return array( |
|
66 | + 'title' => "Posts from search '{$this->query}', page {$this->page} of {$this->total_pages}."); |
|
67 | + } else if($this->total_pages == 1) { |
|
68 | + return array( |
|
69 | + 'title' => "Posts from search '{$this->query}'."); |
|
70 | + } else { |
|
71 | + return array( |
|
72 | + 'title' => "Sorry, '{$this->query}' didn't return any posts."); |
|
73 | + } |
|
74 | 74 | } |
75 | 75 | |
76 | - protected function get_page_number() |
|
77 | - { |
|
76 | + protected function get_page_number() |
|
77 | + { |
|
78 | 78 | $page = URLDecode::getPiece(3); |
79 | - if(isset($page) && is_numeric($page)) |
|
80 | - return $page; |
|
79 | + if(isset($page) && is_numeric($page)) { |
|
80 | + return $page; |
|
81 | + } |
|
81 | 82 | return 1; |
82 | 83 | } |
83 | 84 | |
84 | 85 | private $search_result; |
85 | - private function get_search_result() |
|
86 | - { |
|
86 | + private function get_search_result() |
|
87 | + { |
|
87 | 88 | if(!isset($this->search_result)) |
88 | 89 | { |
89 | 90 | global $container; |
@@ -99,40 +100,44 @@ discard block |
||
99 | 100 | return $this->search_result; |
100 | 101 | } |
101 | 102 | |
102 | - protected function get_list_results() |
|
103 | - { |
|
103 | + protected function get_list_results() |
|
104 | + { |
|
104 | 105 | return array_slice($this->get_search_result(), $this->offset, self::$POSTS_PER_PAGE); |
105 | 106 | } |
106 | 107 | |
107 | - protected function get_list_description() |
|
108 | - { |
|
108 | + protected function get_list_description() |
|
109 | + { |
|
109 | 110 | $start = $this->offset + 1; |
110 | 111 | $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
111 | 112 | |
112 | 113 | return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count(), $this->query); |
113 | 114 | } |
114 | 115 | |
115 | - protected function get_list_next_link() |
|
116 | - { |
|
117 | - if($this->page == 1) |
|
118 | - return; |
|
119 | - if($this->page == 2) |
|
120 | - return Content::instance('URLSafe', "/search/{$this->query}/")->activate(); |
|
116 | + protected function get_list_next_link() |
|
117 | + { |
|
118 | + if($this->page == 1) { |
|
119 | + return; |
|
120 | + } |
|
121 | + if($this->page == 2) { |
|
122 | + return Content::instance('URLSafe', "/search/{$this->query}/")->activate(); |
|
123 | + } |
|
121 | 124 | return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page - 1) . '/')->activate(); |
122 | 125 | } |
123 | 126 | |
124 | - protected function get_list_prev_link() |
|
125 | - { |
|
126 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
127 | - return; |
|
127 | + protected function get_list_prev_link() |
|
128 | + { |
|
129 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) { |
|
130 | + return; |
|
131 | + } |
|
128 | 132 | return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page + 1) . '/')->activate(); |
129 | 133 | } |
130 | 134 | |
131 | 135 | private $total_post_count; |
132 | - protected function get_total_post_count() |
|
133 | - { |
|
134 | - if(!isset($this->total_post_count)) |
|
135 | - $this->total_post_count = count($this->get_search_result()); |
|
136 | + protected function get_total_post_count() |
|
137 | + { |
|
138 | + if(!isset($this->total_post_count)) { |
|
139 | + $this->total_post_count = count($this->get_search_result()); |
|
140 | + } |
|
136 | 141 | return $this->total_post_count; |
137 | 142 | } |
138 | 143 |
@@ -25,7 +25,7 @@ |
||
25 | 25 | { |
26 | 26 | $this->set_body('body_view', 'Resume'); |
27 | 27 | |
28 | - $resumePath = Loader::getRootURL('portfolio') . "/jsonresume/{$this->resume}"; |
|
28 | + $resumePath = Loader::getRootURL('portfolio')."/jsonresume/{$this->resume}"; |
|
29 | 29 | $resume = file_get_contents($resumePath); |
30 | 30 | $resume = json_decode($resume, true); |
31 | 31 | $this->set_body('body_data', $resume); |
@@ -2,13 +2,13 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'portfolio/DefaultPageController'); |
4 | 4 | |
5 | -class ResumeController extends DefaultPageController |
|
6 | -{ |
|
5 | +class ResumeController extends DefaultPageController |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | protected $resume = 'resume-20160318.json'; |
9 | 9 | |
10 | - protected function set_head_data() |
|
11 | - { |
|
10 | + protected function set_head_data() |
|
11 | + { |
|
12 | 12 | $this->set_title("Resume | Jacob Emerick's Portfolio"); |
13 | 13 | $this->set_description("Resume for Jacob Emerick, a software engineer extraordinaire"); |
14 | 14 | $this->set_keywords([ |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | ]); |
22 | 22 | } |
23 | 23 | |
24 | - protected function set_body_data() |
|
25 | - { |
|
24 | + protected function set_body_data() |
|
25 | + { |
|
26 | 26 | $this->set_body('body_view', 'Resume'); |
27 | 27 | |
28 | 28 | $resumePath = Loader::getRootURL('portfolio') . "/jsonresume/{$this->resume}"; |
@@ -89,7 +89,7 @@ |
||
89 | 89 | |
90 | 90 | return [ |
91 | 91 | 'success' => |
92 | - "Thank you for your message, {$_POST['name']}! " . |
|
92 | + "Thank you for your message, {$_POST['name']}! ". |
|
93 | 93 | "I'll get back to you as soon as possible." |
94 | 94 | ]; |
95 | 95 | } |
@@ -2,11 +2,11 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'portfolio/DefaultPageController'); |
4 | 4 | |
5 | -class ContactController extends DefaultPageController |
|
6 | -{ |
|
5 | +class ContactController extends DefaultPageController |
|
6 | +{ |
|
7 | 7 | |
8 | - protected function set_head_data() |
|
9 | - { |
|
8 | + protected function set_head_data() |
|
9 | + { |
|
10 | 10 | $this->set_title("Contact Page | Jacob Emerick's Portfolio"); |
11 | 11 | $this->set_description("Contact page for Jacob Emerick's Portfolio"); |
12 | 12 | $this->set_keywords([ |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | ]); |
20 | 20 | } |
21 | 21 | |
22 | - protected function set_body_data() |
|
23 | - { |
|
22 | + protected function set_body_data() |
|
23 | + { |
|
24 | 24 | $this->set_body('body_view', 'Contact'); |
25 | 25 | |
26 | 26 | $body_data = []; |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | parent::set_body_data(); |
34 | 34 | } |
35 | 35 | |
36 | - private function process_form_data() |
|
37 | - { |
|
36 | + private function process_form_data() |
|
37 | + { |
|
38 | 38 | $errors = []; |
39 | 39 | |
40 | 40 | if ( |
@@ -33,15 +33,15 @@ discard block |
||
33 | 33 | ], |
34 | 34 | [ |
35 | 35 | 'name' => 'Projects', |
36 | - 'link' => Loader::getRootURL() . 'projects/', |
|
36 | + 'link' => Loader::getRootURL().'projects/', |
|
37 | 37 | ], |
38 | 38 | [ |
39 | 39 | 'name' => 'Résumé', |
40 | - 'link' => Loader::getRootURL() . 'resume/', |
|
40 | + 'link' => Loader::getRootURL().'resume/', |
|
41 | 41 | ], |
42 | 42 | [ |
43 | 43 | 'name' => 'Contact', |
44 | - 'link' => Loader::getRootURL() . 'contact/', |
|
44 | + 'link' => Loader::getRootURL().'contact/', |
|
45 | 45 | ], |
46 | 46 | ]; |
47 | 47 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $active_page = ucfirst(URLDecode::getPiece(1)); |
52 | 52 | } |
53 | 53 | |
54 | - return array_map(function ($row) use ($active_page) { |
|
54 | + return array_map(function($row) use ($active_page) { |
|
55 | 55 | $row = (object) $row; |
56 | 56 | $row->active = ($row->name == $active_page); |
57 | 57 | return $row; |
@@ -2,19 +2,19 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', '/PageController'); |
4 | 4 | |
5 | -abstract class DefaultPageController extends PageController |
|
6 | -{ |
|
5 | +abstract class DefaultPageController extends PageController |
|
6 | +{ |
|
7 | 7 | |
8 | - public function __construct() |
|
9 | - { |
|
8 | + public function __construct() |
|
9 | + { |
|
10 | 10 | parent::__construct(); |
11 | 11 | |
12 | 12 | $this->add_css('reset'); |
13 | 13 | $this->add_css('portfolio', 4); |
14 | 14 | } |
15 | 15 | |
16 | - protected function set_body_data() |
|
17 | - { |
|
16 | + protected function set_body_data() |
|
17 | + { |
|
18 | 18 | $this->set_body('header_data', [ |
19 | 19 | 'menu' => $this->get_menu(), |
20 | 20 | 'home_link' => Loader::getRootURL(), |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | $this->set_body_view('Page'); |
25 | 25 | } |
26 | 26 | |
27 | - protected function get_menu() |
|
28 | - { |
|
27 | + protected function get_menu() |
|
28 | + { |
|
29 | 29 | $menu = [ |
30 | 30 | [ |
31 | 31 | 'name' => 'About', |
@@ -35,16 +35,16 @@ discard block |
||
35 | 35 | |
36 | 36 | private function process_form() |
37 | 37 | { |
38 | - if(!Request::hasPost() || Request::getPost('submit') != 'Send Message!') |
|
38 | + if (!Request::hasPost() || Request::getPost('submit') != 'Send Message!') |
|
39 | 39 | return (object) array('display' => 'normal'); |
40 | 40 | |
41 | 41 | Loader::load('utility', 'Validate'); |
42 | 42 | $error_result = array(); |
43 | - if(!Validate::checkRequest('post', 'name', 'string')) |
|
43 | + if (!Validate::checkRequest('post', 'name', 'string')) |
|
44 | 44 | $error_result['name'] = 'please enter your name'; |
45 | - if(!Validate::checkRequest('post', 'email', 'string')) |
|
45 | + if (!Validate::checkRequest('post', 'email', 'string')) |
|
46 | 46 | $error_result['email'] = 'please enter a valid email'; |
47 | - if(!Validate::checkRequest('post', 'message', 'string')) |
|
47 | + if (!Validate::checkRequest('post', 'message', 'string')) |
|
48 | 48 | $error_result['message'] = 'please write a message'; |
49 | 49 | |
50 | 50 | $values = (object) array( |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | 'email' => Request::getPost('email'), |
53 | 53 | 'message' => Request::getPost('message')); |
54 | 54 | |
55 | - if(count($error_result) > 0) |
|
55 | + if (count($error_result) > 0) |
|
56 | 56 | { |
57 | 57 | return (object) array( |
58 | 58 | 'display' => 'error', |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | ->addTo($container['config']->admin_email) |
66 | 66 | ->setSubject('Home Page Contact') |
67 | 67 | ->setPlainMessage( |
68 | - "Name: {$values->name}\n" . |
|
69 | - "Email: {$values->email}\n" . |
|
68 | + "Name: {$values->name}\n". |
|
69 | + "Email: {$values->email}\n". |
|
70 | 70 | "Message: {$values->message}" |
71 | 71 | ) |
72 | 72 | ->send(); |
@@ -5,71 +5,71 @@ |
||
5 | 5 | final class ContactController extends DefaultPageController |
6 | 6 | { |
7 | 7 | |
8 | - private static $TITLE = 'Contact Jacob Emerick | Waterfalls of the Keweenaw'; |
|
9 | - private static $DESCRIPTION = 'Contact page to reach Jacob Emerick by email or social networks'; |
|
8 | + private static $TITLE = 'Contact Jacob Emerick | Waterfalls of the Keweenaw'; |
|
9 | + private static $DESCRIPTION = 'Contact page to reach Jacob Emerick by email or social networks'; |
|
10 | 10 | |
11 | - private static $KEYWORD_ARRAY = array( |
|
12 | - 'contact', |
|
13 | - 'email', |
|
14 | - 'waterfalls', |
|
15 | - 'Jacob Emerick'); |
|
11 | + private static $KEYWORD_ARRAY = array( |
|
12 | + 'contact', |
|
13 | + 'email', |
|
14 | + 'waterfalls', |
|
15 | + 'Jacob Emerick'); |
|
16 | 16 | |
17 | - protected function set_head_data() |
|
18 | - { |
|
19 | - $this->set_title(self::$TITLE); |
|
20 | - $this->set_description(self::$DESCRIPTION); |
|
21 | - $this->set_keywords(self::$KEYWORD_ARRAY); |
|
17 | + protected function set_head_data() |
|
18 | + { |
|
19 | + $this->set_title(self::$TITLE); |
|
20 | + $this->set_description(self::$DESCRIPTION); |
|
21 | + $this->set_keywords(self::$KEYWORD_ARRAY); |
|
22 | 22 | |
23 | - parent::set_head_data(); |
|
24 | - } |
|
23 | + parent::set_head_data(); |
|
24 | + } |
|
25 | 25 | |
26 | - protected function set_body_data() |
|
27 | - { |
|
28 | - $this->set_body('form_container', $this->process_form()); |
|
29 | - $this->set_body('view', 'Contact'); |
|
26 | + protected function set_body_data() |
|
27 | + { |
|
28 | + $this->set_body('form_container', $this->process_form()); |
|
29 | + $this->set_body('view', 'Contact'); |
|
30 | 30 | |
31 | - parent::set_body_data(); |
|
32 | - } |
|
31 | + parent::set_body_data(); |
|
32 | + } |
|
33 | 33 | |
34 | - private function process_form() |
|
35 | - { |
|
36 | - if(!Request::hasPost() || Request::getPost('submit') != 'Send Message!') |
|
37 | - return (object) array('display' => 'normal'); |
|
34 | + private function process_form() |
|
35 | + { |
|
36 | + if(!Request::hasPost() || Request::getPost('submit') != 'Send Message!') |
|
37 | + return (object) array('display' => 'normal'); |
|
38 | 38 | |
39 | - Loader::load('utility', 'Validate'); |
|
40 | - $error_result = array(); |
|
41 | - if(!Validate::checkRequest('post', 'name', 'string')) |
|
42 | - $error_result['name'] = 'please enter your name'; |
|
43 | - if(!Validate::checkRequest('post', 'email', 'string')) |
|
44 | - $error_result['email'] = 'please enter a valid email'; |
|
45 | - if(!Validate::checkRequest('post', 'message', 'string')) |
|
46 | - $error_result['message'] = 'please write a message'; |
|
39 | + Loader::load('utility', 'Validate'); |
|
40 | + $error_result = array(); |
|
41 | + if(!Validate::checkRequest('post', 'name', 'string')) |
|
42 | + $error_result['name'] = 'please enter your name'; |
|
43 | + if(!Validate::checkRequest('post', 'email', 'string')) |
|
44 | + $error_result['email'] = 'please enter a valid email'; |
|
45 | + if(!Validate::checkRequest('post', 'message', 'string')) |
|
46 | + $error_result['message'] = 'please write a message'; |
|
47 | 47 | |
48 | - $values = (object) array( |
|
49 | - 'name' => Request::getPost('name'), |
|
50 | - 'email' => Request::getPost('email'), |
|
51 | - 'message' => Request::getPost('message')); |
|
48 | + $values = (object) array( |
|
49 | + 'name' => Request::getPost('name'), |
|
50 | + 'email' => Request::getPost('email'), |
|
51 | + 'message' => Request::getPost('message')); |
|
52 | 52 | |
53 | - if(count($error_result) > 0) |
|
54 | - { |
|
55 | - return (object) array( |
|
56 | - 'display' => 'error', |
|
57 | - 'messages' => $error_result, |
|
58 | - 'values' => $values); |
|
59 | - } |
|
53 | + if(count($error_result) > 0) |
|
54 | + { |
|
55 | + return (object) array( |
|
56 | + 'display' => 'error', |
|
57 | + 'messages' => $error_result, |
|
58 | + 'values' => $values); |
|
59 | + } |
|
60 | 60 | |
61 | 61 | global $container; |
62 | 62 | $sent = $container['mail'] |
63 | - ->addTo($container['config']->admin_email) |
|
64 | - ->setSubject('Waterfall Site Contact') |
|
65 | - ->setPlainMessage( |
|
63 | + ->addTo($container['config']->admin_email) |
|
64 | + ->setSubject('Waterfall Site Contact') |
|
65 | + ->setPlainMessage( |
|
66 | 66 | "Name: {$values->name}\n" . |
67 | 67 | "Email: {$values->email}\n" . |
68 | 68 | "Message: {$values->message}" |
69 | - ) |
|
70 | - ->send(); |
|
69 | + ) |
|
70 | + ->send(); |
|
71 | 71 | |
72 | - return (object) array('display' => 'success'); |
|
73 | - } |
|
72 | + return (object) array('display' => 'success'); |
|
73 | + } |
|
74 | 74 | |
75 | 75 | } |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'waterfalls/DefaultPageController'); |
4 | 4 | |
5 | -final class ContactController extends DefaultPageController |
|
6 | -{ |
|
5 | +final class ContactController extends DefaultPageController |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | private static $TITLE = 'Contact Jacob Emerick | Waterfalls of the Keweenaw'; |
9 | 9 | private static $DESCRIPTION = 'Contact page to reach Jacob Emerick by email or social networks'; |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | 'waterfalls', |
15 | 15 | 'Jacob Emerick'); |
16 | 16 | |
17 | - protected function set_head_data() |
|
18 | - { |
|
17 | + protected function set_head_data() |
|
18 | + { |
|
19 | 19 | $this->set_title(self::$TITLE); |
20 | 20 | $this->set_description(self::$DESCRIPTION); |
21 | 21 | $this->set_keywords(self::$KEYWORD_ARRAY); |
@@ -23,27 +23,31 @@ discard block |
||
23 | 23 | parent::set_head_data(); |
24 | 24 | } |
25 | 25 | |
26 | - protected function set_body_data() |
|
27 | - { |
|
26 | + protected function set_body_data() |
|
27 | + { |
|
28 | 28 | $this->set_body('form_container', $this->process_form()); |
29 | 29 | $this->set_body('view', 'Contact'); |
30 | 30 | |
31 | 31 | parent::set_body_data(); |
32 | 32 | } |
33 | 33 | |
34 | - private function process_form() |
|
35 | - { |
|
36 | - if(!Request::hasPost() || Request::getPost('submit') != 'Send Message!') |
|
37 | - return (object) array('display' => 'normal'); |
|
34 | + private function process_form() |
|
35 | + { |
|
36 | + if(!Request::hasPost() || Request::getPost('submit') != 'Send Message!') { |
|
37 | + return (object) array('display' => 'normal'); |
|
38 | + } |
|
38 | 39 | |
39 | 40 | Loader::load('utility', 'Validate'); |
40 | 41 | $error_result = array(); |
41 | - if(!Validate::checkRequest('post', 'name', 'string')) |
|
42 | - $error_result['name'] = 'please enter your name'; |
|
43 | - if(!Validate::checkRequest('post', 'email', 'string')) |
|
44 | - $error_result['email'] = 'please enter a valid email'; |
|
45 | - if(!Validate::checkRequest('post', 'message', 'string')) |
|
46 | - $error_result['message'] = 'please write a message'; |
|
42 | + if(!Validate::checkRequest('post', 'name', 'string')) { |
|
43 | + $error_result['name'] = 'please enter your name'; |
|
44 | + } |
|
45 | + if(!Validate::checkRequest('post', 'email', 'string')) { |
|
46 | + $error_result['email'] = 'please enter a valid email'; |
|
47 | + } |
|
48 | + if(!Validate::checkRequest('post', 'message', 'string')) { |
|
49 | + $error_result['message'] = 'please write a message'; |
|
50 | + } |
|
47 | 51 | |
48 | 52 | $values = (object) array( |
49 | 53 | 'name' => Request::getPost('name'), |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $namespace = 'portfolio'; |
4 | -require_once __DIR__ . '/../../bootstrap.php'; |
|
4 | +require_once __DIR__.'/../../bootstrap.php'; |
|
5 | 5 | |
6 | 6 | // route |
7 | 7 | Loader::loadInstance('router', 'Router'); |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $namespace = 'portfolio'; |
4 | -require_once __DIR__ . '/../../bootstrap.php'; |
|
4 | +require_once __DIR__.'/../../bootstrap.php'; |
|
5 | 5 | |
6 | 6 | // route |
7 | 7 | Loader::loadInstance('router', 'Router'); |