Skip to content

Commit

Permalink
Merge pull request #16 from Ymox/master
Browse files Browse the repository at this point in the history
A few corrections
  • Loading branch information
uran1980 authored Dec 28, 2017
2 parents 40b0f22 + fe7c47e commit 16d5b70
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 25 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name" : "uran1980/yii2-translate-panel",
"description" : "Yii2 Translate Panel makes the translation of your application awesome!",
"version" : "0.1.30",
"version" : "0.1.31",
"type" : "yii2-extension",
"keywords" : [
"yii2",
Expand Down
4 changes: 2 additions & 2 deletions controllers/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function actionDelete($id)
);

// -------------------- DELETE TRANSLATION BY ID -----------------------
$model = $this->findModel($id);
$model = parent::findModel($id);
$model->message = '@@' . $model->message . '@@';
if ( $model->save() ) {
// clear cache
Expand Down Expand Up @@ -166,7 +166,7 @@ public function actionRestore($id)
);

// -------------------- RESTORE TRANSLATION BY ID ----------------------
$model = $this->findModel($id);
$model = parent::findModel($id);
$model->message = trim($model->message, '@@');
if ( $model->save() ) {
// clear cache
Expand Down
3 changes: 2 additions & 1 deletion views/default/_message-tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use yii\helpers\Html;
use yii\bootstrap\Tabs;
use uran1980\yii\modules\i18n\Module;

$items = [];

Expand All @@ -17,7 +18,7 @@
'dir' => (in_array($lang, ['ar', 'fa']) ? 'rtl' : 'ltr'),
'rows' => 3,
];
if (!Yii::$app->i18n->translations[$model->category]->forceTranslation && Yii::$app->sourceLanguage == $lang) {
if (isset(Yii::$app->i18n->translations[$model->category]) && !Yii::$app->i18n->translations[$model->category]->forceTranslation && Yii::$app->sourceLanguage == $lang) {
$parameters['disabled'] = 'disabled';
$parameters['title'] = Module::t('Please set [forceTranslation] to true to be able to edit this field');
}
Expand Down
44 changes: 24 additions & 20 deletions views/default/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,18 @@
return '<span class="btn-ajax-wrap">' . Html::a('<i class="glyphicon glyphicon-refresh"></i>', str_replace('delete', 'restore', $url), [
'class' => 'btn btn-xs btn-info btn-ajax',
'action' => 'translation-restore',
// 'title' => Module::t('Restore'),
// 'data-confirm' => Module::t('Are you sure you want to restore this item?'),
'data-toggle' => 'confirmation',
'data-singleton' => 'true',
'data-placement' => 'top',
'data-btn-ok-lable' => Module::t('Yes'),
'data-btn-ok-class' => 'btn-xs btn-success',
'data-btn-cancel' => Module::t('No'),
'data-btn-cancel-class' => 'btn-xs btn-warning',
'data-popout' => 'true',
'data' => [
//'toggle' => 'confirmation',
'popout' => true,
'singleton' => true,
'placement' => 'left',
'title' => Module::t('Are you sure you want to restore this item?'),
'method' => 'post',
'btn-ok-label' => Module::t('Yes'),
'btn-ok-class' => 'btn-xs btn-success',
'btn-cancel' => Module::t('No'),
'btn-cancel-class' => 'btn-xs btn-warning',
],
'before-send-title' => Module::t('Request sent'),
'before-send-message' => Module::t('Please, wait...'),
'success-title' => Module::t('Server Response'),
Expand All @@ -213,16 +215,18 @@
return '<span class="btn-ajax-wrap">' . Html::a('<i class="glyphicon glyphicon-trash"></i>', $url, [
'class' => 'btn btn-xs btn-danger btn-ajax',
'action' => 'translation-delete',
// 'title' => Module::t('Delete'),
// 'data-confirm' => Module::t('Are you sure you want to delete this item?'),
'data-toggle' => 'confirmation',
'data-singleton' => 'true',
'data-placement' => 'top',
'data-btn-ok-lable' => Module::t('Yes'),
'data-btn-ok-class' => 'btn-xs btn-success',
'data-btn-cancel' => Module::t('No'),
'data-btn-cancel-class' => 'btn-xs btn-warning',
'data-popout' => 'true',
'data' => [
//'toggle' => 'confirmation',
'popout' => true,
'singleton' => true,
'placement' => 'left',
'title' => Module::t('Are you sure you want to restore this item?'),
'method' => 'post',
'btn-ok-label' => Module::t('Yes'),
'btn-ok-class' => 'btn-xs btn-success',
'btn-cancel' => Module::t('No'),
'btn-cancel-class' => 'btn-xs btn-warning',
],
'before-send-title' => Module::t('Request sent'),
'before-send-message' => Module::t('Please, wait...'),
'success-title' => Module::t('Server Response'),
Expand Down
2 changes: 1 addition & 1 deletion views/default/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
? $model->message : $message->translation);
echo $form->field($message, '[' . $language . ']translation', ['options' => ['class' => 'form-group col-sm-6']])
->textInput(
(!Yii::$app->i18n->translations[$model->category]['forceTranslation'] && Yii::$app->sourceLanguage == $language)
(isset(Yii::$app->i18n->translations[$model->category]['forceTranslation']) && !Yii::$app->i18n->translations[$model->category]['forceTranslation'] && Yii::$app->sourceLanguage == $language)
? ['disabled' => 'disabled', 'title' => Module::t('Please set [forceTranslation] to true to be able to edit this field')]
: []
)->label(strtoupper($language));
Expand Down

0 comments on commit 16d5b70

Please sign in to comment.