/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
common/widgets/model/View.php
89 строк
3 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace common\widgets\model; use common\components\crud\ViewCrud; use common\widgets\DetailView; /** * Отображение специфичных данных о модели * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2020 */ class View extends BaseWidget { /** * Показывать системыне поля * @var bool */ public $use_system = true; /** * Выполнение виджета * * @return string */ public function run() { /** * echo DetailView::widget([ * 'model'=>$model, * 'condensed'=>true, * 'hover'=>true, * 'mode'=>DetailView::MODE_VIEW, * 'panel'=>[ * 'heading'=>'Book # ' . $model->id, * 'type'=>DetailView::TYPE_INFO, * ], * 'attributes'=>[ * 'code', * 'name', * ['attribute'=>'publish_date', 'type'=>DetailView::INPUT_DATE], * ] * ]); */ $fields = $this->crud->fields(); $model = $this->model; if ($this->crud instanceof ViewCrud) { $this->use_system = $this->crud->use_system; } // показывать или нет системные поля if ($this->use_system) { // Кто добавил запись if ($model->hasAttribute($model->created_attribute['user'])) { $fields['created'] = $model->created_attribute['date'] . ':datetime'; $fields[] = [ 'value' => function () use ($model) { return $model->owner ? $model->owner : null; }, 'format' => ['lichnost', 'short'], 'label' => $model->getAttributeLabel($model->created_attribute['user']), ]; } // Кто обновил запись if ($model->hasAttribute($model->updated_attribute['user'])) { $fields['updated'] = $model->updated_attribute['date'] . ':datetime'; $fields[] = [ 'value' => function () use ($model) { return $model->updater ? $model->updater : null; }, 'format' => ['lichnost', 'short'], 'label' => $model->getAttributeLabel($model->updated_attribute['user']), ]; } } echo DetailView::widget([ 'model' => $this->model, 'attributes' => $fields, ]); } }