<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Admin\Layout; use Illuminate\Contracts\Support\Renderable; use ModStart\Admin\Auth\AdminPermission; use ModStart\Core\Dao\DynamicModel; use ModStart\Core\Input\Request; use ModStart\Core\Input\Response; use ModStart\Core\Util\IdUtil; use ModStart\Field\AbstractField; use ModStart\Form\Form; use ModStart\Layout\Page; use ModStart\Repository\RepositoryUtil; use ModStart\Widget\Box; class AdminConfigBuilder implements Renderable { private $page; private $form; private $pagePrepend = array(); private $config = array('disableBoxWrap' => false); public function __construct() { $this->form = new Form(DynamicModel::class); $this->useFrame(); } public function form() { return $this->form; } public function page() { return $this->page; } public function useFrame() { $this->page = new AdminPage(); $this->form->showReset(false)->showSubmit(true); } public function useDialog() { $this->page = new AdminDialogPage(); $this->form->showReset(false)->showSubmit(false); } public function pagePrepend($TvJeT) { array_unshift($this->pagePrepend, $TvJeT); } public function render() { goto B9tRv; lxXZ_: if (!$this->config['disableBoxWrap']) { $LZvlB = new Box($this->form, $this->page->pageTitle()); } goto PT_I5; PT_I5: $this->page->body($LZvlB); goto q8tWU; B9tRv: if (!empty($this->pagePrepend)) { foreach ($this->pagePrepend as $yFnpO) { $this->page->row($yFnpO); } } goto rSwR2; rSwR2: $LZvlB = $this->form; goto lxXZ_; q8tWU: return $this->page->render(); goto MU7I9; MU7I9: } public function perform($yFnpO = null, $yeJzO = null) { goto eAQ_c; Fxhm_: $this->form->item(RepositoryUtil::itemFromArray($yFnpO)); goto uW_yG; uW_yG: $this->form->fillFields(); goto AIHMx; eAQ_c: if (Request::isPost()) { AdminPermission::demoCheck(); return $this->form->formRequest(function (Form $wDk8k) use($yeJzO) { if ($yeJzO) { $N2Xaa = call_user_func($yeJzO, $wDk8k); if (null !== $N2Xaa) { return $N2Xaa; } } else { $KVWtm = modstart_config(); foreach ($wDk8k->dataForming() as $Fkd1C => $pk5fc) { $KVWtm->set($Fkd1C, $pk5fc); } } return Response::jsonSuccess(L('Save Success')); }); } goto scDb_; AIHMx: return $this; goto qb8y8; scDb_: if (null === $yFnpO) { goto Sv6nv; Sv6nv: $yFnpO = array(); goto pcw7Z; pcw7Z: $KVWtm = modstart_config(); goto Rs5ms; Rs5ms: foreach ($this->form->fields() as $Mk6lP) { goto Bl0kx; OEJG5: if (is_array($pk5fc)) { $pk5fc = json_encode($pk5fc, JSON_UNESCAPED_UNICODE); } goto AhZ2W; Zq_M0: if ($SAuk9) { $pk5fc = modstart_config($Mk6lP->column()); } else { $pk5fc = null; } goto OEJG5; AhZ2W: $yFnpO[$Mk6lP->column()] = $pk5fc; goto hAM9M; D_9L1: $SAuk9 = $KVWtm->has($Mk6lP->column()); goto Zq_M0; Bl0kx: if ($Mk6lP->isLayoutField()) { continue; } goto D_9L1; hAM9M: } goto TSege; TSege: } else { if (false === $yFnpO) { $yFnpO = array(); foreach ($this->form->fields() as $Mk6lP) { if ($Mk6lP->isLayoutField()) { continue; } $yFnpO[$Mk6lP->column()] = null; } } } goto Fxhm_; qb8y8: } public function contentFixedBottomContentSave() { $this->contentFixedBottomContent('<button type="submit" class="btn btn-primary">' . L('Save') . '</button>'); } public function contentFixedBottomContent($f6TlW) { goto xr6sT; mJ3Bs: return $this; goto HZ5S4; VLJcQ: $this->layoutHtml('
<div class="content-fixed-bottom-toolbox-placeholder" id="' . $PMDE9 . 'Placeholder"></div>
<div class="content-fixed-bottom-toolbox" id="' . $PMDE9 . 'Content">' . $f6TlW . '</div>
<script>$(function(){ $("#' . $PMDE9 . 'Placeholder").css("height",20+$("#' . $PMDE9 . 'Content").height()+"px"); });</script>
'); goto mJ3Bs; xr6sT: $PMDE9 = IdUtil::generate('ContentFixedBottomContent'); goto VLJcQ; HZ5S4: } public function __call($c6VKG, $lLyBI) { goto JYnqo; neH0X: if (method_exists($this->page, $c6VKG)) { return $this->page->{$c6VKG}(...$lLyBI); } goto N9gCK; JYnqo: if (isset($this->config[$c6VKG])) { $this->config[$c6VKG] = $lLyBI[0]; return $this; } goto neH0X; N9gCK: return $this->form->{$c6VKG}(...$lLyBI); goto ZccDw; ZccDw: } }