Skip to content

Commit f074c7f

Browse files
committed
0.4.3
Доработка представлений
1 parent 7099195 commit f074c7f

File tree

6 files changed

+56
-32
lines changed

6 files changed

+56
-32
lines changed

common/models/extend/DocumentExtend.php

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,28 @@ private function genereteView($templateData, $view, $type) {
155155
} else {
156156
$view = str_replace('{=' . $field['title'] . '=}', Yii::t('app', '(не задано)'), $view);
157157
}
158-
if (strpos($view, '{^_' . $field['title'] . '_^}') !== false) {
159-
$image = Html::img($field['value']['path'], [
160-
'class' => 'full-width',
161-
'alt' => Yii::t('app', $field['title'])
162-
]);
163-
$view = str_replace('{^_' . $field['title'] . '_^}', $image, $view);
164-
}
165-
if (strpos($view, '{^=' . $field['title'] . '=^}') !== false) {
166-
$image = Html::img($field['value']['path'], [
167-
'class' => 'full-width cursor-pointer',
168-
'alt' => Yii::t('app', $field['title']),
169-
'onclick' => '
158+
// только для изображений
159+
if ($field['value']['extension'] == 'jpg' ||
160+
$field['value']['extension'] == 'jpeg' ||
161+
$field['value']['extension'] == 'png') {
162+
163+
// если файл не существуйт, назначаем картинку нет фото
164+
$image = Yii::getAlias( '@frontend/web' . $field['value']['path']);
165+
if(!file_exists($image)) {
166+
$field['value']['path'] = '/images/service/no-foto.png';
167+
}
168+
if (strpos($view, '{^_' . $field['title'] . '_^}') !== false) {
169+
$image = Html::img($field['value']['path'], [
170+
'class' => 'full-width',
171+
'alt' => Yii::t('app', $field['title'])
172+
]);
173+
$view = str_replace('{^_' . $field['title'] . '_^}', $image, $view);
174+
}
175+
if (strpos($view, '{^=' . $field['title'] . '=^}') !== false) {
176+
$image = Html::img($field['value']['path'], [
177+
'class' => 'full-width cursor-pointer',
178+
'alt' => Yii::t('app', $field['title']),
179+
'onclick' => '
170180
$.pjax({
171181
type: "GET",
172182
url: "' . Url::to(['/site/show-image', 'img' => $field['value']['path']]) . '",
@@ -176,26 +186,24 @@ private function genereteView($templateData, $view, $type) {
176186
scrollTo: false
177187
})
178188
'
179-
]);
180-
$view = str_replace('{^=' . $field['title'] . '=^}', $image, $view);
181-
}
189+
]);
190+
$view = str_replace('{^=' . $field['title'] . '=^}', $image, $view);
191+
}
182192

183-
// карусель
184-
if (isset($carouselItems) && $carouselItems) {
185-
if (isset($field['value'])) {
186-
$keyItem = array_search($field['title'], $carouselItems);
187-
if ($keyItem !== false &&
188-
($field['value']['extension'] == 'jpg' ||
189-
$field['value']['extension'] == 'jpeg' ||
190-
$field['value']['extension'] == 'png')) {
191-
// если файл используется в карусели и он является картинкой добавляем его к массиву файлов
192-
if (!isset($carouselFiles)) {
193-
$carouselFiles = [];
193+
// карусель
194+
if (isset($carouselItems) && $carouselItems) {
195+
if (isset($field['value'])) {
196+
$keyItem = array_search($field['title'], $carouselItems);
197+
if ($keyItem !== false) {
198+
// если файл используется в карусели и он является картинкой добавляем его к массиву файлов
199+
if (!isset($carouselFiles)) {
200+
$carouselFiles = [];
201+
}
202+
$carouselFiles[] = Html::img($field['value']['path'], [
203+
'class' => 'full-width animated fadeIn'
204+
]);
205+
unset($carouselItems[$keyItem]);
194206
}
195-
$carouselFiles[] = Html::img($field['value']['path'], [
196-
'class' => 'full-width animated fadeIn'
197-
]);
198-
unset($carouselItems[$keyItem]);
199207
}
200208
}
201209
}
@@ -229,6 +237,13 @@ private function genereteView($templateData, $view, $type) {
229237
if (!isset($carouselFiles)) {
230238
$carouselFiles = [];
231239
}
240+
241+
// если файл не существуйт, назначаем картинку нет фото
242+
$image = Yii::getAlias( '@frontend/web' . $file['path']);
243+
if(!file_exists($image)) {
244+
$file['path'] = '/images/service/no-foto.png';
245+
}
246+
232247
$carouselFiles[] = Html::img($file['path'], [
233248
'class' => 'full-width animated fadeIn'
234249
]);

frontend/views/templates/control/blocks/carousel/index.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
CarouselAsset::register($this);
1717
?>
18+
<?php if (count($items) > 1): ?>
1819
<?= Carousel::widget([
1920
'items' => $items,
2021
'options' => [
@@ -45,4 +46,8 @@
4546
$('#block-carousel').carousel({interval: false});
4647
});
4748
JS;
48-
$this->registerJs($js);
49+
$this->registerJs($js);
50+
?>
51+
<?php else: ?>
52+
<?= $items[0] ?>
53+
<?php endif; ?>

frontend/views/templates/control/blocks/search/search.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
?>
3838
<div class="block-search">
3939
<div class="col-xs-12">
40+
<h3 class="text-center m-b-md"><?= Yii::t('app', $modelSearch->parent->name) ?></h3>
4041
<div class="document-form-search">
4142
<div class="search-<?= $templateName; ?>">
4243
<?php $form = ActiveForm::begin([

frontend/views/templates/control/views/_default/_item.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
/* @var $modelDocumentForm \common\models\forms\DocumentForm Выбранный элемент */
1717
/* @var $tree array Дерево элемента */
1818
/* @var $templateName string *//* @var $fieldsManage \common\widgets\TemplateOfElement\components\FieldsManage */
19+
1920
$fieldsManage = Yii::$app->fieldsManage;
2021
$templateData = $fieldsManage->getData($modelDocumentForm->id, $modelDocumentForm->template_id);
2122

22-
$this->title = Yii::t('app', $page['title']);
23+
$this->title = Yii::t('app', $modelDocumentForm->title);
2324

2425
// Формируем "хлебные крошки"
2526
foreach ($tree as $value) {

frontend/views/templates/control/views/_default/_list.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
/* @var $tree array Дерево элемента */
2020
/* @var $templateName string */
2121

22+
$this->title = Yii::t('app', $modelSearch->parent->name);
23+
2224
// Формируем "хлебные крошки"
2325
foreach ($tree as $value) {
2426
if ($value['alias'] == $page['alias']) {
10.5 KB
Loading

0 commit comments

Comments
 (0)