<?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($O4nvM) { array_unshift($this->pagePrepend, $O4nvM); } public function render() { goto XzDIw; XzDIw: if (!empty($this->pagePrepend)) { foreach ($this->pagePrepend as $P1uVJ) { $this->page->row($P1uVJ); } } goto CYtAN; CYtAN: if ($this->page instanceof WebDialogPage) { $this->page->body($this->form); } else { $this->page->body(new Box($this->form, $this->pageTitle())); } goto ESV56; ESV56: return $this->page->render(); goto ygnOR; ygnOR: } public function perform($P1uVJ = null, $liNDm = null) { goto qWgtI; BqPQ_: $this->form->item(RepositoryUtil::itemFromArray($P1uVJ)); goto p3v6O; vPoZh: if (null === $P1uVJ) { $P1uVJ = array(); foreach ($this->form->fields() as $Ldet7) { $P1uVJ[$Ldet7->column()] = null; } } goto BqPQ_; qWgtI: if (Request::isPost()) { return $this->form->formRequest(function (Form $dBWZm) use($liNDm) { $bCCWW = call_user_func($liNDm, $dBWZm); if (null !== $bCCWW) { return $bCCWW; } return Response::jsonSuccess(L('Save Success')); }); } goto vPoZh; i2GP_: return $this; goto GRuau; p3v6O: $this->form->fillFields(); goto i2GP_; GRuau: } public function __call($glP3G, $bY7Wp) { if (method_exists($this->page, $glP3G)) { return $this->page->{$glP3G}(...$bY7Wp); } return $this->form->{$glP3G}(...$bY7Wp); } }