<?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($iLXxb) { array_unshift($this->pagePrepend, $iLXxb); } public function render() { goto FilOt; p4hyL: if ($this->page instanceof WebDialogPage) { $this->page->body($this->form); } else { $this->page->body(new Box($this->form, $this->pageTitle())); } goto bU8wv; FilOt: if (!empty($this->pagePrepend)) { foreach ($this->pagePrepend as $Xvngd) { $this->page->row($Xvngd); } } goto p4hyL; bU8wv: return $this->page->render(); goto m0GP_; m0GP_: } public function perform($Xvngd = null, $SO11l = null) { goto nLyxT; nK2Oj: $this->form->item(RepositoryUtil::itemFromArray($Xvngd)); goto YG0ff; LlZZN: return $this; goto VN_cO; YG0ff: $this->form->fillFields(); goto LlZZN; nLyxT: if (Request::isPost()) { return $this->form->formRequest(function (Form $aDbJm) use($SO11l) { $f3Nqc = call_user_func($SO11l, $aDbJm); if (null !== $f3Nqc) { return $f3Nqc; } return Response::jsonSuccess(L('Save Success')); }); } goto vyFgZ; vyFgZ: if (null === $Xvngd) { $Xvngd = array(); foreach ($this->form->fields() as $acdQI) { $Xvngd[$acdQI->column()] = null; } } goto nK2Oj; VN_cO: } public function __call($sQIr6, $g59Hh) { if (method_exists($this->page, $sQIr6)) { return $this->page->{$sQIr6}(...$g59Hh); } return $this->form->{$sQIr6}(...$g59Hh); } }