<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Field; use ModStart\Core\Util\ConvertUtil; use ModStart\Field\Type\FieldRenderMode; class Tree extends AbstractField { private $columnNames = array('id' => 'id', 'title' => 'title', 'children' => '_child'); protected function setup() { $this->addVariables(array('spread' => true, 'nodes' => array())); } public function columnNameId($wvO30) { $this->columnNames['id'] = $wvO30; return $this; } public function columnNameTitle($wvO30) { $this->columnNames['title'] = $wvO30; return $this; } public function columnNameChildren($wvO30) { $this->columnNames['children'] = $wvO30; return $this; } public function spread($wvO30) { $this->addVariables(array('spread' => $wvO30)); return $this; } public function unserializeValue($wvO30, AbstractField $Lgjfa) { if (null === $wvO30) { return $wvO30; } return ConvertUtil::toArray($wvO30); } public function serializeValue($wvO30, $w5oww) { return json_encode($wvO30); } public function prepareInput($wvO30, $w5oww) { return ConvertUtil::toArray($wvO30); } public function tree($CxvjP) { goto yfjOi; eTwlF: $this->addVariables(array('nodes' => $this->formatNodes($CxvjP))); goto j0gNj; j0gNj: return $this; goto I0n2a; yfjOi: if ($CxvjP instanceof \Closure) { $CxvjP = $CxvjP($this); } goto eTwlF; I0n2a: } private function formatNodes($CxvjP) { goto Vm3Uq; HlCfm: return $JtdYi; goto VARYt; DcaGd: foreach ($CxvjP as $ZpLX1) { goto U6J1C; BVEnL: $mbB90['spread'] = $this->getVariable('spread', true); goto zO6_1; DLzdU: $mbB90['title'] = $ZpLX1[$this->columnNames['title']]; goto cRTCB; zO6_1: $mbB90['id'] = $ZpLX1[$this->columnNames['id']]; goto DLzdU; cRTCB: if (!empty($ZpLX1[$this->columnNames['children']])) { $mbB90['children'] = $this->formatNodes($ZpLX1[$this->columnNames['children']]); } goto pEVcV; U6J1C: $mbB90 = array(); goto BVEnL; pEVcV: $JtdYi[] = $mbB90; goto YVwj9; YVwj9: } goto HlCfm; Vm3Uq: $JtdYi = array(); goto DcaGd; VARYt: } }