Ejemplo n.º 1
0
 /**
  * Initializes the pager.
  */
 public function init()
 {
     $this->nextPageLabel = Module::t('Next') . ' »';
     $this->prevPageLabel = '« ' . Module::t('Prev.');
     $this->firstPageLabel = Module::t('First');
     $this->lastPageLabel = Module::t('Last');
     parent::init();
 }
Ejemplo n.º 2
0
 /**
  * Initializes the default button rendering callbacks.
  */
 protected function initDefaultButtons()
 {
     if (!isset($this->buttons['view'])) {
         $this->buttons['view'] = function ($url, $model, $key) {
             return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, ['class' => 'btn btn-xs btn-default', 'title' => Module::t('View'), 'data-pjax' => '0']);
         };
     }
     if (!isset($this->buttons['update'])) {
         $this->buttons['update'] = function ($url, $model, $key) {
             return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, ['class' => 'btn btn-xs btn-default', 'title' => Module::t('Update'), 'data-pjax' => '0']);
         };
     }
     if (!isset($this->buttons['save'])) {
         $this->buttons['save'] = function ($url, $model, $key) {
             return Html::a('<span class="glyphicon glyphicon-download"></span> ' . Module::t('Save'), $url, ['class' => 'btn btn-xs btn-success', 'title' => Module::t('Save'), 'data-pjax' => '0']);
         };
     }
     if (!isset($this->buttons['delete'])) {
         $this->buttons['delete'] = function ($url, $model, $key) {
             return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, ['class' => 'btn btn-xs btn-danger margin-left-10px', 'title' => Module::t('Delete'), 'data-confirm' => Module::t('Are you sure you want to delete this item?'), 'data-method' => 'post', 'data-pjax' => '0']);
         };
     }
 }
Ejemplo n.º 3
0
?>
"><i class="fa fa-recycle"></i> <?php 
echo Module::t('Clear Cache');
?>
</a>
        </span>
    </h2>
    <?php 
echo GridView::widget(['filterModel' => $searchModel, 'dataProvider' => $searchModel->search(Yii::$app->getRequest()->get()), 'columns' => [['class' => SerialColumn::className()], ['attribute' => 'message', 'format' => 'raw', 'contentOptions' => ['class' => 'source-message'], 'value' => function ($model, $key, $index, $column) {
    return $this->render('_source-message-content', ['model' => $model, 'key' => $key, 'index' => $index, 'column' => $column]);
}], ['class' => ActionColumn::className(), 'header' => '<i class="fa fa-copy"></i>', 'footer' => '<i class="fa fa-copy"></i>', 'template' => '{copy}', 'headerOptions' => ['width' => '30'], 'buttons' => ['copy' => function ($url, $model, $key) {
    return Html::a('<i class="fa fa-arrow-right "></i>', '', ['class' => 'btn btn-xs btn-default btn-translation-copy-from-source', 'title' => Module::t('Copy from source message')]);
}]], ['attribute' => 'translation', 'headerOptions' => ['width' => '400'], 'contentOptions' => ['class' => 'translation-tabs tabs-mini'], 'value' => function ($model, $key, $index, $column) {
    return $this->render('_message-tabs', ['model' => $model, 'key' => $key, 'index' => $index, 'column' => $column]);
}, 'format' => 'raw'], ['attribute' => 'category', 'headerOptions' => ['width' => '150'], 'contentOptions' => ['class' => 'text-align-center'], 'value' => function ($model, $key, $index, $dataColumn) {
    return $model->category;
}, 'filter' => ArrayHelper::map($searchModel::getCategories(), 'category', 'category'), 'filterInputOptions' => DataColumn::$filterOptionsForChosenSelect], ['attribute' => 'status', 'headerOptions' => ['width' => '150'], 'contentOptions' => ['class' => 'text-align-center'], 'value' => '', 'filter' => Html::dropDownList($searchModel->formName() . '[status]', $searchModel->status, $searchModel->getStatus(), DataColumn::$filterOptionsForChosenSelect), 'visible' => false], ['class' => ActionColumn::className(), 'template' => '{save} {fullscreen} {delete}', 'buttons' => ['save' => function ($url, $model, $key) {
    return Html::a('<i class="glyphicon glyphicon-download"></i> ' . Module::t('Save'), $url, ['class' => 'btn btn-xs btn-success btn-translation-save', 'action' => 'translation-save', 'title' => Module::t('Save'), 'before-send-title' => Module::t('Request sent'), 'before-send-message' => Module::t('Please, wait...'), 'success-title' => Module::t('Server Response'), 'success-message' => Module::t('Message successfully saved.')]);
}, 'delete' => function ($url, $model, $key) {
    if (strstr($model->message, '@@')) {
        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', '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', 'before-send-title' => Module::t('Request sent'), 'before-send-message' => Module::t('Please, wait...'), 'success-title' => Module::t('Server Response'), 'success-message' => Module::t('Message successfully restored.')]) . '</span>';
    } else {
        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', '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', 'before-send-title' => Module::t('Request sent'), 'before-send-message' => Module::t('Please, wait...'), 'success-title' => Module::t('Server Response'), 'success-message' => Module::t('Message successfully deleted.')]) . '</span>';
    }
}]], ['attribute' => 'location', 'value' => function ($model, $key, $index, $dataColumn) {
    return $model->location;
}, 'enableSorting' => false, 'visible' => false]]]);
?>
</div>
<?php 
echo ScrollToTop::widget();
Ejemplo n.º 4
0
</div>
            <div class="panel-body"><?php 
