1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Aiur18\Question; |
4
|
|
|
|
5
|
|
|
use Anax\Commons\ContainerInjectableInterface; |
6
|
|
|
use Anax\Commons\ContainerInjectableTrait; |
7
|
|
|
use Aiur18\Question\HTMLForm\CreateForm; |
8
|
|
|
use Aiur18\Question\HTMLForm\EditForm; |
|
|
|
|
9
|
|
|
use Aiur18\Question\HTMLForm\DeleteForm; |
10
|
|
|
use Aiur18\Question\HTMLForm\UpdateForm; |
11
|
|
|
use Aiur18\Question\HTMLForm\CreateAnswer; |
12
|
|
|
use Aiur18\Question\HTMLForm\CreateComment; |
13
|
|
|
use Aiur18\getset\getset; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* A sample controller to show how a controller class can be implemented. |
17
|
|
|
*/ |
18
|
|
|
class QuestionController implements ContainerInjectableInterface |
19
|
|
|
{ |
20
|
|
|
use ContainerInjectableTrait; |
21
|
|
|
|
22
|
|
|
|
23
|
|
|
|
24
|
|
|
/** variables |
25
|
|
|
*/ |
26
|
|
|
public $makaroner; |
27
|
|
|
|
28
|
|
|
/** Method |
29
|
|
|
*/ |
30
|
|
|
public function indexActionGet() : object |
31
|
|
|
{ |
32
|
|
|
$getServer = new getSet(); |
33
|
|
|
if ($getServer->getServer('user_id') != null) { |
34
|
|
|
$page = $this->di->get("page"); |
35
|
|
|
$question = new Question(); |
36
|
|
|
$question->setDb($this->di->get("dbqb")); |
37
|
|
|
|
38
|
|
|
$page->add("question/crud/view-all", [ |
39
|
|
|
"items" => $question->findAll(), |
40
|
|
|
]); |
41
|
|
|
|
42
|
|
|
return $page->render([ |
43
|
|
|
"title" => "A collection of items", |
44
|
|
|
]); |
45
|
|
|
} else { |
46
|
|
|
$this->di->get("response")->redirect("user/login")->send(); |
|
|
|
|
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
|
52
|
|
|
/** Method |
53
|
|
|
*/ |
54
|
|
|
public function createAction() : object |
55
|
|
|
{ |
56
|
|
|
$getServer = new getSet(); |
57
|
|
|
if ($getServer->getServer('user_id') != null) { |
58
|
|
|
$page = $this->di->get("page"); |
59
|
|
|
$form = new CreateForm($this->di); |
60
|
|
|
$form->check(); |
61
|
|
|
|
62
|
|
|
$page->add("question/crud/create", [ |
63
|
|
|
"form" => $form->getHTML(), |
64
|
|
|
]); |
65
|
|
|
|
66
|
|
|
return $page->render([ |
67
|
|
|
"title" => "Create a item", |
68
|
|
|
]); |
69
|
|
|
} else { |
70
|
|
|
$this->di->get("response")->redirect("user/login")->send(); |
|
|
|
|
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
|
76
|
|
|
/** Method |
77
|
|
|
*/ |
78
|
|
|
public function deleteAction() : object |
79
|
|
|
{ |
80
|
|
|
$getServer = new getSet(); |
81
|
|
|
if ($getServer->getServer('user_id') != null) { |
82
|
|
|
$page = $this->di->get("page"); |
83
|
|
|
$form = new DeleteForm($this->di); |
84
|
|
|
$form->check(); |
85
|
|
|
|
86
|
|
|
$page->add("question/crud/delete", [ |
87
|
|
|
"form" => $form->getHTML(), |
88
|
|
|
]); |
89
|
|
|
|
90
|
|
|
return $page->render([ |
91
|
|
|
"title" => "Delete an item", |
92
|
|
|
]); |
93
|
|
|
} else { |
94
|
|
|
$this->di->get("response")->redirect("user/login")->send(); |
|
|
|
|
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
|
99
|
|
|
|
100
|
|
|
/** Method |
101
|
|
|
*/ |
102
|
|
|
public function updateAction(int $id) : object |
103
|
|
|
{ |
104
|
|
|
$getServer = new getSet(); |
105
|
|
|
if ($getServer->getServer('user_id') != null) { |
106
|
|
|
$page = $this->di->get("page"); |
107
|
|
|
|
108
|
|
|
$form = new CreateForm($this->di, $id); |
|
|
|
|
109
|
|
|
$form->check(); |
110
|
|
|
$questInfo = $form->getItemDetails($id); |
111
|
|
|
|
112
|
|
|
$answer = new CreateAnswer($this->di, $id); |
113
|
|
|
$answer->check(); |
114
|
|
|
|
115
|
|
|
|
116
|
|
|
$answ4quest = new Answer(); |
117
|
|
|
$answ4quest->setDb($this->di->get("dbqb")); |
118
|
|
|
|
119
|
|
|
$com4quest = new Comment(); |
120
|
|
|
$com4quest->setDb($this->di->get("dbqb")); |
121
|
|
|
|
122
|
|
|
// //Fixa så ej session helst |
123
|
|
|
$getServer = new getSet(); |
124
|
|
|
$getServer->setServer('id_question', $id); |
125
|
|
|
// $_SESSION['id_question'] = $id; |
126
|
|
|
|
127
|
|
|
$page->add("question/crud/createAnswer", [ |
128
|
|
|
"answer" => $answer->getHTML(), |
129
|
|
|
"questInfo" => $questInfo, |
130
|
|
|
"items" => $answ4quest->findAllWhere("id_question = ?", $id), |
131
|
|
|
"itemz" => [ |
132
|
|
|
"itemz1" => $answ4quest->findAllWhere("id_question = ?", $id), |
133
|
|
|
|
134
|
|
|
"itemz2" => $com4quest->findAll(), |
135
|
|
|
], |
136
|
|
|
]); |
137
|
|
|
|
138
|
|
|
return $page->render([ |
139
|
|
|
"title" => "Create a item", |
140
|
|
|
]); |
141
|
|
|
} else { |
142
|
|
|
$this->di->get("response")->redirect("user/login")->send(); |
|
|
|
|
143
|
|
|
} |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
|
147
|
|
|
/** Method |
148
|
|
|
*/ |
149
|
|
|
public function commentAction($idAnswer) : object |
150
|
|
|
{ |
151
|
|
|
$getServer = new getSet(); |
152
|
|
|
if ($getServer->getServer('user_id') != null) { |
153
|
|
|
$page = $this->di->get("page"); |
154
|
|
|
|
155
|
|
|
// //Fixa så ej session helst |
156
|
|
|
$idQuestion = $getServer->getServer('id_question'); |
157
|
|
|
|
158
|
|
|
$form = new CreateComment($this->di, $idAnswer, $idQuestion); |
159
|
|
|
$form->check(); |
160
|
|
|
|
161
|
|
|
$page->add("question/crud/comment", [ |
162
|
|
|
"form" => $form->getHTML(), |
163
|
|
|
]); |
164
|
|
|
|
165
|
|
|
return $page->render([ |
166
|
|
|
"title" => "Create a item", |
167
|
|
|
]); |
168
|
|
|
} else { |
169
|
|
|
$this->di->get("response")->redirect("user/login")->send(); |
|
|
|
|
170
|
|
|
} |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
|
174
|
|
|
|
175
|
|
|
/** Method |
176
|
|
|
*/ |
177
|
|
|
public function commentqAction($idAnswer) : object |
|
|
|
|
178
|
|
|
{ |
179
|
|
|
$getServer = new getSet(); |
180
|
|
|
if ($getServer->getServer('user_id') != null) { |
181
|
|
|
$page = $this->di->get("page"); |
182
|
|
|
|
183
|
|
|
// //Fixa så ej session helst |
184
|
|
|
$idQuestion = $getServer->getServer('id_question'); |
185
|
|
|
$idAnswer = "question"; |
186
|
|
|
|
187
|
|
|
|
188
|
|
|
|
189
|
|
|
$form = new CreateComment($this->di, $idAnswer, $idQuestion); |
190
|
|
|
$form->check(); |
191
|
|
|
|
192
|
|
|
$page->add("question/crud/comment", [ |
193
|
|
|
"form" => $form->getHTML(), |
194
|
|
|
]); |
195
|
|
|
|
196
|
|
|
return $page->render([ |
197
|
|
|
"title" => "Create a item", |
198
|
|
|
]); |
199
|
|
|
} else { |
200
|
|
|
$this->di->get("response")->redirect("user/login")->send(); |
|
|
|
|
201
|
|
|
} |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
|
205
|
|
|
|
206
|
|
|
|
207
|
|
|
/** Method |
208
|
|
|
*/ |
209
|
|
|
public function tagsActionGet() : object |
210
|
|
|
{ |
211
|
|
|
$getServer = new getSet(); |
212
|
|
|
if ($getServer->getServer('user_id') != null) { |
213
|
|
|
$page = $this->di->get("page"); |
214
|
|
|
$tags = new Question(); |
215
|
|
|
$tags->setDb($this->di->get("dbqb")); |
216
|
|
|
|
217
|
|
|
$page->add("question/crud/all-tags", [ |
218
|
|
|
"items" => $tags->findAll(), |
219
|
|
|
]); |
220
|
|
|
|
221
|
|
|
return $page->render([ |
222
|
|
|
"title" => "A collection of tags", |
223
|
|
|
]); |
224
|
|
|
} else { |
225
|
|
|
$this->di->get("response")->redirect("user/login")->send(); |
|
|
|
|
226
|
|
|
} |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
|
230
|
|
|
/** Method |
231
|
|
|
*/ |
232
|
|
|
public function spectagActionGet($tag) : object |
233
|
|
|
{ |
234
|
|
|
$getServer = new getSet(); |
235
|
|
|
if ($getServer->getServer('user_id') != null) { |
236
|
|
|
$page = $this->di->get("page"); |
237
|
|
|
|
238
|
|
|
$tagInfo = new Question(); |
239
|
|
|
$tagInfo->setDb($this->di->get("dbqb")); |
240
|
|
|
|
241
|
|
|
// $comments = new Comment(); |
242
|
|
|
// $comments->setDb($this->di->get("dbqb")); |
243
|
|
|
|
244
|
|
|
$page->add("question/crud/info", [ |
245
|
|
|
"tagInfo" => $tagInfo->findAllWhere("{$tag} = ?", 1), |
246
|
|
|
]); |
247
|
|
|
|
248
|
|
|
return $page->render([ |
249
|
|
|
"title" => "A collection of users", |
250
|
|
|
]); |
251
|
|
|
} else { |
252
|
|
|
$this->di->get("response")->redirect("user/login")->send(); |
|
|
|
|
253
|
|
|
} |
254
|
|
|
} |
255
|
|
|
} |
256
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths