<?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($btrD9) { array_unshift($this->pagePrepend, $btrD9); } public function render() { goto pQO4S; pQO4S: if (!empty($this->pagePrepend)) { foreach ($this->pagePrepend as $V563N) { $this->page->row($V563N); } } goto zx7KY; J6C_7: return $this->page->render(); goto ayj7e; zx7KY: if ($this->page instanceof WebDialogPage) { $this->page->body($this->form); } else { $this->page->body(new Box($this->form, $this->pageTitle())); } goto J6C_7; ayj7e: } public function perform($V563N = null, $Yzz3F = null) { goto Rv_G9; IK7MK: $this->form->item(RepositoryUtil::itemFromArray($V563N)); goto qDhqK; Rxoqd: return $this; goto bn11L; qDhqK: $this->form->fillFields(); goto Rxoqd; Rv_G9: if (Request::isPost()) { return $this->form->formRequest(function (Form $mjvnb) use($Yzz3F) { $gbVzz = call_user_func($Yzz3F, $mjvnb); if (null !== $gbVzz) { return $gbVzz; } return Response::jsonSuccess(L('Save Success')); }); } goto cRCrJ; cRCrJ: if (null === $V563N) { $V563N = array(); foreach ($this->form->fields() as $pu1ro) { $V563N[$pu1ro->column()] = null; } } goto IK7MK; bn11L: } public function __call($XggBq, $lUGZC) { if (method_exists($this->page, $XggBq)) { return $this->page->{$XggBq}(...$lUGZC); } return $this->form->{$XggBq}(...$lUGZC); } }