Passed
Push — master ( 28b043...488f68 )
by Francis
01:19
created
views/post_edit.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,13 @@
 block discarded – undo
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">
Please login to merge, or discard this patch.
models/BlogManager.php 1 patch
Braces   +42 added lines, -14 removed lines patch added patch discarded remove patch
@@ -46,9 +46,15 @@  discard block
 block discarded – undo
46 46
       "content" => $content,
47 47
       "slug"    => url_title($title)
48 48
     );
49
-    if (is_numeric($title)) $data["slug"] = "_" . $data["slug"];
50
-    if ($adminId != null) $data["poster_id"] = $adminId;
51
-    if ($this->db->insert($this->table_name, $data)) return $this->db->insert_id();
49
+    if (is_numeric($title)) {
50
+      $data["slug"] = "_" . $data["slug"];
51
+    }
52
+    if ($adminId != null) {
53
+      $data["poster_id"] = $adminId;
54
+    }
55
+    if ($this->db->insert($this->table_name, $data)) {
56
+      return $this->db->insert_id();
57
+    }
52 58
     return false;
53 59
   }
54 60
   /**
@@ -66,9 +72,15 @@  discard block
 block discarded – undo
66 72
       "published"      => 1,
67 73
       "date_published" => date("Y-m-d H:i:s")
68 74
     );
69
-    if (is_numeric($title)) $data["slug"] = "_" . $data["slug"];
70
-    if ($adminId != null) $data["poster_id"] = $adminId;
71
-    if ($this->db->insert($this->table_name, $data)) return $this->db->insert_id();
75
+    if (is_numeric($title)) {
76
+      $data["slug"] = "_" . $data["slug"];
77
+    }
78
+    if ($adminId != null) {
79
+      $data["poster_id"] = $adminId;
80
+    }
81
+    if ($this->db->insert($this->table_name, $data)) {
82
+      return $this->db->insert_id();
83
+    }
72 84
     return false;
73 85
   }
74 86
   /**
@@ -82,8 +94,12 @@  discard block
 block discarded – undo
82 94
    * @return array           Array of posts for a given page.
83 95
    */
84 96
   function getPosts($page=1, $limit=5, $filter=false, $hits=false) {
85
-    if ($limit != 0) $this->db->limit($limit, ($page * $limit) - $limit);
86
-    if ($filter) $this->db->where("published", 1);
97
+    if ($limit != 0) {
98
+      $this->db->limit($limit, ($page * $limit) - $limit);
99
+    }
100
+    if ($filter) {
101
+      $this->db->where("published", 1);
102
+    }
87 103
     if ($hits) {
88 104
       $this->db->order_by("hits", "DESC");
89 105
     } else {
@@ -98,8 +114,12 @@  discard block
 block discarded – undo
98 114
    * @return [type]          [description]
99 115
    */
100 116
   function getRecentPosts($limit=5, $filter=false) {
101
-    if ($limit != null && $limit != null) $this->db->limit($limit);
102
-    if ($filter) $this->db->where("published", 1);
117
+    if ($limit != null && $limit != null) {
118
+      $this->db->limit($limit);
119
+    }
120
+    if ($filter) {
121
+      $this->db->where("published", 1);
122
+    }
103 123
     $this->db->order_by("id", "DESC");
104 124
     return $this->db->get($this->table_name)->result_array();
105 125
   }
@@ -151,7 +171,9 @@  discard block
 block discarded – undo
151 171
       $src = array();
152 172
       // Get the contents of the src tag.
153 173
       preg_match("/(http|https):\/\/[a-zA-Z0-9-._\/]+/", $share_image, $src);
154
-      if (count($src) == 0) return $post;
174
+      if (count($src) == 0) {
175
+        return $post;
176
+      }
155 177
       $post["share_image"] = $src[0];
156 178
       return $post;
157 179
     }
@@ -165,7 +187,9 @@  discard block
 block discarded – undo
165 187
   function getHits($postId) {
166 188
     $this->db->where("id", $postId);
167 189
     $query = $this->db->get($this->table_name);
168
-    if ($query->num_rows() > 0) return $query->result()[0]->hits;
190
+    if ($query->num_rows() > 0) {
191
+      return $query->result()[0]->hits;
192
+    }
169 193
     return 0;
170 194
   }
171 195
   /**
@@ -206,8 +230,12 @@  discard block
 block discarded – undo
206 230
    * @return [type]          [description]
207 231
    */
208 232
   function searchPosts($words, $page, $limit=0, $filter=false) {
209
-    if ($limit != 0) $this->db->limit($limit, ($page * $limit) - $limit);
210
-    if ($filter) $this->db->where("published", 1);
233
+    if ($limit != 0) {
234
+      $this->db->limit($limit, ($page * $limit) - $limit);
235
+    }
236
+    if ($filter) {
237
+      $this->db->where("published", 1);
238
+    }
211 239
     $this->db->like("title", $words);
212 240
     $this->db->or_like("content", $words);
213 241
     return $this->db->get($this->table_name)->result_array();
Please login to merge, or discard this patch.
libraries/Blogger.php 1 patch
Braces   +21 added lines, -7 removed lines patch added patch discarded remove patch
@@ -89,7 +89,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
   }
Please login to merge, or discard this patch.