Passed
Push — RefactoringPosts ( 744e11...92981d )
by Stone
01:58
created
App/Controllers/Admin/Category.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use Core\Constant;
8 8
 use Core\Container;
9 9
 
10
-class Category extends AdminController{
10
+class Category extends AdminController {
11 11
 
12 12
     protected $siteConfig;
13 13
     protected $pagination;
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         $totalCategories = $this->categoryModel->countCategories();
45 45
         $pagination = $this->pagination->getPagination($page, $totalCategories, $linesPerPage);
46 46
 
47
-        if($linesPerPage !== Constant::LIST_PER_PAGE){
47
+        if ($linesPerPage !== Constant::LIST_PER_PAGE) {
48 48
             $this->data['paginationPostsPerPage'] = $linesPerPage;
49 49
         }
50 50
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         $categorySlug = $category["categories_slug"];
73 73
 
74 74
         //Sanity check on ID
75
-        if($categoryId == null )
75
+        if ($categoryId == null)
76 76
         {
77 77
             throw new \ErrorException("invalid category ID");
78 78
         }
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
 
82 82
         //Error checking
83 83
         $error = false;
84
-        if($categoryName == "")
84
+        if ($categoryName == "")
85 85
         {
86 86
             $error = true;
87 87
             $this->alertBox->setAlert("empty name not allowed", "error");
88 88
         }
89
-        if($categorySlug == "")
89
+        if ($categorySlug == "")
90 90
         {
91 91
             $error = true;
92 92
             $this->alertBox->setAlert("empty slug not allowed", "error");
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
 
105 105
         //checking result and redirecting
106 106
         if ($categoryUpdate) {
107
-            $this->alertBox->setAlert("Category " . $categoryName . " updated");
107
+            $this->alertBox->setAlert("Category ".$categoryName." updated");
108 108
             $this->container->getResponse()->redirect("/admin/category/list/");
109 109
         }
110
-        $this->alertBox->setAlert("Error updating " . $categoryName, "error");
110
+        $this->alertBox->setAlert("Error updating ".$categoryName, "error");
111 111
         $this->container->getResponse()->redirect("/admin/category/list/");
112 112
     }
113 113
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 
124 124
         $removedCategory = $this->categoryModel->delete($categoryId);
125 125
 
126
-        if($removedCategory)
126
+        if ($removedCategory)
127 127
         {
128 128
             $this->alertBox->setAlert("Category ".$categoryName." deleted");
129 129
         }
@@ -149,12 +149,12 @@  discard block
 block discarded – undo
149 149
 
150 150
         //Error checking
151 151
         $error = false;
152
-        if($categoryName == "")
152
+        if ($categoryName == "")
153 153
         {
154 154
             $error = true;
155 155
             $this->alertBox->setAlert("empty name not allowed", "error");
156 156
         }
157
-        if($categorySlug == "")
157
+        if ($categorySlug == "")
158 158
         {
159 159
             $error = true;
160 160
             $this->alertBox->setAlert("empty slug not allowed", "error");
@@ -172,10 +172,10 @@  discard block
 block discarded – undo
172 172
 
173 173
         //checking result and redirecting
174 174
         if ($categoryNew) {
175
-            $this->alertBox->setAlert("Category " . $categoryName . " created");
175
+            $this->alertBox->setAlert("Category ".$categoryName." created");
176 176
             $this->container->getResponse()->redirect("/admin/category/list/");
177 177
         }
178
-        $this->alertBox->setAlert("Error creating " . $categoryName, "error");
178
+        $this->alertBox->setAlert("Error creating ".$categoryName, "error");
179 179
         $this->container->getResponse()->redirect("/admin/category/list/");
180 180
     }
181 181
 }
182 182
\ No newline at end of file
Please login to merge, or discard this patch.
App/Controllers/Admin/Post.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         $totalPosts = $this->postModel->totalNumberFullPosts();
78 78
         $pagination = $this->pagination->getPagination($page, $totalPosts, $postsPerPage);
79 79
 
80
-        if($postsPerPage !== Constant::LIST_PER_PAGE){
80
+        if ($postsPerPage !== Constant::LIST_PER_PAGE) {
81 81
             $this->data['paginationPostsPerPage'] = $postsPerPage;
82 82
         }
83 83
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         $onFrontPage = $posts["isOnFrontPage"];
133 133
         $idUser = $userSessionId;
134 134
 
135
-        if(!is_int($idUser) || $idUser === null)
135
+        if (!is_int($idUser) || $idUser === null)
136 136
         {
137 137
             throw new \Error("Invalid userID");
138 138
         }
@@ -166,10 +166,10 @@  discard block
 block discarded – undo
166 166
 
167 167
         //checking result and redirecting
168 168
         if ($postId != null) {
169
-            $this->alertBox->setAlert("Post " . $title . " Created");
170
-            $this->container->getResponse()->redirect("admin/post/modify/" . $postSlug);
169
+            $this->alertBox->setAlert("Post ".$title." Created");
170
+            $this->container->getResponse()->redirect("admin/post/modify/".$postSlug);
171 171
         }
172
-        $this->alertBox->setAlert("Error creating " . $title, "error");
172
+        $this->alertBox->setAlert("Error creating ".$title, "error");
173 173
         $this->container->getResponse()->redirect("admin/post/new");
174 174
 
175 175
     }
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
 
238 238
         //checking result and redirecting
239 239
         if ($postUpdate) {
240
-            $this->alertBox->setAlert("Post " . $title . " Updated");
241
-            $this->container->getResponse()->redirect("admin/post/modify/" . $postSlug);
240
+            $this->alertBox->setAlert("Post ".$title." Updated");
241
+            $this->container->getResponse()->redirect("admin/post/modify/".$postSlug);
242 242
         }
243
-        $this->alertBox->setAlert("Error updating " . $title, "error");
244
-        $this->container->getResponse()->redirect("admin/post/modify/" . $originalPostSlug);
243
+        $this->alertBox->setAlert("Error updating ".$title, "error");
244
+        $this->container->getResponse()->redirect("admin/post/modify/".$originalPostSlug);
245 245
     }
246 246
 
247 247
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
         $this->tagModel->removeTagsOnPost($postId);
258 258
         $removedPost = $this->postModel->deletePost($postId);
259 259
 
260
-        if($removedPost)
260
+        if ($removedPost)
261 261
         {
262 262
             $this->alertBox->setAlert("Post ".$postTitle." deleted");
263 263
         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -211,10 +211,12 @@
 block discarded – undo
211 211
             $this->alertBox->setAlert("empty slug not allowed", "error");
212 212
         }
213 213
 
214
-        if ($postSlug != $originalPostSlug) //if the slug has been updated
214
+        if ($postSlug != $originalPostSlug) {
215
+            //if the slug has been updated
215 216
         {
216 217
             if (!$this->postModel->isPostSlugUnique($postSlug)) {
217 218
                 $error = true;
219
+        }
218 220
                 $originalPostSlug = $this->postModel->getPostSlugFromId($postId);
219 221
                 $this->alertBox->setAlert("Slug not unique", "error");
220 222
             }
Please login to merge, or discard this patch.
App/Controllers/Ajax/PostVerification.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
         $postId = $this->request->getData("postId");
28 28
 
29 29
         $data = false;
30
-        if(!$this->isAlphaNum($postSlug))
30
+        if (!$this->isAlphaNum($postSlug))
31 31
         {
32 32
             echo json_encode($data);
33 33
             return true;
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
 
38 38
         $data = $postModel->isPostSlugUnique($postSlug);
39 39
 
40
-        if($data == false) //slug is not unique, but could be from the same post
40
+        if ($data == false) //slug is not unique, but could be from the same post
41 41
         {
42 42
             $slugOfId = $postModel->getPostSlugFromId($postId);
43
-            if($slugOfId === $postSlug)
43
+            if ($slugOfId === $postSlug)
44 44
             {
45 45
                 //it's the same post, return true
46 46
                 $data = true;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,9 +37,11 @@
 block discarded – undo
37 37
 
38 38
         $data = $postModel->isPostSlugUnique($postSlug);
39 39
 
40
-        if($data == false) //slug is not unique, but could be from the same post
40
+        if($data == false) {
41
+            //slug is not unique, but could be from the same post
41 42
         {
42 43
             $slugOfId = $postModel->getPostSlugFromId($postId);
44
+        }
43 45
             if($slugOfId === $postSlug)
44 46
             {
45 47
                 //it's the same post, return true
Please login to merge, or discard this patch.