<?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($Nahzt) { array_unshift($this->pagePrepend, $Nahzt); } public function render() { goto RMAlf; RMAlf: if (!empty($this->pagePrepend)) { foreach ($this->pagePrepend as $El_MH) { $this->page->row($El_MH); } } goto M1m3s; D25HX: return $this->page->render(); goto pJxEP; M1m3s: if ($this->page instanceof WebDialogPage) { $this->page->body($this->form); } else { $this->page->body(new Box($this->form, $this->pageTitle())); } goto D25HX; pJxEP: } public function perform($El_MH = null, $r1VBm = null) { goto QH4AL; Is1RO: return $this; goto q5zjg; QH4AL: if (Request::isPost()) { return $this->form->formRequest(function (Form $u4AHU) use($r1VBm) { $JOw_A = call_user_func($r1VBm, $u4AHU); if (null !== $JOw_A) { return $JOw_A; } return Response::jsonSuccess(L('Save Success')); }); } goto atY1o; D7Lbm: $this->form->item(RepositoryUtil::itemFromArray($El_MH)); goto nukkK; nukkK: $this->form->fillFields(); goto Is1RO; atY1o: if (null === $El_MH) { $El_MH = array(); foreach ($this->form->fields() as $SQ6_6) { $El_MH[$SQ6_6->column()] = null; } } goto D7Lbm; q5zjg: } public function __call($rPkIY, $HPXJC) { if (method_exists($this->page, $rPkIY)) { return $this->page->{$rPkIY}(...$HPXJC); } return $this->form->{$rPkIY}(...$HPXJC); } }