@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | use Core\Controller; |
9 | 9 | use Core\Container; |
10 | 10 | |
11 | -class Post extends Controller{ |
|
11 | +class Post extends Controller { |
|
12 | 12 | |
13 | 13 | protected $siteConfig; |
14 | 14 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @throws \Twig_Error_Runtime |
27 | 27 | * @throws \Twig_Error_Syntax |
28 | 28 | */ |
29 | - public function viewPost(string $slug){ |
|
29 | + public function viewPost(string $slug) { |
|
30 | 30 | |
31 | 31 | $tagModel = new TagModel($this->container); |
32 | 32 | $postModel = new PostModel($this->container); |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | $posts = $postModel->getSinglePost($postId); |
39 | 39 | |
40 | 40 | //only admins can view unpublished posts |
41 | - if(!$posts->published) |
|
41 | + if (!$posts->published) |
|
42 | 42 | { |
43 | - if(!$this->auth->isAdmin()) |
|
43 | + if (!$this->auth->isAdmin()) |
|
44 | 44 | { |
45 | 45 | throw new \Exception("File does not exist", "404"); |
46 | 46 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | $categories = $categoryModel->getCategories(); |
35 | 35 | foreach ($categories as $category) { |
36 | 36 | $data += [ |
37 | - $category->category_name => '/category/posts/' . $category->categories_slug |
|
37 | + $category->category_name => '/category/posts/'.$category->categories_slug |
|
38 | 38 | ]; |
39 | 39 | } |
40 | 40 | return $data; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $table = $reflect->getShortName(); //this is to only get the model name, otherwise we get the full namespace |
139 | 139 | //since our models all end with Model, we should remove it. |
140 | 140 | $table = $this->removeFromEnd($table, 'Model'); |
141 | - $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 |
|
141 | + $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 | 142 | $table = strtolower($table); //the database names are in lowercase |
143 | 143 | } |
144 | 144 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | //if we are here, then table doesn't exist, check for view |
164 | - $view = 'v_' . $table; |
|
164 | + $view = 'v_'.$table; |
|
165 | 165 | $stmt->bindValue(':table', $view, PDO::PARAM_STR); |
166 | 166 | $stmt->execute(); |
167 | 167 | $exists = $stmt->rowCount() > 0; //will return 1 if table exists or 0 if non existant |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | protected function getTablePrefix($table) |
186 | 186 | { |
187 | 187 | if (Config::TABLE_PREFIX != '') { |
188 | - $table = Config::TABLE_PREFIX . '_' . $table; |
|
188 | + $table = Config::TABLE_PREFIX.'_'.$table; |
|
189 | 189 | } |
190 | 190 | return $table; |
191 | 191 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | protected function getRowById($rowId, $table = null) |
255 | 255 | { |
256 | 256 | $tableName = $this->getTable($table); |
257 | - $idName = 'id' . $tableName; |
|
257 | + $idName = 'id'.$tableName; |
|
258 | 258 | $sql = "SELECT * FROM $tableName WHERE $idName = :rowId"; |
259 | 259 | $this->query($sql); |
260 | 260 | $this->bind(':rowId', $rowId); |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | protected function getRowBySlug(String $slug, $table = null): array |
299 | 299 | { |
300 | 300 | $tableName = $this->getTable($table); |
301 | - $slugName = $tableName . '_slug'; |
|
301 | + $slugName = $tableName.'_slug'; |
|
302 | 302 | $sql = "SELECT * FROM $tableName WHERE $slugName = :slug"; |
303 | 303 | $this->query($sql); |
304 | 304 | $this->bind(':slug', $slug); |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | { |
22 | 22 | |
23 | 23 | if (!$this->isAlphaNum($table)) { |
24 | - throw new \Exception("Invalid table name " . $table); |
|
24 | + throw new \Exception("Invalid table name ".$table); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | if (!$this->isAlphaNum($columnName)) { |
28 | - throw new \Exception("Invalid Column name " . $columnName); |
|
28 | + throw new \Exception("Invalid Column name ".$columnName); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | $slugTbl = $this->getTablePrefix($table); |
@@ -49,15 +49,15 @@ discard block |
||
49 | 49 | public function getIdFromSlug(string $slug, string $table, string $columnName, string $idColumn): int |
50 | 50 | { |
51 | 51 | if (!$this->isAlphaNum($table)) { |
52 | - throw new \Exception("Invalid table name " . $table); |
|
52 | + throw new \Exception("Invalid table name ".$table); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | if (!$this->isAlphaNum($columnName)) { |
56 | - throw new \Exception("Invalid Slug Column name " . $columnName); |
|
56 | + throw new \Exception("Invalid Slug Column name ".$columnName); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | if (!$this->isAlphaNum($idColumn)) { |
60 | - throw new \Exception("Invalid ID Column name " . $columnName); |
|
60 | + throw new \Exception("Invalid ID Column name ".$columnName); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | $slugTbl = $this->getTablePrefix($table); |
@@ -85,15 +85,15 @@ discard block |
||
85 | 85 | public function getSlugFromId(int $searchId, string $table, string $columnName, string $slugColumn): string |
86 | 86 | { |
87 | 87 | if (!$this->isAlphaNum($table)) { |
88 | - throw new \Exception("Invalid table name " . $table); |
|
88 | + throw new \Exception("Invalid table name ".$table); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | if (!$this->isAlphaNum($columnName)) { |
92 | - throw new \Exception("Invalid Slug Column name " . $columnName); |
|
92 | + throw new \Exception("Invalid Slug Column name ".$columnName); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | if (!$this->isAlphaNum($slugColumn)) { |
96 | - throw new \Exception("Invalid ID Column name " . $columnName); |
|
96 | + throw new \Exception("Invalid ID Column name ".$columnName); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | $slugTbl = $this->getTablePrefix($table); |