<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Field; use Illuminate\Support\Facades\View; use ModStart\Core\Exception\BizException; use ModStart\Core\Input\InputPackage; use ModStart\Core\Util\ArrayUtil; class CustomField extends AbstractField { public static $supportTypes = array('Text', 'Radio', 'File', 'Files'); protected $value = array('type' => '', 'title' => '', 'data' => array('option' => array())); protected $listable = false; protected function setup() { $this->addVariables(array()); } public function unserializeValue($FT9zA, AbstractField $SQ6_6) { goto ma0ou; Bwkml: if (!isset($FT9zA['data']['option'])) { $FT9zA['data']['option'] = array(); } goto Binxf; P70K8: if (!isset($FT9zA['type'])) { $FT9zA['type'] = ''; } goto yS1Wj; Binxf: return $FT9zA; goto otDzo; yS1Wj: if (!isset($FT9zA['title'])) { $FT9zA['title'] = ''; } goto sIcv1; fKMpD: if (empty($FT9zA)) { $FT9zA = array(); } goto P70K8; sIcv1: if (!isset($FT9zA['data'])) { $FT9zA['data'] = array(); } goto Bwkml; ma0ou: $FT9zA = @json_decode($FT9zA, true); goto fKMpD; otDzo: } public function serializeValue($FT9zA, $TAWWJ) { return json_encode($FT9zA); } public function prepareInput($FT9zA, $TAWWJ) { goto tQPBO; xQ814: return $FT9zA; goto hF9KZ; tQPBO: $FT9zA = @json_decode($FT9zA, true); goto RwFGi; RwFGi: if (empty($FT9zA)) { $FT9zA = array(); } goto xQ814; hF9KZ: } public static function buildRecordNameValue($jSIoT, $TON20, $b2156 = 'fieldCustom', $YVkAX = 5) { goto HHASB; ktux0: for ($eQWJY = 1; $eQWJY <= $YVkAX; $eQWJY++) { if (empty($jSIoT[$b2156 . $eQWJY])) { continue; } $SQ6_6 = $jSIoT[$b2156 . $eQWJY]; if (is_string($SQ6_6)) { $SQ6_6 = @json_decode($SQ6_6, true); } if (empty($SQ6_6['type']) || empty($SQ6_6['title'])) { continue; } $Bhg6G[] = array('name' => $SQ6_6['title'], 'value' => $TON20[$b2156 . $eQWJY], 'field' => $SQ6_6, 'record' => $TON20); } goto aJymY; aJymY: return $Bhg6G; goto laQxu; HHASB: $Bhg6G = array(); goto ktux0; laQxu: } public static function hasFields($EdQjV, $b2156 = 'fieldCustom', $YVkAX = 5) { for ($eQWJY = 1; $eQWJY <= $YVkAX; $eQWJY++) { if (empty($EdQjV[$b2156 . $eQWJY])) { continue; } $SQ6_6 = $EdQjV[$b2156 . $eQWJY]; if (is_string($SQ6_6)) { $SQ6_6 = @json_decode($SQ6_6, true); } if (empty($SQ6_6['type']) || empty($SQ6_6['title'])) { continue; } return true; } return false; } public static function unbuildTableFieldRow(&$EdQjV, $b2156 = 'fieldCustom', $YVkAX = 5) { goto QRJQm; uICfg: $EdQjV['_' . $b2156] = $iRd8v; goto EXPbR; H4o1W: for ($eQWJY = 1; $eQWJY <= $YVkAX; $eQWJY++) { if (empty($EdQjV[$b2156 . $eQWJY])) { continue; } $SQ6_6 = $EdQjV[$b2156 . $eQWJY]; if (is_string($SQ6_6)) { $SQ6_6 = @json_decode($SQ6_6, true); } if (empty($SQ6_6['type']) || empty($SQ6_6['title'])) { continue; } $SQ6_6['_name'] = $b2156 . $eQWJY; $iRd8v[] = $SQ6_6; } goto uICfg; QRJQm: $iRd8v = array(); goto H4o1W; EXPbR: } public static function prepareInputOrFail($SQ6_6, $CrVBf, InputPackage $H2Do2) { goto lSvT3; Df7eL: BizException::throws('未知的自定义字段类型:' . json_encode($SQ6_6)); goto OOPNP; lSvT3: if (empty($SQ6_6['type']) || empty($SQ6_6['title'])) { return ''; } goto ykThx; ykThx: if (!in_array($SQ6_6['type'], static::$supportTypes)) { return ''; } goto Zyrof; Zyrof: switch ($SQ6_6['type']) { case 'Text': case 'Radio': return $H2Do2->getTrimString($CrVBf); case 'File': return $H2Do2->getFilePath($CrVBf); case 'Files': $EdQjV = $H2Do2->getJsonFilesPath($CrVBf); return json_encode($EdQjV, JSON_UNESCAPED_UNICODE); } goto Df7eL; OOPNP: } public static function prepareDetail($SQ6_6, $FT9zA) { goto os1sb; cBJiJ: switch ($SQ6_6['type']) { case 'Text': case 'Radio': case 'File': return $FT9zA; case 'Files': goto eKfT_; af46Y: if (empty($FT9zA) || !is_array($FT9zA)) { $FT9zA = array(); } goto j04Pd; j04Pd: return $FT9zA; goto aqBNQ; eKfT_: $FT9zA = @json_decode($FT9zA, true); goto af46Y; aqBNQ: } goto G_O4Q; os1sb: if (empty($SQ6_6['type']) || empty($SQ6_6['title'])) { return ''; } goto m9k0v; m9k0v: if (!in_array($SQ6_6['type'], static::$supportTypes)) { return ''; } goto cBJiJ; G_O4Q: return null; goto faaDr; faaDr: } public static function renderForm($SQ6_6, $CrVBf, $Kp99R = array()) { goto iVHnd; qQCJH: return View::make('modstart::core.field.customField.form.' . $SQ6_6['type'], array('fieldName' => $CrVBf, 'field' => $SQ6_6, 'param' => $Kp99R))->render(); goto wVClc; iVHnd: if (empty($SQ6_6['type']) || empty($SQ6_6['title'])) { return ''; } goto obsAN; obsAN: if (!in_array($SQ6_6['type'], static::$supportTypes)) { return ''; } goto qQCJH; wVClc: } public static function renderDetail($SQ6_6, $FT9zA) { goto W3JVL; HCDqE: $FT9zA = self::prepareDetail($SQ6_6, $FT9zA); goto zsQQZ; zsQQZ: return View::make('modstart::core.field.customField.detail.' . $SQ6_6['type'], array('field' => $SQ6_6, 'value' => $FT9zA))->render(); goto W8H6N; W3JVL: if (empty($SQ6_6['type']) || empty($SQ6_6['title'])) { return ''; } goto njZNo; njZNo: if (!in_array($SQ6_6['type'], static::$supportTypes)) { return ''; } goto HCDqE; W8H6N: } }