@@ -27,8 +27,8 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | const ABORT = "abortAction"; |
| 29 | 29 | |
| 30 | - function __construct($params=null) { |
|
| 31 | - $this->ci =& get_instance(); |
|
| 30 | + function __construct($params = null) { |
|
| 31 | + $this->ci = & get_instance(); |
|
| 32 | 32 | $this->ci->load->database(); |
| 33 | 33 | $this->table_name = self::TABLE_PREFIX . (isset($params["name"]) ? "_" . $params["name"] : ""); |
| 34 | 34 | $this->ci->load->database(); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @param [type] $adminIdColumnConstraint [description] |
| 46 | 46 | * @return [type] [description] |
| 47 | 47 | */ |
| 48 | - public function install($blogName=null, $adminTableName = null, $adminIdColumnName = null, $adminIdColumnConstraint = null) { |
|
| 48 | + public function install($blogName = null, $adminTableName = null, $adminIdColumnName = null, $adminIdColumnConstraint = null) { |
|
| 49 | 49 | $blogName = $blogName == null ? $this->table_name : self::TABLE_PREFIX . "_" . $blogName; |
| 50 | 50 | $this->ci->load->dbforge(); |
| 51 | 51 | $this->ci->dbforge->add_field("id"); |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * @param boolean $w3css [description] |
| 148 | 148 | * @return [type] [description] |
| 149 | 149 | */ |
| 150 | - public function loadEditor($callback, $postId=null, $w3css=true) { |
|
| 150 | + public function loadEditor($callback, $postId = null, $w3css = true) { |
|
| 151 | 151 | $this->loadScripts($w3css); |
| 152 | 152 | $this->ci->load->helper("form"); |
| 153 | 153 | $data = array( |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * @param [type] $posterId [description] |
| 170 | 170 | * @return [type] [description] |
| 171 | 171 | */ |
| 172 | - public function savePost($posterId=null) { |
|
| 172 | + public function savePost($posterId = null) { |
|
| 173 | 173 | $action = $this->ci->security->xss_clean($this->ci->input->post("action")); |
| 174 | 174 | if ($action == "save") { |
| 175 | 175 | $id = $this->ci->security->xss_clean($this->ci->input->post("id")); |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | * return all posts. false by default. |
| 206 | 206 | * @return array Array of posts for a given page. |
| 207 | 207 | */ |
| 208 | - public function getPosts($page, $limit, $filter=false, $hits=false) { |
|
| 208 | + public function getPosts($page, $limit, $filter = false, $hits = false) { |
|
| 209 | 209 | return $this->ci->bmanager->getPosts($page, $limit, $filter, $hits); |
| 210 | 210 | } |
| 211 | 211 | /** |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * @param boolean $hits [description] |
| 219 | 219 | * @return [type] [description] |
| 220 | 220 | */ |
| 221 | - public function renderPostItems($view=null, $callback=null, $empty_view=null, $page=1, $limit=5, $filter=false, $hits=false, $slug=true) { |
|
| 221 | + public function renderPostItems($view = null, $callback = null, $empty_view = null, $page = 1, $limit = 5, $filter = false, $hits = false, $slug = true) { |
|
| 222 | 222 | if ($view == null || $empty_view == null) $this->ci->load->bind("francis94c/blog", $blogger); |
| 223 | 223 | $posts = $this->getPosts($page, $limit, $filter, $hits); |
| 224 | 224 | if (count($posts) == 0) { |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | * @param boolean $filter [description] |
| 245 | 245 | * @return [type] [description] |
| 246 | 246 | */ |
| 247 | - public function getRecentPosts($limit=5, $filter=false) { |
|
| 247 | + public function getRecentPosts($limit = 5, $filter = false) { |
|
| 248 | 248 | return $this->ci->bmanager->getRecentPosts($limit, $filter); |
| 249 | 249 | } |
| 250 | 250 | /** |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | * @param [type] $view [description] |
| 254 | 254 | * @return [type] [description] |
| 255 | 255 | */ |
| 256 | - public function renderPost($post, $view=null) { |
|
| 256 | + public function renderPost($post, $view = null) { |
|
| 257 | 257 | if (!is_array($post)) $post = $this->ci->bmanager->getPost($post); |
| 258 | 258 | if (!$post) return false; |
| 259 | 259 | $post["content"] = $this->ci->parsedown->text($post["content"]); |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | * @param [type] $postId [description] |
| 290 | 290 | * @return [type] [description] |
| 291 | 291 | */ |
| 292 | - public function getPost($postId, $hit=true) { |
|
| 292 | + public function getPost($postId, $hit = true) { |
|
| 293 | 293 | return $this->ci->bmanager->getPost($postId, $hit); |
| 294 | 294 | } |
| 295 | 295 | /** |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | * @param boolean $filter [description] |
| 326 | 326 | * @return [type] [description] |
| 327 | 327 | */ |
| 328 | - public function searchPosts($words, $page, $limit=0, $filter=false) { |
|
| 328 | + public function searchPosts($words, $page, $limit = 0, $filter = false) { |
|
| 329 | 329 | return $this->ci->bmanager->searchPosts($words, $page, $limit, $filter); |
| 330 | 330 | } |
| 331 | 331 | } |
@@ -89,7 +89,9 @@ discard block |
||
| 89 | 89 | $this->ci->dbforge->add_field($fields); |
| 90 | 90 | $this->ci->dbforge->add_field("date_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); |
| 91 | 91 | $attributes = array('ENGINE' => 'InnoDB'); |
| 92 | - if (!$this->ci->dbforge->create_table($blogName, true, $attributes)) return false; |
|
| 92 | + if (!$this->ci->dbforge->create_table($blogName, true, $attributes)) { |
|
| 93 | + return false; |
|
| 94 | + } |
|
| 93 | 95 | return true; |
| 94 | 96 | } |
| 95 | 97 | /** |
@@ -183,7 +185,9 @@ discard block |
||
| 183 | 185 | } elseif ($action == "publish" || $action == "createAndPublish") { |
| 184 | 186 | if ($action == "publish") { |
| 185 | 187 | $id = $this->ci->security->xss_clean($this->ci->input->post("id")); |
| 186 | - if ($id == "") return self::ABORT; |
|
| 188 | + if ($id == "") { |
|
| 189 | + return self::ABORT; |
|
| 190 | + } |
|
| 187 | 191 | $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); |
| 188 | 192 | $this->ci->bmanager->publishPost($id, true); |
| 189 | 193 | return self::PUBLISH; |
@@ -192,7 +196,9 @@ discard block |
||
| 192 | 196 | return self::CREATE_AND_PUBLISH; |
| 193 | 197 | } |
| 194 | 198 | } elseif ($action == "delete") { |
| 195 | - if ($this->ci->bmanager->deletePost($this->ci->security->xss_clean($this->ci->input->post("id")))) return self::DELETE; |
|
| 199 | + if ($this->ci->bmanager->deletePost($this->ci->security->xss_clean($this->ci->input->post("id")))) { |
|
| 200 | + return self::DELETE; |
|
| 201 | + } |
|
| 196 | 202 | } |
| 197 | 203 | return false; |
| 198 | 204 | } |
@@ -219,7 +225,9 @@ discard block |
||
| 219 | 225 | * @return [type] [description] |
| 220 | 226 | */ |
| 221 | 227 | public function renderPostItems($view=null, $callback=null, $empty_view=null, $page=1, $limit=5, $filter=false, $hits=false, $slug=true) { |
| 222 | - if ($view == null || $empty_view == null) $this->ci->load->bind("francis94c/blog", $blogger); |
|
| 228 | + if ($view == null || $empty_view == null) { |
|
| 229 | + $this->ci->load->bind("francis94c/blog", $blogger); |
|
| 230 | + } |
|
| 223 | 231 | $posts = $this->getPosts($page, $limit, $filter, $hits); |
| 224 | 232 | if (count($posts) == 0) { |
| 225 | 233 | if ($empty_view == null) { $blogger->load->view("empty"); } else { |
@@ -254,8 +262,12 @@ discard block |
||
| 254 | 262 | * @return [type] [description] |
| 255 | 263 | */ |
| 256 | 264 | public function renderPost($post, $view=null) { |
| 257 | - if (!is_array($post)) $post = $this->ci->bmanager->getPost($post); |
|
| 258 | - if (!$post) return false; |
|
| 265 | + if (!is_array($post)) { |
|
| 266 | + $post = $this->ci->bmanager->getPost($post); |
|
| 267 | + } |
|
| 268 | + if (!$post) { |
|
| 269 | + return false; |
|
| 270 | + } |
|
| 259 | 271 | $post["content"] = $this->ci->parsedown->text($post["content"]); |
| 260 | 272 | if ($view == null) { |
| 261 | 273 | $this->ci->load->splint("francis94c/blog", "-post_item", $post); |
@@ -273,7 +285,9 @@ discard block |
||
| 273 | 285 | $data = array(); |
| 274 | 286 | $data["title"] = $post["title"]; |
| 275 | 287 | $data["description"] = substr($post["content"], 0, 154); |
| 276 | - if (isset($post["share_image"])) $data["image_link"] = $post["share_image"]; |
|
| 288 | + if (isset($post["share_image"])) { |
|
| 289 | + $data["image_link"] = $post["share_image"]; |
|
| 290 | + } |
|
| 277 | 291 | $data["url"] = current_url(); |
| 278 | 292 | return $this->ci->load->splint(self::PACKAGE, "-meta_og", $data, true); |
| 279 | 293 | } |
@@ -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); |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | * [setUp description] |
| 14 | 14 | */ |
| 15 | 15 | public static function setUpBeforeClass(): void { |
| 16 | - self::$ci =& get_instance(); |
|
| 16 | + self::$ci = & get_instance(); |
|
| 17 | 17 | self::$ci->load->database('mysqli://root@localhost/test_db'); |
| 18 | 18 | $queries = [ |
| 19 | 19 | "CREATE TABLE IF NOT EXISTS admins (id INT(7) AUTO_INCREMENT PRIMARY KEY, name VARCHAR(20) NOT NULL, password TEXT NOT NULL) Engine=InnoDB;", |