<?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 ($oMuOc, AbstractField $acdQI) { $kFc4w = InputPackage::buildFromInput(); $q2nIJ = $kFc4w->getJson($acdQI->column, array()); ModelUtil::relationAssign($this->getVariable('relationTable'), $this->getVariable('relationModelIdKey'), $oMuOc, $this->getVariable('relationIdKey'), $q2nIJ); }); } public function mode($bJtEU) { $this->addVariables(array('mode' => $bJtEU)); return $this; } public function relationTable($wt8xl, $NBLev, $L4Dbl) { goto ubo8j; p5mAm: return $this; goto nuTLI; AmG6c: $this->addVariables(array('relationIdKey' => $L4Dbl)); goto p5mAm; ubo8j: $this->addVariables(array('relationTable' => $wt8xl)); goto G40T0; G40T0: $this->addVariables(array('relationModelIdKey' => $NBLev)); goto AmG6c; nuTLI: } public function groupTags($BwMie, $M3Flv = 'title', $OIoBn = '_child') { goto UidA8; MIl7e: $this->addVariables(array('groupTags' => $BwMie, 'groupTagsTitleKey' => $M3Flv, 'groupTagsChildKey' => $OIoBn)); goto LckCd; UidA8: $this->mode(self::MODE_GROUP_TAGS); goto MIl7e; LckCd: return $this; goto S733Z; S733Z: } public function renderView(AbstractField $acdQI, $Xvngd, $K_IJ6 = 0) { goto Ml0Kv; AYWBF: if ($Xvngd) { goto D8SL_; D8SL_: $qYnLb = $acdQI->getVariable('relationTable'); goto HsEAQ; HsEAQ: $rTnOQ = $acdQI->getVariable('relationModelIdKey'); goto JCrTz; JCrTz: $L4Dbl = $acdQI->getVariable('relationIdKey'); goto GPj0B; GPj0B: $q2nIJ = ModelUtil::values($qYnLb, $L4Dbl, array($rTnOQ => $Xvngd->id)); goto zOx8Q; zOx8Q: } goto tZxID; Ml0Kv: $q2nIJ = array(); goto AYWBF; BU9Fq: return parent::renderView($acdQI, $Xvngd, $K_IJ6); goto W68TF; tZxID: $this->value($q2nIJ); goto BU9Fq; W68TF: } 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); } }