<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Field; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Input\InputPackage; use ModStart\Core\Util\ConvertUtil; class ManyRelation extends AbstractField { const MODE_GROUP_TAGS = 'groupTags'; protected $isCustomField = true; protected $defaultValue = array(); protected function setup() { $this->addVariables(array('relationTable' => '', 'relationModelIdKey' => '', 'relationIdKey' => '', 'mode' => self::MODE_GROUP_TAGS, 'groupTags' => array(), 'groupTagsTitleKey' => 'title', 'groupTagsChildKey' => '_child')); $this->hookValueSaved(function ($a1OPc, AbstractField $pu1ro) { $do_OL = InputPackage::buildFromInput(); $bP0d3 = $do_OL->getJson($pu1ro->column, array()); ModelUtil::relationAssign($this->getVariable('relationTable'), $this->getVariable('relationModelIdKey'), $a1OPc, $this->getVariable('relationIdKey'), $bP0d3); }); } public function mode($oWpPb) { $this->addVariables(array('mode' => $oWpPb)); return $this; } public function relationTable($Y2RbY, $e1WjV, $iYBOY) { goto xmhSQ; xmhSQ: $this->addVariables(array('relationTable' => $Y2RbY)); goto MM3AG; U2euk: return $this; goto hjfjs; eJcEb: $this->addVariables(array('relationIdKey' => $iYBOY)); goto U2euk; MM3AG: $this->addVariables(array('relationModelIdKey' => $e1WjV)); goto eJcEb; hjfjs: } public function groupTags($ed1Ls, $P9Sjb = 'title', $gWtcG = '_child') { goto vfbtg; E_ku1: return $this; goto D2WMW; vfbtg: $this->mode(self::MODE_GROUP_TAGS); goto AeTXK; AeTXK: $this->addVariables(array('groupTags' => $ed1Ls, 'groupTagsTitleKey' => $P9Sjb, 'groupTagsChildKey' => $gWtcG)); goto E_ku1; D2WMW: } public function renderView(AbstractField $pu1ro, $V563N, $aDVv6 = 0) { goto aBgV6; MAKaZ: if ($V563N) { goto n3UtI; ZNH0Y: $bP0d3 = ModelUtil::values($ykRSg, $iYBOY, array($Vu4fQ => $V563N->id)); goto nYn3z; cCeT_: $iYBOY = $pu1ro->getVariable('relationIdKey'); goto ZNH0Y; n3UtI: $ykRSg = $pu1ro->getVariable('relationTable'); goto U3PPo; U3PPo: $Vu4fQ = $pu1ro->getVariable('relationModelIdKey'); goto cCeT_; nYn3z: } goto qZD8g; aBgV6: $bP0d3 = array(); goto MAKaZ; qZD8g: $this->value($bP0d3); goto KeAlW; KeAlW: return parent::renderView($pu1ro, $V563N, $aDVv6); goto iudxZ; iudxZ: } 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); } }