<?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($brUx_) { array_unshift($this->pagePrepend, $brUx_); } public function render() { goto WDWAa; WDWAa: if (!empty($this->pagePrepend)) { foreach ($this->pagePrepend as $OV1o4) { $this->page->row($OV1o4); } } goto gCg3b; dFQaE: return $this->page->render(); goto ueIl8; gCg3b: if ($this->page instanceof WebDialogPage) { $this->page->body($this->form); } else { $this->page->body(new Box($this->form, $this->pageTitle())); } goto dFQaE; ueIl8: } public function perform($OV1o4 = null, $uTSeU = null) { goto yHuBe; EwnI9: $this->form->item(RepositoryUtil::itemFromArray($OV1o4)); goto l19A3; lk7D1: return $this; goto bGfAP; yHuBe: if (Request::isPost()) { return $this->form->formRequest(function (Form $yfPYJ) use($uTSeU) { $Z5nZL = call_user_func($uTSeU, $yfPYJ); if (null !== $Z5nZL) { return $Z5nZL; } return Response::jsonSuccess(L('Save Success')); }); } goto aKX_7; l19A3: $this->form->fillFields(); goto lk7D1; aKX_7: if (null === $OV1o4) { $OV1o4 = array(); foreach ($this->form->fields() as $E8QRJ) { $OV1o4[$E8QRJ->column()] = null; } } goto EwnI9; bGfAP: } public function __call($f0dxO, $RSGSj) { if (method_exists($this->page, $f0dxO)) { return $this->page->{$f0dxO}(...$RSGSj); } return $this->form->{$f0dxO}(...$RSGSj); } }