@@ 22-79 (lines=58) @@ | ||
19 | * |
|
20 | * @author Andrey Girnik <[email protected]> |
|
21 | */ |
|
22 | class AppAlbum extends Album |
|
23 | { |
|
24 | /** |
|
25 | * Application field. Corresponds to the file type of application. |
|
26 | * In the thml form field should also be called. |
|
27 | * Can have the values according with the selected type of: |
|
28 | * FileSetter::INSERTED_DATA_ID |
|
29 | * FileSetter::INSERTED_DATA_URL |
|
30 | * |
|
31 | * @var array application(array of 'mediafile id' or 'mediafile url'). |
|
32 | */ |
|
33 | public $application; |
|
34 | ||
35 | /** |
|
36 | * {@inheritdoc} |
|
37 | */ |
|
38 | public function rules() |
|
39 | { |
|
40 | return ArrayHelper::merge(parent::rules(), [ |
|
41 | [ |
|
42 | UploadModelInterface::FILE_TYPE_APP, |
|
43 | function($attribute) { |
|
44 | if (!is_array($this->{$attribute})) { |
|
45 | $this->addError($attribute, 'Application field content must be an array.'); |
|
46 | } |
|
47 | }, |
|
48 | 'skipOnError' => false, |
|
49 | ], |
|
50 | ]); |
|
51 | } |
|
52 | ||
53 | /** |
|
54 | * @inheritdoc |
|
55 | */ |
|
56 | public function behaviors() |
|
57 | { |
|
58 | return ArrayHelper::merge(parent::behaviors(), [ |
|
59 | 'mediafile' => [ |
|
60 | 'class' => BehaviorMediafile::class, |
|
61 | 'name' => self::ALBUM_TYPE_APP, |
|
62 | 'attributes' => [ |
|
63 | UploadModelInterface::FILE_TYPE_THUMB, |
|
64 | UploadModelInterface::FILE_TYPE_APP, |
|
65 | ], |
|
66 | ] |
|
67 | ]); |
|
68 | } |
|
69 | ||
70 | /** |
|
71 | * Get album's application files. |
|
72 | * |
|
73 | * @return ActiveRecord[] |
|
74 | */ |
|
75 | public function getAppFiles() |
|
76 | { |
|
77 | return OwnerMediafile::getMediaFiles($this->type, $this->id, static::getFileType(self::ALBUM_TYPE_APP)); |
|
78 | } |
|
79 | } |
|
80 |
@@ 22-79 (lines=58) @@ | ||
19 | * |
|
20 | * @author Andrey Girnik <[email protected]> |
|
21 | */ |
|
22 | class AudioAlbum extends Album |
|
23 | { |
|
24 | /** |
|
25 | * Audio field. Corresponds to the file type of audio. |
|
26 | * In the thml form field should also be called. |
|
27 | * Can have the values according with the selected type of: |
|
28 | * FileSetter::INSERTED_DATA_ID |
|
29 | * FileSetter::INSERTED_DATA_URL |
|
30 | * |
|
31 | * @var array audio(array of 'mediafile id' or 'mediafile url'). |
|
32 | */ |
|
33 | public $audio; |
|
34 | ||
35 | /** |
|
36 | * {@inheritdoc} |
|
37 | */ |
|
38 | public function rules() |
|
39 | { |
|
40 | return ArrayHelper::merge(parent::rules(), [ |
|
41 | [ |
|
42 | UploadModelInterface::FILE_TYPE_AUDIO, |
|
43 | function($attribute) { |
|
44 | if (!is_array($this->{$attribute})) { |
|
45 | $this->addError($attribute, 'Audio field content must be an array.'); |
|
46 | } |
|
47 | }, |
|
48 | 'skipOnError' => false, |
|
49 | ], |
|
50 | ]); |
|
51 | } |
|
52 | ||
53 | /** |
|
54 | * @inheritdoc |
|
55 | */ |
|
56 | public function behaviors() |
|
57 | { |
|
58 | return ArrayHelper::merge(parent::behaviors(), [ |
|
59 | 'mediafile' => [ |
|
60 | 'class' => BehaviorMediafile::class, |
|
61 | 'name' => self::ALBUM_TYPE_AUDIO, |
|
62 | 'attributes' => [ |
|
63 | UploadModelInterface::FILE_TYPE_THUMB, |
|
64 | UploadModelInterface::FILE_TYPE_AUDIO, |
|
65 | ], |
|
66 | ] |
|
67 | ]); |
|
68 | } |
|
69 | ||
70 | /** |
|
71 | * Get album's audio. |
|
72 | * |
|
73 | * @return ActiveRecord[] |
|
74 | */ |
|
75 | public function getAudioFiles() |
|
76 | { |
|
77 | return OwnerMediafile::getMediaFiles($this->type, $this->id, static::getFileType(self::ALBUM_TYPE_AUDIO)); |
|
78 | } |
|
79 | } |
|
80 |
@@ 22-79 (lines=58) @@ | ||
19 | * |
|
20 | * @author Andrey Girnik <[email protected]> |
|
21 | */ |
|
22 | class ImageAlbum extends Album |
|
23 | { |
|
24 | /** |
|
25 | * Image field. Corresponds to the file type of image. |
|
26 | * In the thml form field should also be called. |
|
27 | * Can have the values according with the selected type of: |
|
28 | * FileSetter::INSERTED_DATA_ID |
|
29 | * FileSetter::INSERTED_DATA_URL |
|
30 | * |
|
31 | * @var array image(array of 'mediafile id' or 'mediafile url'). |
|
32 | */ |
|
33 | public $image; |
|
34 | ||
35 | /** |
|
36 | * {@inheritdoc} |
|
37 | */ |
|
38 | public function rules() |
|
39 | { |
|
40 | return ArrayHelper::merge(parent::rules(), [ |
|
41 | [ |
|
42 | UploadModelInterface::FILE_TYPE_IMAGE, |
|
43 | function($attribute) { |
|
44 | if (!is_array($this->{$attribute})) { |
|
45 | $this->addError($attribute, 'Image field content must be an array.'); |
|
46 | } |
|
47 | }, |
|
48 | 'skipOnError' => false, |
|
49 | ], |
|
50 | ]); |
|
51 | } |
|
52 | ||
53 | /** |
|
54 | * @inheritdoc |
|
55 | */ |
|
56 | public function behaviors() |
|
57 | { |
|
58 | return ArrayHelper::merge(parent::behaviors(), [ |
|
59 | 'mediafile' => [ |
|
60 | 'class' => BehaviorMediafile::class, |
|
61 | 'name' => self::ALBUM_TYPE_IMAGE, |
|
62 | 'attributes' => [ |
|
63 | UploadModelInterface::FILE_TYPE_THUMB, |
|
64 | UploadModelInterface::FILE_TYPE_IMAGE, |
|
65 | ], |
|
66 | ] |
|
67 | ]); |
|
68 | } |
|
69 | ||
70 | /** |
|
71 | * Get album's images. |
|
72 | * |
|
73 | * @return ActiveRecord[] |
|
74 | */ |
|
75 | public function getImageFiles() |
|
76 | { |
|
77 | return OwnerMediafile::getMediaFiles($this->type, $this->id, static::getFileType(self::ALBUM_TYPE_IMAGE)); |
|
78 | } |
|
79 | } |
|
80 |
@@ 22-79 (lines=58) @@ | ||
19 | * |
|
20 | * @author Andrey Girnik <[email protected]> |
|
21 | */ |
|
22 | class OtherAlbum extends Album |
|
23 | { |
|
24 | /** |
|
25 | * Other field. Corresponds to the file type of other. |
|
26 | * In the thml form field should also be called. |
|
27 | * Can have the values according with the selected type of: |
|
28 | * FileSetter::INSERTED_DATA_ID |
|
29 | * FileSetter::INSERTED_DATA_URL |
|
30 | * |
|
31 | * @var array other(array of 'mediafile id' or 'mediafile url'). |
|
32 | */ |
|
33 | public $other; |
|
34 | ||
35 | /** |
|
36 | * {@inheritdoc} |
|
37 | */ |
|
38 | public function rules() |
|
39 | { |
|
40 | return ArrayHelper::merge(parent::rules(), [ |
|
41 | [ |
|
42 | UploadModelInterface::FILE_TYPE_OTHER, |
|
43 | function($attribute) { |
|
44 | if (!is_array($this->{$attribute})) { |
|
45 | $this->addError($attribute, 'Other field content must be an array.'); |
|
46 | } |
|
47 | }, |
|
48 | 'skipOnError' => false, |
|
49 | ], |
|
50 | ]); |
|
51 | } |
|
52 | ||
53 | /** |
|
54 | * @inheritdoc |
|
55 | */ |
|
56 | public function behaviors() |
|
57 | { |
|
58 | return ArrayHelper::merge(parent::behaviors(), [ |
|
59 | 'mediafile' => [ |
|
60 | 'class' => BehaviorMediafile::class, |
|
61 | 'name' => self::ALBUM_TYPE_OTHER, |
|
62 | 'attributes' => [ |
|
63 | UploadModelInterface::FILE_TYPE_THUMB, |
|
64 | UploadModelInterface::FILE_TYPE_OTHER, |
|
65 | ], |
|
66 | ] |
|
67 | ]); |
|
68 | } |
|
69 | ||
70 | /** |
|
71 | * Get album's other files. |
|
72 | * |
|
73 | * @return ActiveRecord[] |
|
74 | */ |
|
75 | public function getOtherFiles() |
|
76 | { |
|
77 | return OwnerMediafile::getMediaFiles($this->type, $this->id, static::getFileType(self::ALBUM_TYPE_OTHER)); |
|
78 | } |
|
79 | } |
|
80 |
@@ 22-79 (lines=58) @@ | ||
19 | * |
|
20 | * @author Andrey Girnik <[email protected]> |
|
21 | */ |
|
22 | class TextAlbum extends Album |
|
23 | { |
|
24 | /** |
|
25 | * Text field. Corresponds to the file type of text. |
|
26 | * In the thml form field should also be called. |
|
27 | * Can have the values according with the selected type of: |
|
28 | * FileSetter::INSERTED_DATA_ID |
|
29 | * FileSetter::INSERTED_DATA_URL |
|
30 | * |
|
31 | * @var array text(array of 'mediafile id' or 'mediafile url'). |
|
32 | */ |
|
33 | public $text; |
|
34 | ||
35 | /** |
|
36 | * {@inheritdoc} |
|
37 | */ |
|
38 | public function rules() |
|
39 | { |
|
40 | return ArrayHelper::merge(parent::rules(), [ |
|
41 | [ |
|
42 | UploadModelInterface::FILE_TYPE_TEXT, |
|
43 | function($attribute) { |
|
44 | if (!is_array($this->{$attribute})) { |
|
45 | $this->addError($attribute, 'Text field content must be an array.'); |
|
46 | } |
|
47 | }, |
|
48 | 'skipOnError' => false, |
|
49 | ], |
|
50 | ]); |
|
51 | } |
|
52 | ||
53 | /** |
|
54 | * @inheritdoc |
|
55 | */ |
|
56 | public function behaviors() |
|
57 | { |
|
58 | return ArrayHelper::merge(parent::behaviors(), [ |
|
59 | 'mediafile' => [ |
|
60 | 'class' => BehaviorMediafile::class, |
|
61 | 'name' => self::ALBUM_TYPE_TEXT, |
|
62 | 'attributes' => [ |
|
63 | UploadModelInterface::FILE_TYPE_THUMB, |
|
64 | UploadModelInterface::FILE_TYPE_TEXT, |
|
65 | ], |
|
66 | ] |
|
67 | ]); |
|
68 | } |
|
69 | ||
70 | /** |
|
71 | * Get album's text files. |
|
72 | * |
|
73 | * @return ActiveRecord[] |
|
74 | */ |
|
75 | public function getTextFiles() |
|
76 | { |
|
77 | return OwnerMediafile::getMediaFiles($this->type, $this->id, static::getFileType(self::ALBUM_TYPE_TEXT)); |
|
78 | } |
|
79 | } |
|
80 |
@@ 22-79 (lines=58) @@ | ||
19 | * |
|
20 | * @author Andrey Girnik <[email protected]> |
|
21 | */ |
|
22 | class VideoAlbum extends Album |
|
23 | { |
|
24 | /** |
|
25 | * Video field. Corresponds to the file type of video. |
|
26 | * In the thml form field should also be called. |
|
27 | * Can have the values according with the selected type of: |
|
28 | * FileSetter::INSERTED_DATA_ID |
|
29 | * FileSetter::INSERTED_DATA_URL |
|
30 | * |
|
31 | * @var array video(array of 'mediafile id' or 'mediafile url'). |
|
32 | */ |
|
33 | public $video; |
|
34 | ||
35 | /** |
|
36 | * {@inheritdoc} |
|
37 | */ |
|
38 | public function rules() |
|
39 | { |
|
40 | return ArrayHelper::merge(parent::rules(), [ |
|
41 | [ |
|
42 | UploadModelInterface::FILE_TYPE_VIDEO, |
|
43 | function($attribute) { |
|
44 | if (!is_array($this->{$attribute})) { |
|
45 | $this->addError($attribute, 'Video field content must be an array.'); |
|
46 | } |
|
47 | }, |
|
48 | 'skipOnError' => false, |
|
49 | ], |
|
50 | ]); |
|
51 | } |
|
52 | ||
53 | /** |
|
54 | * @inheritdoc |
|
55 | */ |
|
56 | public function behaviors() |
|
57 | { |
|
58 | return ArrayHelper::merge(parent::behaviors(), [ |
|
59 | 'mediafile' => [ |
|
60 | 'class' => BehaviorMediafile::class, |
|
61 | 'name' => self::ALBUM_TYPE_VIDEO, |
|
62 | 'attributes' => [ |
|
63 | UploadModelInterface::FILE_TYPE_THUMB, |
|
64 | UploadModelInterface::FILE_TYPE_VIDEO, |
|
65 | ], |
|
66 | ] |
|
67 | ]); |
|
68 | } |
|
69 | ||
70 | /** |
|
71 | * Get album's video. |
|
72 | * |
|
73 | * @return ActiveRecord[] |
|
74 | */ |
|
75 | public function getVideoFiles() |
|
76 | { |
|
77 | return OwnerMediafile::getMediaFiles($this->type, $this->id, static::getFileType(self::ALBUM_TYPE_VIDEO)); |
|
78 | } |
|
79 | } |
|
80 |