<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Admin\Layout; use Illuminate\Contracts\Support\Renderable; use ModStart\Admin\Auth\AdminPermission; 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 AdminConfigBuilder 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 AdminPage(); $this->form->showReset(false)->showSubmit(true); } public function useDialog() { $this->page = new AdminDialogPage(); $this->form->showReset(false)->showSubmit(false); } public function pagePrepend($ylaEt) { array_unshift($this->pagePrepend, $ylaEt); } public function render() { goto dyp0_; tzu6P: $this->page->body(new Box($this->form, $this->page->pageTitle())); goto uSX8a; uSX8a: return $this->page->render(); goto pEj3I; dyp0_: if (!empty($this->pagePrepend)) { foreach ($this->pagePrepend as $Nrp0b) { $this->page->row($Nrp0b); } } goto tzu6P; pEj3I: } public function perform($Nrp0b = null, $l2aoe = null) { goto Zk2N1; X8lg8: $this->form->fillFields(); goto yRi5N; GGNky: if (null === $Nrp0b) { $Nrp0b = array(); foreach ($this->form->fields() as $Q2vn5) { $Nrp0b[$Q2vn5->column()] = modstart_config($Q2vn5->column(), $Q2vn5->defaultValue()); } } else { if (false === $Nrp0b) { $Nrp0b = array(); foreach ($this->form->fields() as $Q2vn5) { $Nrp0b[$Q2vn5->column()] = null; } } } goto fr4C0; fr4C0: $this->form->item(RepositoryUtil::itemFromArray($Nrp0b)); goto X8lg8; Zk2N1: if (Request::isPost()) { AdminPermission::demoCheck(); return $this->form->formRequest(function (Form $Pl0Cf) use($l2aoe) { if ($l2aoe) { $uotzZ = call_user_func($l2aoe, $Pl0Cf); if (null !== $uotzZ) { return $uotzZ; } } else { $KGvTC = modstart_config(); foreach ($Pl0Cf->dataForming() as $U9AsU => $ohYVl) { $KGvTC->set($U9AsU, $ohYVl); } } return Response::jsonSuccess(L('Save Success')); }); } goto GGNky; yRi5N: return $this; goto UpwIs; UpwIs: } public function __call($TUuqF, $MVaFK) { if (method_exists($this->page, $TUuqF)) { return $this->page->{$TUuqF}(...$MVaFK); } return $this->form->{$TUuqF}(...$MVaFK); } }