<?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($ylaEt) { array_unshift($this->pagePrepend, $ylaEt); } public function render() { goto G91pL; gwOTt: return $this->page->render(); goto ZqPTT; G91pL: if (!empty($this->pagePrepend)) { foreach ($this->pagePrepend as $Nrp0b) { $this->page->row($Nrp0b); } } goto aTXRw; aTXRw: $this->page->body(new Box($this->form, $this->pageTitle())); goto gwOTt; ZqPTT: } public function perform($Nrp0b = null, $l2aoe = null) { goto esiSf; KGYh1: $this->form->fillFields(); goto Nf6aF; mvpuo: $this->form->item(RepositoryUtil::itemFromArray($Nrp0b)); goto KGYh1; Nf6aF: return $this; goto ed1ON; AP7WX: if (null === $Nrp0b) { $Nrp0b = array(); foreach ($this->form->fields() as $Q2vn5) { $Nrp0b[$Q2vn5->column()] = null; } } goto mvpuo; esiSf: if (Request::isPost()) { return $this->form->formRequest(function (Form $Pl0Cf) use($l2aoe) { $uotzZ = call_user_func($l2aoe, $Pl0Cf); if (null !== $uotzZ) { return $uotzZ; } return Response::jsonSuccess(L('Save Success')); }); } goto AP7WX; ed1ON: } public function __call($TUuqF, $MVaFK) { if (method_exists($this->page, $TUuqF)) { return $this->page->{$TUuqF}(...$MVaFK); } return $this->form->{$TUuqF}(...$MVaFK); } }