<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Field; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Util\ConvertUtil; use ModStart\Core\Util\TagUtil; use ModStart\Field\Type\FieldRenderMode; class Tags extends AbstractField { const SERIALIZE_TYPE_DEFAULT = null; const SERIALIZE_TYPE_COLON_SEPARATED = 1; protected $value = array(); protected function setup() { $this->addVariables(array('tags' => array(), 'serializeType' => null)); } public function tags($tzAUI) { $this->addVariables(array('tags' => $tzAUI)); return $this; } public function serializeType($tzAUI) { $this->addVariables(array('serializeType' => $tzAUI)); return $this; } public function tagType($BTuN4) { return self::tags($BTuN4::getList()); } public function tagModel($I1hTb, $kkQsP = 'id', $Zmb65 = 'title') { return $this->tags(ModelUtil::valueMap($I1hTb, $kkQsP, $Zmb65)); } public function tagModelField($I1hTb, $vBHXo = 'tag', $dMFDj = null) { goto uY_Mb; jS253: $YTFCB = array(); goto FJJNd; FJJNd: foreach ($X2SsU as $tzAUI) { goto n2jg6; ld1v6: switch ($dMFDj) { case self::SERIALIZE_TYPE_COLON_SEPARATED: $rgHNr = TagUtil::string2Array($tzAUI); break; default: $rgHNr = ConvertUtil::toArray($tzAUI); break; } goto nRgH9; n2jg6: $rgHNr = null; goto ld1v6; nRgH9: if (empty($rgHNr)) { continue; } goto aIZ99; aIZ99: foreach ($rgHNr as $ohYVl) { $YTFCB[$ohYVl] = $ohYVl; } goto gCF9U; gCF9U: } goto auZ9m; auZ9m: return $this->tags($YTFCB); goto Fydb1; uY_Mb: $X2SsU = ModelUtil::values($I1hTb, $vBHXo); goto jS253; Fydb1: } public function unserializeValue($tzAUI, AbstractField $Q2vn5) { switch ($this->getVariable('serializeType')) { case self::SERIALIZE_TYPE_COLON_SEPARATED: return TagUtil::string2Array($tzAUI); default: return ConvertUtil::toArray($tzAUI); } } public function serializeValue($tzAUI, $pWRTh) { switch ($this->getVariable('serializeType')) { case self::SERIALIZE_TYPE_COLON_SEPARATED: return TagUtil::array2String($tzAUI); default: return json_encode($tzAUI); } } public function prepareInput($tzAUI, $pWRTh) { switch ($this->getVariable('serializeType')) { case self::SERIALIZE_TYPE_COLON_SEPARATED: return TagUtil::string2Array($tzAUI); default: return ConvertUtil::toArray($tzAUI); } } }