@@ -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); |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | $tag_clause = "'{$tag_clause}'"; |
| 81 | 81 | |
| 82 | 82 | $exclude_clause = ''; |
| 83 | - if(count($exclude_posts) > 0) |
|
| 83 | + if (count($exclude_posts) > 0) |
|
| 84 | 84 | { |
| 85 | 85 | $exclude_clause .= " && `ptlink`.`post_id` NOT IN ('"; |
| 86 | 86 | $exclude_clause .= implode("', '", $exclude_posts); |
@@ -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,7 +163,7 @@ |
||
| 163 | 163 | { |
| 164 | 164 | $path = self::escape($path); |
| 165 | 165 | |
| 166 | - if($commenter != 0) |
|
| 166 | + if ($commenter != 0) |
|
| 167 | 167 | $trusted_commenter_clause = "(`commenter`.`trusted` = '1' || `commenter`.`id` = '{$commenter}')"; |
| 168 | 168 | else |
| 169 | 169 | $trusted_commenter_clause = "`commenter`.`trusted` = '1'"; |
@@ -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,7 +37,7 @@ discard block |
||
| 37 | 37 | Loader::load('collector', 'image/PhotoCollector'); |
| 38 | 38 | $photo_result = PhotoCollector::getRow($id); |
| 39 | 39 | |
| 40 | - if($photo_result == null) |
|
| 40 | + if ($photo_result == null) |
|
| 41 | 41 | return; |
| 42 | 42 | |
| 43 | 43 | $name = $photo_result->name; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | $tag_result = TagCollector::getTagsForPost($post->id); |
| 89 | 89 | $tag_array = array(); |
| 90 | - foreach($tag_result as $tag) |
|
| 90 | + foreach ($tag_result as $tag) |
|
| 91 | 91 | { |
| 92 | 92 | $tag_object = new stdclass(); |
| 93 | 93 | $tag_object->name = $tag->tag; |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | { |
| 102 | 102 | $body = $post->body; |
| 103 | 103 | |
| 104 | - if($trim) |
|
| 104 | + if ($trim) |
|
| 105 | 105 | $body = Content::instance('SmartTrim', $body)->activate(self::$LENGTH_OF_TRIMMED_POST); |
| 106 | 106 | |
| 107 | 107 | $body = Content::instance('FixPhoto', $body)->activate(false, 'standard'); |
@@ -126,9 +126,9 @@ discard block |
||
| 126 | 126 | $maximum_tag_count = $this->get_maximum_tag_count($tag_result); |
| 127 | 127 | |
| 128 | 128 | $cloud_array = array(); |
| 129 | - foreach($tag_result as $tag) |
|
| 129 | + foreach ($tag_result as $tag) |
|
| 130 | 130 | { |
| 131 | - if($tag->tag_count < self::$MINIMUM_TAG_COUNT) |
|
| 131 | + if ($tag->tag_count < self::$MINIMUM_TAG_COUNT) |
|
| 132 | 132 | continue; |
| 133 | 133 | |
| 134 | 134 | $tag_object = new stdclass(); |
@@ -145,9 +145,9 @@ discard block |
||
| 145 | 145 | { |
| 146 | 146 | $maximum = 1; |
| 147 | 147 | |
| 148 | - foreach($tag_result as $tag) |
|
| 148 | + foreach ($tag_result as $tag) |
|
| 149 | 149 | { |
| 150 | - if($tag->tag_count > $maximum) |
|
| 150 | + if ($tag->tag_count > $maximum) |
|
| 151 | 151 | $maximum = $tag->tag_count; |
| 152 | 152 | } |
| 153 | 153 | return $maximum; |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | $comment_array = CommentCollector::getRecentBlogComments(self::$RECENT_COMMENT_COUNT); |
| 159 | 159 | |
| 160 | 160 | $array = array(); |
| 161 | - foreach($comment_array as $comment) |
|
| 161 | + foreach ($comment_array as $comment) |
|
| 162 | 162 | { |
| 163 | 163 | $body = $comment->body; |
| 164 | 164 | $body = strip_tags($body); |
@@ -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,7 +38,7 @@ discard block |
||
| 38 | 38 | 'date' => date('Y'))); |
| 39 | 39 | |
| 40 | 40 | Loader::loadInstance('utility', 'Database'); |
| 41 | - if(Database::isConnected() === false) |
|
| 41 | + if (Database::isConnected() === false) |
|
| 42 | 42 | $this->unavailable(); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $post_result = $activityRepository->getActivities(5); |
| 64 | 64 | |
| 65 | 65 | $post_array = array(); |
| 66 | - foreach($post_result as $row) { |
|
| 66 | + foreach ($post_result as $row) { |
|
| 67 | 67 | array_push($post_array, $this->expand_post($row)); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | $headers = $this->headers; |
| 100 | 100 | Header::$headers(); |
| 101 | 101 | Loader::load('view', '/Head', $this->data_array['head']); |
| 102 | - foreach($this->body_view_array as $view) |
|
| 102 | + foreach ($this->body_view_array as $view) |
|
| 103 | 103 | { |
| 104 | - if(substr($view, 0, 1) == '/') |
|
| 104 | + if (substr($view, 0, 1) == '/') |
|
| 105 | 105 | Loader::load('view', $view, $this->data_array['body']); |
| 106 | 106 | else |
| 107 | 107 | Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']); |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE)); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - if($view == '/404' || $view == '/503') |
|
| 116 | + if ($view == '/404' || $view == '/503') |
|
| 117 | 117 | exit; |
| 118 | 118 | } |
| 119 | 119 | |
@@ -169,10 +169,10 @@ discard block |
||
| 169 | 169 | |
| 170 | 170 | private function load_assets() |
| 171 | 171 | { |
| 172 | - $css_array = array_map(function ($stylesheet) { |
|
| 172 | + $css_array = array_map(function($stylesheet) { |
|
| 173 | 173 | return "/css/{$stylesheet}.css"; |
| 174 | 174 | }, $this->css_array); |
| 175 | - $js_array = array_map(function ($script) { |
|
| 175 | + $js_array = array_map(function($script) { |
|
| 176 | 176 | if (substr($script, 0, 4) == 'http') { |
| 177 | 177 | return $script; |
| 178 | 178 | } |
@@ -190,26 +190,26 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | protected function eject() |
| 192 | 192 | { |
| 193 | - if(get_class($this) !== 'Error404Controller') |
|
| 193 | + if (get_class($this) !== 'Error404Controller') |
|
| 194 | 194 | Loader::loadNew('controller', '/Error404Controller')->activate(); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | protected function unavailable() |
| 198 | 198 | { |
| 199 | - if(get_class($this) !== 'Error503Controller') |
|
| 199 | + if (get_class($this) !== 'Error503Controller') |
|
| 200 | 200 | Loader::loadNew('controller', '/Error503Controller')->activate(); |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | protected function redirect($uri, $method = 301) |
| 204 | 204 | { |
| 205 | - switch($method) |
|
| 205 | + switch ($method) |
|
| 206 | 206 | { |
| 207 | 207 | case 301 : |
| 208 | - if(get_class($this) !== 'Error301Controller') |
|
| 208 | + if (get_class($this) !== 'Error301Controller') |
|
| 209 | 209 | Loader::loadNew('controller', '/Error301Controller', array($uri))->activate(); |
| 210 | 210 | break; |
| 211 | 211 | case 303 : |
| 212 | - if(get_class($this) !== 'Error303Controller') |
|
| 212 | + if (get_class($this) !== 'Error303Controller') |
|
| 213 | 213 | Loader::loadNew('controller', '/Error303Controller', array($uri))->activate(); |
| 214 | 214 | break; |
| 215 | 215 | } |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | private $comment_errors; |
| 230 | 230 | protected function handle_comment_submit($site_id, $path, $redirect_url, $page_title) |
| 231 | 231 | { |
| 232 | - if(Request::hasPost() && Request::getPost('submit') == 'Submit Comment') |
|
| 232 | + if (Request::hasPost() && Request::getPost('submit') == 'Submit Comment') |
|
| 233 | 233 | { |
| 234 | 234 | $parameters = array($site_id, $path, $redirect_url, $page_title); |
| 235 | 235 | $this->comment_errors = Loader::loadNew('module', 'form/CommentSubmitModule', $parameters)->activate(); |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | $comment_array = array(); |
| 248 | 248 | $comment_result = CommentCollector::getCommentsForURL($site, $path, $commenter->id); |
| 249 | 249 | |
| 250 | - foreach($comment_result as $comment) |
|
| 250 | + foreach ($comment_result as $comment) |
|
| 251 | 251 | { |
| 252 | 252 | $comment_object = new stdclass(); |
| 253 | 253 | $comment_object->id = $comment->id; |
@@ -257,12 +257,12 @@ discard block |
||
| 257 | 257 | $comment_object->url = $comment->url; |
| 258 | 258 | $comment_object->trusted = $comment->trusted; |
| 259 | 259 | |
| 260 | - if($comment->reply == 0 && Request::getPost('type') == $comment->id) |
|
| 260 | + if ($comment->reply == 0 && Request::getPost('type') == $comment->id) |
|
| 261 | 261 | $comment_object->errors = $this->comment_errors; |
| 262 | 262 | else |
| 263 | 263 | $comment_object->errors = array(); |
| 264 | 264 | |
| 265 | - if($comment->reply == 0) |
|
| 265 | + if ($comment->reply == 0) |
|
| 266 | 266 | { |
| 267 | 267 | $comment_object->replies = array(); |
| 268 | 268 | $comment_array[$comment->id] = $comment_object; |
@@ -293,21 +293,21 @@ discard block |
||
| 293 | 293 | $commenter->website = ''; |
| 294 | 294 | |
| 295 | 295 | $commenter_cookie = Cookie::instance('Commenter'); |
| 296 | - if(!$commenter_cookie->exists()) |
|
| 296 | + if (!$commenter_cookie->exists()) |
|
| 297 | 297 | return $commenter; |
| 298 | 298 | |
| 299 | 299 | $commenter_cookie_value = $commenter_cookie->getValue(); |
| 300 | 300 | $commenter_cookie_value = json_decode($commenter_cookie_value); |
| 301 | 301 | |
| 302 | - if($commenter_cookie_value === NULL) |
|
| 302 | + if ($commenter_cookie_value === NULL) |
|
| 303 | 303 | return $commenter; |
| 304 | 304 | |
| 305 | - if(!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) |
|
| 305 | + if (!isset($commenter_cookie_value->name) || !isset($commenter_cookie_value->email)) |
|
| 306 | 306 | return $commenter; |
| 307 | 307 | |
| 308 | 308 | $commenter_object = CommentCollector::getCommenterByFields($commenter_cookie_value->name, $commenter_cookie_value->email, (isset($commenter_cookie_value->website) ? $commenter_cookie_value->website : '')); |
| 309 | 309 | |
| 310 | - if($commenter_object === NULL) |
|
| 310 | + if ($commenter_object === NULL) |
|
| 311 | 311 | return $commenter; |
| 312 | 312 | |
| 313 | 313 | $commenter->id = $commenter_object->id; |
@@ -24,6 +24,11 @@ |
||
| 24 | 24 | return Loader::getImagePath('photo', $path);
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | + /** |
|
| 28 | + * @param string $string |
|
| 29 | + * @param boolean $is_absolute |
|
| 30 | + * @param string $size |
|
| 31 | + */ |
|
| 27 | 32 | private function get_thumb($string, $is_absolute, $size) |
| 28 | 33 | {
|
| 29 | 34 | list($category, $file_name) = explode('/', $string);
|
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | protected function execute($is_absolute = false, $size = 'thumb') |
| 13 | 13 | { |
| 14 | - if(preg_match(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $match) === 1) |
|
| 14 | + if (preg_match(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $match) === 1) |
|
| 15 | 15 | $this->content = $this->get_thumb($match[1], $is_absolute, $size); |
| 16 | 16 | else |
| 17 | 17 | $this->content = self::$DEFAULT_RETURN; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | Loader::load('collector', 'image/PhotoCollector'); |
| 36 | 36 | $photo_result = PhotoCollector::fetchRow($category, $photo); |
| 37 | - if($photo_result == false) |
|
| 37 | + if ($photo_result == false) |
|
| 38 | 38 | return ''; |
| 39 | 39 | |
| 40 | 40 | $height = $file_size[1]; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $description = $photo_result->description; |
| 43 | 43 | |
| 44 | 44 | $domain = '/'; |
| 45 | - if($is_absolute) |
|
| 45 | + if ($is_absolute) |
|
| 46 | 46 | $domain = Loader::getRootUrl(); |
| 47 | 47 | |
| 48 | 48 | return sprintf(self::$IMAGE_NODE, $domain, $category, $photo, $size, $extension, $height, $width, $description); |
@@ -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,10 +10,10 @@ discard block |
||
| 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) |
|
| 13 | + if (count($matches[1]) == 0) |
|
| 14 | 14 | return; |
| 15 | 15 | |
| 16 | - foreach($matches[3] as $key => $match) |
|
| 16 | + foreach ($matches[3] as $key => $match) |
|
| 17 | 17 | { |
| 18 | 18 | $replacement = $match; |
| 19 | 19 | $replacement = $this->wrap_in_list($replacement); |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | { |
| 30 | 30 | $content_array = explode("\n", $content); |
| 31 | 31 | |
| 32 | - foreach($content_array as $key => $row) |
|
| 32 | + foreach ($content_array as $key => $row) |
|
| 33 | 33 | { |
| 34 | 34 | $new_row = ($key % 2 == 0) ? '<li class="even">' : '<li class="odd">'; |
| 35 | 35 | $new_row .= '<p>'; |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | private function highlight_code($content, $type) |
| 48 | 48 | { |
| 49 | - switch($type) |
|
| 49 | + switch ($type) |
|
| 50 | 50 | { |
| 51 | 51 | default : |
| 52 | 52 | return $content; |