<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\App\Web\Layout; use Illuminate\Contracts\Support\Renderable; use ModStart\Core\Dao\DynamicModel; use ModStart\Core\Input\Request; use ModStart\Core\Input\Response; use ModStart\Form\Form; use ModStart\Layout\Page; use ModStart\Repository\RepositoryUtil; use ModStart\Widget\Box; class WebConfigBuilder implements Renderable { private $page; private $form; private $pagePrepend = array(); 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 WebPage(); $this->form->showReset(false)->showSubmit(true); } public function useDialog() { $this->page = new WebDialogPage(); $this->form->showReset(false)->showSubmit(false); } public function pagePrepend($y1m38) { array_unshift($this->pagePrepend, $y1m38); } public function render() { goto bLsPV; wJH_s: return $this->page->render(); goto zL1Q5; qAfVE: if ($this->page instanceof WebDialogPage) { $this->page->body($this->form); } else { $this->page->body(new Box($this->form, $this->pageTitle())); } goto wJH_s; bLsPV: if (!empty($this->pagePrepend)) { foreach ($this->pagePrepend as $nsWl0) { $this->page->row($nsWl0); } } goto qAfVE; zL1Q5: } public function perform($nsWl0 = null, $R6Imz = null) { goto xEOXh; WPbGL: if (null === $nsWl0) { $nsWl0 = array(); foreach ($this->form->fields() as $VWt5t) { $nsWl0[$VWt5t->column()] = null; } } goto RAPN9; xEOXh: if (Request::isPost()) { return $this->form->formRequest(function (Form $tzSkY) use($R6Imz) { $UdQ1p = call_user_func($R6Imz, $tzSkY); if (null !== $UdQ1p) { return $UdQ1p; } return Response::jsonSuccess(L('Save Success')); }); } goto WPbGL; RKb0m: $this->form->fillFields(); goto W2vhx; RAPN9: $this->form->item(RepositoryUtil::itemFromArray($nsWl0)); goto RKb0m; W2vhx: return $this; goto oI9ia; oI9ia: } public function __call($L1g9F, $CUZy6) { if (method_exists($this->page, $L1g9F)) { return $this->page->{$L1g9F}(...$CUZy6); } return $this->form->{$L1g9F}(...$CUZy6); } }