<?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($uTsZq) { array_unshift($this->pagePrepend, $uTsZq); } public function render() { goto wgzvo; oML3D: if ($this->page instanceof WebDialogPage) { $this->page->body($this->form); } else { $this->page->body(new Box($this->form, $this->pageTitle())); } goto FzUHW; wgzvo: if (!empty($this->pagePrepend)) { foreach ($this->pagePrepend as $Esk0p) { $this->page->row($Esk0p); } } goto oML3D; FzUHW: return $this->page->render(); goto EwGNs; EwGNs: } public function perform($Esk0p = null, $b9NqF = null) { goto NDJor; NDJor: if (Request::isPost()) { return $this->form->formRequest(function (Form $SKFwZ) use($b9NqF) { $ZIe4d = call_user_func($b9NqF, $SKFwZ); if (null !== $ZIe4d) { return $ZIe4d; } return Response::jsonSuccess(L('Save Success')); }); } goto h0izn; h0izn: if (null === $Esk0p) { $Esk0p = array(); foreach ($this->form->fields() as $rZfgs) { $Esk0p[$rZfgs->column()] = null; } } goto Yp4pj; Yp4pj: $this->form->item(RepositoryUtil::itemFromArray($Esk0p)); goto ZrdsN; ZrdsN: $this->form->fillFields(); goto otbt6; otbt6: return $this; goto XMvcH; XMvcH: } public function __call($ZZMEd, $rxS2C) { if (method_exists($this->page, $ZZMEd)) { return $this->page->{$ZZMEd}(...$rxS2C); } return $this->form->{$ZZMEd}(...$rxS2C); } }