@@ -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 | } |