@@ -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); |
@@ -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')
|
@@ -102,10 +102,11 @@ discard block |
||
| 102 | 102 | Loader::load('view', '/Head', $this->data_array['head']); |
| 103 | 103 | foreach($this->body_view_array as $view) |
| 104 | 104 | { |
| 105 | - if(substr($view, 0, 1) == '/') |
|
| 106 | - Loader::load('view', $view, $this->data_array['body']); |
|
| 107 | - else |
|
| 108 | - Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']); |
|
| 105 | + if(substr($view, 0, 1) == '/') {
|
|
| 106 | + Loader::load('view', $view, $this->data_array['body']);
|
|
| 107 | + } else {
|
|
| 108 | + Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']);
|
|
| 109 | + } |
|
| 109 | 110 | } |
| 110 | 111 | |
| 111 | 112 | if (URLDecode::getSite() == 'waterfalls') { |
@@ -114,8 +115,9 @@ discard block |
||
| 114 | 115 | Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE)); |
| 115 | 116 | } |
| 116 | 117 | |
| 117 | - if($view == '/404' || $view == '/503') |
|
| 118 | - exit; |
|
| 118 | + if($view == '/404' || $view == '/503') {
|
|
| 119 | + exit; |
|
| 120 | + } |
|
| 119 | 121 | } |
| 120 | 122 | |
| 121 | 123 | protected function set_header_method($method) |
@@ -195,14 +197,16 @@ discard block |
||
| 195 | 197 | |
| 196 | 198 | protected function eject() |
| 197 | 199 | { |
| 198 | - if(get_class($this) !== 'Error404Controller') |
|
| 199 | - Loader::loadNew('controller', '/Error404Controller')->activate(); |
|
| 200 | + if(get_class($this) !== 'Error404Controller') {
|
|
| 201 | + Loader::loadNew('controller', '/Error404Controller')->activate();
|
|
| 202 | + } |
|
| 200 | 203 | } |
| 201 | 204 | |
| 202 | 205 | protected function unavailable() |
| 203 | 206 | { |
| 204 | - if(get_class($this) !== 'Error503Controller') |
|
| 205 | - Loader::loadNew('controller', '/Error503Controller')->activate(); |
|
| 207 | + if(get_class($this) !== 'Error503Controller') {
|
|
| 208 | + Loader::loadNew('controller', '/Error503Controller')->activate();
|
|
| 209 | + } |
|
| 206 | 210 | } |
| 207 | 211 | |
| 208 | 212 | protected function redirect($uri, $method = 301) |
@@ -210,12 +214,14 @@ discard block |
||
| 210 | 214 | switch($method) |
| 211 | 215 | { |
| 212 | 216 | case 301 : |
| 213 | - if(get_class($this) !== 'Error301Controller') |
|
| 214 | - Loader::loadNew('controller', '/Error301Controller', array($uri))->activate(); |
|
| 217 | + if(get_class($this) !== 'Error301Controller') {
|
|
| 218 | + Loader::loadNew('controller', '/Error301Controller', array($uri))->activate();
|
|
| 219 | + } |
|
| 215 | 220 | break; |
| 216 | 221 | case 303 : |
| 217 | - if(get_class($this) !== 'Error303Controller') |
|
| 218 | - Loader::loadNew('controller', '/Error303Controller', array($uri))->activate(); |
|
| 222 | + if(get_class($this) !== 'Error303Controller') {
|
|
| 223 | + Loader::loadNew('controller', '/Error303Controller', array($uri))->activate();
|
|
| 224 | + } |
|
| 219 | 225 | break; |
| 220 | 226 | } |
| 221 | 227 | } |
@@ -262,18 +268,19 @@ discard block |
||
| 262 | 268 | $comment_object->url = $comment->url; |
| 263 | 269 | $comment_object->trusted = $comment->trusted; |
| 264 | 270 | |
| 265 | - if($comment->reply == 0 && Request::getPost('type') == $comment->id) |
|
| 266 | - $comment_object->errors = $this->comment_errors; |
|
| 267 | - else |
|
| 268 | - $comment_object->errors = array(); |
|
| 271 | + if($comment->reply == 0 && Request::getPost('type') == $comment->id) {
|
|
| 272 | + $comment_object->errors = $this->comment_errors; |
|
| 273 | + } else {
|
|
| 274 | + $comment_object->errors = array(); |
|
| 275 | + } |
|
| 269 | 276 | |
| 270 | 277 | if($comment->reply == 0) |
| 271 | 278 | { |
| 272 | 279 | $comment_object->replies = array(); |
| 273 | 280 | $comment_array[$comment->id] = $comment_object; |
| 274 | - } |
|
| 275 | - else |
|
| 276 | - $comment_array[$comment->reply]->replies[$comment->id] = $comment_object; |
|
| 281 | + } else {
|
|
| 282 | + $comment_array[$comment->reply]->replies[$comment->id] = $comment_object; |
|
| 283 | + } |
|
| 277 | 284 | } |
| 278 | 285 | |
| 279 | 286 | $comment_count = CommentCollector::getCommentCountForURL($site, $path); |
@@ -298,22 +305,26 @@ discard block |
||
| 298 | 305 | $commenter->website = ''; |
| 299 | 306 | |
| 300 | 307 | $commenter_cookie = Cookie::instance('Commenter'); |
| 301 | - if(!$commenter_cookie->exists()) |
|
| 302 | - return $commenter; |
|
| 308 | + if(!$commenter_cookie->exists()) {
|
|
| 309 | + return $commenter; |
|
| 310 | + } |
|
| 303 | 311 | |
| 304 | 312 | $commenter_cookie_value = $commenter_cookie->getValue(); |
| 305 | 313 | $commenter_cookie_value = json_decode($commenter_cookie_value); |
| 306 | 314 | |
| 307 | - if($commenter_cookie_value === NULL) |
|
| 308 | - return $commenter; |
|
| 315 | + if($commenter_cookie_value === NULL) {
|
|
| 316 | + return $commenter; |
|
| 317 | + } |
|
| 309 | 318 | |
| 310 | - if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) |
|
| 311 | - return $commenter; |
|
| 319 | + if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) {
|
|
| 320 | + return $commenter; |
|
| 321 | + } |
|
| 312 | 322 | |
| 313 | 323 | $commenter_object = CommentCollector::getCommenterByFields($commenter_cookie_value->name, $commenter_cookie_value->email, (isset($commenter_cookie_value->website) ? $commenter_cookie_value->website : '')); |
| 314 | 324 | |
| 315 | - if($commenter_object === NULL) |
|
| 316 | - return $commenter; |
|
| 325 | + if($commenter_object === NULL) {
|
|
| 326 | + return $commenter; |
|
| 327 | + } |
|
| 317 | 328 | |
| 318 | 329 | $commenter->id = $commenter_object->id; |
| 319 | 330 | $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 | { |
@@ -62,6 +62,9 @@ |
||
| 62 | 62 | $this->is_trimmed = true; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | + /** |
|
| 66 | + * @param string $content |
|
| 67 | + */ |
|
| 65 | 68 | private function trim_html_string($content, $length) |
| 66 | 69 | {
|
| 67 | 70 | $content = preg_replace(self::$PHOTO_PLACEHOLDER_MATCH, '', $content); |
@@ -33,17 +33,19 @@ discard block |
||
| 33 | 33 | return; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if(count($args) == 2) |
|
| 37 | - $etc = $args[1]; |
|
| 38 | - else |
|
| 39 | - $etc = self::$ETC; |
|
| 36 | + if(count($args) == 2) {
|
|
| 37 | + $etc = $args[1]; |
|
| 38 | + } else {
|
|
| 39 | + $etc = self::$ETC; |
|
| 40 | + } |
|
| 40 | 41 | |
| 41 | 42 | $length = $args[0]; |
| 42 | 43 | |
| 43 | - if($length < strlen($this->content)) |
|
| 44 | - $this->trim_string($length); |
|
| 45 | - else |
|
| 46 | - $etc = ''; |
|
| 44 | + if($length < strlen($this->content)) {
|
|
| 45 | + $this->trim_string($length); |
|
| 46 | + } else {
|
|
| 47 | + $etc = ''; |
|
| 48 | + } |
|
| 47 | 49 | $this->check_exclude_tags(); |
| 48 | 50 | $this->close_tags($etc); |
| 49 | 51 | } |
@@ -54,8 +56,9 @@ discard block |
||
| 54 | 56 | |
| 55 | 57 | $last_right_bracket_position = strripos($content, self::$RIGHT_BRACKET); |
| 56 | 58 | $last_left_bracket_position = strripos($content, self::$LEFT_BRACKET); |
| 57 | - if($last_left_bracket_position > $last_right_bracket_position) |
|
| 58 | - $content = substr($content, 0, $last_left_bracket_position); |
|
| 59 | + if($last_left_bracket_position > $last_right_bracket_position) {
|
|
| 60 | + $content = substr($content, 0, $last_left_bracket_position); |
|
| 61 | + } |
|
| 59 | 62 | $content = trim($content); |
| 60 | 63 | |
| 61 | 64 | $this->content = $content; |
@@ -76,14 +79,16 @@ discard block |
||
| 76 | 79 | foreach($matches[0] as $match) |
| 77 | 80 | { |
| 78 | 81 | $max_length += strlen($match[0]); |
| 79 | - if($max_length <= $match[1]) |
|
| 80 | - break; |
|
| 82 | + if($max_length <= $match[1]) {
|
|
| 83 | + break; |
|
| 84 | + } |
|
| 81 | 85 | |
| 82 | 86 | $content = substr($content, 0, $match[1]) . $match[0] . substr($content, $match[1]); |
| 83 | 87 | } |
| 84 | 88 | |
| 85 | - if(substr($content, -7) == '</p><p>') |
|
| 86 | - $content = substr($content, 0, -7); |
|
| 89 | + if(substr($content, -7) == '</p><p>') {
|
|
| 90 | + $content = substr($content, 0, -7); |
|
| 91 | + } |
|
| 87 | 92 | |
| 88 | 93 | return $content; |
| 89 | 94 | } |
@@ -118,9 +123,9 @@ discard block |
||
| 118 | 123 | { |
| 119 | 124 | $key = array_search($tag, $open_tags); |
| 120 | 125 | unset($open_tags[$key]); |
| 121 | - } |
|
| 122 | - else |
|
| 123 | - $open_tags[] = $tag; |
|
| 126 | + } else {
|
|
| 127 | + $open_tags[] = $tag; |
|
| 128 | + } |
|
| 124 | 129 | } |
| 125 | 130 | |
| 126 | 131 | $open_tags = array_reverse($open_tags); |
@@ -128,13 +133,14 @@ discard block |
||
| 128 | 133 | { |
| 129 | 134 | foreach($open_tags as $key => $open_tag) |
| 130 | 135 | { |
| 131 | - if($key == count($open_tags) - 1) |
|
| 132 | - $content .= $etc; |
|
| 136 | + if($key == count($open_tags) - 1) {
|
|
| 137 | + $content .= $etc; |
|
| 138 | + } |
|
| 133 | 139 | $content .= "</{$open_tag}>"; |
| 134 | 140 | } |
| 135 | - } |
|
| 136 | - else |
|
| 137 | - $content .= $etc; |
|
| 141 | + } else {
|
|
| 142 | + $content .= $etc; |
|
| 143 | + } |
|
| 138 | 144 | |
| 139 | 145 | $this->content = $content; |
| 140 | 146 | } |