<?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($TvJeT) { array_unshift($this->pagePrepend, $TvJeT); } public function render() { goto hWuBO; wDyh_: return $this->page->render(); goto dqKrI; hWuBO: if (!empty($this->pagePrepend)) { foreach ($this->pagePrepend as $yFnpO) { $this->page->row($yFnpO); } } goto ZRPk5; ZRPk5: if ($this->page instanceof WebDialogPage) { $this->page->body($this->form); } else { $this->page->body(new Box($this->form, $this->pageTitle())); } goto wDyh_; dqKrI: } public function perform($yFnpO = null, $yeJzO = null) { goto LUbzI; L_BKD: if (null === $yFnpO) { $yFnpO = array(); foreach ($this->form->fields() as $Mk6lP) { $yFnpO[$Mk6lP->column()] = null; } } goto OGTo_; Qiafj: return $this; goto FQG7Q; OGTo_: $this->form->item(RepositoryUtil::itemFromArray($yFnpO)); goto SLTtR; SLTtR: $this->form->fillFields(); goto Qiafj; LUbzI: if (Request::isPost()) { return $this->form->formRequest(function (Form $wDk8k) use($yeJzO) { $N2Xaa = call_user_func($yeJzO, $wDk8k); if (null !== $N2Xaa) { return $N2Xaa; } return Response::jsonSuccess(L('Save Success')); }); } goto L_BKD; FQG7Q: } public function __call($c6VKG, $lLyBI) { if (method_exists($this->page, $c6VKG)) { return $this->page->{$c6VKG}(...$lLyBI); } return $this->form->{$c6VKG}(...$lLyBI); } }