forked from typecho/typecho
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStat.php
340 lines (314 loc) · 10.3 KB
/
Stat.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<?php
namespace Widget;
if (!defined('__TYPECHO_ROOT_DIR__')) {
exit;
}
/**
* 全局统计组件
*
* @property-read int $publishedPostsNum
* @property-read int $waitingPostsNum
* @property-read int $draftPostsNum
* @property-read int $myPublishedPostsNum
* @property-read int $myWaitingPostsNum
* @property-read int $myDraftPostsNum
* @property-read int $currentPublishedPostsNum
* @property-read int $currentWaitingPostsNum
* @property-read int $currentDraftPostsNum
* @property-read int $publishedPagesNum
* @property-read int $draftPagesNum
* @property-read int $publishedCommentsNum
* @property-read int $waitingCommentsNum
* @property-read int $spamCommentsNum
* @property-read int $myPublishedCommentsNum
* @property-read int $myWaitingCommentsNum
* @property-read int $mySpamCommentsNum
* @property-read int $currentCommentsNum
* @property-read int $currentPublishedCommentsNum
* @property-read int $currentWaitingCommentsNum
* @property-read int $currentSpamCommentsNum
* @property-read int $categoriesNum
* @property-read int $tagsNum
*/
class Stat extends Base
{
/**
* @param int $components
*/
protected function initComponents(int &$components)
{
$components = self::INIT_USER;
}
/**
* 获取已发布的文章数目
*
* @return integer
*/
protected function ___publishedPostsNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(cid)' => 'num'])
->from('table.contents')
->where('table.contents.type = ?', 'post')
->where('table.contents.status = ?', 'publish'))->num;
}
/**
* 获取待审核的文章数目
*
* @return integer
*/
protected function ___waitingPostsNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(cid)' => 'num'])
->from('table.contents')
->where('table.contents.type = ? OR table.contents.type = ?', 'post', 'post_draft')
->where('table.contents.status = ?', 'waiting'))->num;
}
/**
* 获取草稿文章数目
*
* @return integer
*/
protected function ___draftPostsNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(cid)' => 'num'])
->from('table.contents')
->where('table.contents.type = ?', 'post_draft'))->num;
}
/**
* 获取当前用户已发布的文章数目
*
* @return integer
*/
protected function ___myPublishedPostsNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(cid)' => 'num'])
->from('table.contents')
->where('table.contents.type = ?', 'post')
->where('table.contents.status = ?', 'publish')
->where('table.contents.authorId = ?', $this->user->uid))->num;
}
/**
* 获取当前用户待审核文章数目
*
* @return integer
*/
protected function ___myWaitingPostsNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(cid)' => 'num'])
->from('table.contents')
->where('table.contents.type = ? OR table.contents.type = ?', 'post', 'post_draft')
->where('table.contents.status = ?', 'waiting')
->where('table.contents.authorId = ?', $this->user->uid))->num;
}
/**
* 获取当前用户草稿文章数目
*
* @return integer
*/
protected function ___myDraftPostsNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(cid)' => 'num'])
->from('table.contents')
->where('table.contents.type = ?', 'post_draft')
->where('table.contents.authorId = ?', $this->user->uid))->num;
}
/**
* 获取当前用户已发布的文章数目
*
* @return integer
*/
protected function ___currentPublishedPostsNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(cid)' => 'num'])
->from('table.contents')
->where('table.contents.type = ?', 'post')
->where('table.contents.status = ?', 'publish')
->where('table.contents.authorId = ?', $this->request->filter('int')->get('uid')))->num;
}
/**
* 获取当前用户待审核文章数目
*
* @return integer
*/
protected function ___currentWaitingPostsNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(cid)' => 'num'])
->from('table.contents')
->where('table.contents.type = ? OR table.contents.type = ?', 'post', 'post_draft')
->where('table.contents.status = ?', 'waiting')
->where('table.contents.authorId = ?', $this->request->filter('int')->get('uid')))->num;
}
/**
* 获取当前用户草稿文章数目
*
* @return integer
*/
protected function ___currentDraftPostsNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(cid)' => 'num'])
->from('table.contents')
->where('table.contents.type = ?', 'post_draft')
->where('table.contents.authorId = ?', $this->request->filter('int')->get('uid')))->num;
}
/**
* 获取已发布页面数目
*
* @return integer
*/
protected function ___publishedPagesNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(cid)' => 'num'])
->from('table.contents')
->where('table.contents.type = ?', 'page')
->where('table.contents.status = ?', 'publish'))->num;
}
/**
* 获取草稿页面数目
*
* @return integer
*/
protected function ___draftPagesNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(cid)' => 'num'])
->from('table.contents')
->where('table.contents.type = ?', 'page_draft'))->num;
}
/**
* 获取当前显示的评论数目
*
* @return integer
*/
protected function ___publishedCommentsNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(coid)' => 'num'])
->from('table.comments')
->where('table.comments.status = ?', 'approved'))->num;
}
/**
* 获取当前待审核的评论数目
*
* @return integer
*/
protected function ___waitingCommentsNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(coid)' => 'num'])
->from('table.comments')
->where('table.comments.status = ?', 'waiting'))->num;
}
/**
* 获取当前垃圾评论数目
*
* @return integer
*/
protected function ___spamCommentsNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(coid)' => 'num'])
->from('table.comments')
->where('table.comments.status = ?', 'spam'))->num;
}
/**
* 获取当前用户显示的评论数目
*
* @return integer
*/
protected function ___myPublishedCommentsNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(coid)' => 'num'])
->from('table.comments')
->where('table.comments.status = ?', 'approved')
->where('table.comments.ownerId = ?', $this->user->uid))->num;
}
/**
* 获取当前用户待审核的评论数目
*
* @return integer
*/
protected function ___myWaitingCommentsNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(coid)' => 'num'])
->from('table.comments')
->where('table.comments.status = ?', 'waiting')
->where('table.comments.ownerId = ?', $this->user->uid))->num;
}
/**
* 获取当前用户垃圾评论数目
*
* @return integer
*/
protected function ___mySpamCommentsNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(coid)' => 'num'])
->from('table.comments')
->where('table.comments.status = ?', 'spam')
->where('table.comments.ownerId = ?', $this->user->uid))->num;
}
/**
* 获取当前文章的评论数目
*
* @return integer
*/
protected function ___currentCommentsNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(coid)' => 'num'])
->from('table.comments')
->where('table.comments.cid = ?', $this->request->filter('int')->get('cid')))->num;
}
/**
* 获取当前文章显示的评论数目
*
* @return integer
*/
protected function ___currentPublishedCommentsNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(coid)' => 'num'])
->from('table.comments')
->where('table.comments.status = ?', 'approved')
->where('table.comments.cid = ?', $this->request->filter('int')->get('cid')))->num;
}
/**
* 获取当前文章待审核的评论数目
*
* @return integer
*/
protected function ___currentWaitingCommentsNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(coid)' => 'num'])
->from('table.comments')
->where('table.comments.status = ?', 'waiting')
->where('table.comments.cid = ?', $this->request->filter('int')->get('cid')))->num;
}
/**
* 获取当前文章垃圾评论数目
*
* @return integer
*/
protected function ___currentSpamCommentsNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(coid)' => 'num'])
->from('table.comments')
->where('table.comments.status = ?', 'spam')
->where('table.comments.cid = ?', $this->request->filter('int')->get('cid')))->num;
}
/**
* 获取分类数目
*
* @return integer
*/
protected function ___categoriesNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(mid)' => 'num'])
->from('table.metas')
->where('table.metas.type = ?', 'category'))->num;
}
/**
* 获取标签数目
*
* @return integer
*/
protected function ___tagsNum(): int
{
return $this->db->fetchObject($this->db->select(['COUNT(mid)' => 'num'])
->from('table.metas')
->where('table.metas.type = ?', 'tag'))->num;
}
}