|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @package Cadmium\System\Modules\Profile |
|
5
|
|
|
* @author Anton Romanov |
|
6
|
|
|
* @copyright Copyright (c) 2015-2017, Anton Romanov |
|
7
|
|
|
* @link http://cadmium-cms.com |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Modules\Profile\Handler { |
|
11
|
|
|
|
|
12
|
|
|
use Frames, Modules\Auth, Utils\Range, Utils\View, Date, Geo\Country, Template; |
|
13
|
|
|
|
|
14
|
|
|
class Overview extends Frames\Site\Area\Authorized { |
|
15
|
|
|
|
|
16
|
|
|
protected $_title = 'TITLE_PROFILE'; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Get the contents block |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
private function getContents() : Template\Block { |
|
23
|
|
|
|
|
24
|
|
|
$contents = View::get('Blocks/Profile/Overview'); |
|
25
|
|
|
|
|
26
|
|
|
# Set general |
|
27
|
|
|
|
|
28
|
|
|
$contents->name = Auth::get('name'); |
|
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
$contents->email = Auth::get('email'); |
|
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
$contents->rank = (Range\Rank::get(Auth::get('rank')) ?? ''); |
|
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
$contents->time = Date::get(DATE_FORMAT_DATETIME, Auth::get('time_registered')); |
|
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
# Set sex |
|
37
|
|
|
|
|
38
|
|
|
$contents->sex = (Range\Sex::get(Auth::get('sex')) ?? ''); |
|
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
# Set full name & city |
|
41
|
|
|
|
|
42
|
|
|
foreach (['full_name', 'city'] as $name) { |
|
43
|
|
|
|
|
44
|
|
|
if ('' === ($text = Auth::get($name))) $contents->getBlock($name)->disable(); |
|
45
|
|
|
|
|
46
|
|
|
else $contents->getBlock($name)->text = $text; |
|
|
|
|
|
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
# Set country |
|
50
|
|
|
|
|
51
|
|
|
if ('' === ($country = Auth::get('country'))) $contents->getBlock('country')->disable(); else { |
|
52
|
|
|
|
|
53
|
|
|
$contents->getBlock('country')->code = $country; |
|
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
$contents->getBlock('country')->name = (Country::get($country) ?? ''); |
|
|
|
|
|
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
# ------------------------ |
|
59
|
|
|
|
|
60
|
|
|
return $contents; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Handle the request |
|
65
|
|
|
*/ |
|
66
|
|
|
|
|
67
|
|
|
protected function handle() : Template\Block { |
|
68
|
|
|
|
|
69
|
|
|
return $this->getContents(); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
Since your code implements the magic setter
_set, this function will be called for any write access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.