1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* HiPanel core package |
4
|
|
|
* |
5
|
|
|
* @link https://hipanel.com/ |
6
|
|
|
* @package hipanel-core |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
* @copyright Copyright (c) 2014-2019, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace hipanel\base; |
12
|
|
|
|
13
|
|
|
use hipanel\models\Blocking; |
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
|
|
|
'states' => Yii::t('hipanel', 'Statuses'), |
66
|
|
|
'type' => Yii::t('hipanel', 'Type'), |
67
|
|
|
'types' => Yii::t('hipanel', 'Types'), |
68
|
|
|
'note' => Yii::t('hipanel', 'Note'), |
69
|
|
|
'descr' => Yii::t('hipanel', 'Description'), |
70
|
|
|
'comment' => Yii::t('hipanel', 'Comment'), |
71
|
|
|
'created_date' => Yii::t('hipanel', 'Registered'), |
72
|
|
|
'updated_date' => Yii::t('hipanel', 'Last update'), |
73
|
|
|
]; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function attributeLabels() |
77
|
|
|
{ |
78
|
|
|
return $this->defaultAttributeLabels(); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
protected static $mergedLabels = []; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Merge Attribute labels for Model. |
85
|
|
|
*/ |
86
|
|
|
public function mergeAttributeLabels($labels) |
87
|
|
|
{ |
88
|
|
|
if (!isset(static::$mergedLabels[static::class])) { |
89
|
|
|
$default = $this->defaultAttributeLabels(); |
90
|
|
|
foreach ($this->attributes() as $k) { |
91
|
|
|
$label = $labels[$k] ?: $default[$k]; |
92
|
|
|
if (!$label) { |
93
|
|
|
if (preg_match('/(.+)_[a-z]+$/', $k, $m)) { |
94
|
|
|
if (isset($labels[$m[1]])) { |
95
|
|
|
$label = $labels[$m[1]]; |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
if (!$label) { |
100
|
|
|
$toTranslate = preg_replace(['/_id$/', '/_label$/', '/_ids$/', '/_like$/'], [' ID', '', ' IDs', ''], $k); |
101
|
|
|
$toTranslate = preg_replace('/_/', ' ', $toTranslate); |
102
|
|
|
$label = Yii::t(static::$i18nDictionary, ucfirst($toTranslate)); |
103
|
|
|
} |
104
|
|
|
$labels[$k] = $label; |
105
|
|
|
} |
106
|
|
|
static::$mergedLabels[static::class] = $labels; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
return static::$mergedLabels[static::class]; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function getClient() |
113
|
|
|
{ |
114
|
|
|
return $this->client; |
|
|
|
|
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function getClientId() |
118
|
|
|
{ |
119
|
|
|
return $this->client_id; |
|
|
|
|
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function getSeller() |
123
|
|
|
{ |
124
|
|
|
return $this->seller; |
|
|
|
|
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
public function getSellerId() |
128
|
|
|
{ |
129
|
|
|
return $this->seller_id; |
|
|
|
|
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
public function getBlocking() |
133
|
|
|
{ |
134
|
|
|
return $this->hasOne(Blocking::class, ['id' => 'id']); |
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
|
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@property
annotation 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.