<?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($Gttsd) { $this->columnNames['id'] = $Gttsd; return $this; } public function columnNameTitle($Gttsd) { $this->columnNames['title'] = $Gttsd; return $this; } public function columnNameChildren($Gttsd) { $this->columnNames['children'] = $Gttsd; return $this; } public function spread($Gttsd) { $this->addVariables(array('spread' => $Gttsd)); return $this; } public function unserializeValue($Gttsd, AbstractField $acdQI) { if (null === $Gttsd) { return $Gttsd; } return ConvertUtil::toArray($Gttsd); } public function serializeValue($Gttsd, $BWo2e) { return json_encode($Gttsd); } public function prepareInput($Gttsd, $BWo2e) { return ConvertUtil::toArray($Gttsd); } public function tree($JfCUQ) { goto UPBHG; x2w36: $this->addVariables(array('nodes' => $this->formatNodes($JfCUQ))); goto By5t8; By5t8: return $this; goto a1v2o; UPBHG: if ($JfCUQ instanceof \Closure) { $JfCUQ = $JfCUQ($this); } goto x2w36; a1v2o: } private function formatNodes($JfCUQ) { goto I61ca; I61ca: $bs3PA = array(); goto a9kig; yYWtI: return $bs3PA; goto gs2IL; a9kig: foreach ($JfCUQ as $Xvngd) { goto rpwxm; dEP6A: $NQy2q['id'] = $Xvngd[$this->columnNames['id']]; goto zq3B5; rpwxm: $NQy2q = array(); goto DbTxW; DbTxW: $NQy2q['spread'] = $this->getVariable('spread', true); goto dEP6A; Q3zFD: $bs3PA[] = $NQy2q; goto I2cMN; zq3B5: $NQy2q['title'] = $Xvngd[$this->columnNames['title']]; goto coQ8i; coQ8i: if (!empty($Xvngd[$this->columnNames['children']])) { $NQy2q['children'] = $this->formatNodes($Xvngd[$this->columnNames['children']]); } goto Q3zFD; I2cMN: } goto yYWtI; gs2IL: } }