1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* Hosting Plugin for HiPanel |
5
|
|
|
* |
6
|
|
|
* @link https://github.com/hiqdev/hipanel-module-hosting |
7
|
|
|
* @package hipanel-module-hosting |
8
|
|
|
* @license BSD-3-Clause |
9
|
|
|
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace hipanel\modules\hosting\widgets\backup; |
13
|
|
|
|
14
|
|
|
use hipanel\modules\hosting\models\Backuping; |
15
|
|
|
use hipanel\modules\hosting\models\Hdomain; |
16
|
|
|
use Yii; |
17
|
|
|
use yii\base\Widget; |
18
|
|
|
use yii\helpers\Html; |
19
|
|
|
|
20
|
|
|
class BackupGridRow extends Widget |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var \hipanel\base\Model |
24
|
|
|
*/ |
25
|
|
|
public $model; |
26
|
|
|
|
27
|
|
|
public function run() |
28
|
|
|
{ |
29
|
|
|
if ($this->model->backuping_exists) { |
30
|
|
|
return $this->generateBackupingLink(); |
31
|
|
|
} else { |
32
|
|
|
return $this->generateBackupingEnableLink(); |
33
|
|
|
} |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
protected function getRealObjectId() |
37
|
|
|
{ |
38
|
|
|
$id = $this->model->id; |
39
|
|
|
|
40
|
|
|
if ($this->model instanceof Hdomain) { |
41
|
|
|
$id = $this->model->isAlias() ? $this->model->vhost_id : $this->model->id; |
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
return $id; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
protected function generateBackupingLink() |
48
|
|
|
{ |
49
|
|
|
$id = $this->getRealObjectId(); |
50
|
|
|
|
51
|
|
|
$linkToBackup = Html::a('<i class="fa fa-archive" aria-hidden="true"></i> ' . |
52
|
|
|
Yii::t('hipanel/hosting', 'Backup settings'), ['@backuping/view', 'id' => $id]); |
53
|
|
|
|
54
|
|
|
return $linkToBackup; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
protected function generateBackupingEnableLink() |
58
|
|
|
{ |
59
|
|
|
$text = '<i class="fa fa-check" aria-hidden="true"></i> '; |
60
|
|
|
$text .= Yii::t('hipanel/hosting', 'Enable backuping'); |
61
|
|
|
|
62
|
|
|
$linkToBackup = Html::a($text, ['@hdomain/enable-backuping'], [ |
63
|
|
|
'data-method' => 'POST', |
64
|
|
|
'data-params' => [ |
65
|
|
|
'Hdomain[id]' => $this->getRealObjectId() |
66
|
|
|
] |
67
|
|
|
]); |
68
|
|
|
|
69
|
|
|
return $linkToBackup; |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
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.