/** * Updates an existing PageData model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id_page * @param string $language * @return mixed */ public function actionUpdate($id_page, $language) { $model = $this->findModel($id_page, $language); $model->setScenario('update'); //if (!Yii::$app->user->can('ownAction', ['model' => $model])) { // throw new ForbiddenHttpException('You are not allowed to perform this action.'); //} /* copy to other languages */ $languages = Message::getLocaleList(); $q = new Query(); $pageLang = $q->select(['language'])->from('{{%core_page_data}}')->where(['id_page' => $id_page])->all(); foreach ($pageLang as $pl) { if (in_array($pl['language'], array_keys($languages))) { unset($languages[$pl['language']]); } } //var_dump($languages); /* submitted */ if (Yii::$app->request->isPost) { /* page data */ $model->load(Yii::$app->request->post()); $model->page->load(Yii::$app->request->post()); $model->page->save(); $model->save(); return $this->redirect(['update', 'id_page' => $model->id_page, 'language' => $model->language]); } else { return $this->render('update', ['model' => $model, 'languages' => $languages]); } }
/** * @inheritdoc */ public function run() { //$currentLang=Yii::$app->language; $langs = array_reverse(Message::getLocaleList()); echo Html::beginTag('div', ['class' => 'language-selection']); foreach ($langs as $code => $lang) { $c = strtolower(substr($code, -2)); $icon = Flag::widget(['tag' => 'span', 'country' => $c, 'squared' => false, 'options' => []]); echo Html::a($icon, $this->langUrl($code), ['title' => $lang]); } echo Html::endTag('div'); }
/** * Index * @return string */ public function actionIndex() { $searchModel = new MessageSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); /* new lang list */ $langs = Core::getLocaleList(); $currents = Message::getLocaleList([Yii::$app->sourceLanguage]); foreach ($currents as $key => $name) { unset($langs[$key]); } return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'langs' => $langs]); }
/** * page view * @param $id * @return string * @throws NotFoundHttpException * @internal param $name */ public function actionPage($id) { $model = Page::findOne($id); if (!$model) { throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.')); } /* found */ if ($model->content->language !== Yii::$app->language) { Yii::$app->session->setFlash('info', Yii::t('app', 'This page has no {CUR_LANG} version. You are currently viewing the {LANGUAGE} version.', ['CUR_LANG' => Message::getLocaleList()[Yii::$app->language], 'LANGUAGE' => Message::getLocaleList()[$model->content->language]])); } /* seo */ /* metaData */ $title = $model->content->title; $keywords = $model->content->keywords; $description = $model->content->description; $metaTags[] = ['name' => 'keywords', 'content' => $keywords]; $metaTags[] = ['name' => 'description', 'content' => $description]; /* Facebook */ $metaTags[] = ['property' => 'og:title', 'content' => $title]; $metaTags[] = ['property' => 'og:description', 'content' => $description]; $metaTags[] = ['property' => 'og:type', 'content' => 'article']; // article, product, profile etc $metaTags[] = ['property' => 'og:image', 'content' => $model->content->thumbnail]; //best 1200 x 630 $metaTags[] = ['property' => 'og:url', 'content' => $model->content->getViewUrl(true)]; if ($appId = Setting::getValue('fbAppId')) { $metaTags[] = ['property' => 'fb:app_id', 'content' => $appId]; } //$metaTags[]=['property' => 'fb:app_id', 'content' => '']; //$metaTags[]=['property' => 'fb:admins', 'content' => '']; /* Twitter */ $metaTags[] = ['name' => 'twitter:card', 'content' => 'summary_large_image']; $metaTags[] = ['name' => 'twitter:site', 'content' => Setting::getValue('twitterSite')]; // $metaTags[]=['name'=>'twitter:title', 'content'=>$title]; // $metaTags[]=['name'=>'twitter:description', 'content'=>$description]; // $metaTags[]=['name'=>'twitter:image', 'content'=>'']; // $metaTags[]=['name'=>'twitter:data1', 'content'=>'']; // $metaTags[]=['name'=>'twitter:label1', 'content'=>'']; // $metaTags[]=['name'=>'twitter:data2', 'content'=>'']; // $metaTags[]=['name'=>'twitter:label2', 'content'=>'']; /* jsonld */ $imageObject = $model->content->getImageObject(); $jsonLd = (object) ['@type' => 'Article', 'http://schema.org/name' => $title, 'http://schema.org/headline' => $description, 'http://schema.org/articleBody' => $model->content->content, 'http://schema.org/dateCreated' => Yii::$app->formatter->asDate($model->content->created_at, 'php:c'), 'http://schema.org/dateModified' => Yii::$app->formatter->asDate($model->content->updated_at, 'php:c'), 'http://schema.org/datePublished' => Yii::$app->formatter->asDate($model->content->created_at, 'php:c'), 'http://schema.org/url' => Yii::$app->request->absoluteUrl, 'http://schema.org/image' => (object) ['@type' => 'ImageObject', 'http://schema.org/url' => !empty($imageObject['url']) ? $imageObject['url'] : '', 'http://schema.org/width' => !empty($imageObject['width']) ? $imageObject['width'] : '', 'http://schema.org/height' => !empty($imageObject['height']) ? $imageObject['height'] : ''], 'http://schema.org/author' => (object) ['@type' => 'Organization', 'http://schema.org/name' => Yii::$app->name], 'http://schema.org/publisher' => (object) ['@type' => 'Organization', 'http://schema.org/name' => Yii::$app->name, 'http://schema.org/logo' => (object) ['@type' => 'ImageObject', 'http://schema.org/url' => Yii::$app->urlManager->createAbsoluteUrl(Yii::$app->homeUrl . '/images/logo.png')]], 'http://schema.org/mainEntityOfPage' => (object) ['@type' => 'WebPage', '@id' => Yii::$app->request->absoluteUrl]]; /* OK */ $data['title'] = $title; $data['metaTags'] = $metaTags; $data['jsonLd'] = $jsonLd; $this->registerMetaTagJsonLD($data); return $this->render('page', ['model' => $model]); }
$this->params['breadcrumbs'][] = $this->title; //$this->registerJs('$(document).on("pjax:send", function(){ $("#loading").modal("show");});$(document).on("pjax:complete", function(){ $("#loading").modal("hide");})'); $this->registerJs('$(document).on("pjax:send", function(){ $(".grid-view-overlay").removeClass("hidden");});$(document).on("pjax:complete", function(){ $(".grid-view-overlay").addClass("hidden");})'); //$js=file_get_contents(__DIR__.'/index.min.js'); //$this->registerJs($js); $css = file_get_contents(__DIR__ . '/index.css'); $this->registerCss($css); ?> <div class="i18n-message-index"> <div class="box box-primary"> <div class="box-body"> <?php Pjax::begin(['id' => 'message-translation-wrap']); ?> <?php echo GridView::widget(['id' => 'i18n-message-grid', 'options' => ['class' => 'grid-view table-responsive'], 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'language', 'value' => 'language', 'filter' => Message::getLocaleList([Yii::$app->sourceLanguage])], ['attribute' => 'category', 'value' => 'source.category', 'filter' => SourceMessage::getCategoryList()], ['attribute' => 'message', 'value' => 'source.message'], ['attribute' => 'translation', 'format' => 'raw', 'value' => function ($model) { return \modernkernel\jeditable\Editable::widget(['content' => strip_tags($model->translation), 'saveUrl' => Yii::$app->urlManager->createUrl(['/i18n/save-translation']), 'options' => ['id' => 'message_' . $model->id . '_' . $model->language, 'class' => 'jeditable-text'], 'clientOptions' => ['tooltip' => Yii::t('app', 'Click to edit'), 'indicator' => Yii::t('app', 'Saving...'), 'width' => '93%']]); }], ['attribute' => 'is_translated', 'value' => function ($model) { return Core::getYesNoText($model->is_translated); }, 'filter' => Core::getYesNoOption()], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}']]]); ?> <?php Pjax::end(); ?> <div> <?php echo \yii\helpers\Html::beginForm(Yii::$app->urlManager->createUrl(['/i18n/add']), 'post', ['class' => 'form-inline']); ?> <div class="form-group"> <label for="language"><?php echo Yii::t('app', 'Language');
<div class="box-header with-border"> <h1 class="box-title"><?php echo Yii::t('app', 'Profile'); ?> </h1> </div> <div class="box-body"> <div class="account-form"> <?php $form = ActiveForm::begin(['action' => Yii::$app->urlManager->createUrl(['/account'])]); ?> <?php echo $form->field($model, 'fullname')->textInput(['maxlength' => true, 'disabled' => !$model->canChangeName()]); ?> <?php echo $form->field($model, 'language')->widget(Select2Widget::className(), ['bootstrap' => false, 'items' => \common\models\Message::getLocaleList()]); ?> <?php echo $form->field($model, 'timezone')->widget(Select2Widget::className(), ['bootstrap' => false, 'items' => Core::getTimezoneList()]); ?> <div class="form-group"> <?php echo Html::submitButton(Yii::t('app', 'Save'), ['class' => 'btn btn-primary']); ?> </div <?php ActiveForm::end(); ?> </div> </div> </div>
?> <div class="page-create"> <div class="box box-success"> <div class="box-body"> <div class="page-data-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($page, 'id')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'language')->dropDownList(Message::getLocaleList()); ?> <?php echo $form->field($model, 'title')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'description')->textarea(['rows' => 3]); ?> <div class="nav-tabs-custom"> <ul class="nav nav-tabs"> <li class="active"><a href="#tab_content" data-toggle="tab" aria-expanded="true"><?php echo $model->getAttributeLabel('content'); ?>
/** * UrlManager */ protected function configUrlManager() { $modules = scandir(__DIR__ . '/../../vendor/modernkernel'); $urlManager = ['ignoreLanguageUrlPatterns' => ['#^account/auth#' => '#^account/auth#', '#^site/logout#' => '#^site/logout#', '#^site/robots#' => '#^robots.txt#', '#^site/sitemap#' => '#^sitemap\\.xml#', '#^blog/sitemap#' => '#^blog/sitemap\\d+\\.xml#'], 'rules' => ['' => 'site/index', 'sitemap.xml' => 'site/sitemap', 'robots.txt' => 'site/robots', 'manifest.json' => 'site/manifest', 'browserconfig.xml' => 'site/browserconfig', '<id:.+?>.html' => 'site/page', 'blog/<action:(manage|create|update|delete)>' => 'blog/<action>', 'blog/sitemap<page:\\d+>.xml' => 'blog/sitemap', 'blog' => 'blog/index', 'blog/<name:.+?>' => 'blog/view', 'page/sitemap<page:\\d+>.xml' => 'page/sitemap']]; foreach ($modules as $module) { if (!preg_match('/[\\.]+/', $module)) { $urlManagerFile = __DIR__ . '/../../vendor/modernkernel/' . $module . '/urlManager.php'; if (is_file($urlManagerFile)) { $urlManagerConfig = (require $urlManagerFile); $urlManager['ignoreLanguageUrlPatterns'] = array_merge($urlManager['ignoreLanguageUrlPatterns'], $urlManagerConfig['ignoreLanguageUrlPatterns']); $urlManager['rules'] = array_merge($urlManager['rules'], $urlManagerConfig['rules']); } } } Yii::$container->set('common\\components\\LocaleUrl', ['languages' => array_keys(Message::getLocaleList()), 'languageParam' => 'lang', 'enableLanguagePersistence' => false, 'enableDefaultLanguageUrlCode' => (bool) Setting::getValue('languageUrlCode'), 'enableLanguageDetection' => false, 'ignoreLanguageUrlPatterns' => $urlManager['ignoreLanguageUrlPatterns'], 'rules' => $urlManager['rules']]); }
$this->registerJs('$(document).on("pjax:send", function(){ $(".grid-view-overlay").removeClass("hidden");});$(document).on("pjax:complete", function(){ $(".grid-view-overlay").addClass("hidden");})'); //$js=file_get_contents(__DIR__.'/index.min.js'); //$this->registerJs($js); //$css=file_get_contents(__DIR__.'/index.css'); //$this->registerCss($css); ?> <div class="page-index"> <div class="box box-primary"> <div class="box-body"> <?php Pjax::begin(); ?> <?php echo GridView::widget(['options' => ['class' => 'grid-view table-responsive'], 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id_page', ['attribute' => 'language', 'value' => function ($model) { return Message::getLocaleList()[$model->language]; }, 'filter' => Message::getLocaleList()], 'title', 'description', ['attribute' => 'status', 'value' => function ($model) { return $model->statusText; }, 'filter' => PageData::getStatusOption()], ['class' => 'yii\\grid\\ActionColumn']]]); ?> <?php Pjax::end(); ?> <p> <?php echo Html::a(Yii::t('app', 'Add new Page'), ['/page/create'], ['class' => 'btn btn-success']); ?> </p> </div> <!-- Loading (remove the following to stop the loading)--> <div class="overlay grid-view-overlay hidden">