@@ -5,13 +5,13 @@ discard block |
||
5 | 5 | final class CommentCollector extends Collector |
6 | 6 | { |
7 | 7 | |
8 | - public static function getCommenterByFields($name, $email, $website) |
|
9 | - { |
|
10 | - $name = self::escape($name); |
|
11 | - $email = self::escape($email); |
|
12 | - $website = self::escape($website); |
|
8 | + public static function getCommenterByFields($name, $email, $website) |
|
9 | + { |
|
10 | + $name = self::escape($name); |
|
11 | + $email = self::escape($email); |
|
12 | + $website = self::escape($website); |
|
13 | 13 | |
14 | - $query = " |
|
14 | + $query = " |
|
15 | 15 | SELECT |
16 | 16 | * |
17 | 17 | FROM |
@@ -22,14 +22,14 @@ discard block |
||
22 | 22 | `url` = '{$website}' |
23 | 23 | LIMIT 1"; |
24 | 24 | |
25 | - return self::run_row_query($query); |
|
26 | - } |
|
25 | + return self::run_row_query($query); |
|
26 | + } |
|
27 | 27 | |
28 | - public static function getCommentByBody($body) |
|
29 | - { |
|
30 | - $body = self::escape($body); |
|
28 | + public static function getCommentByBody($body) |
|
29 | + { |
|
30 | + $body = self::escape($body); |
|
31 | 31 | |
32 | - $query = " |
|
32 | + $query = " |
|
33 | 33 | SELECT |
34 | 34 | * |
35 | 35 | FROM |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | `body` = '{$body}' |
39 | 39 | LIMIT 1"; |
40 | 40 | |
41 | - return self::run_row_query($query); |
|
42 | - } |
|
41 | + return self::run_row_query($query); |
|
42 | + } |
|
43 | 43 | |
44 | - public static function getCommentPageByURL($path, $site) |
|
45 | - { |
|
46 | - $path = self::escape($path); |
|
44 | + public static function getCommentPageByURL($path, $site) |
|
45 | + { |
|
46 | + $path = self::escape($path); |
|
47 | 47 | |
48 | - $query = " |
|
48 | + $query = " |
|
49 | 49 | SELECT |
50 | 50 | * |
51 | 51 | FROM |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | LIMIT |
57 | 57 | 1"; |
58 | 58 | |
59 | - return self::run_row_query($query); |
|
60 | - } |
|
59 | + return self::run_row_query($query); |
|
60 | + } |
|
61 | 61 | |
62 | - public static function getNotificationForPage($comment_page) |
|
63 | - { |
|
64 | - $query = " |
|
62 | + public static function getNotificationForPage($comment_page) |
|
63 | + { |
|
64 | + $query = " |
|
65 | 65 | SELECT |
66 | 66 | `name`, |
67 | 67 | `email` |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | ORDER BY |
81 | 81 | `date` DESC"; |
82 | 82 | |
83 | - return self::run_query($query); |
|
84 | - } |
|
83 | + return self::run_query($query); |
|
84 | + } |
|
85 | 85 | |
86 | - public static function getRecentBlogComments($count) |
|
87 | - { |
|
88 | - $query = " |
|
86 | + public static function getRecentBlogComments($count) |
|
87 | + { |
|
88 | + $query = " |
|
89 | 89 | SELECT |
90 | 90 | `comment_meta`.`id`, |
91 | 91 | `post`.`category`, |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | `comment_meta`.`date` DESC |
112 | 112 | LIMIT {$count}"; |
113 | 113 | |
114 | - return self::run_query($query); |
|
115 | - } |
|
114 | + return self::run_query($query); |
|
115 | + } |
|
116 | 116 | |
117 | 117 | public static function getRecentWaterfallComments($count = 5) |
118 | 118 | { |
@@ -159,16 +159,16 @@ discard block |
||
159 | 159 | return self::run_query($query); |
160 | 160 | } |
161 | 161 | |
162 | - public static function getCommentsForURL($site, $path, $commenter = 0) |
|
163 | - { |
|
164 | - $path = self::escape($path); |
|
162 | + public static function getCommentsForURL($site, $path, $commenter = 0) |
|
163 | + { |
|
164 | + $path = self::escape($path); |
|
165 | 165 | |
166 | - if($commenter != 0) |
|
167 | - $trusted_commenter_clause = "(`commenter`.`trusted` = '1' || `commenter`.`id` = '{$commenter}')"; |
|
168 | - else |
|
169 | - $trusted_commenter_clause = "`commenter`.`trusted` = '1'"; |
|
166 | + if($commenter != 0) |
|
167 | + $trusted_commenter_clause = "(`commenter`.`trusted` = '1' || `commenter`.`id` = '{$commenter}')"; |
|
168 | + else |
|
169 | + $trusted_commenter_clause = "`commenter`.`trusted` = '1'"; |
|
170 | 170 | |
171 | - $query = " |
|
171 | + $query = " |
|
172 | 172 | SELECT |
173 | 173 | `comment_meta`.`id`, |
174 | 174 | `comment_meta`.`reply`, |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | ORDER BY |
195 | 195 | `comment_meta`.`date`"; |
196 | 196 | |
197 | - return self::run_query($query); |
|
198 | - } |
|
197 | + return self::run_query($query); |
|
198 | + } |
|
199 | 199 | |
200 | - public static function getCommentCountForURL($site, $path) |
|
201 | - { |
|
202 | - $path = self::escape($path); |
|
200 | + public static function getCommentCountForURL($site, $path) |
|
201 | + { |
|
202 | + $path = self::escape($path); |
|
203 | 203 | |
204 | - $query = " |
|
204 | + $query = " |
|
205 | 205 | SELECT |
206 | 206 | COUNT(1) AS `count` |
207 | 207 | FROM |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | ORDER BY |
219 | 219 | `comment_meta`.`date`"; |
220 | 220 | |
221 | - return self::get_count($query); |
|
222 | - } |
|
221 | + return self::get_count($query); |
|
222 | + } |
|
223 | 223 | |
224 | 224 | } |
225 | 225 | \ No newline at end of file |
@@ -5,29 +5,29 @@ |
||
5 | 5 | abstract class Collector |
6 | 6 | { |
7 | 7 | |
8 | - protected static function run_query($query) |
|
9 | - { |
|
10 | - return Database::select($query); |
|
11 | - } |
|
12 | - |
|
13 | - protected static function run_row_query($query) |
|
14 | - { |
|
15 | - return Database::selectRow($query); |
|
16 | - } |
|
17 | - |
|
18 | - protected static function get_count($query) |
|
19 | - { |
|
20 | - return Database::selectRow($query)->count; |
|
21 | - } |
|
22 | - |
|
23 | - protected static function check_exists($query) |
|
24 | - { |
|
25 | - return Database::selectRow($query) !== null; |
|
26 | - } |
|
27 | - |
|
28 | - protected static function escape($string) |
|
29 | - { |
|
30 | - return Database::escape($string); |
|
31 | - } |
|
8 | + protected static function run_query($query) |
|
9 | + { |
|
10 | + return Database::select($query); |
|
11 | + } |
|
12 | + |
|
13 | + protected static function run_row_query($query) |
|
14 | + { |
|
15 | + return Database::selectRow($query); |
|
16 | + } |
|
17 | + |
|
18 | + protected static function get_count($query) |
|
19 | + { |
|
20 | + return Database::selectRow($query)->count; |
|
21 | + } |
|
22 | + |
|
23 | + protected static function check_exists($query) |
|
24 | + { |
|
25 | + return Database::selectRow($query) !== null; |
|
26 | + } |
|
27 | + |
|
28 | + protected static function escape($string) |
|
29 | + { |
|
30 | + return Database::escape($string); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | } |
@@ -5,136 +5,136 @@ |
||
5 | 5 | final class TagController extends DefaultListController |
6 | 6 | { |
7 | 7 | |
8 | - private static $TITLE_MAIN = "%s Tag | Jacob Emerick's Blog"; |
|
9 | - private static $DESCRIPTION_MAIN = "Posts tagged with %s on Jacob Emerick's Blog, a website about Upper Peninsula hiking and web development best practices."; |
|
8 | + private static $TITLE_MAIN = "%s Tag | Jacob Emerick's Blog"; |
|
9 | + private static $DESCRIPTION_MAIN = "Posts tagged with %s on Jacob Emerick's Blog, a website about Upper Peninsula hiking and web development best practices."; |
|
10 | 10 | |
11 | - private static $TITLE_PAGINATED = "%s - Page %d of %d | Jacob Emerick's Blog"; |
|
12 | - private static $DESCRIPTION_PAGINATED = "Page %d of %d with posts tagged with %s on Jacob Emerick's Blog, a website about the hiking and development adventures of a young man."; |
|
11 | + private static $TITLE_PAGINATED = "%s - Page %d of %d | Jacob Emerick's Blog"; |
|
12 | + private static $DESCRIPTION_PAGINATED = "Page %d of %d with posts tagged with %s on Jacob Emerick's Blog, a website about the hiking and development adventures of a young man."; |
|
13 | 13 | |
14 | - private static $KEYWORD_ARRAY = array( |
|
15 | - 'hiking', |
|
16 | - 'web development', |
|
17 | - 'blog', |
|
18 | - 'Jacob Emerick'); |
|
14 | + private static $KEYWORD_ARRAY = array( |
|
15 | + 'hiking', |
|
16 | + 'web development', |
|
17 | + 'blog', |
|
18 | + 'Jacob Emerick'); |
|
19 | 19 | |
20 | - private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d posts tagged with %s.'; |
|
20 | + private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d posts tagged with %s.'; |
|
21 | 21 | |
22 | - private $tag; |
|
22 | + private $tag; |
|
23 | 23 | |
24 | - public function __construct() |
|
25 | - { |
|
26 | - $tag = URLDecode::getPiece(2); |
|
27 | - $tag = str_replace('-', ' ', $tag); |
|
24 | + public function __construct() |
|
25 | + { |
|
26 | + $tag = URLDecode::getPiece(2); |
|
27 | + $tag = str_replace('-', ' ', $tag); |
|
28 | 28 | |
29 | 29 | global $container; |
30 | 30 | $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
31 | 31 | $tag_result = $repository->findTagByTitle($tag); |
32 | 32 | |
33 | - if($tag_result === false) |
|
34 | - $this->eject(); |
|
33 | + if($tag_result === false) |
|
34 | + $this->eject(); |
|
35 | 35 | |
36 | - $this->tag = $tag_result; |
|
36 | + $this->tag = $tag_result; |
|
37 | 37 | |
38 | - parent::__construct(); |
|
39 | - } |
|
38 | + parent::__construct(); |
|
39 | + } |
|
40 | 40 | |
41 | - protected function set_head_data() |
|
42 | - { |
|
43 | - parent::set_head_data(); |
|
41 | + protected function set_head_data() |
|
42 | + { |
|
43 | + parent::set_head_data(); |
|
44 | 44 | |
45 | - if($this->page == 1) |
|
46 | - { |
|
47 | - $this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->tag['tag']))); |
|
48 | - $this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->tag['tag']))); |
|
49 | - } |
|
50 | - else |
|
51 | - { |
|
52 | - $this->set_title(sprintf(self::$TITLE_PAGINATED, ucwords($this->tag['tag']), $this->page, $this->total_pages)); |
|
53 | - $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages, ucwords($this->tag['tag']))); |
|
54 | - } |
|
45 | + if($this->page == 1) |
|
46 | + { |
|
47 | + $this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->tag['tag']))); |
|
48 | + $this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->tag['tag']))); |
|
49 | + } |
|
50 | + else |
|
51 | + { |
|
52 | + $this->set_title(sprintf(self::$TITLE_PAGINATED, ucwords($this->tag['tag']), $this->page, $this->total_pages)); |
|
53 | + $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages, ucwords($this->tag['tag']))); |
|
54 | + } |
|
55 | 55 | |
56 | - $keyword_array = self::$KEYWORD_ARRAY; |
|
57 | - array_unshift($keyword_array, $this->tag['tag']); |
|
58 | - $this->set_keywords($keyword_array); |
|
59 | - } |
|
60 | - |
|
61 | - protected function get_introduction() |
|
62 | - { |
|
63 | - $tag = ucwords($this->tag['tag']); |
|
56 | + $keyword_array = self::$KEYWORD_ARRAY; |
|
57 | + array_unshift($keyword_array, $this->tag['tag']); |
|
58 | + $this->set_keywords($keyword_array); |
|
59 | + } |
|
60 | + |
|
61 | + protected function get_introduction() |
|
62 | + { |
|
63 | + $tag = ucwords($this->tag['tag']); |
|
64 | 64 | |
65 | - if($this->page == 1) |
|
66 | - { |
|
65 | + if($this->page == 1) |
|
66 | + { |
|
67 | 67 | global $container; |
68 | 68 | $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
69 | 69 | $introduction_result = $repository->findByType('tag', $this->tag['tag']); |
70 | 70 | |
71 | - if($introduction_result !== false) |
|
72 | - { |
|
73 | - $introduction = array(); |
|
74 | - $introduction['title'] = $introduction_result['title']; |
|
75 | - $introduction['content'] = $introduction_result['content']; |
|
76 | - $introduction['image'] = $this->get_introduction_image($introduction_result['image']); |
|
71 | + if($introduction_result !== false) |
|
72 | + { |
|
73 | + $introduction = array(); |
|
74 | + $introduction['title'] = $introduction_result['title']; |
|
75 | + $introduction['content'] = $introduction_result['content']; |
|
76 | + $introduction['image'] = $this->get_introduction_image($introduction_result['image']); |
|
77 | 77 | |
78 | - return $introduction; |
|
79 | - } |
|
78 | + return $introduction; |
|
79 | + } |
|
80 | 80 | |
81 | - return array( |
|
82 | - 'title' => "Viewing posts about {$tag}."); |
|
83 | - } |
|
81 | + return array( |
|
82 | + 'title' => "Viewing posts about {$tag}."); |
|
83 | + } |
|
84 | 84 | |
85 | - return array( |
|
86 | - 'title' => "{$tag} posts, page {$this->page} of {$this->total_pages}."); |
|
87 | - } |
|
88 | - |
|
89 | - protected function get_page_number() |
|
90 | - { |
|
91 | - $page = URLDecode::getPiece(3); |
|
92 | - if(isset($page) && is_numeric($page)) |
|
93 | - return $page; |
|
94 | - return 1; |
|
95 | - } |
|
96 | - |
|
97 | - protected function get_list_results() |
|
98 | - { |
|
85 | + return array( |
|
86 | + 'title' => "{$tag} posts, page {$this->page} of {$this->total_pages}."); |
|
87 | + } |
|
88 | + |
|
89 | + protected function get_page_number() |
|
90 | + { |
|
91 | + $page = URLDecode::getPiece(3); |
|
92 | + if(isset($page) && is_numeric($page)) |
|
93 | + return $page; |
|
94 | + return 1; |
|
95 | + } |
|
96 | + |
|
97 | + protected function get_list_results() |
|
98 | + { |
|
99 | 99 | global $container; |
100 | 100 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
101 | 101 | return $repository->getActivePostsByTag($this->tag['id'], self::$POSTS_PER_PAGE, $this->offset); |
102 | - } |
|
102 | + } |
|
103 | 103 | |
104 | - protected function get_list_description() |
|
105 | - { |
|
106 | - $start = $this->offset + 1; |
|
107 | - $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
104 | + protected function get_list_description() |
|
105 | + { |
|
106 | + $start = $this->offset + 1; |
|
107 | + $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
108 | 108 | |
109 | - return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count(), $this->tag['tag']); |
|
110 | - } |
|
111 | - |
|
112 | - protected function get_list_next_link() |
|
113 | - { |
|
114 | - if($this->page == 1) |
|
115 | - return; |
|
116 | - if($this->page == 2) |
|
117 | - return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/")->activate(); |
|
118 | - return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/" . ($this->page - 1) . '/')->activate(); |
|
119 | - } |
|
120 | - |
|
121 | - protected function get_list_prev_link() |
|
122 | - { |
|
123 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
124 | - return; |
|
125 | - return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/" . ($this->page + 1) . '/')->activate(); |
|
126 | - } |
|
127 | - |
|
128 | - private $total_post_count; |
|
129 | - protected function get_total_post_count() |
|
130 | - { |
|
131 | - if(!isset($this->total_post_count)) { |
|
109 | + return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count(), $this->tag['tag']); |
|
110 | + } |
|
111 | + |
|
112 | + protected function get_list_next_link() |
|
113 | + { |
|
114 | + if($this->page == 1) |
|
115 | + return; |
|
116 | + if($this->page == 2) |
|
117 | + return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/")->activate(); |
|
118 | + return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/" . ($this->page - 1) . '/')->activate(); |
|
119 | + } |
|
120 | + |
|
121 | + protected function get_list_prev_link() |
|
122 | + { |
|
123 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
124 | + return; |
|
125 | + return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/" . ($this->page + 1) . '/')->activate(); |
|
126 | + } |
|
127 | + |
|
128 | + private $total_post_count; |
|
129 | + protected function get_total_post_count() |
|
130 | + { |
|
131 | + if(!isset($this->total_post_count)) { |
|
132 | 132 | global $container; |
133 | 133 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
134 | 134 | $this->total_post_count = $repository->getActivePostsCountByTag($this->tag['id']); |
135 | 135 | } |
136 | 136 | |
137 | - return $this->total_post_count; |
|
138 | - } |
|
137 | + return $this->total_post_count; |
|
138 | + } |
|
139 | 139 | |
140 | 140 | } |
@@ -6,191 +6,191 @@ 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 | - } |
|
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 | 66 | |
67 | - protected function get_introduction() {} |
|
67 | + protected function get_introduction() {} |
|
68 | 68 | |
69 | - protected function set_body_data() |
|
70 | - { |
|
71 | - parent::set_body_data(); |
|
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("{$this->post['category']}/{$this->post['path']}"), |
|
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("{$this->post['category']}/{$this->post['path']}"), |
|
82 | 82 | )); |
83 | - } |
|
83 | + } |
|
84 | 84 | |
85 | - protected function get_post_description() |
|
86 | - { |
|
87 | - $description = $this->post['body']; |
|
88 | - $description = strip_tags($description); |
|
89 | - $description = Content::instance('SmartTrim', $description)->activate(self::$PAGE_DESCRIPTION_LIMIT); |
|
85 | + protected function get_post_description() |
|
86 | + { |
|
87 | + $description = $this->post['body']; |
|
88 | + $description = strip_tags($description); |
|
89 | + $description = Content::instance('SmartTrim', $description)->activate(self::$PAGE_DESCRIPTION_LIMIT); |
|
90 | 90 | |
91 | - return $description; |
|
92 | - } |
|
91 | + return $description; |
|
92 | + } |
|
93 | 93 | |
94 | - protected function get_post_keywords() |
|
95 | - { |
|
96 | - $keyword_array = array(); |
|
97 | - $keywords = $this->tags; |
|
94 | + protected function get_post_keywords() |
|
95 | + { |
|
96 | + $keyword_array = array(); |
|
97 | + $keywords = $this->tags; |
|
98 | 98 | |
99 | - foreach($keywords as $keyword) |
|
100 | - { |
|
101 | - $keyword_array[] = $keyword['tag']; |
|
102 | - } |
|
99 | + foreach($keywords as $keyword) |
|
100 | + { |
|
101 | + $keyword_array[] = $keyword['tag']; |
|
102 | + } |
|
103 | 103 | |
104 | - $keyword_array[] = 'blog'; |
|
105 | - $keyword_array[] = 'Jacob Emerick'; |
|
104 | + $keyword_array[] = 'blog'; |
|
105 | + $keyword_array[] = 'Jacob Emerick'; |
|
106 | 106 | |
107 | - return $keyword_array; |
|
108 | - } |
|
107 | + return $keyword_array; |
|
108 | + } |
|
109 | 109 | |
110 | - private function get_series_posts() |
|
111 | - { |
|
112 | - $series_posts = $this->fetch_series_posts(); |
|
113 | - if(count($series_posts) < 1) |
|
114 | - return array(); |
|
110 | + private function get_series_posts() |
|
111 | + { |
|
112 | + $series_posts = $this->fetch_series_posts(); |
|
113 | + if(count($series_posts) < 1) |
|
114 | + return array(); |
|
115 | 115 | |
116 | - $previous_post = new stdclass(); |
|
117 | - $next_post = new stdclass(); |
|
116 | + $previous_post = new stdclass(); |
|
117 | + $next_post = new stdclass(); |
|
118 | 118 | |
119 | - $found_current_post = false; |
|
120 | - foreach($series_posts as $post_row) |
|
121 | - { |
|
122 | - if($post_row['post'] == $this->post['id']) |
|
123 | - { |
|
124 | - $found_current_post = true; |
|
125 | - continue; |
|
126 | - } |
|
119 | + $found_current_post = false; |
|
120 | + foreach($series_posts as $post_row) |
|
121 | + { |
|
122 | + if($post_row['post'] == $this->post['id']) |
|
123 | + { |
|
124 | + $found_current_post = true; |
|
125 | + continue; |
|
126 | + } |
|
127 | 127 | |
128 | - $post = new stdclass(); |
|
128 | + $post = new stdclass(); |
|
129 | 129 | |
130 | - if ( |
|
130 | + if ( |
|
131 | 131 | strpos($post_row['title'], 'Rainy Supe Loop') === 0 || |
132 | 132 | strpos($post_row['title'], 'Malapais Loop') === 0 || |
133 | 133 | strpos($post_row['title'], 'Mazatzal Peak Loop') === 0 || |
134 | 134 | strpos($post_row['title'], 'Dripping Springs Loop') === 0 |
135 | - ) { |
|
135 | + ) { |
|
136 | 136 | $title = $post_row['title']; |
137 | 137 | $title = explode(':', $title); |
138 | 138 | $title = array_pop($title); |
139 | 139 | $title = trim($title); |
140 | 140 | $post->title = $title; |
141 | - } else if (strpos($post_row['title'], 'Isle Royale') === 0) { |
|
142 | - $title = $post_row['title']; |
|
143 | - $title = explode(',', $title); |
|
144 | - $title = array_pop($title); |
|
145 | - $title = trim($title); |
|
146 | - $post->title = $title; |
|
147 | - } else { |
|
148 | - $post->title = $post_row['title']; |
|
149 | - } |
|
141 | + } else if (strpos($post_row['title'], 'Isle Royale') === 0) { |
|
142 | + $title = $post_row['title']; |
|
143 | + $title = explode(',', $title); |
|
144 | + $title = array_pop($title); |
|
145 | + $title = trim($title); |
|
146 | + $post->title = $title; |
|
147 | + } else { |
|
148 | + $post->title = $post_row['title']; |
|
149 | + } |
|
150 | 150 | |
151 | - $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
|
151 | + $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
|
152 | 152 | |
153 | - if(!$found_current_post) |
|
154 | - $previous_post = $post; |
|
155 | - else |
|
156 | - { |
|
157 | - $next_post = $post; |
|
158 | - break; |
|
159 | - } |
|
160 | - } |
|
153 | + if(!$found_current_post) |
|
154 | + $previous_post = $post; |
|
155 | + else |
|
156 | + { |
|
157 | + $next_post = $post; |
|
158 | + break; |
|
159 | + } |
|
160 | + } |
|
161 | 161 | |
162 | - return array( |
|
163 | - 'title' => $post_row['series_title'], |
|
164 | - 'description' => Content::instance('FixInternalLink', $post_row['series_description'])->activate(), |
|
165 | - 'previous' => $previous_post, |
|
166 | - 'next' => $next_post); |
|
167 | - } |
|
162 | + return array( |
|
163 | + 'title' => $post_row['series_title'], |
|
164 | + 'description' => Content::instance('FixInternalLink', $post_row['series_description'])->activate(), |
|
165 | + 'previous' => $previous_post, |
|
166 | + 'next' => $next_post); |
|
167 | + } |
|
168 | 168 | |
169 | - private $series_posts; |
|
170 | - private function fetch_series_posts() |
|
171 | - { |
|
172 | - if(!isset($this->series_posts)) { |
|
173 | - global $container; |
|
174 | - $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']); |
|
175 | - $this->series_posts = $repository->getSeriesForPost($this->post['id']); |
|
176 | - } |
|
177 | - return $this->series_posts; |
|
178 | - } |
|
169 | + private $series_posts; |
|
170 | + private function fetch_series_posts() |
|
171 | + { |
|
172 | + if(!isset($this->series_posts)) { |
|
173 | + global $container; |
|
174 | + $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']); |
|
175 | + $this->series_posts = $repository->getSeriesForPost($this->post['id']); |
|
176 | + } |
|
177 | + return $this->series_posts; |
|
178 | + } |
|
179 | 179 | |
180 | - private function get_related_posts() |
|
181 | - { |
|
182 | - $tag_array = array(); |
|
183 | - foreach($this->tags as $tag) |
|
184 | - { |
|
185 | - $tag_array[] = $tag['id']; |
|
186 | - } |
|
180 | + private function get_related_posts() |
|
181 | + { |
|
182 | + $tag_array = array(); |
|
183 | + foreach($this->tags as $tag) |
|
184 | + { |
|
185 | + $tag_array[] = $tag['id']; |
|
186 | + } |
|
187 | 187 | |
188 | - $series_posts = $this->fetch_series_posts(); |
|
189 | - $exclude_post_array = array(); |
|
190 | - foreach($series_posts as $series_post) |
|
191 | - { |
|
192 | - $exclude_post_array[] = $series_post['post']; |
|
193 | - } |
|
188 | + $series_posts = $this->fetch_series_posts(); |
|
189 | + $exclude_post_array = array(); |
|
190 | + foreach($series_posts as $series_post) |
|
191 | + { |
|
192 | + $exclude_post_array[] = $series_post['post']; |
|
193 | + } |
|
194 | 194 | |
195 | 195 | global $container; |
196 | 196 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
@@ -198,20 +198,20 @@ discard block |
||
198 | 198 | |
199 | 199 | $post_array = array(); |
200 | 200 | |
201 | - foreach($post_result as $post_row) |
|
202 | - { |
|
203 | - $post = new stdclass(); |
|
204 | - $post->title = $post_row['title']; |
|
205 | - $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
|
206 | - $post->category = ucwords(str_replace('-', ' ', $post_row['category'])); |
|
207 | - $post->thumb = Content::instance('FetchFirstPhoto', $post_row['body'])->activate(); |
|
208 | - $post->body = Content::instance('SmartTrim', $post_row['body'])->activate(($post->thumb !== '') ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG); |
|
201 | + foreach($post_result as $post_row) |
|
202 | + { |
|
203 | + $post = new stdclass(); |
|
204 | + $post->title = $post_row['title']; |
|
205 | + $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
|
206 | + $post->category = ucwords(str_replace('-', ' ', $post_row['category'])); |
|
207 | + $post->thumb = Content::instance('FetchFirstPhoto', $post_row['body'])->activate(); |
|
208 | + $post->body = Content::instance('SmartTrim', $post_row['body'])->activate(($post->thumb !== '') ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG); |
|
209 | 209 | |
210 | - $post_array[] = $post; |
|
211 | - } |
|
210 | + $post_array[] = $post; |
|
211 | + } |
|
212 | 212 | |
213 | - return $post_array; |
|
214 | - } |
|
213 | + return $post_array; |
|
214 | + } |
|
215 | 215 | |
216 | 216 | protected function get_comment_array($path) |
217 | 217 | { |
@@ -5,64 +5,64 @@ |
||
5 | 5 | abstract class DefaultListController extends DefaultPageController |
6 | 6 | { |
7 | 7 | |
8 | - protected static $POSTS_PER_PAGE = 10; |
|
8 | + protected static $POSTS_PER_PAGE = 10; |
|
9 | 9 | |
10 | - protected $page; |
|
11 | - protected $offset; |
|
10 | + protected $page; |
|
11 | + protected $offset; |
|
12 | 12 | |
13 | - public function __construct() |
|
14 | - { |
|
15 | - parent::__construct(); |
|
13 | + public function __construct() |
|
14 | + { |
|
15 | + parent::__construct(); |
|
16 | 16 | |
17 | - $this->page = $this->get_page_number(); |
|
18 | - $this->total_pages = ceil($this->get_total_post_count() / self::$POSTS_PER_PAGE); |
|
19 | - $this->offset = ($this->page - 1) * self::$POSTS_PER_PAGE; |
|
20 | - } |
|
17 | + $this->page = $this->get_page_number(); |
|
18 | + $this->total_pages = ceil($this->get_total_post_count() / self::$POSTS_PER_PAGE); |
|
19 | + $this->offset = ($this->page - 1) * self::$POSTS_PER_PAGE; |
|
20 | + } |
|
21 | 21 | |
22 | - abstract protected function get_page_number(); |
|
23 | - abstract protected function get_list_results(); |
|
24 | - abstract protected function get_list_description(); |
|
25 | - abstract protected function get_list_next_link(); |
|
26 | - abstract protected function get_list_prev_link(); |
|
27 | - abstract protected function get_total_post_count(); |
|
22 | + abstract protected function get_page_number(); |
|
23 | + abstract protected function get_list_results(); |
|
24 | + abstract protected function get_list_description(); |
|
25 | + abstract protected function get_list_next_link(); |
|
26 | + abstract protected function get_list_prev_link(); |
|
27 | + abstract protected function get_total_post_count(); |
|
28 | 28 | |
29 | - protected function set_head_data() |
|
30 | - { |
|
31 | - parent::set_head_data(); |
|
29 | + protected function set_head_data() |
|
30 | + { |
|
31 | + parent::set_head_data(); |
|
32 | 32 | |
33 | - $this->set_head('next_link', $this->get_list_next_link()); |
|
34 | - $this->set_head('previous_link', $this->get_list_prev_link()); |
|
35 | - } |
|
33 | + $this->set_head('next_link', $this->get_list_next_link()); |
|
34 | + $this->set_head('previous_link', $this->get_list_prev_link()); |
|
35 | + } |
|
36 | 36 | |
37 | - protected function set_body_data() |
|
38 | - { |
|
39 | - parent::set_body_data(); |
|
37 | + protected function set_body_data() |
|
38 | + { |
|
39 | + parent::set_body_data(); |
|
40 | 40 | |
41 | - $this->set_body('view', 'Listing'); |
|
42 | - $this->set_body('data', $this->get_list_body_data()); |
|
43 | - } |
|
41 | + $this->set_body('view', 'Listing'); |
|
42 | + $this->set_body('data', $this->get_list_body_data()); |
|
43 | + } |
|
44 | 44 | |
45 | - final private function get_list_body_data() |
|
46 | - { |
|
47 | - return array( |
|
48 | - 'posts' => $this->get_list_posts(), |
|
49 | - 'show_top_navigation' => ($this->page !== 1), |
|
50 | - 'navigation' => array( |
|
51 | - 'description' => $this->get_list_description(), |
|
52 | - 'next' => $this->get_list_next_link(), |
|
53 | - 'prev' => $this->get_list_prev_link())); |
|
54 | - } |
|
45 | + final private function get_list_body_data() |
|
46 | + { |
|
47 | + return array( |
|
48 | + 'posts' => $this->get_list_posts(), |
|
49 | + 'show_top_navigation' => ($this->page !== 1), |
|
50 | + 'navigation' => array( |
|
51 | + 'description' => $this->get_list_description(), |
|
52 | + 'next' => $this->get_list_next_link(), |
|
53 | + 'prev' => $this->get_list_prev_link())); |
|
54 | + } |
|
55 | 55 | |
56 | - final private function get_list_posts() |
|
57 | - { |
|
58 | - $post_array = array(); |
|
59 | - foreach($this->get_list_results() as $post) |
|
60 | - { |
|
61 | - $post_array[] = $this->format_post($post, true); |
|
62 | - } |
|
63 | - if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
64 | - $this->eject(); |
|
65 | - return $post_array; |
|
66 | - } |
|
56 | + final private function get_list_posts() |
|
57 | + { |
|
58 | + $post_array = array(); |
|
59 | + foreach($this->get_list_results() as $post) |
|
60 | + { |
|
61 | + $post_array[] = $this->format_post($post, true); |
|
62 | + } |
|
63 | + if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
64 | + $this->eject(); |
|
65 | + return $post_array; |
|
66 | + } |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | \ No newline at end of file |
@@ -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 | } |
@@ -5,47 +5,47 @@ |
||
5 | 5 | final class AboutController extends DefaultPageController |
6 | 6 | { |
7 | 7 | |
8 | - private static $TITLE = 'About the Blog | Jacob Emerick'; |
|
9 | - private static $DESCRIPTION = "A little bit about the awesomeness on Jacob Emerick's Blog, diving into the topics covered, technology used, and methodology of writing new posts."; |
|
10 | - |
|
11 | - private static $KEYWORD_ARRAY = array( |
|
12 | - 'about', |
|
13 | - 'technologies', |
|
14 | - 'background', |
|
15 | - 'blog', |
|
16 | - 'Jacob Emerick'); |
|
17 | - |
|
18 | - protected function set_head_data() |
|
19 | - { |
|
20 | - $this->set_title(self::$TITLE); |
|
21 | - $this->set_description(self::$DESCRIPTION); |
|
22 | - $this->set_keywords(self::$KEYWORD_ARRAY); |
|
8 | + private static $TITLE = 'About the Blog | Jacob Emerick'; |
|
9 | + private static $DESCRIPTION = "A little bit about the awesomeness on Jacob Emerick's Blog, diving into the topics covered, technology used, and methodology of writing new posts."; |
|
10 | + |
|
11 | + private static $KEYWORD_ARRAY = array( |
|
12 | + 'about', |
|
13 | + 'technologies', |
|
14 | + 'background', |
|
15 | + 'blog', |
|
16 | + 'Jacob Emerick'); |
|
17 | + |
|
18 | + protected function set_head_data() |
|
19 | + { |
|
20 | + $this->set_title(self::$TITLE); |
|
21 | + $this->set_description(self::$DESCRIPTION); |
|
22 | + $this->set_keywords(self::$KEYWORD_ARRAY); |
|
23 | 23 | |
24 | - parent::set_head_data(); |
|
25 | - } |
|
24 | + parent::set_head_data(); |
|
25 | + } |
|
26 | 26 | |
27 | - protected function set_body_data() |
|
28 | - { |
|
29 | - $this->set_body('view', 'About'); |
|
27 | + protected function set_body_data() |
|
28 | + { |
|
29 | + $this->set_body('view', 'About'); |
|
30 | 30 | |
31 | - parent::set_body_data(); |
|
32 | - } |
|
31 | + parent::set_body_data(); |
|
32 | + } |
|
33 | 33 | |
34 | - protected function get_introduction() |
|
35 | - { |
|
34 | + protected function get_introduction() |
|
35 | + { |
|
36 | 36 | global $container; |
37 | 37 | $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
38 | 38 | $introduction_result = $repository->findByType('about'); |
39 | 39 | |
40 | - if($introduction_result !== null) |
|
41 | - { |
|
42 | - $introduction = array(); |
|
43 | - $introduction['title'] = $introduction_result['title']; |
|
44 | - $introduction['content'] = $introduction_result['content']; |
|
45 | - $introduction['image'] = $this->get_introduction_image($introduction_result['image']); |
|
40 | + if($introduction_result !== null) |
|
41 | + { |
|
42 | + $introduction = array(); |
|
43 | + $introduction['title'] = $introduction_result['title']; |
|
44 | + $introduction['content'] = $introduction_result['content']; |
|
45 | + $introduction['image'] = $this->get_introduction_image($introduction_result['image']); |
|
46 | 46 | |
47 | - return $introduction; |
|
48 | - } |
|
49 | - } |
|
47 | + return $introduction; |
|
48 | + } |
|
49 | + } |
|
50 | 50 | |
51 | 51 | } |
@@ -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 | } |
@@ -5,180 +5,180 @@ |
||
5 | 5 | final class CategoryController extends DefaultListController |
6 | 6 | { |
7 | 7 | |
8 | - private static $TITLE_MAIN_HIKING = "Hiking | Posts on Upper Peninsula Exploring on Jacob Emerick's Blog"; |
|
9 | - private static $DESCRIPTION_MAIN_HIKING = "Posts on Jacob Emerick's Blog about hiking the Upper Peninsula, exploring the Huron Mountains, and hunting waterfalls in the Keweenaw."; |
|
10 | - |
|
11 | - private static $TITLE_MAIN_PERSONAL = "Personal | Posts about life changes on Jacob Emerick's Blog"; |
|
12 | - private static $DESCRIPTION_MAIN_PERSONAL = "Stories about life changes for Jacob and Katie. New jobs, getting married, and general thoughts on things."; |
|
13 | - |
|
14 | - private static $TITLE_MAIN_WEBDEVELOPMENT = "Web Development | Tutorials and Best Practices on Jacob Emerick's Blog"; |
|
15 | - private static $DESCRIPTION_MAIN_WEBDEVELOPMENT = "Variety of tutorials and advice on best practices on Jacob Emerick's Blog, with a focus on object-orientated PHP development and project management."; |
|
16 | - |
|
17 | - private static $TITLE_PAGINATED_HIKING = "Hiking - Page %d of %d | Jacob Emerick's Blog"; |
|
18 | - private static $DESCRIPTION_PAGINATED_HIKING = "Page %d of %d about hiking on Jacob Emerick's Blog. Posts about hiking the Upper Peninsula, exploring the Huron Mountains, and hunting waterfalls of the Keweenaw."; |
|
19 | - |
|
20 | - private static $TITLE_PAGINATED_PERSONAL = "Personal - Page %d of %d | Jacob Emerick's Blog"; |
|
21 | - private static $DESCRIPTION_PAGINATED_PERSONAL = "Page %d of %d of personal posts on Jacob Emerick's Blog about life changes and general musings."; |
|
22 | - |
|
23 | - private static $TITLE_PAGINATED_WEBDEVELOPMENT = "Web Development - Page %d of %d | Jacob Emerick's Blog"; |
|
24 | - private static $DESCRIPTION_PAGINATED_WEBDEVELOPMENT = "Page %d of %d of posts on web development, ranging from general tutorials to advanced best practices, on Jacob Emerick's Blog."; |
|
25 | - |
|
26 | - private static $KEYWORD_ARRAY_HIKING = array( |
|
27 | - 'hiking', |
|
28 | - 'upper peninsula', |
|
29 | - 'huron mountains', |
|
30 | - 'keweenaw', |
|
31 | - 'michigan', |
|
32 | - 'backpacking', |
|
33 | - 'Jacob Emerick'); |
|
34 | - |
|
35 | - private static $KEYWORD_ARRAY_PERSONAL = array( |
|
36 | - 'dealerfire', |
|
37 | - 'sparknet', |
|
38 | - 'katie', |
|
39 | - 'logan', |
|
40 | - 'marriage', |
|
41 | - 'Jacob Emerick'); |
|
42 | - |
|
43 | - private static $KEYWORD_ARRAY_WEBDEVELOPMENT = array( |
|
44 | - 'best practices', |
|
45 | - 'object orientated php', |
|
46 | - 'data abstraction', |
|
47 | - 'semantic web', |
|
48 | - 'responsive design', |
|
49 | - 'responsible development', |
|
50 | - 'Jacob Emerick'); |
|
51 | - |
|
52 | - private $category; |
|
53 | - |
|
54 | - private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d posts in the %s category.'; |
|
55 | - |
|
56 | - public function __construct() |
|
57 | - { |
|
58 | - $url = URLDecode::getPiece(1); |
|
59 | - $this->category = (object) array( |
|
60 | - 'display' => ucwords(str_replace('-', ' ', $url)), |
|
61 | - 'link' => $url); |
|
8 | + private static $TITLE_MAIN_HIKING = "Hiking | Posts on Upper Peninsula Exploring on Jacob Emerick's Blog"; |
|
9 | + private static $DESCRIPTION_MAIN_HIKING = "Posts on Jacob Emerick's Blog about hiking the Upper Peninsula, exploring the Huron Mountains, and hunting waterfalls in the Keweenaw."; |
|
10 | + |
|
11 | + private static $TITLE_MAIN_PERSONAL = "Personal | Posts about life changes on Jacob Emerick's Blog"; |
|
12 | + private static $DESCRIPTION_MAIN_PERSONAL = "Stories about life changes for Jacob and Katie. New jobs, getting married, and general thoughts on things."; |
|
13 | + |
|
14 | + private static $TITLE_MAIN_WEBDEVELOPMENT = "Web Development | Tutorials and Best Practices on Jacob Emerick's Blog"; |
|
15 | + private static $DESCRIPTION_MAIN_WEBDEVELOPMENT = "Variety of tutorials and advice on best practices on Jacob Emerick's Blog, with a focus on object-orientated PHP development and project management."; |
|
16 | + |
|
17 | + private static $TITLE_PAGINATED_HIKING = "Hiking - Page %d of %d | Jacob Emerick's Blog"; |
|
18 | + private static $DESCRIPTION_PAGINATED_HIKING = "Page %d of %d about hiking on Jacob Emerick's Blog. Posts about hiking the Upper Peninsula, exploring the Huron Mountains, and hunting waterfalls of the Keweenaw."; |
|
19 | + |
|
20 | + private static $TITLE_PAGINATED_PERSONAL = "Personal - Page %d of %d | Jacob Emerick's Blog"; |
|
21 | + private static $DESCRIPTION_PAGINATED_PERSONAL = "Page %d of %d of personal posts on Jacob Emerick's Blog about life changes and general musings."; |
|
22 | + |
|
23 | + private static $TITLE_PAGINATED_WEBDEVELOPMENT = "Web Development - Page %d of %d | Jacob Emerick's Blog"; |
|
24 | + private static $DESCRIPTION_PAGINATED_WEBDEVELOPMENT = "Page %d of %d of posts on web development, ranging from general tutorials to advanced best practices, on Jacob Emerick's Blog."; |
|
25 | + |
|
26 | + private static $KEYWORD_ARRAY_HIKING = array( |
|
27 | + 'hiking', |
|
28 | + 'upper peninsula', |
|
29 | + 'huron mountains', |
|
30 | + 'keweenaw', |
|
31 | + 'michigan', |
|
32 | + 'backpacking', |
|
33 | + 'Jacob Emerick'); |
|
34 | + |
|
35 | + private static $KEYWORD_ARRAY_PERSONAL = array( |
|
36 | + 'dealerfire', |
|
37 | + 'sparknet', |
|
38 | + 'katie', |
|
39 | + 'logan', |
|
40 | + 'marriage', |
|
41 | + 'Jacob Emerick'); |
|
42 | + |
|
43 | + private static $KEYWORD_ARRAY_WEBDEVELOPMENT = array( |
|
44 | + 'best practices', |
|
45 | + 'object orientated php', |
|
46 | + 'data abstraction', |
|
47 | + 'semantic web', |
|
48 | + 'responsive design', |
|
49 | + 'responsible development', |
|
50 | + 'Jacob Emerick'); |
|
51 | + |
|
52 | + private $category; |
|
53 | + |
|
54 | + private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d posts in the %s category.'; |
|
55 | + |
|
56 | + public function __construct() |
|
57 | + { |
|
58 | + $url = URLDecode::getPiece(1); |
|
59 | + $this->category = (object) array( |
|
60 | + 'display' => ucwords(str_replace('-', ' ', $url)), |
|
61 | + 'link' => $url); |
|
62 | 62 | |
63 | - parent::__construct(); |
|
64 | - } |
|
63 | + parent::__construct(); |
|
64 | + } |
|
65 | 65 | |
66 | - protected function set_head_data() |
|
67 | - { |
|
68 | - parent::set_head_data(); |
|
66 | + protected function set_head_data() |
|
67 | + { |
|
68 | + parent::set_head_data(); |
|
69 | 69 | |
70 | - switch($this->category->display) |
|
71 | - { |
|
72 | - case 'Hiking' : |
|
73 | - if($this->page == 1) |
|
74 | - { |
|
75 | - $this->set_title(self::$TITLE_MAIN_HIKING); |
|
76 | - $this->set_description(self::$DESCRIPTION_MAIN_HIKING); |
|
77 | - } |
|
78 | - else |
|
79 | - { |
|
80 | - $this->set_title(sprintf(self::$TITLE_PAGINATED_HIKING, $this->page, $this->total_pages)); |
|
81 | - $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED_HIKING, $this->page, $this->total_pages)); |
|
82 | - } |
|
83 | - $this->set_keywords(self::$KEYWORD_ARRAY_HIKING); |
|
84 | - break; |
|
85 | - case 'Personal' : |
|
86 | - if($this->page == 1) |
|
87 | - { |
|
88 | - $this->set_title(self::$TITLE_MAIN_PERSONAL); |
|
89 | - $this->set_description(self::$DESCRIPTION_MAIN_PERSONAL); |
|
90 | - } |
|
91 | - else |
|
92 | - { |
|
93 | - $this->set_title(sprintf(self::$TITLE_PAGINATED_PERSONAL, $this->page, $this->total_pages)); |
|
94 | - $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED_PERSONAL, $this->page, $this->total_pages)); |
|
95 | - } |
|
96 | - $this->set_keywords(self::$KEYWORD_ARRAY_PERSONAL); |
|
97 | - break; |
|
98 | - case 'Web Development' : |
|
99 | - if($this->page == 1) |
|
100 | - { |
|
101 | - $this->set_title(self::$TITLE_MAIN_WEBDEVELOPMENT); |
|
102 | - $this->set_description(self::$DESCRIPTION_MAIN_WEBDEVELOPMENT); |
|
103 | - } |
|
104 | - else |
|
105 | - { |
|
106 | - $this->set_title(sprintf(self::$TITLE_PAGINATED_WEBDEVELOPMENT, $this->page, $this->total_pages)); |
|
107 | - $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED_WEBDEVELOPMENT, $this->page, $this->total_pages)); |
|
108 | - } |
|
109 | - $this->set_keywords(self::$KEYWORD_ARRAY_WEBDEVELOPMENT); |
|
110 | - break; |
|
111 | - } |
|
112 | - } |
|
113 | - |
|
114 | - protected function get_introduction() |
|
115 | - { |
|
116 | - if($this->page == 1) |
|
117 | - { |
|
70 | + switch($this->category->display) |
|
71 | + { |
|
72 | + case 'Hiking' : |
|
73 | + if($this->page == 1) |
|
74 | + { |
|
75 | + $this->set_title(self::$TITLE_MAIN_HIKING); |
|
76 | + $this->set_description(self::$DESCRIPTION_MAIN_HIKING); |
|
77 | + } |
|
78 | + else |
|
79 | + { |
|
80 | + $this->set_title(sprintf(self::$TITLE_PAGINATED_HIKING, $this->page, $this->total_pages)); |
|
81 | + $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED_HIKING, $this->page, $this->total_pages)); |
|
82 | + } |
|
83 | + $this->set_keywords(self::$KEYWORD_ARRAY_HIKING); |
|
84 | + break; |
|
85 | + case 'Personal' : |
|
86 | + if($this->page == 1) |
|
87 | + { |
|
88 | + $this->set_title(self::$TITLE_MAIN_PERSONAL); |
|
89 | + $this->set_description(self::$DESCRIPTION_MAIN_PERSONAL); |
|
90 | + } |
|
91 | + else |
|
92 | + { |
|
93 | + $this->set_title(sprintf(self::$TITLE_PAGINATED_PERSONAL, $this->page, $this->total_pages)); |
|
94 | + $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED_PERSONAL, $this->page, $this->total_pages)); |
|
95 | + } |
|
96 | + $this->set_keywords(self::$KEYWORD_ARRAY_PERSONAL); |
|
97 | + break; |
|
98 | + case 'Web Development' : |
|
99 | + if($this->page == 1) |
|
100 | + { |
|
101 | + $this->set_title(self::$TITLE_MAIN_WEBDEVELOPMENT); |
|
102 | + $this->set_description(self::$DESCRIPTION_MAIN_WEBDEVELOPMENT); |
|
103 | + } |
|
104 | + else |
|
105 | + { |
|
106 | + $this->set_title(sprintf(self::$TITLE_PAGINATED_WEBDEVELOPMENT, $this->page, $this->total_pages)); |
|
107 | + $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED_WEBDEVELOPMENT, $this->page, $this->total_pages)); |
|
108 | + } |
|
109 | + $this->set_keywords(self::$KEYWORD_ARRAY_WEBDEVELOPMENT); |
|
110 | + break; |
|
111 | + } |
|
112 | + } |
|
113 | + |
|
114 | + protected function get_introduction() |
|
115 | + { |
|
116 | + if($this->page == 1) |
|
117 | + { |
|
118 | 118 | global $container; |
119 | 119 | $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
120 | 120 | $introduction_result = $repository->findByType('category', $this->category->link); |
121 | 121 | |
122 | - $introduction = array(); |
|
123 | - $introduction['title'] = $introduction_result['title']; |
|
124 | - $introduction['content'] = $introduction_result['content']; |
|
125 | - $introduction['image'] = $this->get_introduction_image($introduction_result['image']); |
|
122 | + $introduction = array(); |
|
123 | + $introduction['title'] = $introduction_result['title']; |
|
124 | + $introduction['content'] = $introduction_result['content']; |
|
125 | + $introduction['image'] = $this->get_introduction_image($introduction_result['image']); |
|
126 | 126 | |
127 | - return $introduction; |
|
128 | - } |
|
127 | + return $introduction; |
|
128 | + } |
|
129 | 129 | |
130 | - return array( |
|
131 | - 'title' => "Posts about {$this->category->display}, page {$this->page} of {$this->total_pages}."); |
|
132 | - } |
|
133 | - |
|
134 | - protected function get_page_number() |
|
135 | - { |
|
136 | - $page = URLDecode::getPiece(2); |
|
137 | - if(isset($page) && is_numeric($page)) |
|
138 | - return $page; |
|
139 | - return 1; |
|
140 | - } |
|
141 | - |
|
142 | - protected function get_list_results() |
|
143 | - { |
|
130 | + return array( |
|
131 | + 'title' => "Posts about {$this->category->display}, page {$this->page} of {$this->total_pages}."); |
|
132 | + } |
|
133 | + |
|
134 | + protected function get_page_number() |
|
135 | + { |
|
136 | + $page = URLDecode::getPiece(2); |
|
137 | + if(isset($page) && is_numeric($page)) |
|
138 | + return $page; |
|
139 | + return 1; |
|
140 | + } |
|
141 | + |
|
142 | + protected function get_list_results() |
|
143 | + { |
|
144 | 144 | global $container; |
145 | 145 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
146 | 146 | return $repository->getActivePostsByCategory($this->category->link, self::$POSTS_PER_PAGE, $this->offset); |
147 | - } |
|
147 | + } |
|
148 | 148 | |
149 | - protected function get_list_description() |
|
150 | - { |
|
151 | - $start = $this->offset + 1; |
|
152 | - $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
149 | + protected function get_list_description() |
|
150 | + { |
|
151 | + $start = $this->offset + 1; |
|
152 | + $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
153 | 153 | |
154 | - return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count(), $this->category->display); |
|
155 | - } |
|
156 | - |
|
157 | - protected function get_list_next_link() |
|
158 | - { |
|
159 | - if($this->page == 1) |
|
160 | - return; |
|
161 | - if($this->page == 2) |
|
162 | - return Content::instance('URLSafe', "/{$this->category->link}/")->activate(); |
|
163 | - return Content::instance('URLSafe', "/{$this->category->link}/" . ($this->page - 1) . '/')->activate(); |
|
164 | - } |
|
165 | - |
|
166 | - protected function get_list_prev_link() |
|
167 | - { |
|
168 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
169 | - return; |
|
170 | - return Content::instance('URLSafe', "/{$this->category->link}/" . ($this->page + 1) . '/')->activate(); |
|
171 | - } |
|
172 | - |
|
173 | - private $total_post_count; |
|
174 | - protected function get_total_post_count() |
|
175 | - { |
|
176 | - if(!isset($this->total_post_count)) { |
|
154 | + return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count(), $this->category->display); |
|
155 | + } |
|
156 | + |
|
157 | + protected function get_list_next_link() |
|
158 | + { |
|
159 | + if($this->page == 1) |
|
160 | + return; |
|
161 | + if($this->page == 2) |
|
162 | + return Content::instance('URLSafe', "/{$this->category->link}/")->activate(); |
|
163 | + return Content::instance('URLSafe', "/{$this->category->link}/" . ($this->page - 1) . '/')->activate(); |
|
164 | + } |
|
165 | + |
|
166 | + protected function get_list_prev_link() |
|
167 | + { |
|
168 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
169 | + return; |
|
170 | + return Content::instance('URLSafe', "/{$this->category->link}/" . ($this->page + 1) . '/')->activate(); |
|
171 | + } |
|
172 | + |
|
173 | + private $total_post_count; |
|
174 | + protected function get_total_post_count() |
|
175 | + { |
|
176 | + if(!isset($this->total_post_count)) { |
|
177 | 177 | global $container; |
178 | 178 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
179 | 179 | $this->total_post_count = $repository->getActivePostsCountByCategory($this->category->link); |
180 | 180 | } |
181 | - return $this->total_post_count; |
|
182 | - } |
|
181 | + return $this->total_post_count; |
|
182 | + } |
|
183 | 183 | |
184 | 184 | } |