<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Field; use ModStart\Core\Util\ConvertUtil; use ModStart\Core\Util\SerializeUtil; 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($HDpl6) { $this->columnNames['id'] = $HDpl6; return $this; } public function columnNameTitle($HDpl6) { $this->columnNames['title'] = $HDpl6; return $this; } public function columnNameChildren($HDpl6) { $this->columnNames['children'] = $HDpl6; return $this; } public function spread($HDpl6) { $this->addVariables(array('spread' => $HDpl6)); return $this; } public function unserializeValue($HDpl6, AbstractField $E8QRJ) { if (null === $HDpl6) { return $HDpl6; } return ConvertUtil::toArray($HDpl6); } public function serializeValue($HDpl6, $xTADA) { return SerializeUtil::jsonEncode($HDpl6); } public function prepareInput($HDpl6, $xTADA) { return ConvertUtil::toArray($HDpl6); } public function tree($l9jHV) { goto zhhia; zhhia: if ($l9jHV instanceof \Closure) { $l9jHV = $l9jHV($this); } goto AE6Te; AE6Te: $this->addVariables(array('nodes' => $this->formatNodes($l9jHV))); goto Gpsqv; Gpsqv: return $this; goto OyMik; OyMik: } private function formatNodes($l9jHV) { goto SP9TY; SP9TY: $pWf7i = array(); goto Dh2Ev; Dh2Ev: foreach ($l9jHV as $OV1o4) { goto AqDxb; nqK5H: $S4AZg['id'] = $OV1o4[$this->columnNames['id']]; goto zaMv2; zaMv2: $S4AZg['title'] = $OV1o4[$this->columnNames['title']]; goto uqm2u; DRr_e: $S4AZg['spread'] = $this->getVariable('spread', true); goto nqK5H; AqDxb: $S4AZg = array(); goto DRr_e; uqm2u: if (!empty($OV1o4[$this->columnNames['children']])) { $S4AZg['children'] = $this->formatNodes($OV1o4[$this->columnNames['children']]); } goto vLGoE; vLGoE: $pWf7i[] = $S4AZg; goto H3v2D; H3v2D: } goto RXUgd; RXUgd: return $pWf7i; goto dz2NP; dz2NP: } }