This repository has been archived by the owner on Jun 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathModule.php
127 lines (110 loc) · 4.13 KB
/
Module.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
namespace bupy7\pages;
use Yii;
use yii\base\InvalidConfigException;
/**
* Module implements CRUD with static pages.
*
* @author Vasilij Belosludcev http://mihaly4.ru
* @since 1.0.0
*/
class Module extends \yii\base\Module
{
/**
* @var string Table name of model \bupy7\pages\models\Page.
* @see \yii\db\ActiveRecord::tableName()
*/
public $tableName = '{{%page}}';
/**
* @var boolean Enable ability add images via Imperavi Redactor? If this property is 'true', you must be
* set property '$pathToImages' and '$urlToImages'.
*/
public $addImage = false;
/**
* @var boolean Enable ability upload images via Imperavi Redactor? If this property is 'true', you must be
* set property '$pathToImages', '$urlToImages' and '$imageUploadAction'.
*/
public $uploadImage = false;
/**
* @var string Alias of absolute path to directory with images for upload images via Imperavi Redactor. If not
* set, then this ability not used.
* @example '@webroot/uploads/images'
* @see \vova07\imperavi\actions\GetAction::$path
*/
public $pathToImages;
/**
* @var string Alias of URL to directory with images for get images uploaded via Imperavi Redactor. If not set,
* then this ability not used.
* @example '@web/uploads/images'
* @see \vova07\imperavi\actions\GetAction::$url
*/
public $urlToImages;
/**
* @var boolean Enable ability add files via Imperavi Redactor? If this property is 'true', you must be
* set property '$pathToFiles' and '$urlToFiles'.
*/
public $addFile = false;
/**
* @var boolean Enable ability upload files via Imperavi Redactor? If this property is 'true', you must be
* set property '$pathToFiles', '$urlToFiles' and '$fileUploadAction'.
*/
public $uploadFile = false;
/**
* @var string Alias of absolute path to directory with files for upload files via Imperavi Redactor. If not set,
* then this ability not used.
* @example '@webroot/uploads/files'
* @see \vova07\imperavi\actions\GetAction::$path
*/
public $pathToFiles;
/**
* @var string Alias of URL to directory with files for uploaded files via Imperavi Redactor. If not set, then
* this ability not used.
* @example '@web/uploads/files'
* @see \vova07\imperavi\actions\GetAction::$url
*/
public $urlToFiles;
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (($this->addImage || $this->uploadImage) && !($this->pathToImages && $this->urlToImages)) {
throw new InvalidConfigException("For add or upload image via Imperavi Redactor you must be set"
. " 'pathToImages' and 'urlToImages'.");
}
if (($this->addFile || $this->uploadFile) && !($this->pathToFiles && $this->urlToFiles)) {
throw new InvalidConfigException("For add or upload file via Imperavi Redactor you must be set"
. " 'pathToFiles' and 'urlToFiles'.");
}
$this->registerTranslations();
}
/**
* Registeration translation files.
*/
public function registerTranslations()
{
Yii::$app->i18n->translations['bupy7/pages/*'] = [
'class' => 'yii\i18n\PhpMessageSource',
'sourceLanguage' => 'en',
'forceTranslation' => true,
'basePath' => '@bupy7/pages/messages',
'fileMap' => [
'bupy7/pages/core' => 'core.php',
],
];
}
/**
* Translates a message to the specified language.
*
* @param string $message the message to be translated.
* @param array $params the parameters that will be used to replace the corresponding placeholders in the message.
* @param string $language the language code (e.g. `en-US`, `en`). If this is null, the current application language
* will be used.
* @return string
*/
public static function t($message, $params = [], $language = null)
{
return Yii::t('bupy7/pages/core', $message, $params, $language);
}
}