<?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 ($dsc00, AbstractField $VWt5t) { $Zxpx_ = InputPackage::buildFromInput(); $i5Ynu = $Zxpx_->getJson($VWt5t->column, array()); ModelUtil::relationAssign($this->getVariable('relationTable'), $this->getVariable('relationModelIdKey'), $dsc00, $this->getVariable('relationIdKey'), $i5Ynu); }); } public function mode($ybhyk) { $this->addVariables(array('mode' => $ybhyk)); return $this; } public function relationTable($Beeb4, $KJ1Pb, $qPbXR) { goto H6F_h; Rw9T7: return $this; goto Q43Pi; H6F_h: $this->addVariables(array('relationTable' => $Beeb4)); goto C1vxp; C1vxp: $this->addVariables(array('relationModelIdKey' => $KJ1Pb)); goto yaOxp; yaOxp: $this->addVariables(array('relationIdKey' => $qPbXR)); goto Rw9T7; Q43Pi: } public function groupTags($TG8rD, $v2yGX = 'title', $sgIsl = '_child') { goto HVQha; usG9A: return $this; goto nuo9X; QPuzN: $this->addVariables(array('groupTags' => $TG8rD, 'groupTagsTitleKey' => $v2yGX, 'groupTagsChildKey' => $sgIsl)); goto usG9A; HVQha: $this->mode(self::MODE_GROUP_TAGS); goto QPuzN; nuo9X: } public function renderView(AbstractField $VWt5t, $nsWl0, $R80S9 = 0) { goto O8dWv; O8dWv: $i5Ynu = array(); goto DTIit; YP65k: return parent::renderView($VWt5t, $nsWl0, $R80S9); goto RnbMo; jT9KT: $this->value($i5Ynu); goto YP65k; DTIit: if ($nsWl0) { goto tNCWw; j71YH: $Q1UI3 = $VWt5t->getVariable('relationModelIdKey'); goto EPn3W; EPn3W: $qPbXR = $VWt5t->getVariable('relationIdKey'); goto NJc2G; tNCWw: $I9ROm = $VWt5t->getVariable('relationTable'); goto j71YH; NJc2G: $i5Ynu = ModelUtil::values($I9ROm, $qPbXR, array($Q1UI3 => $nsWl0->id)); goto reKPx; reKPx: } goto jT9KT; RnbMo: } public function unserializeValue($gwXrh, AbstractField $VWt5t) { if (null === $gwXrh) { return $gwXrh; } return ConvertUtil::toArray($gwXrh); } public function serializeValue($gwXrh, $uV19D) { return json_encode($gwXrh); } public function prepareInput($gwXrh, $uV19D) { return ConvertUtil::toArray($gwXrh); } }