@@ -63,7 +63,7 @@ |
||
63 | 63 | { |
64 | 64 | $post = new Post(); |
65 | 65 | $post->setDb($this->di->get("dbqb")); |
66 | - $post->acronym = $this->form->value("acronym"); |
|
66 | + $post->acronym = $this->form->value("acronym"); |
|
67 | 67 | $post->title = $this->form->value("title"); |
68 | 68 | $post->text = $this->form->value("text"); |
69 | 69 | $post->save(); |
@@ -96,37 +96,37 @@ |
||
96 | 96 | * |
97 | 97 | * @return object as a response object |
98 | 98 | */ |
99 | - public function viewAction(int $id) : object |
|
100 | - { |
|
101 | - $page = $this->di->get("page"); |
|
102 | - |
|
103 | - // posts |
|
104 | - $post = new Post(); |
|
105 | - $post->setDb($this->di->get("dbqb")); |
|
106 | - $posts = $post->find("postId", $id); |
|
107 | - |
|
108 | - // tags |
|
109 | - $tag = new Tag(); |
|
110 | - $tag->setDb($this->di->get("dbqb")); |
|
111 | - $tags = $tag->find("postId", $id); |
|
112 | - |
|
113 | - // comments |
|
114 | - $comment = new Comment(); |
|
115 | - $comment->setDb($this->di->get("dbqb")); |
|
116 | - $comments = $comment->find("postId", $id); |
|
117 | - |
|
118 | - $data = [ |
|
119 | - "post" => $posts, |
|
120 | - "comments" => $comments, |
|
121 | - "tags" => $tags, |
|
122 | - "userId" => $this->di->get("session")->get("userId"), |
|
123 | - "get" => $_GET |
|
124 | - ]; |
|
125 | - |
|
126 | - $page->add("post/crud/view-post", $data); |
|
127 | - |
|
128 | - return $page->render([ |
|
129 | - "title" => "Showing post", |
|
130 | - ]); |
|
131 | - } |
|
99 | + public function viewAction(int $id) : object |
|
100 | + { |
|
101 | + $page = $this->di->get("page"); |
|
102 | + |
|
103 | + // posts |
|
104 | + $post = new Post(); |
|
105 | + $post->setDb($this->di->get("dbqb")); |
|
106 | + $posts = $post->find("postId", $id); |
|
107 | + |
|
108 | + // tags |
|
109 | + $tag = new Tag(); |
|
110 | + $tag->setDb($this->di->get("dbqb")); |
|
111 | + $tags = $tag->find("postId", $id); |
|
112 | + |
|
113 | + // comments |
|
114 | + $comment = new Comment(); |
|
115 | + $comment->setDb($this->di->get("dbqb")); |
|
116 | + $comments = $comment->find("postId", $id); |
|
117 | + |
|
118 | + $data = [ |
|
119 | + "post" => $posts, |
|
120 | + "comments" => $comments, |
|
121 | + "tags" => $tags, |
|
122 | + "userId" => $this->di->get("session")->get("userId"), |
|
123 | + "get" => $_GET |
|
124 | + ]; |
|
125 | + |
|
126 | + $page->add("post/crud/view-post", $data); |
|
127 | + |
|
128 | + return $page->render([ |
|
129 | + "title" => "Showing post", |
|
130 | + ]); |
|
131 | + } |
|
132 | 132 | } |
@@ -31,45 +31,45 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @return object as a response object |
33 | 33 | */ |
34 | - public function createAction(int $id) : object |
|
35 | - { |
|
36 | - $userId = $this->di->get("session")->get("userId"); |
|
37 | - if (!$userId) { |
|
38 | - $this->di->get("response")->redirect("user/login"); |
|
39 | - } |
|
34 | + public function createAction(int $id) : object |
|
35 | + { |
|
36 | + $userId = $this->di->get("session")->get("userId"); |
|
37 | + if (!$userId) { |
|
38 | + $this->di->get("response")->redirect("user/login"); |
|
39 | + } |
|
40 | 40 | |
41 | - //Form |
|
42 | - $form = new CreateForm($this->di, $id); |
|
43 | - $form->check(); |
|
41 | + //Form |
|
42 | + $form = new CreateForm($this->di, $id); |
|
43 | + $form->check(); |
|
44 | 44 | |
45 | - //Post |
|
46 | - $post = new Post(); |
|
47 | - $post->setDb($this->di->get("dbqb")); |
|
45 | + //Post |
|
46 | + $post = new Post(); |
|
47 | + $post->setDb($this->di->get("dbqb")); |
|
48 | 48 | |
49 | - //Post |
|
50 | - $comment = new Comment(); |
|
51 | - $comment->setDb($this->di->get("dbqb")); |
|
49 | + //Post |
|
50 | + $comment = new Comment(); |
|
51 | + $comment->setDb($this->di->get("dbqb")); |
|
52 | 52 | |
53 | 53 | |
54 | - $data = [ |
|
55 | - "comments" => $comment->find("postId", $id), |
|
56 | - "post" => $post->find("postId", $id), |
|
57 | - "userId" => $userId, |
|
58 | - "filter" => new MarkdownExtra() |
|
59 | - ]; |
|
54 | + $data = [ |
|
55 | + "comments" => $comment->find("postId", $id), |
|
56 | + "post" => $post->find("postId", $id), |
|
57 | + "userId" => $userId, |
|
58 | + "filter" => new MarkdownExtra() |
|
59 | + ]; |
|
60 | 60 | |
61 | - //Page |
|
62 | - $page = $this->di->get("page"); |
|
63 | - $page->add("post/crud/view-post", $data); |
|
61 | + //Page |
|
62 | + $page = $this->di->get("page"); |
|
63 | + $page->add("post/crud/view-post", $data); |
|
64 | 64 | |
65 | - $page->add("post/crud/create", [ |
|
66 | - "form" => $form->getHTML(), |
|
67 | - ]); |
|
65 | + $page->add("post/crud/create", [ |
|
66 | + "form" => $form->getHTML(), |
|
67 | + ]); |
|
68 | 68 | |
69 | - return $page->render([ |
|
70 | - "title" => "comment", |
|
71 | - ]); |
|
72 | - } |
|
69 | + return $page->render([ |
|
70 | + "title" => "comment", |
|
71 | + ]); |
|
72 | + } |
|
73 | 73 | |
74 | 74 | |
75 | 75 | /** |
@@ -79,32 +79,32 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return object as a response object |
81 | 81 | */ |
82 | - public function updateAction(int $id) : object |
|
83 | - { |
|
84 | - $userId = $this->di->get("session")->get("userId"); |
|
85 | - |
|
86 | - //Comment |
|
87 | - $comment = new Comment(); |
|
88 | - $comment->setDb($this->di->get("dbqb")); |
|
89 | - $comment->find("commentId", $id); |
|
90 | - |
|
91 | - if (!$userId || ($comment->id != $userId)) { |
|
92 | - $this->di->get("response")->redirect("user/login"); |
|
93 | - } |
|
94 | - |
|
95 | - //Form |
|
96 | - $form = new UpdateForm($this->di, $id); |
|
97 | - $form->check(); |
|
98 | - |
|
99 | - //Page |
|
100 | - $page = $this->di->get("page"); |
|
101 | - $page->add("post/crud/update", [ |
|
102 | - "form" => $form->getHTML(), |
|
103 | - "type" => "comment" |
|
104 | - ]); |
|
105 | - |
|
106 | - return $page->render([ |
|
107 | - "title" => "Edit comment", |
|
108 | - ]); |
|
109 | - } |
|
82 | + public function updateAction(int $id) : object |
|
83 | + { |
|
84 | + $userId = $this->di->get("session")->get("userId"); |
|
85 | + |
|
86 | + //Comment |
|
87 | + $comment = new Comment(); |
|
88 | + $comment->setDb($this->di->get("dbqb")); |
|
89 | + $comment->find("commentId", $id); |
|
90 | + |
|
91 | + if (!$userId || ($comment->id != $userId)) { |
|
92 | + $this->di->get("response")->redirect("user/login"); |
|
93 | + } |
|
94 | + |
|
95 | + //Form |
|
96 | + $form = new UpdateForm($this->di, $id); |
|
97 | + $form->check(); |
|
98 | + |
|
99 | + //Page |
|
100 | + $page = $this->di->get("page"); |
|
101 | + $page->add("post/crud/update", [ |
|
102 | + "form" => $form->getHTML(), |
|
103 | + "type" => "comment" |
|
104 | + ]); |
|
105 | + |
|
106 | + return $page->render([ |
|
107 | + "title" => "Edit comment", |
|
108 | + ]); |
|
109 | + } |
|
110 | 110 | } |
@@ -22,7 +22,6 @@ |
||
22 | 22 | * @param string $message with details. |
23 | 23 | * |
24 | 24 | * @throws Anax\Route\Exception\NotFoundException |
25 | - |
|
26 | 25 | * @return object as the response. |
27 | 26 | */ |
28 | 27 | public function catchAll(...$args) : object |
@@ -21,7 +21,6 @@ |
||
21 | 21 | * @param array $args as a variadic to catch all arguments. |
22 | 22 | * |
23 | 23 | * @throws Anax\Route\Exception\NotFoundException when route is not found. |
24 | - |
|
25 | 24 | * @return object as the response. |
26 | 25 | * |
27 | 26 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |