<?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($ib3B9) { $this->columnNames['id'] = $ib3B9; return $this; } public function columnNameTitle($ib3B9) { $this->columnNames['title'] = $ib3B9; return $this; } public function columnNameChildren($ib3B9) { $this->columnNames['children'] = $ib3B9; return $this; } public function spread($ib3B9) { $this->addVariables(array('spread' => $ib3B9)); return $this; } public function unserializeValue($ib3B9, AbstractField $pu1ro) { if (null === $ib3B9) { return $ib3B9; } return ConvertUtil::toArray($ib3B9); } public function serializeValue($ib3B9, $nzuw7) { return json_encode($ib3B9); } public function prepareInput($ib3B9, $nzuw7) { return ConvertUtil::toArray($ib3B9); } public function tree($TNMTq) { goto Us9Xm; te_k3: $this->addVariables(array('nodes' => $this->formatNodes($TNMTq))); goto hO7AC; Us9Xm: if ($TNMTq instanceof \Closure) { $TNMTq = $TNMTq($this); } goto te_k3; hO7AC: return $this; goto LBHOr; LBHOr: } private function formatNodes($TNMTq) { goto DQkQh; jMCbJ: foreach ($TNMTq as $V563N) { goto qh2Q2; Ja77E: if (!empty($V563N[$this->columnNames['children']])) { $Zj23p['children'] = $this->formatNodes($V563N[$this->columnNames['children']]); } goto RCBDj; d5YlI: $Zj23p['id'] = $V563N[$this->columnNames['id']]; goto w0vHh; f6oRR: $Zj23p['spread'] = $this->getVariable('spread', true); goto d5YlI; w0vHh: $Zj23p['title'] = $V563N[$this->columnNames['title']]; goto Ja77E; RCBDj: $xbtey[] = $Zj23p; goto sW3lE; qh2Q2: $Zj23p = array(); goto f6oRR; sW3lE: } goto bmoES; bmoES: return $xbtey; goto vj3L9; DQkQh: $xbtey = array(); goto jMCbJ; vj3L9: } }