@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | </textarea> |
| 48 | 48 | </div> |
| 49 | 49 | <?php |
| 50 | -$ci =& get_instance(); |
|
| 50 | +$ci = & get_instance(); |
|
| 51 | 51 | $ci->load->splint("francis94c/ci-parsedown", "+Parsedown", null, "parsedown"); |
| 52 | 52 | ?> |
| 53 | 53 | <div class="w3-padding w3-margin w3-border w3-round" id="preview"> |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * @return [type] [description] |
| 77 | 77 | */ |
| 78 | 78 | function saveAndPublish() { |
| 79 | - document.getElementById("action").value = <?=$type == "edit" ? "\"publish\"" : "\"createAndPublish\"";?>; |
|
| 79 | + document.getElementById("action").value = <?=$type == "edit" ? "\"publish\"" : "\"createAndPublish\""; ?>; |
|
| 80 | 80 | document.getElementById("postForm").submit(); |
| 81 | 81 | } |
| 82 | 82 | /** |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | </script> |
| 105 | 105 | <input type="hidden" name="id" value="<?=$type == "edit" ? $id : ""?>"/> |
| 106 | 106 | <input id="action" type="hidden" name="action" value="publish"/> |
| 107 | -<?=form_close();?> |
|
| 107 | +<?=form_close(); ?> |
|
| 108 | 108 | <button onclick="save();" class="w3-margin w3-button w3-teal w3-round w3-hover-theme"><?=$type == "edit" ? "Save" : "Create"?></button> |
| 109 | 109 | <button onclick="promptPublish();" class="w3-margin w3-button w3-teal w3-hover-theme w3-round"><?=$type == "edit" ? "Save and Publish" : "Create and Publish"?></button> |
| 110 | 110 | <?php if ($type == "edit") {?> |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | function __construct() { |
| 13 | 13 | parent::__construct(); |
| 14 | - $this->ci =& get_instance(); |
|
| 14 | + $this->ci = & get_instance(); |
|
| 15 | 15 | $this->ci->load->database(); |
| 16 | 16 | } |
| 17 | 17 | /** |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * database. Returns false if the post couldn't be |
| 41 | 41 | * created. |
| 42 | 42 | */ |
| 43 | - function createPost($title, $content, $adminId=null) { |
|
| 43 | + function createPost($title, $content, $adminId = null) { |
|
| 44 | 44 | $this->ci->load->helper("url"); |
| 45 | 45 | $data = array( |
| 46 | 46 | "title" => $title, |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @param [type] $adminId [description] |
| 60 | 60 | * @return [type] [description] |
| 61 | 61 | */ |
| 62 | - function createAndPublishPost($title, $content, $adminId=null) { |
|
| 62 | + function createAndPublishPost($title, $content, $adminId = null) { |
|
| 63 | 63 | $data = array( |
| 64 | 64 | "title" => $title, |
| 65 | 65 | "content" => $content, |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param boolean $hits order by hits. |
| 83 | 83 | * @return array Array of posts for a given page. |
| 84 | 84 | */ |
| 85 | - function getPosts($page=1, $limit=5, $filter=false, $hits=false) { |
|
| 85 | + function getPosts($page = 1, $limit = 5, $filter = false, $hits = false) { |
|
| 86 | 86 | if ($limit != 0) $this->db->limit($limit, ($page * $limit) - $limit); |
| 87 | 87 | if ($filter) $this->db->where("published", 1); |
| 88 | 88 | if ($hits) { |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * @param boolean $filter [description] |
| 99 | 99 | * @return [type] [description] |
| 100 | 100 | */ |
| 101 | - function getRecentPosts($limit=5, $filter=false) { |
|
| 101 | + function getRecentPosts($limit = 5, $filter = false) { |
|
| 102 | 102 | if ($limit != null && $limit != null) $this->db->limit($limit); |
| 103 | 103 | if ($filter) $this->db->where("published", 1); |
| 104 | 104 | $this->db->order_by("id", "DESC"); |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @return bool True on success, False if not. |
| 114 | 114 | */ |
| 115 | 115 | function savePost($postId, $title, $content) { |
| 116 | - $data = array ( |
|
| 116 | + $data = array( |
|
| 117 | 117 | "title" => $title, |
| 118 | 118 | "content" => $content, |
| 119 | 119 | "slug" => url_title($title) |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @param int $postId ID of the post to retrieve. |
| 128 | 128 | * @return array An associative array for the Posts's data. |
| 129 | 129 | */ |
| 130 | - function getPost($postId, $hit=true) { |
|
| 130 | + function getPost($postId, $hit = true) { |
|
| 131 | 131 | if (is_numeric($postId)) { |
| 132 | 132 | $this->db->where("id", $postId); |
| 133 | 133 | } else { |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | $this->db->update($this->table_name); |
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | - $post = $query->result_array()[0]; |
|
| 146 | + $post = $query->result_array()[0]; |
|
| 147 | 147 | $images = array(); |
| 148 | 148 | // Fetch all images in post. |
| 149 | 149 | preg_match("/<img\s[^>]*?src\s*=\s*['\"]([^'\"]*?)['\"][^>]*?>/", $post["content"], $images); |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | * @param boolean $filter [description] |
| 207 | 207 | * @return [type] [description] |
| 208 | 208 | */ |
| 209 | - function searchPosts($words, $page, $limit=0, $filter=false) { |
|
| 209 | + function searchPosts($words, $page, $limit = 0, $filter = false) { |
|
| 210 | 210 | if ($limit != 0) $this->db->limit($limit, ($page * $limit) - $limit); |
| 211 | 211 | if ($filter) $this->db->where("published", 1); |
| 212 | 212 | $this->db->like("title", $words); |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | * Prerquisites for the Unit Tests. |
| 15 | 15 | */ |
| 16 | 16 | public static function setUpBeforeClass(): void { |
| 17 | - self::$ci =& get_instance(); |
|
| 17 | + self::$ci = & get_instance(); |
|
| 18 | 18 | self::$ci->load->database('mysqli://root@localhost/test_db'); |
| 19 | 19 | $queries = [ |
| 20 | 20 | "CREATE TABLE IF NOT EXISTS admins (id INT(7) AUTO_INCREMENT PRIMARY KEY, name VARCHAR(20) NOT NULL, password TEXT NOT NULL) Engine=InnoDB;", |
@@ -69,8 +69,8 @@ discard block |
||
| 69 | 69 | * Constructor |
| 70 | 70 | * @param mixed $params associative array of parameters. See README.md |
| 71 | 71 | */ |
| 72 | - function __construct($params=null) { |
|
| 73 | - $this->ci =& /** @scrutinizer ignore-call */ get_instance(); |
|
| 72 | + function __construct($params = null) { |
|
| 73 | + $this->ci = & /** @scrutinizer ignore-call */ get_instance(); |
|
| 74 | 74 | $this->ci->load->database(); |
| 75 | 75 | $this->table_name = self::TABLE_PREFIX . (isset($params["name"]) ? "_" . $params["name"] : ""); |
| 76 | 76 | $this->ci->load->database(); |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @return bool True on Success, False if Not. |
| 96 | 96 | */ |
| 97 | - public function install(string $blogName=null, string $adminTableName=null, string $adminIdColumnName=null, int $adminIdColumnConstraint=null): bool { |
|
| 97 | + public function install(string $blogName = null, string $adminTableName = null, string $adminIdColumnName = null, int $adminIdColumnConstraint = null): bool { |
|
| 98 | 98 | $blogName = $blogName === null ? $this->table_name : self::TABLE_PREFIX . "_" . $blogName; |
| 99 | 99 | $this->ci->load->dbforge(); |
| 100 | 100 | $this->ci->dbforge->add_field("id"); |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * |
| 215 | 215 | * @return bool True if sucessfull without errors, false if not. |
| 216 | 216 | */ |
| 217 | - public function loadEditor(string $callback, int $postId=null, bool $w3css=true): bool { |
|
| 217 | + public function loadEditor(string $callback, int $postId = null, bool $w3css = true): bool { |
|
| 218 | 218 | $this->loadScripts($w3css); |
| 219 | 219 | $this->ci->load->helper("form"); |
| 220 | 220 | $data = array( |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | * inputs. These are public string constants declared in |
| 245 | 245 | * this file. |
| 246 | 246 | */ |
| 247 | - public function savePost(int $posterId=null): string { |
|
| 247 | + public function savePost(int $posterId = null): string { |
|
| 248 | 248 | $action = $this->ci->security->xss_clean($this->ci->input->post("action")); |
| 249 | 249 | if ($action == "save") { |
| 250 | 250 | $id = $this->ci->security->xss_clean($this->ci->input->post("id")); |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * return all posts. false by default. |
| 283 | 283 | * @return array Array of posts for a given page. |
| 284 | 284 | */ |
| 285 | - public function getPosts($page, $limit, $filter=false, $hits=false) { |
|
| 285 | + public function getPosts($page, $limit, $filter = false, $hits = false) { |
|
| 286 | 286 | return $this->ci->bmanager->getPosts($page, $limit, $filter, $hits); |
| 287 | 287 | } |
| 288 | 288 | /** |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | * @param boolean $hits [description] |
| 296 | 296 | * @return [type] [description] |
| 297 | 297 | */ |
| 298 | - public function renderPostItems($view=null, $callback=null, $empty_view=null, $page=1, $limit=5, $filter=false, $hits=false, $slug=true) { |
|
| 298 | + public function renderPostItems($view = null, $callback = null, $empty_view = null, $page = 1, $limit = 5, $filter = false, $hits = false, $slug = true) { |
|
| 299 | 299 | if ($view == null || $empty_view == null) $this->ci->load->bind("francis94c/blog", $blogger); |
| 300 | 300 | $posts = $this->getPosts($page, $limit, $filter, $hits); |
| 301 | 301 | if (count($posts) == 0) { |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | * @param boolean $filter [description] |
| 322 | 322 | * @return [type] [description] |
| 323 | 323 | */ |
| 324 | - public function getRecentPosts($limit=5, $filter=false) { |
|
| 324 | + public function getRecentPosts($limit = 5, $filter = false) { |
|
| 325 | 325 | return $this->ci->bmanager->getRecentPosts($limit, $filter); |
| 326 | 326 | } |
| 327 | 327 | /** |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | * @param [type] $view [description] |
| 331 | 331 | * @return [type] [description] |
| 332 | 332 | */ |
| 333 | - public function renderPost($post, $view=null) { |
|
| 333 | + public function renderPost($post, $view = null) { |
|
| 334 | 334 | if (!is_array($post)) $post = $this->ci->bmanager->getPost($post); |
| 335 | 335 | if (!$post) return false; |
| 336 | 336 | $post["content"] = $this->ci->parsedown->text($post["content"]); |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | * @param [type] $postId [description] |
| 367 | 367 | * @return [type] [description] |
| 368 | 368 | */ |
| 369 | - public function getPost($postId, $hit=true) { |
|
| 369 | + public function getPost($postId, $hit = true) { |
|
| 370 | 370 | return $this->ci->bmanager->getPost($postId, $hit); |
| 371 | 371 | } |
| 372 | 372 | /** |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | * @param boolean $filter [description] |
| 403 | 403 | * @return [type] [description] |
| 404 | 404 | */ |
| 405 | - public function searchPosts($words, $page, $limit=0, $filter=false) { |
|
| 405 | + public function searchPosts($words, $page, $limit = 0, $filter = false) { |
|
| 406 | 406 | return $this->ci->bmanager->searchPosts($words, $page, $limit, $filter); |
| 407 | 407 | } |
| 408 | 408 | } |