@@ -5,52 +5,52 @@ discard block |
||
5 | 5 | abstract class PageController |
6 | 6 | { |
7 | 7 | |
8 | - private static $TRACKING_CODE = 'UA-11745070-1'; |
|
8 | + private static $TRACKING_CODE = 'UA-11745070-1'; |
|
9 | 9 | |
10 | - protected static $DEPRECATED_BLOGS = array( |
|
11 | - 10 => 63, |
|
12 | - 55 => 67, |
|
13 | - ); |
|
14 | - |
|
15 | - private $headers; |
|
16 | - private $css_array = array(); |
|
17 | - private $font_css_array = array(); |
|
18 | - private $js_array = array(); |
|
19 | - |
|
20 | - private $data_array = array(); |
|
21 | - private $body_view_array = array(); |
|
22 | - |
|
23 | - protected function set_head_data() {} |
|
24 | - protected function set_body_data() {} |
|
25 | - protected function set_data() {} |
|
26 | - |
|
27 | - public function __construct() |
|
28 | - { |
|
29 | - $this->set_header_method('sendHTML'); |
|
10 | + protected static $DEPRECATED_BLOGS = array( |
|
11 | + 10 => 63, |
|
12 | + 55 => 67, |
|
13 | + ); |
|
14 | + |
|
15 | + private $headers; |
|
16 | + private $css_array = array(); |
|
17 | + private $font_css_array = array(); |
|
18 | + private $js_array = array(); |
|
19 | + |
|
20 | + private $data_array = array(); |
|
21 | + private $body_view_array = array(); |
|
22 | + |
|
23 | + protected function set_head_data() {} |
|
24 | + protected function set_body_data() {} |
|
25 | + protected function set_data() {} |
|
26 | + |
|
27 | + public function __construct() |
|
28 | + { |
|
29 | + $this->set_header_method('sendHTML'); |
|
30 | 30 | |
31 | - $this->set_head('google_verification', 'sgAISiuoWfK54KXnOfm2oU4vQdad8eyNCQX7LkZ1OxM'); |
|
32 | - $this->set_head('bing_verification', 'AF1A4CEA30A7589590E9294C4B512607'); |
|
31 | + $this->set_head('google_verification', 'sgAISiuoWfK54KXnOfm2oU4vQdad8eyNCQX7LkZ1OxM'); |
|
32 | + $this->set_head('bing_verification', 'AF1A4CEA30A7589590E9294C4B512607'); |
|
33 | 33 | |
34 | - $this->set_body('domain_container', $this->get_domain_container()); |
|
35 | - $this->set_body('footer', array( |
|
36 | - 'link' => Loader::getRootUrl('site'), |
|
37 | - 'anchor' => 'jacobemerick.com', |
|
38 | - 'date' => date('Y'))); |
|
39 | - } |
|
40 | - |
|
41 | - protected function get_domain_container() |
|
42 | - { |
|
43 | - $domain_container = new stdclass(); |
|
34 | + $this->set_body('domain_container', $this->get_domain_container()); |
|
35 | + $this->set_body('footer', array( |
|
36 | + 'link' => Loader::getRootUrl('site'), |
|
37 | + 'anchor' => 'jacobemerick.com', |
|
38 | + 'date' => date('Y'))); |
|
39 | + } |
|
40 | + |
|
41 | + protected function get_domain_container() |
|
42 | + { |
|
43 | + $domain_container = new stdclass(); |
|
44 | 44 | |
45 | - $domain_container->blog = Loader::getRootUrl('blog'); |
|
46 | - $domain_container->home = Loader::getRootUrl('home'); |
|
47 | - $domain_container->lifestream = Loader::getRootUrl('lifestream'); |
|
48 | - $domain_container->map = Loader::getRootUrl('map'); |
|
49 | - $domain_container->portfolio = Loader::getRootUrl('portfolio'); |
|
50 | - $domain_container->waterfalls = Loader::getRootUrl('waterfalls'); |
|
45 | + $domain_container->blog = Loader::getRootUrl('blog'); |
|
46 | + $domain_container->home = Loader::getRootUrl('home'); |
|
47 | + $domain_container->lifestream = Loader::getRootUrl('lifestream'); |
|
48 | + $domain_container->map = Loader::getRootUrl('map'); |
|
49 | + $domain_container->portfolio = Loader::getRootUrl('portfolio'); |
|
50 | + $domain_container->waterfalls = Loader::getRootUrl('waterfalls'); |
|
51 | 51 | |
52 | - return $domain_container; |
|
53 | - } |
|
52 | + return $domain_container; |
|
53 | + } |
|
54 | 54 | |
55 | 55 | protected function get_recent_activity() |
56 | 56 | { |
@@ -84,24 +84,24 @@ discard block |
||
84 | 84 | return (object) $post; |
85 | 85 | } |
86 | 86 | |
87 | - public function activate() |
|
88 | - { |
|
89 | - $this->set_head_data(); |
|
90 | - $this->set_body_data(); |
|
91 | - $this->set_data(); |
|
87 | + public function activate() |
|
88 | + { |
|
89 | + $this->set_head_data(); |
|
90 | + $this->set_body_data(); |
|
91 | + $this->set_data(); |
|
92 | 92 | |
93 | - $this->load_assets(); |
|
93 | + $this->load_assets(); |
|
94 | 94 | |
95 | - $headers = $this->headers; |
|
96 | - Header::$headers(); |
|
97 | - Loader::load('view', '/Head', $this->data_array['head']); |
|
98 | - foreach($this->body_view_array as $view) |
|
99 | - { |
|
100 | - if(substr($view, 0, 1) == '/') |
|
101 | - Loader::load('view', $view, $this->data_array['body']); |
|
102 | - else |
|
103 | - Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']); |
|
104 | - } |
|
95 | + $headers = $this->headers; |
|
96 | + Header::$headers(); |
|
97 | + Loader::load('view', '/Head', $this->data_array['head']); |
|
98 | + foreach($this->body_view_array as $view) |
|
99 | + { |
|
100 | + if(substr($view, 0, 1) == '/') |
|
101 | + Loader::load('view', $view, $this->data_array['body']); |
|
102 | + else |
|
103 | + Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']); |
|
104 | + } |
|
105 | 105 | |
106 | 106 | if (URLDecode::getSite() == 'waterfalls') { |
107 | 107 | Loader::load('view', '/WaterfallFoot'); |
@@ -109,134 +109,134 @@ discard block |
||
109 | 109 | Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE)); |
110 | 110 | } |
111 | 111 | |
112 | - if($view == '/404' || $view == '/503') |
|
113 | - exit; |
|
114 | - } |
|
115 | - |
|
116 | - protected function set_header_method($method) |
|
117 | - { |
|
118 | - $this->headers = $method; |
|
119 | - } |
|
120 | - |
|
121 | - protected function set_title($value) |
|
122 | - { |
|
123 | - $this->set_head('title', $value); |
|
124 | - } |
|
125 | - |
|
126 | - protected function set_author($value) |
|
127 | - { |
|
128 | - $this->set_head('author', $value); |
|
129 | - } |
|
130 | - |
|
131 | - protected function set_description($value) |
|
132 | - { |
|
133 | - $this->set_head('description', $value); |
|
134 | - } |
|
135 | - |
|
136 | - protected function set_keywords($array) |
|
137 | - { |
|
138 | - $this->set_head('keywords', implode(', ', $array)); |
|
139 | - } |
|
112 | + if($view == '/404' || $view == '/503') |
|
113 | + exit; |
|
114 | + } |
|
115 | + |
|
116 | + protected function set_header_method($method) |
|
117 | + { |
|
118 | + $this->headers = $method; |
|
119 | + } |
|
120 | + |
|
121 | + protected function set_title($value) |
|
122 | + { |
|
123 | + $this->set_head('title', $value); |
|
124 | + } |
|
125 | + |
|
126 | + protected function set_author($value) |
|
127 | + { |
|
128 | + $this->set_head('author', $value); |
|
129 | + } |
|
130 | + |
|
131 | + protected function set_description($value) |
|
132 | + { |
|
133 | + $this->set_head('description', $value); |
|
134 | + } |
|
135 | + |
|
136 | + protected function set_keywords($array) |
|
137 | + { |
|
138 | + $this->set_head('keywords', implode(', ', $array)); |
|
139 | + } |
|
140 | 140 | |
141 | - protected function set_canonical($url) |
|
142 | - { |
|
143 | - $this->set_head('canonical', $url); |
|
144 | - } |
|
145 | - |
|
146 | - protected function set_head($set, $value) |
|
147 | - { |
|
148 | - $this->data_array['head'][$set] = $value; |
|
149 | - } |
|
150 | - |
|
151 | - protected function set_body($set, $value) |
|
152 | - { |
|
153 | - $this->data_array['body'][$set] = $value; |
|
154 | - } |
|
155 | - |
|
156 | - protected function add_css($file, $version = 1) |
|
157 | - { |
|
158 | - $this->css_array[] = [$file, $version]; |
|
159 | - } |
|
160 | - |
|
161 | - protected function add_js($file) |
|
162 | - { |
|
163 | - $this->js_array[] = $file; |
|
164 | - } |
|
165 | - |
|
166 | - private function load_assets() |
|
167 | - { |
|
141 | + protected function set_canonical($url) |
|
142 | + { |
|
143 | + $this->set_head('canonical', $url); |
|
144 | + } |
|
145 | + |
|
146 | + protected function set_head($set, $value) |
|
147 | + { |
|
148 | + $this->data_array['head'][$set] = $value; |
|
149 | + } |
|
150 | + |
|
151 | + protected function set_body($set, $value) |
|
152 | + { |
|
153 | + $this->data_array['body'][$set] = $value; |
|
154 | + } |
|
155 | + |
|
156 | + protected function add_css($file, $version = 1) |
|
157 | + { |
|
158 | + $this->css_array[] = [$file, $version]; |
|
159 | + } |
|
160 | + |
|
161 | + protected function add_js($file) |
|
162 | + { |
|
163 | + $this->js_array[] = $file; |
|
164 | + } |
|
165 | + |
|
166 | + private function load_assets() |
|
167 | + { |
|
168 | 168 | $css_array = array_map(function ($stylesheet) { |
169 | - $path = "/css/{$stylesheet[0]}.css"; |
|
170 | - if ($stylesheet[1] > 1) { |
|
169 | + $path = "/css/{$stylesheet[0]}.css"; |
|
170 | + if ($stylesheet[1] > 1) { |
|
171 | 171 | $path .= "?v={$stylesheet[1]}"; |
172 | - } |
|
173 | - return $path; |
|
172 | + } |
|
173 | + return $path; |
|
174 | 174 | }, $this->css_array); |
175 | 175 | $js_array = array_map(function ($script) { |
176 | - if (substr($script, 0, 4) == 'http') { |
|
176 | + if (substr($script, 0, 4) == 'http') { |
|
177 | 177 | return $script; |
178 | - } |
|
179 | - return "/js/{$script}.min.js"; |
|
178 | + } |
|
179 | + return "/js/{$script}.min.js"; |
|
180 | 180 | }, $this->js_array); |
181 | 181 | |
182 | - $this->set_head('css_link_array', $css_array); |
|
183 | - $this->set_head('js_link_array', $js_array); |
|
184 | - } |
|
185 | - |
|
186 | - protected function set_body_view($view) |
|
187 | - { |
|
188 | - $this->body_view_array[] = $view; |
|
189 | - } |
|
190 | - |
|
191 | - protected function eject() |
|
192 | - { |
|
193 | - if(get_class($this) !== 'Error404Controller') |
|
194 | - Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
195 | - } |
|
196 | - |
|
197 | - protected function unavailable() |
|
198 | - { |
|
199 | - if(get_class($this) !== 'Error503Controller') |
|
200 | - Loader::loadNew('controller', '/Error503Controller')->activate(); |
|
201 | - } |
|
202 | - |
|
203 | - protected function redirect($uri, $method = 301) |
|
204 | - { |
|
205 | - switch($method) |
|
206 | - { |
|
207 | - case 301 : |
|
208 | - if(get_class($this) !== 'Error301Controller') |
|
209 | - Loader::loadNew('controller', '/Error301Controller', array($uri))->activate(); |
|
210 | - break; |
|
211 | - case 303 : |
|
212 | - if(get_class($this) !== 'Error303Controller') |
|
213 | - Loader::loadNew('controller', '/Error303Controller', array($uri))->activate(); |
|
214 | - break; |
|
215 | - } |
|
216 | - } |
|
217 | - |
|
218 | - final protected function get_parsed_date($date) |
|
219 | - { |
|
220 | - $parsed_date = new stdclass(); |
|
182 | + $this->set_head('css_link_array', $css_array); |
|
183 | + $this->set_head('js_link_array', $js_array); |
|
184 | + } |
|
185 | + |
|
186 | + protected function set_body_view($view) |
|
187 | + { |
|
188 | + $this->body_view_array[] = $view; |
|
189 | + } |
|
190 | + |
|
191 | + protected function eject() |
|
192 | + { |
|
193 | + if(get_class($this) !== 'Error404Controller') |
|
194 | + Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
195 | + } |
|
196 | + |
|
197 | + protected function unavailable() |
|
198 | + { |
|
199 | + if(get_class($this) !== 'Error503Controller') |
|
200 | + Loader::loadNew('controller', '/Error503Controller')->activate(); |
|
201 | + } |
|
202 | + |
|
203 | + protected function redirect($uri, $method = 301) |
|
204 | + { |
|
205 | + switch($method) |
|
206 | + { |
|
207 | + case 301 : |
|
208 | + if(get_class($this) !== 'Error301Controller') |
|
209 | + Loader::loadNew('controller', '/Error301Controller', array($uri))->activate(); |
|
210 | + break; |
|
211 | + case 303 : |
|
212 | + if(get_class($this) !== 'Error303Controller') |
|
213 | + Loader::loadNew('controller', '/Error303Controller', array($uri))->activate(); |
|
214 | + break; |
|
215 | + } |
|
216 | + } |
|
217 | + |
|
218 | + final protected function get_parsed_date($date) |
|
219 | + { |
|
220 | + $parsed_date = new stdclass(); |
|
221 | 221 | |
222 | - $parsed_date->stamp = date('c', strtotime($date)); |
|
223 | - $parsed_date->friendly = date('F j, Y', strtotime($date)); |
|
224 | - $parsed_date->elapsed = Content::instance('ElapsedTime', $date)->activate(); |
|
222 | + $parsed_date->stamp = date('c', strtotime($date)); |
|
223 | + $parsed_date->friendly = date('F j, Y', strtotime($date)); |
|
224 | + $parsed_date->elapsed = Content::instance('ElapsedTime', $date)->activate(); |
|
225 | 225 | |
226 | - return $parsed_date; |
|
227 | - } |
|
228 | - |
|
229 | - private $comment_errors; |
|
230 | - protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title) |
|
231 | - { |
|
232 | - if(Request::hasPost() && Request::getPost('submit') == 'Submit Comment') |
|
233 | - { |
|
234 | - $parameters = array($site_id, $path, $redirect_url, $page_title); |
|
235 | - $this->comment_errors = Loader::loadNew('module', 'form/CommentSubmitModule', $parameters)->activate(); |
|
236 | - } |
|
226 | + return $parsed_date; |
|
227 | + } |
|
228 | + |
|
229 | + private $comment_errors; |
|
230 | + protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title) |
|
231 | + { |
|
232 | + if(Request::hasPost() && Request::getPost('submit') == 'Submit Comment') |
|
233 | + { |
|
234 | + $parameters = array($site_id, $path, $redirect_url, $page_title); |
|
235 | + $this->comment_errors = Loader::loadNew('module', 'form/CommentSubmitModule', $parameters)->activate(); |
|
236 | + } |
|
237 | 237 | |
238 | - return; |
|
239 | - } |
|
238 | + return; |
|
239 | + } |
|
240 | 240 | |
241 | 241 | protected function get_comment_array($site, $path) |
242 | 242 | { |
@@ -6,150 +6,150 @@ |
||
6 | 6 | abstract class DefaultPageController extends PageController |
7 | 7 | { |
8 | 8 | |
9 | - private static $RECENT_COMMENT_COUNT = 10; |
|
10 | - private static $MINIMUM_TAG_COUNT = 10; |
|
11 | - protected static $LENGTH_OF_TRIMMED_POST = 300; |
|
9 | + private static $RECENT_COMMENT_COUNT = 10; |
|
10 | + private static $MINIMUM_TAG_COUNT = 10; |
|
11 | + protected static $LENGTH_OF_TRIMMED_POST = 300; |
|
12 | 12 | |
13 | - protected static $BLOG_SITE_ID = 2; |
|
13 | + protected static $BLOG_SITE_ID = 2; |
|
14 | 14 | |
15 | - private static $INTRODUCTION_IMAGE_PATTERN = '<img src="/photo/%s/%s-size-%s.jpg" height="%d" width="%d" alt="%s" />'; |
|
15 | + private static $INTRODUCTION_IMAGE_PATTERN = '<img src="/photo/%s/%s-size-%s.jpg" height="%d" width="%d" alt="%s" />'; |
|
16 | 16 | |
17 | - protected function set_head_data() |
|
18 | - { |
|
17 | + protected function set_head_data() |
|
18 | + { |
|
19 | 19 | $this->set_head('rss_link', [ |
20 | - 'title' => 'Jacob Emerick Blog Feed', |
|
21 | - 'url' => '/rss.xml' |
|
20 | + 'title' => 'Jacob Emerick Blog Feed', |
|
21 | + 'url' => '/rss.xml' |
|
22 | 22 | ]); |
23 | 23 | $this->set_head('rss_comment_link', [ |
24 | - 'title' => 'Jacob Emerick Blog Comment Feed', |
|
25 | - 'url' => '/rss-comments.xml' |
|
24 | + 'title' => 'Jacob Emerick Blog Comment Feed', |
|
25 | + 'url' => '/rss-comments.xml' |
|
26 | 26 | ]); |
27 | 27 | |
28 | - $this->add_css('normalize'); |
|
29 | - $this->add_css('blog'); |
|
30 | - } |
|
31 | - |
|
32 | - protected function get_introduction() |
|
33 | - { |
|
34 | - return; |
|
35 | - } |
|
36 | - |
|
37 | - protected function get_introduction_image($id) |
|
38 | - { |
|
39 | - Loader::load('collector', 'image/PhotoCollector'); |
|
40 | - $photo_result = PhotoCollector::getRow($id); |
|
28 | + $this->add_css('normalize'); |
|
29 | + $this->add_css('blog'); |
|
30 | + } |
|
31 | + |
|
32 | + protected function get_introduction() |
|
33 | + { |
|
34 | + return; |
|
35 | + } |
|
36 | + |
|
37 | + protected function get_introduction_image($id) |
|
38 | + { |
|
39 | + Loader::load('collector', 'image/PhotoCollector'); |
|
40 | + $photo_result = PhotoCollector::getRow($id); |
|
41 | 41 | |
42 | - if($photo_result == null) |
|
43 | - return; |
|
42 | + if($photo_result == null) |
|
43 | + return; |
|
44 | 44 | |
45 | - $name = $photo_result->name; |
|
46 | - $category = $photo_result->category; |
|
47 | - $size = 'medium'; |
|
48 | - $height = 375; |
|
49 | - $width = 500; |
|
50 | - $description = $photo_result->description; |
|
45 | + $name = $photo_result->name; |
|
46 | + $category = $photo_result->category; |
|
47 | + $size = 'medium'; |
|
48 | + $height = 375; |
|
49 | + $width = 500; |
|
50 | + $description = $photo_result->description; |
|
51 | 51 | |
52 | - return sprintf(self::$INTRODUCTION_IMAGE_PATTERN, $category, $name, $size, $height, $width, $description); |
|
53 | - } |
|
54 | - |
|
55 | - protected function set_body_data() |
|
56 | - { |
|
57 | - $this->set_body('introduction', $this->get_introduction()); |
|
58 | - $this->set_body('right_side', $this->get_right_side()); |
|
59 | - $this->set_body('activity_array', $this->get_recent_activity()); |
|
52 | + return sprintf(self::$INTRODUCTION_IMAGE_PATTERN, $category, $name, $size, $height, $width, $description); |
|
53 | + } |
|
54 | + |
|
55 | + protected function set_body_data() |
|
56 | + { |
|
57 | + $this->set_body('introduction', $this->get_introduction()); |
|
58 | + $this->set_body('right_side', $this->get_right_side()); |
|
59 | + $this->set_body('activity_array', $this->get_recent_activity()); |
|
60 | 60 | |
61 | - $this->set_body_view('Page'); |
|
62 | - } |
|
61 | + $this->set_body_view('Page'); |
|
62 | + } |
|
63 | 63 | |
64 | - final protected function format_post($post, $trim = false) |
|
65 | - { |
|
66 | - $post_object = new stdclass(); |
|
64 | + final protected function format_post($post, $trim = false) |
|
65 | + { |
|
66 | + $post_object = new stdclass(); |
|
67 | 67 | |
68 | - $post_object->title = $post['title']; |
|
69 | - $post_object->path = "/{$post['category']}/{$post['path']}/"; |
|
70 | - $post_object->category = ucwords(str_replace('-', ' ', $post['category'])); |
|
71 | - $post_object->category_link = "/{$post['category']}/"; |
|
72 | - $post_object->tags = $this->get_tags_for_post($post); |
|
73 | - $post_object->image = Content::instance('FetchFirstPhoto', $post['body'])->activate(false, 'small'); |
|
74 | - $post_object->body = $this->get_body_for_post($post, $trim); |
|
75 | - $post_object->date = $this->get_parsed_date($post['date']); |
|
76 | - |
|
77 | - return $post_object; |
|
78 | - } |
|
79 | - |
|
80 | - final private function get_tags_for_post($post) |
|
81 | - { |
|
68 | + $post_object->title = $post['title']; |
|
69 | + $post_object->path = "/{$post['category']}/{$post['path']}/"; |
|
70 | + $post_object->category = ucwords(str_replace('-', ' ', $post['category'])); |
|
71 | + $post_object->category_link = "/{$post['category']}/"; |
|
72 | + $post_object->tags = $this->get_tags_for_post($post); |
|
73 | + $post_object->image = Content::instance('FetchFirstPhoto', $post['body'])->activate(false, 'small'); |
|
74 | + $post_object->body = $this->get_body_for_post($post, $trim); |
|
75 | + $post_object->date = $this->get_parsed_date($post['date']); |
|
76 | + |
|
77 | + return $post_object; |
|
78 | + } |
|
79 | + |
|
80 | + final private function get_tags_for_post($post) |
|
81 | + { |
|
82 | 82 | global $container; |
83 | 83 | $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
84 | 84 | $tag_result = $repository->getTagsForPost($post['id']); |
85 | 85 | |
86 | 86 | $tag_array = array(); |
87 | - foreach($tag_result as $tag) |
|
88 | - { |
|
89 | - $tag_object = new stdclass(); |
|
90 | - $tag_object->name = $tag['tag']; |
|
91 | - $tag_object->link = Content::instance('URLSafe', "/tag/{$tag['tag']}/")->activate(); |
|
92 | - $tag_array[] = $tag_object; |
|
93 | - } |
|
94 | - return $tag_array; |
|
95 | - } |
|
96 | - |
|
97 | - final private function get_body_for_post($post, $trim) |
|
98 | - { |
|
99 | - $body = $post['body']; |
|
87 | + foreach($tag_result as $tag) |
|
88 | + { |
|
89 | + $tag_object = new stdclass(); |
|
90 | + $tag_object->name = $tag['tag']; |
|
91 | + $tag_object->link = Content::instance('URLSafe', "/tag/{$tag['tag']}/")->activate(); |
|
92 | + $tag_array[] = $tag_object; |
|
93 | + } |
|
94 | + return $tag_array; |
|
95 | + } |
|
96 | + |
|
97 | + final private function get_body_for_post($post, $trim) |
|
98 | + { |
|
99 | + $body = $post['body']; |
|
100 | 100 | |
101 | - if($trim) |
|
102 | - $body = Content::instance('SmartTrim', $body)->activate(self::$LENGTH_OF_TRIMMED_POST); |
|
101 | + if($trim) |
|
102 | + $body = Content::instance('SmartTrim', $body)->activate(self::$LENGTH_OF_TRIMMED_POST); |
|
103 | 103 | |
104 | - $body = Content::instance('FixPhoto', $body)->activate(false, 'standard'); |
|
105 | - $body = Content::instance('MarkupCode', $body)->activate(); |
|
104 | + $body = Content::instance('FixPhoto', $body)->activate(false, 'standard'); |
|
105 | + $body = Content::instance('MarkupCode', $body)->activate(); |
|
106 | 106 | |
107 | - return $body; |
|
108 | - } |
|
109 | - |
|
110 | - final protected function get_right_side() |
|
111 | - { |
|
112 | - $side_array = array(); |
|
113 | - $side_array['tags'] = $this->get_tag_cloud(); |
|
114 | - $side_array['comments'] = $this->get_comments(); |
|
115 | - return $side_array; |
|
116 | - } |
|
117 | - |
|
118 | - final private function get_tag_cloud() |
|
119 | - { |
|
107 | + return $body; |
|
108 | + } |
|
109 | + |
|
110 | + final protected function get_right_side() |
|
111 | + { |
|
112 | + $side_array = array(); |
|
113 | + $side_array['tags'] = $this->get_tag_cloud(); |
|
114 | + $side_array['comments'] = $this->get_comments(); |
|
115 | + return $side_array; |
|
116 | + } |
|
117 | + |
|
118 | + final private function get_tag_cloud() |
|
119 | + { |
|
120 | 120 | global $container; |
121 | 121 | $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
122 | 122 | $tag_result = $repository->getTagCloud(); |
123 | 123 | |
124 | - $maximum_tag_count = $this->get_maximum_tag_count($tag_result); |
|
124 | + $maximum_tag_count = $this->get_maximum_tag_count($tag_result); |
|
125 | 125 | |
126 | - $cloud_array = array(); |
|
127 | - foreach($tag_result as $tag) |
|
128 | - { |
|
129 | - if($tag['count'] < self::$MINIMUM_TAG_COUNT) |
|
130 | - continue; |
|
126 | + $cloud_array = array(); |
|
127 | + foreach($tag_result as $tag) |
|
128 | + { |
|
129 | + if($tag['count'] < self::$MINIMUM_TAG_COUNT) |
|
130 | + continue; |
|
131 | 131 | |
132 | - $tag_object = new stdclass(); |
|
133 | - $tag_object->name = $tag['tag']; |
|
134 | - $tag_object->link = Content::instance('URLSafe', "/tag/{$tag['tag']}/")->activate(); |
|
135 | - $tag_object->scalar = floor(($tag['count'] - 1) * (9 / ($maximum_tag_count - self::$MINIMUM_TAG_COUNT))); |
|
136 | - $cloud_array[] = $tag_object; |
|
137 | - } |
|
132 | + $tag_object = new stdclass(); |
|
133 | + $tag_object->name = $tag['tag']; |
|
134 | + $tag_object->link = Content::instance('URLSafe', "/tag/{$tag['tag']}/")->activate(); |
|
135 | + $tag_object->scalar = floor(($tag['count'] - 1) * (9 / ($maximum_tag_count - self::$MINIMUM_TAG_COUNT))); |
|
136 | + $cloud_array[] = $tag_object; |
|
137 | + } |
|
138 | 138 | |
139 | - return $cloud_array; |
|
140 | - } |
|
139 | + return $cloud_array; |
|
140 | + } |
|
141 | 141 | |
142 | - final private function get_maximum_tag_count($tag_result) |
|
143 | - { |
|
144 | - $maximum = 1; |
|
142 | + final private function get_maximum_tag_count($tag_result) |
|
143 | + { |
|
144 | + $maximum = 1; |
|
145 | 145 | |
146 | - foreach($tag_result as $tag) |
|
147 | - { |
|
148 | - if($tag['count'] > $maximum) |
|
149 | - $maximum = $tag['count']; |
|
150 | - } |
|
151 | - return $maximum; |
|
152 | - } |
|
146 | + foreach($tag_result as $tag) |
|
147 | + { |
|
148 | + if($tag['count'] > $maximum) |
|
149 | + $maximum = $tag['count']; |
|
150 | + } |
|
151 | + return $maximum; |
|
152 | + } |
|
153 | 153 | |
154 | 154 | final private function get_comments() |
155 | 155 | { |
@@ -1,71 +1,71 @@ |
||
1 | 1 | <? |
2 | 2 | |
3 | 3 | Loader::load('collector', array( |
4 | - 'waterfall/CountyCollector', |
|
5 | - 'waterfall/WatercourseCollector', |
|
6 | - 'waterfall/WaterfallCollector')); |
|
4 | + 'waterfall/CountyCollector', |
|
5 | + 'waterfall/WatercourseCollector', |
|
6 | + 'waterfall/WaterfallCollector')); |
|
7 | 7 | Loader::load('controller', 'waterfalls/DefaultListController'); |
8 | 8 | |
9 | 9 | abstract class DefaultWaterfallListController extends DefaultListController |
10 | 10 | { |
11 | 11 | |
12 | - protected static $ITEM_COUNT_PER_PAGE = 24; |
|
12 | + protected static $ITEM_COUNT_PER_PAGE = 24; |
|
13 | 13 | |
14 | - final protected function get_list_view() |
|
15 | - { |
|
16 | - return 'FallListing'; |
|
17 | - } |
|
14 | + final protected function get_list_view() |
|
15 | + { |
|
16 | + return 'FallListing'; |
|
17 | + } |
|
18 | 18 | |
19 | - protected function get_item_count_per_page() |
|
20 | - { |
|
21 | - return self::$ITEM_COUNT_PER_PAGE; |
|
22 | - } |
|
19 | + protected function get_item_count_per_page() |
|
20 | + { |
|
21 | + return self::$ITEM_COUNT_PER_PAGE; |
|
22 | + } |
|
23 | 23 | |
24 | - final protected function format_item($item) |
|
25 | - { |
|
26 | - $item_array = array(); |
|
24 | + final protected function format_item($item) |
|
25 | + { |
|
26 | + $item_array = array(); |
|
27 | 27 | |
28 | - $item_array['name'] = $item->name; |
|
29 | - $item_array['watercourse'] = $item->watercourse; |
|
30 | - $item_array['county'] = $item->county; |
|
31 | - $item_array['image'] = $this->get_image_element($item->photo_category, $item->photo, $item->photo_description, 'medium'); |
|
32 | - $item_array['path'] = "/{$item->watercourse_alias}/{$item->waterfall_alias}/"; |
|
33 | - $item_array['comment_count'] = 0; // todo this |
|
28 | + $item_array['name'] = $item->name; |
|
29 | + $item_array['watercourse'] = $item->watercourse; |
|
30 | + $item_array['county'] = $item->county; |
|
31 | + $item_array['image'] = $this->get_image_element($item->photo_category, $item->photo, $item->photo_description, 'medium'); |
|
32 | + $item_array['path'] = "/{$item->watercourse_alias}/{$item->waterfall_alias}/"; |
|
33 | + $item_array['comment_count'] = 0; // todo this |
|
34 | 34 | |
35 | - return $item_array; |
|
36 | - } |
|
35 | + return $item_array; |
|
36 | + } |
|
37 | 37 | |
38 | - final protected function get_sidebar() |
|
39 | - { |
|
40 | - $county_result = CountyCollector::getCountyList(); |
|
41 | - $county_list = array(); |
|
38 | + final protected function get_sidebar() |
|
39 | + { |
|
40 | + $county_result = CountyCollector::getCountyList(); |
|
41 | + $county_list = array(); |
|
42 | 42 | |
43 | - foreach($county_result as $county_row) |
|
44 | - { |
|
45 | - $county = new stdclass(); |
|
46 | - $county->name = $county_row->name; |
|
47 | - $county->uri = "/{$county_row->alias}/"; |
|
48 | - $county->count = $county_row->count; |
|
43 | + foreach($county_result as $county_row) |
|
44 | + { |
|
45 | + $county = new stdclass(); |
|
46 | + $county->name = $county_row->name; |
|
47 | + $county->uri = "/{$county_row->alias}/"; |
|
48 | + $county->count = $county_row->count; |
|
49 | 49 | |
50 | - $county_list[] = $county; |
|
51 | - } |
|
50 | + $county_list[] = $county; |
|
51 | + } |
|
52 | 52 | |
53 | - $watercourse_result = WatercourseCollector::getWatercourseList(); |
|
54 | - $watercourse_list = array(); |
|
53 | + $watercourse_result = WatercourseCollector::getWatercourseList(); |
|
54 | + $watercourse_list = array(); |
|
55 | 55 | |
56 | - foreach($watercourse_result as $watercourse_row) |
|
57 | - { |
|
58 | - $watercourse = new stdclass(); |
|
59 | - $watercourse->name = $watercourse_row->name; |
|
60 | - $watercourse->uri = "/{$watercourse_row->alias}/"; |
|
61 | - $watercourse->count = $watercourse_row->count; |
|
56 | + foreach($watercourse_result as $watercourse_row) |
|
57 | + { |
|
58 | + $watercourse = new stdclass(); |
|
59 | + $watercourse->name = $watercourse_row->name; |
|
60 | + $watercourse->uri = "/{$watercourse_row->alias}/"; |
|
61 | + $watercourse->count = $watercourse_row->count; |
|
62 | 62 | |
63 | - $watercourse_list[] = $watercourse; |
|
64 | - } |
|
63 | + $watercourse_list[] = $watercourse; |
|
64 | + } |
|
65 | 65 | |
66 | - return array( |
|
67 | - 'county_list' => $county_list, |
|
68 | - 'watercourse_list' => $watercourse_list); |
|
69 | - } |
|
66 | + return array( |
|
67 | + 'county_list' => $county_list, |
|
68 | + 'watercourse_list' => $watercourse_list); |
|
69 | + } |
|
70 | 70 | |
71 | 71 | } |
@@ -1,72 +1,72 @@ |
||
1 | 1 | <? |
2 | 2 | |
3 | 3 | Loader::load('collector', array( |
4 | - 'waterfall/CompanionCollector', |
|
5 | - 'waterfall/LogCollector', |
|
6 | - 'waterfall/PeriodCollector')); |
|
4 | + 'waterfall/CompanionCollector', |
|
5 | + 'waterfall/LogCollector', |
|
6 | + 'waterfall/PeriodCollector')); |
|
7 | 7 | Loader::load('controller', 'waterfalls/DefaultListController'); |
8 | 8 | |
9 | 9 | abstract class DefaultLogListController extends DefaultListController |
10 | 10 | { |
11 | 11 | |
12 | - private static $ITEM_COUNT_PER_PAGE = 10; |
|
12 | + private static $ITEM_COUNT_PER_PAGE = 10; |
|
13 | 13 | |
14 | - final protected function get_list_view() |
|
15 | - { |
|
16 | - return 'LogListing'; |
|
17 | - } |
|
14 | + final protected function get_list_view() |
|
15 | + { |
|
16 | + return 'LogListing'; |
|
17 | + } |
|
18 | 18 | |
19 | - final protected function get_item_count_per_page() |
|
20 | - { |
|
21 | - return self::$ITEM_COUNT_PER_PAGE; |
|
22 | - } |
|
19 | + final protected function get_item_count_per_page() |
|
20 | + { |
|
21 | + return self::$ITEM_COUNT_PER_PAGE; |
|
22 | + } |
|
23 | 23 | |
24 | - final protected function format_item($item) |
|
25 | - { |
|
26 | - $item_array = array(); |
|
24 | + final protected function format_item($item) |
|
25 | + { |
|
26 | + $item_array = array(); |
|
27 | 27 | |
28 | - $item_array['title'] = $item->title; |
|
29 | - $item_array['image'] = $this->get_image_element($item->photo_category, $item->photo, $item->photo_description); |
|
30 | - $item_array['waterfall_list'] = LogCollector::getWaterfallListForLog($item->id); |
|
31 | - $item_array['introduction'] = $item->introduction; |
|
32 | - $item_array['path'] = "/journal/{$item->alias}/"; |
|
33 | - $item_array['comment_count'] = 0; // todo - this |
|
34 | - $item_array['date'] = $this->get_parsed_date($item->date); |
|
28 | + $item_array['title'] = $item->title; |
|
29 | + $item_array['image'] = $this->get_image_element($item->photo_category, $item->photo, $item->photo_description); |
|
30 | + $item_array['waterfall_list'] = LogCollector::getWaterfallListForLog($item->id); |
|
31 | + $item_array['introduction'] = $item->introduction; |
|
32 | + $item_array['path'] = "/journal/{$item->alias}/"; |
|
33 | + $item_array['comment_count'] = 0; // todo - this |
|
34 | + $item_array['date'] = $this->get_parsed_date($item->date); |
|
35 | 35 | |
36 | - return $item_array; |
|
37 | - } |
|
36 | + return $item_array; |
|
37 | + } |
|
38 | 38 | |
39 | - final protected function get_sidebar() |
|
40 | - { |
|
41 | - $companion_result = CompanionCollector::getCompanionList(); |
|
42 | - $companion_list = array(); |
|
39 | + final protected function get_sidebar() |
|
40 | + { |
|
41 | + $companion_result = CompanionCollector::getCompanionList(); |
|
42 | + $companion_list = array(); |
|
43 | 43 | |
44 | - foreach($companion_result as $companion_row) |
|
45 | - { |
|
46 | - $companion = new stdclass(); |
|
47 | - $companion->name = $companion_row->name; |
|
48 | - $companion->uri = "/companion/{$companion_row->alias}/"; |
|
49 | - $companion->count = $companion_row->count; |
|
44 | + foreach($companion_result as $companion_row) |
|
45 | + { |
|
46 | + $companion = new stdclass(); |
|
47 | + $companion->name = $companion_row->name; |
|
48 | + $companion->uri = "/companion/{$companion_row->alias}/"; |
|
49 | + $companion->count = $companion_row->count; |
|
50 | 50 | |
51 | - $companion_list[] = $companion; |
|
52 | - } |
|
51 | + $companion_list[] = $companion; |
|
52 | + } |
|
53 | 53 | |
54 | - $period_result = PeriodCollector::getPeriodList(); |
|
55 | - $period_list = array(); |
|
54 | + $period_result = PeriodCollector::getPeriodList(); |
|
55 | + $period_list = array(); |
|
56 | 56 | |
57 | - foreach($period_result as $period_row) |
|
58 | - { |
|
59 | - $period = new stdclass(); |
|
60 | - $period->name = $period_row->name; |
|
61 | - $period->uri = "/period/{$period_row->alias}/"; |
|
62 | - $period->count = $period_row->count; |
|
57 | + foreach($period_result as $period_row) |
|
58 | + { |
|
59 | + $period = new stdclass(); |
|
60 | + $period->name = $period_row->name; |
|
61 | + $period->uri = "/period/{$period_row->alias}/"; |
|
62 | + $period->count = $period_row->count; |
|
63 | 63 | |
64 | - $period_list[] = $period; |
|
65 | - } |
|
64 | + $period_list[] = $period; |
|
65 | + } |
|
66 | 66 | |
67 | - return array( |
|
68 | - 'companion_list' => $companion_list, |
|
69 | - 'period_list' => $period_list); |
|
70 | - } |
|
67 | + return array( |
|
68 | + 'companion_list' => $companion_list, |
|
69 | + 'period_list' => $period_list); |
|
70 | + } |
|
71 | 71 | |
72 | 72 | } |
@@ -8,24 +8,24 @@ discard block |
||
8 | 8 | class WaterfallRouter extends Router |
9 | 9 | { |
10 | 10 | |
11 | - protected function get_redirect_array() |
|
12 | - { |
|
13 | - return array( |
|
14 | - (object) array( |
|
15 | - 'pattern' => '@/index.(html|htm|php)$@', |
|
16 | - 'replace' => '/'), |
|
17 | - (object) array( |
|
18 | - 'pattern' => '@^/home(/?)$@', |
|
19 | - 'replace' => '/'), |
|
20 | - (object) array( |
|
21 | - 'pattern' => '@^/falls/by-rating(/?)$@', |
|
22 | - 'replace' => '/falls/'), |
|
23 | - (object) array( |
|
24 | - 'pattern' => '@^/falls/by-rating/([0-9]+)(/?)$@', |
|
25 | - 'replace' => '/falls/'), |
|
26 | - (object) array( |
|
27 | - 'pattern' => '@^/falls/results(/?)$@', |
|
28 | - 'replace' => '/falls/'), |
|
11 | + protected function get_redirect_array() |
|
12 | + { |
|
13 | + return array( |
|
14 | + (object) array( |
|
15 | + 'pattern' => '@/index.(html|htm|php)$@', |
|
16 | + 'replace' => '/'), |
|
17 | + (object) array( |
|
18 | + 'pattern' => '@^/home(/?)$@', |
|
19 | + 'replace' => '/'), |
|
20 | + (object) array( |
|
21 | + 'pattern' => '@^/falls/by-rating(/?)$@', |
|
22 | + 'replace' => '/falls/'), |
|
23 | + (object) array( |
|
24 | + 'pattern' => '@^/falls/by-rating/([0-9]+)(/?)$@', |
|
25 | + 'replace' => '/falls/'), |
|
26 | + (object) array( |
|
27 | + 'pattern' => '@^/falls/results(/?)$@', |
|
28 | + 'replace' => '/falls/'), |
|
29 | 29 | (object) array( |
30 | 30 | 'pattern' => '@^/log(/?)$@', |
31 | 31 | 'replace' => '/journal/'), |
@@ -35,47 +35,47 @@ discard block |
||
35 | 35 | (object) array( |
36 | 36 | 'pattern' => '@^/map/([^/]+)(/?)$@', |
37 | 37 | 'replace' => '/map/'), |
38 | - (object) array( |
|
39 | - 'pattern' => '@^/about/([a-z]*)(/?)$@', |
|
40 | - 'replace' => '/about/'), |
|
41 | - (object) array( |
|
42 | - 'pattern' => '@^/birch-creek/birch-creek-falls/?$@', |
|
43 | - 'replace' => '/birch-creek/gold-mine-falls/'), |
|
44 | - (object) array( |
|
45 | - 'pattern' => '@^/big-iron-river/bonanza-falls/?$@', |
|
46 | - 'replace' => '/big-iron-river/greenwood-falls/'), |
|
47 | - (object) array( |
|
48 | - 'pattern' => '@^/east-branch-huron-river/east-branch-huron-river-falls/?$@', |
|
49 | - 'replace' => '/east-branch-huron-river/east-branch-falls/'), |
|
50 | - (object) array( |
|
51 | - 'pattern' => '@^/montreal-river/lower-montreal-falls/?$@', |
|
52 | - 'replace' => '/montreal-river/montreal-falls/'), |
|
53 | - (object) array( |
|
54 | - 'pattern' => '@^/manganese-creek/manganese-gorge-falls/?$@', |
|
55 | - 'replace' => '/manganese-creek/manganese-falls/'), |
|
56 | - (object) array( |
|
57 | - 'pattern' => '@^/dead-river/tourist-park-dam-falls/?$@', |
|
58 | - 'replace' => '/dead-river/tourist-park-falls/'), |
|
59 | - (object) array( |
|
60 | - 'pattern' => '@^/sturgeon-river/upper-sturgeon-falls/?$@', |
|
61 | - 'replace' => '/sturgeon-river/little-spruce-falls/'), |
|
62 | - (object) array( |
|
63 | - 'pattern' => '@^/tahquamenon-river/upper-tahquamenon-falls/?$@', |
|
64 | - 'replace' => '/tahquamenon-river/tahquamenon-falls/'), |
|
65 | - (object) array( |
|
66 | - 'pattern' => '@^/west-branch-huron-river/west-branch-huron-river-falls/?@', |
|
67 | - 'replace' => '/west-branch-huron-river/west-branch-falls/'), |
|
68 | - (object) array( |
|
69 | - 'pattern' => '@^/west-branch-yellow-dog-river/west-branch-yellow-dog-falls/?@', |
|
70 | - 'replace' => '/west-branch-yellow-dog-river/west-branch-falls/'), |
|
71 | - (object) array( |
|
72 | - 'pattern' => '@^/baltimore-river/peanut-butter-falls/?@', |
|
73 | - 'replace' => '/baltimore-river/konteko-falls/'), |
|
74 | - ); |
|
75 | - } |
|
38 | + (object) array( |
|
39 | + 'pattern' => '@^/about/([a-z]*)(/?)$@', |
|
40 | + 'replace' => '/about/'), |
|
41 | + (object) array( |
|
42 | + 'pattern' => '@^/birch-creek/birch-creek-falls/?$@', |
|
43 | + 'replace' => '/birch-creek/gold-mine-falls/'), |
|
44 | + (object) array( |
|
45 | + 'pattern' => '@^/big-iron-river/bonanza-falls/?$@', |
|
46 | + 'replace' => '/big-iron-river/greenwood-falls/'), |
|
47 | + (object) array( |
|
48 | + 'pattern' => '@^/east-branch-huron-river/east-branch-huron-river-falls/?$@', |
|
49 | + 'replace' => '/east-branch-huron-river/east-branch-falls/'), |
|
50 | + (object) array( |
|
51 | + 'pattern' => '@^/montreal-river/lower-montreal-falls/?$@', |
|
52 | + 'replace' => '/montreal-river/montreal-falls/'), |
|
53 | + (object) array( |
|
54 | + 'pattern' => '@^/manganese-creek/manganese-gorge-falls/?$@', |
|
55 | + 'replace' => '/manganese-creek/manganese-falls/'), |
|
56 | + (object) array( |
|
57 | + 'pattern' => '@^/dead-river/tourist-park-dam-falls/?$@', |
|
58 | + 'replace' => '/dead-river/tourist-park-falls/'), |
|
59 | + (object) array( |
|
60 | + 'pattern' => '@^/sturgeon-river/upper-sturgeon-falls/?$@', |
|
61 | + 'replace' => '/sturgeon-river/little-spruce-falls/'), |
|
62 | + (object) array( |
|
63 | + 'pattern' => '@^/tahquamenon-river/upper-tahquamenon-falls/?$@', |
|
64 | + 'replace' => '/tahquamenon-river/tahquamenon-falls/'), |
|
65 | + (object) array( |
|
66 | + 'pattern' => '@^/west-branch-huron-river/west-branch-huron-river-falls/?@', |
|
67 | + 'replace' => '/west-branch-huron-river/west-branch-falls/'), |
|
68 | + (object) array( |
|
69 | + 'pattern' => '@^/west-branch-yellow-dog-river/west-branch-yellow-dog-falls/?@', |
|
70 | + 'replace' => '/west-branch-yellow-dog-river/west-branch-falls/'), |
|
71 | + (object) array( |
|
72 | + 'pattern' => '@^/baltimore-river/peanut-butter-falls/?@', |
|
73 | + 'replace' => '/baltimore-river/konteko-falls/'), |
|
74 | + ); |
|
75 | + } |
|
76 | 76 | |
77 | - protected function check_for_special_redirect($uri) |
|
78 | - { |
|
77 | + protected function check_for_special_redirect($uri) |
|
78 | + { |
|
79 | 79 | if (preg_match('@^/falls/([a-z\'-]+)(/?)$@', $uri, $matches)) { |
80 | 80 | $alias = $matches[1]; |
81 | 81 | $alias = str_replace("'", '', $alias); |
@@ -128,81 +128,81 @@ discard block |
||
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
131 | - return $uri; |
|
132 | - } |
|
131 | + return $uri; |
|
132 | + } |
|
133 | 133 | |
134 | - protected function get_direct_array() |
|
135 | - { |
|
136 | - return array( |
|
137 | - (object) array( |
|
138 | - 'match' => '/', |
|
139 | - 'controller' => 'HomeController'), |
|
140 | - (object) array( |
|
141 | - 'match' => '/falls/', |
|
142 | - 'controller' => 'WaterfallListController'), |
|
143 | - (object) array( |
|
144 | - 'match' => '/falls/([0-9]+)/', |
|
145 | - 'controller' => 'WaterfallListController'), |
|
146 | - (object) array( |
|
147 | - 'match' => '/([a-z]+)-county/', |
|
148 | - 'controller' => 'CountyListController'), |
|
149 | - (object) array( |
|
150 | - 'match' => '/([a-z]+)-county/([0-9]+)/', |
|
151 | - 'controller' => 'CountyListController'), |
|
152 | - (object) array( |
|
153 | - 'match' => '/([a-z0-9-]+)-(creek|river)/', |
|
154 | - 'controller' => 'WatercourseListController'), |
|
155 | - (object) array( |
|
156 | - 'match' => '/([a-z0-9-]+)-(creek|river)/([0-9]+)/', |
|
157 | - 'controller' => 'WatercourseListController'), |
|
158 | - (object) array( |
|
159 | - 'match' => '/category/([a-z]+)/', |
|
160 | - 'controller' => 'CategoryListController'), |
|
161 | - (object) array( |
|
162 | - 'match' => '/category/([a-z]+)/([0-9]+)/', |
|
163 | - 'controller' => 'CategoryListController'), |
|
164 | - (object) array( |
|
165 | - 'match' => '/([a-z0-9-]+)-(creek|river)/([a-z-]+)/', |
|
166 | - 'controller' => 'WaterfallController'), |
|
167 | - (object) array( |
|
168 | - 'match' => '/map/', |
|
169 | - 'controller' => 'MapController'), |
|
134 | + protected function get_direct_array() |
|
135 | + { |
|
136 | + return array( |
|
137 | + (object) array( |
|
138 | + 'match' => '/', |
|
139 | + 'controller' => 'HomeController'), |
|
140 | + (object) array( |
|
141 | + 'match' => '/falls/', |
|
142 | + 'controller' => 'WaterfallListController'), |
|
143 | + (object) array( |
|
144 | + 'match' => '/falls/([0-9]+)/', |
|
145 | + 'controller' => 'WaterfallListController'), |
|
146 | + (object) array( |
|
147 | + 'match' => '/([a-z]+)-county/', |
|
148 | + 'controller' => 'CountyListController'), |
|
149 | + (object) array( |
|
150 | + 'match' => '/([a-z]+)-county/([0-9]+)/', |
|
151 | + 'controller' => 'CountyListController'), |
|
152 | + (object) array( |
|
153 | + 'match' => '/([a-z0-9-]+)-(creek|river)/', |
|
154 | + 'controller' => 'WatercourseListController'), |
|
155 | + (object) array( |
|
156 | + 'match' => '/([a-z0-9-]+)-(creek|river)/([0-9]+)/', |
|
157 | + 'controller' => 'WatercourseListController'), |
|
158 | + (object) array( |
|
159 | + 'match' => '/category/([a-z]+)/', |
|
160 | + 'controller' => 'CategoryListController'), |
|
161 | + (object) array( |
|
162 | + 'match' => '/category/([a-z]+)/([0-9]+)/', |
|
163 | + 'controller' => 'CategoryListController'), |
|
164 | + (object) array( |
|
165 | + 'match' => '/([a-z0-9-]+)-(creek|river)/([a-z-]+)/', |
|
166 | + 'controller' => 'WaterfallController'), |
|
167 | + (object) array( |
|
168 | + 'match' => '/map/', |
|
169 | + 'controller' => 'MapController'), |
|
170 | 170 | (object) array( |
171 | 171 | 'match' => '/map/#[a-z-/]+', |
172 | 172 | 'controller' => 'MapController'), |
173 | - (object) array( |
|
174 | - 'match' => '/journal/', |
|
175 | - 'controller' => 'LogListController'), |
|
176 | - (object) array( |
|
177 | - 'match' => '/journal/([0-9]+)/', |
|
178 | - 'controller' => 'LogListController'), |
|
179 | - (object) array( |
|
180 | - 'match' => '/journal/[a-z-]+/', |
|
181 | - 'controller' => 'LogController'), |
|
182 | - (object) array( |
|
183 | - 'match' => '/companion/([a-z-]+)/', |
|
184 | - 'controller' => 'CompanionListController'), |
|
185 | - (object) array( |
|
186 | - 'match' => '/companion/([a-z-]+)/([0-9]+)/', |
|
187 | - 'controller' => 'CompanionListController'), |
|
188 | - (object) array( |
|
189 | - 'match' => '/period/([a-z-]+)/', |
|
190 | - 'controller' => 'PeriodListController'), |
|
191 | - (object) array( |
|
192 | - 'match' => '/period/([a-z-]+)/([0-9]+)/', |
|
193 | - 'controller' => 'PeriodListController'), |
|
194 | - (object) array( |
|
195 | - 'match' => '/journal/tag/([a-z-]+)/', |
|
196 | - 'controller' => 'LogTagListController'), |
|
197 | - (object) array( |
|
198 | - 'match' => '/journal/tag/([a-z-]+)/([0-9]+)/', |
|
199 | - 'controller' => 'LogTagListController'), |
|
200 | - (object) array( |
|
201 | - 'match' => '/about/', |
|
202 | - 'controller' => 'AboutController'), |
|
203 | - (object) array( |
|
204 | - 'match' => '/contact/', |
|
205 | - 'controller' => 'ContactController')); |
|
206 | - } |
|
173 | + (object) array( |
|
174 | + 'match' => '/journal/', |
|
175 | + 'controller' => 'LogListController'), |
|
176 | + (object) array( |
|
177 | + 'match' => '/journal/([0-9]+)/', |
|
178 | + 'controller' => 'LogListController'), |
|
179 | + (object) array( |
|
180 | + 'match' => '/journal/[a-z-]+/', |
|
181 | + 'controller' => 'LogController'), |
|
182 | + (object) array( |
|
183 | + 'match' => '/companion/([a-z-]+)/', |
|
184 | + 'controller' => 'CompanionListController'), |
|
185 | + (object) array( |
|
186 | + 'match' => '/companion/([a-z-]+)/([0-9]+)/', |
|
187 | + 'controller' => 'CompanionListController'), |
|
188 | + (object) array( |
|
189 | + 'match' => '/period/([a-z-]+)/', |
|
190 | + 'controller' => 'PeriodListController'), |
|
191 | + (object) array( |
|
192 | + 'match' => '/period/([a-z-]+)/([0-9]+)/', |
|
193 | + 'controller' => 'PeriodListController'), |
|
194 | + (object) array( |
|
195 | + 'match' => '/journal/tag/([a-z-]+)/', |
|
196 | + 'controller' => 'LogTagListController'), |
|
197 | + (object) array( |
|
198 | + 'match' => '/journal/tag/([a-z-]+)/([0-9]+)/', |
|
199 | + 'controller' => 'LogTagListController'), |
|
200 | + (object) array( |
|
201 | + 'match' => '/about/', |
|
202 | + 'controller' => 'AboutController'), |
|
203 | + (object) array( |
|
204 | + 'match' => '/contact/', |
|
205 | + 'controller' => 'ContactController')); |
|
206 | + } |
|
207 | 207 | |
208 | 208 | } |
@@ -6,131 +6,131 @@ discard block |
||
6 | 6 | final class PostController extends DefaultPageController |
7 | 7 | { |
8 | 8 | |
9 | - private static $PAGE_DESCRIPTION_LIMIT = 250; |
|
9 | + private static $PAGE_DESCRIPTION_LIMIT = 250; |
|
10 | 10 | |
11 | - private static $TITLE = "%s | Jacob Emerick's Blog"; |
|
12 | - private static $AUTHOR = 'Jacob Emerick'; |
|
13 | - private static $AUTHOR_URL = 'https://home.jacobemerick.com/'; |
|
11 | + private static $TITLE = "%s | Jacob Emerick's Blog"; |
|
12 | + private static $AUTHOR = 'Jacob Emerick'; |
|
13 | + private static $AUTHOR_URL = 'https://home.jacobemerick.com/'; |
|
14 | 14 | |
15 | - private static $POST_LENGTH_SHORT = 100; |
|
16 | - private static $POST_LENGTH_LONG = 140; |
|
15 | + private static $POST_LENGTH_SHORT = 100; |
|
16 | + private static $POST_LENGTH_LONG = 140; |
|
17 | 17 | |
18 | - private $post; |
|
19 | - private $tags; |
|
20 | - private $comment_errors = array(); |
|
18 | + private $post; |
|
19 | + private $tags; |
|
20 | + private $comment_errors = array(); |
|
21 | 21 | |
22 | - public function __construct() |
|
23 | - { |
|
24 | - parent::__construct(); |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + parent::__construct(); |
|
25 | 25 | |
26 | 26 | global $container; |
27 | 27 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
28 | 28 | $this->post = $repository->findPostByPath(URLDecode::getPiece(2)); |
29 | 29 | |
30 | - if($this->post == null) |
|
31 | - $this->eject(); |
|
30 | + if($this->post == null) |
|
31 | + $this->eject(); |
|
32 | 32 | |
33 | - $this->handle_comment_submit( |
|
34 | - self::$BLOG_SITE_ID, |
|
35 | - $this->post['path'], |
|
36 | - Loader::getRootUrl('blog') . $this->post['category'] . '/' . $this->post['path'] . '/', |
|
37 | - $this->post['title']); |
|
33 | + $this->handle_comment_submit( |
|
34 | + self::$BLOG_SITE_ID, |
|
35 | + $this->post['path'], |
|
36 | + Loader::getRootUrl('blog') . $this->post['category'] . '/' . $this->post['path'] . '/', |
|
37 | + $this->post['title']); |
|
38 | 38 | |
39 | 39 | global $container; |
40 | 40 | $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']); |
41 | 41 | $this->tags = $repository->getTagsForPost($this->post['id']); |
42 | - } |
|
42 | + } |
|
43 | 43 | |
44 | - protected function set_head_data() |
|
45 | - { |
|
46 | - parent::set_head_data(); |
|
44 | + protected function set_head_data() |
|
45 | + { |
|
46 | + parent::set_head_data(); |
|
47 | 47 | |
48 | - $this->set_title(sprintf(self::$TITLE, $this->post['title'])); |
|
49 | - $this->set_description($this->get_post_description()); |
|
50 | - $this->set_keywords($this->get_post_keywords()); |
|
51 | - $this->set_author(self::$AUTHOR); |
|
48 | + $this->set_title(sprintf(self::$TITLE, $this->post['title'])); |
|
49 | + $this->set_description($this->get_post_description()); |
|
50 | + $this->set_keywords($this->get_post_keywords()); |
|
51 | + $this->set_author(self::$AUTHOR); |
|
52 | 52 | |
53 | 53 | $photo = Content::instance('FetchFirstPhoto', $this->post['body'])->activate(true); |
54 | 54 | $photo = preg_match('/^<img src="([a-z-:\.\/]+)" [^>]+>$/', $photo, $matches); |
55 | 55 | $this->set_head('thumbnail', $matches[1]); |
56 | 56 | |
57 | - if (array_key_exists($this->post['id'], self::$DEPRECATED_BLOGS)) { |
|
58 | - $log_id = self::$DEPRECATED_BLOGS[$this->post['id']]; |
|
59 | - $log = LogCollector::getById($log_id); |
|
60 | - if (!empty($log)) { |
|
61 | - $log_url = Loader::getRootUrl('waterfalls') . "journal/{$log->alias}/"; |
|
62 | - $this->set_canonical($log_url); |
|
63 | - } |
|
64 | - } |
|
65 | - } |
|
66 | - |
|
67 | - protected function get_introduction() {} |
|
68 | - |
|
69 | - protected function set_body_data() |
|
70 | - { |
|
71 | - parent::set_body_data(); |
|
57 | + if (array_key_exists($this->post['id'], self::$DEPRECATED_BLOGS)) { |
|
58 | + $log_id = self::$DEPRECATED_BLOGS[$this->post['id']]; |
|
59 | + $log = LogCollector::getById($log_id); |
|
60 | + if (!empty($log)) { |
|
61 | + $log_url = Loader::getRootUrl('waterfalls') . "journal/{$log->alias}/"; |
|
62 | + $this->set_canonical($log_url); |
|
63 | + } |
|
64 | + } |
|
65 | + } |
|
66 | + |
|
67 | + protected function get_introduction() {} |
|
68 | + |
|
69 | + protected function set_body_data() |
|
70 | + { |
|
71 | + parent::set_body_data(); |
|
72 | 72 | |
73 | - $this->set_body('title', $this->post['title']); |
|
74 | - $this->set_body('view', 'Post'); |
|
75 | - $this->set_body('data', array( |
|
76 | - 'post' => $this->format_post($this->post, false), |
|
77 | - 'series_posts' => $this->get_series_posts(), |
|
78 | - 'related_posts' => $this->get_related_posts(), |
|
79 | - 'author' => self::$AUTHOR, |
|
80 | - 'author_url' => self::$AUTHOR_URL, |
|
81 | - 'comment_array' => $this->get_comment_array( |
|
82 | - 'blog.jacobemerick.com', |
|
83 | - "{$this->post['category']}/{$this->post['path']}" |
|
84 | - ), |
|
73 | + $this->set_body('title', $this->post['title']); |
|
74 | + $this->set_body('view', 'Post'); |
|
75 | + $this->set_body('data', array( |
|
76 | + 'post' => $this->format_post($this->post, false), |
|
77 | + 'series_posts' => $this->get_series_posts(), |
|
78 | + 'related_posts' => $this->get_related_posts(), |
|
79 | + 'author' => self::$AUTHOR, |
|
80 | + 'author_url' => self::$AUTHOR_URL, |
|
81 | + 'comment_array' => $this->get_comment_array( |
|
82 | + 'blog.jacobemerick.com', |
|
83 | + "{$this->post['category']}/{$this->post['path']}" |
|
84 | + ), |
|
85 | 85 | )); |
86 | - } |
|
86 | + } |
|
87 | 87 | |
88 | - protected function get_post_description() |
|
89 | - { |
|
90 | - $description = $this->post['body']; |
|
91 | - $description = strip_tags($description); |
|
92 | - $description = Content::instance('SmartTrim', $description)->activate(self::$PAGE_DESCRIPTION_LIMIT); |
|
88 | + protected function get_post_description() |
|
89 | + { |
|
90 | + $description = $this->post['body']; |
|
91 | + $description = strip_tags($description); |
|
92 | + $description = Content::instance('SmartTrim', $description)->activate(self::$PAGE_DESCRIPTION_LIMIT); |
|
93 | 93 | |
94 | - return $description; |
|
95 | - } |
|
94 | + return $description; |
|
95 | + } |
|
96 | 96 | |
97 | - protected function get_post_keywords() |
|
98 | - { |
|
99 | - $keyword_array = array(); |
|
100 | - $keywords = $this->tags; |
|
97 | + protected function get_post_keywords() |
|
98 | + { |
|
99 | + $keyword_array = array(); |
|
100 | + $keywords = $this->tags; |
|
101 | 101 | |
102 | - foreach($keywords as $keyword) |
|
103 | - { |
|
104 | - $keyword_array[] = $keyword['tag']; |
|
105 | - } |
|
102 | + foreach($keywords as $keyword) |
|
103 | + { |
|
104 | + $keyword_array[] = $keyword['tag']; |
|
105 | + } |
|
106 | 106 | |
107 | - $keyword_array[] = 'blog'; |
|
108 | - $keyword_array[] = 'Jacob Emerick'; |
|
107 | + $keyword_array[] = 'blog'; |
|
108 | + $keyword_array[] = 'Jacob Emerick'; |
|
109 | 109 | |
110 | - return $keyword_array; |
|
111 | - } |
|
112 | - |
|
113 | - private function get_series_posts() |
|
114 | - { |
|
115 | - $series_posts = $this->fetch_series_posts(); |
|
116 | - if(count($series_posts) < 1) |
|
117 | - return array(); |
|
110 | + return $keyword_array; |
|
111 | + } |
|
112 | + |
|
113 | + private function get_series_posts() |
|
114 | + { |
|
115 | + $series_posts = $this->fetch_series_posts(); |
|
116 | + if(count($series_posts) < 1) |
|
117 | + return array(); |
|
118 | 118 | |
119 | - $previous_post = new stdclass(); |
|
120 | - $next_post = new stdclass(); |
|
119 | + $previous_post = new stdclass(); |
|
120 | + $next_post = new stdclass(); |
|
121 | 121 | |
122 | - $found_current_post = false; |
|
123 | - foreach($series_posts as $post_row) |
|
124 | - { |
|
125 | - if($post_row['post'] == $this->post['id']) |
|
126 | - { |
|
127 | - $found_current_post = true; |
|
128 | - continue; |
|
129 | - } |
|
122 | + $found_current_post = false; |
|
123 | + foreach($series_posts as $post_row) |
|
124 | + { |
|
125 | + if($post_row['post'] == $this->post['id']) |
|
126 | + { |
|
127 | + $found_current_post = true; |
|
128 | + continue; |
|
129 | + } |
|
130 | 130 | |
131 | - $post = new stdclass(); |
|
131 | + $post = new stdclass(); |
|
132 | 132 | |
133 | - if ( |
|
133 | + if ( |
|
134 | 134 | strpos($post_row['title'], 'Rainy Supe Loop') === 0 || |
135 | 135 | strpos($post_row['title'], 'Malapais Loop') === 0 || |
136 | 136 | strpos($post_row['title'], 'Mazatzal Peak Loop') === 0 || |
@@ -139,65 +139,65 @@ discard block |
||
139 | 139 | strpos($post_row['title'], 'Copper Camp Loop') === 0 || |
140 | 140 | strpos($post_row['title'], 'Across the Mazatzals') === 0 || |
141 | 141 | strpos($post_row['title'], 'Upper Mazzie Loop') === 0 |
142 | - ) { |
|
142 | + ) { |
|
143 | 143 | $title = $post_row['title']; |
144 | 144 | $title = explode(':', $title); |
145 | 145 | $title = array_pop($title); |
146 | 146 | $title = trim($title); |
147 | 147 | $post->title = $title; |
148 | - } else if (strpos($post_row['title'], 'Isle Royale') === 0) { |
|
149 | - $title = $post_row['title']; |
|
150 | - $title = explode(',', $title); |
|
151 | - $title = array_pop($title); |
|
152 | - $title = trim($title); |
|
153 | - $post->title = $title; |
|
154 | - } else { |
|
155 | - $post->title = $post_row['title']; |
|
156 | - } |
|
157 | - |
|
158 | - $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
|
148 | + } else if (strpos($post_row['title'], 'Isle Royale') === 0) { |
|
149 | + $title = $post_row['title']; |
|
150 | + $title = explode(',', $title); |
|
151 | + $title = array_pop($title); |
|
152 | + $title = trim($title); |
|
153 | + $post->title = $title; |
|
154 | + } else { |
|
155 | + $post->title = $post_row['title']; |
|
156 | + } |
|
157 | + |
|
158 | + $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
|
159 | 159 | |
160 | - if(!$found_current_post) |
|
161 | - $previous_post = $post; |
|
162 | - else |
|
163 | - { |
|
164 | - $next_post = $post; |
|
165 | - break; |
|
166 | - } |
|
167 | - } |
|
160 | + if(!$found_current_post) |
|
161 | + $previous_post = $post; |
|
162 | + else |
|
163 | + { |
|
164 | + $next_post = $post; |
|
165 | + break; |
|
166 | + } |
|
167 | + } |
|
168 | 168 | |
169 | - return array( |
|
170 | - 'title' => $post_row['series_title'], |
|
171 | - 'description' => Content::instance('FixInternalLink', $post_row['series_description'])->activate(), |
|
172 | - 'previous' => $previous_post, |
|
173 | - 'next' => $next_post); |
|
174 | - } |
|
175 | - |
|
176 | - private $series_posts; |
|
177 | - private function fetch_series_posts() |
|
178 | - { |
|
179 | - if(!isset($this->series_posts)) { |
|
180 | - global $container; |
|
181 | - $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']); |
|
182 | - $this->series_posts = $repository->getSeriesForPost($this->post['id']); |
|
183 | - } |
|
184 | - return $this->series_posts; |
|
185 | - } |
|
186 | - |
|
187 | - private function get_related_posts() |
|
188 | - { |
|
189 | - $tag_array = array(); |
|
190 | - foreach($this->tags as $tag) |
|
191 | - { |
|
192 | - $tag_array[] = $tag['id']; |
|
193 | - } |
|
169 | + return array( |
|
170 | + 'title' => $post_row['series_title'], |
|
171 | + 'description' => Content::instance('FixInternalLink', $post_row['series_description'])->activate(), |
|
172 | + 'previous' => $previous_post, |
|
173 | + 'next' => $next_post); |
|
174 | + } |
|
175 | + |
|
176 | + private $series_posts; |
|
177 | + private function fetch_series_posts() |
|
178 | + { |
|
179 | + if(!isset($this->series_posts)) { |
|
180 | + global $container; |
|
181 | + $repository = new Jacobemerick\Web\Domain\Blog\Series\MysqlSeriesRepository($container['db_connection_locator']); |
|
182 | + $this->series_posts = $repository->getSeriesForPost($this->post['id']); |
|
183 | + } |
|
184 | + return $this->series_posts; |
|
185 | + } |
|
186 | + |
|
187 | + private function get_related_posts() |
|
188 | + { |
|
189 | + $tag_array = array(); |
|
190 | + foreach($this->tags as $tag) |
|
191 | + { |
|
192 | + $tag_array[] = $tag['id']; |
|
193 | + } |
|
194 | 194 | |
195 | - $series_posts = $this->fetch_series_posts(); |
|
196 | - $exclude_post_array = array(); |
|
197 | - foreach($series_posts as $series_post) |
|
198 | - { |
|
199 | - $exclude_post_array[] = $series_post['post']; |
|
200 | - } |
|
195 | + $series_posts = $this->fetch_series_posts(); |
|
196 | + $exclude_post_array = array(); |
|
197 | + foreach($series_posts as $series_post) |
|
198 | + { |
|
199 | + $exclude_post_array[] = $series_post['post']; |
|
200 | + } |
|
201 | 201 | |
202 | 202 | global $container; |
203 | 203 | $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
@@ -205,18 +205,18 @@ discard block |
||
205 | 205 | |
206 | 206 | $post_array = array(); |
207 | 207 | |
208 | - foreach($post_result as $post_row) |
|
209 | - { |
|
210 | - $post = new stdclass(); |
|
211 | - $post->title = $post_row['title']; |
|
212 | - $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
|
213 | - $post->category = ucwords(str_replace('-', ' ', $post_row['category'])); |
|
214 | - $post->thumb = Content::instance('FetchFirstPhoto', $post_row['body'])->activate(); |
|
215 | - $post->body = Content::instance('SmartTrim', $post_row['body'])->activate(($post->thumb !== '') ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG); |
|
208 | + foreach($post_result as $post_row) |
|
209 | + { |
|
210 | + $post = new stdclass(); |
|
211 | + $post->title = $post_row['title']; |
|
212 | + $post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/"; |
|
213 | + $post->category = ucwords(str_replace('-', ' ', $post_row['category'])); |
|
214 | + $post->thumb = Content::instance('FetchFirstPhoto', $post_row['body'])->activate(); |
|
215 | + $post->body = Content::instance('SmartTrim', $post_row['body'])->activate(($post->thumb !== '') ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG); |
|
216 | 216 | |
217 | - $post_array[] = $post; |
|
218 | - } |
|
217 | + $post_array[] = $post; |
|
218 | + } |
|
219 | 219 | |
220 | - return $post_array; |
|
221 | - } |
|
220 | + return $post_array; |
|
221 | + } |
|
222 | 222 | } |