|
15 | 15 |
|
16 | 16 | $errors = null; |
17 | 17 |
|
18 | | -if($model->hasErrors()) { |
| 18 | +if ($model->hasErrors()) { |
19 | 19 | $errors = Html::errorSummary($model, [ |
20 | | - 'header' => '<strong>'.Yii::t('TranslationModule.base', 'The translations for {settings} could not be loaded:', $model->getMessageSettingString()).'</strong>', |
| 20 | + 'header' => '<strong>' . Yii::t('TranslationModule.base', 'The translations for {settings} could not be loaded:', $model->getMessageSettingString()) . '</strong>', |
21 | 21 | ]); |
22 | 22 |
|
23 | 23 | // Fallback to default selection |
24 | 24 | $model = new TranslationForm(); |
25 | 25 | $model->load([]); |
26 | 26 |
|
27 | | - if(!$model->validate()) { |
| 27 | + if (!$model->validate()) { |
28 | 28 | throw new NotFoundHttpException(); |
29 | 29 | } |
30 | 30 | } |
31 | 31 |
|
32 | 32 | $hasParentLanguage = $model->getParentLanguage() !== null; |
| 33 | +$canManage = $model->canManage(); |
33 | 34 | ?> |
34 | 35 |
|
35 | 36 | <?= Html::beginTag('div', $options) ?> |
|
72 | 73 |
|
73 | 74 | <div class="panel-body"> |
74 | 75 |
|
75 | | - <?php if(!empty($errors)) : ?> |
| 76 | + <?php if (!empty($errors)) : ?> |
76 | 77 |
|
77 | 78 | <div class="alert alert-danger"> |
78 | 79 | <?= $errors ?> |
|
95 | 96 | </div> |
96 | 97 |
|
97 | 98 | <p class="clearfix" style="margin-bottom:0"> |
98 | | - <?= Button::save()->submit()->right() ?> |
| 99 | + <?= $canManage ? Button::save()->submit()->right() : '' ?> |
99 | 100 | </p> |
100 | 101 |
|
101 | 102 | <hr class="mt-0"> |
|
111 | 112 | <div class="elem"> |
112 | 113 | <div class="pre"><?= Html::encode($original) ?></div> |
113 | 114 | <div> |
114 | | - <?= Button::light('<span>' . Yii::t('TranslationModule.base', 'Adopt original language') . '</span>') |
| 115 | + <?= $canManage |
| 116 | + ? Button::light('<span>' . Yii::t('TranslationModule.base', 'Adopt original language') . '</span>') |
115 | 117 | ->icon('arrow-right') |
116 | 118 | ->action('copyOriginal') |
117 | 119 | ->tooltip(Yii::t('TranslationModule.base', 'Adopt original language')) |
118 | | - ->loader(false) ?> |
| 120 | + ->loader(false) |
| 121 | + : '' ?> |
119 | 122 | </div> |
120 | 123 | </div> |
121 | 124 | <div class="elem <?= $model->getTranslationFieldClass($original) ?>"> |
122 | 125 | <div> |
123 | | - <?= Html::textArea(TranslationLog::tid($original), $translated, [ |
124 | | - 'class' => 'form-control translation ' . (empty($translated) ? 'empty' : 'translated'), |
125 | | - 'placeholder' => $model->parentMessages[$original] ?? '', |
126 | | - ]) ?> |
| 126 | + <?php if ($canManage) : ?> |
| 127 | + <?= Html::textArea(TranslationLog::tid($original), $translated, [ |
| 128 | + 'class' => 'form-control translation ' . (empty($translated) ? 'empty' : 'translated'), |
| 129 | + 'placeholder' => $model->parentMessages[$original] ?? '', |
| 130 | + ]) ?> |
| 131 | + <?php else : ?> |
| 132 | + <div class="pre"><?= Html::encode($translated) ?></div> |
| 133 | + <?php endif; ?> |
127 | 134 |
|
128 | | - <?php if(!empty($model->getHelpBlockMessage($original))) : ?> |
| 135 | + <?php if (!empty($model->getHelpBlockMessage($original))) : ?> |
129 | 136 | <p class="form-text"><?= Html::encode($model->getHelpBlockMessage($original)) ?></p> |
130 | 137 | <?php endif; ?> |
131 | 138 | </div> |
|
136 | 143 | ->tooltip(Yii::t('TranslationModule.base', 'View translation history')) |
137 | 144 | ->loader(false) ?> |
138 | 145 |
|
139 | | - <?= $hasParentLanguage ? |
140 | | - Button::success('<span>' . Yii::t('TranslationModule.base', 'Confirm translation') . '</span>') |
| 146 | + <?= $hasParentLanguage && $canManage |
| 147 | + ? Button::success('<span>' . Yii::t('TranslationModule.base', 'Confirm translation') . '</span>') |
141 | 148 | ->icon('check') |
142 | 149 | ->action('copyParent') |
143 | 150 | ->tooltip(Yii::t('TranslationModule.base', 'Confirm translation')) |
144 | 151 | ->cssClass($translated === '' ? '' : 'translation-confirm-approved') |
145 | | - ->loader(false) : '' ?> |
| 152 | + ->loader(false) |
| 153 | + : '' ?> |
146 | 154 | </div> |
147 | 155 | </div> |
148 | 156 | </div> |
|
152 | 160 | <hr> |
153 | 161 |
|
154 | 162 | <p class="clearfix"> |
155 | | - <?= Button::save()->submit()->right() ?> |
| 163 | + <?= $canManage ? Button::save()->submit()->right() : '' ?> |
156 | 164 | </p> |
157 | 165 | <?php endif; ?> |
158 | 166 | </div> |
|
0 commit comments