1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @link https://github.com/yiimaker/yii2-banner |
4
|
|
|
* @copyright Copyright (c) 2017 Yii Maker |
5
|
|
|
* @license BSD 3-Clause License |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace ymaker\banner\backend\models\entities; |
9
|
|
|
|
10
|
|
|
use ymaker\banner\backend\Module as BannerModule; |
11
|
|
|
use ymaker\banner\common\models\entities\BannerTranslation as CommonBannerTranslation; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* This is the model class for table "{{%banner_translation}}". |
15
|
|
|
* |
16
|
|
|
* @author Vladimir Kuprienko <[email protected]> |
17
|
|
|
* @since 1.0 |
18
|
|
|
*/ |
19
|
|
|
class BannerTranslation extends CommonBannerTranslation |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var \yii\web\UploadedFile |
23
|
|
|
*/ |
24
|
|
|
public $imageFile; |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Returns internal form name. |
29
|
|
|
* |
30
|
|
|
* @return string |
31
|
|
|
*/ |
32
|
|
|
public static function internalFormName() |
33
|
|
|
{ |
34
|
|
|
$reflector = new \ReflectionClass(self::class); |
35
|
|
|
return $reflector->getShortName(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @inheritdoc |
40
|
|
|
*/ |
41
|
|
|
public function formName() |
42
|
|
|
{ |
43
|
|
|
return parent::formName() . '[' . $this->language . ']'; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @inheritdoc |
48
|
|
|
*/ |
49
|
|
|
public function rules() |
50
|
|
|
{ |
51
|
|
|
return [ |
52
|
|
|
['banner_id', 'safe'], |
53
|
|
|
|
54
|
|
|
['language', 'safe'], |
55
|
|
|
|
56
|
|
|
['content', 'string'], |
57
|
|
|
|
58
|
|
|
['hint', 'string', 'max' => 255], |
59
|
|
|
|
60
|
|
|
['file_name', 'string', 'max' => 255], |
61
|
|
|
|
62
|
|
|
['alt', 'string', 'max' => 255], |
63
|
|
|
|
64
|
|
|
['link', 'string', 'max' => 255], |
65
|
|
|
['link', 'default', 'value' => '#'], |
66
|
|
|
|
67
|
|
|
['imageFile', 'file', 'extensions' => 'png, jpg, gif, svg'], |
68
|
|
|
]; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @inheritdoc |
73
|
|
|
*/ |
74
|
|
|
public function attributeLabels() |
75
|
|
|
{ |
76
|
|
|
$labels = [ |
77
|
|
|
'content' => BannerModule::t('Content'), |
78
|
|
|
'hint' => BannerModule::t('Hint'), |
79
|
|
|
'alt' => BannerModule::t('Alt'), |
80
|
|
|
'link' => BannerModule::t('Link'), |
81
|
|
|
'imageFile' => BannerModule::t('Banner image'), |
82
|
|
|
]; |
83
|
|
|
|
84
|
|
|
foreach ($labels as $key => $label) { |
85
|
|
|
$labels[$key] = $this->addLabelPostfix($label); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
return $labels; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Adds prefix to label. |
93
|
|
|
* |
94
|
|
|
* @param string $label |
95
|
|
|
* @return string |
96
|
|
|
*/ |
97
|
|
|
protected function addLabelPostfix($label) |
98
|
|
|
{ |
99
|
|
|
return $label . ' [' . $this->language . ']'; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|