<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Field; use ModStart\Core\Util\ConvertUtil; use ModStart\Field\Type\FieldRenderMode; class Tree extends AbstractField { protected $value = array(); private $columnNames = array('id' => 'id', 'title' => 'title', 'children' => 'children'); protected function setup() { $this->addVariables(array('spread' => true, 'nodes' => array())); } public function columnNameId($FT9zA) { $this->columnNames['id'] = $FT9zA; return $this; } public function columnNameTitle($FT9zA) { $this->columnNames['title'] = $FT9zA; return $this; } public function columnNameChildren($FT9zA) { $this->columnNames['children'] = $FT9zA; return $this; } public function spread($FT9zA) { $this->addVariables(array('spread' => $FT9zA)); return $this; } public function unserializeValue($FT9zA, AbstractField $SQ6_6) { return ConvertUtil::toArray($FT9zA); } public function serializeValue($FT9zA, $TAWWJ) { return json_encode($FT9zA); } public function prepareInput($FT9zA, $TAWWJ) { return ConvertUtil::toArray($FT9zA); } public function tree($W4RxL) { goto Hu6Z_; X6OPO: return $this; goto Jor_o; Hu6Z_: if ($W4RxL instanceof \Closure) { $W4RxL = $W4RxL($this); } goto idBq4; idBq4: $this->addVariables(array('nodes' => $this->formatNodes($W4RxL))); goto X6OPO; Jor_o: } private function formatNodes($W4RxL) { goto QfW_k; iH8in: return $mpKYz; goto nzuxP; ZpOjE: foreach ($W4RxL as $El_MH) { goto CbKLG; nV0Sy: $uVAlr['spread'] = $this->getVariable('spread', true); goto vVxZC; vVxZC: $uVAlr['id'] = $El_MH[$this->columnNames['id']]; goto kpqtV; p3nSs: $mpKYz[] = $uVAlr; goto xMKI5; CbKLG: $uVAlr = array(); goto nV0Sy; kpqtV: $uVAlr['title'] = $El_MH[$this->columnNames['title']]; goto frS4g; frS4g: if (!empty($El_MH[$this->columnNames['children']])) { $uVAlr['children'] = $this->formatNodes($El_MH[$this->columnNames['children']]); } goto p3nSs; xMKI5: } goto iH8in; QfW_k: $mpKYz = array(); goto ZpOjE; nzuxP: } }