echo Html::encode($model->message);
?>
</div>
        </div>
        <?php 
$form = ActiveForm::begin();
?>
        <div class="row">
            <?php 
foreach ($model->messages as $language => $message) {
    ?>
                <?php 
    echo $form->field($model->messages[$language], '[' . $language . ']translation', ['options' => ['class' => 'form-group col-sm-6']])->textInput()->label($language);
    ?>
            <?php 
}
?>
        </div>
        <div class="form-group">
            <?php 
echo Html::submitButton($model->getIsNewRecord() ? Module::t('Create') : Module::t('Update'), ['class' => $model->getIsNewRecord() ? 'btn btn-success' : 'btn btn-primary']);
?>
        </div>
        <?php 
$form::end();
?>
    </div>
</div>
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['id' => Module::t('ID'), 'category' => Module::t('Category'), 'message' => Module::t('Sourse Messages'), 'translation' => Module::t('Message Translations'), 'status' => Module::t('Translation status')];
 }
 /**
  * @return array
  */
 public function attributeLabels()
 {
     return ['id' => 'ID', 'category' => Module::t('Category'), 'message' => Module::t('Message'), 'status' => Module::t('Translation status'), 'location' => Module::t('Location')];
 }
 public function actionRestore($id)
 {
     // ---------------------- CHECK IS AJAX REQUEST ------------------------
     if (!Yii::$app->getRequest()->isAjax) {
         return $this->redirect(['/translations']);
     }
     // ------------------ SET JSON FORMAT FOR RESPONSE ---------------------
     // @see https://github.com/samdark/yii2-cookbook/blob/master/book/response-formats.md
     Yii::$app->getResponse()->format = \yii\web\Response::FORMAT_JSON;
     // --------------------- SET DEFAULT RESPONSE --------------------------
     $response = array('status' => 'error', 'message' => Module::t('An unexpected error occured!'));
     // -------------------- RESTORE TRANSLATION BY ID ----------------------
     $model = $this->findModel($id);
     $model->message = trim($model->message, '@@');
     if ($model->save()) {
         // clear cache
         foreach (Yii::$app->i18n->languages as $language) {
             Yii::$app->cache->delete(['yii\\i18n\\DbMessageSource', $model->category, $language]);
         }
         // set response
         $response['status'] = 'success';
         $response['message'] = 'Translation successfully restored.';
     }
     return $response;
 }