|
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 = 'app'; |
|
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('app', 'ID'), |
|
38
|
|
|
'client_id' => Yii::t('app', 'Client'), |
|
39
|
|
|
'seller' => Yii::t('app', 'Reseller'), |
|
40
|
|
|
'seller_id' => Yii::t('app', 'Reseller'), |
|
41
|
|
|
'domain_id' => Yii::t('app', 'Domain ID'), |
|
42
|
|
|
'domain' => Yii::t('app', 'Domain Name'), |
|
43
|
|
|
'hdomain_id' => Yii::t('app', 'Domain ID'), |
|
44
|
|
|
'hdomain' => Yii::t('app', 'Domain Name'), |
|
45
|
|
|
'server_id' => Yii::t('app', 'Server ID'), |
|
46
|
|
|
'account_id' => Yii::t('app', 'Account ID'), |
|
47
|
|
|
'service_id' => Yii::t('app', 'Service ID'), |
|
48
|
|
|
'tariff_id' => Yii::t('app', 'Tariff ID'), |
|
49
|
|
|
'contact_id' => Yii::t('app', 'Contact ID'), |
|
50
|
|
|
'article_id' => Yii::t('app', 'Article ID'), |
|
51
|
|
|
'host_id' => Yii::t('app', 'Host ID'), |
|
52
|
|
|
'bill_id' => Yii::t('app', 'Bill ID'), |
|
53
|
|
|
'backup_id' => Yii::t('app', 'Backup ID'), |
|
54
|
|
|
'backuping_id' => Yii::t('app', 'Backuping ID'), |
|
55
|
|
|
'crontab_id' => Yii::t('app', 'Crontab ID'), |
|
56
|
|
|
'ip_id' => Yii::t('app', 'IP ID'), |
|
57
|
|
|
'ip' => Yii::t('app', 'IP'), |
|
58
|
|
|
'mail_id' => Yii::t('app', 'Mail ID'), |
|
59
|
|
|
'request_id' => Yii::t('app', 'Request ID'), |
|
60
|
|
|
'db_id' => Yii::t('app', 'DataBase ID'), |
|
61
|
|
|
'db' => Yii::t('app', 'DataBase'), |
|
62
|
|
|
'state_id' => Yii::t('app', 'Status ID'), |
|
63
|
|
|
'state_label' => Yii::t('app', 'Status label'), |
|
64
|
|
|
'state' => Yii::t('app', 'Status'), |
|
65
|
|
|
'type' => Yii::t('app', 'Type'), |
|
66
|
|
|
'type_id' => Yii::t('app', 'Type'), |
|
67
|
|
|
'type_label' => Yii::t('app', 'Type'), |
|
68
|
|
|
'descr' => Yii::t('app', 'Description'), |
|
69
|
|
|
]; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
protected static $mergedLabels = []; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Merge Attribute labels for Model. |
|
76
|
|
|
*/ |
|
77
|
|
|
public function mergeAttributeLabels($labels) |
|
78
|
|
|
{ |
|
79
|
|
|
if (!isset(static::$mergedLabels[static::class])) { |
|
80
|
|
|
$default = $this->defaultAttributeLabels(); |
|
81
|
|
|
foreach ($this->attributes() as $k) { |
|
82
|
|
|
$label = $labels[$k] ?: $default[$k]; |
|
83
|
|
|
if (!$label) { |
|
84
|
|
|
if (preg_match('/(.+)_[a-z]+$/', $k, $m)) { |
|
85
|
|
|
if (isset($labels[$m[1]])) { |
|
86
|
|
|
$label = $labels[$m[1]]; |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
if (!$label) { |
|
91
|
|
|
$toTranslate = preg_replace(['/_id$/', '/_label$/', '/_ids$/', '/_like$/'], [' ID', '', ' IDs', ''], $k); |
|
92
|
|
|
$toTranslate = preg_replace('/_/', ' ', $toTranslate); |
|
93
|
|
|
$label = Yii::t(static::$i18nDictionary, ucfirst($toTranslate)); |
|
94
|
|
|
} |
|
95
|
|
|
$labels[$k] = $label; |
|
96
|
|
|
} |
|
97
|
|
|
static::$mergedLabels[static::class] = $labels; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
return static::$mergedLabels[static::class]; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
public function getClient() |
|
104
|
|
|
{ |
|
105
|
|
|
return $this->client; |
|
|
|
|
|
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
public function getClientId() |
|
109
|
|
|
{ |
|
110
|
|
|
return $this->client_id; |
|
|
|
|
|
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
public function getSeller() |
|
114
|
|
|
{ |
|
115
|
|
|
return $this->seller; |
|
|
|
|
|
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
public function getSellerId() |
|
119
|
|
|
{ |
|
120
|
|
|
return $this->seller_id; |
|
|
|
|
|
|
121
|
|
|
} |
|
122
|
|
|
} |
|
123
|
|
|
|
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.