|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* WebHemi. |
|
4
|
|
|
* |
|
5
|
|
|
* PHP version 7.1 |
|
6
|
|
|
* |
|
7
|
|
|
* @copyright 2012 - 2018 Gixx-web (http://www.gixx-web.com) |
|
8
|
|
|
* @license https://opensource.org/licenses/MIT The MIT License (MIT) |
|
9
|
|
|
* |
|
10
|
|
|
* @link http://www.gixx-web.com |
|
11
|
|
|
*/ |
|
12
|
|
|
declare(strict_types = 1); |
|
13
|
|
|
|
|
14
|
|
|
namespace WebHemi\Middleware\Action\Website\Directory; |
|
15
|
|
|
|
|
16
|
|
|
use RuntimeException; |
|
17
|
|
|
use WebHemi\Data\Entity; |
|
18
|
|
|
use WebHemi\Middleware\Action\Website\IndexAction; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Class UserAction |
|
22
|
|
|
*/ |
|
23
|
|
|
class UserAction extends IndexAction |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* Gets template map name or template file path. |
|
27
|
|
|
* |
|
28
|
|
|
* @return string |
|
29
|
|
|
*/ |
|
30
|
|
|
public function getTemplateName() : string |
|
31
|
|
|
{ |
|
32
|
|
|
return 'website-user'; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Gets template data. |
|
37
|
|
|
* |
|
38
|
|
|
* @return array |
|
39
|
|
|
*/ |
|
40
|
|
|
public function getTemplateData() : array |
|
41
|
|
|
{ |
|
42
|
|
|
$blogPosts = []; |
|
43
|
|
|
$parameters = $this->getRoutingParameters(); |
|
44
|
|
|
|
|
45
|
|
|
$userName = $parameters['basename'] ?? ''; |
|
46
|
|
|
|
|
47
|
|
|
if ($parameters['path'] == '/' || empty($userName)) { |
|
48
|
|
|
throw new RuntimeException('Forbidden', 403); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @var Entity\UserEntity $userEntity |
|
53
|
|
|
*/ |
|
54
|
|
|
$userEntity = $this->getUserStorage() |
|
55
|
|
|
->getUserByUserName($userName); |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @var array $userMeta |
|
59
|
|
|
*/ |
|
60
|
|
|
$userMeta = $this->getUserStorage() |
|
61
|
|
|
->getSimpleUserMetaListByUser((int) $userEntity->getUserId()); |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @var Entity\ApplicationEntity $applicationEntity |
|
65
|
|
|
*/ |
|
66
|
|
|
$applicationEntity = $this->getApplicationStorage() |
|
67
|
|
|
->getApplicationByName($this->environmentManager->getSelectedApplication()); |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @var Entity\EntitySet $publications |
|
71
|
|
|
*/ |
|
72
|
|
|
$publications = $this->getFilesystemStorage() |
|
73
|
|
|
->getFilesystemPublishedDocumentListByAuthor( |
|
74
|
|
|
$applicationEntity->getApplicationId(), |
|
75
|
|
|
$userEntity->getUserId() |
|
76
|
|
|
); |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @var Entity\FilesystemPublishedDocumentEntity $publishedDocumentEntity |
|
80
|
|
|
*/ |
|
81
|
|
|
foreach ($publications as $publishedDocumentEntity) { |
|
82
|
|
|
$blogPosts[] = $this->getBlobPostData($applicationEntity, $publishedDocumentEntity); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
return [ |
|
86
|
|
|
'activeMenu' => '', |
|
87
|
|
|
'user' => [ |
|
88
|
|
|
'userId' => $userEntity->getUserId(), |
|
89
|
|
|
'userName' => $userEntity->getUserName(), |
|
90
|
|
|
'url' => $this->environmentManager->getRequestUri(), |
|
91
|
|
|
'meta' => $userMeta, |
|
92
|
|
|
], |
|
93
|
|
|
'application' => $this->getApplicationData($applicationEntity), |
|
94
|
|
|
'blogPosts' => $blogPosts, |
|
95
|
|
|
]; |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|