|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* HiPanel core package |
|
5
|
|
|
* |
|
6
|
|
|
* @link https://hipanel.com/ |
|
7
|
|
|
* @package hipanel-core |
|
8
|
|
|
* @license BSD-3-Clause |
|
9
|
|
|
* @copyright Copyright (c) 2014-2016, HiQDev (http://hiqdev.com/) |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace hipanel\base; |
|
13
|
|
|
|
|
14
|
|
|
use Yii; |
|
15
|
|
|
|
|
16
|
|
|
class Model extends \hiqdev\hiart\ActiveRecord |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* @var string the i18n dictionary name that will be used to translate labels of Model |
|
20
|
|
|
*/ |
|
21
|
|
|
public static $i18nDictionary = 'hipanel'; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* No rules be default. |
|
25
|
|
|
*/ |
|
26
|
|
|
public function rules() |
|
27
|
|
|
{ |
|
28
|
|
|
return []; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* return default labels for attribute. |
|
33
|
|
|
*/ |
|
34
|
|
|
public function defaultAttributeLabels() |
|
35
|
|
|
{ |
|
36
|
|
|
return [ |
|
37
|
|
|
'id' => Yii::t('hipanel', 'ID'), |
|
38
|
|
|
'remoteid' => Yii::t('hipanel', 'Remote ID'), |
|
39
|
|
|
'client' => Yii::t('hipanel', 'Client'), |
|
40
|
|
|
'client_id' => Yii::t('hipanel', 'Client'), |
|
41
|
|
|
'seller' => Yii::t('hipanel', 'Reseller'), |
|
42
|
|
|
'seller_id' => Yii::t('hipanel', 'Reseller'), |
|
43
|
|
|
'domain' => Yii::t('hipanel', 'Domain name'), |
|
44
|
|
|
'hdomain' => Yii::t('hipanel', 'Domain name'), |
|
45
|
|
|
'ns' => Yii::t('hipanel', 'Name Server'), |
|
46
|
|
|
'nss' => Yii::t('hipanel', 'Name Servers'), |
|
47
|
|
|
'server' => Yii::t('hipanel', 'Server'), |
|
48
|
|
|
'account' => Yii::t('hipanel', 'Account'), |
|
49
|
|
|
'service' => Yii::t('hipanel', 'Service'), |
|
50
|
|
|
'tariff' => Yii::t('hipanel', 'Tariff'), |
|
51
|
|
|
'contact' => Yii::t('hipanel', 'Contact'), |
|
52
|
|
|
'article' => Yii::t('hipanel', 'Article'), |
|
53
|
|
|
'host' => Yii::t('hipanel', 'Host'), |
|
54
|
|
|
'bill' => Yii::t('hipanel', 'Bill'), |
|
55
|
|
|
'backup' => Yii::t('hipanel', 'Backup'), |
|
56
|
|
|
'backuping' => Yii::t('hipanel', 'Backuping'), |
|
57
|
|
|
'crontab' => Yii::t('hipanel', 'Crontab'), |
|
58
|
|
|
'ip' => Yii::t('hipanel', 'IP'), |
|
59
|
|
|
'ips' => Yii::t('hipanel', 'IPs'), |
|
60
|
|
|
'mail' => Yii::t('hipanel', 'Mail'), |
|
61
|
|
|
'request' => Yii::t('hipanel', 'Request'), |
|
62
|
|
|
'db' => Yii::t('hipanel', 'Database'), |
|
63
|
|
|
'state' => Yii::t('hipanel', 'Status'), |
|
64
|
|
|
'status' => Yii::t('hipanel', 'Status'), |
|
65
|
|
|
'type' => Yii::t('hipanel', 'Type'), |
|
66
|
|
|
'note' => Yii::t('hipanel', 'Note'), |
|
67
|
|
|
'descr' => Yii::t('hipanel', 'Description'), |
|
68
|
|
|
'comment' => Yii::t('hipanel', 'Comment'), |
|
69
|
|
|
'created_date' => Yii::t('hipanel', 'Registered'), |
|
70
|
|
|
'updated_date' => Yii::t('hipanel', 'Last update'), |
|
71
|
|
|
]; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function attributeLabels() |
|
75
|
|
|
{ |
|
76
|
|
|
return $this->defaultAttributeLabels(); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
protected static $mergedLabels = []; |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Merge Attribute labels for Model. |
|
83
|
|
|
*/ |
|
84
|
|
|
public function mergeAttributeLabels($labels) |
|
85
|
|
|
{ |
|
86
|
|
|
if (!isset(static::$mergedLabels[static::class])) { |
|
87
|
|
|
$default = $this->defaultAttributeLabels(); |
|
88
|
|
|
foreach ($this->attributes() as $k) { |
|
89
|
|
|
$label = $labels[$k] ?: $default[$k]; |
|
90
|
|
|
if (!$label) { |
|
91
|
|
|
if (preg_match('/(.+)_[a-z]+$/', $k, $m)) { |
|
92
|
|
|
if (isset($labels[$m[1]])) { |
|
93
|
|
|
$label = $labels[$m[1]]; |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
if (!$label) { |
|
98
|
|
|
$toTranslate = preg_replace(['/_id$/', '/_label$/', '/_ids$/', '/_like$/'], [' ID', '', ' IDs', ''], $k); |
|
99
|
|
|
$toTranslate = preg_replace('/_/', ' ', $toTranslate); |
|
100
|
|
|
$label = Yii::t(static::$i18nDictionary, ucfirst($toTranslate)); |
|
101
|
|
|
} |
|
102
|
|
|
$labels[$k] = $label; |
|
103
|
|
|
} |
|
104
|
|
|
static::$mergedLabels[static::class] = $labels; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
return static::$mergedLabels[static::class]; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
public function getClient() |
|
111
|
|
|
{ |
|
112
|
|
|
return $this->client; |
|
|
|
|
|
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
public function getClientId() |
|
116
|
|
|
{ |
|
117
|
|
|
return $this->client_id; |
|
|
|
|
|
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
public function getSeller() |
|
121
|
|
|
{ |
|
122
|
|
|
return $this->seller; |
|
|
|
|
|
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
public function getSellerId() |
|
126
|
|
|
{ |
|
127
|
|
|
return $this->seller_id; |
|
|
|
|
|
|
128
|
|
|
} |
|
129
|
|
|
} |
|
130
|
|
|
|
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read 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.