public function actionIndex()
 {
     /** @var Module $module */
     $module = Module::getInstance();
     $model = $module->getConfigurationModel();
     if ($model->load(Yii::$app->request->post())) {
         //$validate = $model->validate();
         foreach (I18N::getAvailableLanguages() as $language) {
             $modelI18n = $model->getTranslation($language['locale']);
             $modelI18n->load(Yii::$app->request->post());
         }
         if ($module->saveConfigurationModel($model)) {
             Yii::$app->session->addFlash('success', Yii::t('maddoger/website', 'Saved.'));
             return $this->refresh();
         }
     }
     return $this->render('index', ['model' => $model]);
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $pageClass = Module::getInstance()->pageModelClass;
     /**
      * @var \yii\db\ActiveQuery $query
      */
     $query = $pageClass::find();
     $query->joinWith('translations');
     $query->distinct();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->defaultOrder = ['slug' => SORT_ASC];
     $dataProvider->sort->attributes['title'] = ['asc' => [PageI18n::tableName() . '.[[title]]' => SORT_ASC], 'desc' => [PageI18n::tableName() . '.[[title]]' => SORT_DESC], 'default' => SORT_ASC];
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     if ($this->title) {
         $query->andWhere(['or', ['like', PageI18n::tableName() . '.[[title]]', $this->title], ['like', PageI18n::tableName() . '.[[language]]', $this->title]]);
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'layout', $this->layout])->andFilterWhere(['like', 'default_language', $this->default_language]);
     return $dataProvider;
 }
Exemplo n.º 3
0
<?php

/* @var $this yii\web\View */
use maddoger\core\i18n\I18N;
use maddoger\website\backend\Module as BackendModule;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $model maddoger\website\common\models\Page */
$this->title = Yii::t('maddoger/website', 'Configuration');
$availableLanguages = I18N::getAvailableLanguages();
$activeLanguage = $availableLanguages[0]['locale'];
$layouts = BackendModule::getInstance()->getConfiguration()->layouts;
$layouts = $layouts ? array_merge(['' => Yii::t('maddoger/website', 'Default')], $layouts) : ['' => Yii::t('maddoger/website', 'Default')];
$textFormats = BackendModule::getInstance()->textFormats;
$textFormats = array_merge(['' => Yii::t('maddoger/website', 'Default')], $textFormats ? ArrayHelper::getColumn($textFormats, 'label', true) : []);
?>
<div class="page-update">

    <div class="page-form">

        <?php 
$form = ActiveForm::begin();
?>
        <div class="row">
            <div class="col-md-6">

                <div class="nav-tabs-custom" id="translations">
                    <ul class="nav nav-tabs">
                        <li class="header"><?php 
echo Yii::t('maddoger/website', 'SEO');
Exemplo n.º 4
0
 /**
  * @return string
  */
 public function getFormattedText()
 {
     return Module::getInstance()->getFormattedText($this->text_format, $this->text_source, $this->language);
 }
Exemplo n.º 5
0
 /**
  * Finds the Page model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Page the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     $pageClass = Module::getInstance()->pageModelClass;
     if (($model = $pageClass::find()->where(['id' => $id])->with(['translations'])->limit(1)->one()) !== null) {
         /** @var Page $model */
         return $model;
     } else {
         throw new NotFoundHttpException(Yii::t('maddoger/website', 'The requested page does not exist.'));
     }
 }
Exemplo n.º 6
0
    }
    ?>
                    <div class="tab-pane <?php 
    echo $language['locale'] == $activeLanguage ? 'active' : '';
    ?>
"
                         id="i18n_<?php 
    echo $language['locale'];
    ?>
">
                        <?php 
    echo $form->field($modelI18n, 'title', ['enableClientValidation' => false])->textInput(['maxlength' => 150]);
    ?>

                        <?php 
    echo $form->field($modelI18n, 'text_format', ['enableClientValidation' => false])->widget(FormatDropdown::className(), ['context' => BackendModule::getInstance(), 'changeFormatMessage' => $changeFormatMessage, 'changeFormatUrl' => $changeFormatUrl]);
    ?>

                        <?php 
    echo $form->field($modelI18n, 'text_source', ['enableClientValidation' => false])->widget(TextEditor::className());
    ?>
                        <br />
                        <button
                            type="button"
                            class="btn btn-block btn-default collapsed"
                            role="button"
                            data-toggle="collapse"
                            data-target=".seo"
                            aria-expanded="false" aria-controls="seo" title="Кликните, чтобы открыть">Настройки SEO</button>

                        <div class="seo collapse">
Exemplo n.º 7
0
<?php

/* @var yii\web\View $this */
use maddoger\website\backend\Module;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
/* @var string $text */
/* @var string $fieldName */
/* @var array $formatInfo */
if (isset($formatInfo['widgetClass'])) {
    $widgetClass = $formatInfo['widgetClass'];
    $options = isset($formatInfo['widgetOptions']) ? $formatInfo['widgetOptions'] : [];
    $additionalOptions = Module::getInstance()->textEditorWidgetOptions;
    if ($additionalOptions) {
        $options = ArrayHelper::merge($options, $additionalOptions);
    }
    $options['name'] = $fieldName;
    $options['value'] = $text;
    echo $widgetClass::widget($options);
} else {
    echo Html::textarea($fieldName, $text, ['class' => 'form-control', 'rows' => 20]);
}
Exemplo n.º 8
0
                <li class="header"><?php 
echo Yii::t('maddoger/website', 'Content');
?>
</li>
                <?php 
foreach ($availableLanguages as $language) {
    echo Html::tag('li', Html::a($language['name'], '#i18n_' . $language['locale'], ['data-toggle' => 'tab']), ['class' => $language['locale'] == $activeLanguage ? 'active' : '']);
}
?>
            </ul>
            <div class="tab-content">
                <?php 
foreach ($availableLanguages as $language) {
    $modelI18n = $model->getTranslation($language['locale'], true);
    if (!$modelI18n->text_format) {
        $modelI18n->text_format = BackendModule::getInstance()->config->defaultTextFormat;
    }
    ?>
                    <div class="tab-pane <?php 
    echo $language['locale'] == $activeLanguage ? 'active' : '';
    ?>
"
                         id="i18n_<?php 
    echo $language['locale'];
    ?>
">
                        <?php 
    echo $form->field($modelI18n, 'title', ['enableClientValidation' => false])->textInput(['maxlength' => 150]);
    ?>

                        <?php