<?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($y1m38) { array_unshift($this->pagePrepend, $y1m38); } public function render() { goto p5BU3; LV2Lu: $this->page->body($DYWlr); goto dU1Im; p5BU3: if (!empty($this->pagePrepend)) { foreach ($this->pagePrepend as $nsWl0) { $this->page->row($nsWl0); } } goto GSuvS; GSuvS: $DYWlr = $this->form; goto NdGWB; dU1Im: return $this->page->render(); goto oQw9f; NdGWB: if (!$this->config['disableBoxWrap']) { $DYWlr = new Box($this->form, $this->page->pageTitle()); } goto LV2Lu; oQw9f: } public function perform($nsWl0 = null, $R6Imz = null) { goto b6hCI; a417N: return $this; goto FaiWW; b6hCI: if (Request::isPost()) { AdminPermission::demoCheck(); return $this->form->formRequest(function (Form $tzSkY) use($R6Imz) { if ($R6Imz) { $UdQ1p = call_user_func($R6Imz, $tzSkY); if (null !== $UdQ1p) { return $UdQ1p; } } else { $eYjRX = modstart_config(); foreach ($tzSkY->dataForming() as $GBNIv => $VFelt) { $eYjRX->set($GBNIv, $VFelt); } } return Response::jsonSuccess(L('Save Success')); }); } goto IWRqa; IWRqa: if (null === $nsWl0) { goto EYpX1; EYpX1: $nsWl0 = array(); goto ktcQt; ktcQt: $eYjRX = modstart_config(); goto MuxhH; MuxhH: foreach ($this->form->fields() as $VWt5t) { goto xlQeE; xlQeE: if ($VWt5t->isLayoutField()) { continue; } goto yHtGf; SmyK2: $nsWl0[$VWt5t->column()] = $VFelt; goto qxkbb; kyp67: if ($g2NSd) { $VFelt = modstart_config($VWt5t->column()); } else { $VFelt = null; } goto T_btO; yHtGf: $g2NSd = $eYjRX->has($VWt5t->column()); goto kyp67; T_btO: if (is_array($VFelt)) { $VFelt = json_encode($VFelt, JSON_UNESCAPED_UNICODE); } goto SmyK2; qxkbb: } goto gmRIG; gmRIG: } else { if (false === $nsWl0) { $nsWl0 = array(); foreach ($this->form->fields() as $VWt5t) { if ($VWt5t->isLayoutField()) { continue; } $nsWl0[$VWt5t->column()] = null; } } } goto cnOg4; cnOg4: $this->form->item(RepositoryUtil::itemFromArray($nsWl0)); goto VkX7m; VkX7m: $this->form->fillFields(); goto a417N; FaiWW: } public function contentFixedBottomContentSave() { $this->contentFixedBottomContent('<button type="submit" class="btn btn-primary">' . L('Save') . '</button>'); } public function contentFixedBottomContent($STW4e) { goto y2Nca; y2Nca: $xYu70 = IdUtil::generate('ContentFixedBottomContent'); goto wd0Lm; wd0Lm: $this->layoutHtml('
<div class="content-fixed-bottom-toolbox-placeholder" id="' . $xYu70 . 'Placeholder"></div>
<div class="content-fixed-bottom-toolbox" id="' . $xYu70 . 'Content">' . $STW4e . '</div>
<script>$(function(){ $("#' . $xYu70 . 'Placeholder").css("height",20+$("#' . $xYu70 . 'Content").height()+"px"); });</script>
'); goto cuQHN; cuQHN: return $this; goto kPl9_; kPl9_: } public function __call($L1g9F, $CUZy6) { goto Bflv8; B0rZi: if (method_exists($this->page, $L1g9F)) { return $this->page->{$L1g9F}(...$CUZy6); } goto Hqejw; Hqejw: return $this->form->{$L1g9F}(...$CUZy6); goto CoUjz; Bflv8: if (isset($this->config[$L1g9F])) { $this->config[$L1g9F] = $CUZy6[0]; return $this; } goto B0rZi; CoUjz: } }