<?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($LZohU) { array_unshift($this->pagePrepend, $LZohU); } public function render() { goto JpKr2; f_Htw: if ($this->page instanceof WebDialogPage) { $this->page->body($this->form); } else { $this->page->body(new Box($this->form, $this->pageTitle())); } goto vI1B9; JpKr2: if (!empty($this->pagePrepend)) { foreach ($this->pagePrepend as $ZpLX1) { $this->page->row($ZpLX1); } } goto f_Htw; vI1B9: return $this->page->render(); goto HAffO; HAffO: } public function perform($ZpLX1 = null, $aCnQE = null) { goto ec6Dj; FuNmZ: $this->form->item(RepositoryUtil::itemFromArray($ZpLX1)); goto Y3QYu; ec6Dj: if (Request::isPost()) { return $this->form->formRequest(function (Form $LEyIF) use($aCnQE) { $pTwJr = call_user_func($aCnQE, $LEyIF); if (null !== $pTwJr) { return $pTwJr; } return Response::jsonSuccess(L('Save Success')); }); } goto oRPD_; Y3QYu: $this->form->fillFields(); goto GkIxt; oRPD_: if (null === $ZpLX1) { $ZpLX1 = array(); foreach ($this->form->fields() as $Lgjfa) { $ZpLX1[$Lgjfa->column()] = null; } } goto FuNmZ; GkIxt: return $this; goto o1vaD; o1vaD: } public function __call($L4owo, $nvZ9A) { if (method_exists($this->page, $L4owo)) { return $this->page->{$L4owo}(...$nvZ9A); } return $this->form->{$L4owo}(...$nvZ9A); } }