@@ -29,7 +29,7 @@ |
||
29 | 29 | $path = URLDecode::getPiece(1); |
30 | 30 | $this->watercourse = WatercourseCollector::getByAlias($path); |
31 | 31 | |
32 | - if(!$this->watercourse) |
|
32 | + if (!$this->watercourse) |
|
33 | 33 | $this->eject(); |
34 | 34 | |
35 | 35 | parent::__construct(); |
@@ -29,8 +29,9 @@ |
||
29 | 29 | $path = URLDecode::getPiece(1); |
30 | 30 | $this->watercourse = WatercourseCollector::getByAlias($path); |
31 | 31 | |
32 | - if(!$this->watercourse) |
|
33 | - $this->eject(); |
|
32 | + if(!$this->watercourse) { |
|
33 | + $this->eject(); |
|
34 | + } |
|
34 | 35 | |
35 | 36 | parent::__construct(); |
36 | 37 | } |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | abstract protected function get_initial_meta(); |
96 | 96 | abstract protected function get_subsequent_meta(); |
97 | 97 | |
98 | - final protected function set_body_data($page_type = 'normal') |
|
99 | - { |
|
100 | - parent::set_body_data($page_type); |
|
98 | + final protected function set_body_data($page_type = 'normal') |
|
99 | + { |
|
100 | + parent::set_body_data($page_type); |
|
101 | 101 | |
102 | 102 | $this->set_body('view', $this->get_list_view()); |
103 | 103 | $this->set_body('data', $this->get_list_body_data()); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | { |
108 | 108 | $body_data_array = array(); |
109 | 109 | |
110 | - $body_data_array['introduction'] = $this->get_introduction(); |
|
110 | + $body_data_array['introduction'] = $this->get_introduction(); |
|
111 | 111 | $body_data_array['items'] = array_map(array($this, 'format_item'), $this->get_items()); |
112 | 112 | $body_data_array['navigation'] = array( |
113 | 113 | 'description' => $this->get_list_description(), |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | $this->offset = ($this->page - 1) * $this->get_item_count_per_page(); |
21 | 21 | |
22 | 22 | $items = $this->get_items(); |
23 | - if(count($items) < 1) |
|
23 | + if (count($items) < 1) |
|
24 | 24 | $this->eject(); |
25 | 25 | } |
26 | 26 | |
27 | 27 | final protected function get_page_number() |
28 | 28 | { |
29 | 29 | $page = $this->get_page_number_piece(); |
30 | - if(isset($page) && is_numeric($page)) |
|
30 | + if (isset($page) && is_numeric($page)) |
|
31 | 31 | return $page; |
32 | 32 | return 1; |
33 | 33 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | final private function get_introduction() |
43 | 43 | { |
44 | - if($this->page == 1) |
|
44 | + if ($this->page == 1) |
|
45 | 45 | return $this->get_initial_introduction(); |
46 | 46 | |
47 | 47 | return $this->get_subsequent_introduction(); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | private $items; |
54 | 54 | protected function get_items() |
55 | 55 | { |
56 | - if(!isset($this->items)) |
|
56 | + if (!isset($this->items)) |
|
57 | 57 | { |
58 | 58 | $total = $this->get_item_count_per_page(); |
59 | 59 | $offset = ($this->page - 1) * $this->get_item_count_per_page(); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | private $item_count; |
69 | 69 | final private function get_item_count() |
70 | 70 | { |
71 | - if(!isset($this->item_count)) |
|
71 | + if (!isset($this->item_count)) |
|
72 | 72 | $this->item_count = $this->get_item_count_result(); |
73 | 73 | return $this->item_count; |
74 | 74 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $this->set_head('next_link', $this->get_list_next_link()); |
83 | 83 | $this->set_head('previous_link', $this->get_list_prev_link()); |
84 | 84 | |
85 | - if($this->page == 1) |
|
85 | + if ($this->page == 1) |
|
86 | 86 | $meta_array = $this->get_initial_meta(); |
87 | 87 | else |
88 | 88 | $meta_array = $this->get_subsequent_meta(); |
@@ -119,16 +119,16 @@ discard block |
||
119 | 119 | |
120 | 120 | final private function get_list_prev_link() |
121 | 121 | { |
122 | - if($this->page == 1) |
|
122 | + if ($this->page == 1) |
|
123 | 123 | return; |
124 | - if($this->page == 2) |
|
124 | + if ($this->page == 2) |
|
125 | 125 | return $this->get_list_link_root(); |
126 | 126 | return $this->get_list_link_root() . ($this->page - 1) . '/'; |
127 | 127 | } |
128 | 128 | |
129 | 129 | final private function get_list_next_link() |
130 | 130 | { |
131 | - if(($this->page * $this->get_item_count_per_page()) >= $this->get_item_count()) |
|
131 | + if (($this->page * $this->get_item_count_per_page()) >= $this->get_item_count()) |
|
132 | 132 | return; |
133 | 133 | return $this->get_list_link_root() . ($this->page + 1) . '/'; |
134 | 134 | } |
@@ -139,27 +139,27 @@ discard block |
||
139 | 139 | { |
140 | 140 | $link_array = array(); |
141 | 141 | |
142 | - if($this->get_item_count_per_page() >= $this->get_item_count()) |
|
142 | + if ($this->get_item_count_per_page() >= $this->get_item_count()) |
|
143 | 143 | return $link_array; |
144 | 144 | |
145 | 145 | $link = new stdclass(); |
146 | 146 | $link->anchor = '« previous'; |
147 | - if($this->get_list_prev_link() !== null) |
|
147 | + if ($this->get_list_prev_link() !== null) |
|
148 | 148 | $link->uri = $this->get_list_prev_link(); |
149 | 149 | else |
150 | 150 | $link->class = 'inactive'; |
151 | 151 | $link_array[] = $link; |
152 | 152 | |
153 | - for($i = 1; $i <= ceil($this->get_item_count() / $this->get_item_count_per_page()); $i++) |
|
153 | + for ($i = 1; $i <= ceil($this->get_item_count() / $this->get_item_count_per_page()); $i++) |
|
154 | 154 | { |
155 | 155 | $link = new stdclass(); |
156 | 156 | $link->anchor = $i; |
157 | 157 | |
158 | - if($i == $this->page) |
|
158 | + if ($i == $this->page) |
|
159 | 159 | $link->class = 'current'; |
160 | 160 | else |
161 | 161 | { |
162 | - if($i == 1) |
|
162 | + if ($i == 1) |
|
163 | 163 | $link->uri = $this->get_list_link_root(); |
164 | 164 | else |
165 | 165 | $link->uri = $this->get_list_link_root() . $i . '/'; |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | |
171 | 171 | $link = new stdclass(); |
172 | 172 | $link->anchor = 'next »'; |
173 | - if($this->get_list_next_link() !== null) |
|
173 | + if ($this->get_list_next_link() !== null) |
|
174 | 174 | $link->uri = $this->get_list_next_link(); |
175 | 175 | else |
176 | 176 | $link->class = 'inactive'; |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | |
193 | 193 | final protected function get_image_element($category, $path, $description, $size = 'small') |
194 | 194 | { |
195 | - switch($size) |
|
195 | + switch ($size) |
|
196 | 196 | { |
197 | 197 | case 'medium' : |
198 | 198 | $height = 375; |
@@ -20,15 +20,17 @@ discard block |
||
20 | 20 | $this->offset = ($this->page - 1) * $this->get_item_count_per_page(); |
21 | 21 | |
22 | 22 | $items = $this->get_items(); |
23 | - if(count($items) < 1) |
|
24 | - $this->eject(); |
|
23 | + if(count($items) < 1) { |
|
24 | + $this->eject(); |
|
25 | + } |
|
25 | 26 | } |
26 | 27 | |
27 | 28 | final protected function get_page_number() |
28 | 29 | { |
29 | 30 | $page = $this->get_page_number_piece(); |
30 | - if(isset($page) && is_numeric($page)) |
|
31 | - return $page; |
|
31 | + if(isset($page) && is_numeric($page)) { |
|
32 | + return $page; |
|
33 | + } |
|
32 | 34 | return 1; |
33 | 35 | } |
34 | 36 | |
@@ -41,8 +43,9 @@ discard block |
||
41 | 43 | |
42 | 44 | final private function get_introduction() |
43 | 45 | { |
44 | - if($this->page == 1) |
|
45 | - return $this->get_initial_introduction(); |
|
46 | + if($this->page == 1) { |
|
47 | + return $this->get_initial_introduction(); |
|
48 | + } |
|
46 | 49 | |
47 | 50 | return $this->get_subsequent_introduction(); |
48 | 51 | } |
@@ -68,8 +71,9 @@ discard block |
||
68 | 71 | private $item_count; |
69 | 72 | final private function get_item_count() |
70 | 73 | { |
71 | - if(!isset($this->item_count)) |
|
72 | - $this->item_count = $this->get_item_count_result(); |
|
74 | + if(!isset($this->item_count)) { |
|
75 | + $this->item_count = $this->get_item_count_result(); |
|
76 | + } |
|
73 | 77 | return $this->item_count; |
74 | 78 | } |
75 | 79 | |
@@ -82,10 +86,11 @@ discard block |
||
82 | 86 | $this->set_head('next_link', $this->get_list_next_link()); |
83 | 87 | $this->set_head('previous_link', $this->get_list_prev_link()); |
84 | 88 | |
85 | - if($this->page == 1) |
|
86 | - $meta_array = $this->get_initial_meta(); |
|
87 | - else |
|
88 | - $meta_array = $this->get_subsequent_meta(); |
|
89 | + if($this->page == 1) { |
|
90 | + $meta_array = $this->get_initial_meta(); |
|
91 | + } else { |
|
92 | + $meta_array = $this->get_subsequent_meta(); |
|
93 | + } |
|
89 | 94 | |
90 | 95 | $this->set_title($meta_array['title']); |
91 | 96 | $this->set_description($meta_array['description']); |
@@ -119,17 +124,20 @@ discard block |
||
119 | 124 | |
120 | 125 | final private function get_list_prev_link() |
121 | 126 | { |
122 | - if($this->page == 1) |
|
123 | - return; |
|
124 | - if($this->page == 2) |
|
125 | - return $this->get_list_link_root(); |
|
127 | + if($this->page == 1) { |
|
128 | + return; |
|
129 | + } |
|
130 | + if($this->page == 2) { |
|
131 | + return $this->get_list_link_root(); |
|
132 | + } |
|
126 | 133 | return $this->get_list_link_root() . ($this->page - 1) . '/'; |
127 | 134 | } |
128 | 135 | |
129 | 136 | final private function get_list_next_link() |
130 | 137 | { |
131 | - if(($this->page * $this->get_item_count_per_page()) >= $this->get_item_count()) |
|
132 | - return; |
|
138 | + if(($this->page * $this->get_item_count_per_page()) >= $this->get_item_count()) { |
|
139 | + return; |
|
140 | + } |
|
133 | 141 | return $this->get_list_link_root() . ($this->page + 1) . '/'; |
134 | 142 | } |
135 | 143 | |
@@ -139,15 +147,17 @@ discard block |
||
139 | 147 | { |
140 | 148 | $link_array = array(); |
141 | 149 | |
142 | - if($this->get_item_count_per_page() >= $this->get_item_count()) |
|
143 | - return $link_array; |
|
150 | + if($this->get_item_count_per_page() >= $this->get_item_count()) { |
|
151 | + return $link_array; |
|
152 | + } |
|
144 | 153 | |
145 | 154 | $link = new stdclass(); |
146 | 155 | $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'; |
|
156 | + if($this->get_list_prev_link() !== null) { |
|
157 | + $link->uri = $this->get_list_prev_link(); |
|
158 | + } else { |
|
159 | + $link->class = 'inactive'; |
|
160 | + } |
|
151 | 161 | $link_array[] = $link; |
152 | 162 | |
153 | 163 | for($i = 1; $i <= ceil($this->get_item_count() / $this->get_item_count_per_page()); $i++) |
@@ -155,14 +165,15 @@ discard block |
||
155 | 165 | $link = new stdclass(); |
156 | 166 | $link->anchor = $i; |
157 | 167 | |
158 | - if($i == $this->page) |
|
159 | - $link->class = 'current'; |
|
160 | - else |
|
168 | + if($i == $this->page) { |
|
169 | + $link->class = 'current'; |
|
170 | + } else |
|
161 | 171 | { |
162 | - if($i == 1) |
|
163 | - $link->uri = $this->get_list_link_root(); |
|
164 | - else |
|
165 | - $link->uri = $this->get_list_link_root() . $i . '/'; |
|
172 | + if($i == 1) { |
|
173 | + $link->uri = $this->get_list_link_root(); |
|
174 | + } else { |
|
175 | + $link->uri = $this->get_list_link_root() . $i . '/'; |
|
176 | + } |
|
166 | 177 | } |
167 | 178 | |
168 | 179 | $link_array[] = $link; |
@@ -170,10 +181,11 @@ discard block |
||
170 | 181 | |
171 | 182 | $link = new stdclass(); |
172 | 183 | $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'; |
|
184 | + if($this->get_list_next_link() !== null) { |
|
185 | + $link->uri = $this->get_list_next_link(); |
|
186 | + } else { |
|
187 | + $link->class = 'inactive'; |
|
188 | + } |
|
177 | 189 | $link_array[] = $link; |
178 | 190 | |
179 | 191 | return $link_array; |
@@ -6,62 +6,62 @@ |
||
6 | 6 | final class MapController extends DefaultPageController |
7 | 7 | { |
8 | 8 | |
9 | - private static $TITLE = 'Map of Upper Peninsula Waterfalls'; |
|
10 | - private static $DESCRIPTION = ''; |
|
11 | - private static $KEYWORD_ARRAY = array(); |
|
9 | + private static $TITLE = 'Map of Upper Peninsula Waterfalls'; |
|
10 | + private static $DESCRIPTION = ''; |
|
11 | + private static $KEYWORD_ARRAY = array(); |
|
12 | 12 | |
13 | - private static $HIDE_ON_INITIAL_LOAD_LIST = array( |
|
14 | - 'Lower Tahquamenon Falls', |
|
15 | - 'Rainbow Falls', |
|
16 | - 'Sandstone Falls', |
|
17 | - 'Upper Tahquamenon Falls', |
|
18 | - ); |
|
13 | + private static $HIDE_ON_INITIAL_LOAD_LIST = array( |
|
14 | + 'Lower Tahquamenon Falls', |
|
15 | + 'Rainbow Falls', |
|
16 | + 'Sandstone Falls', |
|
17 | + 'Upper Tahquamenon Falls', |
|
18 | + ); |
|
19 | 19 | |
20 | - public function __construct() |
|
21 | - { |
|
22 | - parent::__construct(); |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + parent::__construct(); |
|
23 | 23 | |
24 | - $this->add_js('https://maps.googleapis.com/maps/api/js?sensor=false'); |
|
25 | - $this->add_waterfall_js(); |
|
26 | - } |
|
24 | + $this->add_js('https://maps.googleapis.com/maps/api/js?sensor=false'); |
|
25 | + $this->add_waterfall_js(); |
|
26 | + } |
|
27 | 27 | |
28 | - protected function set_head_data() |
|
29 | - { |
|
30 | - parent::set_head_data(); |
|
28 | + protected function set_head_data() |
|
29 | + { |
|
30 | + parent::set_head_data(); |
|
31 | 31 | |
32 | - $this->set_title(self::$TITLE . ' | ' . self::$WEBSITE_TITLE); |
|
33 | - $this->set_description(self::$DESCRIPTION); |
|
34 | - $this->set_keywords(self::$KEYWORD_ARRAY); |
|
35 | - } |
|
32 | + $this->set_title(self::$TITLE . ' | ' . self::$WEBSITE_TITLE); |
|
33 | + $this->set_description(self::$DESCRIPTION); |
|
34 | + $this->set_keywords(self::$KEYWORD_ARRAY); |
|
35 | + } |
|
36 | 36 | |
37 | - protected function set_body_data($page_type = 'wide') |
|
38 | - { |
|
39 | - parent::set_body_data($page_type); |
|
37 | + protected function set_body_data($page_type = 'wide') |
|
38 | + { |
|
39 | + parent::set_body_data($page_type); |
|
40 | 40 | |
41 | - $this->set_head('full_page_map', true); |
|
42 | - $this->set_body('waterfall_list', $this->fetch_waterfall_list()); |
|
43 | - $this->set_body('view', 'Map'); |
|
44 | - } |
|
41 | + $this->set_head('full_page_map', true); |
|
42 | + $this->set_body('waterfall_list', $this->fetch_waterfall_list()); |
|
43 | + $this->set_body('view', 'Map'); |
|
44 | + } |
|
45 | 45 | |
46 | - private function fetch_waterfall_list() |
|
47 | - { |
|
48 | - $list = WaterfallCollector::getMapList(); |
|
49 | - array_walk($list, array($this, 'parse_waterfall')); |
|
50 | - return $list; |
|
51 | - } |
|
46 | + private function fetch_waterfall_list() |
|
47 | + { |
|
48 | + $list = WaterfallCollector::getMapList(); |
|
49 | + array_walk($list, array($this, 'parse_waterfall')); |
|
50 | + return $list; |
|
51 | + } |
|
52 | 52 | |
53 | - private function parse_waterfall(&$waterfall) |
|
54 | - { |
|
55 | - $waterfall = (object) array( |
|
56 | - 'name' => $waterfall->name, |
|
57 | - 'latitude' => $waterfall->latitude, |
|
58 | - 'longitude' => $waterfall->longitude, |
|
59 | - 'link' => "/{$waterfall->watercourse_alias}/{$waterfall->alias}/", |
|
60 | - 'image' => "/photo/{$waterfall->photo_category}/{$waterfall->photo}-size-medium.jpg", |
|
61 | - 'image_alt' => $waterfall->photo_description, |
|
62 | - 'watercourse' => $waterfall->watercourse, |
|
63 | - 'hide_on_initial_load' => (in_array($waterfall->name, self::$HIDE_ON_INITIAL_LOAD_LIST)), |
|
64 | - ); |
|
65 | - } |
|
53 | + private function parse_waterfall(&$waterfall) |
|
54 | + { |
|
55 | + $waterfall = (object) array( |
|
56 | + 'name' => $waterfall->name, |
|
57 | + 'latitude' => $waterfall->latitude, |
|
58 | + 'longitude' => $waterfall->longitude, |
|
59 | + 'link' => "/{$waterfall->watercourse_alias}/{$waterfall->alias}/", |
|
60 | + 'image' => "/photo/{$waterfall->photo_category}/{$waterfall->photo}-size-medium.jpg", |
|
61 | + 'image_alt' => $waterfall->photo_description, |
|
62 | + 'watercourse' => $waterfall->watercourse, |
|
63 | + 'hide_on_initial_load' => (in_array($waterfall->name, self::$HIDE_ON_INITIAL_LOAD_LIST)), |
|
64 | + ); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | $alias = URLDecode::getPiece(2); |
28 | 28 | $this->companion = CompanionCollector::getByAlias($alias); |
29 | 29 | |
30 | - if(!$this->companion) |
|
30 | + if (!$this->companion) |
|
31 | 31 | $this->eject(); |
32 | 32 | |
33 | 33 | parent::__construct(); |
@@ -27,8 +27,9 @@ |
||
27 | 27 | $alias = URLDecode::getPiece(2); |
28 | 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 | |
33 | 34 | parent::__construct(); |
34 | 35 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | Loader::load('collector', 'blog/IntroductionCollector'); |
37 | 37 | $introduction_result = IntroductionCollector::getRow('about'); |
38 | 38 | |
39 | - if($introduction_result !== null) |
|
39 | + if ($introduction_result !== null) |
|
40 | 40 | { |
41 | 41 | $introduction = array(); |
42 | 42 | $introduction['title'] = $introduction_result->title; |
@@ -33,9 +33,9 @@ |
||
33 | 33 | |
34 | 34 | protected function get_introduction() |
35 | 35 | { |
36 | - global $container; |
|
37 | - $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
|
38 | - $introduction_result = $repository->findByType('about'); |
|
36 | + global $container; |
|
37 | + $repository = new Jacobemerick\Web\Domain\Blog\Introduction\MysqlIntroductionRepository($container['db_connection_locator']); |
|
38 | + $introduction_result = $repository->findByType('about'); |
|
39 | 39 | |
40 | 40 | if($introduction_result !== null) |
41 | 41 | { |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | { |
46 | 46 | parent::set_head_data(); |
47 | 47 | |
48 | - if($this->page == 1) |
|
48 | + if ($this->page == 1) |
|
49 | 49 | { |
50 | 50 | $this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->query))); |
51 | 51 | $this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->query))); |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | |
64 | 64 | protected function get_introduction() |
65 | 65 | { |
66 | - if($this->total_pages > 1) |
|
66 | + if ($this->total_pages > 1) |
|
67 | 67 | return array( |
68 | 68 | 'title' => "Posts from search '{$this->query}', page {$this->page} of {$this->total_pages}."); |
69 | - else if($this->total_pages == 1) |
|
69 | + else if ($this->total_pages == 1) |
|
70 | 70 | return array( |
71 | 71 | 'title' => "Posts from search '{$this->query}'."); |
72 | 72 | else |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | protected function get_page_number() |
78 | 78 | { |
79 | 79 | $page = URLDecode::getPiece(3); |
80 | - if(isset($page) && is_numeric($page)) |
|
80 | + if (isset($page) && is_numeric($page)) |
|
81 | 81 | return $page; |
82 | 82 | return 1; |
83 | 83 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | private $search_result; |
86 | 86 | private function get_search_result() |
87 | 87 | { |
88 | - if(!isset($this->search_result)) |
|
88 | + if (!isset($this->search_result)) |
|
89 | 89 | { |
90 | 90 | $posts = PostCollector::getMainList(self::$MAXIMUM_SEARCH_POSTS); |
91 | 91 | |
@@ -113,16 +113,16 @@ discard block |
||
113 | 113 | |
114 | 114 | protected function get_list_next_link() |
115 | 115 | { |
116 | - if($this->page == 1) |
|
116 | + if ($this->page == 1) |
|
117 | 117 | return; |
118 | - if($this->page == 2) |
|
118 | + if ($this->page == 2) |
|
119 | 119 | return Content::instance('URLSafe', "/search/{$this->query}/")->activate(); |
120 | 120 | return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page - 1) . '/')->activate(); |
121 | 121 | } |
122 | 122 | |
123 | 123 | protected function get_list_prev_link() |
124 | 124 | { |
125 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
125 | + if (($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
126 | 126 | return; |
127 | 127 | return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page + 1) . '/')->activate(); |
128 | 128 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | private $total_post_count; |
131 | 131 | protected function get_total_post_count() |
132 | 132 | { |
133 | - if(!isset($this->total_post_count)) |
|
133 | + if (!isset($this->total_post_count)) |
|
134 | 134 | $this->total_post_count = count($this->get_search_result()); |
135 | 135 | return $this->total_post_count; |
136 | 136 | } |
@@ -49,8 +49,7 @@ discard block |
||
49 | 49 | { |
50 | 50 | $this->set_title(sprintf(self::$TITLE_MAIN, ucwords($this->query))); |
51 | 51 | $this->set_description(sprintf(self::$DESCRIPTION_MAIN, ucwords($this->query))); |
52 | - } |
|
53 | - else |
|
52 | + } else |
|
54 | 53 | { |
55 | 54 | $this->set_title(sprintf(self::$TITLE_PAGINATED, ucwords($this->query), $this->page, $this->total_pages)); |
56 | 55 | $this->set_description(sprintf(self::$DESCRIPTION_PAGINATED, $this->page, $this->total_pages, ucwords($this->query))); |
@@ -63,22 +62,24 @@ discard block |
||
63 | 62 | |
64 | 63 | protected function get_introduction() |
65 | 64 | { |
66 | - if($this->total_pages > 1) |
|
67 | - return array( |
|
68 | - 'title' => "Posts from search '{$this->query}', page {$this->page} of {$this->total_pages}."); |
|
69 | - else if($this->total_pages == 1) |
|
70 | - return array( |
|
71 | - 'title' => "Posts from search '{$this->query}'."); |
|
72 | - else |
|
73 | - return array( |
|
74 | - 'title' => "Sorry, '{$this->query}' didn't return any posts."); |
|
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 | 75 | } |
76 | 76 | |
77 | 77 | protected function get_page_number() |
78 | 78 | { |
79 | 79 | $page = URLDecode::getPiece(3); |
80 | - if(isset($page) && is_numeric($page)) |
|
81 | - return $page; |
|
80 | + if(isset($page) && is_numeric($page)) { |
|
81 | + return $page; |
|
82 | + } |
|
82 | 83 | return 1; |
83 | 84 | } |
84 | 85 | |
@@ -113,25 +114,29 @@ discard block |
||
113 | 114 | |
114 | 115 | protected function get_list_next_link() |
115 | 116 | { |
116 | - if($this->page == 1) |
|
117 | - return; |
|
118 | - if($this->page == 2) |
|
119 | - return Content::instance('URLSafe', "/search/{$this->query}/")->activate(); |
|
117 | + if($this->page == 1) { |
|
118 | + return; |
|
119 | + } |
|
120 | + if($this->page == 2) { |
|
121 | + return Content::instance('URLSafe', "/search/{$this->query}/")->activate(); |
|
122 | + } |
|
120 | 123 | return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page - 1) . '/')->activate(); |
121 | 124 | } |
122 | 125 | |
123 | 126 | protected function get_list_prev_link() |
124 | 127 | { |
125 | - if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) |
|
126 | - return; |
|
128 | + if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count()) { |
|
129 | + return; |
|
130 | + } |
|
127 | 131 | return Content::instance('URLSafe', "/search/{$this->query}/" . ($this->page + 1) . '/')->activate(); |
128 | 132 | } |
129 | 133 | |
130 | 134 | private $total_post_count; |
131 | 135 | protected function get_total_post_count() |
132 | 136 | { |
133 | - if(!isset($this->total_post_count)) |
|
134 | - $this->total_post_count = count($this->get_search_result()); |
|
137 | + if(!isset($this->total_post_count)) { |
|
138 | + $this->total_post_count = count($this->get_search_result()); |
|
139 | + } |
|
135 | 140 | return $this->total_post_count; |
136 | 141 | } |
137 | 142 |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | { |
35 | 35 | $query = URLDecode::getPiece(2); |
36 | 36 | $query = urldecode($query); |
37 | - $query = str_replace('-', ' ', $query); |
|
37 | + $query = str_replace('-', ' ', $query); |
|
38 | 38 | |
39 | 39 | $this->query = $query; |
40 | 40 | |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | { |
88 | 88 | if(!isset($this->search_result)) |
89 | 89 | { |
90 | - global $container; |
|
91 | - $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
92 | - $posts = $repository->getActivePosts(); |
|
90 | + global $container; |
|
91 | + $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']); |
|
92 | + $posts = $repository->getActivePosts(); |
|
93 | 93 | |
94 | 94 | $this->search_result = Search::instance() |
95 | 95 | ->setQuery($this->query) |
@@ -56,11 +56,11 @@ |
||
56 | 56 | final private function get_list_posts() |
57 | 57 | { |
58 | 58 | $post_array = array(); |
59 | - foreach($this->get_list_results() as $post) |
|
59 | + foreach ($this->get_list_results() as $post) |
|
60 | 60 | { |
61 | 61 | $post_array[] = $this->format_post($post, true); |
62 | 62 | } |
63 | - if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
63 | + if (count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
64 | 64 | $this->eject(); |
65 | 65 | return $post_array; |
66 | 66 | } |
@@ -60,8 +60,9 @@ |
||
60 | 60 | { |
61 | 61 | $post_array[] = $this->format_post($post, true); |
62 | 62 | } |
63 | - if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') |
|
64 | - $this->eject(); |
|
63 | + if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search') { |
|
64 | + $this->eject(); |
|
65 | + } |
|
65 | 66 | return $post_array; |
66 | 67 | } |
67 | 68 |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $active_page = $this->get_active_page(); |
42 | 42 | |
43 | 43 | $menu = array(); |
44 | - foreach(self::$MENU as $item) |
|
44 | + foreach (self::$MENU as $item) |
|
45 | 45 | { |
46 | 46 | $menu[] = (object) array( |
47 | 47 | 'name' => $item['name'], |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | { |
57 | 57 | $current_uri = URLDecode::getPiece(1); |
58 | 58 | |
59 | - if(!isset($current_uri)) |
|
59 | + if (!isset($current_uri)) |
|
60 | 60 | return 'About'; |
61 | 61 | |
62 | 62 | $menu = self::$MENU; |
63 | - foreach($menu as $link) |
|
63 | + foreach ($menu as $link) |
|
64 | 64 | { |
65 | - if($link['uri'] == $current_uri) |
|
65 | + if ($link['uri'] == $current_uri) |
|
66 | 66 | return $link['name']; |
67 | 67 | } |
68 | 68 |
@@ -56,14 +56,16 @@ |
||
56 | 56 | { |
57 | 57 | $current_uri = URLDecode::getPiece(1); |
58 | 58 | |
59 | - if(!isset($current_uri)) |
|
60 | - return 'About'; |
|
59 | + if(!isset($current_uri)) { |
|
60 | + return 'About'; |
|
61 | + } |
|
61 | 62 | |
62 | 63 | $menu = self::$MENU; |
63 | 64 | foreach($menu as $link) |
64 | 65 | { |
65 | - if($link['uri'] == $current_uri) |
|
66 | - return $link['name']; |
|
66 | + if($link['uri'] == $current_uri) { |
|
67 | + return $link['name']; |
|
68 | + } |
|
67 | 69 | } |
68 | 70 | |
69 | 71 | return 'About'; |
@@ -29,17 +29,17 @@ |
||
29 | 29 | |
30 | 30 | private function get_form_results() |
31 | 31 | { |
32 | - if(!Request::hasPost()) |
|
32 | + if (!Request::hasPost()) |
|
33 | 33 | return array(); |
34 | 34 | |
35 | - if(!Validate::checkRequest('post', 'name', 'string')) |
|
35 | + if (!Validate::checkRequest('post', 'name', 'string')) |
|
36 | 36 | $error_message['name'] = 'Please enter a value for your name.'; |
37 | - if(!Validate::checkRequest('post', 'email', 'string')) |
|
37 | + if (!Validate::checkRequest('post', 'email', 'string')) |
|
38 | 38 | $error_message['email'] = 'Please enter a valid email address.'; |
39 | - if(!Validate::checkRequest('post', 'message', 'string')) |
|
39 | + if (!Validate::checkRequest('post', 'message', 'string')) |
|
40 | 40 | $error_message['message'] = 'Please enter a message.'; |
41 | 41 | |
42 | - if(!empty($error_message)) |
|
42 | + if (!empty($error_message)) |
|
43 | 43 | { |
44 | 44 | return array( |
45 | 45 | 'error_message' => $error_message, |
@@ -29,15 +29,19 @@ |
||
29 | 29 | |
30 | 30 | private function get_form_results() |
31 | 31 | { |
32 | - if(!Request::hasPost()) |
|
33 | - return array(); |
|
32 | + if(!Request::hasPost()) { |
|
33 | + return array(); |
|
34 | + } |
|
34 | 35 | |
35 | - if(!Validate::checkRequest('post', 'name', 'string')) |
|
36 | - $error_message['name'] = 'Please enter a value for your name.'; |
|
37 | - if(!Validate::checkRequest('post', 'email', 'string')) |
|
38 | - $error_message['email'] = 'Please enter a valid email address.'; |
|
39 | - if(!Validate::checkRequest('post', 'message', 'string')) |
|
40 | - $error_message['message'] = 'Please enter a message.'; |
|
36 | + if(!Validate::checkRequest('post', 'name', 'string')) { |
|
37 | + $error_message['name'] = 'Please enter a value for your name.'; |
|
38 | + } |
|
39 | + if(!Validate::checkRequest('post', 'email', 'string')) { |
|
40 | + $error_message['email'] = 'Please enter a valid email address.'; |
|
41 | + } |
|
42 | + if(!Validate::checkRequest('post', 'message', 'string')) { |
|
43 | + $error_message['message'] = 'Please enter a message.'; |
|
44 | + } |
|
41 | 45 | |
42 | 46 | if(!empty($error_message)) |
43 | 47 | { |
@@ -46,16 +46,16 @@ |
||
46 | 46 | 'value' => Request::getPost()); |
47 | 47 | } |
48 | 48 | |
49 | - global $container; |
|
50 | - $sent = $container['mail'] |
|
51 | - ->addTo($container['config']->admin_email) |
|
52 | - ->setSubject('Site Contact') |
|
53 | - ->setPlainMessage( |
|
54 | - 'Name: ' . Request::getPost('name') . "\n" . |
|
55 | - 'Email: ' . Request::getPost('email') . "\n" . |
|
56 | - 'Message: ' . Request::getPost('message') |
|
57 | - ) |
|
58 | - ->send(); |
|
49 | + global $container; |
|
50 | + $sent = $container['mail'] |
|
51 | + ->addTo($container['config']->admin_email) |
|
52 | + ->setSubject('Site Contact') |
|
53 | + ->setPlainMessage( |
|
54 | + 'Name: ' . Request::getPost('name') . "\n" . |
|
55 | + 'Email: ' . Request::getPost('email') . "\n" . |
|
56 | + 'Message: ' . Request::getPost('message') |
|
57 | + ) |
|
58 | + ->send(); |
|
59 | 59 | |
60 | 60 | return array( |
61 | 61 | 'success_message' => "Thank you for your message, " . Request::getPost('name') . "! I'll get back to you as soon as possible."); |