@@ -17,6 +17,9 @@ discard block |
||
17 | 17 | return self::run_query($query); |
18 | 18 | } |
19 | 19 | |
20 | + /** |
|
21 | + * @param integer $total |
|
22 | + */ |
|
20 | 23 | public static function getMainList($total, $offset = 0) |
21 | 24 | { |
22 | 25 | $query = "SELECT `post`.`id` AS `id`, `title`, `path`, `date`, `body`, `category` FROM `jpemeric_blog`.`post` WHERE `display` = '1' ORDER BY `date` DESC LIMIT {$offset}, {$total}"; |
@@ -29,6 +32,9 @@ discard block |
||
29 | 32 | return self::get_count($query); |
30 | 33 | } |
31 | 34 | |
35 | + /** |
|
36 | + * @param integer $total |
|
37 | + */ |
|
32 | 38 | public static function getPostsForTag($tag_id, $total, $offset = 0) |
33 | 39 | { |
34 | 40 | $query = "SELECT `post`.`id` AS `id`, `title`, `path`, `date`, `body`, `category` FROM `jpemeric_blog`.`post`,`jpemeric_blog`.`ptlink` WHERE `display` = '1' && `post`.`id` = `ptlink`.`post_id` && `ptlink`.`tag_id` = '{$tag_id}' ORDER BY `date` DESC LIMIT {$offset}, {$total}"; |
@@ -41,6 +47,9 @@ discard block |
||
41 | 47 | return self::get_count($query); |
42 | 48 | } |
43 | 49 | |
50 | + /** |
|
51 | + * @param integer $total |
|
52 | + */ |
|
44 | 53 | public static function getPostsForCategory($category, $total, $offset = 0) |
45 | 54 | { |
46 | 55 | $category = self::escape($category); |
@@ -83,6 +83,9 @@ |
||
83 | 83 | return self::run_query($query); |
84 | 84 | } |
85 | 85 | |
86 | + /** |
|
87 | + * @param integer $count |
|
88 | + */ |
|
86 | 89 | public static function getRecentBlogComments($count) |
87 | 90 | { |
88 | 91 | $query = " |
@@ -163,10 +163,11 @@ |
||
163 | 163 | { |
164 | 164 | $path = self::escape($path); |
165 | 165 | |
166 | - if($commenter != 0) |
|
167 | - $trusted_commenter_clause = "(`commenter`.`trusted` = '1' || `commenter`.`id` = '{$commenter}')"; |
|
168 | - else |
|
169 | - $trusted_commenter_clause = "`commenter`.`trusted` = '1'"; |
|
166 | + if($commenter != 0) { |
|
167 | + $trusted_commenter_clause = "(`commenter`.`trusted` = '1' || `commenter`.`id` = '{$commenter}')"; |
|
168 | + } else { |
|
169 | + $trusted_commenter_clause = "`commenter`.`trusted` = '1'"; |
|
170 | + } |
|
170 | 171 | |
171 | 172 | $query = " |
172 | 173 | SELECT |
@@ -19,6 +19,9 @@ |
||
19 | 19 | return self::run_row_query($query); |
20 | 20 | } |
21 | 21 | |
22 | + /** |
|
23 | + * @param integer $type |
|
24 | + */ |
|
22 | 25 | public static function getImagesForPiece($piece_id, $type) |
23 | 26 | { |
24 | 27 | $piece_id = self::escape($piece_id); |
@@ -17,6 +17,9 @@ |
||
17 | 17 | return self::run_row_query($query); |
18 | 18 | } |
19 | 19 | |
20 | + /** |
|
21 | + * @param string $date |
|
22 | + */ |
|
20 | 23 | public static function getTweetByFields($date, $text) |
21 | 24 | { |
22 | 25 | $query = "SELECT * FROM `jpemeric_stream`.`twitter` WHERE `date` = '{$date}' && `text` = '{$text}' LIMIT 1"; |
@@ -34,6 +34,9 @@ discard block |
||
34 | 34 | return self::run_query($query); |
35 | 35 | } |
36 | 36 | |
37 | + /** |
|
38 | + * @param integer $total |
|
39 | + */ |
|
37 | 40 | public static function getRecentList($total) |
38 | 41 | { |
39 | 42 | $query = " |
@@ -178,6 +181,9 @@ discard block |
||
178 | 181 | return self::run_row_query($query); |
179 | 182 | } |
180 | 183 | |
184 | + /** |
|
185 | + * @param string $date |
|
186 | + */ |
|
181 | 187 | public static function getByDate($date) |
182 | 188 | { |
183 | 189 | $date = self::escape($date); |
@@ -117,6 +117,9 @@ |
||
117 | 117 | return self::run_query($query); |
118 | 118 | } |
119 | 119 | |
120 | + /** |
|
121 | + * @param string $alias |
|
122 | + */ |
|
120 | 123 | public static function getByOldAlias($alias) |
121 | 124 | { |
122 | 125 | $alias = self::escape($alias); |
@@ -97,6 +97,9 @@ |
||
97 | 97 | return $tag_array; |
98 | 98 | } |
99 | 99 | |
100 | + /** |
|
101 | + * @param boolean $trim |
|
102 | + */ |
|
100 | 103 | final private function get_body_for_post($post, $trim) |
101 | 104 | { |
102 | 105 | $body = $post->body; |
@@ -37,8 +37,9 @@ discard block |
||
37 | 37 | Loader::load('collector', 'image/PhotoCollector'); |
38 | 38 | $photo_result = PhotoCollector::getRow($id); |
39 | 39 | |
40 | - if($photo_result == null) |
|
41 | - return; |
|
40 | + if($photo_result == null) { |
|
41 | + return; |
|
42 | + } |
|
42 | 43 | |
43 | 44 | $name = $photo_result->name; |
44 | 45 | $category = $photo_result->category; |
@@ -101,8 +102,9 @@ discard block |
||
101 | 102 | { |
102 | 103 | $body = $post->body; |
103 | 104 | |
104 | - if($trim) |
|
105 | - $body = Content::instance('SmartTrim', $body)->activate(self::$LENGTH_OF_TRIMMED_POST); |
|
105 | + if($trim) { |
|
106 | + $body = Content::instance('SmartTrim', $body)->activate(self::$LENGTH_OF_TRIMMED_POST); |
|
107 | + } |
|
106 | 108 | |
107 | 109 | $body = Content::instance('FixPhoto', $body)->activate(false, 'standard'); |
108 | 110 | $body = Content::instance('MarkupCode', $body)->activate(); |
@@ -128,8 +130,9 @@ discard block |
||
128 | 130 | $cloud_array = array(); |
129 | 131 | foreach($tag_result as $tag) |
130 | 132 | { |
131 | - if($tag->tag_count < self::$MINIMUM_TAG_COUNT) |
|
132 | - continue; |
|
133 | + if($tag->tag_count < self::$MINIMUM_TAG_COUNT) { |
|
134 | + continue; |
|
135 | + } |
|
133 | 136 | |
134 | 137 | $tag_object = new stdclass(); |
135 | 138 | $tag_object->name = $tag->tag; |
@@ -147,8 +150,9 @@ discard block |
||
147 | 150 | |
148 | 151 | foreach($tag_result as $tag) |
149 | 152 | { |
150 | - if($tag->tag_count > $maximum) |
|
151 | - $maximum = $tag->tag_count; |
|
153 | + if($tag->tag_count > $maximum) { |
|
154 | + $maximum = $tag->tag_count; |
|
155 | + } |
|
152 | 156 | } |
153 | 157 | return $maximum; |
154 | 158 | } |
@@ -204,6 +204,9 @@ discard block |
||
204 | 204 | exit; |
205 | 205 | } |
206 | 206 | |
207 | + /** |
|
208 | + * @param string $method |
|
209 | + */ |
|
207 | 210 | protected function set_header_method($method) |
208 | 211 | { |
209 | 212 | $this->headers = $method; |
@@ -214,6 +217,9 @@ discard block |
||
214 | 217 | $this->set_head('title', $value); |
215 | 218 | } |
216 | 219 | |
220 | + /** |
|
221 | + * @param string $value |
|
222 | + */ |
|
217 | 223 | protected function set_author($value) |
218 | 224 | { |
219 | 225 | $this->set_head('author', $value); |
@@ -229,26 +235,41 @@ discard block |
||
229 | 235 | $this->set_head('keywords', implode(', ', $array)); |
230 | 236 | } |
231 | 237 | |
238 | + /** |
|
239 | + * @param string $url |
|
240 | + */ |
|
232 | 241 | protected function set_canonical($url) |
233 | 242 | { |
234 | 243 | $this->set_head('canonical', $url); |
235 | 244 | } |
236 | 245 | |
246 | + /** |
|
247 | + * @param string $set |
|
248 | + */ |
|
237 | 249 | protected function set_head($set, $value) |
238 | 250 | { |
239 | 251 | $this->data_array['head'][$set] = $value; |
240 | 252 | } |
241 | 253 | |
254 | + /** |
|
255 | + * @param string $set |
|
256 | + */ |
|
242 | 257 | protected function set_body($set, $value) |
243 | 258 | { |
244 | 259 | $this->data_array['body'][$set] = $value; |
245 | 260 | } |
246 | 261 | |
262 | + /** |
|
263 | + * @param string $file |
|
264 | + */ |
|
247 | 265 | protected function add_css($file) |
248 | 266 | { |
249 | 267 | $this->css_array[] = $file; |
250 | 268 | } |
251 | 269 | |
270 | + /** |
|
271 | + * @param string $file |
|
272 | + */ |
|
252 | 273 | protected function add_js($file) |
253 | 274 | { |
254 | 275 | $this->js_array[] = $file; |
@@ -271,6 +292,9 @@ discard block |
||
271 | 292 | $this->set_head('js_link_array', $js_array); |
272 | 293 | } |
273 | 294 | |
295 | + /** |
|
296 | + * @param string $view |
|
297 | + */ |
|
274 | 298 | protected function set_body_view($view) |
275 | 299 | { |
276 | 300 | $this->body_view_array[] = $view; |
@@ -315,6 +339,10 @@ discard block |
||
315 | 339 | } |
316 | 340 | |
317 | 341 | private $comment_errors; |
342 | + |
|
343 | + /** |
|
344 | + * @param string $redirect_url |
|
345 | + */ |
|
318 | 346 | protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title) |
319 | 347 | { |
320 | 348 | if(Request::hasPost() && Request::getPost('submit') == 'Submit Comment') |
@@ -38,8 +38,9 @@ discard block |
||
38 | 38 | 'date' => date('Y'))); |
39 | 39 | |
40 | 40 | Loader::loadInstance('utility', 'Database'); |
41 | - if(Database::isConnected() === false) |
|
42 | - $this->unavailable(); |
|
41 | + if(Database::isConnected() === false) { |
|
42 | + $this->unavailable(); |
|
43 | + } |
|
43 | 44 | } |
44 | 45 | |
45 | 46 | protected function get_domain_container() |
@@ -96,8 +97,9 @@ discard block |
||
96 | 97 | $post->title = "Blogged about {$category}: <a href=\"{$row['url']}\">{$row['title']}</a>."; |
97 | 98 | $post->comments = $row['comments']; |
98 | 99 | |
99 | - if($format == 'full') |
|
100 | - $post->image = Content::instance('FetchFirstPhoto', $row['body'])->activate(false, 'standard'); |
|
100 | + if($format == 'full') { |
|
101 | + $post->image = Content::instance('FetchFirstPhoto', $row['body'])->activate(false, 'standard'); |
|
102 | + } |
|
101 | 103 | break; |
102 | 104 | case 'book' : |
103 | 105 | $row = $bookRepository->getBookById($raw_post['type_id']); |
@@ -105,8 +107,9 @@ discard block |
||
105 | 107 | $post->type = 'book'; |
106 | 108 | $post->title = "Just finished reading {$row['title']} by {$row['author']}."; |
107 | 109 | |
108 | - if($format == 'full') |
|
109 | - $post->image = "<img alt=\"{$row['title']} by {$row['author']}\" src=\"{$row['image']}\" />"; |
|
110 | + if($format == 'full') { |
|
111 | + $post->image = "<img alt=\"{$row['title']} by {$row['author']}\" src=\"{$row['image']}\" />"; |
|
112 | + } |
|
110 | 113 | break; |
111 | 114 | case 'distance' : |
112 | 115 | $row = $distanceRepository->getDistanceById($raw_post['type_id']); |
@@ -115,16 +118,16 @@ discard block |
||
115 | 118 | if($row['type'] == 'running') |
116 | 119 | { |
117 | 120 | $post->title = "Ran {$row['distance']} miles and felt {$row['felt']}."; |
118 | - if(strlen($row['message']) > 0) |
|
119 | - $post->title .= " Afterwards, I was all like '{$row['message']}'."; |
|
120 | - } |
|
121 | - else if($row['type'] == 'hiking') |
|
121 | + if(strlen($row['message']) > 0) { |
|
122 | + $post->title .= " Afterwards, I was all like '{$row['message']}'."; |
|
123 | + } |
|
124 | + } else if($row['type'] == 'hiking') |
|
122 | 125 | { |
123 | 126 | $post->title = "Hiked {$row['distance']} miles and felt {$row['felt']}."; |
124 | - if(strlen($row['title']) > 0) |
|
125 | - $post->title .= " I was hiking up around the {$row['title']} area."; |
|
126 | - } |
|
127 | - else if ($row['type'] == 'walking') { |
|
127 | + if(strlen($row['title']) > 0) { |
|
128 | + $post->title .= " I was hiking up around the {$row['title']} area."; |
|
129 | + } |
|
130 | + } else if ($row['type'] == 'walking') { |
|
128 | 131 | $post->title = "Walked {$row['distance']} miles and felt {$row['felt']}."; |
129 | 132 | } |
130 | 133 | break; |
@@ -139,10 +142,11 @@ discard block |
||
139 | 142 | |
140 | 143 | $post->type = 'twitter'; |
141 | 144 | |
142 | - if($format == 'full') |
|
143 | - $post->title = $row['text_formatted_full']; |
|
144 | - else |
|
145 | - $post->title = $row['text_formatted']; |
|
145 | + if($format == 'full') { |
|
146 | + $post->title = $row['text_formatted_full']; |
|
147 | + } else { |
|
148 | + $post->title = $row['text_formatted']; |
|
149 | + } |
|
146 | 150 | |
147 | 151 | $post->retweets = ($row['is_retweet'] == 0) ? $row['retweets'] : 0; |
148 | 152 | $post->favorites = ($row['is_retweet'] == 0) ? $row['favorites'] : 0; |
@@ -152,13 +156,15 @@ discard block |
||
152 | 156 | |
153 | 157 | $post->type = 'youtube'; |
154 | 158 | |
155 | - if($format == 'full') |
|
156 | - $post->title = "Favorited {$row['title']} by {$row['author']} on YouTube."; |
|
157 | - else |
|
158 | - $post->title = "Favorited <a href=\"http://www.youtube.com/watch?feature=player_embedded&v={$row['video_id']}\" rel=\"nofollow\" target=\"_blank\" title=\"{$row['content']}\">{$row['title']}</a> by {$row['author']} on YouTube."; |
|
159 | + if($format == 'full') { |
|
160 | + $post->title = "Favorited {$row['title']} by {$row['author']} on YouTube."; |
|
161 | + } else { |
|
162 | + $post->title = "Favorited <a href=\"http://www.youtube.com/watch?feature=player_embedded&v={$row['video_id']}\" rel=\"nofollow\" target=\"_blank\" title=\"{$row['content']}\">{$row['title']}</a> by {$row['author']} on YouTube."; |
|
163 | + } |
|
159 | 164 | |
160 | - if($format == 'full') |
|
161 | - $post->embed_code = "<iframe src=\"http://www.youtube.com/embed/{$row['video_id']}?rel=0\" frameborder=\"0\" allowfullscreen></iframe>"; |
|
165 | + if($format == 'full') { |
|
166 | + $post->embed_code = "<iframe src=\"http://www.youtube.com/embed/{$row['video_id']}?rel=0\" frameborder=\"0\" allowfullscreen></iframe>"; |
|
167 | + } |
|
162 | 168 | break; |
163 | 169 | } |
164 | 170 | |
@@ -187,10 +193,11 @@ discard block |
||
187 | 193 | Loader::load('view', '/Head', $this->data_array['head']); |
188 | 194 | foreach($this->body_view_array as $view) |
189 | 195 | { |
190 | - if(substr($view, 0, 1) == '/') |
|
191 | - Loader::load('view', $view, $this->data_array['body']); |
|
192 | - else |
|
193 | - Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']); |
|
196 | + if(substr($view, 0, 1) == '/') { |
|
197 | + Loader::load('view', $view, $this->data_array['body']); |
|
198 | + } else { |
|
199 | + Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']); |
|
200 | + } |
|
194 | 201 | } |
195 | 202 | |
196 | 203 | if (URLDecode::getSite() == 'waterfalls') { |
@@ -199,8 +206,9 @@ discard block |
||
199 | 206 | Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE)); |
200 | 207 | } |
201 | 208 | |
202 | - if($view == '/404' || $view == '/503') |
|
203 | - exit; |
|
209 | + if($view == '/404' || $view == '/503') { |
|
210 | + exit; |
|
211 | + } |
|
204 | 212 | } |
205 | 213 | |
206 | 214 | protected function set_header_method($method) |
@@ -273,14 +281,16 @@ discard block |
||
273 | 281 | |
274 | 282 | protected function eject() |
275 | 283 | { |
276 | - if(get_class($this) !== 'Error404Controller') |
|
277 | - Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
284 | + if(get_class($this) !== 'Error404Controller') { |
|
285 | + Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
286 | + } |
|
278 | 287 | } |
279 | 288 | |
280 | 289 | protected function unavailable() |
281 | 290 | { |
282 | - if(get_class($this) !== 'Error503Controller') |
|
283 | - Loader::loadNew('controller', '/Error503Controller')->activate(); |
|
291 | + if(get_class($this) !== 'Error503Controller') { |
|
292 | + Loader::loadNew('controller', '/Error503Controller')->activate(); |
|
293 | + } |
|
284 | 294 | } |
285 | 295 | |
286 | 296 | protected function redirect($uri, $method = 301) |
@@ -288,12 +298,14 @@ discard block |
||
288 | 298 | switch($method) |
289 | 299 | { |
290 | 300 | case 301 : |
291 | - if(get_class($this) !== 'Error301Controller') |
|
292 | - Loader::loadNew('controller', '/Error301Controller', array($uri))->activate(); |
|
301 | + if(get_class($this) !== 'Error301Controller') { |
|
302 | + Loader::loadNew('controller', '/Error301Controller', array($uri))->activate(); |
|
303 | + } |
|
293 | 304 | break; |
294 | 305 | case 303 : |
295 | - if(get_class($this) !== 'Error303Controller') |
|
296 | - Loader::loadNew('controller', '/Error303Controller', array($uri))->activate(); |
|
306 | + if(get_class($this) !== 'Error303Controller') { |
|
307 | + Loader::loadNew('controller', '/Error303Controller', array($uri))->activate(); |
|
308 | + } |
|
297 | 309 | break; |
298 | 310 | } |
299 | 311 | } |
@@ -340,18 +352,19 @@ discard block |
||
340 | 352 | $comment_object->url = $comment->url; |
341 | 353 | $comment_object->trusted = $comment->trusted; |
342 | 354 | |
343 | - if($comment->reply == 0 && Request::getPost('type') == $comment->id) |
|
344 | - $comment_object->errors = $this->comment_errors; |
|
345 | - else |
|
346 | - $comment_object->errors = array(); |
|
355 | + if($comment->reply == 0 && Request::getPost('type') == $comment->id) { |
|
356 | + $comment_object->errors = $this->comment_errors; |
|
357 | + } else { |
|
358 | + $comment_object->errors = array(); |
|
359 | + } |
|
347 | 360 | |
348 | 361 | if($comment->reply == 0) |
349 | 362 | { |
350 | 363 | $comment_object->replies = array(); |
351 | 364 | $comment_array[$comment->id] = $comment_object; |
352 | - } |
|
353 | - else |
|
354 | - $comment_array[$comment->reply]->replies[$comment->id] = $comment_object; |
|
365 | + } else { |
|
366 | + $comment_array[$comment->reply]->replies[$comment->id] = $comment_object; |
|
367 | + } |
|
355 | 368 | } |
356 | 369 | |
357 | 370 | $comment_count = CommentCollector::getCommentCountForURL($site, $path); |
@@ -376,22 +389,26 @@ discard block |
||
376 | 389 | $commenter->website = ''; |
377 | 390 | |
378 | 391 | $commenter_cookie = Cookie::instance('Commenter'); |
379 | - if(!$commenter_cookie->exists()) |
|
380 | - return $commenter; |
|
392 | + if(!$commenter_cookie->exists()) { |
|
393 | + return $commenter; |
|
394 | + } |
|
381 | 395 | |
382 | 396 | $commenter_cookie_value = $commenter_cookie->getValue(); |
383 | 397 | $commenter_cookie_value = json_decode($commenter_cookie_value); |
384 | 398 | |
385 | - if($commenter_cookie_value === NULL) |
|
386 | - return $commenter; |
|
399 | + if($commenter_cookie_value === NULL) { |
|
400 | + return $commenter; |
|
401 | + } |
|
387 | 402 | |
388 | - if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) |
|
389 | - return $commenter; |
|
403 | + if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) { |
|
404 | + return $commenter; |
|
405 | + } |
|
390 | 406 | |
391 | 407 | $commenter_object = CommentCollector::getCommenterByFields($commenter_cookie_value->name, $commenter_cookie_value->email, (isset($commenter_cookie_value->website) ? $commenter_cookie_value->website : '')); |
392 | 408 | |
393 | - if($commenter_object === NULL) |
|
394 | - return $commenter; |
|
409 | + if($commenter_object === NULL) { |
|
410 | + return $commenter; |
|
411 | + } |
|
395 | 412 | |
396 | 413 | $commenter->id = $commenter_object->id; |
397 | 414 | $commenter->name = $commenter_object->name; |
@@ -25,6 +25,9 @@ discard block |
||
25 | 25 | return; |
26 | 26 | } |
27 | 27 | |
28 | + /** |
|
29 | + * @param string $content |
|
30 | + */ |
|
28 | 31 | private function wrap_in_list($content) |
29 | 32 | { |
30 | 33 | $content_array = explode("\n", $content); |
@@ -44,6 +47,9 @@ discard block |
||
44 | 47 | return $content; |
45 | 48 | } |
46 | 49 | |
50 | + /** |
|
51 | + * @param string $type |
|
52 | + */ |
|
47 | 53 | private function highlight_code($content, $type) |
48 | 54 | { |
49 | 55 | switch($type) |
@@ -10,8 +10,9 @@ |
||
10 | 10 | protected function execute($title = '') |
11 | 11 | { |
12 | 12 | preg_match_all(self::$MARKUP_DELIMITER, $this->content, $matches); |
13 | - if(count($matches[1]) == 0) |
|
14 | - return; |
|
13 | + if(count($matches[1]) == 0) { |
|
14 | + return; |
|
15 | + } |
|
15 | 16 | |
16 | 17 | foreach($matches[3] as $key => $match) |
17 | 18 | { |