@@ -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,73 +5,73 @@ |
||
5 | 5 | final class ContactController extends DefaultPageController |
6 | 6 | { |
7 | 7 | |
8 | - private static $TITLE = 'Contact | Jacob Emerick'; |
|
9 | - private static $DESCRIPTION = 'Contact page to reach Jacob Emerick by email or social networks'; |
|
8 | + private static $TITLE = 'Contact | Jacob Emerick'; |
|
9 | + private static $DESCRIPTION = 'Contact page to reach Jacob Emerick by email or social networks'; |
|
10 | 10 | |
11 | - private static $KEYWORD_ARRAY = array( |
|
12 | - 'Jacob Emerick', |
|
13 | - 'jacobemerick', |
|
14 | - 'jpemeric', |
|
15 | - 'contact', |
|
16 | - 'email', |
|
17 | - 'connect'); |
|
11 | + private static $KEYWORD_ARRAY = array( |
|
12 | + 'Jacob Emerick', |
|
13 | + 'jacobemerick', |
|
14 | + 'jpemeric', |
|
15 | + 'contact', |
|
16 | + 'email', |
|
17 | + 'connect'); |
|
18 | 18 | |
19 | - protected function set_head_data() |
|
20 | - { |
|
21 | - $this->set_title(self::$TITLE); |
|
22 | - $this->set_description(self::$DESCRIPTION); |
|
23 | - $this->set_keywords(self::$KEYWORD_ARRAY); |
|
19 | + protected function set_head_data() |
|
20 | + { |
|
21 | + $this->set_title(self::$TITLE); |
|
22 | + $this->set_description(self::$DESCRIPTION); |
|
23 | + $this->set_keywords(self::$KEYWORD_ARRAY); |
|
24 | 24 | |
25 | - parent::set_head_data(); |
|
26 | - } |
|
25 | + parent::set_head_data(); |
|
26 | + } |
|
27 | 27 | |
28 | - protected function set_body_data() |
|
29 | - { |
|
30 | - $this->set_body('form_container', $this->process_form()); |
|
31 | - $this->set_body_view('Contact'); |
|
28 | + protected function set_body_data() |
|
29 | + { |
|
30 | + $this->set_body('form_container', $this->process_form()); |
|
31 | + $this->set_body_view('Contact'); |
|
32 | 32 | |
33 | - parent::set_body_data(); |
|
34 | - } |
|
33 | + parent::set_body_data(); |
|
34 | + } |
|
35 | 35 | |
36 | - private function process_form() |
|
37 | - { |
|
38 | - if(!Request::hasPost() || Request::getPost('submit') != 'Send Message!') |
|
39 | - return (object) array('display' => 'normal'); |
|
36 | + private function process_form() |
|
37 | + { |
|
38 | + if(!Request::hasPost() || Request::getPost('submit') != 'Send Message!') |
|
39 | + return (object) array('display' => 'normal'); |
|
40 | 40 | |
41 | - Loader::load('utility', 'Validate'); |
|
42 | - $error_result = array(); |
|
43 | - if(!Validate::checkRequest('post', 'name', 'string')) |
|
44 | - $error_result['name'] = 'please enter your name'; |
|
45 | - if(!Validate::checkRequest('post', 'email', 'string')) |
|
46 | - $error_result['email'] = 'please enter a valid email'; |
|
47 | - if(!Validate::checkRequest('post', 'message', 'string')) |
|
48 | - $error_result['message'] = 'please write a message'; |
|
41 | + Loader::load('utility', 'Validate'); |
|
42 | + $error_result = array(); |
|
43 | + if(!Validate::checkRequest('post', 'name', 'string')) |
|
44 | + $error_result['name'] = 'please enter your name'; |
|
45 | + if(!Validate::checkRequest('post', 'email', 'string')) |
|
46 | + $error_result['email'] = 'please enter a valid email'; |
|
47 | + if(!Validate::checkRequest('post', 'message', 'string')) |
|
48 | + $error_result['message'] = 'please write a message'; |
|
49 | 49 | |
50 | - $values = (object) array( |
|
51 | - 'name' => Request::getPost('name'), |
|
52 | - 'email' => Request::getPost('email'), |
|
53 | - 'message' => Request::getPost('message')); |
|
50 | + $values = (object) array( |
|
51 | + 'name' => Request::getPost('name'), |
|
52 | + 'email' => Request::getPost('email'), |
|
53 | + 'message' => Request::getPost('message')); |
|
54 | 54 | |
55 | - if(count($error_result) > 0) |
|
56 | - { |
|
57 | - return (object) array( |
|
58 | - 'display' => 'error', |
|
59 | - 'messages' => $error_result, |
|
60 | - 'values' => $values); |
|
61 | - } |
|
55 | + if(count($error_result) > 0) |
|
56 | + { |
|
57 | + return (object) array( |
|
58 | + 'display' => 'error', |
|
59 | + 'messages' => $error_result, |
|
60 | + 'values' => $values); |
|
61 | + } |
|
62 | 62 | |
63 | 63 | global $container; |
64 | 64 | $sent = $container['mail'] |
65 | - ->addTo($container['config']->admin_email) |
|
66 | - ->setSubject('Home Page Contact') |
|
67 | - ->setPlainMessage( |
|
65 | + ->addTo($container['config']->admin_email) |
|
66 | + ->setSubject('Home Page Contact') |
|
67 | + ->setPlainMessage( |
|
68 | 68 | "Name: {$values->name}\n" . |
69 | 69 | "Email: {$values->email}\n" . |
70 | 70 | "Message: {$values->message}" |
71 | - ) |
|
72 | - ->send(); |
|
71 | + ) |
|
72 | + ->send(); |
|
73 | 73 | |
74 | - return (object) array('display' => 'success'); |
|
75 | - } |
|
74 | + return (object) array('display' => 'success'); |
|
75 | + } |
|
76 | 76 | |
77 | 77 | } |
@@ -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'), |
@@ -48,11 +48,11 @@ |
||
48 | 48 | $recentPosts = $postRepository->getActivePosts(3); |
49 | 49 | |
50 | 50 | $recent_post_array = array(); |
51 | - foreach($recentPosts as $postResult) |
|
51 | + foreach ($recentPosts as $postResult) |
|
52 | 52 | { |
53 | 53 | $post = new stdclass(); |
54 | 54 | $post->title = $postResult['title']; |
55 | - $post->url = Loader::getRootUrl('blog') . "{$postResult['category']}/{$postResult['path']}/"; |
|
55 | + $post->url = Loader::getRootUrl('blog')."{$postResult['category']}/{$postResult['path']}/"; |
|
56 | 56 | $post->category = ucwords(str_replace('-', ' ', $postResult['category'])); |
57 | 57 | $post->thumb = Content::instance('FetchFirstPhoto', $postResult['body'])->activate(); |
58 | 58 | $post->body = Content::instance('SmartTrim', $postResult['body'])->activate(($post->thumb !== '') ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG); |
@@ -8,58 +8,58 @@ |
||
8 | 8 | final class HomeController extends DefaultPageController |
9 | 9 | { |
10 | 10 | |
11 | - private static $TITLE = "Jacob Emerick's Home | Web Developer, Hiker, Innovator"; |
|
12 | - private static $DESCRIPTION = 'Home page for Jacob Emerick, with links to his blog, waterfall site, and other side projects'; |
|
11 | + private static $TITLE = "Jacob Emerick's Home | Web Developer, Hiker, Innovator"; |
|
12 | + private static $DESCRIPTION = 'Home page for Jacob Emerick, with links to his blog, waterfall site, and other side projects'; |
|
13 | 13 | |
14 | - private static $KEYWORD_ARRAY = array( |
|
15 | - 'Jacob Emerick', |
|
16 | - 'jacobemerick', |
|
17 | - 'jpemeric', |
|
18 | - 'home', |
|
19 | - 'web developer', |
|
20 | - 'hiker', |
|
21 | - 'application programmer', |
|
22 | - 'innovator'); |
|
14 | + private static $KEYWORD_ARRAY = array( |
|
15 | + 'Jacob Emerick', |
|
16 | + 'jacobemerick', |
|
17 | + 'jpemeric', |
|
18 | + 'home', |
|
19 | + 'web developer', |
|
20 | + 'hiker', |
|
21 | + 'application programmer', |
|
22 | + 'innovator'); |
|
23 | 23 | |
24 | - private static $POST_LENGTH_SHORT = 160; |
|
25 | - private static $POST_LENGTH_LONG = 240; |
|
24 | + private static $POST_LENGTH_SHORT = 160; |
|
25 | + private static $POST_LENGTH_LONG = 240; |
|
26 | 26 | |
27 | - protected function set_head_data() |
|
28 | - { |
|
29 | - $this->set_title(self::$TITLE); |
|
30 | - $this->set_description(self::$DESCRIPTION); |
|
31 | - $this->set_keywords(self::$KEYWORD_ARRAY); |
|
27 | + protected function set_head_data() |
|
28 | + { |
|
29 | + $this->set_title(self::$TITLE); |
|
30 | + $this->set_description(self::$DESCRIPTION); |
|
31 | + $this->set_keywords(self::$KEYWORD_ARRAY); |
|
32 | 32 | |
33 | - parent::set_head_data(); |
|
34 | - } |
|
33 | + parent::set_head_data(); |
|
34 | + } |
|
35 | 35 | |
36 | - protected function set_body_data() |
|
37 | - { |
|
38 | - $this->set_body('post_array', $this->get_recent_posts()); |
|
39 | - $this->set_body_view('Home'); |
|
36 | + protected function set_body_data() |
|
37 | + { |
|
38 | + $this->set_body('post_array', $this->get_recent_posts()); |
|
39 | + $this->set_body_view('Home'); |
|
40 | 40 | |
41 | - parent::set_body_data(); |
|
42 | - } |
|
41 | + parent::set_body_data(); |
|
42 | + } |
|
43 | 43 | |
44 | - private function get_recent_posts() |
|
45 | - { |
|
44 | + private function get_recent_posts() |
|
45 | + { |
|
46 | 46 | global $container; |
47 | 47 | $postRepository = new MysqlPostRepository($container['db_connection_locator']); |
48 | 48 | $recentPosts = $postRepository->getActivePosts(3); |
49 | 49 | |
50 | - $recent_post_array = array(); |
|
51 | - foreach($recentPosts as $postResult) |
|
52 | - { |
|
53 | - $post = new stdclass(); |
|
54 | - $post->title = $postResult['title']; |
|
55 | - $post->url = Loader::getRootUrl('blog') . "{$postResult['category']}/{$postResult['path']}/"; |
|
56 | - $post->category = ucwords(str_replace('-', ' ', $postResult['category'])); |
|
57 | - $post->thumb = Content::instance('FetchFirstPhoto', $postResult['body'])->activate(); |
|
58 | - $post->body = Content::instance('SmartTrim', $postResult['body'])->activate(($post->thumb !== '') ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG); |
|
50 | + $recent_post_array = array(); |
|
51 | + foreach($recentPosts as $postResult) |
|
52 | + { |
|
53 | + $post = new stdclass(); |
|
54 | + $post->title = $postResult['title']; |
|
55 | + $post->url = Loader::getRootUrl('blog') . "{$postResult['category']}/{$postResult['path']}/"; |
|
56 | + $post->category = ucwords(str_replace('-', ' ', $postResult['category'])); |
|
57 | + $post->thumb = Content::instance('FetchFirstPhoto', $postResult['body'])->activate(); |
|
58 | + $post->body = Content::instance('SmartTrim', $postResult['body'])->activate(($post->thumb !== '') ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG); |
|
59 | 59 | |
60 | - $recent_post_array[] = $post; |
|
61 | - } |
|
62 | - return $recent_post_array; |
|
63 | - } |
|
60 | + $recent_post_array[] = $post; |
|
61 | + } |
|
62 | + return $recent_post_array; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | } |
@@ -5,8 +5,8 @@ discard block |
||
5 | 5 | Loader::load('controller', 'home/DefaultPageController'); |
6 | 6 | Loader::load('utility', 'Content'); |
7 | 7 | |
8 | -final class HomeController extends DefaultPageController |
|
9 | -{ |
|
8 | +final class HomeController extends DefaultPageController |
|
9 | +{ |
|
10 | 10 | |
11 | 11 | private static $TITLE = "Jacob Emerick's Home | Web Developer, Hiker, Innovator"; |
12 | 12 | private static $DESCRIPTION = 'Home page for Jacob Emerick, with links to his blog, waterfall site, and other side projects'; |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | private static $POST_LENGTH_SHORT = 160; |
25 | 25 | private static $POST_LENGTH_LONG = 240; |
26 | 26 | |
27 | - protected function set_head_data() |
|
28 | - { |
|
27 | + protected function set_head_data() |
|
28 | + { |
|
29 | 29 | $this->set_title(self::$TITLE); |
30 | 30 | $this->set_description(self::$DESCRIPTION); |
31 | 31 | $this->set_keywords(self::$KEYWORD_ARRAY); |
@@ -33,16 +33,16 @@ discard block |
||
33 | 33 | parent::set_head_data(); |
34 | 34 | } |
35 | 35 | |
36 | - protected function set_body_data() |
|
37 | - { |
|
36 | + protected function set_body_data() |
|
37 | + { |
|
38 | 38 | $this->set_body('post_array', $this->get_recent_posts()); |
39 | 39 | $this->set_body_view('Home'); |
40 | 40 | |
41 | 41 | parent::set_body_data(); |
42 | 42 | } |
43 | 43 | |
44 | - private function get_recent_posts() |
|
45 | - { |
|
44 | + private function get_recent_posts() |
|
45 | + { |
|
46 | 46 | global $container; |
47 | 47 | $postRepository = new MysqlPostRepository($container['db_connection_locator']); |
48 | 48 | $recentPosts = $postRepository->getActivePosts(3); |
@@ -30,7 +30,7 @@ discard block |
||
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) |
|
33 | + if ($tag_result === false) |
|
34 | 34 | $this->eject(); |
35 | 35 | |
36 | 36 | $this->tag = $tag_result; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | { |
43 | 43 | parent::set_head_data(); |
44 | 44 | |
45 | - if($this->page == 1) |
|
45 | + if ($this->page == 1) |
|
46 | 46 | { |
47 | 47 | $this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->tag['tag']))); |
48 | 48 | $this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->tag['tag']))); |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | { |
63 | 63 | $tag = ucwords($this->tag['tag']); |
64 | 64 | |
65 | - if($this->page == 1) |
|
65 | + if ($this->page == 1) |
|
66 | 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) |
|
71 | + if ($introduction_result !== false) |
|
72 | 72 | { |
73 | 73 | $introduction = array(); |
74 | 74 | $introduction['title'] = $introduction_result['title']; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | protected function get_page_number() |
90 | 90 | { |
91 | 91 | $page = URLDecode::getPiece(3); |
92 | - if(isset($page) && is_numeric($page)) |
|
92 | + if (isset($page) && is_numeric($page)) |
|
93 | 93 | return $page; |
94 | 94 | return 1; |
95 | 95 | } |
@@ -111,24 +111,24 @@ discard block |
||
111 | 111 | |
112 | 112 | protected function get_list_next_link() |
113 | 113 | { |
114 | - if($this->page == 1) |
|
114 | + if ($this->page == 1) |
|
115 | 115 | return; |
116 | - if($this->page == 2) |
|
116 | + if ($this->page == 2) |
|
117 | 117 | return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/")->activate(); |
118 | - return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/" . ($this->page - 1) . '/')->activate(); |
|
118 | + return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/".($this->page - 1).'/')->activate(); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | protected function get_list_prev_link() |
122 | 122 | { |
123 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
123 | + if (($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
124 | 124 | return; |
125 | - return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/" . ($this->page + 1) . '/')->activate(); |
|
125 | + return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/".($this->page + 1).'/')->activate(); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | private $total_post_count; |
129 | 129 | protected function get_total_post_count() |
130 | 130 | { |
131 | - if(!isset($this->total_post_count)) { |
|
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']); |
@@ -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 | } |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'blog/DefaultListController'); |
4 | 4 | |
5 | -final class TagController extends DefaultListController |
|
6 | -{ |
|
5 | +final class TagController extends DefaultListController |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | private static $TITLE_MAIN = "%s Tag | Jacob Emerick's Blog"; |
9 | 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."; |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | |
22 | 22 | private $tag; |
23 | 23 | |
24 | - public function __construct() |
|
25 | - { |
|
24 | + public function __construct() |
|
25 | + { |
|
26 | 26 | $tag = URLDecode::getPiece(2); |
27 | 27 | $tag = str_replace('-', ' ', $tag); |
28 | 28 | |
@@ -30,24 +30,24 @@ discard block |
||
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 | |
36 | 37 | $this->tag = $tag_result; |
37 | 38 | |
38 | 39 | parent::__construct(); |
39 | 40 | } |
40 | 41 | |
41 | - protected function set_head_data() |
|
42 | - { |
|
42 | + protected function set_head_data() |
|
43 | + { |
|
43 | 44 | parent::set_head_data(); |
44 | 45 | |
45 | 46 | if($this->page == 1) |
46 | 47 | { |
47 | 48 | $this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->tag['tag']))); |
48 | 49 | $this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->tag['tag']))); |
49 | - } |
|
50 | - else |
|
50 | + } else |
|
51 | 51 | { |
52 | 52 | $this->set_title(sprintf(self::$TITLE_PAGINATED, ucwords($this->tag['tag']), $this->page, $this->total_pages)); |
53 | 53 | $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages, ucwords($this->tag['tag']))); |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | $this->set_keywords($keyword_array); |
59 | 59 | } |
60 | 60 | |
61 | - protected function get_introduction() |
|
62 | - { |
|
61 | + protected function get_introduction() |
|
62 | + { |
|
63 | 63 | $tag = ucwords($this->tag['tag']); |
64 | 64 | |
65 | 65 | if($this->page == 1) |
@@ -86,48 +86,52 @@ discard block |
||
86 | 86 | 'title' => "{$tag} posts, page {$this->page} of {$this->total_pages}."); |
87 | 87 | } |
88 | 88 | |
89 | - protected function get_page_number() |
|
90 | - { |
|
89 | + protected function get_page_number() |
|
90 | + { |
|
91 | 91 | $page = URLDecode::getPiece(3); |
92 | - if(isset($page) && is_numeric($page)) |
|
93 | - return $page; |
|
92 | + if(isset($page) && is_numeric($page)) { |
|
93 | + return $page; |
|
94 | + } |
|
94 | 95 | return 1; |
95 | 96 | } |
96 | 97 | |
97 | - protected function get_list_results() |
|
98 | - { |
|
98 | + protected function get_list_results() |
|
99 | + { |
|
99 | 100 | global $container; |
100 | 101 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
101 | 102 | return $repository->getActivePostsByTag($this->tag['id'], self::$POSTS_PER_PAGE, $this->offset); |
102 | 103 | } |
103 | 104 | |
104 | - protected function get_list_description() |
|
105 | - { |
|
105 | + protected function get_list_description() |
|
106 | + { |
|
106 | 107 | $start = $this->offset + 1; |
107 | 108 | $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
108 | 109 | |
109 | 110 | return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count(), $this->tag['tag']); |
110 | 111 | } |
111 | 112 | |
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(); |
|
113 | + protected function get_list_next_link() |
|
114 | + { |
|
115 | + if($this->page == 1) { |
|
116 | + return; |
|
117 | + } |
|
118 | + if($this->page == 2) { |
|
119 | + return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/")->activate(); |
|
120 | + } |
|
118 | 121 | return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/" . ($this->page - 1) . '/')->activate(); |
119 | 122 | } |
120 | 123 | |
121 | - protected function get_list_prev_link() |
|
122 | - { |
|
123 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
124 | - return; |
|
124 | + protected function get_list_prev_link() |
|
125 | + { |
|
126 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) { |
|
127 | + return; |
|
128 | + } |
|
125 | 129 | return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/" . ($this->page + 1) . '/')->activate(); |
126 | 130 | } |
127 | 131 | |
128 | 132 | private $total_post_count; |
129 | - protected function get_total_post_count() |
|
130 | - { |
|
133 | + protected function get_total_post_count() |
|
134 | + { |
|
131 | 135 | if(!isset($this->total_post_count)) { |
132 | 136 | global $container; |
133 | 137 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | { |
68 | 68 | parent::set_head_data(); |
69 | 69 | |
70 | - switch($this->category->display) |
|
70 | + switch ($this->category->display) |
|
71 | 71 | { |
72 | 72 | case 'Hiking' : |
73 | - if($this->page == 1) |
|
73 | + if ($this->page == 1) |
|
74 | 74 | { |
75 | 75 | $this->set_title(self::$TITLE_MAIN_HIKING); |
76 | 76 | $this->set_description(self::$DESCRIPTION_MAIN_HIKING); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $this->set_keywords(self::$KEYWORD_ARRAY_HIKING); |
84 | 84 | break; |
85 | 85 | case 'Personal' : |
86 | - if($this->page == 1) |
|
86 | + if ($this->page == 1) |
|
87 | 87 | { |
88 | 88 | $this->set_title(self::$TITLE_MAIN_PERSONAL); |
89 | 89 | $this->set_description(self::$DESCRIPTION_MAIN_PERSONAL); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $this->set_keywords(self::$KEYWORD_ARRAY_PERSONAL); |
97 | 97 | break; |
98 | 98 | case 'Web Development' : |
99 | - if($this->page == 1) |
|
99 | + if ($this->page == 1) |
|
100 | 100 | { |
101 | 101 | $this->set_title(self::$TITLE_MAIN_WEBDEVELOPMENT); |
102 | 102 | $this->set_description(self::$DESCRIPTION_MAIN_WEBDEVELOPMENT); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | protected function get_introduction() |
115 | 115 | { |
116 | - if($this->page == 1) |
|
116 | + if ($this->page == 1) |
|
117 | 117 | { |
118 | 118 | global $container; |
119 | 119 | $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | protected function get_page_number() |
135 | 135 | { |
136 | 136 | $page = URLDecode::getPiece(2); |
137 | - if(isset($page) && is_numeric($page)) |
|
137 | + if (isset($page) && is_numeric($page)) |
|
138 | 138 | return $page; |
139 | 139 | return 1; |
140 | 140 | } |
@@ -156,24 +156,24 @@ discard block |
||
156 | 156 | |
157 | 157 | protected function get_list_next_link() |
158 | 158 | { |
159 | - if($this->page == 1) |
|
159 | + if ($this->page == 1) |
|
160 | 160 | return; |
161 | - if($this->page == 2) |
|
161 | + if ($this->page == 2) |
|
162 | 162 | return Content::instance('URLSafe', "/{$this->category->link}/")->activate(); |
163 | - return Content::instance('URLSafe', "/{$this->category->link}/" . ($this->page - 1) . '/')->activate(); |
|
163 | + return Content::instance('URLSafe', "/{$this->category->link}/".($this->page - 1).'/')->activate(); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | protected function get_list_prev_link() |
167 | 167 | { |
168 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
168 | + if (($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
169 | 169 | return; |
170 | - return Content::instance('URLSafe', "/{$this->category->link}/" . ($this->page + 1) . '/')->activate(); |
|
170 | + return Content::instance('URLSafe', "/{$this->category->link}/".($this->page + 1).'/')->activate(); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | private $total_post_count; |
174 | 174 | protected function get_total_post_count() |
175 | 175 | { |
176 | - if(!isset($this->total_post_count)) { |
|
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); |
@@ -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 | } |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | Loader::load('controller', 'blog/DefaultListController'); |
4 | 4 | |
5 | -final class CategoryController extends DefaultListController |
|
6 | -{ |
|
5 | +final class CategoryController extends DefaultListController |
|
6 | +{ |
|
7 | 7 | |
8 | 8 | private static $TITLE_MAIN_HIKING = "Hiking | Posts on Upper Peninsula Exploring on Jacob Emerick's Blog"; |
9 | 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."; |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | |
54 | 54 | private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d posts in the %s category.'; |
55 | 55 | |
56 | - public function __construct() |
|
57 | - { |
|
56 | + public function __construct() |
|
57 | + { |
|
58 | 58 | $url = URLDecode::getPiece(1); |
59 | 59 | $this->category = (object) array( |
60 | 60 | 'display' => ucwords(str_replace('-', ' ', $url)), |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | parent::__construct(); |
64 | 64 | } |
65 | 65 | |
66 | - protected function set_head_data() |
|
67 | - { |
|
66 | + protected function set_head_data() |
|
67 | + { |
|
68 | 68 | parent::set_head_data(); |
69 | 69 | |
70 | 70 | switch($this->category->display) |
@@ -74,8 +74,7 @@ discard block |
||
74 | 74 | { |
75 | 75 | $this->set_title(self::$TITLE_MAIN_HIKING); |
76 | 76 | $this->set_description(self::$DESCRIPTION_MAIN_HIKING); |
77 | - } |
|
78 | - else |
|
77 | + } else |
|
79 | 78 | { |
80 | 79 | $this->set_title(sprintf(self::$TITLE_PAGINATED_HIKING, $this->page, $this->total_pages)); |
81 | 80 | $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED_HIKING, $this->page, $this->total_pages)); |
@@ -87,8 +86,7 @@ discard block |
||
87 | 86 | { |
88 | 87 | $this->set_title(self::$TITLE_MAIN_PERSONAL); |
89 | 88 | $this->set_description(self::$DESCRIPTION_MAIN_PERSONAL); |
90 | - } |
|
91 | - else |
|
89 | + } else |
|
92 | 90 | { |
93 | 91 | $this->set_title(sprintf(self::$TITLE_PAGINATED_PERSONAL, $this->page, $this->total_pages)); |
94 | 92 | $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED_PERSONAL, $this->page, $this->total_pages)); |
@@ -100,8 +98,7 @@ discard block |
||
100 | 98 | { |
101 | 99 | $this->set_title(self::$TITLE_MAIN_WEBDEVELOPMENT); |
102 | 100 | $this->set_description(self::$DESCRIPTION_MAIN_WEBDEVELOPMENT); |
103 | - } |
|
104 | - else |
|
101 | + } else |
|
105 | 102 | { |
106 | 103 | $this->set_title(sprintf(self::$TITLE_PAGINATED_WEBDEVELOPMENT, $this->page, $this->total_pages)); |
107 | 104 | $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED_WEBDEVELOPMENT, $this->page, $this->total_pages)); |
@@ -111,8 +108,8 @@ discard block |
||
111 | 108 | } |
112 | 109 | } |
113 | 110 | |
114 | - protected function get_introduction() |
|
115 | - { |
|
111 | + protected function get_introduction() |
|
112 | + { |
|
116 | 113 | if($this->page == 1) |
117 | 114 | { |
118 | 115 | global $container; |
@@ -131,48 +128,52 @@ discard block |
||
131 | 128 | 'title' => "Posts about {$this->category->display}, page {$this->page} of {$this->total_pages}."); |
132 | 129 | } |
133 | 130 | |
134 | - protected function get_page_number() |
|
135 | - { |
|
131 | + protected function get_page_number() |
|
132 | + { |
|
136 | 133 | $page = URLDecode::getPiece(2); |
137 | - if(isset($page) && is_numeric($page)) |
|
138 | - return $page; |
|
134 | + if(isset($page) && is_numeric($page)) { |
|
135 | + return $page; |
|
136 | + } |
|
139 | 137 | return 1; |
140 | 138 | } |
141 | 139 | |
142 | - protected function get_list_results() |
|
143 | - { |
|
140 | + protected function get_list_results() |
|
141 | + { |
|
144 | 142 | global $container; |
145 | 143 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
146 | 144 | return $repository->getActivePostsByCategory($this->category->link, self::$POSTS_PER_PAGE, $this->offset); |
147 | 145 | } |
148 | 146 | |
149 | - protected function get_list_description() |
|
150 | - { |
|
147 | + protected function get_list_description() |
|
148 | + { |
|
151 | 149 | $start = $this->offset + 1; |
152 | 150 | $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
153 | 151 | |
154 | 152 | return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count(), $this->category->display); |
155 | 153 | } |
156 | 154 | |
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(); |
|
155 | + protected function get_list_next_link() |
|
156 | + { |
|
157 | + if($this->page == 1) { |
|
158 | + return; |
|
159 | + } |
|
160 | + if($this->page == 2) { |
|
161 | + return Content::instance('URLSafe', "/{$this->category->link}/")->activate(); |
|
162 | + } |
|
163 | 163 | return Content::instance('URLSafe', "/{$this->category->link}/" . ($this->page - 1) . '/')->activate(); |
164 | 164 | } |
165 | 165 | |
166 | - protected function get_list_prev_link() |
|
167 | - { |
|
168 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
169 | - return; |
|
166 | + protected function get_list_prev_link() |
|
167 | + { |
|
168 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) { |
|
169 | + return; |
|
170 | + } |
|
170 | 171 | return Content::instance('URLSafe', "/{$this->category->link}/" . ($this->page + 1) . '/')->activate(); |
171 | 172 | } |
172 | 173 | |
173 | 174 | private $total_post_count; |
174 | - protected function get_total_post_count() |
|
175 | - { |
|
175 | + protected function get_total_post_count() |
|
176 | + { |
|
176 | 177 | if(!isset($this->total_post_count)) { |
177 | 178 | global $container; |
178 | 179 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
@@ -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', |