@@ -5,7 +5,7 @@ |
||
| 5 | 5 | use Cocur\Slugify\Slugify; |
| 6 | 6 | use Core\Modules\Module; |
| 7 | 7 | |
| 8 | -class Slug extends Module{ |
|
| 8 | +class Slug extends Module { |
|
| 9 | 9 | public function isSlugValid(string $slug):bool |
| 10 | 10 | { |
| 11 | 11 | $slugify = new Slugify(); |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | $this->onlyPost(); |
| 33 | 33 | |
| 34 | 34 | $postSlug = $this->request->getData("postSlug"); |
| 35 | - $postId = (int)$this->request->getData("postId"); |
|
| 35 | + $postId = (int) $this->request->getData("postId"); |
|
| 36 | 36 | |
| 37 | 37 | $data = false; |
| 38 | 38 | if (!$this->slug->isSlugValid($postSlug)) { |
@@ -42,11 +42,11 @@ discard block |
||
| 42 | 42 | public function viewPost(string $slug, string $page = "page-1", int $linesPerPage = Constant::COMMENTS_PER_PAGE) |
| 43 | 43 | { |
| 44 | 44 | |
| 45 | - $postId = (int)$this->postModel->getPostIdFromSlug($slug); |
|
| 45 | + $postId = (int) $this->postModel->getPostIdFromSlug($slug); |
|
| 46 | 46 | |
| 47 | 47 | $posts = $this->postModel->getSinglePost($postId); |
| 48 | 48 | |
| 49 | - if($posts === false) |
|
| 49 | + if ($posts === false) |
|
| 50 | 50 | { |
| 51 | 51 | throw new \Exception("Page no longer exists", "404"); |
| 52 | 52 | } |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | $this->onlyUser(); |
| 90 | 90 | |
| 91 | 91 | //get the session userId |
| 92 | - $userId = (int)$this->session->get("userId"); |
|
| 93 | - $comment = (string)$this->request->getData("newComment"); |
|
| 94 | - $postId = (int)$this->request->getData("postId"); |
|
| 92 | + $userId = (int) $this->session->get("userId"); |
|
| 93 | + $comment = (string) $this->request->getData("newComment"); |
|
| 94 | + $postId = (int) $this->request->getData("postId"); |
|
| 95 | 95 | |
| 96 | 96 | //check if we are admin, Admins do not need moderation |
| 97 | 97 | $admin = $this->session->get('user_role_level') >= Constant::ADMIN_LEVEL; |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | $post = $this->postModel->getSinglePost($postId); |
| 104 | 104 | $baseUrl = $this->request->getBaseUrl(); |
| 105 | 105 | |
| 106 | - $emailMessage = "<h1>New comment on post " . $post->title . "</a></h1>"; |
|
| 107 | - $emailMessage .= "<p>Check it out <a href='" . $baseUrl . "admin/comments/moderate-comment/" . $commentId . "'>here</a> </p>"; |
|
| 106 | + $emailMessage = "<h1>New comment on post ".$post->title."</a></h1>"; |
|
| 107 | + $emailMessage .= "<p>Check it out <a href='".$baseUrl."admin/comments/moderate-comment/".$commentId."'>here</a> </p>"; |
|
| 108 | 108 | |
| 109 | 109 | $this->sendMail->send($siteConfig["admin_email_address"], "New comment added", $emailMessage); |
| 110 | 110 | |
@@ -113,6 +113,6 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | $postSlug = $this->postModel->getPostSlugFromId($postId); |
| 115 | 115 | |
| 116 | - $this->response->redirect("/post/view-post/" . $postSlug); |
|
| 116 | + $this->response->redirect("/post/view-post/".$postSlug); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | \ No newline at end of file |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $this->onlyPost(); |
| 118 | 118 | |
| 119 | 119 | $posts = $this->request->getDataFull(); |
| 120 | - $userSessionId = (int)$this->session->get("userId"); |
|
| 120 | + $userSessionId = (int) $this->session->get("userId"); |
|
| 121 | 121 | |
| 122 | 122 | |
| 123 | 123 | $title = trim($posts["postTitle"]); |
@@ -163,10 +163,10 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | //checking result and redirecting |
| 165 | 165 | if ($postId != null) { |
| 166 | - $this->alertBox->setAlert("Post " . $title . " Created"); |
|
| 167 | - $this->container->getResponse()->redirect("admin/post/modify/" . $postSlug); |
|
| 166 | + $this->alertBox->setAlert("Post ".$title." Created"); |
|
| 167 | + $this->container->getResponse()->redirect("admin/post/modify/".$postSlug); |
|
| 168 | 168 | } |
| 169 | - $this->alertBox->setAlert("Error creating " . $title, "error"); |
|
| 169 | + $this->alertBox->setAlert("Error creating ".$title, "error"); |
|
| 170 | 170 | $this->container->getResponse()->redirect("admin/post/new"); |
| 171 | 171 | |
| 172 | 172 | } |
@@ -231,11 +231,11 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | //checking result and redirecting |
| 233 | 233 | if ($postUpdate) { |
| 234 | - $this->alertBox->setAlert("Post " . $title . " Updated"); |
|
| 235 | - $this->container->getResponse()->redirect("admin/post/modify/" . $postSlug); |
|
| 234 | + $this->alertBox->setAlert("Post ".$title." Updated"); |
|
| 235 | + $this->container->getResponse()->redirect("admin/post/modify/".$postSlug); |
|
| 236 | 236 | } |
| 237 | - $this->alertBox->setAlert("Error updating " . $title, "error"); |
|
| 238 | - $this->container->getResponse()->redirect("admin/post/modify/" . $originalPostSlug); |
|
| 237 | + $this->alertBox->setAlert("Error updating ".$title, "error"); |
|
| 238 | + $this->container->getResponse()->redirect("admin/post/modify/".$originalPostSlug); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | $removedPost = $this->postModel->deletePost($postId); |
| 253 | 253 | |
| 254 | 254 | if ($removedPost) { |
| 255 | - $this->alertBox->setAlert("Post " . $postTitle . " deleted"); |
|
| 255 | + $this->alertBox->setAlert("Post ".$postTitle." deleted"); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | $this->response->redirect("admin/post/list/"); |