@@ -5,64 +5,64 @@ |
||
5 | 5 | abstract class DefaultListController extends DefaultPageController |
6 | 6 | { |
7 | 7 | |
8 | - protected static $POSTS_PER_PAGE = 10; |
|
8 | + protected static $POSTS_PER_PAGE = 10; |
|
9 | 9 | |
10 | - protected $page; |
|
11 | - protected $offset; |
|
10 | + protected $page; |
|
11 | + protected $offset; |
|
12 | 12 | |
13 | - public function __construct() |
|
14 | - { |
|
15 | - parent::__construct(); |
|
13 | + public function __construct() |
|
14 | + { |
|
15 | + parent::__construct(); |
|
16 | 16 | |
17 | - $this->page = $this->get_page_number(); |
|
18 | - $this->total_pages = ceil($this->get_total_post_count() / self::$POSTS_PER_PAGE); |
|
19 | - $this->offset = ($this->page - 1) * self::$POSTS_PER_PAGE; |
|
20 | - } |
|
17 | + $this->page = $this->get_page_number(); |
|
18 | + $this->total_pages = ceil($this->get_total_post_count() / self::$POSTS_PER_PAGE); |
|
19 | + $this->offset = ($this->page - 1) * self::$POSTS_PER_PAGE; |
|
20 | + } |
|
21 | 21 | |
22 | - abstract protected function get_page_number(); |
|
23 | - abstract protected function get_list_results(); |
|
24 | - abstract protected function get_list_description(); |
|
25 | - abstract protected function get_list_next_link(); |
|
26 | - abstract protected function get_list_prev_link(); |
|
27 | - abstract protected function get_total_post_count(); |
|
22 | + abstract protected function get_page_number(); |
|
23 | + abstract protected function get_list_results(); |
|
24 | + abstract protected function get_list_description(); |
|
25 | + abstract protected function get_list_next_link(); |
|
26 | + abstract protected function get_list_prev_link(); |
|
27 | + abstract protected function get_total_post_count(); |
|
28 | 28 | |
29 | - protected function set_head_data() |
|
30 | - { |
|
31 | - parent::set_head_data(); |
|
29 | + protected function set_head_data() |
|
30 | + { |
|
31 | + parent::set_head_data(); |
|
32 | 32 | |
33 | - $this->set_head('next_link', $this->get_list_next_link()); |
|
34 | - $this->set_head('previous_link', $this->get_list_prev_link()); |
|
35 | - } |
|
33 | + $this->set_head('next_link', $this->get_list_next_link()); |
|
34 | + $this->set_head('previous_link', $this->get_list_prev_link()); |
|
35 | + } |
|
36 | 36 | |
37 | - protected function set_body_data() |
|
38 | - { |
|
39 | - parent::set_body_data(); |
|
37 | + protected function set_body_data() |
|
38 | + { |
|
39 | + parent::set_body_data(); |
|
40 | 40 | |
41 | - $this->set_body('view', 'Listing'); |
|
42 | - $this->set_body('data', $this->get_list_body_data()); |
|
43 | - } |
|
41 | + $this->set_body('view', 'Listing'); |
|
42 | + $this->set_body('data', $this->get_list_body_data()); |
|
43 | + } |
|
44 | 44 | |
45 | - final private function get_list_body_data() |
|
46 | - { |
|
47 | - return array( |
|
48 | - 'posts' => $this->get_list_posts(), |
|
49 | - 'show_top_navigation' => ($this->page !== 1), |
|
50 | - 'navigation' => array( |
|
51 | - 'description' => $this->get_list_description(), |
|
52 | - 'next' => $this->get_list_next_link(), |
|
53 | - 'prev' => $this->get_list_prev_link())); |
|
54 | - } |
|
45 | + final private function get_list_body_data() |
|
46 | + { |
|
47 | + return array( |
|
48 | + 'posts' => $this->get_list_posts(), |
|
49 | + 'show_top_navigation' => ($this->page !== 1), |
|
50 | + 'navigation' => array( |
|
51 | + 'description' => $this->get_list_description(), |
|
52 | + 'next' => $this->get_list_next_link(), |
|
53 | + 'prev' => $this->get_list_prev_link())); |
|
54 | + } |
|
55 | 55 | |
56 | - final private function get_list_posts() |
|
57 | - { |
|
58 | - $post_array = array(); |
|
59 | - foreach($this->get_list_results() as $post) |
|
60 | - { |
|
61 | - $post_array[] = $this->format_post($post, true); |
|
62 | - } |
|
63 | - if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
64 | - $this->eject(); |
|
65 | - return $post_array; |
|
66 | - } |
|
56 | + final private function get_list_posts() |
|
57 | + { |
|
58 | + $post_array = array(); |
|
59 | + foreach($this->get_list_results() as $post) |
|
60 | + { |
|
61 | + $post_array[] = $this->format_post($post, true); |
|
62 | + } |
|
63 | + if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
64 | + $this->eject(); |
|
65 | + return $post_array; |
|
66 | + } |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | \ No newline at end of file |
@@ -6,134 +6,134 @@ |
||
6 | 6 | final class SearchController extends DefaultListController |
7 | 7 | { |
8 | 8 | |
9 | - private static $TITLE_MAIN = "%s Search | Jacob Emerick's Blog"; |
|
10 | - private static $DESCRIPTION_MAIN = "Posts containing the phrase %s on Jacob Emerick's Blog."; |
|
11 | - |
|
12 | - private static $TITLE_PAGINATED = "%s Search - Page %d of %d | Jacob Emerick's Blog"; |
|
13 | - private static $DESCRIPTION_PAGINATED = "Page %d of %d with posts containing the phrase %s on Jacob Emerick's Blog."; |
|
14 | - |
|
15 | - private static $KEYWORD_ARRAY = array( |
|
16 | - 'hiking', |
|
17 | - 'web development', |
|
18 | - 'blog', |
|
19 | - 'Jacob Emerick'); |
|
20 | - |
|
21 | - private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d posts containing the phrase %s.'; |
|
22 | - private static $SEARCH_WEIGHTS = array( |
|
23 | - array( |
|
24 | - 'field' => 'title', |
|
25 | - 'weight' => 8), |
|
26 | - array( |
|
27 | - 'field' => 'body', |
|
28 | - 'weight' => 4)); |
|
29 | - |
|
30 | - private $query; |
|
31 | - |
|
32 | - public function __construct() |
|
33 | - { |
|
34 | - $query = URLDecode::getPiece(2); |
|
35 | - $query = urldecode($query); |
|
9 | + private static $TITLE_MAIN = "%s Search | Jacob Emerick's Blog"; |
|
10 | + private static $DESCRIPTION_MAIN = "Posts containing the phrase %s on Jacob Emerick's Blog."; |
|
11 | + |
|
12 | + private static $TITLE_PAGINATED = "%s Search - Page %d of %d | Jacob Emerick's Blog"; |
|
13 | + private static $DESCRIPTION_PAGINATED = "Page %d of %d with posts containing the phrase %s on Jacob Emerick's Blog."; |
|
14 | + |
|
15 | + private static $KEYWORD_ARRAY = array( |
|
16 | + 'hiking', |
|
17 | + 'web development', |
|
18 | + 'blog', |
|
19 | + 'Jacob Emerick'); |
|
20 | + |
|
21 | + private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d posts containing the phrase %s.'; |
|
22 | + private static $SEARCH_WEIGHTS = array( |
|
23 | + array( |
|
24 | + 'field' => 'title', |
|
25 | + 'weight' => 8), |
|
26 | + array( |
|
27 | + 'field' => 'body', |
|
28 | + 'weight' => 4)); |
|
29 | + |
|
30 | + private $query; |
|
31 | + |
|
32 | + public function __construct() |
|
33 | + { |
|
34 | + $query = URLDecode::getPiece(2); |
|
35 | + $query = urldecode($query); |
|
36 | 36 | $query = str_replace('-', ' ', $query); |
37 | 37 | |
38 | - $this->query = $query; |
|
38 | + $this->query = $query; |
|
39 | 39 | |
40 | - parent::__construct(); |
|
41 | - } |
|
40 | + parent::__construct(); |
|
41 | + } |
|
42 | 42 | |
43 | - protected function set_head_data() |
|
44 | - { |
|
45 | - parent::set_head_data(); |
|
43 | + protected function set_head_data() |
|
44 | + { |
|
45 | + parent::set_head_data(); |
|
46 | 46 | |
47 | - if($this->page == 1) |
|
48 | - { |
|
49 | - $this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->query))); |
|
50 | - $this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->query))); |
|
51 | - } |
|
52 | - else |
|
53 | - { |
|
54 | - $this->set_title(sprintf(self::$TITLE_PAGINATED, ucwords($this->query), $this->page, $this->total_pages)); |
|
55 | - $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages, ucwords($this->query))); |
|
56 | - } |
|
47 | + if($this->page == 1) |
|
48 | + { |
|
49 | + $this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->query))); |
|
50 | + $this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->query))); |
|
51 | + } |
|
52 | + else |
|
53 | + { |
|
54 | + $this->set_title(sprintf(self::$TITLE_PAGINATED, ucwords($this->query), $this->page, $this->total_pages)); |
|
55 | + $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages, ucwords($this->query))); |
|
56 | + } |
|
57 | 57 | |
58 | - $keyword_array = self::$KEYWORD_ARRAY; |
|
59 | - array_unshift($keyword_array, $this->query); |
|
60 | - $this->set_keywords($keyword_array); |
|
61 | - } |
|
62 | - |
|
63 | - protected function get_introduction() |
|
64 | - { |
|
65 | - if($this->total_pages > 1) |
|
66 | - return array( |
|
67 | - 'title' => "Posts from search '{$this->query}', page {$this->page} of {$this->total_pages}."); |
|
68 | - else if($this->total_pages == 1) |
|
69 | - return array( |
|
70 | - 'title' => "Posts from search '{$this->query}'."); |
|
71 | - else |
|
72 | - return array( |
|
73 | - 'title' => "Sorry, '{$this->query}' didn't return any posts."); |
|
74 | - } |
|
75 | - |
|
76 | - protected function get_page_number() |
|
77 | - { |
|
78 | - $page = URLDecode::getPiece(3); |
|
79 | - if(isset($page) && is_numeric($page)) |
|
80 | - return $page; |
|
81 | - return 1; |
|
82 | - } |
|
83 | - |
|
84 | - private $search_result; |
|
85 | - private function get_search_result() |
|
86 | - { |
|
87 | - if(!isset($this->search_result)) |
|
88 | - { |
|
58 | + $keyword_array = self::$KEYWORD_ARRAY; |
|
59 | + array_unshift($keyword_array, $this->query); |
|
60 | + $this->set_keywords($keyword_array); |
|
61 | + } |
|
62 | + |
|
63 | + protected function get_introduction() |
|
64 | + { |
|
65 | + if($this->total_pages > 1) |
|
66 | + return array( |
|
67 | + 'title' => "Posts from search '{$this->query}', page {$this->page} of {$this->total_pages}."); |
|
68 | + else if($this->total_pages == 1) |
|
69 | + return array( |
|
70 | + 'title' => "Posts from search '{$this->query}'."); |
|
71 | + else |
|
72 | + return array( |
|
73 | + 'title' => "Sorry, '{$this->query}' didn't return any posts."); |
|
74 | + } |
|
75 | + |
|
76 | + protected function get_page_number() |
|
77 | + { |
|
78 | + $page = URLDecode::getPiece(3); |
|
79 | + if(isset($page) && is_numeric($page)) |
|
80 | + return $page; |
|
81 | + return 1; |
|
82 | + } |
|
83 | + |
|
84 | + private $search_result; |
|
85 | + private function get_search_result() |
|
86 | + { |
|
87 | + if(!isset($this->search_result)) |
|
88 | + { |
|
89 | 89 | global $container; |
90 | 90 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
91 | 91 | $posts = $repository->getActivePosts(); |
92 | 92 | |
93 | - $this->search_result = Search::instance() |
|
94 | - ->setQuery($this->query) |
|
95 | - ->setResult($posts) |
|
96 | - ->setWeight(self::$SEARCH_WEIGHTS) |
|
97 | - ->perform(); |
|
98 | - } |
|
99 | - return $this->search_result; |
|
100 | - } |
|
101 | - |
|
102 | - protected function get_list_results() |
|
103 | - { |
|
104 | - return array_slice($this->get_search_result(), $this->offset, self::$POSTS_PER_PAGE); |
|
105 | - } |
|
106 | - |
|
107 | - protected function get_list_description() |
|
108 | - { |
|
109 | - $start = $this->offset + 1; |
|
110 | - $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
93 | + $this->search_result = Search::instance() |
|
94 | + ->setQuery($this->query) |
|
95 | + ->setResult($posts) |
|
96 | + ->setWeight(self::$SEARCH_WEIGHTS) |
|
97 | + ->perform(); |
|
98 | + } |
|
99 | + return $this->search_result; |
|
100 | + } |
|
101 | + |
|
102 | + protected function get_list_results() |
|
103 | + { |
|
104 | + return array_slice($this->get_search_result(), $this->offset, self::$POSTS_PER_PAGE); |
|
105 | + } |
|
106 | + |
|
107 | + protected function get_list_description() |
|
108 | + { |
|
109 | + $start = $this->offset + 1; |
|
110 | + $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
111 | 111 | |
112 | - return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count(), $this->query); |
|
113 | - } |
|
114 | - |
|
115 | - protected function get_list_next_link() |
|
116 | - { |
|
117 | - if($this->page == 1) |
|
118 | - return; |
|
119 | - if($this->page == 2) |
|
120 | - return Content::instance('URLSafe', "/search/{$this->query}/")->activate(); |
|
121 | - return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page - 1) . '/')->activate(); |
|
122 | - } |
|
123 | - |
|
124 | - protected function get_list_prev_link() |
|
125 | - { |
|
126 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
127 | - return; |
|
128 | - return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page + 1) . '/')->activate(); |
|
129 | - } |
|
130 | - |
|
131 | - private $total_post_count; |
|
132 | - protected function get_total_post_count() |
|
133 | - { |
|
134 | - if(!isset($this->total_post_count)) |
|
135 | - $this->total_post_count = count($this->get_search_result()); |
|
136 | - return $this->total_post_count; |
|
137 | - } |
|
112 | + return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count(), $this->query); |
|
113 | + } |
|
114 | + |
|
115 | + protected function get_list_next_link() |
|
116 | + { |
|
117 | + if($this->page == 1) |
|
118 | + return; |
|
119 | + if($this->page == 2) |
|
120 | + return Content::instance('URLSafe', "/search/{$this->query}/")->activate(); |
|
121 | + return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page - 1) . '/')->activate(); |
|
122 | + } |
|
123 | + |
|
124 | + protected function get_list_prev_link() |
|
125 | + { |
|
126 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
127 | + return; |
|
128 | + return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page + 1) . '/')->activate(); |
|
129 | + } |
|
130 | + |
|
131 | + private $total_post_count; |
|
132 | + protected function get_total_post_count() |
|
133 | + { |
|
134 | + if(!isset($this->total_post_count)) |
|
135 | + $this->total_post_count = count($this->get_search_result()); |
|
136 | + return $this->total_post_count; |
|
137 | + } |
|
138 | 138 | |
139 | 139 | } |
@@ -5,47 +5,47 @@ |
||
5 | 5 | final class AboutController extends DefaultPageController |
6 | 6 | { |
7 | 7 | |
8 | - private static $TITLE = 'About the Blog | Jacob Emerick'; |
|
9 | - private static $DESCRIPTION = "A little bit about the awesomeness on Jacob Emerick's Blog, diving into the topics covered, technology used, and methodology of writing new posts."; |
|
10 | - |
|
11 | - private static $KEYWORD_ARRAY = array( |
|
12 | - 'about', |
|
13 | - 'technologies', |
|
14 | - 'background', |
|
15 | - 'blog', |
|
16 | - 'Jacob Emerick'); |
|
17 | - |
|
18 | - protected function set_head_data() |
|
19 | - { |
|
20 | - $this->set_title(self::$TITLE); |
|
21 | - $this->set_description(self::$DESCRIPTION); |
|
22 | - $this->set_keywords(self::$KEYWORD_ARRAY); |
|
8 | + private static $TITLE = 'About the Blog | Jacob Emerick'; |
|
9 | + private static $DESCRIPTION = "A little bit about the awesomeness on Jacob Emerick's Blog, diving into the topics covered, technology used, and methodology of writing new posts."; |
|
10 | + |
|
11 | + private static $KEYWORD_ARRAY = array( |
|
12 | + 'about', |
|
13 | + 'technologies', |
|
14 | + 'background', |
|
15 | + 'blog', |
|
16 | + 'Jacob Emerick'); |
|
17 | + |
|
18 | + protected function set_head_data() |
|
19 | + { |
|
20 | + $this->set_title(self::$TITLE); |
|
21 | + $this->set_description(self::$DESCRIPTION); |
|
22 | + $this->set_keywords(self::$KEYWORD_ARRAY); |
|
23 | 23 | |
24 | - parent::set_head_data(); |
|
25 | - } |
|
24 | + parent::set_head_data(); |
|
25 | + } |
|
26 | 26 | |
27 | - protected function set_body_data() |
|
28 | - { |
|
29 | - $this->set_body('view', 'About'); |
|
27 | + protected function set_body_data() |
|
28 | + { |
|
29 | + $this->set_body('view', 'About'); |
|
30 | 30 | |
31 | - parent::set_body_data(); |
|
32 | - } |
|
31 | + parent::set_body_data(); |
|
32 | + } |
|
33 | 33 | |
34 | - protected function get_introduction() |
|
35 | - { |
|
34 | + protected function get_introduction() |
|
35 | + { |
|
36 | 36 | global $container; |
37 | 37 | $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
38 | 38 | $introduction_result = $repository->findByType('about'); |
39 | 39 | |
40 | - if($introduction_result !== null) |
|
41 | - { |
|
42 | - $introduction = array(); |
|
43 | - $introduction['title'] = $introduction_result['title']; |
|
44 | - $introduction['content'] = $introduction_result['content']; |
|
45 | - $introduction['image'] = $this->get_introduction_image($introduction_result['image']); |
|
40 | + if($introduction_result !== null) |
|
41 | + { |
|
42 | + $introduction = array(); |
|
43 | + $introduction['title'] = $introduction_result['title']; |
|
44 | + $introduction['content'] = $introduction_result['content']; |
|
45 | + $introduction['image'] = $this->get_introduction_image($introduction_result['image']); |
|
46 | 46 | |
47 | - return $introduction; |
|
48 | - } |
|
49 | - } |
|
47 | + return $introduction; |
|
48 | + } |
|
49 | + } |
|
50 | 50 | |
51 | 51 | } |
@@ -5,115 +5,115 @@ |
||
5 | 5 | final class HomeController extends DefaultListController |
6 | 6 | { |
7 | 7 | |
8 | - private static $TITLE_MAIN = "Jacob Emerick's Blog | Posts on Hiking, Web Development, and more"; |
|
9 | - private static $TITLE_PAGINATED = "Page %d of %d in Jacob Emerick's Blog"; |
|
10 | - |
|
11 | - private static $DESCRIPTION_MAIN = "Jacob Emerick's Blog - a collection of posts about hiking the Upper Peninsula, learning to be a web developer, and other experiences of a young man."; |
|
12 | - private static $DESCRIPTION_PAGINATED = "Page %d of %d of posts about hiking in the Upper Peninsula, learning to be a web developer, and more on Jacob Emerick's Blog."; |
|
13 | - |
|
14 | - private static $KEYWORD_ARRAY = array( |
|
15 | - 'blog', |
|
16 | - 'Jacob Emerick', |
|
17 | - 'hiking', |
|
18 | - 'Huron Mountains', |
|
19 | - 'Peshekee Highlands', |
|
20 | - 'Keweenaw', |
|
21 | - 'Michigan', |
|
22 | - 'Upper Peninsula', |
|
23 | - 'leadership', |
|
24 | - 'web development', |
|
25 | - 'php programming', |
|
26 | - 'data handling', |
|
27 | - 'optimization'); |
|
28 | - |
|
29 | - private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d total posts.'; |
|
30 | - |
|
31 | - protected function set_head_data() |
|
32 | - { |
|
33 | - parent::set_head_data(); |
|
8 | + private static $TITLE_MAIN = "Jacob Emerick's Blog | Posts on Hiking, Web Development, and more"; |
|
9 | + private static $TITLE_PAGINATED = "Page %d of %d in Jacob Emerick's Blog"; |
|
10 | + |
|
11 | + private static $DESCRIPTION_MAIN = "Jacob Emerick's Blog - a collection of posts about hiking the Upper Peninsula, learning to be a web developer, and other experiences of a young man."; |
|
12 | + private static $DESCRIPTION_PAGINATED = "Page %d of %d of posts about hiking in the Upper Peninsula, learning to be a web developer, and more on Jacob Emerick's Blog."; |
|
13 | + |
|
14 | + private static $KEYWORD_ARRAY = array( |
|
15 | + 'blog', |
|
16 | + 'Jacob Emerick', |
|
17 | + 'hiking', |
|
18 | + 'Huron Mountains', |
|
19 | + 'Peshekee Highlands', |
|
20 | + 'Keweenaw', |
|
21 | + 'Michigan', |
|
22 | + 'Upper Peninsula', |
|
23 | + 'leadership', |
|
24 | + 'web development', |
|
25 | + 'php programming', |
|
26 | + 'data handling', |
|
27 | + 'optimization'); |
|
28 | + |
|
29 | + private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d total posts.'; |
|
30 | + |
|
31 | + protected function set_head_data() |
|
32 | + { |
|
33 | + parent::set_head_data(); |
|
34 | 34 | |
35 | - if($this->page == 1) |
|
36 | - $this->set_title(self::$TITLE_MAIN); |
|
37 | - else |
|
38 | - $this->set_title(sprintf(self::$TITLE_PAGINATED, $this->page, $this->total_pages)); |
|
35 | + if($this->page == 1) |
|
36 | + $this->set_title(self::$TITLE_MAIN); |
|
37 | + else |
|
38 | + $this->set_title(sprintf(self::$TITLE_PAGINATED, $this->page, $this->total_pages)); |
|
39 | 39 | |
40 | - if($this->page == 1) |
|
41 | - $this->set_description(self::$DESCRIPTION_MAIN); |
|
42 | - else |
|
43 | - $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages)); |
|
40 | + if($this->page == 1) |
|
41 | + $this->set_description(self::$DESCRIPTION_MAIN); |
|
42 | + else |
|
43 | + $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages)); |
|
44 | 44 | |
45 | - $this->set_keywords(self::$KEYWORD_ARRAY); |
|
46 | - } |
|
45 | + $this->set_keywords(self::$KEYWORD_ARRAY); |
|
46 | + } |
|
47 | 47 | |
48 | - protected function get_introduction() |
|
49 | - { |
|
50 | - if($this->page == 1) |
|
51 | - { |
|
48 | + protected function get_introduction() |
|
49 | + { |
|
50 | + if($this->page == 1) |
|
51 | + { |
|
52 | 52 | global $container; |
53 | 53 | $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
54 | 54 | $introduction_result = $repository->findByType('home'); |
55 | 55 | |
56 | - $introduction = array(); |
|
57 | - $introduction['title'] = $introduction_result['title']; |
|
58 | - $introduction['content'] = $introduction_result['content']; |
|
59 | - $introduction['image'] = $this->get_introduction_image($introduction_result['image']); |
|
56 | + $introduction = array(); |
|
57 | + $introduction['title'] = $introduction_result['title']; |
|
58 | + $introduction['content'] = $introduction_result['content']; |
|
59 | + $introduction['image'] = $this->get_introduction_image($introduction_result['image']); |
|
60 | 60 | |
61 | - return $introduction; |
|
62 | - } |
|
61 | + return $introduction; |
|
62 | + } |
|
63 | 63 | |
64 | - return array( |
|
65 | - 'title' => "All of Jacob Emerick's posts, page {$this->page} of {$this->total_pages}."); |
|
66 | - } |
|
67 | - |
|
68 | - protected function get_page_number() |
|
69 | - { |
|
70 | - $page = URLDecode::getPiece(1); |
|
71 | - if(isset($page) && is_numeric($page)) |
|
72 | - return $page; |
|
73 | - return 1; |
|
74 | - } |
|
75 | - |
|
76 | - protected function get_list_results() |
|
77 | - { |
|
64 | + return array( |
|
65 | + 'title' => "All of Jacob Emerick's posts, page {$this->page} of {$this->total_pages}."); |
|
66 | + } |
|
67 | + |
|
68 | + protected function get_page_number() |
|
69 | + { |
|
70 | + $page = URLDecode::getPiece(1); |
|
71 | + if(isset($page) && is_numeric($page)) |
|
72 | + return $page; |
|
73 | + return 1; |
|
74 | + } |
|
75 | + |
|
76 | + protected function get_list_results() |
|
77 | + { |
|
78 | 78 | global $container; |
79 | 79 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
80 | 80 | return $repository->getActivePosts(self::$POSTS_PER_PAGE, $this->offset); |
81 | - } |
|
81 | + } |
|
82 | 82 | |
83 | - protected function get_list_description() |
|
84 | - { |
|
85 | - $start = $this->offset + 1; |
|
86 | - $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
83 | + protected function get_list_description() |
|
84 | + { |
|
85 | + $start = $this->offset + 1; |
|
86 | + $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
87 | 87 | |
88 | - return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count()); |
|
89 | - } |
|
90 | - |
|
91 | - protected function get_list_next_link() |
|
92 | - { |
|
93 | - if($this->page == 1) |
|
94 | - return; |
|
95 | - if($this->page == 2) |
|
96 | - return '/'; |
|
97 | - return '/' . ($this->page - 1) . '/'; |
|
98 | - } |
|
99 | - |
|
100 | - protected function get_list_prev_link() |
|
101 | - { |
|
102 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
103 | - return; |
|
104 | - return '/' . ($this->page + 1) . '/'; |
|
105 | - } |
|
106 | - |
|
107 | - private $total_post_count; |
|
108 | - protected function get_total_post_count() |
|
109 | - { |
|
110 | - if(!isset($this->total_post_count)) { |
|
111 | - global $container; |
|
112 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
113 | - $this->total_post_count = $repository->getActivePostsCount(); |
|
114 | - } |
|
115 | - |
|
116 | - return $this->total_post_count; |
|
117 | - } |
|
88 | + return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count()); |
|
89 | + } |
|
90 | + |
|
91 | + protected function get_list_next_link() |
|
92 | + { |
|
93 | + if($this->page == 1) |
|
94 | + return; |
|
95 | + if($this->page == 2) |
|
96 | + return '/'; |
|
97 | + return '/' . ($this->page - 1) . '/'; |
|
98 | + } |
|
99 | + |
|
100 | + protected function get_list_prev_link() |
|
101 | + { |
|
102 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
103 | + return; |
|
104 | + return '/' . ($this->page + 1) . '/'; |
|
105 | + } |
|
106 | + |
|
107 | + private $total_post_count; |
|
108 | + protected function get_total_post_count() |
|
109 | + { |
|
110 | + if(!isset($this->total_post_count)) { |
|
111 | + global $container; |
|
112 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
113 | + $this->total_post_count = $repository->getActivePostsCount(); |
|
114 | + } |
|
115 | + |
|
116 | + return $this->total_post_count; |
|
117 | + } |
|
118 | 118 | |
119 | 119 | } |
@@ -5,180 +5,180 @@ |
||
5 | 5 | final class CategoryController extends DefaultListController |
6 | 6 | { |
7 | 7 | |
8 | - private static $TITLE_MAIN_HIKING = "Hiking | Posts on Upper Peninsula Exploring on Jacob Emerick's Blog"; |
|
9 | - private static $DESCRIPTION_MAIN_HIKING = "Posts on Jacob Emerick's Blog about hiking the Upper Peninsula, exploring the Huron Mountains, and hunting waterfalls in the Keweenaw."; |
|
10 | - |
|
11 | - private static $TITLE_MAIN_PERSONAL = "Personal | Posts about life changes on Jacob Emerick's Blog"; |
|
12 | - private static $DESCRIPTION_MAIN_PERSONAL = "Stories about life changes for Jacob and Katie. New jobs, getting married, and general thoughts on things."; |
|
13 | - |
|
14 | - private static $TITLE_MAIN_WEBDEVELOPMENT = "Web Development | Tutorials and Best Practices on Jacob Emerick's Blog"; |
|
15 | - private static $DESCRIPTION_MAIN_WEBDEVELOPMENT = "Variety of tutorials and advice on best practices on Jacob Emerick's Blog, with a focus on object-orientated PHP development and project management."; |
|
16 | - |
|
17 | - private static $TITLE_PAGINATED_HIKING = "Hiking - Page %d of %d | Jacob Emerick's Blog"; |
|
18 | - private static $DESCRIPTION_PAGINATED_HIKING = "Page %d of %d about hiking on Jacob Emerick's Blog. Posts about hiking the Upper Peninsula, exploring the Huron Mountains, and hunting waterfalls of the Keweenaw."; |
|
19 | - |
|
20 | - private static $TITLE_PAGINATED_PERSONAL = "Personal - Page %d of %d | Jacob Emerick's Blog"; |
|
21 | - private static $DESCRIPTION_PAGINATED_PERSONAL = "Page %d of %d of personal posts on Jacob Emerick's Blog about life changes and general musings."; |
|
22 | - |
|
23 | - private static $TITLE_PAGINATED_WEBDEVELOPMENT = "Web Development - Page %d of %d | Jacob Emerick's Blog"; |
|
24 | - private static $DESCRIPTION_PAGINATED_WEBDEVELOPMENT = "Page %d of %d of posts on web development, ranging from general tutorials to advanced best practices, on Jacob Emerick's Blog."; |
|
25 | - |
|
26 | - private static $KEYWORD_ARRAY_HIKING = array( |
|
27 | - 'hiking', |
|
28 | - 'upper peninsula', |
|
29 | - 'huron mountains', |
|
30 | - 'keweenaw', |
|
31 | - 'michigan', |
|
32 | - 'backpacking', |
|
33 | - 'Jacob Emerick'); |
|
34 | - |
|
35 | - private static $KEYWORD_ARRAY_PERSONAL = array( |
|
36 | - 'dealerfire', |
|
37 | - 'sparknet', |
|
38 | - 'katie', |
|
39 | - 'logan', |
|
40 | - 'marriage', |
|
41 | - 'Jacob Emerick'); |
|
42 | - |
|
43 | - private static $KEYWORD_ARRAY_WEBDEVELOPMENT = array( |
|
44 | - 'best practices', |
|
45 | - 'object orientated php', |
|
46 | - 'data abstraction', |
|
47 | - 'semantic web', |
|
48 | - 'responsive design', |
|
49 | - 'responsible development', |
|
50 | - 'Jacob Emerick'); |
|
51 | - |
|
52 | - private $category; |
|
53 | - |
|
54 | - private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d posts in the %s category.'; |
|
55 | - |
|
56 | - public function __construct() |
|
57 | - { |
|
58 | - $url = URLDecode::getPiece(1); |
|
59 | - $this->category = (object) array( |
|
60 | - 'display' => ucwords(str_replace('-', ' ', $url)), |
|
61 | - 'link' => $url); |
|
8 | + private static $TITLE_MAIN_HIKING = "Hiking | Posts on Upper Peninsula Exploring on Jacob Emerick's Blog"; |
|
9 | + private static $DESCRIPTION_MAIN_HIKING = "Posts on Jacob Emerick's Blog about hiking the Upper Peninsula, exploring the Huron Mountains, and hunting waterfalls in the Keweenaw."; |
|
10 | + |
|
11 | + private static $TITLE_MAIN_PERSONAL = "Personal | Posts about life changes on Jacob Emerick's Blog"; |
|
12 | + private static $DESCRIPTION_MAIN_PERSONAL = "Stories about life changes for Jacob and Katie. New jobs, getting married, and general thoughts on things."; |
|
13 | + |
|
14 | + private static $TITLE_MAIN_WEBDEVELOPMENT = "Web Development | Tutorials and Best Practices on Jacob Emerick's Blog"; |
|
15 | + private static $DESCRIPTION_MAIN_WEBDEVELOPMENT = "Variety of tutorials and advice on best practices on Jacob Emerick's Blog, with a focus on object-orientated PHP development and project management."; |
|
16 | + |
|
17 | + private static $TITLE_PAGINATED_HIKING = "Hiking - Page %d of %d | Jacob Emerick's Blog"; |
|
18 | + private static $DESCRIPTION_PAGINATED_HIKING = "Page %d of %d about hiking on Jacob Emerick's Blog. Posts about hiking the Upper Peninsula, exploring the Huron Mountains, and hunting waterfalls of the Keweenaw."; |
|
19 | + |
|
20 | + private static $TITLE_PAGINATED_PERSONAL = "Personal - Page %d of %d | Jacob Emerick's Blog"; |
|
21 | + private static $DESCRIPTION_PAGINATED_PERSONAL = "Page %d of %d of personal posts on Jacob Emerick's Blog about life changes and general musings."; |
|
22 | + |
|
23 | + private static $TITLE_PAGINATED_WEBDEVELOPMENT = "Web Development - Page %d of %d | Jacob Emerick's Blog"; |
|
24 | + private static $DESCRIPTION_PAGINATED_WEBDEVELOPMENT = "Page %d of %d of posts on web development, ranging from general tutorials to advanced best practices, on Jacob Emerick's Blog."; |
|
25 | + |
|
26 | + private static $KEYWORD_ARRAY_HIKING = array( |
|
27 | + 'hiking', |
|
28 | + 'upper peninsula', |
|
29 | + 'huron mountains', |
|
30 | + 'keweenaw', |
|
31 | + 'michigan', |
|
32 | + 'backpacking', |
|
33 | + 'Jacob Emerick'); |
|
34 | + |
|
35 | + private static $KEYWORD_ARRAY_PERSONAL = array( |
|
36 | + 'dealerfire', |
|
37 | + 'sparknet', |
|
38 | + 'katie', |
|
39 | + 'logan', |
|
40 | + 'marriage', |
|
41 | + 'Jacob Emerick'); |
|
42 | + |
|
43 | + private static $KEYWORD_ARRAY_WEBDEVELOPMENT = array( |
|
44 | + 'best practices', |
|
45 | + 'object orientated php', |
|
46 | + 'data abstraction', |
|
47 | + 'semantic web', |
|
48 | + 'responsive design', |
|
49 | + 'responsible development', |
|
50 | + 'Jacob Emerick'); |
|
51 | + |
|
52 | + private $category; |
|
53 | + |
|
54 | + private static $LIST_DESCRIPTION = 'Viewing %d - %d of %d posts in the %s category.'; |
|
55 | + |
|
56 | + public function __construct() |
|
57 | + { |
|
58 | + $url = URLDecode::getPiece(1); |
|
59 | + $this->category = (object) array( |
|
60 | + 'display' => ucwords(str_replace('-', ' ', $url)), |
|
61 | + 'link' => $url); |
|
62 | 62 | |
63 | - parent::__construct(); |
|
64 | - } |
|
63 | + parent::__construct(); |
|
64 | + } |
|
65 | 65 | |
66 | - protected function set_head_data() |
|
67 | - { |
|
68 | - parent::set_head_data(); |
|
66 | + protected function set_head_data() |
|
67 | + { |
|
68 | + parent::set_head_data(); |
|
69 | 69 | |
70 | - switch($this->category->display) |
|
71 | - { |
|
72 | - case 'Hiking' : |
|
73 | - if($this->page == 1) |
|
74 | - { |
|
75 | - $this->set_title(self::$TITLE_MAIN_HIKING); |
|
76 | - $this->set_description(self::$DESCRIPTION_MAIN_HIKING); |
|
77 | - } |
|
78 | - else |
|
79 | - { |
|
80 | - $this->set_title(sprintf(self::$TITLE_PAGINATED_HIKING, $this->page, $this->total_pages)); |
|
81 | - $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED_HIKING, $this->page, $this->total_pages)); |
|
82 | - } |
|
83 | - $this->set_keywords(self::$KEYWORD_ARRAY_HIKING); |
|
84 | - break; |
|
85 | - case 'Personal' : |
|
86 | - if($this->page == 1) |
|
87 | - { |
|
88 | - $this->set_title(self::$TITLE_MAIN_PERSONAL); |
|
89 | - $this->set_description(self::$DESCRIPTION_MAIN_PERSONAL); |
|
90 | - } |
|
91 | - else |
|
92 | - { |
|
93 | - $this->set_title(sprintf(self::$TITLE_PAGINATED_PERSONAL, $this->page, $this->total_pages)); |
|
94 | - $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED_PERSONAL, $this->page, $this->total_pages)); |
|
95 | - } |
|
96 | - $this->set_keywords(self::$KEYWORD_ARRAY_PERSONAL); |
|
97 | - break; |
|
98 | - case 'Web Development' : |
|
99 | - if($this->page == 1) |
|
100 | - { |
|
101 | - $this->set_title(self::$TITLE_MAIN_WEBDEVELOPMENT); |
|
102 | - $this->set_description(self::$DESCRIPTION_MAIN_WEBDEVELOPMENT); |
|
103 | - } |
|
104 | - else |
|
105 | - { |
|
106 | - $this->set_title(sprintf(self::$TITLE_PAGINATED_WEBDEVELOPMENT, $this->page, $this->total_pages)); |
|
107 | - $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED_WEBDEVELOPMENT, $this->page, $this->total_pages)); |
|
108 | - } |
|
109 | - $this->set_keywords(self::$KEYWORD_ARRAY_WEBDEVELOPMENT); |
|
110 | - break; |
|
111 | - } |
|
112 | - } |
|
113 | - |
|
114 | - protected function get_introduction() |
|
115 | - { |
|
116 | - if($this->page == 1) |
|
117 | - { |
|
70 | + switch($this->category->display) |
|
71 | + { |
|
72 | + case 'Hiking' : |
|
73 | + if($this->page == 1) |
|
74 | + { |
|
75 | + $this->set_title(self::$TITLE_MAIN_HIKING); |
|
76 | + $this->set_description(self::$DESCRIPTION_MAIN_HIKING); |
|
77 | + } |
|
78 | + else |
|
79 | + { |
|
80 | + $this->set_title(sprintf(self::$TITLE_PAGINATED_HIKING, $this->page, $this->total_pages)); |
|
81 | + $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED_HIKING, $this->page, $this->total_pages)); |
|
82 | + } |
|
83 | + $this->set_keywords(self::$KEYWORD_ARRAY_HIKING); |
|
84 | + break; |
|
85 | + case 'Personal' : |
|
86 | + if($this->page == 1) |
|
87 | + { |
|
88 | + $this->set_title(self::$TITLE_MAIN_PERSONAL); |
|
89 | + $this->set_description(self::$DESCRIPTION_MAIN_PERSONAL); |
|
90 | + } |
|
91 | + else |
|
92 | + { |
|
93 | + $this->set_title(sprintf(self::$TITLE_PAGINATED_PERSONAL, $this->page, $this->total_pages)); |
|
94 | + $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED_PERSONAL, $this->page, $this->total_pages)); |
|
95 | + } |
|
96 | + $this->set_keywords(self::$KEYWORD_ARRAY_PERSONAL); |
|
97 | + break; |
|
98 | + case 'Web Development' : |
|
99 | + if($this->page == 1) |
|
100 | + { |
|
101 | + $this->set_title(self::$TITLE_MAIN_WEBDEVELOPMENT); |
|
102 | + $this->set_description(self::$DESCRIPTION_MAIN_WEBDEVELOPMENT); |
|
103 | + } |
|
104 | + else |
|
105 | + { |
|
106 | + $this->set_title(sprintf(self::$TITLE_PAGINATED_WEBDEVELOPMENT, $this->page, $this->total_pages)); |
|
107 | + $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED_WEBDEVELOPMENT, $this->page, $this->total_pages)); |
|
108 | + } |
|
109 | + $this->set_keywords(self::$KEYWORD_ARRAY_WEBDEVELOPMENT); |
|
110 | + break; |
|
111 | + } |
|
112 | + } |
|
113 | + |
|
114 | + protected function get_introduction() |
|
115 | + { |
|
116 | + if($this->page == 1) |
|
117 | + { |
|
118 | 118 | global $container; |
119 | 119 | $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
120 | 120 | $introduction_result = $repository->findByType('category', $this->category->link); |
121 | 121 | |
122 | - $introduction = array(); |
|
123 | - $introduction['title'] = $introduction_result['title']; |
|
124 | - $introduction['content'] = $introduction_result['content']; |
|
125 | - $introduction['image'] = $this->get_introduction_image($introduction_result['image']); |
|
122 | + $introduction = array(); |
|
123 | + $introduction['title'] = $introduction_result['title']; |
|
124 | + $introduction['content'] = $introduction_result['content']; |
|
125 | + $introduction['image'] = $this->get_introduction_image($introduction_result['image']); |
|
126 | 126 | |
127 | - return $introduction; |
|
128 | - } |
|
127 | + return $introduction; |
|
128 | + } |
|
129 | 129 | |
130 | - return array( |
|
131 | - 'title' => "Posts about {$this->category->display}, page {$this->page} of {$this->total_pages}."); |
|
132 | - } |
|
133 | - |
|
134 | - protected function get_page_number() |
|
135 | - { |
|
136 | - $page = URLDecode::getPiece(2); |
|
137 | - if(isset($page) && is_numeric($page)) |
|
138 | - return $page; |
|
139 | - return 1; |
|
140 | - } |
|
141 | - |
|
142 | - protected function get_list_results() |
|
143 | - { |
|
130 | + return array( |
|
131 | + 'title' => "Posts about {$this->category->display}, page {$this->page} of {$this->total_pages}."); |
|
132 | + } |
|
133 | + |
|
134 | + protected function get_page_number() |
|
135 | + { |
|
136 | + $page = URLDecode::getPiece(2); |
|
137 | + if(isset($page) && is_numeric($page)) |
|
138 | + return $page; |
|
139 | + return 1; |
|
140 | + } |
|
141 | + |
|
142 | + protected function get_list_results() |
|
143 | + { |
|
144 | 144 | global $container; |
145 | 145 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
146 | 146 | return $repository->getActivePostsByCategory($this->category->link, self::$POSTS_PER_PAGE, $this->offset); |
147 | - } |
|
147 | + } |
|
148 | 148 | |
149 | - protected function get_list_description() |
|
150 | - { |
|
151 | - $start = $this->offset + 1; |
|
152 | - $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
149 | + protected function get_list_description() |
|
150 | + { |
|
151 | + $start = $this->offset + 1; |
|
152 | + $end = min($this->offset + self::$POSTS_PER_PAGE, $this->get_total_post_count()); |
|
153 | 153 | |
154 | - return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count(), $this->category->display); |
|
155 | - } |
|
156 | - |
|
157 | - protected function get_list_next_link() |
|
158 | - { |
|
159 | - if($this->page == 1) |
|
160 | - return; |
|
161 | - if($this->page == 2) |
|
162 | - return Content::instance('URLSafe', "/{$this->category->link}/")->activate(); |
|
163 | - return Content::instance('URLSafe', "/{$this->category->link}/" . ($this->page - 1) . '/')->activate(); |
|
164 | - } |
|
165 | - |
|
166 | - protected function get_list_prev_link() |
|
167 | - { |
|
168 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
169 | - return; |
|
170 | - return Content::instance('URLSafe', "/{$this->category->link}/" . ($this->page + 1) . '/')->activate(); |
|
171 | - } |
|
172 | - |
|
173 | - private $total_post_count; |
|
174 | - protected function get_total_post_count() |
|
175 | - { |
|
176 | - if(!isset($this->total_post_count)) { |
|
154 | + return sprintf(self::$LIST_DESCRIPTION, $start, $end, $this->get_total_post_count(), $this->category->display); |
|
155 | + } |
|
156 | + |
|
157 | + protected function get_list_next_link() |
|
158 | + { |
|
159 | + if($this->page == 1) |
|
160 | + return; |
|
161 | + if($this->page == 2) |
|
162 | + return Content::instance('URLSafe', "/{$this->category->link}/")->activate(); |
|
163 | + return Content::instance('URLSafe', "/{$this->category->link}/" . ($this->page - 1) . '/')->activate(); |
|
164 | + } |
|
165 | + |
|
166 | + protected function get_list_prev_link() |
|
167 | + { |
|
168 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
169 | + return; |
|
170 | + return Content::instance('URLSafe', "/{$this->category->link}/" . ($this->page + 1) . '/')->activate(); |
|
171 | + } |
|
172 | + |
|
173 | + private $total_post_count; |
|
174 | + protected function get_total_post_count() |
|
175 | + { |
|
176 | + if(!isset($this->total_post_count)) { |
|
177 | 177 | global $container; |
178 | 178 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
179 | 179 | $this->total_post_count = $repository->getActivePostsCountByCategory($this->category->link); |
180 | 180 | } |
181 | - return $this->total_post_count; |
|
182 | - } |
|
181 | + return $this->total_post_count; |
|
182 | + } |
|
183 | 183 | |
184 | 184 | } |
@@ -5,206 +5,206 @@ |
||
5 | 5 | abstract class DefaultListController extends DefaultPageController |
6 | 6 | { |
7 | 7 | |
8 | - private static $IMAGE_ELEMENT_PATTERN = '<img src="/photo/%s/%s-size-%s.jpg" alt="%s" height="%s" width="%s" />'; |
|
9 | - |
|
10 | - protected $page; |
|
11 | - protected $page_count; |
|
12 | - protected $offset; |
|
13 | - |
|
14 | - public function __construct() |
|
15 | - { |
|
16 | - parent::__construct(); |
|
17 | - |
|
18 | - $this->page = $this->get_page_number(); |
|
19 | - $this->page_count = ceil($this->get_item_count() / $this->get_item_count_per_page()); |
|
20 | - $this->offset = ($this->page - 1) * $this->get_item_count_per_page(); |
|
21 | - |
|
22 | - $items = $this->get_items(); |
|
23 | - if(count($items) < 1) |
|
24 | - $this->eject(); |
|
25 | - } |
|
26 | - |
|
27 | - final protected function get_page_number() |
|
28 | - { |
|
29 | - $page = $this->get_page_number_piece(); |
|
30 | - if(isset($page) && is_numeric($page)) |
|
31 | - return $page; |
|
32 | - return 1; |
|
33 | - } |
|
34 | - |
|
35 | - abstract protected function get_page_number_piece(); |
|
36 | - |
|
37 | - abstract protected function get_item_count_per_page(); |
|
38 | - abstract protected function format_item($item); |
|
39 | - abstract protected function get_sidebar(); |
|
40 | - abstract protected function get_list_view(); |
|
41 | - |
|
42 | - final private function get_introduction() |
|
43 | - { |
|
44 | - if($this->page == 1) |
|
45 | - return $this->get_initial_introduction(); |
|
46 | - |
|
47 | - return $this->get_subsequent_introduction(); |
|
48 | - } |
|
49 | - |
|
50 | - abstract protected function get_initial_introduction(); |
|
51 | - abstract protected function get_subsequent_introduction(); |
|
52 | - |
|
53 | - private $items; |
|
54 | - protected function get_items() |
|
55 | - { |
|
56 | - if(!isset($this->items)) |
|
57 | - { |
|
58 | - $total = $this->get_item_count_per_page(); |
|
59 | - $offset = ($this->page - 1) * $this->get_item_count_per_page(); |
|
8 | + private static $IMAGE_ELEMENT_PATTERN = '<img src="/photo/%s/%s-size-%s.jpg" alt="%s" height="%s" width="%s" />'; |
|
9 | + |
|
10 | + protected $page; |
|
11 | + protected $page_count; |
|
12 | + protected $offset; |
|
13 | + |
|
14 | + public function __construct() |
|
15 | + { |
|
16 | + parent::__construct(); |
|
17 | + |
|
18 | + $this->page = $this->get_page_number(); |
|
19 | + $this->page_count = ceil($this->get_item_count() / $this->get_item_count_per_page()); |
|
20 | + $this->offset = ($this->page - 1) * $this->get_item_count_per_page(); |
|
21 | + |
|
22 | + $items = $this->get_items(); |
|
23 | + if(count($items) < 1) |
|
24 | + $this->eject(); |
|
25 | + } |
|
26 | + |
|
27 | + final protected function get_page_number() |
|
28 | + { |
|
29 | + $page = $this->get_page_number_piece(); |
|
30 | + if(isset($page) && is_numeric($page)) |
|
31 | + return $page; |
|
32 | + return 1; |
|
33 | + } |
|
34 | + |
|
35 | + abstract protected function get_page_number_piece(); |
|
36 | + |
|
37 | + abstract protected function get_item_count_per_page(); |
|
38 | + abstract protected function format_item($item); |
|
39 | + abstract protected function get_sidebar(); |
|
40 | + abstract protected function get_list_view(); |
|
41 | + |
|
42 | + final private function get_introduction() |
|
43 | + { |
|
44 | + if($this->page == 1) |
|
45 | + return $this->get_initial_introduction(); |
|
46 | + |
|
47 | + return $this->get_subsequent_introduction(); |
|
48 | + } |
|
49 | + |
|
50 | + abstract protected function get_initial_introduction(); |
|
51 | + abstract protected function get_subsequent_introduction(); |
|
52 | + |
|
53 | + private $items; |
|
54 | + protected function get_items() |
|
55 | + { |
|
56 | + if(!isset($this->items)) |
|
57 | + { |
|
58 | + $total = $this->get_item_count_per_page(); |
|
59 | + $offset = ($this->page - 1) * $this->get_item_count_per_page(); |
|
60 | 60 | |
61 | - $this->items = $this->get_item_result($total, $offset); |
|
62 | - } |
|
63 | - return $this->items; |
|
64 | - } |
|
61 | + $this->items = $this->get_item_result($total, $offset); |
|
62 | + } |
|
63 | + return $this->items; |
|
64 | + } |
|
65 | 65 | |
66 | - abstract protected function get_item_result($total, $offset); |
|
66 | + abstract protected function get_item_result($total, $offset); |
|
67 | 67 | |
68 | - private $item_count; |
|
69 | - final private function get_item_count() |
|
70 | - { |
|
71 | - if(!isset($this->item_count)) |
|
72 | - $this->item_count = $this->get_item_count_result(); |
|
73 | - return $this->item_count; |
|
74 | - } |
|
68 | + private $item_count; |
|
69 | + final private function get_item_count() |
|
70 | + { |
|
71 | + if(!isset($this->item_count)) |
|
72 | + $this->item_count = $this->get_item_count_result(); |
|
73 | + return $this->item_count; |
|
74 | + } |
|
75 | 75 | |
76 | - abstract protected function get_item_count_result(); |
|
76 | + abstract protected function get_item_count_result(); |
|
77 | 77 | |
78 | - final protected function set_head_data() |
|
79 | - { |
|
80 | - parent::set_head_data(); |
|
78 | + final protected function set_head_data() |
|
79 | + { |
|
80 | + parent::set_head_data(); |
|
81 | 81 | |
82 | - $this->set_head('next_link', $this->get_list_next_link()); |
|
83 | - $this->set_head('previous_link', $this->get_list_prev_link()); |
|
82 | + $this->set_head('next_link', $this->get_list_next_link()); |
|
83 | + $this->set_head('previous_link', $this->get_list_prev_link()); |
|
84 | 84 | |
85 | - if($this->page == 1) |
|
86 | - $meta_array = $this->get_initial_meta(); |
|
87 | - else |
|
88 | - $meta_array = $this->get_subsequent_meta(); |
|
85 | + if($this->page == 1) |
|
86 | + $meta_array = $this->get_initial_meta(); |
|
87 | + else |
|
88 | + $meta_array = $this->get_subsequent_meta(); |
|
89 | 89 | |
90 | - $this->set_title($meta_array['title']); |
|
91 | - $this->set_description($meta_array['description']); |
|
92 | - $this->set_keywords($meta_array['keywords']); |
|
93 | - } |
|
90 | + $this->set_title($meta_array['title']); |
|
91 | + $this->set_description($meta_array['description']); |
|
92 | + $this->set_keywords($meta_array['keywords']); |
|
93 | + } |
|
94 | 94 | |
95 | - abstract protected function get_initial_meta(); |
|
96 | - abstract protected function get_subsequent_meta(); |
|
95 | + abstract protected function get_initial_meta(); |
|
96 | + abstract protected function get_subsequent_meta(); |
|
97 | 97 | |
98 | 98 | final protected function set_body_data($page_type = 'normal') |
99 | 99 | { |
100 | 100 | parent::set_body_data($page_type); |
101 | 101 | |
102 | - $this->set_body('view', $this->get_list_view()); |
|
103 | - $this->set_body('data', $this->get_list_body_data()); |
|
104 | - } |
|
102 | + $this->set_body('view', $this->get_list_view()); |
|
103 | + $this->set_body('data', $this->get_list_body_data()); |
|
104 | + } |
|
105 | 105 | |
106 | - final private function get_list_body_data() |
|
107 | - { |
|
108 | - $body_data_array = array(); |
|
106 | + final private function get_list_body_data() |
|
107 | + { |
|
108 | + $body_data_array = array(); |
|
109 | 109 | |
110 | 110 | $body_data_array['introduction'] = $this->get_introduction(); |
111 | - $body_data_array['items'] = array_map(array($this, 'format_item'), $this->get_items()); |
|
112 | - $body_data_array['navigation'] = array( |
|
113 | - 'description' => $this->get_list_description(), |
|
114 | - 'list' => $this->get_list_link_array()); |
|
115 | - $body_data_array['sidebar'] = $this->get_sidebar(); |
|
116 | - |
|
117 | - return $body_data_array; |
|
118 | - } |
|
119 | - |
|
120 | - final private function get_list_prev_link() |
|
121 | - { |
|
122 | - if($this->page == 1) |
|
123 | - return; |
|
124 | - if($this->page == 2) |
|
125 | - return $this->get_list_link_root(); |
|
126 | - return $this->get_list_link_root() . ($this->page - 1) . '/'; |
|
127 | - } |
|
128 | - |
|
129 | - final private function get_list_next_link() |
|
130 | - { |
|
131 | - if(($this->page * $this->get_item_count_per_page()) >= $this->get_item_count()) |
|
132 | - return; |
|
133 | - return $this->get_list_link_root() . ($this->page + 1) . '/'; |
|
134 | - } |
|
135 | - |
|
136 | - abstract protected function get_list_link_root(); |
|
137 | - |
|
138 | - final private function get_list_link_array() |
|
139 | - { |
|
140 | - $link_array = array(); |
|
141 | - |
|
142 | - if($this->get_item_count_per_page() >= $this->get_item_count()) |
|
143 | - return $link_array; |
|
144 | - |
|
145 | - $link = new stdclass(); |
|
146 | - $link->anchor = '« previous'; |
|
147 | - if($this->get_list_prev_link() !== null) |
|
148 | - $link->uri = $this->get_list_prev_link(); |
|
149 | - else |
|
150 | - $link->class = 'inactive'; |
|
151 | - $link_array[] = $link; |
|
152 | - |
|
153 | - for($i = 1; $i <= ceil($this->get_item_count() / $this->get_item_count_per_page()); $i++) |
|
154 | - { |
|
155 | - $link = new stdclass(); |
|
156 | - $link->anchor = $i; |
|
111 | + $body_data_array['items'] = array_map(array($this, 'format_item'), $this->get_items()); |
|
112 | + $body_data_array['navigation'] = array( |
|
113 | + 'description' => $this->get_list_description(), |
|
114 | + 'list' => $this->get_list_link_array()); |
|
115 | + $body_data_array['sidebar'] = $this->get_sidebar(); |
|
116 | + |
|
117 | + return $body_data_array; |
|
118 | + } |
|
119 | + |
|
120 | + final private function get_list_prev_link() |
|
121 | + { |
|
122 | + if($this->page == 1) |
|
123 | + return; |
|
124 | + if($this->page == 2) |
|
125 | + return $this->get_list_link_root(); |
|
126 | + return $this->get_list_link_root() . ($this->page - 1) . '/'; |
|
127 | + } |
|
128 | + |
|
129 | + final private function get_list_next_link() |
|
130 | + { |
|
131 | + if(($this->page * $this->get_item_count_per_page()) >= $this->get_item_count()) |
|
132 | + return; |
|
133 | + return $this->get_list_link_root() . ($this->page + 1) . '/'; |
|
134 | + } |
|
135 | + |
|
136 | + abstract protected function get_list_link_root(); |
|
137 | + |
|
138 | + final private function get_list_link_array() |
|
139 | + { |
|
140 | + $link_array = array(); |
|
141 | + |
|
142 | + if($this->get_item_count_per_page() >= $this->get_item_count()) |
|
143 | + return $link_array; |
|
144 | + |
|
145 | + $link = new stdclass(); |
|
146 | + $link->anchor = '« previous'; |
|
147 | + if($this->get_list_prev_link() !== null) |
|
148 | + $link->uri = $this->get_list_prev_link(); |
|
149 | + else |
|
150 | + $link->class = 'inactive'; |
|
151 | + $link_array[] = $link; |
|
152 | + |
|
153 | + for($i = 1; $i <= ceil($this->get_item_count() / $this->get_item_count_per_page()); $i++) |
|
154 | + { |
|
155 | + $link = new stdclass(); |
|
156 | + $link->anchor = $i; |
|
157 | 157 | |
158 | - if($i == $this->page) |
|
159 | - $link->class = 'current'; |
|
160 | - else |
|
161 | - { |
|
162 | - if($i == 1) |
|
163 | - $link->uri = $this->get_list_link_root(); |
|
164 | - else |
|
165 | - $link->uri = $this->get_list_link_root() . $i . '/'; |
|
166 | - } |
|
158 | + if($i == $this->page) |
|
159 | + $link->class = 'current'; |
|
160 | + else |
|
161 | + { |
|
162 | + if($i == 1) |
|
163 | + $link->uri = $this->get_list_link_root(); |
|
164 | + else |
|
165 | + $link->uri = $this->get_list_link_root() . $i . '/'; |
|
166 | + } |
|
167 | 167 | |
168 | - $link_array[] = $link; |
|
169 | - } |
|
170 | - |
|
171 | - $link = new stdclass(); |
|
172 | - $link->anchor = 'next »'; |
|
173 | - if($this->get_list_next_link() !== null) |
|
174 | - $link->uri = $this->get_list_next_link(); |
|
175 | - else |
|
176 | - $link->class = 'inactive'; |
|
177 | - $link_array[] = $link; |
|
178 | - |
|
179 | - return $link_array; |
|
180 | - } |
|
181 | - |
|
182 | - final private function get_list_description() |
|
183 | - { |
|
184 | - $start = ($this->page - 1) * $this->get_item_count_per_page() + 1; |
|
185 | - $end = min($this->page * $this->get_item_count_per_page(), $this->get_item_count()); |
|
186 | - $total = $this->get_item_count(); |
|
187 | - |
|
188 | - return sprintf($this->get_list_description_pattern(), $start, $end, $total); |
|
189 | - } |
|
190 | - |
|
191 | - abstract protected function get_list_description_pattern(); |
|
192 | - |
|
193 | - final protected function get_image_element($category, $path, $description, $size = 'small') |
|
194 | - { |
|
195 | - switch($size) |
|
196 | - { |
|
197 | - case 'medium' : |
|
198 | - $height = 375; |
|
199 | - $width = 500; |
|
200 | - break; |
|
201 | - case 'small' : |
|
202 | - $height = 180; |
|
203 | - $width = 240; |
|
204 | - break; |
|
205 | - } |
|
206 | - |
|
207 | - return sprintf(self::$IMAGE_ELEMENT_PATTERN, $category, $path, $size, $description, $height, $width); |
|
208 | - } |
|
168 | + $link_array[] = $link; |
|
169 | + } |
|
170 | + |
|
171 | + $link = new stdclass(); |
|
172 | + $link->anchor = 'next »'; |
|
173 | + if($this->get_list_next_link() !== null) |
|
174 | + $link->uri = $this->get_list_next_link(); |
|
175 | + else |
|
176 | + $link->class = 'inactive'; |
|
177 | + $link_array[] = $link; |
|
178 | + |
|
179 | + return $link_array; |
|
180 | + } |
|
181 | + |
|
182 | + final private function get_list_description() |
|
183 | + { |
|
184 | + $start = ($this->page - 1) * $this->get_item_count_per_page() + 1; |
|
185 | + $end = min($this->page * $this->get_item_count_per_page(), $this->get_item_count()); |
|
186 | + $total = $this->get_item_count(); |
|
187 | + |
|
188 | + return sprintf($this->get_list_description_pattern(), $start, $end, $total); |
|
189 | + } |
|
190 | + |
|
191 | + abstract protected function get_list_description_pattern(); |
|
192 | + |
|
193 | + final protected function get_image_element($category, $path, $description, $size = 'small') |
|
194 | + { |
|
195 | + switch($size) |
|
196 | + { |
|
197 | + case 'medium' : |
|
198 | + $height = 375; |
|
199 | + $width = 500; |
|
200 | + break; |
|
201 | + case 'small' : |
|
202 | + $height = 180; |
|
203 | + $width = 240; |
|
204 | + break; |
|
205 | + } |
|
206 | + |
|
207 | + return sprintf(self::$IMAGE_ELEMENT_PATTERN, $category, $path, $size, $description, $height, $width); |
|
208 | + } |
|
209 | 209 | |
210 | 210 | } |
211 | 211 | \ No newline at end of file |
@@ -6,104 +6,104 @@ |
||
6 | 6 | final class PeriodListController extends DefaultLogListController |
7 | 7 | { |
8 | 8 | |
9 | - private static $DEFAULT_TITLE = '%s Hiking Stories, Page %d of %d'; |
|
10 | - private static $DEFAULT_DESCRIPTION = 'Page %d of %d of epic %s hiking stories written by Jacob Emerick, all about his adventures hunting waterfalls in the Upper Peninsula of Michigan'; |
|
11 | - private static $DEFAULT_HEADER = 'Page %d of Awesome %s Waterfall Hiking Stories'; |
|
9 | + private static $DEFAULT_TITLE = '%s Hiking Stories, Page %d of %d'; |
|
10 | + private static $DEFAULT_DESCRIPTION = 'Page %d of %d of epic %s hiking stories written by Jacob Emerick, all about his adventures hunting waterfalls in the Upper Peninsula of Michigan'; |
|
11 | + private static $DEFAULT_HEADER = 'Page %d of Awesome %s Waterfall Hiking Stories'; |
|
12 | 12 | |
13 | - private static $KEYWORD_ARRAY = array( |
|
14 | - 'journal', |
|
15 | - 'stories', |
|
16 | - 'blog', |
|
17 | - 'waterfalls'); |
|
13 | + private static $KEYWORD_ARRAY = array( |
|
14 | + 'journal', |
|
15 | + 'stories', |
|
16 | + 'blog', |
|
17 | + 'waterfalls'); |
|
18 | 18 | |
19 | - private static $NAVIGATION_DESCRIPTION = 'displaying %d ~ %d of %d %PERIOD% journal entries'; |
|
20 | - private static $LINK_ROOT = '/period/%s/'; |
|
19 | + private static $NAVIGATION_DESCRIPTION = 'displaying %d ~ %d of %d %PERIOD% journal entries'; |
|
20 | + private static $LINK_ROOT = '/period/%s/'; |
|
21 | 21 | |
22 | - private $period; |
|
22 | + private $period; |
|
23 | 23 | |
24 | - public function __construct() |
|
25 | - { |
|
26 | - $alias = URLDecode::getPiece(2); |
|
27 | - $this->period = PeriodCollector::getByAlias($alias); |
|
24 | + public function __construct() |
|
25 | + { |
|
26 | + $alias = URLDecode::getPiece(2); |
|
27 | + $this->period = PeriodCollector::getByAlias($alias); |
|
28 | 28 | |
29 | - if(!$this->period) |
|
30 | - $this->eject(); |
|
29 | + if(!$this->period) |
|
30 | + $this->eject(); |
|
31 | 31 | |
32 | - parent::__construct(); |
|
33 | - } |
|
32 | + parent::__construct(); |
|
33 | + } |
|
34 | 34 | |
35 | - protected function get_initial_meta() |
|
36 | - { |
|
37 | - $meta_array = array(); |
|
35 | + protected function get_initial_meta() |
|
36 | + { |
|
37 | + $meta_array = array(); |
|
38 | 38 | |
39 | - $meta_array['title'] = "Hiking Stories - {$this->period->name} | " . self::$WEBSITE_TITLE; |
|
40 | - $meta_array['description'] = $this->period->description; |
|
41 | - $meta_array['keywords'] = $this->get_keyword_array(); |
|
39 | + $meta_array['title'] = "Hiking Stories - {$this->period->name} | " . self::$WEBSITE_TITLE; |
|
40 | + $meta_array['description'] = $this->period->description; |
|
41 | + $meta_array['keywords'] = $this->get_keyword_array(); |
|
42 | 42 | |
43 | - return $meta_array; |
|
44 | - } |
|
43 | + return $meta_array; |
|
44 | + } |
|
45 | 45 | |
46 | - protected function get_subsequent_meta() |
|
47 | - { |
|
48 | - $meta_array = array(); |
|
46 | + protected function get_subsequent_meta() |
|
47 | + { |
|
48 | + $meta_array = array(); |
|
49 | 49 | |
50 | - $meta_array['title'] = sprintf(self::$DEFAULT_TITLE . ' | ' . self::$WEBSITE_TITLE, $this->period->name, $this->page, $this->page_count); |
|
51 | - $meta_array['description'] = sprintf(self::$DEFAULT_DESCRIPTION, $this->page, $this->page_count, $this->period->name); |
|
52 | - $meta_array['keywords'] = $this->get_keyword_array(); |
|
50 | + $meta_array['title'] = sprintf(self::$DEFAULT_TITLE . ' | ' . self::$WEBSITE_TITLE, $this->period->name, $this->page, $this->page_count); |
|
51 | + $meta_array['description'] = sprintf(self::$DEFAULT_DESCRIPTION, $this->page, $this->page_count, $this->period->name); |
|
52 | + $meta_array['keywords'] = $this->get_keyword_array(); |
|
53 | 53 | |
54 | - return $meta_array; |
|
55 | - } |
|
56 | - |
|
57 | - private function get_keyword_array() |
|
58 | - { |
|
59 | - $keyword_array = self::$KEYWORD_ARRAY; |
|
60 | - array_unshift($keyword_array, strtolower($this->period->name)); |
|
61 | - return $keyword_array; |
|
62 | - } |
|
63 | - |
|
64 | - protected function get_initial_introduction() |
|
65 | - { |
|
66 | - $introduction = array(); |
|
54 | + return $meta_array; |
|
55 | + } |
|
56 | + |
|
57 | + private function get_keyword_array() |
|
58 | + { |
|
59 | + $keyword_array = self::$KEYWORD_ARRAY; |
|
60 | + array_unshift($keyword_array, strtolower($this->period->name)); |
|
61 | + return $keyword_array; |
|
62 | + } |
|
63 | + |
|
64 | + protected function get_initial_introduction() |
|
65 | + { |
|
66 | + $introduction = array(); |
|
67 | 67 | |
68 | - $introduction['title'] = $this->period->title; |
|
69 | - $introduction['description'] = Content::instance('FixInternalLink', $this->period->introduction)->activate(); |
|
70 | - $introduction['image'] = $this->get_image_element($this->period->photo_category, $this->period->photo, $this->period->photo_description, 'medium'); |
|
68 | + $introduction['title'] = $this->period->title; |
|
69 | + $introduction['description'] = Content::instance('FixInternalLink', $this->period->introduction)->activate(); |
|
70 | + $introduction['image'] = $this->get_image_element($this->period->photo_category, $this->period->photo, $this->period->photo_description, 'medium'); |
|
71 | 71 | |
72 | - return $introduction; |
|
73 | - } |
|
74 | - |
|
75 | - protected function get_subsequent_introduction() |
|
76 | - { |
|
77 | - return array( |
|
78 | - 'title' => sprintf(self::$DEFAULT_HEADER, $this->page, $this->period->name)); |
|
79 | - } |
|
80 | - |
|
81 | - protected function get_page_number_piece() |
|
82 | - { |
|
83 | - return URLDecode::getPiece(3); |
|
84 | - } |
|
85 | - |
|
86 | - protected function get_item_result($total, $offset) |
|
87 | - { |
|
88 | - return PeriodCollector::getLogListForPeriod($this->period->id, $total, $offset); |
|
89 | - } |
|
90 | - |
|
91 | - protected function get_item_count_result() |
|
92 | - { |
|
93 | - return PeriodCollector::getLogCountForPeriod($this->period->id); |
|
94 | - } |
|
95 | - |
|
96 | - protected function get_list_description_pattern() |
|
97 | - { |
|
98 | - $period = $this->period->name; |
|
99 | - $period = strtolower($period); |
|
100 | - $navigation_description = str_replace('%PERIOD%', $period, self::$NAVIGATION_DESCRIPTION); |
|
101 | - return $navigation_description; |
|
102 | - } |
|
103 | - |
|
104 | - protected function get_list_link_root() |
|
105 | - { |
|
106 | - return sprintf(self::$LINK_ROOT, $this->period->alias); |
|
107 | - } |
|
72 | + return $introduction; |
|
73 | + } |
|
74 | + |
|
75 | + protected function get_subsequent_introduction() |
|
76 | + { |
|
77 | + return array( |
|
78 | + 'title' => sprintf(self::$DEFAULT_HEADER, $this->page, $this->period->name)); |
|
79 | + } |
|
80 | + |
|
81 | + protected function get_page_number_piece() |
|
82 | + { |
|
83 | + return URLDecode::getPiece(3); |
|
84 | + } |
|
85 | + |
|
86 | + protected function get_item_result($total, $offset) |
|
87 | + { |
|
88 | + return PeriodCollector::getLogListForPeriod($this->period->id, $total, $offset); |
|
89 | + } |
|
90 | + |
|
91 | + protected function get_item_count_result() |
|
92 | + { |
|
93 | + return PeriodCollector::getLogCountForPeriod($this->period->id); |
|
94 | + } |
|
95 | + |
|
96 | + protected function get_list_description_pattern() |
|
97 | + { |
|
98 | + $period = $this->period->name; |
|
99 | + $period = strtolower($period); |
|
100 | + $navigation_description = str_replace('%PERIOD%', $period, self::$NAVIGATION_DESCRIPTION); |
|
101 | + return $navigation_description; |
|
102 | + } |
|
103 | + |
|
104 | + protected function get_list_link_root() |
|
105 | + { |
|
106 | + return sprintf(self::$LINK_ROOT, $this->period->alias); |
|
107 | + } |
|
108 | 108 | |
109 | 109 | } |
110 | 110 | \ No newline at end of file |
@@ -6,102 +6,102 @@ |
||
6 | 6 | final class CompanionListController extends DefaultLogListController |
7 | 7 | { |
8 | 8 | |
9 | - private static $DEFAULT_TITLE = 'Hiking with %s, Page %d of %d'; |
|
10 | - private static $DEFAULT_DESCRIPTION = 'Page %d of %d of legendary hiking stories with %s written by Jacob Emerick, all about his adventures hunting waterfalls in the Upper Peninsula of Michigan'; |
|
11 | - private static $DEFAULT_HEADER = 'Page %d of Legendary Hiking Stories with %s'; |
|
12 | - |
|
13 | - private static $KEYWORD_ARRAY = array( |
|
14 | - 'hiking companions', |
|
15 | - 'journal', |
|
16 | - 'stories', |
|
17 | - 'blog', |
|
18 | - 'waterfalls'); |
|
19 | - |
|
20 | - private static $NAVIGATION_DESCRIPTION = 'displaying %d ~ %d of %d journal entries with %COMPANION%'; |
|
21 | - private static $LINK_ROOT = '/companion/%s/'; |
|
22 | - |
|
23 | - private $companion; |
|
24 | - |
|
25 | - public function __construct() |
|
26 | - { |
|
27 | - $alias = URLDecode::getPiece(2); |
|
28 | - $this->companion = CompanionCollector::getByAlias($alias); |
|
9 | + private static $DEFAULT_TITLE = 'Hiking with %s, Page %d of %d'; |
|
10 | + private static $DEFAULT_DESCRIPTION = 'Page %d of %d of legendary hiking stories with %s written by Jacob Emerick, all about his adventures hunting waterfalls in the Upper Peninsula of Michigan'; |
|
11 | + private static $DEFAULT_HEADER = 'Page %d of Legendary Hiking Stories with %s'; |
|
12 | + |
|
13 | + private static $KEYWORD_ARRAY = array( |
|
14 | + 'hiking companions', |
|
15 | + 'journal', |
|
16 | + 'stories', |
|
17 | + 'blog', |
|
18 | + 'waterfalls'); |
|
19 | + |
|
20 | + private static $NAVIGATION_DESCRIPTION = 'displaying %d ~ %d of %d journal entries with %COMPANION%'; |
|
21 | + private static $LINK_ROOT = '/companion/%s/'; |
|
22 | + |
|
23 | + private $companion; |
|
24 | + |
|
25 | + public function __construct() |
|
26 | + { |
|
27 | + $alias = URLDecode::getPiece(2); |
|
28 | + $this->companion = CompanionCollector::getByAlias($alias); |
|
29 | 29 | |
30 | - if(!$this->companion) |
|
31 | - $this->eject(); |
|
30 | + if(!$this->companion) |
|
31 | + $this->eject(); |
|
32 | 32 | |
33 | - parent::__construct(); |
|
34 | - } |
|
33 | + parent::__construct(); |
|
34 | + } |
|
35 | 35 | |
36 | - protected function get_initial_meta() |
|
37 | - { |
|
38 | - $meta_array = array(); |
|
36 | + protected function get_initial_meta() |
|
37 | + { |
|
38 | + $meta_array = array(); |
|
39 | 39 | |
40 | - $meta_array['title'] = "Hiking Stories with {$this->companion->name} | " . self::$WEBSITE_TITLE; |
|
41 | - $meta_array['description'] = $this->companion->description; |
|
42 | - $meta_array['keywords'] = $this->get_keyword_array(); |
|
40 | + $meta_array['title'] = "Hiking Stories with {$this->companion->name} | " . self::$WEBSITE_TITLE; |
|
41 | + $meta_array['description'] = $this->companion->description; |
|
42 | + $meta_array['keywords'] = $this->get_keyword_array(); |
|
43 | 43 | |
44 | - return $meta_array; |
|
45 | - } |
|
44 | + return $meta_array; |
|
45 | + } |
|
46 | 46 | |
47 | - protected function get_subsequent_meta() |
|
48 | - { |
|
49 | - $meta_array = array(); |
|
47 | + protected function get_subsequent_meta() |
|
48 | + { |
|
49 | + $meta_array = array(); |
|
50 | 50 | |
51 | - $meta_array['title'] = sprintf(self::$DEFAULT_TITLE . ' | ' . self::$WEBSITE_TITLE, $this->companion->name, $this->page, $this->page_count); |
|
52 | - $meta_array['description'] = sprintf(self::$DEFAULT_DESCRIPTION, $this->page, $this->page_count, $this->companion->name); |
|
53 | - $meta_array['keywords'] = $this->get_keyword_array(); |
|
51 | + $meta_array['title'] = sprintf(self::$DEFAULT_TITLE . ' | ' . self::$WEBSITE_TITLE, $this->companion->name, $this->page, $this->page_count); |
|
52 | + $meta_array['description'] = sprintf(self::$DEFAULT_DESCRIPTION, $this->page, $this->page_count, $this->companion->name); |
|
53 | + $meta_array['keywords'] = $this->get_keyword_array(); |
|
54 | 54 | |
55 | - return $meta_array; |
|
56 | - } |
|
57 | - |
|
58 | - private function get_keyword_array() |
|
59 | - { |
|
60 | - $keyword_array = self::$KEYWORD_ARRAY; |
|
61 | - array_unshift($keyword_array, strtolower($this->companion->name)); |
|
62 | - return $keyword_array; |
|
63 | - } |
|
64 | - |
|
65 | - protected function get_initial_introduction() |
|
66 | - { |
|
67 | - $introduction = array(); |
|
55 | + return $meta_array; |
|
56 | + } |
|
57 | + |
|
58 | + private function get_keyword_array() |
|
59 | + { |
|
60 | + $keyword_array = self::$KEYWORD_ARRAY; |
|
61 | + array_unshift($keyword_array, strtolower($this->companion->name)); |
|
62 | + return $keyword_array; |
|
63 | + } |
|
64 | + |
|
65 | + protected function get_initial_introduction() |
|
66 | + { |
|
67 | + $introduction = array(); |
|
68 | 68 | |
69 | - $introduction['title'] = $this->companion->title; |
|
70 | - $introduction['description'] = Content::instance('FixInternalLink', $this->companion->introduction)->activate(); |
|
71 | - $introduction['image'] = $this->get_image_element($this->companion->photo_category, $this->companion->photo, $this->companion->photo_description, 'medium'); |
|
69 | + $introduction['title'] = $this->companion->title; |
|
70 | + $introduction['description'] = Content::instance('FixInternalLink', $this->companion->introduction)->activate(); |
|
71 | + $introduction['image'] = $this->get_image_element($this->companion->photo_category, $this->companion->photo, $this->companion->photo_description, 'medium'); |
|
72 | 72 | |
73 | - return $introduction; |
|
74 | - } |
|
75 | - |
|
76 | - protected function get_subsequent_introduction() |
|
77 | - { |
|
78 | - return array( |
|
79 | - 'title' => sprintf(self::$DEFAULT_HEADER, $this->page, $this->companion->name)); |
|
80 | - } |
|
81 | - |
|
82 | - protected function get_page_number_piece() |
|
83 | - { |
|
84 | - return URLDecode::getPiece(3); |
|
85 | - } |
|
86 | - |
|
87 | - protected function get_item_result($total, $offset) |
|
88 | - { |
|
89 | - return CompanionCollector::getLogListForCompanion($this->companion->id, $total, $offset); |
|
90 | - } |
|
91 | - |
|
92 | - protected function get_item_count_result() |
|
93 | - { |
|
94 | - return CompanionCollector::getLogCountForCompanion($this->companion->id); |
|
95 | - } |
|
96 | - |
|
97 | - protected function get_list_description_pattern() |
|
98 | - { |
|
99 | - return str_replace('%COMPANION%', $this->companion->name, self::$NAVIGATION_DESCRIPTION); |
|
100 | - } |
|
101 | - |
|
102 | - protected function get_list_link_root() |
|
103 | - { |
|
104 | - return sprintf(self::$LINK_ROOT, $this->companion->alias); |
|
105 | - } |
|
73 | + return $introduction; |
|
74 | + } |
|
75 | + |
|
76 | + protected function get_subsequent_introduction() |
|
77 | + { |
|
78 | + return array( |
|
79 | + 'title' => sprintf(self::$DEFAULT_HEADER, $this->page, $this->companion->name)); |
|
80 | + } |
|
81 | + |
|
82 | + protected function get_page_number_piece() |
|
83 | + { |
|
84 | + return URLDecode::getPiece(3); |
|
85 | + } |
|
86 | + |
|
87 | + protected function get_item_result($total, $offset) |
|
88 | + { |
|
89 | + return CompanionCollector::getLogListForCompanion($this->companion->id, $total, $offset); |
|
90 | + } |
|
91 | + |
|
92 | + protected function get_item_count_result() |
|
93 | + { |
|
94 | + return CompanionCollector::getLogCountForCompanion($this->companion->id); |
|
95 | + } |
|
96 | + |
|
97 | + protected function get_list_description_pattern() |
|
98 | + { |
|
99 | + return str_replace('%COMPANION%', $this->companion->name, self::$NAVIGATION_DESCRIPTION); |
|
100 | + } |
|
101 | + |
|
102 | + protected function get_list_link_root() |
|
103 | + { |
|
104 | + return sprintf(self::$LINK_ROOT, $this->companion->alias); |
|
105 | + } |
|
106 | 106 | |
107 | 107 | } |
108 | 108 | \ No newline at end of file |
@@ -1,97 +1,97 @@ |
||
1 | 1 | <? |
2 | 2 | |
3 | 3 | Loader::load('collector', array( |
4 | - 'image/PhotoCollector', |
|
5 | - 'waterfall/LogCollector')); |
|
4 | + 'image/PhotoCollector', |
|
5 | + 'waterfall/LogCollector')); |
|
6 | 6 | Loader::load('controller', 'waterfalls/DefaultLogListController'); |
7 | 7 | |
8 | 8 | final class LogListController extends DefaultLogListController |
9 | 9 | { |
10 | 10 | |
11 | - private static $PRIMARY_TITLE = 'Journal from Waterfall Hikes'; |
|
12 | - private static $PRIMARY_DESCRIPTION = 'Stories written by Jacob Emerick about his epic waterfall adventures in the general Keweenaw, Ontonagon, and Marquette areas.'; |
|
13 | - private static $PRIMARY_INTRODUCTION_HEADER = 'Journal of Waterfall Adventuring'; |
|
14 | - private static $PRIMARY_INTRODUCTION_IMAGE = 707; |
|
15 | - private static $PRIMARY_INTRODUCTION_DESCRIPTION = 'Whether he is hiking alone through the woods, with Logan running ahead to chase down deer, or with a group of friends, every hike that Jacob sets out turns into an adventure. Hopping from slick rock to rock along a small creek in the city, splashing through deep water over an uncertain riverbed, or pushing thick branches out of the way in thick brush, every journey turns into a little story of discovery.'; |
|
16 | - |
|
17 | - private static $SECONDARY_TITLE = 'Journal Entries - Page %d'; |
|
18 | - private static $SECONDARY_DESCRIPTION = 'Page %d of %d of epic hiking stories written by Jacob Emerick, all about his adventures hunting waterfalls in the Upper Peninsula of Michigan'; |
|
19 | - private static $SECONDARY_INTRODUCTION_HEADER = 'Waterfall Adventure Journal, Page %d of %d'; |
|
20 | - |
|
21 | - private static $KEYWORD_ARRAY = array( |
|
22 | - 'journal', |
|
23 | - 'travel log', |
|
24 | - 'blog', |
|
25 | - 'waterfalls', |
|
26 | - 'hiking companions'); |
|
27 | - |
|
28 | - private static $NAVIGATION_DESCRIPTION = 'displaying %d ~ %d of %d total journal entries'; |
|
29 | - private static $LINK_ROOT = '/journal/'; |
|
30 | - |
|
31 | - protected function get_initial_meta() |
|
32 | - { |
|
33 | - $meta_array = array(); |
|
11 | + private static $PRIMARY_TITLE = 'Journal from Waterfall Hikes'; |
|
12 | + private static $PRIMARY_DESCRIPTION = 'Stories written by Jacob Emerick about his epic waterfall adventures in the general Keweenaw, Ontonagon, and Marquette areas.'; |
|
13 | + private static $PRIMARY_INTRODUCTION_HEADER = 'Journal of Waterfall Adventuring'; |
|
14 | + private static $PRIMARY_INTRODUCTION_IMAGE = 707; |
|
15 | + private static $PRIMARY_INTRODUCTION_DESCRIPTION = 'Whether he is hiking alone through the woods, with Logan running ahead to chase down deer, or with a group of friends, every hike that Jacob sets out turns into an adventure. Hopping from slick rock to rock along a small creek in the city, splashing through deep water over an uncertain riverbed, or pushing thick branches out of the way in thick brush, every journey turns into a little story of discovery.'; |
|
16 | + |
|
17 | + private static $SECONDARY_TITLE = 'Journal Entries - Page %d'; |
|
18 | + private static $SECONDARY_DESCRIPTION = 'Page %d of %d of epic hiking stories written by Jacob Emerick, all about his adventures hunting waterfalls in the Upper Peninsula of Michigan'; |
|
19 | + private static $SECONDARY_INTRODUCTION_HEADER = 'Waterfall Adventure Journal, Page %d of %d'; |
|
20 | + |
|
21 | + private static $KEYWORD_ARRAY = array( |
|
22 | + 'journal', |
|
23 | + 'travel log', |
|
24 | + 'blog', |
|
25 | + 'waterfalls', |
|
26 | + 'hiking companions'); |
|
27 | + |
|
28 | + private static $NAVIGATION_DESCRIPTION = 'displaying %d ~ %d of %d total journal entries'; |
|
29 | + private static $LINK_ROOT = '/journal/'; |
|
30 | + |
|
31 | + protected function get_initial_meta() |
|
32 | + { |
|
33 | + $meta_array = array(); |
|
34 | 34 | |
35 | - $meta_array['title'] = self::$PRIMARY_TITLE . ' | ' . self::$WEBSITE_TITLE; |
|
36 | - $meta_array['description'] = self::$PRIMARY_DESCRIPTION; |
|
37 | - $meta_array['keywords'] = self::$KEYWORD_ARRAY; |
|
35 | + $meta_array['title'] = self::$PRIMARY_TITLE . ' | ' . self::$WEBSITE_TITLE; |
|
36 | + $meta_array['description'] = self::$PRIMARY_DESCRIPTION; |
|
37 | + $meta_array['keywords'] = self::$KEYWORD_ARRAY; |
|
38 | 38 | |
39 | - return $meta_array; |
|
40 | - } |
|
39 | + return $meta_array; |
|
40 | + } |
|
41 | 41 | |
42 | - protected function get_subsequent_meta() |
|
43 | - { |
|
44 | - $meta_array = array(); |
|
42 | + protected function get_subsequent_meta() |
|
43 | + { |
|
44 | + $meta_array = array(); |
|
45 | 45 | |
46 | - $meta_array['title'] = sprintf(self::$SECONDARY_TITLE . ' | ' . self::$WEBSITE_TITLE, $this->page); |
|
47 | - $meta_array['description'] = sprintf(self::$SECONDARY_DESCRIPTION, $this->page, $this->page_count); |
|
48 | - $meta_array['keywords'] = self::$KEYWORD_ARRAY; |
|
46 | + $meta_array['title'] = sprintf(self::$SECONDARY_TITLE . ' | ' . self::$WEBSITE_TITLE, $this->page); |
|
47 | + $meta_array['description'] = sprintf(self::$SECONDARY_DESCRIPTION, $this->page, $this->page_count); |
|
48 | + $meta_array['keywords'] = self::$KEYWORD_ARRAY; |
|
49 | 49 | |
50 | - return $meta_array; |
|
51 | - } |
|
50 | + return $meta_array; |
|
51 | + } |
|
52 | 52 | |
53 | - protected function get_initial_introduction() |
|
54 | - { |
|
55 | - $introduction = array(); |
|
53 | + protected function get_initial_introduction() |
|
54 | + { |
|
55 | + $introduction = array(); |
|
56 | 56 | |
57 | - $introduction['title'] = self::$PRIMARY_INTRODUCTION_HEADER; |
|
58 | - $introduction['description'] = self::$PRIMARY_INTRODUCTION_DESCRIPTION; |
|
57 | + $introduction['title'] = self::$PRIMARY_INTRODUCTION_HEADER; |
|
58 | + $introduction['description'] = self::$PRIMARY_INTRODUCTION_DESCRIPTION; |
|
59 | 59 | |
60 | - $image = PhotoCollector::getRow(self::$PRIMARY_INTRODUCTION_IMAGE); |
|
61 | - $introduction['image'] = $this->get_image_element($image->category, $image->name, $image->description, 'medium'); |
|
60 | + $image = PhotoCollector::getRow(self::$PRIMARY_INTRODUCTION_IMAGE); |
|
61 | + $introduction['image'] = $this->get_image_element($image->category, $image->name, $image->description, 'medium'); |
|
62 | 62 | |
63 | - return $introduction; |
|
64 | - } |
|
65 | - |
|
66 | - protected function get_subsequent_introduction() |
|
67 | - { |
|
68 | - return array( |
|
69 | - 'title' => sprintf(self::$SECONDARY_INTRODUCTION_HEADER, $this->page, $this->page_count)); |
|
70 | - } |
|
71 | - |
|
72 | - protected function get_page_number_piece() |
|
73 | - { |
|
74 | - return URLDecode::getPiece(2); |
|
75 | - } |
|
76 | - |
|
77 | - protected function get_item_result($total, $offset) |
|
78 | - { |
|
79 | - return LogCollector::getList($total, $offset); |
|
80 | - } |
|
81 | - |
|
82 | - protected function get_item_count_result() |
|
83 | - { |
|
84 | - return LogCollector::getListCount(); |
|
85 | - } |
|
86 | - |
|
87 | - protected function get_list_description_pattern() |
|
88 | - { |
|
89 | - return self::$NAVIGATION_DESCRIPTION; |
|
90 | - } |
|
91 | - |
|
92 | - protected function get_list_link_root() |
|
93 | - { |
|
94 | - return self::$LINK_ROOT; |
|
95 | - } |
|
63 | + return $introduction; |
|
64 | + } |
|
65 | + |
|
66 | + protected function get_subsequent_introduction() |
|
67 | + { |
|
68 | + return array( |
|
69 | + 'title' => sprintf(self::$SECONDARY_INTRODUCTION_HEADER, $this->page, $this->page_count)); |
|
70 | + } |
|
71 | + |
|
72 | + protected function get_page_number_piece() |
|
73 | + { |
|
74 | + return URLDecode::getPiece(2); |
|
75 | + } |
|
76 | + |
|
77 | + protected function get_item_result($total, $offset) |
|
78 | + { |
|
79 | + return LogCollector::getList($total, $offset); |
|
80 | + } |
|
81 | + |
|
82 | + protected function get_item_count_result() |
|
83 | + { |
|
84 | + return LogCollector::getListCount(); |
|
85 | + } |
|
86 | + |
|
87 | + protected function get_list_description_pattern() |
|
88 | + { |
|
89 | + return self::$NAVIGATION_DESCRIPTION; |
|
90 | + } |
|
91 | + |
|
92 | + protected function get_list_link_root() |
|
93 | + { |
|
94 | + return self::$LINK_ROOT; |
|
95 | + } |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | \ No newline at end of file |