<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Field; use ModStart\Core\Exception\BizException; class ComplexFieldsList extends AbstractField { protected $value = array(); protected $width = 300; protected $listable = false; protected function setup() { $this->addVariables(array('fields' => array(), 'valueItem' => new \stdClass(), 'iconServer' => modstart_admin_url('widget/icon'), 'hasIcon' => false)); } private function getValueItem() { goto wotZm; wNI8h: $bnGeC = array(); goto bgdtn; wotZm: $xG2vi = $this->getVariable('fields'); goto wNI8h; El7wl: if (empty($bnGeC)) { $bnGeC = new \stdClass(); } goto PpE44; PpE44: return $bnGeC; goto D3cmU; bgdtn: foreach ($xG2vi as $QRy1p) { $bnGeC[$QRy1p['name']] = isset($QRy1p['defaultValue']) ? $QRy1p['defaultValue'] : null; } goto El7wl; D3cmU: } public function iconServer($J1_hF) { $this->addVariables(array('iconServer' => $J1_hF)); return $this; } public function fields($gwXrh) { goto ELVRY; vJpUL: $this->addVariables(array('valueItem' => $this->getValueItem())); goto PmzTK; ELVRY: $this->addVariables(array('fields' => $gwXrh)); goto vJpUL; qoPCS: foreach ($gwXrh as $QRy1p) { goto yL2OS; qH8Kb: $pBHdS[$QRy1p['name']] = true; goto aCHQo; aCHQo: if ($QRy1p['type'] == 'icon') { $this->addVariables(array('hasIcon' => true)); } goto VvvF0; yL2OS: BizException::throwsIf('ComplexFieldsList.字段名重复 - ' . $QRy1p['name'], isset($pBHdS[$QRy1p['name']])); goto qH8Kb; VvvF0: } goto pQpnP; pQpnP: return $this; goto ZKxN7; PmzTK: $pBHdS = array(); goto qoPCS; ZKxN7: } public function unserializeValue($gwXrh, AbstractField $VWt5t) { goto zuYyQ; zuYyQ: $gwXrh = @json_decode($gwXrh, true); goto D_nzr; D_nzr: if (empty($gwXrh)) { $gwXrh = array(); } goto JdY9M; JdY9M: return $gwXrh; goto Whxro; Whxro: } public function serializeValue($gwXrh, $uV19D) { return json_encode($gwXrh, JSON_UNESCAPED_UNICODE); } public function prepareInput($gwXrh, $uV19D) { goto ibl0f; Ql8hq: if (empty($gwXrh)) { $gwXrh = array(); } goto nCeRr; nCeRr: return $gwXrh; goto r3Rso; ibl0f: $gwXrh = @json_decode($gwXrh, true); goto Ql8hq; r3Rso: } }