@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | * Constructor |
| 75 | 75 | * @param mixed $params associative array of parameters. See README.md |
| 76 | 76 | */ |
| 77 | - function __construct($params=null) { |
|
| 78 | - $this->ci =& /** @scrutinizer ignore-call */ get_instance(); |
|
| 77 | + function __construct($params = null) { |
|
| 78 | + $this->ci = & /** @scrutinizer ignore-call */ get_instance(); |
|
| 79 | 79 | $this->ci->load->database(); |
| 80 | 80 | $this->table_name = self::TABLE_PREFIX . (isset($params["name"]) ? "_" . $params["name"] : ""); |
| 81 | 81 | $this->ci->load->database(); |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @return bool True on Success, False if Not. |
| 101 | 101 | */ |
| 102 | - public function install(string $blogName=null, string $adminTableName=null, string $adminIdColumnName=null, int $adminIdColumnConstraint=null): bool { |
|
| 102 | + public function install(string $blogName = null, string $adminTableName = null, string $adminIdColumnName = null, int $adminIdColumnConstraint = null): bool { |
|
| 103 | 103 | $blogName = $blogName === null ? $this->table_name : self::TABLE_PREFIX . "_" . $blogName; |
| 104 | 104 | $this->ci->load->dbforge(); |
| 105 | 105 | $this->ci->dbforge->add_field("id"); |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * |
| 220 | 220 | * @return bool True if sucessfull without errors, false if not. |
| 221 | 221 | */ |
| 222 | - public function loadEditor(string $callback, int $postId=null, bool $w3css=true): bool { |
|
| 222 | + public function loadEditor(string $callback, int $postId = null, bool $w3css = true): bool { |
|
| 223 | 223 | $this->loadScripts($w3css); |
| 224 | 224 | $this->ci->load->helper("form"); |
| 225 | 225 | $data = array( |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * inputs. These are public string constants declared in |
| 250 | 250 | * this file. |
| 251 | 251 | */ |
| 252 | - public function savePost(int $posterId=null): string { |
|
| 252 | + public function savePost(int $posterId = null): string { |
|
| 253 | 253 | $action = $this->ci->security->xss_clean($this->ci->input->post("action")); |
| 254 | 254 | if ($action == "save") { |
| 255 | 255 | $id = $this->ci->security->xss_clean($this->ci->input->post("id")); |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | * |
| 294 | 294 | * @return array Array of posts for a given page. |
| 295 | 295 | */ |
| 296 | - public function getPosts(int $page, int $limit, bool $filter=false, bool $hits=false): array { |
|
| 296 | + public function getPosts(int $page, int $limit, bool $filter = false, bool $hits = false): array { |
|
| 297 | 297 | return $this->ci->bmanager->getPosts($page, $limit, $filter, $hits); |
| 298 | 298 | } |
| 299 | 299 | /** |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | * @param boolean $hits [description] |
| 307 | 307 | * @return [type] [description] |
| 308 | 308 | */ |
| 309 | - public function renderPostItems($view=null, $callback=null, $empty_view=null, $page=1, $limit=5, $filter=false, $hits=false, $slug=true) { |
|
| 309 | + public function renderPostItems($view = null, $callback = null, $empty_view = null, $page = 1, $limit = 5, $filter = false, $hits = false, $slug = true) { |
|
| 310 | 310 | if ($view == null || $empty_view == null) $this->ci->load->bind("francis94c/blog", $blogger); |
| 311 | 311 | $posts = $this->getPosts($page, $limit, $filter, $hits); |
| 312 | 312 | if (count($posts) == 0) { |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | * @param boolean $filter [description] |
| 333 | 333 | * @return [type] [description] |
| 334 | 334 | */ |
| 335 | - public function getRecentPosts($limit=5, $filter=false) { |
|
| 335 | + public function getRecentPosts($limit = 5, $filter = false) { |
|
| 336 | 336 | return $this->ci->bmanager->getRecentPosts($limit, $filter); |
| 337 | 337 | } |
| 338 | 338 | /** |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | * @param [type] $view [description] |
| 342 | 342 | * @return [type] [description] |
| 343 | 343 | */ |
| 344 | - public function renderPost($post, $view=null) { |
|
| 344 | + public function renderPost($post, $view = null) { |
|
| 345 | 345 | if (!is_array($post)) $post = $this->ci->bmanager->getPost($post); |
| 346 | 346 | if (!$post) return false; |
| 347 | 347 | $post["content"] = $this->ci->parsedown->text($post["content"]); |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | * @param [type] $postId [description] |
| 378 | 378 | * @return [type] [description] |
| 379 | 379 | */ |
| 380 | - public function getPost($postId, $hit=true) { |
|
| 380 | + public function getPost($postId, $hit = true) { |
|
| 381 | 381 | return $this->ci->bmanager->getPost($postId, $hit); |
| 382 | 382 | } |
| 383 | 383 | /** |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | * @param boolean $filter [description] |
| 414 | 414 | * @return [type] [description] |
| 415 | 415 | */ |
| 416 | - public function searchPosts($words, $page, $limit=0, $filter=false) { |
|
| 416 | + public function searchPosts($words, $page, $limit = 0, $filter = false) { |
|
| 417 | 417 | return $this->ci->bmanager->searchPosts($words, $page, $limit, $filter); |
| 418 | 418 | } |
| 419 | 419 | } |
@@ -143,7 +143,9 @@ discard block |
||
| 143 | 143 | $this->ci->dbforge->add_field($fields); |
| 144 | 144 | $this->ci->dbforge->add_field("date_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); |
| 145 | 145 | $attributes = array('ENGINE' => 'InnoDB'); |
| 146 | - if (!$this->ci->dbforge->create_table($blogName, true, $attributes)) return false; |
|
| 146 | + if (!$this->ci->dbforge->create_table($blogName, true, $attributes)) { |
|
| 147 | + return false; |
|
| 148 | + } |
|
| 147 | 149 | return true; |
| 148 | 150 | } |
| 149 | 151 | /** |
@@ -263,7 +265,9 @@ discard block |
||
| 263 | 265 | } elseif ($action == "publish" || $action == "createAndPublish") { |
| 264 | 266 | if ($action == "publish") { |
| 265 | 267 | $id = $this->ci->security->xss_clean($this->ci->input->post("id")); |
| 266 | - if ($id == "") return self::ABORT; |
|
| 268 | + if ($id == "") { |
|
| 269 | + return self::ABORT; |
|
| 270 | + } |
|
| 267 | 271 | $this->ci->bmanager->savePost($id, $this->ci->security->xss_clean($this->ci->input->post("title")), $this->ci->security->xss_clean($this->ci->input->post("editor")), $posterId); |
| 268 | 272 | $this->ci->bmanager->publishPost($id, true); |
| 269 | 273 | return self::PUBLISH; |
@@ -274,7 +278,9 @@ discard block |
||
| 274 | 278 | return self::ABORT; |
| 275 | 279 | } |
| 276 | 280 | } elseif ($action == "delete") { |
| 277 | - if ($this->ci->bmanager->deletePost($this->ci->security->xss_clean($this->ci->input->post("id")))) return self::DELETE; |
|
| 281 | + if ($this->ci->bmanager->deletePost($this->ci->security->xss_clean($this->ci->input->post("id")))) { |
|
| 282 | + return self::DELETE; |
|
| 283 | + } |
|
| 278 | 284 | } |
| 279 | 285 | return self::NO_ACTION; |
| 280 | 286 | } |
@@ -307,7 +313,9 @@ discard block |
||
| 307 | 313 | * @return [type] [description] |
| 308 | 314 | */ |
| 309 | 315 | public function renderPostItems($view=null, $callback=null, $empty_view=null, $page=1, $limit=5, $filter=false, $hits=false, $slug=true) { |
| 310 | - if ($view == null || $empty_view == null) $this->ci->load->bind("francis94c/blog", $blogger); |
|
| 316 | + if ($view == null || $empty_view == null) { |
|
| 317 | + $this->ci->load->bind("francis94c/blog", $blogger); |
|
| 318 | + } |
|
| 311 | 319 | $posts = $this->getPosts($page, $limit, $filter, $hits); |
| 312 | 320 | if (count($posts) == 0) { |
| 313 | 321 | if ($empty_view == null) { $blogger->load->view("empty"); } else { |
@@ -342,8 +350,12 @@ discard block |
||
| 342 | 350 | * @return [type] [description] |
| 343 | 351 | */ |
| 344 | 352 | public function renderPost($post, $view=null) { |
| 345 | - if (!is_array($post)) $post = $this->ci->bmanager->getPost($post); |
|
| 346 | - if (!$post) return false; |
|
| 353 | + if (!is_array($post)) { |
|
| 354 | + $post = $this->ci->bmanager->getPost($post); |
|
| 355 | + } |
|
| 356 | + if (!$post) { |
|
| 357 | + return false; |
|
| 358 | + } |
|
| 347 | 359 | $post["content"] = $this->ci->parsedown->text($post["content"]); |
| 348 | 360 | if ($view == null) { |
| 349 | 361 | $this->ci->load->splint("francis94c/blog", "-post_item", $post); |
@@ -361,7 +373,9 @@ discard block |
||
| 361 | 373 | $data = array(); |
| 362 | 374 | $data["title"] = $post["title"]; |
| 363 | 375 | $data["description"] = substr($post["content"], 0, 154); |
| 364 | - if (isset($post["share_image"])) $data["image_link"] = $post["share_image"]; |
|
| 376 | + if (isset($post["share_image"])) { |
|
| 377 | + $data["image_link"] = $post["share_image"]; |
|
| 378 | + } |
|
| 365 | 379 | $data["url"] = current_url(); |
| 366 | 380 | return $this->ci->load->splint(self::PACKAGE, "-meta_og", $data, true); |
| 367 | 381 | } |