itstructure /
yii2-template-multilanguage
| 1 | <?php |
||
| 2 | |||
| 3 | use yii\helpers\{Html, Url}; |
||
| 4 | use yii\grid\GridView; |
||
| 5 | use yii\widgets\DetailView; |
||
| 6 | use yii\data\{ArrayDataProvider, Pagination}; |
||
| 7 | use Itstructure\FieldWidgets\TableMultilanguage; |
||
| 8 | use Itstructure\AdminModule\models\Language; |
||
| 9 | use Itstructure\MFUploader\Module as MFUModule; |
||
| 10 | use Itstructure\MFUploader\interfaces\UploadModelInterface; |
||
| 11 | use Itstructure\MFUploader\models\album\Album; |
||
| 12 | use app\models\Page; |
||
| 13 | |||
| 14 | /* @var $this yii\web\View */ |
||
| 15 | /* @var $model Page */ |
||
| 16 | /* @var $albumsDataProvider ArrayDataProvider */ |
||
| 17 | /* @var $images array */ |
||
| 18 | /* @var $images_pagination Pagination */ |
||
| 19 | |||
| 20 | $images_items = $images['items']; |
||
| 21 | $images_pagination = $images['pagination']; |
||
| 22 | |||
| 23 | $this->title = $model->getDefaultTranslate('title'); |
||
| 24 | $this->params['breadcrumbs'][] = [ |
||
| 25 | 'label' => Yii::t('pages', 'Pages'), |
||
| 26 | 'url' => [ |
||
| 27 | $this->params['urlPrefix'].'index' |
||
| 28 | ] |
||
| 29 | ]; |
||
| 30 | $this->params['breadcrumbs'][] = $this->title; |
||
| 31 | ?> |
||
| 32 | |||
| 33 | <style> |
||
| 34 | h5 { |
||
| 35 | font-weight: bold; |
||
| 36 | padding: 5px; |
||
| 37 | } |
||
| 38 | </style> |
||
| 39 | |||
| 40 | <div class="page-view"> |
||
| 41 | |||
| 42 | <p> |
||
| 43 | <?php echo Html::a(Yii::t('app', 'Update'), [ |
||
| 44 | $this->params['urlPrefix'].'update', |
||
| 45 | 'id' => $model->id |
||
| 46 | ], [ |
||
| 47 | 'class' => 'btn btn-primary' |
||
| 48 | ]) ?> |
||
| 49 | |||
| 50 | <?php echo Html::a(Yii::t('app', 'Delete'), [ |
||
| 51 | $this->params['urlPrefix'].'delete', |
||
| 52 | 'id' => $model->id |
||
| 53 | ], [ |
||
| 54 | 'class' => 'btn btn-danger', |
||
| 55 | 'data'=>[ |
||
| 56 | 'method' => 'post', |
||
| 57 | 'confirm' => Yii::t('app', 'Are you sure you want to do this action?'), |
||
| 58 | ] |
||
| 59 | ]) ?> |
||
| 60 | </p> |
||
| 61 | |||
| 62 | <h3><?php echo Yii::t('app', 'Translate'); ?></h3> |
||
| 63 | <?php echo TableMultilanguage::widget([ |
||
| 64 | 'fields' => [ |
||
| 65 | [ |
||
| 66 | 'name' => 'title', |
||
| 67 | 'label' => Yii::t('app', 'Title'), |
||
| 68 | ], |
||
| 69 | [ |
||
| 70 | 'name' => 'description', |
||
| 71 | 'label' => Yii::t('app', 'Description'), |
||
| 72 | ], |
||
| 73 | [ |
||
| 74 | 'name' => 'content', |
||
| 75 | 'label' => Yii::t('app', 'Content'), |
||
| 76 | ], |
||
| 77 | [ |
||
| 78 | 'name' => 'metaKeys', |
||
| 79 | 'label' => Yii::t('app', 'Meta keys'), |
||
| 80 | ], |
||
| 81 | [ |
||
| 82 | 'name' => 'metaDescription', |
||
| 83 | 'label' => Yii::t('app', 'Meta description'), |
||
| 84 | ], |
||
| 85 | ], |
||
| 86 | 'model' => $model, |
||
| 87 | 'languageModel' => new Language(), |
||
| 88 | ]) ?> |
||
| 89 | |||
| 90 | <?php echo DetailView::widget([ |
||
| 91 | 'model' => $model, |
||
| 92 | 'attributes' => [ |
||
| 93 | 'id', |
||
| 94 | 'thumbnail' => [ |
||
| 95 | 'label' => MFUModule::t('main', 'Thumbnail'), |
||
| 96 | 'value' => function ($model) { |
||
| 97 | /* @var $model Page */ |
||
| 98 | $thumbnailModel = $model->getThumbnailModel(); |
||
| 99 | return $thumbnailModel == null ? '' : Html::a($model->getDefaultThumbImage(), Url::to($thumbnailModel->getThumbUrl(MFUModule::THUMB_ALIAS_LARGE)), [ |
||
| 100 | 'target' => '_blank' |
||
| 101 | ]); |
||
| 102 | }, |
||
| 103 | 'format' => 'raw', |
||
| 104 | ], |
||
| 105 | [ |
||
| 106 | 'label' => Yii::t('app', 'Icon'), |
||
| 107 | 'value' => function($model) { |
||
| 108 | /* @var $model Page */ |
||
| 109 | return Html::tag('i', '', ['class' => empty($model->icon) ? 'fa fa-file fa-2x' : $model->icon]); |
||
| 110 | }, |
||
| 111 | 'format' => 'raw', |
||
| 112 | ], |
||
| 113 | [ |
||
| 114 | 'attribute' => 'alias', |
||
| 115 | 'label' => Yii::t('app', 'URL Alias'), |
||
| 116 | ], |
||
| 117 | [ |
||
| 118 | 'label' => Yii::t('app', 'Active status'), |
||
| 119 | 'value' => function($model) { |
||
| 120 | /* @var $model Page */ |
||
| 121 | if ($model->active == 1){ |
||
| 122 | return '<i class="fa fa-check-circle text-success"> ' . Yii::t('app', 'Active') . '</i>'; |
||
| 123 | } else { |
||
| 124 | return '<i class="fa fa-times text-danger"> ' . Yii::t('app', 'Inactive') . '</i>'; |
||
| 125 | } |
||
| 126 | }, |
||
| 127 | 'format' => 'raw', |
||
| 128 | ], |
||
| 129 | [ |
||
| 130 | 'attribute' => 'created_at', |
||
| 131 | 'format' => ['date', 'dd.MM.Y HH:mm:ss'], |
||
| 132 | 'label' => Yii::t('app', 'Created date'), |
||
| 133 | ], |
||
| 134 | [ |
||
| 135 | 'attribute' => 'updated_at', |
||
| 136 | 'format' => ['date', 'dd.MM.Y HH:mm:ss'], |
||
| 137 | 'label' => Yii::t('app', 'Updated date'), |
||
| 138 | ], |
||
| 139 | ], |
||
| 140 | ]) ?> |
||
| 141 | |||
| 142 | <!-- Existing files begin --> |
||
| 143 | <?php if ($images_pagination->totalCount > 0): ?> |
||
| 144 | <div class="panel panel-default"> |
||
| 145 | <div class="panel-heading"><?php echo MFUModule::t('main', 'Existing files'); ?></div> |
||
| 146 | <div class="panel-body"> |
||
| 147 | <?php echo $this->render('../mediafiles/_existing-mediafiles', [ |
||
| 148 | 'edition' => false, |
||
| 149 | 'mediafiles' => $images_items, |
||
| 150 | 'pages' => $images_pagination, |
||
| 151 | 'fileType' => UploadModelInterface::FILE_TYPE_IMAGE, |
||
| 152 | ]) ?> |
||
| 153 | </div> |
||
| 154 | </div> |
||
| 155 | <?php endif; ?> |
||
| 156 | <!-- Existing files end --> |
||
| 157 | |||
| 158 | <?php if (count($albums = $model->getAlbums()) > 0): ?> |
||
| 159 | <h3><?php echo MFUModule::t('album', 'Albums') ?></h3> |
||
| 160 | <?php echo GridView::widget([ |
||
| 161 | 'dataProvider' => new ArrayDataProvider([ |
||
| 162 | 'allModels' => $albums |
||
| 163 | ]), |
||
| 164 | 'columns' => [ |
||
| 165 | 'thumbnail' => [ |
||
| 166 | 'label' => MFUModule::t('main', 'Thumbnail'), |
||
| 167 | 'value' => function($item) { |
||
| 168 | /** @var Album $item */ |
||
| 169 | return Html::a( |
||
| 170 | $item->getDefaultThumbImage(), |
||
| 171 | Url::to([ |
||
| 172 | '/'.$this->params['shortLanguage'].'/mfuploader/'.$item->getFileType($item->type).'-album/view', 'id' => $item->id |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
|
|||
| 173 | ]) |
||
| 174 | ); |
||
| 175 | }, |
||
| 176 | 'format' => 'raw', |
||
| 177 | ], |
||
| 178 | 'name' => [ |
||
| 179 | 'label' => MFUModule::t('album', 'Title'), |
||
| 180 | 'value' => function($item) { |
||
| 181 | /** @var Album $item */ |
||
| 182 | return Html::a( |
||
| 183 | Html::encode($item->title), |
||
| 184 | Url::to([ |
||
| 185 | '/'.$this->params['shortLanguage'].'/mfuploader/'.$item->getFileType($item->type).'-album/view', 'id' => $item->id |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 186 | ]) |
||
| 187 | ); |
||
| 188 | }, |
||
| 189 | 'format' => 'raw', |
||
| 190 | ], |
||
| 191 | 'description' => [ |
||
| 192 | 'label' => MFUModule::t('album', 'Description'), |
||
| 193 | 'value' => function($item) { |
||
| 194 | /** @var Album $item */ |
||
| 195 | return $item->description; |
||
| 196 | }, |
||
| 197 | ], |
||
| 198 | ], |
||
| 199 | ]); ?> |
||
| 200 | <?php endif; ?> |
||
| 201 | |||
| 202 | <?php echo Html::a(Yii::t('pages', 'View articles'), [ |
||
| 203 | '/'.$this->params['shortLanguage'].'/admin/articles/index', 'ArticleSearch[pageId]' => $model->id |
||
| 204 | ], [ |
||
| 205 | 'class' => 'btn btn-primary' |
||
| 206 | ]) ?> |
||
| 207 | |||
| 208 | </div> |
||
| 209 |