<?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($tzAUI) { $this->columnNames['id'] = $tzAUI; return $this; } public function columnNameTitle($tzAUI) { $this->columnNames['title'] = $tzAUI; return $this; } public function columnNameChildren($tzAUI) { $this->columnNames['children'] = $tzAUI; return $this; } public function spread($tzAUI) { $this->addVariables(array('spread' => $tzAUI)); return $this; } public function unserializeValue($tzAUI, AbstractField $Q2vn5) { return ConvertUtil::toArray($tzAUI); } public function serializeValue($tzAUI, $pWRTh) { return json_encode($tzAUI); } public function prepareInput($tzAUI, $pWRTh) { return ConvertUtil::toArray($tzAUI); } public function tree($Heozd) { goto vSa1o; AS0QA: return $this; goto eD995; vSa1o: if ($Heozd instanceof \Closure) { $Heozd = $Heozd($this); } goto RwDbO; RwDbO: $this->addVariables(array('nodes' => $this->formatNodes($Heozd))); goto AS0QA; eD995: } private function formatNodes($Heozd) { goto QM81m; plcvl: foreach ($Heozd as $Nrp0b) { goto QR4iS; EIFrM: $dZlBq['id'] = $Nrp0b[$this->columnNames['id']]; goto Eis1Q; Eis1Q: $dZlBq['title'] = $Nrp0b[$this->columnNames['title']]; goto Rhx82; BHZp9: $BawGQ[] = $dZlBq; goto aAkrZ; Rhx82: if (!empty($Nrp0b[$this->columnNames['children']])) { $dZlBq['children'] = $this->formatNodes($Nrp0b[$this->columnNames['children']]); } goto BHZp9; QR4iS: $dZlBq = array(); goto zgNG1; zgNG1: $dZlBq['spread'] = $this->getVariable('spread', true); goto EIFrM; aAkrZ: } goto Eh1Bt; QM81m: $BawGQ = array(); goto plcvl; Eh1Bt: return $BawGQ; goto YkWEB; YkWEB: } }