public function getValue($record) { $value = $this->admin->getColumnValue($this->name, $record); list($column, $model) = $this->admin->getChainedModel($this->name, $record); if ($model === null) { return null; } $field = $model->getField($column, false); if ($field) { if (is_a($field, HasManyField::className()) || is_a($field, ManyToManyField::className())) { return null; } else { if (is_a($field, BooleanField::className())) { return $value ? '<i class="icon checkmark"></i>' : ''; } else { if (!empty($field->choices) && array_key_exists($value, $field->choices)) { return $field->choices[$value]; } else { return (string) $value; } } } } else { return (string) $model->{$column}; } }
public function delete($pk) { parent::delete($pk); if (isset($_GET['_next'])) { Mindy::app()->request->redirect($_GET['_next']); Mindy::app()->end(); } }
public function renderHeadCell() { $title = $this->getTitle(); $classes = ['th-' . $this->name]; $orderColumn = $this->admin->orderColumn($this->name); if ($orderColumn) { if ($this->currentOrder == $orderColumn) { $class[] = 'desc'; $orderColumn = '-' . $orderColumn; } else { $class[] = 'asc'; } $request = Mindy::app()->request; $urlManager = Mindy::app()->urlManager; $title = strtr('<a href="{url}?order={order}&search={search}&id={id}">{title}</a>', ['{title}' => $title, '{url}' => $urlManager->reverse('admin:list', ['moduleName' => $this->moduleName, 'adminClass' => $this->admin->classNameShort()]), '{order}' => $orderColumn, '{search}' => $request->getParam('search'), '{id}' => $request->getParam('id')]); } return strtr($this->headCellTemplate, ['{title}' => $title, '{html}' => $this->formatHtmlAttributes(['class' => implode(' ', $classes)])]); }
/** * @param array $breadcrumbs * @param ModelAdmin $admin * @return array */ public function formatBreadcrumbs(array $breadcrumbs, ModelAdmin $admin) { foreach ($breadcrumbs as $i => &$item) { if ($i == 1) { $item['items'] = $this->menuToBreadcrumbs($admin->getModule()); break; } continue; } return $breadcrumbs; }
public function update($pk, array $data = [], array $files = []) { $context = parent::update($pk, $data, $files); $context['breadcrumbs'] = array_merge($this->getBreadcrumbs(), $this->getParentBreadcrumbs($context['model'])); return $context; }