@@ -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") {?> |
@@ -1,7 +1,13 @@ |
||
1 | 1 | <?php |
2 | -if (!isset($title)) $title = ""; |
|
3 | -if (!isset($content)) $content = ""; |
|
4 | -if (!isset($prompt_color)) $prompt_color = "w3-green"; |
|
2 | +if (!isset($title)) { |
|
3 | + $title = ""; |
|
4 | +} |
|
5 | +if (!isset($content)) { |
|
6 | + $content = ""; |
|
7 | +} |
|
8 | +if (!isset($prompt_color)) { |
|
9 | + $prompt_color = "w3-green"; |
|
10 | +} |
|
5 | 11 | ?> |
6 | 12 | <div id="publishModal" class="w3-modal w3-animate-opacity"> |
7 | 13 | <div class="w3-modal-content"> |
@@ -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;", |
@@ -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 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * database. Returns 0 if the post couldn't be |
45 | 45 | * created. |
46 | 46 | */ |
47 | - function createPost(string $title, string $content, int $adminId=null): int { |
|
47 | + function createPost(string $title, string $content, int $adminId = null): int { |
|
48 | 48 | $this->ci->load->helper("url"); |
49 | 49 | $data = array( |
50 | 50 | "title" => $title, |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param [type] $adminId [description] |
64 | 64 | * @return [type] [description] |
65 | 65 | */ |
66 | - function createAndPublishPost($title, $content, $adminId=null) { |
|
66 | + function createAndPublishPost($title, $content, $adminId = null) { |
|
67 | 67 | $data = array( |
68 | 68 | "title" => $title, |
69 | 69 | "content" => $content, |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param boolean $hits order by hits. |
87 | 87 | * @return array Array of posts for a given page. |
88 | 88 | */ |
89 | - function getPosts($page=1, $limit=5, $filter=false, $hits=false) { |
|
89 | + function getPosts($page = 1, $limit = 5, $filter = false, $hits = false) { |
|
90 | 90 | if ($limit != 0) $this->db->limit($limit, ($page * $limit) - $limit); |
91 | 91 | if ($filter) $this->db->where("published", 1); |
92 | 92 | if ($hits) { |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param boolean $filter [description] |
103 | 103 | * @return [type] [description] |
104 | 104 | */ |
105 | - function getRecentPosts($limit=5, $filter=false) { |
|
105 | + function getRecentPosts($limit = 5, $filter = false) { |
|
106 | 106 | if ($limit != null && $limit != null) $this->db->limit($limit); |
107 | 107 | if ($filter) $this->db->where("published", 1); |
108 | 108 | $this->db->order_by("id", "DESC"); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @return bool True on success, False if not. |
118 | 118 | */ |
119 | 119 | function savePost($postId, $title, $content): bool { |
120 | - $data = array ( |
|
120 | + $data = array( |
|
121 | 121 | "title" => $title, |
122 | 122 | "content" => $content, |
123 | 123 | "slug" => url_title($title) |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param int $postId ID of the post to retrieve. |
132 | 132 | * @return array An associative array for the Posts's data. |
133 | 133 | */ |
134 | - function getPost($postId, $hit=true) { |
|
134 | + function getPost($postId, $hit = true) { |
|
135 | 135 | if (is_numeric($postId)) { |
136 | 136 | $this->db->where("id", $postId); |
137 | 137 | } else { |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $this->db->update($this->table_name); |
148 | 148 | } |
149 | 149 | } |
150 | - $post = $query->result_array()[0]; |
|
150 | + $post = $query->result_array()[0]; |
|
151 | 151 | $images = array(); |
152 | 152 | // Fetch all images in post. |
153 | 153 | preg_match("/<img\s[^>]*?src\s*=\s*['\"]([^'\"]*?)['\"][^>]*?>/", $post["content"], $images); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @param boolean $filter [description] |
211 | 211 | * @return [type] [description] |
212 | 212 | */ |
213 | - function searchPosts($words, $page, $limit=0, $filter=false) { |
|
213 | + function searchPosts($words, $page, $limit = 0, $filter = false) { |
|
214 | 214 | if ($limit != 0) $this->db->limit($limit, ($page * $limit) - $limit); |
215 | 215 | if ($filter) $this->db->where("published", 1); |
216 | 216 | $this->db->like("title", $words); |
@@ -51,9 +51,15 @@ discard block |
||
51 | 51 | "content" => $content, |
52 | 52 | "slug" => url_title($title) |
53 | 53 | ); |
54 | - if (is_numeric($title)) $data["slug"] = "_" . $data["slug"]; |
|
55 | - if ($adminId !== null) $data["poster_id"] = $adminId; |
|
56 | - if ($this->db->insert($this->table_name, $data)) return $this->db->insert_id(); |
|
54 | + if (is_numeric($title)) { |
|
55 | + $data["slug"] = "_" . $data["slug"]; |
|
56 | + } |
|
57 | + if ($adminId !== null) { |
|
58 | + $data["poster_id"] = $adminId; |
|
59 | + } |
|
60 | + if ($this->db->insert($this->table_name, $data)) { |
|
61 | + return $this->db->insert_id(); |
|
62 | + } |
|
57 | 63 | return 0; |
58 | 64 | } |
59 | 65 | /** |
@@ -71,9 +77,15 @@ discard block |
||
71 | 77 | "published" => 1, |
72 | 78 | "date_published" => date("Y-m-d H:i:s") |
73 | 79 | ); |
74 | - if (is_numeric($title)) $data["slug"] = "_" . $data["slug"]; |
|
75 | - if ($adminId != null) $data["poster_id"] = $adminId; |
|
76 | - if ($this->db->insert($this->table_name, $data)) return $this->db->insert_id(); |
|
80 | + if (is_numeric($title)) { |
|
81 | + $data["slug"] = "_" . $data["slug"]; |
|
82 | + } |
|
83 | + if ($adminId != null) { |
|
84 | + $data["poster_id"] = $adminId; |
|
85 | + } |
|
86 | + if ($this->db->insert($this->table_name, $data)) { |
|
87 | + return $this->db->insert_id(); |
|
88 | + } |
|
77 | 89 | return false; |
78 | 90 | } |
79 | 91 | /** |
@@ -87,8 +99,12 @@ discard block |
||
87 | 99 | * @return array Array of posts for a given page. |
88 | 100 | */ |
89 | 101 | function getPosts($page=1, $limit=5, $filter=false, $hits=false) { |
90 | - if ($limit != 0) $this->db->limit($limit, ($page * $limit) - $limit); |
|
91 | - if ($filter) $this->db->where("published", 1); |
|
102 | + if ($limit != 0) { |
|
103 | + $this->db->limit($limit, ($page * $limit) - $limit); |
|
104 | + } |
|
105 | + if ($filter) { |
|
106 | + $this->db->where("published", 1); |
|
107 | + } |
|
92 | 108 | if ($hits) { |
93 | 109 | $this->db->order_by("hits", "DESC"); |
94 | 110 | } else { |
@@ -103,8 +119,12 @@ discard block |
||
103 | 119 | * @return [type] [description] |
104 | 120 | */ |
105 | 121 | function getRecentPosts($limit=5, $filter=false) { |
106 | - if ($limit != null && $limit != null) $this->db->limit($limit); |
|
107 | - if ($filter) $this->db->where("published", 1); |
|
122 | + if ($limit != null && $limit != null) { |
|
123 | + $this->db->limit($limit); |
|
124 | + } |
|
125 | + if ($filter) { |
|
126 | + $this->db->where("published", 1); |
|
127 | + } |
|
108 | 128 | $this->db->order_by("id", "DESC"); |
109 | 129 | return $this->db->get($this->table_name)->result_array(); |
110 | 130 | } |
@@ -156,7 +176,9 @@ discard block |
||
156 | 176 | $src = array(); |
157 | 177 | // Get the contents of the src tag. |
158 | 178 | preg_match("/(http|https):\/\/[a-zA-Z0-9-._\/]+/", $share_image, $src); |
159 | - if (count($src) == 0) return $post; |
|
179 | + if (count($src) == 0) { |
|
180 | + return $post; |
|
181 | + } |
|
160 | 182 | $post["share_image"] = $src[0]; |
161 | 183 | return $post; |
162 | 184 | } |
@@ -170,7 +192,9 @@ discard block |
||
170 | 192 | function getHits($postId) { |
171 | 193 | $this->db->where("id", $postId); |
172 | 194 | $query = $this->db->get($this->table_name); |
173 | - if ($query->num_rows() > 0) return $query->result()[0]->hits; |
|
195 | + if ($query->num_rows() > 0) { |
|
196 | + return $query->result()[0]->hits; |
|
197 | + } |
|
174 | 198 | return 0; |
175 | 199 | } |
176 | 200 | /** |
@@ -211,8 +235,12 @@ discard block |
||
211 | 235 | * @return [type] [description] |
212 | 236 | */ |
213 | 237 | function searchPosts($words, $page, $limit=0, $filter=false) { |
214 | - if ($limit != 0) $this->db->limit($limit, ($page * $limit) - $limit); |
|
215 | - if ($filter) $this->db->where("published", 1); |
|
238 | + if ($limit != 0) { |
|
239 | + $this->db->limit($limit, ($page * $limit) - $limit); |
|
240 | + } |
|
241 | + if ($filter) { |
|
242 | + $this->db->where("published", 1); |
|
243 | + } |
|
216 | 244 | $this->db->like("title", $words); |
217 | 245 | $this->db->or_like("content", $words); |
218 | 246 | return $this->db->get($this->table_name)->result_array(); |
@@ -284,7 +284,6 @@ |
||
284 | 284 | * submited form.] |
285 | 285 | * |
286 | 286 | * @param int $posterId ID of the publishing Admin. |
287 | - |
|
288 | 287 | * @return string Action reached while processing form inputs. |
289 | 288 | */ |
290 | 289 | private function handlePublishPost(int $posterId=null): string { |
@@ -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"); |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return bool True if sucessfull without errors, false if not. |
217 | 217 | */ |
218 | - public function loadEditor(string $callback, int $postId=null, bool $w3css=true): bool { |
|
218 | + public function loadEditor(string $callback, int $postId = null, bool $w3css = true): bool { |
|
219 | 219 | $this->loadScripts($w3css); |
220 | 220 | $this->ci->load->helper("form"); |
221 | 221 | $data = array( |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * inputs. These are public string constants declared in |
246 | 246 | * this file. |
247 | 247 | */ |
248 | - public function savePost(int $posterId=null): string { |
|
248 | + public function savePost(int $posterId = null): string { |
|
249 | 249 | $action = $this->ci->security->xss_clean($this->ci->input->post("action")); |
250 | 250 | switch ($action) { |
251 | 251 | case "save": |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return string Action taken during the pocess; Blogger::CREATE Or Blogger::EDIT |
271 | 271 | */ |
272 | - private function handleSavePost(int $posterId=null): string { |
|
272 | + private function handleSavePost(int $posterId = null): string { |
|
273 | 273 | $id = $this->ci->security->xss_clean($this->ci->input->post("id")); |
274 | 274 | if ($id != "") { |
275 | 275 | if (!$this->ci->bmanager->savePost($this->ci->input->post("id"), $this->ci->security->xss_clean($this->ci->input->post("title")), $this->ci->security->xss_clean($this->ci->input->post("editor")), $posterId)) return self::ABORT; |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | |
288 | 288 | * @return string Action reached while processing form inputs. |
289 | 289 | */ |
290 | - private function handlePublishPost(int $posterId=null): string { |
|
290 | + private function handlePublishPost(int $posterId = null): string { |
|
291 | 291 | $id = $this->ci->security->xss_clean($this->ci->input->post("id")); |
292 | 292 | if ($id == "") return self::ABORT; |
293 | 293 | if (!$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)) return self::ABORT; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * |
310 | 310 | * @return array Array of posts for a given page. |
311 | 311 | */ |
312 | - public function getPosts(int $page, int $limit, bool $filter=false, bool $hits=false): array { |
|
312 | + public function getPosts(int $page, int $limit, bool $filter = false, bool $hits = false): array { |
|
313 | 313 | return $this->ci->bmanager->getPosts($page, $limit, $filter, $hits); |
314 | 314 | } |
315 | 315 | /** |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * @param boolean $hits [description] |
323 | 323 | * @return [type] [description] |
324 | 324 | */ |
325 | - public function renderPostItems($view=null, $callback=null, $empty_view=null, $page=1, $limit=5, $filter=false, $hits=false, $slug=true) { |
|
325 | + public function renderPostItems($view = null, $callback = null, $empty_view = null, $page = 1, $limit = 5, $filter = false, $hits = false, $slug = true) { |
|
326 | 326 | if ($view == null || $empty_view == null) $this->ci->load->bind("francis94c/blog", $blogger); |
327 | 327 | $posts = $this->getPosts($page, $limit, $filter, $hits); |
328 | 328 | if (count($posts) == 0) { |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | * @param boolean $filter [description] |
349 | 349 | * @return [type] [description] |
350 | 350 | */ |
351 | - public function getRecentPosts($limit=5, $filter=false) { |
|
351 | + public function getRecentPosts($limit = 5, $filter = false) { |
|
352 | 352 | return $this->ci->bmanager->getRecentPosts($limit, $filter); |
353 | 353 | } |
354 | 354 | /** |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | * @param [type] $view [description] |
358 | 358 | * @return [type] [description] |
359 | 359 | */ |
360 | - public function renderPost($post, $view=null) { |
|
360 | + public function renderPost($post, $view = null) { |
|
361 | 361 | if (!is_array($post)) $post = $this->ci->bmanager->getPost($post); |
362 | 362 | if (!$post) return false; |
363 | 363 | $post["content"] = $this->ci->parsedown->text($post["content"]); |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * @param [type] $postId [description] |
394 | 394 | * @return [type] [description] |
395 | 395 | */ |
396 | - public function getPost($postId, $hit=true) { |
|
396 | + public function getPost($postId, $hit = true) { |
|
397 | 397 | return $this->ci->bmanager->getPost($postId, $hit); |
398 | 398 | } |
399 | 399 | /** |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | * @param boolean $filter [description] |
430 | 430 | * @return [type] [description] |
431 | 431 | */ |
432 | - public function searchPosts($words, $page, $limit=0, $filter=false) { |
|
432 | + public function searchPosts($words, $page, $limit = 0, $filter = false) { |
|
433 | 433 | return $this->ci->bmanager->searchPosts($words, $page, $limit, $filter); |
434 | 434 | } |
435 | 435 | } |
@@ -139,7 +139,9 @@ discard block |
||
139 | 139 | } |
140 | 140 | $this->ci->dbforge->add_field("date_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP"); |
141 | 141 | $attributes = array('ENGINE' => 'InnoDB'); |
142 | - if (!$this->ci->dbforge->create_table($blogName, true, $attributes)) return false; |
|
142 | + if (!$this->ci->dbforge->create_table($blogName, true, $attributes)) { |
|
143 | + return false; |
|
144 | + } |
|
143 | 145 | return true; |
144 | 146 | } |
145 | 147 | /** |
@@ -253,10 +255,14 @@ discard block |
||
253 | 255 | case "publish": |
254 | 256 | return $this->handlePublishPost($posterId); |
255 | 257 | case "createAndPublish": |
256 | - if ($this->ci->bmanager->createAndPublishPost($this->ci->security->xss_clean($this->ci->input->post("title")), $this->ci->security->xss_clean($this->ci->input->post("editor")), $posterId) !== false) return self::CREATE_AND_PUBLISH; |
|
258 | + if ($this->ci->bmanager->createAndPublishPost($this->ci->security->xss_clean($this->ci->input->post("title")), $this->ci->security->xss_clean($this->ci->input->post("editor")), $posterId) !== false) { |
|
259 | + return self::CREATE_AND_PUBLISH; |
|
260 | + } |
|
257 | 261 | return self::ABORT; |
258 | 262 | case "delete": |
259 | - if ($this->ci->bmanager->deletePost($this->ci->security->xss_clean($this->ci->input->post("id")))) return self::DELETE; |
|
263 | + if ($this->ci->bmanager->deletePost($this->ci->security->xss_clean($this->ci->input->post("id")))) { |
|
264 | + return self::DELETE; |
|
265 | + } |
|
260 | 266 | return self::ABORT; |
261 | 267 | default: |
262 | 268 | return self::NO_ACTION; |
@@ -272,10 +278,14 @@ discard block |
||
272 | 278 | private function handleSavePost(int $posterId=null): string { |
273 | 279 | $id = $this->ci->security->xss_clean($this->ci->input->post("id")); |
274 | 280 | if ($id != "") { |
275 | - if (!$this->ci->bmanager->savePost($this->ci->input->post("id"), $this->ci->security->xss_clean($this->ci->input->post("title")), $this->ci->security->xss_clean($this->ci->input->post("editor")), $posterId)) return self::ABORT; |
|
281 | + if (!$this->ci->bmanager->savePost($this->ci->input->post("id"), $this->ci->security->xss_clean($this->ci->input->post("title")), $this->ci->security->xss_clean($this->ci->input->post("editor")), $posterId)) { |
|
282 | + return self::ABORT; |
|
283 | + } |
|
276 | 284 | return self::EDIT; |
277 | 285 | } else { |
278 | - if ($this->ci->bmanager->createPost($this->ci->security->xss_clean($this->ci->input->post("title")), $this->ci->security->xss_clean($this->ci->input->post("editor")), $posterId) == 0) return self::ABORT; |
|
286 | + if ($this->ci->bmanager->createPost($this->ci->security->xss_clean($this->ci->input->post("title")), $this->ci->security->xss_clean($this->ci->input->post("editor")), $posterId) == 0) { |
|
287 | + return self::ABORT; |
|
288 | + } |
|
279 | 289 | return self::CREATE; |
280 | 290 | } |
281 | 291 | } |
@@ -289,9 +299,15 @@ discard block |
||
289 | 299 | */ |
290 | 300 | private function handlePublishPost(int $posterId=null): string { |
291 | 301 | $id = $this->ci->security->xss_clean($this->ci->input->post("id")); |
292 | - if ($id == "") return self::ABORT; |
|
293 | - if (!$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)) return self::ABORT; |
|
294 | - if (!$this->ci->bmanager->publishPost($id, true)) return self::ABORT; |
|
302 | + if ($id == "") { |
|
303 | + return self::ABORT; |
|
304 | + } |
|
305 | + if (!$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)) { |
|
306 | + return self::ABORT; |
|
307 | + } |
|
308 | + if (!$this->ci->bmanager->publishPost($id, true)) { |
|
309 | + return self::ABORT; |
|
310 | + } |
|
295 | 311 | return self::PUBLISH; |
296 | 312 | } |
297 | 313 | /** |
@@ -323,7 +339,9 @@ discard block |
||
323 | 339 | * @return [type] [description] |
324 | 340 | */ |
325 | 341 | public function renderPostItems($view=null, $callback=null, $empty_view=null, $page=1, $limit=5, $filter=false, $hits=false, $slug=true) { |
326 | - if ($view == null || $empty_view == null) $this->ci->load->bind("francis94c/blog", $blogger); |
|
342 | + if ($view == null || $empty_view == null) { |
|
343 | + $this->ci->load->bind("francis94c/blog", $blogger); |
|
344 | + } |
|
327 | 345 | $posts = $this->getPosts($page, $limit, $filter, $hits); |
328 | 346 | if (count($posts) == 0) { |
329 | 347 | if ($empty_view == null) { $blogger->load->view("empty"); } else { |
@@ -358,8 +376,12 @@ discard block |
||
358 | 376 | * @return [type] [description] |
359 | 377 | */ |
360 | 378 | public function renderPost($post, $view=null) { |
361 | - if (!is_array($post)) $post = $this->ci->bmanager->getPost($post); |
|
362 | - if (!$post) return false; |
|
379 | + if (!is_array($post)) { |
|
380 | + $post = $this->ci->bmanager->getPost($post); |
|
381 | + } |
|
382 | + if (!$post) { |
|
383 | + return false; |
|
384 | + } |
|
363 | 385 | $post["content"] = $this->ci->parsedown->text($post["content"]); |
364 | 386 | if ($view == null) { |
365 | 387 | $this->ci->load->splint("francis94c/blog", "-post_item", $post); |
@@ -377,7 +399,9 @@ discard block |
||
377 | 399 | $data = array(); |
378 | 400 | $data["title"] = $post["title"]; |
379 | 401 | $data["description"] = substr($post["content"], 0, 154); |
380 | - if (isset($post["share_image"])) $data["image_link"] = $post["share_image"]; |
|
402 | + if (isset($post["share_image"])) { |
|
403 | + $data["image_link"] = $post["share_image"]; |
|
404 | + } |
|
381 | 405 | $data["url"] = current_url(); |
382 | 406 | return $this->ci->load->splint(self::PACKAGE, "-meta_og", $data, true); |
383 | 407 | } |