|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Radchasay\Overview; |
|
4
|
|
|
|
|
5
|
|
|
use \Anax\Configure\ConfigureInterface; |
|
6
|
|
|
use \Anax\Configure\ConfigureTrait; |
|
7
|
|
|
use \Anax\DI\InjectionAwareInterface; |
|
8
|
|
|
use \Anax\Di\InjectionAwareTrait; |
|
9
|
|
|
use \Radchasay\Comment\Post; |
|
10
|
|
|
use \Radchasay\Comment\Comment; |
|
11
|
|
|
use \Radchasay\Comment\CommentComments; |
|
12
|
|
|
use \Radchasay\Overview\Overview; |
|
13
|
|
|
use \Radchasay\Comment\PostCategory; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* A controller class. |
|
17
|
|
|
*/ |
|
18
|
|
|
class OverviewController implements |
|
19
|
|
|
ConfigureInterface, |
|
20
|
|
|
InjectionAwareInterface |
|
21
|
|
|
{ |
|
22
|
|
|
use ConfigureTrait, |
|
23
|
|
|
InjectionAwareTrait; |
|
24
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var $data description |
|
28
|
|
|
*/ |
|
29
|
|
|
//private $data; |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Description. |
|
34
|
|
|
* |
|
35
|
|
|
* @param datatype $variable Description |
|
|
|
|
|
|
36
|
|
|
* |
|
37
|
|
|
* @throws Exception |
|
38
|
|
|
* |
|
39
|
|
|
* @return void |
|
40
|
|
|
*/ |
|
41
|
|
View Code Duplication |
public function getIndex() |
|
|
|
|
|
|
42
|
|
|
{ |
|
43
|
|
|
$title = "A index page"; |
|
44
|
|
|
$view = $this->di->get("view"); |
|
45
|
|
|
$pageRender = $this->di->get("pageRender"); |
|
46
|
|
|
$db = $this->di->get("db"); |
|
47
|
|
|
|
|
48
|
|
|
$user = new User(); |
|
49
|
|
|
$user->setDb($db); |
|
50
|
|
|
$res = $user->getInformationLimit(5); |
|
51
|
|
|
|
|
52
|
|
|
var_dump($res); |
|
|
|
|
|
|
53
|
|
|
|
|
54
|
|
|
$data = [ |
|
55
|
|
|
"content" => "An index page", |
|
56
|
|
|
]; |
|
57
|
|
|
|
|
58
|
|
|
$view->add("default1/article", $data); |
|
59
|
|
|
|
|
60
|
|
|
$pageRender->renderPage(["title" => $title]); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function overview() |
|
64
|
|
|
{ |
|
65
|
|
|
$title = "Overview"; |
|
66
|
|
|
$view = $this->di->get("view"); |
|
67
|
|
|
$pageRender = $this->di->get("pageRender"); |
|
68
|
|
|
|
|
69
|
|
|
$posts = $this->getPosts(); |
|
70
|
|
|
|
|
71
|
|
|
$allPosts = []; |
|
72
|
|
|
|
|
73
|
|
View Code Duplication |
foreach ($posts as $p) { |
|
|
|
|
|
|
74
|
|
|
array_push($allPosts, [$p, $this->getTags([$p->postid])]); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
$data = [ |
|
78
|
|
|
"items" => $this->getUsers(), |
|
79
|
|
|
"posts" => $allPosts, |
|
80
|
|
|
"popularTags" => $this->getPopularTags() |
|
81
|
|
|
]; |
|
82
|
|
|
|
|
83
|
|
|
$view->add("overview/overview", $data); |
|
84
|
|
|
|
|
85
|
|
|
$pageRender->renderPage(["title" => $title]); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
View Code Duplication |
public function getUsers() |
|
|
|
|
|
|
89
|
|
|
{ |
|
90
|
|
|
$overview = new Overview(); |
|
91
|
|
|
|
|
92
|
|
|
$data = $overview->returnLimitUsers($this->di->get("db"), "points desc", 5); |
|
93
|
|
|
|
|
94
|
|
|
return $data; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function getPosts() |
|
98
|
|
|
{ |
|
99
|
|
|
$overview = new Overview(); |
|
100
|
|
|
|
|
101
|
|
|
$data = $overview->returnLimitPosts($this->di->get("db")); |
|
102
|
|
|
|
|
103
|
|
|
return $data; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
View Code Duplication |
public function getTags($id) |
|
|
|
|
|
|
107
|
|
|
{ |
|
108
|
|
|
$overview = new Overview(); |
|
109
|
|
|
|
|
110
|
|
|
$data = $overview->returnAllTagsFromPost($this->di->get("db"), [$id]); |
|
111
|
|
|
|
|
112
|
|
|
return $data; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
public function getPopularTags() |
|
116
|
|
|
{ |
|
117
|
|
|
$overview = new Overview(); |
|
118
|
|
|
|
|
119
|
|
|
$data = $overview->returnPopularTags($this->di->get("db")); |
|
120
|
|
|
|
|
121
|
|
|
return $data; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
View Code Duplication |
public function getCatName($id) |
|
|
|
|
|
|
125
|
|
|
{ |
|
126
|
|
|
$postcat = new PostCategory(); |
|
127
|
|
|
$postcat->setDb($this->di->get("db")); |
|
128
|
|
|
$res = $postcat->getCatName($id); |
|
129
|
|
|
return $res; |
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.