<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Field; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Input\InputPackage; use ModStart\Core\Util\ConvertUtil; use ModStart\Core\Util\SerializeUtil; 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 ($y_XTM, AbstractField $E8QRJ) { $sYsuI = InputPackage::buildFromInput(); $c6Fiz = $sYsuI->getJson($E8QRJ->column, array()); ModelUtil::relationAssign($this->getVariable('relationTable'), $this->getVariable('relationModelIdKey'), $y_XTM, $this->getVariable('relationIdKey'), $c6Fiz); }); } public function mode($TaJ4B) { $this->addVariables(array('mode' => $TaJ4B)); return $this; } public function relationTable($wyCKK, $kEetP, $vT06r) { goto MMS0j; bMkuT: return $this; goto o9Bbg; mZivg: $this->addVariables(array('relationIdKey' => $vT06r)); goto bMkuT; SUWGO: $this->addVariables(array('relationModelIdKey' => $kEetP)); goto mZivg; MMS0j: $this->addVariables(array('relationTable' => $wyCKK)); goto SUWGO; o9Bbg: } public function groupTags($u5dP6, $inNl8 = 'title', $ER320 = '_child') { goto nsOQx; Q7SEH: return $this; goto qJHge; RNMLj: $this->addVariables(array('groupTags' => $u5dP6, 'groupTagsTitleKey' => $inNl8, 'groupTagsChildKey' => $ER320)); goto Q7SEH; nsOQx: $this->mode(self::MODE_GROUP_TAGS); goto RNMLj; qJHge: } public function renderView(AbstractField $E8QRJ, $OV1o4, $xlsSz = 0) { goto PmbDN; smkYQ: if ($OV1o4) { goto L00us; L00us: $B8eAf = $E8QRJ->getVariable('relationTable'); goto pJuRD; pJuRD: $neUxN = $E8QRJ->getVariable('relationModelIdKey'); goto m1zGo; cJot0: $c6Fiz = ModelUtil::values($B8eAf, $vT06r, array($neUxN => $OV1o4->id)); goto mMz1V; m1zGo: $vT06r = $E8QRJ->getVariable('relationIdKey'); goto cJot0; mMz1V: } goto GatLo; GatLo: $this->value($c6Fiz); goto QeKYs; PmbDN: $c6Fiz = array(); goto smkYQ; QeKYs: return parent::renderView($E8QRJ, $OV1o4, $xlsSz); goto s6SR1; s6SR1: } 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); } }