@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | string $postSlug |
| 136 | 136 | ) |
| 137 | 137 | { |
| 138 | - $sql=" |
|
| 138 | + $sql = " |
|
| 139 | 139 | UPDATE $this->postsTbl |
| 140 | 140 | SET |
| 141 | 141 | title = :title, |
@@ -151,15 +151,15 @@ discard block |
||
| 151 | 151 | idposts = :postId |
| 152 | 152 | ;"; |
| 153 | 153 | $this->query($sql); |
| 154 | - $this->bind(":title",$title); |
|
| 155 | - $this->bind(":postImage",$postImage); |
|
| 156 | - $this->bind(":idCategory",$idCategory); |
|
| 157 | - $this->bind(":article",$article); |
|
| 158 | - $this->bind(":idUser",$idUser); |
|
| 159 | - $this->bind(":published",$published); |
|
| 160 | - $this->bind(":onFrontPage",$onFrontPage); |
|
| 161 | - $this->bind(":postSlug",$postSlug); |
|
| 162 | - $this->bind(":postId",$postId); |
|
| 154 | + $this->bind(":title", $title); |
|
| 155 | + $this->bind(":postImage", $postImage); |
|
| 156 | + $this->bind(":idCategory", $idCategory); |
|
| 157 | + $this->bind(":article", $article); |
|
| 158 | + $this->bind(":idUser", $idUser); |
|
| 159 | + $this->bind(":published", $published); |
|
| 160 | + $this->bind(":onFrontPage", $onFrontPage); |
|
| 161 | + $this->bind(":postSlug", $postSlug); |
|
| 162 | + $this->bind(":postId", $postId); |
|
| 163 | 163 | |
| 164 | 164 | return $this->execute(); |
| 165 | 165 | } |
@@ -21,11 +21,11 @@ discard block |
||
| 21 | 21 | { |
| 22 | 22 | |
| 23 | 23 | if (!$this->isAlphaNum($table)) { |
| 24 | - throw new \ErrorException("Invalid table name " . $table); |
|
| 24 | + throw new \ErrorException("Invalid table name ".$table); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | if (!$this->isAlphaNum($columnName)) { |
| 28 | - throw new \ErrorException("Invalid Column name " . $columnName); |
|
| 28 | + throw new \ErrorException("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 \ErrorException("Invalid table name " . $table); |
|
| 52 | + throw new \ErrorException("Invalid table name ".$table); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | if (!$this->isAlphaNum($columnName)) { |
| 56 | - throw new \ErrorException("Invalid Slug Column name " . $columnName); |
|
| 56 | + throw new \ErrorException("Invalid Slug Column name ".$columnName); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | if (!$this->isAlphaNum($idColumn)) { |
| 60 | - throw new \ErrorException("Invalid ID Column name " . $columnName); |
|
| 60 | + throw new \ErrorException("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 \ErrorException("Invalid table name " . $table); |
|
| 88 | + throw new \ErrorException("Invalid table name ".$table); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | if (!$this->isAlphaNum($columnName)) { |
| 92 | - throw new \ErrorException("Invalid Slug Column name " . $columnName); |
|
| 92 | + throw new \ErrorException("Invalid Slug Column name ".$columnName); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | if (!$this->isAlphaNum($slugColumn)) { |
| 96 | - throw new \ErrorException("Invalid ID Column name " . $columnName); |
|
| 96 | + throw new \ErrorException("Invalid ID Column name ".$columnName); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $slugTbl = $this->getTablePrefix($table); |
@@ -121,10 +121,10 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | if ($postId != null) { |
| 124 | - $this->alertBox->setAlert("Post " . $title . " Created"); |
|
| 125 | - $this->container->getResponse()->redirect("admin/post/modify/" . $postSlug); |
|
| 124 | + $this->alertBox->setAlert("Post ".$title." Created"); |
|
| 125 | + $this->container->getResponse()->redirect("admin/post/modify/".$postSlug); |
|
| 126 | 126 | } |
| 127 | - $this->alertBox->setAlert("Error creating " . $title, "error"); |
|
| 127 | + $this->alertBox->setAlert("Error creating ".$title, "error"); |
|
| 128 | 128 | $this->container->getResponse()->redirect("admin/post/new"); |
| 129 | 129 | |
| 130 | 130 | } |
@@ -204,11 +204,11 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | if ($postUpdate) { |
| 207 | - $this->alertBox->setAlert("Post " . $title . " Updated"); |
|
| 208 | - $this->container->getResponse()->redirect("admin/post/modify/" . $postSlug); |
|
| 207 | + $this->alertBox->setAlert("Post ".$title." Updated"); |
|
| 208 | + $this->container->getResponse()->redirect("admin/post/modify/".$postSlug); |
|
| 209 | 209 | } |
| 210 | - $this->alertBox->setAlert("Error updating " . $title, "error"); |
|
| 211 | - $this->container->getResponse()->redirect("admin/post/modify/" . $originalPostSlug); |
|
| 210 | + $this->alertBox->setAlert("Error updating ".$title, "error"); |
|
| 211 | + $this->container->getResponse()->redirect("admin/post/modify/".$originalPostSlug); |
|
| 212 | 212 | |
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | \ No newline at end of file |
@@ -174,10 +174,12 @@ |
||
| 174 | 174 | $this->alertBox->setAlert("empty slug not allowed", "error"); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - if ($postSlug != $originalPostSlug) //if the slug has been updated |
|
| 177 | + if ($postSlug != $originalPostSlug) { |
|
| 178 | + //if the slug has been updated |
|
| 178 | 179 | { |
| 179 | 180 | if (!$slugModel->isUnique($postSlug, "posts", "posts_slug")) { |
| 180 | 181 | $error = true; |
| 182 | + } |
|
| 181 | 183 | $originalPostSlug = $slugModel->getSlugFromId($postId, "posts", "idposts", "posts_slug"); |
| 182 | 184 | $this->alertBox->setAlert("Slug not unique", "error"); |
| 183 | 185 | } |