<?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 LNDRy; vsB3s: $yBo_a = array(); goto QmjaK; LNDRy: $Qirc_ = $this->getVariable('fields'); goto vsB3s; wedUt: if (empty($yBo_a)) { $yBo_a = new \stdClass(); } goto optdb; QmjaK: foreach ($Qirc_ as $w_wjF) { $yBo_a[$w_wjF['name']] = isset($w_wjF['defaultValue']) ? $w_wjF['defaultValue'] : null; } goto wedUt; optdb: return $yBo_a; goto dnful; dnful: } public function iconServer($xyEtj) { $this->addVariables(array('iconServer' => $xyEtj)); return $this; } public function fields($ib3B9) { goto aktgM; aktgM: $this->addVariables(array('fields' => $ib3B9)); goto Ochur; Ochur: $this->addVariables(array('valueItem' => $this->getValueItem())); goto DLAmt; DLAmt: $OViVr = array(); goto x78ao; iPJ7y: return $this; goto GoOb0; x78ao: foreach ($ib3B9 as $w_wjF) { goto R3Zij; vQe4o: if ($w_wjF['type'] == 'icon') { $this->addVariables(array('hasIcon' => true)); } goto gEl0Y; R3Zij: BizException::throwsIf('ComplexFieldsList.字段名重复 - ' . $w_wjF['name'], isset($OViVr[$w_wjF['name']])); goto qpdms; qpdms: $OViVr[$w_wjF['name']] = true; goto vQe4o; gEl0Y: } goto iPJ7y; GoOb0: } public function unserializeValue($ib3B9, AbstractField $pu1ro) { goto DnHAQ; qPcNj: if (empty($ib3B9)) { $ib3B9 = array(); } goto HmZ5g; HmZ5g: return $ib3B9; goto O5QzF; DnHAQ: $ib3B9 = @json_decode($ib3B9, true); goto qPcNj; O5QzF: } public function serializeValue($ib3B9, $nzuw7) { return json_encode($ib3B9, JSON_UNESCAPED_UNICODE); } public function prepareInput($ib3B9, $nzuw7) { goto judVs; mmBzK: if (empty($ib3B9)) { $ib3B9 = array(); } goto dSI21; dSI21: return $ib3B9; goto e31gv; judVs: $ib3B9 = @json_decode($ib3B9, true); goto mmBzK; e31gv: } }