@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $this->query($sql); |
88 | 88 | if ($select != null) { |
89 | 89 | foreach ($select as $col => $val) { |
90 | - $this->bind(":" . $col, $val); |
|
90 | + $this->bind(":".$col, $val); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | $this->bind(":limit", $limit); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $this->query($sql); |
122 | 122 | if ($select != null) { |
123 | 123 | foreach ($select as $col => $val) { |
124 | - $this->bind(":" . $col, $val); |
|
124 | + $this->bind(":".$col, $val); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | $this->execute(); |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | |
292 | 292 | $this->execute(); |
293 | 293 | |
294 | - return (int)$this->dbh->lastInsertId(); |
|
294 | + return (int) $this->dbh->lastInsertId(); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $table = $reflect->getShortName(); //this is to only get the model name, otherwise we get the full namespace |
140 | 140 | //since our models all end with Model, we should remove it. |
141 | 141 | $table = $this->removeFromEnd($table, 'Model'); |
142 | - $table = $table . 's'; //adding the s since the table should be plural. Might be some special case where the plural isn't just with an s |
|
142 | + $table = $table.'s'; //adding the s since the table should be plural. Might be some special case where the plural isn't just with an s |
|
143 | 143 | $table = strtolower($table); //the database names are in lowercase |
144 | 144 | } |
145 | 145 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | } |
163 | 163 | |
164 | 164 | //if we are here, then table doesn't exist, check for view |
165 | - $view = 'v_' . $table; |
|
165 | + $view = 'v_'.$table; |
|
166 | 166 | $stmt->bindValue(':table', $view, PDO::PARAM_STR); |
167 | 167 | $stmt->execute(); |
168 | 168 | $exists = $stmt->rowCount() > 0; //will return 1 if table exists or 0 if non existant |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | protected function getTablePrefix($table) |
187 | 187 | { |
188 | 188 | if (Config::TABLE_PREFIX != '') { |
189 | - $table = Config::TABLE_PREFIX . '_' . $table; |
|
189 | + $table = Config::TABLE_PREFIX.'_'.$table; |
|
190 | 190 | } |
191 | 191 | return $table; |
192 | 192 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | protected function getRowById($rowId, $table = null) |
256 | 256 | { |
257 | 257 | $tableName = $this->getTable($table); |
258 | - $idName = 'id' . $tableName; |
|
258 | + $idName = 'id'.$tableName; |
|
259 | 259 | $sql = "SELECT * FROM $tableName WHERE $idName = :rowId"; |
260 | 260 | $this->query($sql); |
261 | 261 | $this->bind(':rowId', $rowId); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | //Searching for the page break tag |
86 | 86 | $breakTagPosition = strpos($text, "<!-- EndOfExcerptBlogOc -->"); |
87 | - if($breakTagPosition > 0){ |
|
87 | + if ($breakTagPosition > 0) { |
|
88 | 88 | return $this->completeDom(substr($text, 0, $breakTagPosition)); |
89 | 89 | } |
90 | 90 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $string = preg_split('/(<img[^>]+\>)|(<p[^>]+\>)|(<span[^>]+\>)|\s/', $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); |
93 | 93 | |
94 | 94 | //The preg split can return false, probably will never happen but just in case. |
95 | - if(!$string) |
|
95 | + if (!$string) |
|
96 | 96 | { |
97 | 97 | throw new \Error("excerpt generation failed"); |
98 | 98 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $trimed .= $string[$wordCounter]; |
106 | 106 | if ($wordCounter < $count - 1) { |
107 | 107 | $trimed .= " "; |
108 | - } else { |
|
108 | + }else { |
|
109 | 109 | $trimed .= "[...]"; |
110 | 110 | } |
111 | 111 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $result = true; |
160 | 160 | foreach ($strings as $string) |
161 | 161 | { |
162 | - if(!$this->isAlphaNum($string)) |
|
162 | + if (!$this->isAlphaNum($string)) |
|
163 | 163 | { |
164 | 164 | $result = false; |
165 | 165 | } |
@@ -7,7 +7,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -77,7 +77,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -211,10 +211,12 @@ |
||
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 | } |
@@ -27,7 +27,7 @@ discard block |
||
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 |
||
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; |
@@ -37,9 +37,11 @@ |
||
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 |