<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Nav\Admin\Controller; use Illuminate\Routing\Controller; use ModStart\Admin\Concern\HasAdminQuickCRUD; use ModStart\Admin\Layout\AdminCRUDBuilder; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Type\TypeUtil; use ModStart\Field\AbstractField; use ModStart\Field\AutoRenderedFieldValue; use ModStart\Field\Type\FieldRenderMode; use ModStart\Form\Form; use ModStart\ModStart; use ModStart\Repository\Filter\ScopeFilter; use ModStart\Support\Concern\HasFields; use Module\Nav\Type\NavOpenType; use Module\Nav\Type\NavPosition; use Module\Nav\Util\NavUtil; class NavController extends Controller { use HasAdminQuickCRUD; protected function crud(AdminCRUDBuilder $a1cww) { goto pYoVY; pYoVY: if ($a1cww->mode() == AdminCRUDBuilder::MODE_FORM) { goto a0HbW; nSC8D: ModStart::script('window.__positionNavs=' . json_encode($aSpkS) . ';'); goto cA4D6; cA4D6: ModStart::scriptFile('module/Nav/Admin/Controller/NavEdit.js'); goto Df2EM; a0HbW: $aSpkS = array(); goto Z32B7; Z32B7: foreach (NavUtil::tree() as $hf0nR) { $aSpkS[] = array('id' => $hf0nR['id'], 'position' => $hf0nR['position'], 'name' => $hf0nR['name']); if (!empty($hf0nR['_child'])) { foreach ($hf0nR['_child'] as $Eh9lH) { $aSpkS[] = array('id' => $Eh9lH['id'], 'position' => $Eh9lH['position'], 'name' => $hf0nR['name'] . ' → ' . $Eh9lH['name']); } } } goto nSC8D; Df2EM: } goto SMt6x; bUunG: $a1cww->scopeDefault(NavPosition::first()); goto vCE3c; XpDv_: foreach (NavPosition::getList() as $ySsOv => $sKrwM) { $a1cww->scopeFilter($ySsOv, $sKrwM, function (ScopeFilter $q81IC) use($ySsOv) { return $q81IC->where('position', $ySsOv); }); } goto bUunG; vCE3c: $a1cww->hookSaved(function (Form $ukDy3) { $zEBpl = $ukDy3->item(); if ($zEBpl->pid > 0) { $m4xhO = ModelUtil::get('nav', $zEBpl->pid); ModelUtil::update('nav', $zEBpl->id, array('position' => $m4xhO['position'])); } })->hookChanged(function (Form $ukDy3) { NavUtil::clearCache(); })->canBatchDelete(true)->asTree('id', 'pid', 'sort', 'name')->treeMaxLevel(3)->title('导航设置'); goto o8a5y; SMt6x: $a1cww->init('nav')->field(function ($a1cww) { $a1cww->id('id', 'ID'); $a1cww->select('position', '位置')->optionType(NavPosition::class)->hookRendering(function (AbstractField $AlE6h, $zEBpl, $gIdrT) { switch ($AlE6h->renderMode()) { case FieldRenderMode::DETAIL: case FieldRenderMode::GRID: if ($zEBpl->pid) { return AutoRenderedFieldValue::make(''); } return AutoRenderedFieldValue::make(TypeUtil::name(NavPosition::class, $zEBpl->position)); } }); $a1cww->text('name', '名称'); $a1cww->icon('icon', '图标')->help('部分主题支持图标显示'); $a1cww->link('link', '链接'); $a1cww->switch('enable', '启用')->optionsYesNo()->gridEditable(true)->defaultValue(true); $a1cww->radio('openType', '打开方式')->optionType(NavOpenType::class)->defaultValue(NavOpenType::CURRENT_WINDOW); $a1cww->display('created_at', L('Created At'))->listable(false); $a1cww->display('updated_at', L('Updated At'))->listable(false); }); goto XpDv_; o8a5y: } }