1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Controllers\Admin; |
4
|
|
|
|
5
|
|
|
use App\Models\CommentModel; |
6
|
|
|
use Core\AdminController; |
7
|
|
|
use Core\Constant; |
8
|
|
|
use Core\Container; |
9
|
|
|
use Core\Traits\StringFunctions; |
10
|
|
|
|
11
|
|
|
class Comments extends AdminController{ |
12
|
|
|
|
13
|
|
|
use StringFunctions; |
|
|
|
|
14
|
|
|
|
15
|
|
|
protected $siteConfig; |
16
|
|
|
protected $pagination; |
17
|
|
|
|
18
|
|
|
private $commentModel; |
19
|
|
|
|
20
|
|
|
public function __construct(Container $container) |
21
|
|
|
{ |
22
|
|
|
$this->loadModules[] = 'SiteConfig'; |
23
|
|
|
$this->loadModules[] = 'pagination'; |
24
|
|
|
parent::__construct($container); |
25
|
|
|
$this->commentModel = new CommentModel($this->container); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
public function viewComments(string $page = "page-1", int $linesPerPage = Constant::LIST_PER_PAGE) |
30
|
|
|
{ |
31
|
|
|
$this->onlyAdmin(); |
32
|
|
|
|
33
|
|
|
$totalComments = $this->commentModel->countPendingComments(); |
34
|
|
|
$pagination = $this->pagination->getPagination($page, $totalComments, $linesPerPage); |
35
|
|
|
|
36
|
|
|
if ($linesPerPage !== Constant::LIST_PER_PAGE) { |
37
|
|
|
$this->data['paginationPostsPerPage'] = $linesPerPage; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
$this->data['pagination'] = $pagination; |
41
|
|
|
$this->data['configs'] = $this->siteConfig->getSiteConfig(); |
42
|
|
|
$this->data["comments"] = $this->commentModel->getPendingCommentsList($pagination["offset"], $linesPerPage); |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
$this->renderView('Admin/Comments'); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function pendingComments(string $page = "page-1", int $linesPerPage = Constant::LIST_PER_PAGE) |
49
|
|
|
{ |
50
|
|
|
$this->onlyAdmin(); |
51
|
|
|
|
52
|
|
|
$totalComments = $this->commentModel->countPendingComments(); |
53
|
|
|
$pagination = $this->pagination->getPagination($page, $totalComments, $linesPerPage); |
54
|
|
|
|
55
|
|
|
if ($linesPerPage !== Constant::LIST_PER_PAGE) { |
56
|
|
|
$this->data['paginationPostsPerPage'] = $linesPerPage; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
$this->data['pagination'] = $pagination; |
60
|
|
|
$this->data['configs'] = $this->siteConfig->getSiteConfig(); |
61
|
|
|
$this->data["comments"] = $this->commentModel->getPendingCommentsList($pagination["offset"], $linesPerPage); |
62
|
|
|
$this->data['pendingView'] = true; |
63
|
|
|
|
64
|
|
|
$this->renderView('Admin/Comments'); |
65
|
|
|
|
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function moderateComment(int $commentId) |
|
|
|
|
69
|
|
|
{ |
70
|
|
|
$this->onlyAdmin(); |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
$this->renderView('Admin/ViewComment'); |
74
|
|
|
} |
75
|
|
|
} |